diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..7fd10bbe --- /dev/null +++ b/Gemfile @@ -0,0 +1,38 @@ +source :gemcutter +source :rubyforge +source "http://gems.github.com/" + +gem "rake", "~>0.8.7" +gem "rails", "~>2.3.12" +gem "highline", "~>1.5.0" +gem "RedCloth", "4.2.3" +gem "soap4r" +gem "sanitize", "~>1.2.1" +gem "rack", "1.1.0" +gem "will_paginate", "~> 2.3.15" +gem "has_many_polymorphs", "~> 2.13" +gem "aasm", "2.2.0" +gem "actionwebservice", :git => "git://github.com/dejan/actionwebservice.git" +gem "rubycas-client" +gem "ruby-openid", :require => "openid" +gem "sqlite3" + + +gem "webrat", ">=0.7.0", :groups => [:cucumber, :test] +gem "database_cleaner", ">=0.5.0", :groups => [:cucumber, :selenium] +gem "cucumber-rails", "~>0.3.0", :groups => :cucumber + +group :test do + gem "flexmock" + gem "ZenTest", ">=4.0.0" + gem "hpricot" + gem "hoe" + gem "rspec-rails", "~>1.3.3" + gem "thoughtbot-factory_girl" +end + +group :selenium do + gem "selenium-client" + gem "mongrel" +end + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..5dfd12ba --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,119 @@ +GIT + remote: git://github.com/dejan/actionwebservice.git + revision: f0d48a4f747a998cc431615d69a0bdf089b18be3 + specs: + actionwebservice (2.3.2.1705) + actionpack (>= 2.3.2) + activerecord (>= 2.3.2) + +GEM + remote: http://rubygems.org/ + remote: http://rubygems.org/ + remote: http://gems.github.com/ + specs: + RedCloth (4.2.3) + ZenTest (4.6.1) + aasm (2.2.0) + actionmailer (2.3.14) + actionpack (= 2.3.14) + actionpack (2.3.14) + activesupport (= 2.3.14) + rack (~> 1.1.0) + activerecord (2.3.14) + activesupport (= 2.3.14) + activeresource (2.3.14) + activesupport (= 2.3.14) + activesupport (2.3.14) + builder (3.0.0) + cgi_multipart_eof_fix (2.5.0) + cucumber (1.0.2) + builder (>= 2.1.2) + diff-lcs (>= 1.1.2) + gherkin (~> 2.4.5) + json (>= 1.4.6) + term-ansicolor (>= 1.0.5) + cucumber-rails (0.3.2) + cucumber (>= 0.8.0) + daemons (1.1.4) + database_cleaner (0.6.7) + diff-lcs (1.1.2) + fastthread (1.0.7) + flexmock (0.9.0) + gem_plugin (0.2.3) + gherkin (2.4.11) + json (>= 1.4.6) + has_many_polymorphs (2.13) + activerecord + highline (1.5.2) + hoe (2.12.0) + rake (~> 0.8) + hpricot (0.8.4) + httpclient (2.2.1) + json (1.5.3) + mongrel (1.1.5) + cgi_multipart_eof_fix (>= 2.4) + daemons (>= 1.0.3) + fastthread (>= 1.0.1) + gem_plugin (>= 0.2.3) + nokogiri (1.4.7) + rack (1.1.0) + rack-test (0.6.1) + rack (>= 1.0) + rails (2.3.14) + actionmailer (= 2.3.14) + actionpack (= 2.3.14) + activerecord (= 2.3.14) + activeresource (= 2.3.14) + activesupport (= 2.3.14) + rake (>= 0.8.3) + rake (0.8.7) + rspec (1.3.2) + rspec-rails (1.3.4) + rack (>= 1.0.0) + rspec (~> 1.3.1) + ruby-openid (2.1.8) + rubycas-client (2.2.1) + activesupport + sanitize (1.2.1) + nokogiri (~> 1.4.1) + selenium-client (1.2.18) + soap4r (1.5.8) + httpclient (>= 2.1.1) + sqlite3 (1.3.4) + term-ansicolor (1.0.6) + thoughtbot-factory_girl (1.2.2) + webrat (0.7.3) + nokogiri (>= 1.2.0) + rack (>= 1.0) + rack-test (>= 0.5.3) + will_paginate (2.3.16) + +PLATFORMS + ruby + +DEPENDENCIES + RedCloth (= 4.2.3) + ZenTest (>= 4.0.0) + aasm (= 2.2.0) + actionwebservice! + cucumber-rails (~> 0.3.0) + database_cleaner (>= 0.5.0) + flexmock + has_many_polymorphs (~> 2.13) + highline (~> 1.5.0) + hoe + hpricot + mongrel + rack (= 1.1.0) + rails (~> 2.3.12) + rake (~> 0.8.7) + rspec-rails (~> 1.3.3) + ruby-openid + rubycas-client + sanitize (~> 1.2.1) + selenium-client + soap4r + sqlite3 + thoughtbot-factory_girl + webrat (>= 0.7.0) + will_paginate (~> 2.3.15) diff --git a/Rakefile b/Rakefile index 52e1413e..2704572a 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' -require 'rdoc/task' +require 'rake/rdoctask' require 'tasks/rails' diff --git a/config/boot.rb b/config/boot.rb index 6686664c..57528ecc 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -110,5 +110,19 @@ module Rails end end +class Rails::Boot + def run + load_initializer + + Rails::Initializer.class_eval do + def load_gems + @bundler_loaded ||= Bundler.require :default, Rails.env + end + end + + Rails::Initializer.run(:set_load_path) + end +end + # All that for this: Rails.boot! diff --git a/config/environment.rb b/config/environment.rb index 3be292b1..401bb669 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -24,7 +24,7 @@ Rails::Initializer.run do |config| config.gem "highline" config.gem "RedCloth", :lib => 'redcloth', :version => '4.2.3' config.gem "soap4r", :lib => false - config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice', :source => "http://gems.github.com" + config.gem 'actionwebservice' config.gem 'sanitize', :version => '~> 1.2.1' config.gem 'rack', :version => '1.1.0' config.gem 'will_paginate', :version => '~> 2.3.15' diff --git a/config/preinitializer.rb b/config/preinitializer.rb new file mode 100644 index 00000000..a6b4d1e6 --- /dev/null +++ b/config/preinitializer.rb @@ -0,0 +1,21 @@ +begin + require "rubygems" + require "bundler" +rescue LoadError + raise "Could not load the bundler gem. Install it with `gem install bundler`." +end + +if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") + raise RuntimeError, "Your bundler version is too old for Rails 2.3." + + "Run `gem install bundler` to upgrade." +end + +begin + # Set up load paths for all bundled gems + ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__) + Bundler.setup +rescue Bundler::GemNotFound + raise RuntimeError, "Bundler couldn't find some gems." + + "Did you run `bundle install`?" +end + diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/.specification b/vendor/gems/datanoise-actionwebservice-2.3.2/.specification deleted file mode 100644 index ce200267..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/.specification +++ /dev/null @@ -1,96 +0,0 @@ ---- !ruby/object:Gem::Specification -name: datanoise-actionwebservice -version: !ruby/object:Gem::Version - hash: 7 - prerelease: - segments: - - 2 - - 3 - - 2 - version: 2.3.2 -platform: ruby -authors: -- Leon Breedt, Kent Sibilev -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-03-29 00:00:00 Z -dependencies: -- !ruby/object:Gem::Dependency - name: actionpack - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - none: false - requirements: - - - "=" - - !ruby/object:Gem::Version - hash: 7 - segments: - - 2 - - 3 - - 12 - version: 2.3.12 - type: :runtime - version_requirements: *id001 -- !ruby/object:Gem::Dependency - name: activerecord - prerelease: false - requirement: &id002 !ruby/object:Gem::Requirement - none: false - requirements: - - - "=" - - !ruby/object:Gem::Version - hash: 7 - segments: - - 2 - - 3 - - 12 - version: 2.3.12 - type: :runtime - version_requirements: *id002 -description: Adds WSDL/SOAP and XML-RPC web service support to Action Pack -email: bitserf@gmail.com, ksibilev@yahoo.com -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: [] - -homepage: http://www.rubyonrails.org -licenses: [] - -post_install_message: -rdoc_options: [] - -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" -required_rubygems_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" -requirements: -- none -rubyforge_project: aws -rubygems_version: 1.7.2 -signing_key: -specification_version: 2 -summary: Web service support for Action Pack. -test_files: [] - diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/CHANGELOG b/vendor/gems/datanoise-actionwebservice-2.3.2/CHANGELOG deleted file mode 100644 index 4fccf992..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/CHANGELOG +++ /dev/null @@ -1,320 +0,0 @@ -*2.1.0* - -* Porting to Rails 2.1.0 [Kent Sibilev] - -* Documentation for ActionWebService::API::Base. Closes #7275. [zackchandler] - -* Allow action_web_service to handle various HTTP methods including GET. Closes #7011. [zackchandler] - -* Ensure that DispatcherError is being thrown when a malformed request is received. [Kent Sibilev] - -* Added support for decimal types. Closes #6676. [Kent Sibilev] - -* Removed deprecated end_form_tag helper. [Kent Sibilev] - -* Removed deprecated @request and @response usages. [Kent Sibilev] - -* Removed deprecated end_form_tag helper. [Kent Sibilev] - -* Removed deprecated @request and @response usages. [Kent Sibilev] - -*1.2.6* (November 24th, 2007) - -* Depend on Action Pack 1.13.6 - -* Depend on Active Record 1.15.6 - - -*1.2.5* (October 12th, 2007) - -* Depend on Action Pack 1.13.5 - -* Depend on Active Record 1.15.5 - - -*1.2.4* (October 4th, 2007) - -* Depend on Action Pack 1.13.4 - -* Depend on Active Record 1.15.4 - - -*1.2.3* (March 12th, 2007) - -* Depend on Action Pack 1.13.3 - - -*1.2.2* (Feburary 4th, 2007) - -* Depend on Action Pack 1.13.2 - - -*1.2.1* (January 16th, 2007) - -* Depend on Action Pack 1.13.1 - - -*1.2.0* (January 16th, 2007) - -* Removed invocation of deprecated before_action and around_action filter methods. Corresponding before_invocation and after_invocation methods should be used instead. #6275 [Kent Sibilev] - -* Provide access to the underlying SOAP driver. #6212 [bmilekic, Kent Sibilev] - -* ActionWebService WSDL generation ignores HTTP_X_FORWARDED_HOST [Paul Butcher ] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Fixed XMLRPC multicall when one of the called methods returns a struct object. [Kent Sibilev] - -* Fix invoke_layered since api_method didn't declare :expects. Closes #4720. [Kevin Ballard , Kent Sibilev] - - -*1.1.6* (August 10th, 2006) - -* Rely on Action Pack 1.12.5 - - -*1.1.5* (August 8th, 2006) - -* Rely on Action Pack 1.12.4 and Active Record 1.14.4 - - -*1.1.4* (June 29th, 2006) - -* Rely on Action Pack 1.12.3 - - -*1.1.3* (June 27th, 2006) - -* Rely on Action Pack 1.12.2 and Active Record 1.14.3 - - -*1.1.2* (April 9th, 2006) - -* Rely on Active Record 1.14.2 - - -*1.1.1* (April 6th, 2006) - -* Do not convert driver options to strings (#4499) - - -*1.1.0* (March 27th, 2006) - -* Make ActiveWebService::Struct type reloadable - -* Fix scaffolding action when one of the members of a structural type has date or time type - -* Remove extra index hash when generating scaffold html for parameters of structural type #4374 [joe@mjg2.com] - -* Fix Scaffold Fails with Struct as a Parameter #4363 [joe@mjg2.com] - -* Fix soap type registration of multidimensional arrays (#4232) - -* Fix that marshaler couldn't handle ActiveRecord models defined in a different namespace (#2392). - -* Fix that marshaler couldn't handle structs with members of ActiveRecord type (#1889). - -* Fix that marshaler couldn't handle nil values for inner structs (#3576). - -* Fix that changes to ActiveWebService::API::Base required restarting of the server (#2390). - -* Fix scaffolding for signatures with :date, :time and :base64 types (#3321, #2769, #2078). - -* Fix for incorrect casting of TrueClass/FalseClass instances (#2633, #3421). - -* Fix for incompatibility problems with SOAP4R 1.5.5 (#2553) [Kent Sibilev] - - -*1.0.0* (December 13th, 2005) - -* Become part of Rails 1.0 - -*0.9.4* (December 7th, 2005) - -* Update from LGPL to MIT license as per Minero Aoki's permission. [Marcel Molina Jr.] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Fix that XML-RPC date/time values did not have well-defined behaviour (#2516, #2534). This fix has one caveat, in that we can't support pre-1970 dates from XML-RPC clients. - -*0.9.3* (November 7th, 2005) - -* Upgraded to Action Pack 1.11.0 and Active Record 1.13.0 - - -*0.9.2* (October 26th, 2005) - -* Upgraded to Action Pack 1.10.2 and Active Record 1.12.2 - - -*0.9.1* (October 19th, 2005) - -* Upgraded to Action Pack 1.10.1 and Active Record 1.12.1 - - -*0.9.0* (October 16th, 2005) - -* Fix invalid XML request generation bug in test_invoke [Ken Barker] - -* Add XML-RPC 'system.multicall' support #1941 [jbonnar] - -* Fix duplicate XSD entries for custom types shared across delegated/layered services #1729 [Tyler Kovacs] - -* Allow multiple invocations in the same test method #1720 [dkhawk] - -* Added ActionWebService::API::Base.soap_client and ActionWebService::API::Base.xmlrpc_client helper methods to create the internal clients for an API, useful for testing from ./script/console - -* ActionWebService now always returns UTF-8 responses. - - -*0.8.1* (11 July, 2005) - -* Fix scaffolding for Action Pack controller changes - - -*0.8.0* (6 July, 2005) - -* Fix WSDL generation by aliasing #inherited instead of trying to overwrite it, or the WSDL action may end up not being defined in the controller - -* Add ActionController::Base.wsdl_namespace option, to allow overriding of the namespace used in generated WSDL and SOAP messages. This is equivalent to the [WebService(Namespace = "Value")] attribute in .NET. - -* Add workaround for Ruby 1.8.3's SOAP4R changing the return value of SOAP::Mapping::Registry#find_mapped_soap_class #1414 [Shugo Maeda] - -* Fix moduled controller URLs in WSDL, and add unit test to verify the generated URL #1428 - -* Fix scaffolding template paths, it was broken on Win32 - -* Fix that functional testing of :layered controllers failed when using the SOAP protocol - -* Allow invocation filters in :direct controllers as well, as they have access to more information regarding the web service request than ActionPack filters - -* Add support for a :base64 signature type #1272 [Shugo Maeda] - -* Fix that boolean fields were not rendered correctly in scaffolding - -* Fix that scaffolding was not working for :delegated dispatching - -* Add support for structured types as input parameters to scaffolding, this should let one test the blogging APIs using scaffolding as well - -* Fix that generated WSDL was not using relative_url_root for base URI #1210 [Shugo Maeda] - -* Use UTF-8 encoding by default for SOAP responses, but if an encoding is supplied by caller, use that for the response #1211 [Shugo Maeda, NAKAMURA Hiroshi] - -* If the WSDL was retrieved over HTTPS, use HTTPS URLs in the WSDL too - -* Fix that casting change in 0.7.0 would convert nil values to the default value for the type instead of leaving it as nil - - -*0.7.1* (20th April, 2005) - -* Depend on Active Record 1.10.1 and Action Pack 1.8.1 - - -*0.7.0* (19th April, 2005) - -* When casting structured types, don't try to send obj.name= unless obj responds to it, causes casting to be less likely to fail for XML-RPC - -* Add scaffolding via ActionController::Base.web_service_scaffold for quick testing using a web browser - -* ActionWebService::API::Base#api_methods now returns a hash containing ActionWebService::API::Method objects instead of hashes. However, ActionWebService::API::Method defines a #[]() backwards compatibility method so any existing code utilizing this will still work. - -* The :layered dispatching mode can now be used with SOAP as well, allowing you to support SOAP and XML-RPC clients for APIs like the metaWeblog API - -* Remove ActiveRecordSoapMarshallable workaround, see #912 for details - -* Generalize casting code to be used by both SOAP and XML-RPC (previously, it was only XML-RPC) - -* Ensure return value is properly cast as well, fixes XML-RPC interoperability with Ecto and possibly other clients - -* Include backtraces in 500 error responses for failed request parsing, and remove "rescue nil" statements obscuring real errors for XML-RPC - -* Perform casting of struct members even if the structure is already of the correct type, so that the type we specify for the struct member is always the type of the value seen by the API implementation - - -*0.6.2* (27th March, 2005) - -* Allow method declarations for direct dispatching to declare parameters as well. We treat an arity of < 0 or > 0 as an indication that we should send through parameters. Closes #939. - - -*0.6.1* (22th March, 2005) - -* Fix that method response QNames mismatched with that declared in the WSDL, makes SOAP::WSDLDriverFactory work against AWS again - -* Fix that @request.env was being modified, instead, dup the value gotten from env - -* Fix XML-RPC example to use :layered mode, so it works again - -* Support casting '0' or 0 into false, and '1' or 1 into true, when expecting a boolean value - -* Fix that SOAP fault response fault code values were not QName's #804 - - -*0.6.0* (7th March, 2005) - -* Add action_controller/test_invoke, used for integrating AWS with the Rails testing infrastructure - -* Allow passing through options to the SOAP RPC driver for the SOAP client - -* Make the SOAP WS marshaler use #columns to decide which fields to marshal as well, avoids providing attributes brought in by associations - -* Add ActionWebService::API::Base.allow_active_record_expects option, with a default of false. Setting this to true will allow specifying ActiveRecord::Base model classes in :expects. API writers should take care to validate the received ActiveRecord model objects when turning it on, and/or have an authentication mechanism in place to reduce the security risk. - -* Improve error message reporting. Bugs in either AWS or the web service itself will send back a protocol-specific error report message if possible, otherwise, provide as much detail as possible. - -* Removed type checking of received parameters, and perform casting for XML-RPC if possible, but fallback to the received parameters if casting fails, closes #677 - -* Refactored SOAP and XML-RPC marshaling and encoding into a small library devoted exclusively to protocol specifics, also cleaned up the SOAP marshaling approach, so that array and custom type marshaling should be a bit faster. - -* Add namespaced XML-RPC method name support, closes #678 - -* Replace '::' with '..' in fully qualified type names for marshaling and WSDL. This improves interoperability with .NET, and closes #676. - - -*0.5.0* (24th February, 2005) - - * lib/action_service/dispatcher*: replace "router" fragments with - one file for Action Controllers, moves dispatching work out of - the container - * lib/*,test/*,examples/*: rename project to - ActionWebService. prefix all generic "service" type names with web_. - update all using code as well as the RDoc. - * lib/action_service/router/wsdl.rb: ensure that #wsdl is - defined in the final container class, or the new ActionPack - filtering will exclude it - * lib/action_service/struct.rb,test/struct_test.rb: create a - default #initialize on inherit that accepts a Hash containing - the default member values - * lib/action_service/api/action_controller.rb: add support and - tests for #client_api in controller - * test/router_wsdl_test.rb: add tests to ensure declared - service names don't contain ':', as ':' causes interoperability - issues - * lib/*, test/*: rename "interface" concept to "api", and change all - related uses to reflect this change. update all uses of Inflector - to call the method on String instead. - * test/api_test.rb: add test to ensure API definition not - instantiatable - * lib/action_service/invocation.rb: change @invocation_params to - @method_params - * lib/*: update RDoc - * lib/action_service/struct.rb: update to support base types - * lib/action_service/support/signature.rb: support the notion of - "base types" in signatures, with well-known unambiguous names such as :int, - :bool, etc, which map to the correct Ruby class. accept the same names - used by ActiveRecord as well as longer versions of each, as aliases. - * examples/*: update for seperate API definition updates - * lib/action_service/*, test/*: extensive refactoring: define API methods in - a seperate class, and specify it wherever used with 'service_api'. - this makes writing a client API for accessing defined API methods - with ActionWebService really easy. - * lib/action_service/container.rb: fix a bug in default call - handling for direct dispatching, and add ActionController filter - support for direct dispatching. - * test/router_action_controller_test.rb: add tests to ensure - ActionController filters are actually called. - * test/protocol_soap_test.rb: add more tests for direct dispatching. - -0.3.0 - - * First public release diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/MIT-LICENSE b/vendor/gems/datanoise-actionwebservice-2.3.2/MIT-LICENSE deleted file mode 100644 index 528941e8..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/MIT-LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (C) 2005 Leon Breedt - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/README b/vendor/gems/datanoise-actionwebservice-2.3.2/README deleted file mode 100644 index 178baa7c..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/README +++ /dev/null @@ -1,381 +0,0 @@ -= Action Web Service -- Serving APIs on rails - -Action Web Service provides a way to publish interoperable web service APIs with -Rails without spending a lot of time delving into protocol details. - - -== Features - -* SOAP RPC protocol support -* Dynamic WSDL generation for APIs -* XML-RPC protocol support -* Clients that use the same API definitions as the server for - easy interoperability with other Action Web Service based applications -* Type signature hints to improve interoperability with static languages -* Active Record model class support in signatures - - -== Defining your APIs - -You specify the methods you want to make available as API methods in an -ActionWebService::API::Base derivative, and then specify this API -definition class wherever you want to use that API. - -The implementation of the methods is done separately from the API -specification. - - -==== Method name inflection - -Action Web Service will camelcase the method names according to Rails Inflector -rules for the API visible to public callers. What this means, for example, -is that the method names in generated WSDL will be camelcased, and callers will -have to supply the camelcased name in their requests for the request to -succeed. - -If you do not desire this behaviour, you can turn it off with the -ActionWebService::API::Base +inflect_names+ option. - - -==== Inflection examples - - :add => Add - :find_all => FindAll - - -==== Disabling inflection - - class PersonAPI < ActionWebService::API::Base - inflect_names false - end - - -==== API definition example - - class PersonAPI < ActionWebService::API::Base - api_method :add, :expects => [:string, :string, :bool], :returns => [:int] - api_method :remove, :expects => [:int], :returns => [:bool] - end - -==== API usage example - - class PersonController < ActionController::Base - web_service_api PersonAPI - - def add - end - - def remove - end - end - - -== Publishing your APIs - -Action Web Service uses Action Pack to process protocol requests. There are two -modes of dispatching protocol requests, _Direct_, and _Delegated_. - - -=== Direct dispatching - -This is the default mode. In this mode, public controller instance methods -implement the API methods, and parameters are passed through to the methods in -accordance with the API specification. - -The return value of the method is sent back as the return value to the -caller. - -In this mode, a special api action is generated in the target -controller to unwrap the protocol request, forward it on to the relevant method -and send back the wrapped return value. This action must not be -overridden. - -==== Direct dispatching example - - class PersonController < ApplicationController - web_service_api PersonAPI - - def add - end - - def remove - end - end - - class PersonAPI < ActionWebService::API::Base - ... - end - - -For this example, protocol requests for +Add+ and +Remove+ methods sent to -/person/api will be routed to the controller methods +add+ and +remove+. - - -=== Delegated dispatching - -This mode can be turned on by setting the +web_service_dispatching_mode+ option -in a controller to :delegated. - -In this mode, the controller contains one or more web service objects (objects -that implement an ActionWebService::API::Base definition). These web service -objects are each mapped onto one controller action only. - -==== Delegated dispatching example - - class ApiController < ApplicationController - web_service_dispatching_mode :delegated - - web_service :person, PersonService.new - end - - class PersonService < ActionWebService::Base - web_service_api PersonAPI - - def add - end - - def remove - end - end - - class PersonAPI < ActionWebService::API::Base - ... - end - - -For this example, all protocol requests for +PersonService+ are -sent to the /api/person action. - -The /api/person action is generated when the +web_service+ -method is called. This action must not be overridden. - -Other controller actions (actions that aren't the target of a +web_service+ call) -are ignored for ActionWebService purposes, and can do normal action tasks. - - -=== Layered dispatching - -This mode can be turned on by setting the +web_service_dispatching_mode+ option -in a controller to :layered. - -This mode is similar to _delegated_ mode, in that multiple web service objects -can be attached to one controller, however, all protocol requests are sent to a -single endpoint. - -Use this mode when you want to share code between XML-RPC and SOAP clients, -for APIs where the XML-RPC method names have prefixes. An example of such -a method name would be blogger.newPost. - - -==== Layered dispatching example - - - class ApiController < ApplicationController - web_service_dispatching_mode :layered - - web_service :mt, MovableTypeService.new - web_service :blogger, BloggerService.new - web_service :metaWeblog, MetaWeblogService.new - end - - class MovableTypeService < ActionWebService::Base - ... - end - - class BloggerService < ActionWebService::Base - ... - end - - class MetaWeblogService < ActionWebService::API::Base - ... - end - - -For this example, an XML-RPC call for a method with a name like -mt.getCategories will be sent to the getCategories -method on the :mt service. - - -== Customizing WSDL generation - -You can customize the names used for the SOAP bindings in the generated -WSDL by using the wsdl_service_name option in a controller: - - class WsController < ApplicationController - wsdl_service_name 'MyApp' - end - -You can also customize the namespace used in the generated WSDL for -custom types and message definition types: - - class WsController < ApplicationController - wsdl_namespace 'http://my.company.com/app/wsapi' - end - -The default namespace used is 'urn:ActionWebService', if you don't supply -one. - - -== ActionWebService and UTF-8 - -If you're going to be sending back strings containing non-ASCII UTF-8 -characters using the :string data type, you need to make sure that -Ruby is using UTF-8 as the default encoding for its strings. - -The default in Ruby is to use US-ASCII encoding for strings, which causes a string -validation check in the Ruby SOAP library to fail and your string to be sent -back as a Base-64 value, which may confuse clients that expected strings -because of the WSDL. - -Two ways of setting the default string encoding are: - -* Start Ruby using the -Ku command-line option to the Ruby executable -* Set the $KCODE flag in config/environment.rb to the - string 'UTF8' - - -== Testing your APIs - - -=== Functional testing - -You can perform testing of your APIs by creating a functional test for the -controller dispatching the API, and calling #invoke in the test case to -perform the invocation. - -Example: - - class PersonApiControllerTest < Test::Unit::TestCase - def setup - @controller = PersonController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_add - result = invoke :remove, 1 - assert_equal true, result - end - end - -This example invokes the API method test, defined on -the PersonController, and returns the result. - -If you're not using SOAP (or you're having serialisation difficulties), -you can test XMLRPC like this: - - class PersonApiControllerTest < Test::Unit::TestCase - def setup - @controller = PersonController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @protocol = :xmlrpc # can also be :soap, the default - end - - def test_add - result = invoke :remove, 1 # no change here - assert_equal true, result - end - end - -=== Scaffolding - -You can also test your APIs with a web browser by attaching scaffolding -to the controller. - -Example: - - class PersonController - web_service_scaffold :invocation - end - -This creates an action named invocation on the PersonController. - -Navigating to this action lets you select the method to invoke, supply the parameters, -and view the result of the invocation. - - -== Using the client support - -Action Web Service includes client classes that can use the same API -definition as the server. The advantage of this approach is that your client -will have the same support for Active Record and structured types as the -server, and can just use them directly, and rely on the marshaling to Do The -Right Thing. - -*Note*: The client support is intended for communication between Ruby on Rails -applications that both use Action Web Service. It may work with other servers, but -that is not its intended use, and interoperability can't be guaranteed, especially -not for .NET web services. - -Web services protocol specifications are complex, and Action Web Service client -support can only be guaranteed to work with a subset. - - -==== Factory created client example - - class BlogManagerController < ApplicationController - web_client_api :blogger, :xmlrpc, 'http://url/to/blog/api/RPC2', :handler_name => 'blogger' - end - - class SearchingController < ApplicationController - web_client_api :google, :soap, 'http://url/to/blog/api/beta', :service_name => 'GoogleSearch' - end - -See ActionWebService::API::ActionController::ClassMethods for more details. - -==== Manually created client example - - class PersonAPI < ActionWebService::API::Base - api_method :find_all, :returns => [[Person]] - end - - soap_client = ActionWebService::Client::Soap.new(PersonAPI, "http://...") - persons = soap_client.find_all - - class BloggerAPI < ActionWebService::API::Base - inflect_names false - api_method :getRecentPosts, :returns => [[Blog::Post]] - end - - blog = ActionWebService::Client::XmlRpc.new(BloggerAPI, "http://.../xmlrpc", :handler_name => "blogger") - posts = blog.getRecentPosts - - -See ActionWebService::Client::Soap and ActionWebService::Client::XmlRpc for more details. - -== Dependencies - -Action Web Service requires that the Action Pack and Active Record are either -available to be required immediately or are accessible as GEMs. - -It also requires a version of Ruby that includes SOAP support in the standard -library. At least version 1.8.2 final (2004-12-25) of Ruby is recommended; this -is the version tested against. - - -== Download - -The latest Action Web Service version can be downloaded from -http://rubyforge.org/projects/actionservice - - -== Installation - -You can install Action Web Service with the following command. - - % [sudo] ruby setup.rb - - -== License - -Action Web Service is released under the MIT license. - - -== Support - -The Ruby on Rails mailing list - -Or, to contact the author, send mail to bitserf@gmail.com - diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/Rakefile b/vendor/gems/datanoise-actionwebservice-2.3.2/Rakefile deleted file mode 100644 index 49e1aefd..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/Rakefile +++ /dev/null @@ -1,173 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/packagetask' -require 'rake/gempackagetask' -require 'rake/contrib/rubyforgepublisher' -require 'fileutils' -require File.join(File.dirname(__FILE__), 'lib', 'action_web_service', 'version') - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'actionwebservice' -PKG_VERSION = ActionWebService::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" -PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "aws" -RUBY_FORGE_USER = "webster132" - -desc "Default Task" -task :default => [ :test ] - - -# Run the unit tests -Rake::TestTask.new { |t| - t.libs << "test" - t.test_files = Dir['test/*_test.rb'] - t.verbose = true -} - -SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions)) - -desc 'Build the MySQL test database' -task :build_database do - %x( mysqladmin -uroot create actionwebservice_unittest ) - %x( mysql -uroot actionwebservice_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} ) -end - - -# Generate the RDoc documentation -Rake::RDocTask.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Action Web Service -- Web services for Action Pack" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('CHANGELOG') - rdoc.rdoc_files.include('lib/action_web_service.rb') - rdoc.rdoc_files.include('lib/action_web_service/*.rb') - rdoc.rdoc_files.include('lib/action_web_service/api/*.rb') - rdoc.rdoc_files.include('lib/action_web_service/client/*.rb') - rdoc.rdoc_files.include('lib/action_web_service/container/*.rb') - rdoc.rdoc_files.include('lib/action_web_service/dispatcher/*.rb') - rdoc.rdoc_files.include('lib/action_web_service/protocol/*.rb') - rdoc.rdoc_files.include('lib/action_web_service/support/*.rb') -} - - -# Create compressed packages -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = PKG_NAME - s.summary = "Web service support for Action Pack." - s.description = %q{Adds WSDL/SOAP and XML-RPC web service support to Action Pack} - s.version = PKG_VERSION - - s.author = "Leon Breedt, Kent Sibilev" - s.email = "bitserf@gmail.com, ksibilev@yahoo.com" - s.rubyforge_project = "aws" - s.homepage = "http://www.rubyonrails.org" - - s.add_dependency('actionpack', '= 2.3.12' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.3.12' + PKG_BUILD) - - s.has_rdoc = true - s.requirements << 'none' - s.require_path = 'lib' - s.autorequire = 'actionwebservice' - - s.files = [ "Rakefile", "setup.rb", "README", "TODO", "CHANGELOG", "MIT-LICENSE" ] - s.files = s.files + Dir.glob( "examples/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) } - s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) } - s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) } - s.files = s.files + Dir.glob( "generators/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) } -end -Rake::GemPackageTask.new(spec) do |p| - p.gem_spec = spec - p.need_tar = true - p.need_zip = true -end - - -# Publish beta gem -desc "Publish the API documentation" -task :pgem => [:package] do - Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'` -end - -# Publish documentation -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/aws", "doc").upload -end - - -def each_source_file(*args) - prefix, includes, excludes, open_file = args - prefix ||= File.dirname(__FILE__) - open_file = true if open_file.nil? - includes ||= %w[lib\/action_web_service\.rb$ lib\/action_web_service\/.*\.rb$] - excludes ||= %w[lib\/action_web_service\/vendor] - Find.find(prefix) do |file_name| - next if file_name =~ /\.svn/ - file_name.gsub!(/^\.\//, '') - continue = false - includes.each do |inc| - if file_name.match(/#{inc}/) - continue = true - break - end - end - next unless continue - excludes.each do |exc| - if file_name.match(/#{exc}/) - continue = false - break - end - end - next unless continue - if open_file - File.open(file_name) do |f| - yield file_name, f - end - else - yield file_name - end - end -end - -desc "Count lines of the AWS source code" -task :lines do - total_lines = total_loc = 0 - puts "Per File:" - each_source_file do |file_name, f| - file_lines = file_loc = 0 - while line = f.gets - file_lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - file_loc += 1 - end - puts " #{file_name}: Lines #{file_lines}, LOC #{file_loc}" - total_lines += file_lines - total_loc += file_loc - end - puts "Total:" - puts " Lines #{total_lines}, LOC #{total_loc}" -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - require 'rubyforge' - - packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" } - - rubyforge = RubyForge.new - rubyforge.login - rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages) -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/TODO b/vendor/gems/datanoise-actionwebservice-2.3.2/TODO deleted file mode 100644 index 7c022c14..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/TODO +++ /dev/null @@ -1,32 +0,0 @@ -= Post-1.0 - - Document/Literal SOAP support - - URL-based dispatching, URL identifies method - - - Add :rest dispatching mode, a.l.a. Backpack API. Clean up dispatching - in general. Support vanilla XML-format as a "Rails" protocol? - XML::Simple deserialization into params? - - web_service_dispatching_mode :rest - - def method1(params) - end - - def method2(params) - end - - - /ws/method1 - - /ws/method2 - - - - Allow locking down a controller to only accept messages for a particular - protocol. This will allow us to generate fully conformant error messages - in cases where we currently fudge it if we don't know the protocol. - - - Allow AWS user to participate in typecasting, so they can centralize - workarounds for buggy input in one place - -= Refactoring - - Don't have clean way to go from SOAP Class object to the xsd:NAME type - string -- NaHi possibly looking at remedying this situation diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/README b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/README deleted file mode 100644 index 25ccbd23..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/README +++ /dev/null @@ -1,143 +0,0 @@ -= Google Service example - -This example shows how one would implement an API like Google -Search that uses lots of structured types. - -There are examples for "Direct" and "Delegated" dispatching -modes. - -There is also an example for API definition file autoloading. - - -= Running the examples - - 1. Add the files to an Action Web Service enabled Rails project. - - "Direct" example: - - * Copy direct/search_controller.rb to "app/controllers" - in a Rails project. - * Copy direct/google_search_api.rb to "app/apis" - in a Rails project - - "Delegated" example: - - * Copy delegated/search_controller.rb to "app/controllers" - in a Rails project. - * Copy delegated/google_search_service.rb to "lib" - in a Rails project. - - "Autoloading" example: - - * Copy autoloading/google_search_api.rb to "app/apis" (create the directory - if it doesn't exist) in a Rails project. - - * Copy autoloading/google_search_controller.rb "app/controllers" - in a Rails project. - - - 2. Go to the WSDL url in a browser, and check that it looks correct. - - "Direct" and "Delegated" examples: - http://url_to_project/search/wsdl - - "Autoloading" example: - http://url_to_project/google_search/wsdl - - You can compare it to Google's hand-coded WSDL at http://api.google.com/GoogleSearch.wsdl - and see how close (or not) the generated version is. - - Note that I used GoogleSearch as the canonical "best practice" - interoperable example when implementing WSDL/SOAP support, which might - explain extreme similarities :) - - - 3. Test that it works with .NET (Mono in this example): - - $ wget WSDL_URL - $ mv wsdl GoogleSearch.wsdl - $ wsdl -out:GoogleSearch.cs GoogleSearch.wsdl - - Add these lines to the GoogleSearchService class body (be mindful of the - wrapping): - - public static void Main(string[] args) - { - GoogleSearchResult result; - GoogleSearchService service; - - service = new GoogleSearchService(); - result = service.doGoogleSearch("myApiKey", "my query", 10, 30, true, "restrict", false, "lr", "ie", "oe"); - System.Console.WriteLine("documentFiltering: {0}", result.documentFiltering); - System.Console.WriteLine("searchComments: {0}", result.searchComments); - System.Console.WriteLine("estimatedTotalResultsCount: {0}", result.estimatedTotalResultsCount); - System.Console.WriteLine("estimateIsExact: {0}", result.estimateIsExact); - System.Console.WriteLine("resultElements:"); - foreach (ResultElement element in result.resultElements) { - System.Console.WriteLine("\tsummary: {0}", element.summary); - System.Console.WriteLine("\tURL: {0}", element.URL); - System.Console.WriteLine("\tsnippet: {0}", element.snippet); - System.Console.WriteLine("\ttitle: {0}", element.title); - System.Console.WriteLine("\tcachedSize: {0}", element.cachedSize); - System.Console.WriteLine("\trelatedInformationPresent: {0}", element.relatedInformationPresent); - System.Console.WriteLine("\thostName: {0}", element.hostName); - System.Console.WriteLine("\tdirectoryCategory: {0}", element.directoryCategory.fullViewableName); - System.Console.WriteLine("\tdirectoryTitle: {0}", element.directoryTitle); - } - System.Console.WriteLine("searchQuery: {0}", result.searchQuery); - System.Console.WriteLine("startIndex: {0}", result.startIndex); - System.Console.WriteLine("endIndex: {0}", result.endIndex); - System.Console.WriteLine("searchTips: {0}", result.searchTips); - System.Console.WriteLine("directoryCategories:"); - foreach (DirectoryCategory cat in result.directoryCategories) { - System.Console.WriteLine("\t{0} ({1})", cat.fullViewableName, cat.specialEncoding); - } - System.Console.WriteLine("searchTime: {0}", result.searchTime); - } - - Now compile and run: - - $ mcs -reference:System.Web.Services GoogleSearch.cs - $ mono GoogleSearch.exe - - - If you had the application running (on the same host you got - the WSDL from), you should see something like this: - - - documentFiltering: True - searchComments: - estimatedTotalResultsCount: 322000 - estimateIsExact: False - resultElements: - summary: ONlamp.com: Rolling with Ruby on Rails - URL: http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html - snippet: Curt Hibbs shows off Ruby on Rails by building a simple ... - title: Teh Railz0r - cachedSize: Almost no lines of code! - relatedInformationPresent: True - hostName: rubyonrails.com - directoryCategory: Web Development - directoryTitle: - searchQuery: http://www.google.com/search?q=ruby+on+rails - startIndex: 10 - endIndex: 40 - searchTips: "on" is a very common word and was not included in your search [details] - directoryCategories: - Web Development (UTF-8) - Programming (US-ASCII) - searchTime: 1E-06 - - - Also, if an API method throws an exception, it will be sent back to the - caller in the protocol's exception format, so they should get an exception - thrown on their side with a meaningful error message. - - If you don't like this behaviour, you can do: - - class MyController < ActionController::Base - web_service_exception_reporting false - end - - 4. Crack open a beer. Publishing APIs for working with the same model as - your Rails web app should be easy from now on :) diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/autoloading/google_search_api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/autoloading/google_search_api.rb deleted file mode 100644 index ed69fed7..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/autoloading/google_search_api.rb +++ /dev/null @@ -1,50 +0,0 @@ -class DirectoryCategory < ActionWebService::Struct - member :fullViewableName, :string - member :specialEncoding, :string -end - -class ResultElement < ActionWebService::Struct - member :summary, :string - member :URL, :string - member :snippet, :string - member :title, :string - member :cachedSize, :string - member :relatedInformationPresent, :bool - member :hostName, :string - member :directoryCategory, DirectoryCategory - member :directoryTitle, :string -end - -class GoogleSearchResult < ActionWebService::Struct - member :documentFiltering, :bool - member :searchComments, :string - member :estimatedTotalResultsCount, :int - member :estimateIsExact, :bool - member :resultElements, [ResultElement] - member :searchQuery, :string - member :startIndex, :int - member :endIndex, :int - member :searchTips, :string - member :directoryCategories, [DirectoryCategory] - member :searchTime, :float -end - -class GoogleSearchAPI < ActionWebService::API::Base - inflect_names false - - api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}] - api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}] - - api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [ - {:key=>:string}, - {:q=>:string}, - {:start=>:int}, - {:maxResults=>:int}, - {:filter=>:bool}, - {:restrict=>:string}, - {:safeSearch=>:bool}, - {:lr=>:string}, - {:ie=>:string}, - {:oe=>:string} - ] -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/autoloading/google_search_controller.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/autoloading/google_search_controller.rb deleted file mode 100644 index c62e869d..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/autoloading/google_search_controller.rb +++ /dev/null @@ -1,57 +0,0 @@ -class GoogleSearchController < ApplicationController - wsdl_service_name 'GoogleSearch' - - def doGetCachedPage - "i am a cached page. my key was %s, url was %s" % [@params['key'], @params['url']] - end - - def doSpellingSuggestion - "%s: Did you mean '%s'?" % [@params['key'], @params['phrase']] - end - - def doGoogleSearch - resultElement = ResultElement.new - resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails" - resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html" - resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " + - "almost no Ruby experience. ... Rolling with Ruby on Rails. ..." - resultElement.title = "Teh Railz0r" - resultElement.cachedSize = "Almost no lines of code!" - resultElement.relatedInformationPresent = true - resultElement.hostName = "rubyonrails.com" - resultElement.directoryCategory = category("Web Development", "UTF-8") - - result = GoogleSearchResult.new - result.documentFiltering = @params['filter'] - result.searchComments = "" - result.estimatedTotalResultsCount = 322000 - result.estimateIsExact = false - result.resultElements = [resultElement] - result.searchQuery = "http://www.google.com/search?q=ruby+on+rails" - result.startIndex = @params['start'] - result.endIndex = @params['start'] + @params['maxResults'] - result.searchTips = "\"on\" is a very common word and was not included in your search [details]" - result.searchTime = 0.000001 - - # For Mono, we have to clone objects if they're referenced by more than one place, otherwise - # the Ruby SOAP collapses them into one instance and uses references all over the - # place, confusing Mono. - # - # This has recently been fixed: - # http://bugzilla.ximian.com/show_bug.cgi?id=72265 - result.directoryCategories = [ - category("Web Development", "UTF-8"), - category("Programming", "US-ASCII"), - ] - - result - end - - private - def category(name, encoding) - cat = DirectoryCategory.new - cat.fullViewableName = name.dup - cat.specialEncoding = encoding.dup - cat - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/delegated/google_search_service.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/delegated/google_search_service.rb deleted file mode 100644 index ade354d8..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/delegated/google_search_service.rb +++ /dev/null @@ -1,108 +0,0 @@ -class DirectoryCategory < ActionWebService::Struct - member :fullViewableName, :string - member :specialEncoding, :string -end - -class ResultElement < ActionWebService::Struct - member :summary, :string - member :URL, :string - member :snippet, :string - member :title, :string - member :cachedSize, :string - member :relatedInformationPresent, :bool - member :hostName, :string - member :directoryCategory, DirectoryCategory - member :directoryTitle, :string -end - -class GoogleSearchResult < ActionWebService::Struct - member :documentFiltering, :bool - member :searchComments, :string - member :estimatedTotalResultsCount, :int - member :estimateIsExact, :bool - member :resultElements, [ResultElement] - member :searchQuery, :string - member :startIndex, :int - member :endIndex, :int - member :searchTips, :string - member :directoryCategories, [DirectoryCategory] - member :searchTime, :float -end - -class GoogleSearchAPI < ActionWebService::API::Base - inflect_names false - - api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}] - api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}] - - api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [ - {:key=>:string}, - {:q=>:string}, - {:start=>:int}, - {:maxResults=>:int}, - {:filter=>:bool}, - {:restrict=>:string}, - {:safeSearch=>:bool}, - {:lr=>:string}, - {:ie=>:string}, - {:oe=>:string} - ] -end - -class GoogleSearchService < ActionWebService::Base - web_service_api GoogleSearchAPI - - def doGetCachedPage(key, url) - "i am a cached page" - end - - def doSpellingSuggestion(key, phrase) - "Did you mean 'teh'?" - end - - def doGoogleSearch(key, q, start, maxResults, filter, restrict, safeSearch, lr, ie, oe) - resultElement = ResultElement.new - resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails" - resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html" - resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " + - "almost no Ruby experience. ... Rolling with Ruby on Rails. ..." - resultElement.title = "Teh Railz0r" - resultElement.cachedSize = "Almost no lines of code!" - resultElement.relatedInformationPresent = true - resultElement.hostName = "rubyonrails.com" - resultElement.directoryCategory = category("Web Development", "UTF-8") - - result = GoogleSearchResult.new - result.documentFiltering = filter - result.searchComments = "" - result.estimatedTotalResultsCount = 322000 - result.estimateIsExact = false - result.resultElements = [resultElement] - result.searchQuery = "http://www.google.com/search?q=ruby+on+rails" - result.startIndex = start - result.endIndex = start + maxResults - result.searchTips = "\"on\" is a very common word and was not included in your search [details]" - result.searchTime = 0.000001 - - # For Mono, we have to clone objects if they're referenced by more than one place, otherwise - # the Ruby SOAP collapses them into one instance and uses references all over the - # place, confusing Mono. - # - # This has recently been fixed: - # http://bugzilla.ximian.com/show_bug.cgi?id=72265 - result.directoryCategories = [ - category("Web Development", "UTF-8"), - category("Programming", "US-ASCII"), - ] - - result - end - - private - def category(name, encoding) - cat = DirectoryCategory.new - cat.fullViewableName = name.dup - cat.specialEncoding = encoding.dup - cat - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/delegated/search_controller.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/delegated/search_controller.rb deleted file mode 100644 index 6525921b..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/delegated/search_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'google_search_service' - -class SearchController < ApplicationController - wsdl_service_name 'GoogleSearch' - web_service_dispatching_mode :delegated - web_service :beta3, GoogleSearchService.new -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/direct/google_search_api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/direct/google_search_api.rb deleted file mode 100644 index ed69fed7..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/direct/google_search_api.rb +++ /dev/null @@ -1,50 +0,0 @@ -class DirectoryCategory < ActionWebService::Struct - member :fullViewableName, :string - member :specialEncoding, :string -end - -class ResultElement < ActionWebService::Struct - member :summary, :string - member :URL, :string - member :snippet, :string - member :title, :string - member :cachedSize, :string - member :relatedInformationPresent, :bool - member :hostName, :string - member :directoryCategory, DirectoryCategory - member :directoryTitle, :string -end - -class GoogleSearchResult < ActionWebService::Struct - member :documentFiltering, :bool - member :searchComments, :string - member :estimatedTotalResultsCount, :int - member :estimateIsExact, :bool - member :resultElements, [ResultElement] - member :searchQuery, :string - member :startIndex, :int - member :endIndex, :int - member :searchTips, :string - member :directoryCategories, [DirectoryCategory] - member :searchTime, :float -end - -class GoogleSearchAPI < ActionWebService::API::Base - inflect_names false - - api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}] - api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}] - - api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [ - {:key=>:string}, - {:q=>:string}, - {:start=>:int}, - {:maxResults=>:int}, - {:filter=>:bool}, - {:restrict=>:string}, - {:safeSearch=>:bool}, - {:lr=>:string}, - {:ie=>:string}, - {:oe=>:string} - ] -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/direct/search_controller.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/direct/search_controller.rb deleted file mode 100644 index 7c69f022..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/googlesearch/direct/search_controller.rb +++ /dev/null @@ -1,58 +0,0 @@ -class SearchController < ApplicationController - web_service_api :google_search - wsdl_service_name 'GoogleSearch' - - def doGetCachedPage - "i am a cached page. my key was %s, url was %s" % [@params['key'], @params['url']] - end - - def doSpellingSuggestion - "%s: Did you mean '%s'?" % [@params['key'], @params['phrase']] - end - - def doGoogleSearch - resultElement = ResultElement.new - resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails" - resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html" - resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " + - "almost no Ruby experience. ... Rolling with Ruby on Rails. ..." - resultElement.title = "Teh Railz0r" - resultElement.cachedSize = "Almost no lines of code!" - resultElement.relatedInformationPresent = true - resultElement.hostName = "rubyonrails.com" - resultElement.directoryCategory = category("Web Development", "UTF-8") - - result = GoogleSearchResult.new - result.documentFiltering = @params['filter'] - result.searchComments = "" - result.estimatedTotalResultsCount = 322000 - result.estimateIsExact = false - result.resultElements = [resultElement] - result.searchQuery = "http://www.google.com/search?q=ruby+on+rails" - result.startIndex = @params['start'] - result.endIndex = @params['start'] + @params['maxResults'] - result.searchTips = "\"on\" is a very common word and was not included in your search [details]" - result.searchTime = 0.000001 - - # For Mono, we have to clone objects if they're referenced by more than one place, otherwise - # the Ruby SOAP collapses them into one instance and uses references all over the - # place, confusing Mono. - # - # This has recently been fixed: - # http://bugzilla.ximian.com/show_bug.cgi?id=72265 - result.directoryCategories = [ - category("Web Development", "UTF-8"), - category("Programming", "US-ASCII"), - ] - - result - end - - private - def category(name, encoding) - cat = DirectoryCategory.new - cat.fullViewableName = name.dup - cat.specialEncoding = encoding.dup - cat - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/README b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/README deleted file mode 100644 index f66f5677..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/README +++ /dev/null @@ -1,17 +0,0 @@ -= metaWeblog example - -This example shows how one might begin to go about adding metaWeblog -(http://www.xmlrpc.com/metaWeblogApi) API support to a Rails-based -blogging application. - -The example APIs are more verbose than you may want to make them, for documentation -reasons. - -= Running - - 1. Copy the "apis" directory and its files into "app" in a Rails project. - - 2. Copy the "controllers" directory and its files into "app" in a Rails project - - 3. Fire up a desktop blogging application (such as w.bloggar, MarsEdit, or BloGTK), - point it at http://localhost:3000/xmlrpc/api, and try creating or editing blog posts. diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/blogger_api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/blogger_api.rb deleted file mode 100644 index 9f85a239..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/blogger_api.rb +++ /dev/null @@ -1,60 +0,0 @@ -# -# see the blogger API spec at http://www.blogger.com/developers/api/1_docs/ -# note that the method signatures are subtly different to metaWeblog, they -# are not identical. take care to ensure you handle the different semantics -# properly if you want to support blogger API too, to get maximum compatibility. -# - -module Blog - class Blog < ActionWebService::Struct - member :url, :string - member :blogid, :string - member :blogName, :string - end - - class User < ActionWebService::Struct - member :nickname, :string - member :userid, :string - member :url, :string - member :email, :string - member :lastname, :string - member :firstname, :string - end -end - -# -# blogger -# -class BloggerAPI < ActionWebService::API::Base - inflect_names false - - api_method :newPost, :returns => [:string], :expects => [ - {:appkey=>:string}, - {:blogid=>:string}, - {:username=>:string}, - {:password=>:string}, - {:content=>:string}, - {:publish=>:bool} - ] - - api_method :editPost, :returns => [:bool], :expects => [ - {:appkey=>:string}, - {:postid=>:string}, - {:username=>:string}, - {:password=>:string}, - {:content=>:string}, - {:publish=>:bool} - ] - - api_method :getUsersBlogs, :returns => [[Blog::Blog]], :expects => [ - {:appkey=>:string}, - {:username=>:string}, - {:password=>:string} - ] - - api_method :getUserInfo, :returns => [Blog::User], :expects => [ - {:appkey=>:string}, - {:username=>:string}, - {:password=>:string} - ] -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/blogger_service.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/blogger_service.rb deleted file mode 100644 index b79b53e6..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/blogger_service.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'blogger_api' - -class BloggerService < ActionWebService::Base - web_service_api BloggerAPI - - def initialize - @postid = 0 - end - - def newPost(key, id, user, pw, content, publish) - $stderr.puts "id=#{id} user=#{user} pw=#{pw}, content=#{content.inspect} [#{publish}]" - (@postid += 1).to_s - end - - def editPost(key, post_id, user, pw, content, publish) - $stderr.puts "id=#{post_id} user=#{user} pw=#{pw} content=#{content.inspect} [#{publish}]" - true - end - - def getUsersBlogs(key, user, pw) - $stderr.puts "getting blogs for #{user}" - blog = Blog::Blog.new( - :url =>'http://blog', - :blogid => 'myblog', - :blogName => 'My Blog' - ) - [blog] - end - - def getUserInfo(key, user, pw) - $stderr.puts "getting user info for #{user}" - Blog::User.new(:nickname => 'user', :email => 'user@test.com') - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/meta_weblog_api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/meta_weblog_api.rb deleted file mode 100644 index adef12a2..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/meta_weblog_api.rb +++ /dev/null @@ -1,67 +0,0 @@ -# -# here lie structures, cousins of those on http://www.xmlrpc.com/metaWeblog -# but they don't necessarily the real world reflect -# so if you do, find that your client complains: -# please tell, of problems you suffered through -# - -module Blog - class Post < ActionWebService::Struct - member :title, :string - member :link, :string - member :description, :string - member :author, :string - member :category, :string - member :comments, :string - member :guid, :string - member :pubDate, :string - end - - class Category < ActionWebService::Struct - member :description, :string - member :htmlUrl, :string - member :rssUrl, :string - end -end - -# -# metaWeblog -# -class MetaWeblogAPI < ActionWebService::API::Base - inflect_names false - - api_method :newPost, :returns => [:string], :expects => [ - {:blogid=>:string}, - {:username=>:string}, - {:password=>:string}, - {:struct=>Blog::Post}, - {:publish=>:bool} - ] - - api_method :editPost, :returns => [:bool], :expects => [ - {:postid=>:string}, - {:username=>:string}, - {:password=>:string}, - {:struct=>Blog::Post}, - {:publish=>:bool}, - ] - - api_method :getPost, :returns => [Blog::Post], :expects => [ - {:postid=>:string}, - {:username=>:string}, - {:password=>:string}, - ] - - api_method :getCategories, :returns => [[Blog::Category]], :expects => [ - {:blogid=>:string}, - {:username=>:string}, - {:password=>:string}, - ] - - api_method :getRecentPosts, :returns => [[Blog::Post]], :expects => [ - {:blogid=>:string}, - {:username=>:string}, - {:password=>:string}, - {:numberOfPosts=>:int}, - ] -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/meta_weblog_service.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/meta_weblog_service.rb deleted file mode 100644 index 9c66558f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/apis/meta_weblog_service.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'meta_weblog_api' - -class MetaWeblogService < ActionWebService::Base - web_service_api MetaWeblogAPI - - def initialize - @postid = 0 - end - - def newPost(id, user, pw, struct, publish) - $stderr.puts "id=#{id} user=#{user} pw=#{pw}, struct=#{struct.inspect} [#{publish}]" - (@postid += 1).to_s - end - - def editPost(post_id, user, pw, struct, publish) - $stderr.puts "id=#{post_id} user=#{user} pw=#{pw} struct=#{struct.inspect} [#{publish}]" - true - end - - def getPost(post_id, user, pw) - $stderr.puts "get post #{post_id}" - Blog::Post.new(:title => 'hello world', :description => 'first post!') - end - - def getCategories(id, user, pw) - $stderr.puts "categories for #{user}" - cat = Blog::Category.new( - :description => 'Tech', - :htmlUrl => 'http://blog/tech', - :rssUrl => 'http://blog/tech.rss') - [cat] - end - - def getRecentPosts(id, user, pw, num) - $stderr.puts "recent #{num} posts for #{user} on blog #{id}" - post1 = Blog::Post.new( - :title => 'first post!', - :link => 'http://blog.xeraph.org/testOne.html', - :description => 'this is the first post' - ) - post2 = Blog::Post.new( - :title => 'second post!', - :link => 'http://blog.xeraph.org/testTwo.html', - :description => 'this is the second post' - ) - [post1, post2] - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/controllers/xmlrpc_controller.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/controllers/xmlrpc_controller.rb deleted file mode 100644 index 7486402d..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/examples/metaWeblog/controllers/xmlrpc_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -# -# example controller implementing both blogger and metaWeblog APIs -# in a way that should be compatible with clients supporting both/either. -# -# test by pointing your client at http://URL/xmlrpc/api -# - -require 'meta_weblog_service' -require 'blogger_service' - -class XmlrpcController < ApplicationController - web_service_dispatching_mode :layered - - web_service :metaWeblog, MetaWeblogService.new - web_service :blogger, BloggerService.new -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/USAGE b/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/USAGE deleted file mode 100644 index d3e45b7f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/USAGE +++ /dev/null @@ -1,28 +0,0 @@ -Description: - The web service generator creates the controller and API definition for - a web service. - - The generator takes a web service name and a list of API methods as arguments. - The web service name may be given in CamelCase or under_score and should - contain no extra suffixes. To create a web service within a - module, specify the web service name as 'module/webservice'. - - The generator creates a controller class in app/controllers, an API definition - in app/apis, and a functional test suite in test/functional. - -Example: - ./script/generate web_service User add edit list remove - - User web service. - Controller: app/controllers/user_controller.rb - API: app/apis/user_api.rb - Test: test/functional/user_api_test.rb - -Modules Example: - ./script/generate web_service 'api/registration' register renew - - Registration web service. - Controller: app/controllers/api/registration_controller.rb - API: app/apis/api/registration_api.rb - Test: test/functional/api/registration_api_test.rb - diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/api_definition.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/api_definition.rb deleted file mode 100644 index 97d0b608..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/api_definition.rb +++ /dev/null @@ -1,5 +0,0 @@ -class <%= class_name %>Api < ActionWebService::API::Base -<% for method_name in args -%> - api_method :<%= method_name %> -<% end -%> -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/controller.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/controller.rb deleted file mode 100644 index 7b0a8657..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class <%= class_name %>Controller < ApplicationController - wsdl_service_name '<%= class_name %>' -<% for method_name in args -%> - - def <%= method_name %> - end -<% end -%> -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/functional_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/functional_test.rb deleted file mode 100644 index c4d136f8..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/templates/functional_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper' -require '<%= file_path %>_controller' - -class <%= class_name %>Controller; def rescue_action(e) raise e end; end - -class <%= class_name %>ControllerApiTest < Test::Unit::TestCase - def setup - @controller = <%= class_name %>Controller.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end -<% for method_name in args -%> - - def test_<%= method_name %> - result = invoke :<%= method_name %> - assert_equal nil, result - end -<% end -%> -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/web_service_generator.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/web_service_generator.rb deleted file mode 100644 index 7c47e5a2..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/generators/web_service/web_service_generator.rb +++ /dev/null @@ -1,29 +0,0 @@ -class WebServiceGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_path, "#{class_name}Api", "#{class_name}Controller", "#{class_name}ApiTest" - - # API and test directories. - m.directory File.join('app/services', class_path) - m.directory File.join('app/controllers', class_path) - m.directory File.join('test/functional', class_path) - - # API definition, controller, and functional test. - m.template 'api_definition.rb', - File.join('app/services', - class_path, - "#{file_name}_api.rb") - - m.template 'controller.rb', - File.join('app/controllers', - class_path, - "#{file_name}_controller.rb") - - m.template 'functional_test.rb', - File.join('test/functional', - class_path, - "#{file_name}_api_test.rb") - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service.rb deleted file mode 100644 index cf5d7d63..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service.rb +++ /dev/null @@ -1,66 +0,0 @@ -#-- -# Copyright (C) 2005 Leon Breedt -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -begin - require 'active_support' - require 'action_controller' - require 'active_record' -rescue LoadError - require 'rubygems' - gem 'activesupport', '>= 2.3.0' - gem 'actionpack', '>= 2.3.0' - gem 'activerecord', '>= 2.3.0' -end - -$:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/") - -require 'action_web_service/support/class_inheritable_options' -require 'action_web_service/support/signature_types' -require 'action_web_service/base' -require 'action_web_service/client' -require 'action_web_service/invocation' -require 'action_web_service/api' -require 'action_web_service/casting' -require 'action_web_service/struct' -require 'action_web_service/container' -require 'action_web_service/protocol' -require 'action_web_service/dispatcher' -require 'action_web_service/scaffolding' - -ActionWebService::Base.class_eval do - include ActionWebService::Container::Direct - include ActionWebService::Invocation -end - -ActionController::Base.class_eval do - include ActionWebService::Protocol::Discovery - include ActionWebService::Protocol::Soap - include ActionWebService::Protocol::XmlRpc - include ActionWebService::Container::Direct - include ActionWebService::Container::Delegated - include ActionWebService::Container::ActionController - include ActionWebService::Invocation - include ActionWebService::Dispatcher - include ActionWebService::Dispatcher::ActionController - include ActionWebService::Scaffolding -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/api.rb deleted file mode 100644 index da6c8711..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/api.rb +++ /dev/null @@ -1,297 +0,0 @@ -module ActionWebService # :nodoc: - module API # :nodoc: - # A web service API class specifies the methods that will be available for - # invocation for an API. It also contains metadata such as the method type - # signature hints. - # - # It is not intended to be instantiated. - # - # It is attached to web service implementation classes like - # ActionWebService::Base and ActionController::Base derivatives by using - # container.web_service_api, where container is an - # ActionController::Base or a ActionWebService::Base. - # - # See ActionWebService::Container::Direct::ClassMethods for an example - # of use. - class Base - # Whether to transform the public API method names into camel-cased names - class_inheritable_option :inflect_names, true - - # By default only HTTP POST requests are processed - class_inheritable_option :allowed_http_methods, [ :post ] - - # Whether to allow ActiveRecord::Base models in :expects. - # The default is +false+; you should be aware of the security implications - # of allowing this, and ensure that you don't allow remote callers to - # easily overwrite data they should not have access to. - class_inheritable_option :allow_active_record_expects, false - - # If present, the name of a method to call when the remote caller - # tried to call a nonexistent method. Semantically equivalent to - # +method_missing+. - class_inheritable_option :default_api_method - - # Disallow instantiation - private_class_method :new, :allocate - - class << self - include ActionWebService::SignatureTypes - - # API methods have a +name+, which must be the Ruby method name to use when - # performing the invocation on the web service object. - # - # The signatures for the method input parameters and return value can - # by specified in +options+. - # - # A signature is an array of one or more parameter specifiers. - # A parameter specifier can be one of the following: - # - # * A symbol or string representing one of the Action Web Service base types. - # See ActionWebService::SignatureTypes for a canonical list of the base types. - # * The Class object of the parameter type - # * A single-element Array containing one of the two preceding items. This - # will cause Action Web Service to treat the parameter at that position - # as an array containing only values of the given type. - # * A Hash containing as key the name of the parameter, and as value - # one of the three preceding items - # - # If no method input parameter or method return value signatures are given, - # the method is assumed to take no parameters and/or return no values of - # interest, and any values that are received by the server will be - # discarded and ignored. - # - # Valid options: - # [:expects] Signature for the method input parameters - # [:returns] Signature for the method return value - # [:expects_and_returns] Signature for both input parameters and return value - def api_method(name, options={}) - unless options.is_a?(Hash) - raise(ActionWebServiceError, "Expected a Hash for options") - end - validate_options([:expects, :returns, :expects_and_returns], options.keys) - if options[:expects_and_returns] - expects = options[:expects_and_returns] - returns = options[:expects_and_returns] - else - expects = options[:expects] - returns = options[:returns] - end - expects = canonical_signature(expects) - returns = canonical_signature(returns) - if expects - expects.each do |type| - type = type.element_type if type.is_a?(ArrayType) - if type.type_class.ancestors.include?(ActiveRecord::Base) && !allow_active_record_expects - raise(ActionWebServiceError, "ActiveRecord model classes not allowed in :expects") - end - end - end - name = name.to_sym - public_name = public_api_method_name(name) - method = Method.new(name, public_name, expects, returns) - write_inheritable_hash("api_methods", name => method) - write_inheritable_hash("api_public_method_names", public_name => name) - end - - # Whether the given method name is a service method on this API - # - # class ProjectsApi < ActionWebService::API::Base - # api_method :getCount, :returns => [:int] - # end - # - # ProjectsApi.has_api_method?('GetCount') #=> false - # ProjectsApi.has_api_method?(:getCount) #=> true - def has_api_method?(name) - api_methods.has_key?(name) - end - - # Whether the given public method name has a corresponding service method - # on this API - # - # class ProjectsApi < ActionWebService::API::Base - # api_method :getCount, :returns => [:int] - # end - # - # ProjectsApi.has_api_method?(:getCount) #=> false - # ProjectsApi.has_api_method?('GetCount') #=> true - def has_public_api_method?(public_name) - api_public_method_names.has_key?(public_name) - end - - # The corresponding public method name for the given service method name - # - # ProjectsApi.public_api_method_name('GetCount') #=> "GetCount" - # ProjectsApi.public_api_method_name(:getCount) #=> "GetCount" - def public_api_method_name(name) - if inflect_names - name.to_s.camelize - else - name.to_s - end - end - - # The corresponding service method name for the given public method name - # - # class ProjectsApi < ActionWebService::API::Base - # api_method :getCount, :returns => [:int] - # end - # - # ProjectsApi.api_method_name('GetCount') #=> :getCount - def api_method_name(public_name) - api_public_method_names[public_name] - end - - # A Hash containing all service methods on this API, and their - # associated metadata. - # - # class ProjectsApi < ActionWebService::API::Base - # api_method :getCount, :returns => [:int] - # api_method :getCompletedCount, :returns => [:int] - # end - # - # ProjectsApi.api_methods #=> - # {:getCount=>#, - # :getCompletedCount=>#} - # ProjectsApi.api_methods[:getCount].public_name #=> "GetCount" - def api_methods - read_inheritable_attribute("api_methods") || {} - end - - # The Method instance for the given public API method name, if any - # - # class ProjectsApi < ActionWebService::API::Base - # api_method :getCount, :returns => [:int] - # api_method :getCompletedCount, :returns => [:int] - # end - # - # ProjectsApi.public_api_method_instance('GetCount') #=> <# - # ProjectsApi.public_api_method_instance(:getCount) #=> nil - def public_api_method_instance(public_method_name) - api_method_instance(api_method_name(public_method_name)) - end - - # The Method instance for the given API method name, if any - # - # class ProjectsApi < ActionWebService::API::Base - # api_method :getCount, :returns => [:int] - # api_method :getCompletedCount, :returns => [:int] - # end - # - # ProjectsApi.api_method_instance(:getCount) #=> - # ProjectsApi.api_method_instance('GetCount') #=> - def api_method_instance(method_name) - api_methods[method_name] - end - - # The Method instance for the default API method, if any - def default_api_method_instance - return nil unless name = default_api_method - instance = read_inheritable_attribute("default_api_method_instance") - if instance && instance.name == name - return instance - end - instance = Method.new(name, public_api_method_name(name), nil, nil) - write_inheritable_attribute("default_api_method_instance", instance) - instance - end - - private - def api_public_method_names - read_inheritable_attribute("api_public_method_names") || {} - end - - def validate_options(valid_option_keys, supplied_option_keys) - unknown_option_keys = supplied_option_keys - valid_option_keys - unless unknown_option_keys.empty? - raise(ActionWebServiceError, "Unknown options: #{unknown_option_keys}") - end - end - end - end - - # Represents an API method and its associated metadata, and provides functionality - # to assist in commonly performed API method tasks. - class Method - attr :name - attr :public_name - attr :expects - attr :returns - - def initialize(name, public_name, expects, returns) - @name = name - @public_name = public_name - @expects = expects - @returns = returns - @caster = ActionWebService::Casting::BaseCaster.new(self) - end - - # The list of parameter names for this method - def param_names - return [] unless @expects - @expects.map{ |type| type.name } - end - - # Casts a set of Ruby values into the expected Ruby values - def cast_expects(params) - @caster.cast_expects(params) - end - - # Cast a Ruby return value into the expected Ruby value - def cast_returns(return_value) - @caster.cast_returns(return_value) - end - - # Returns the index of the first expected parameter - # with the given name - def expects_index_of(param_name) - return -1 if @expects.nil? - (0..(@expects.length-1)).each do |i| - return i if @expects[i].name.to_s == param_name.to_s - end - -1 - end - - # Returns a hash keyed by parameter name for the given - # parameter list - def expects_to_hash(params) - return {} if @expects.nil? - h = {} - @expects.zip(params){ |type, param| h[type.name] = param } - h - end - - # Backwards compatibility with previous API - def [](sig_type) - case sig_type - when :expects - @expects.map{|x| compat_signature_entry(x)} - when :returns - @returns.map{|x| compat_signature_entry(x)} - end - end - - # String representation of this method - def to_s - fqn = "" - fqn << (@returns ? (@returns[0].human_name(false) + " ") : "void ") - fqn << "#{@public_name}(" - fqn << @expects.map{ |p| p.human_name }.join(", ") if @expects - fqn << ")" - fqn - end - - private - def compat_signature_entry(entry) - if entry.array? - [compat_signature_entry(entry.element_type)] - else - if entry.spec.is_a?(Hash) - {entry.spec.keys.first => entry.type_class} - else - entry.type_class - end - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/base.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/base.rb deleted file mode 100644 index 6282061d..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/base.rb +++ /dev/null @@ -1,38 +0,0 @@ -module ActionWebService # :nodoc: - class ActionWebServiceError < StandardError # :nodoc: - end - - # An Action Web Service object implements a specified API. - # - # Used by controllers operating in _Delegated_ dispatching mode. - # - # ==== Example - # - # class PersonService < ActionWebService::Base - # web_service_api PersonAPI - # - # def find_person(criteria) - # Person.find(:all) [...] - # end - # - # def delete_person(id) - # Person.find_by_id(id).destroy - # end - # end - # - # class PersonAPI < ActionWebService::API::Base - # api_method :find_person, :expects => [SearchCriteria], :returns => [[Person]] - # api_method :delete_person, :expects => [:int] - # end - # - # class SearchCriteria < ActionWebService::Struct - # member :firstname, :string - # member :lastname, :string - # member :email, :string - # end - class Base - # Whether to report exceptions back to the caller in the protocol's exception - # format - class_inheritable_option :web_service_exception_reporting, true - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/casting.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/casting.rb deleted file mode 100644 index 652af76a..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/casting.rb +++ /dev/null @@ -1,149 +0,0 @@ -require 'time' -require 'date' -require 'xmlrpc/datetime' - -module ActionWebService # :nodoc: - module Casting # :nodoc: - class CastingError < ActionWebServiceError # :nodoc: - end - - # Performs casting of arbitrary values into the correct types for the signature - class BaseCaster # :nodoc: - def initialize(api_method) - @api_method = api_method - end - - # Coerces the parameters in +params+ (an Enumerable) into the types - # this method expects - def cast_expects(params) - self.class.cast_expects(@api_method, params) - end - - # Coerces the given +return_value+ into the type returned by this - # method - def cast_returns(return_value) - self.class.cast_returns(@api_method, return_value) - end - - class << self - include ActionWebService::SignatureTypes - - def cast_expects(api_method, params) # :nodoc: - return [] if api_method.expects.nil? - api_method.expects.zip(params).map{ |type, param| cast(param, type) } - end - - def cast_returns(api_method, return_value) # :nodoc: - return nil if api_method.returns.nil? - cast(return_value, api_method.returns[0]) - end - - def cast(value, signature_type) # :nodoc: - return value if signature_type.nil? # signature.length != params.length - return nil if value.nil? - # XMLRPC protocol doesn't support nil values. It uses false instead. - # It should never happen for SOAP. - if signature_type.structured? && value.equal?(false) - return nil - end - unless signature_type.array? || signature_type.structured? - return value if canonical_type(value.class) == signature_type.type - end - if signature_type.array? - unless value.respond_to?(:entries) && !value.is_a?(String) - raise CastingError, "Don't know how to cast #{value.class} into #{signature_type.type.inspect}" - end - value.entries.map do |entry| - cast(entry, signature_type.element_type) - end - elsif signature_type.structured? - cast_to_structured_type(value, signature_type) - elsif !signature_type.custom? - cast_base_type(value, signature_type) - end - end - - def cast_base_type(value, signature_type) # :nodoc: - # This is a work-around for the fact that XML-RPC special-cases DateTime values into its own DateTime type - # in order to support iso8601 dates. This doesn't work too well for us, so we'll convert it into a Time, - # with the caveat that we won't be able to handle pre-1970 dates that are sent to us. - # - # See http://dev.rubyonrails.com/ticket/2516 - value = value.to_time if value.is_a?(XMLRPC::DateTime) - - case signature_type.type - when :int - Integer(value) - when :string - value.to_s - when :base64 - if value.is_a?(ActionWebService::Base64) - value - else - ActionWebService::Base64.new(value.to_s) - end - when :bool - return false if value.nil? - return value if value == true || value == false - case value.to_s.downcase - when '1', 'true', 'y', 'yes' - true - when '0', 'false', 'n', 'no' - false - else - raise CastingError, "Don't know how to cast #{value.class} into Boolean" - end - when :float - Float(value) - when :decimal - BigDecimal(value.to_s) - when :time - value = "%s/%s/%s %s:%s:%s" % value.values_at(*%w[2 3 1 4 5 6]) if value.kind_of?(Hash) - if value.kind_of?(Time) - value - elsif value.kind_of?(DateTime) - value.to_time - else - Time.parse(value.to_s) - end - when :date - value = "%s/%s/%s" % value.values_at(*%w[2 3 1]) if value.kind_of?(Hash) - value.kind_of?(Date) ? value : Date.parse(value.to_s) - when :datetime - value = "%s/%s/%s %s:%s:%s" % value.values_at(*%w[2 3 1 4 5 6]) if value.kind_of?(Hash) - value.kind_of?(DateTime) ? value : DateTime.parse(value.to_s) - end - end - - def cast_to_structured_type(value, signature_type) # :nodoc: - obj = nil - # if the canonical classes are the same or if the given value is of - # a type that is derived from the signature_type do not attempt to - # "cast" the value into the signature_type as it's already good to go - obj = ( - canonical_type(value.class) == canonical_type(signature_type.type) or - derived_from?(signature_type.type, value.class) - ) ? value : signature_type.type_class.new - if value.respond_to?(:each_pair) - klass = signature_type.type_class - value.each_pair do |name, val| - type = klass.respond_to?(:member_type) ? klass.member_type(name) : nil - val = cast(val, type) if type - # See http://dev.rubyonrails.com/ticket/3567 - val = val.to_time if val.is_a?(XMLRPC::DateTime) - obj.__send__("#{name}=", val) if obj.respond_to?(name) - end - elsif value.respond_to?(:attributes) - signature_type.each_member do |name, type| - val = value.__send__(name) - obj.__send__("#{name}=", cast(val, type)) if obj.respond_to?(name) - end - else - raise CastingError, "Don't know how to cast #{value.class} to #{signature_type.type_class}" - end - obj - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client.rb deleted file mode 100644 index 2a1e3305..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'action_web_service/client/base' -require 'action_web_service/client/soap_client' -require 'action_web_service/client/xmlrpc_client' diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/base.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/base.rb deleted file mode 100644 index 9dada7bf..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/base.rb +++ /dev/null @@ -1,28 +0,0 @@ -module ActionWebService # :nodoc: - module Client # :nodoc: - class ClientError < StandardError # :nodoc: - end - - class Base # :nodoc: - def initialize(api, endpoint_uri) - @api = api - @endpoint_uri = endpoint_uri - end - - def method_missing(name, *args) # :nodoc: - call_name = method_name(name) - return super(name, *args) if call_name.nil? - self.perform_invocation(call_name, args) - end - - private - def method_name(name) - if @api.has_api_method?(name.to_sym) - name.to_s - elsif @api.has_public_api_method?(name.to_s) - @api.api_method_name(name.to_s).to_s - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/soap_client.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/soap_client.rb deleted file mode 100644 index ebabd8ea..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/soap_client.rb +++ /dev/null @@ -1,113 +0,0 @@ -require 'soap/rpc/driver' -require 'uri' - -module ActionWebService # :nodoc: - module Client # :nodoc: - - # Implements SOAP client support (using RPC encoding for the messages). - # - # ==== Example Usage - # - # class PersonAPI < ActionWebService::API::Base - # api_method :find_all, :returns => [[Person]] - # end - # - # soap_client = ActionWebService::Client::Soap.new(PersonAPI, "http://...") - # persons = soap_client.find_all - # - class Soap < Base - # provides access to the underlying soap driver - attr_reader :driver - - # Creates a new web service client using the SOAP RPC protocol. - # - # +api+ must be an ActionWebService::API::Base derivative, and - # +endpoint_uri+ must point at the relevant URL to which protocol requests - # will be sent with HTTP POST. - # - # Valid options: - # [:namespace] If the remote server has used a custom namespace to - # declare its custom types, you can specify it here. This would - # be the namespace declared with a [WebService(Namespace = "http://namespace")] attribute - # in .NET, for example. - # [:driver_options] If you want to supply any custom SOAP RPC driver - # options, you can provide them as a Hash here - # - # The :driver_options option can be used to configure the backend SOAP - # RPC driver. An example of configuring the SOAP backend to do - # client-certificate authenticated SSL connections to the server: - # - # opts = {} - # opts['protocol.http.ssl_config.verify_mode'] = 'OpenSSL::SSL::VERIFY_PEER' - # opts['protocol.http.ssl_config.client_cert'] = client_cert_file_path - # opts['protocol.http.ssl_config.client_key'] = client_key_file_path - # opts['protocol.http.ssl_config.ca_file'] = ca_cert_file_path - # client = ActionWebService::Client::Soap.new(api, 'https://some/service', :driver_options => opts) - def initialize(api, endpoint_uri, options={}) - super(api, endpoint_uri) - @namespace = options[:namespace] || 'urn:ActionWebService' - @driver_options = options[:driver_options] || {} - @protocol = ActionWebService::Protocol::Soap::SoapProtocol.new @namespace - @soap_action_base = options[:soap_action_base] - @soap_action_base ||= URI.parse(endpoint_uri).path - @driver = create_soap_rpc_driver(api, endpoint_uri) - @driver_options.each do |name, value| - @driver.options[name.to_s] = value - end - end - - protected - def perform_invocation(method_name, args) - method = @api.api_methods[method_name.to_sym] - args = method.cast_expects(args.dup) rescue args - return_value = @driver.send(method_name, *args) - method.cast_returns(return_value.dup) rescue return_value - end - - def soap_action(method_name) - "#{@soap_action_base}/#{method_name}" - end - - private - def create_soap_rpc_driver(api, endpoint_uri) - @protocol.register_api(api) - driver = SoapDriver.new(endpoint_uri, nil) - driver.mapping_registry = @protocol.marshaler.registry - api.api_methods.each do |name, method| - qname = XSD::QName.new(@namespace, method.public_name) - action = soap_action(method.public_name) - expects = method.expects - returns = method.returns - param_def = [] - if expects - expects.each do |type| - type_binding = @protocol.marshaler.lookup_type(type) - if SOAP::Version >= "1.5.5" - param_def << ['in', type.name.to_s, [type_binding.type.type_class.to_s]] - else - param_def << ['in', type.name, type_binding.mapping] - end - end - end - if returns - type_binding = @protocol.marshaler.lookup_type(returns[0]) - if SOAP::Version >= "1.5.5" - param_def << ['retval', 'return', [type_binding.type.type_class.to_s]] - else - param_def << ['retval', 'return', type_binding.mapping] - end - end - driver.add_method(qname, action, method.name.to_s, param_def) - end - driver - end - - class SoapDriver < SOAP::RPC::Driver # :nodoc: - def add_method(qname, soapaction, name, param_def) - @proxy.add_rpc_method(qname, soapaction, name, param_def) - add_rpc_method_interface(name, param_def) - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/xmlrpc_client.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/xmlrpc_client.rb deleted file mode 100644 index 42b5c5d4..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/xmlrpc_client.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'uri' -require 'xmlrpc/client' - -module ActionWebService # :nodoc: - module Client # :nodoc: - - # Implements XML-RPC client support - # - # ==== Example Usage - # - # class BloggerAPI < ActionWebService::API::Base - # inflect_names false - # api_method :getRecentPosts, :returns => [[Blog::Post]] - # end - # - # blog = ActionWebService::Client::XmlRpc.new(BloggerAPI, "http://.../RPC", :handler_name => "blogger") - # posts = blog.getRecentPosts - class XmlRpc < Base - - # Creates a new web service client using the XML-RPC protocol. - # - # +api+ must be an ActionWebService::API::Base derivative, and - # +endpoint_uri+ must point at the relevant URL to which protocol requests - # will be sent with HTTP POST. - # - # Valid options: - # [:handler_name] If the remote server defines its services inside special - # handler (the Blogger API uses a "blogger" handler name for example), - # provide it here, or your method calls will fail - def initialize(api, endpoint_uri, options={}) - @api = api - @handler_name = options[:handler_name] - @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.new - @client = XMLRPC::Client.new2(endpoint_uri, options[:proxy], options[:timeout]) - end - - protected - def perform_invocation(method_name, args) - method = @api.api_methods[method_name.to_sym] - if method.expects && method.expects.length != args.length - raise(ArgumentError, "#{method.public_name}: wrong number of arguments (#{args.length} for #{method.expects.length})") - end - args = method.cast_expects(args.dup) rescue args - if method.expects - method.expects.each_with_index{ |type, i| args[i] = @protocol.value_to_xmlrpc_wire_format(args[i], type) } - end - ok, return_value = @client.call2(public_name(method_name), *args) - return (method.cast_returns(return_value.dup) rescue return_value) if ok - raise(ClientError, "#{return_value.faultCode}: #{return_value.faultString}") - end - - def public_name(method_name) - public_name = @api.public_api_method_name(method_name) - @handler_name ? "#{@handler_name}.#{public_name}" : public_name - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container.rb deleted file mode 100644 index 13d9d8ab..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'action_web_service/container/direct_container' -require 'action_web_service/container/delegated_container' -require 'action_web_service/container/action_controller_container' diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/action_controller_container.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/action_controller_container.rb deleted file mode 100644 index bbc28083..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/action_controller_container.rb +++ /dev/null @@ -1,93 +0,0 @@ -module ActionWebService # :nodoc: - module Container # :nodoc: - module ActionController # :nodoc: - def self.included(base) # :nodoc: - class << base - include ClassMethods - alias_method_chain :inherited, :api - alias_method_chain :web_service_api, :require - end - end - - module ClassMethods - # Creates a client for accessing remote web services, using the - # given +protocol+ to communicate with the +endpoint_uri+. - # - # ==== Example - # - # class MyController < ActionController::Base - # web_client_api :blogger, :xmlrpc, "http://blogger.com/myblog/api/RPC2", :handler_name => 'blogger' - # end - # - # In this example, a protected method named blogger will - # now exist on the controller, and calling it will return the - # XML-RPC client object for working with that remote service. - # - # +options+ is the set of protocol client specific options (see - # a protocol client class for details). - # - # If your API definition does not exist on the load path with the - # correct rules for it to be found using +name+, you can pass in - # the API definition class via +options+, using a key of :api - def web_client_api(name, protocol, endpoint_uri, options={}) - unless method_defined?(name) - api_klass = options.delete(:api) || require_web_service_api(name) - class_eval do - define_method(name) do - create_web_service_client(api_klass, protocol, endpoint_uri, options) - end - protected name - end - end - end - - def web_service_api_with_require(definition=nil) # :nodoc: - return web_service_api_without_require if definition.nil? - case definition - when String, Symbol - klass = require_web_service_api(definition) - else - klass = definition - end - web_service_api_without_require(klass) - end - - def require_web_service_api(name) # :nodoc: - case name - when String, Symbol - file_name = name.to_s.underscore + "_api" - class_name = file_name.camelize - class_names = [class_name, class_name.sub(/Api$/, 'API')] - begin - require_dependency(file_name) - rescue LoadError => load_error - requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] - msg = requiree == file_name ? "Missing API definition file in apis/#{file_name}.rb" : "Can't load file: #{requiree}" - raise LoadError.new(msg).copy_blame!(load_error) - end - klass = nil - class_names.each do |name| - klass = name.constantize rescue nil - break unless klass.nil? - end - unless klass - raise(NameError, "neither #{class_names[0]} or #{class_names[1]} found") - end - klass - else - raise(ArgumentError, "expected String or Symbol argument") - end - end - - private - def inherited_with_api(child) - inherited_without_api(child) - begin child.web_service_api(child.controller_path) - rescue MissingSourceFile => e - raise unless e.is_missing?("apis/#{child.controller_path}_api") - end - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/delegated_container.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/delegated_container.rb deleted file mode 100644 index 5477f8d1..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/delegated_container.rb +++ /dev/null @@ -1,86 +0,0 @@ -module ActionWebService # :nodoc: - module Container # :nodoc: - module Delegated # :nodoc: - class ContainerError < ActionWebServiceError # :nodoc: - end - - def self.included(base) # :nodoc: - base.extend(ClassMethods) - base.send(:include, ActionWebService::Container::Delegated::InstanceMethods) - end - - module ClassMethods - # Declares a web service that will provide access to the API of the given - # +object+. +object+ must be an ActionWebService::Base derivative. - # - # Web service object creation can either be _immediate_, where the object - # instance is given at class definition time, or _deferred_, where - # object instantiation is delayed until request time. - # - # ==== Immediate web service object example - # - # class ApiController < ApplicationController - # web_service_dispatching_mode :delegated - # - # web_service :person, PersonService.new - # end - # - # For deferred instantiation, a block should be given instead of an - # object instance. This block will be executed in controller instance - # context, so it can rely on controller instance variables being present. - # - # ==== Deferred web service object example - # - # class ApiController < ApplicationController - # web_service_dispatching_mode :delegated - # - # web_service(:person) { PersonService.new(request.env) } - # end - def web_service(name, object=nil, &block) - if (object && block_given?) || (object.nil? && block.nil?) - raise(ContainerError, "either service, or a block must be given") - end - name = name.to_sym - if block_given? - info = { name => { :block => block } } - else - info = { name => { :object => object } } - end - write_inheritable_hash("web_services", info) - call_web_service_definition_callbacks(self, name, info) - end - - # Whether this service contains a service with the given +name+ - def has_web_service?(name) - web_services.has_key?(name.to_sym) - end - - def web_services # :nodoc: - read_inheritable_attribute("web_services") || {} - end - - def add_web_service_definition_callback(&block) # :nodoc: - write_inheritable_array("web_service_definition_callbacks", [block]) - end - - private - def call_web_service_definition_callbacks(container_class, web_service_name, service_info) - (read_inheritable_attribute("web_service_definition_callbacks") || []).each do |block| - block.call(container_class, web_service_name, service_info) - end - end - end - - module InstanceMethods # :nodoc: - def web_service_object(web_service_name) - info = self.class.web_services[web_service_name.to_sym] - unless info - raise(ContainerError, "no such web service '#{web_service_name}'") - end - service = info[:block] - service ? self.instance_eval(&service) : info[:object] - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/direct_container.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/direct_container.rb deleted file mode 100644 index 8818d8f4..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/container/direct_container.rb +++ /dev/null @@ -1,69 +0,0 @@ -module ActionWebService # :nodoc: - module Container # :nodoc: - module Direct # :nodoc: - class ContainerError < ActionWebServiceError # :nodoc: - end - - def self.included(base) # :nodoc: - base.extend(ClassMethods) - end - - module ClassMethods - # Attaches ActionWebService API +definition+ to the calling class. - # - # Action Controllers can have a default associated API, removing the need - # to call this method if you follow the Action Web Service naming conventions. - # - # A controller with a class name of GoogleSearchController will - # implicitly load app/apis/google_search_api.rb, and expect the - # API definition class to be named GoogleSearchAPI or - # GoogleSearchApi. - # - # ==== Service class example - # - # class MyService < ActionWebService::Base - # web_service_api MyAPI - # end - # - # class MyAPI < ActionWebService::API::Base - # ... - # end - # - # ==== Controller class example - # - # class MyController < ActionController::Base - # web_service_api MyAPI - # end - # - # class MyAPI < ActionWebService::API::Base - # ... - # end - def web_service_api(definition=nil) - if definition.nil? - read_inheritable_attribute("web_service_api") - else - if definition.is_a?(Symbol) - raise(ContainerError, "symbols can only be used for #web_service_api inside of a controller") - end - unless definition.respond_to?(:ancestors) && definition.ancestors.include?(ActionWebService::API::Base) - raise(ContainerError, "#{definition.to_s} is not a valid API definition") - end - write_inheritable_attribute("web_service_api", definition) - call_web_service_api_callbacks(self, definition) - end - end - - def add_web_service_api_callback(&block) # :nodoc: - write_inheritable_array("web_service_api_callbacks", [block]) - end - - private - def call_web_service_api_callbacks(container_class, definition) - (read_inheritable_attribute("web_service_api_callbacks") || []).each do |block| - block.call(container_class, definition) - end - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher.rb deleted file mode 100644 index 601d8313..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'action_web_service/dispatcher/abstract' -require 'action_web_service/dispatcher/action_controller_dispatcher' diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher/abstract.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher/abstract.rb deleted file mode 100644 index cb94d649..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher/abstract.rb +++ /dev/null @@ -1,207 +0,0 @@ -require 'benchmark' - -module ActionWebService # :nodoc: - module Dispatcher # :nodoc: - class DispatcherError < ActionWebService::ActionWebServiceError # :nodoc: - def initialize(*args) - super - set_backtrace(caller) - end - end - - def self.included(base) # :nodoc: - base.class_inheritable_option(:web_service_dispatching_mode, :direct) - base.class_inheritable_option(:web_service_exception_reporting, true) - base.send(:include, ActionWebService::Dispatcher::InstanceMethods) - end - - module InstanceMethods # :nodoc: - private - def invoke_web_service_request(protocol_request) - invocation = web_service_invocation(protocol_request) - if invocation.is_a?(Array) && protocol_request.protocol.is_a?(Protocol::XmlRpc::XmlRpcProtocol) - xmlrpc_multicall_invoke(invocation) - else - web_service_invoke(invocation) - end - end - - def web_service_direct_invoke(invocation) - @method_params = invocation.method_ordered_params - arity = method(invocation.api_method.name).arity rescue 0 - if arity < 0 || arity > 0 - params = @method_params - else - params = [] - end - web_service_filtered_invoke(invocation, params) - end - - def web_service_delegated_invoke(invocation) - web_service_filtered_invoke(invocation, invocation.method_ordered_params) - end - - def web_service_filtered_invoke(invocation, params) - cancellation_reason = nil - return_value = invocation.service.perform_invocation(invocation.api_method.name, params) do |x| - cancellation_reason = x - end - if cancellation_reason - raise(DispatcherError, "request canceled: #{cancellation_reason}") - end - return_value - end - - def web_service_invoke(invocation) - case web_service_dispatching_mode - when :direct - return_value = web_service_direct_invoke(invocation) - when :delegated, :layered - return_value = web_service_delegated_invoke(invocation) - end - web_service_create_response(invocation.protocol, invocation.protocol_options, invocation.api, invocation.api_method, return_value) - end - - def xmlrpc_multicall_invoke(invocations) - responses = [] - invocations.each do |invocation| - if invocation.is_a?(Hash) - responses << [invocation, nil] - next - end - begin - case web_service_dispatching_mode - when :direct - return_value = web_service_direct_invoke(invocation) - when :delegated, :layered - return_value = web_service_delegated_invoke(invocation) - end - api_method = invocation.api_method - if invocation.api.has_api_method?(api_method.name) - response_type = (api_method.returns ? api_method.returns[0] : nil) - return_value = api_method.cast_returns(return_value) - else - response_type = ActionWebService::SignatureTypes.canonical_signature_entry(return_value.class, 0) - end - responses << [return_value, response_type] - rescue Exception => e - responses << [{ 'faultCode' => 3, 'faultString' => e.message }, nil] - end - end - invocation = invocations[0] - invocation.protocol.encode_multicall_response(responses, invocation.protocol_options) - end - - def web_service_invocation(request, level = 0) - public_method_name = request.method_name - invocation = Invocation.new - invocation.protocol = request.protocol - invocation.protocol_options = request.protocol_options - invocation.service_name = request.service_name - if web_service_dispatching_mode == :layered - case invocation.protocol - when Protocol::Soap::SoapProtocol - soap_action = request.protocol_options[:soap_action] - if soap_action && soap_action =~ /^\/\w+\/(\w+)\// - invocation.service_name = $1 - end - when Protocol::XmlRpc::XmlRpcProtocol - if request.method_name =~ /^([^\.]+)\.(.*)$/ - public_method_name = $2 - invocation.service_name = $1 - end - end - end - if invocation.protocol.is_a? Protocol::XmlRpc::XmlRpcProtocol - if public_method_name == 'multicall' && invocation.service_name == 'system' - if level > 0 - raise(DispatcherError, "Recursive system.multicall invocations not allowed") - end - multicall = request.method_params.dup - unless multicall.is_a?(Array) && multicall[0].is_a?(Array) - raise(DispatcherError, "Malformed multicall (expected array of Hash elements)") - end - multicall = multicall[0] - return multicall.map do |item| - raise(DispatcherError, "Multicall elements must be Hash") unless item.is_a?(Hash) - raise(DispatcherError, "Multicall elements must contain a 'methodName' key") unless item.has_key?('methodName') - method_name = item['methodName'] - params = item.has_key?('params') ? item['params'] : [] - multicall_request = request.dup - multicall_request.method_name = method_name - multicall_request.method_params = params - begin - web_service_invocation(multicall_request, level + 1) - rescue Exception => e - {'faultCode' => 4, 'faultMessage' => e.message} - end - end - end - end - case web_service_dispatching_mode - when :direct - invocation.api = self.class.web_service_api - invocation.service = self - when :delegated, :layered - invocation.service = web_service_object(invocation.service_name) - invocation.api = invocation.service.class.web_service_api - end - if invocation.api.nil? - raise(DispatcherError, "no API attached to #{invocation.service.class}") - end - invocation.protocol.register_api(invocation.api) - request.api = invocation.api - if invocation.api.has_public_api_method?(public_method_name) - invocation.api_method = invocation.api.public_api_method_instance(public_method_name) - else - if invocation.api.default_api_method.nil? - raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api}") - else - invocation.api_method = invocation.api.default_api_method_instance - end - end - if invocation.service.nil? - raise(DispatcherError, "no service available for service name #{invocation.service_name}") - end - unless invocation.service.respond_to?(invocation.api_method.name) - raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api} (#{invocation.api_method.name})") - end - request.api_method = invocation.api_method - begin - invocation.method_ordered_params = invocation.api_method.cast_expects(request.method_params.dup) - rescue - logger.warn "Casting of method parameters failed" unless logger.nil? - invocation.method_ordered_params = request.method_params - end - request.method_params = invocation.method_ordered_params - invocation.method_named_params = {} - invocation.api_method.param_names.inject(0) do |m, n| - invocation.method_named_params[n] = invocation.method_ordered_params[m] - m + 1 - end - invocation - end - - def web_service_create_response(protocol, protocol_options, api, api_method, return_value) - if api.has_api_method?(api_method.name) - return_type = api_method.returns ? api_method.returns[0] : nil - return_value = api_method.cast_returns(return_value) - else - return_type = ActionWebService::SignatureTypes.canonical_signature_entry(return_value.class, 0) - end - protocol.encode_response(api_method.public_name + 'Response', return_value, return_type, protocol_options) - end - - class Invocation # :nodoc: - attr_accessor :protocol - attr_accessor :protocol_options - attr_accessor :service_name - attr_accessor :api - attr_accessor :api_method - attr_accessor :method_ordered_params - attr_accessor :method_named_params - attr_accessor :service - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher/action_controller_dispatcher.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher/action_controller_dispatcher.rb deleted file mode 100644 index 160ed0ab..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +++ /dev/null @@ -1,379 +0,0 @@ -require 'benchmark' -require 'builder/xmlmarkup' - -module ActionWebService # :nodoc: - module Dispatcher # :nodoc: - module ActionController # :nodoc: - def self.included(base) # :nodoc: - class << base - include ClassMethods - alias_method_chain :inherited, :action_controller - end - base.class_eval do - alias_method :web_service_direct_invoke_without_controller, :web_service_direct_invoke - end - base.add_web_service_api_callback do |klass, api| - if klass.web_service_dispatching_mode == :direct - klass.class_eval 'def api; dispatch_web_service_request; end' - end - end - base.add_web_service_definition_callback do |klass, name, info| - if klass.web_service_dispatching_mode == :delegated - klass.class_eval "def #{name}; dispatch_web_service_request; end" - elsif klass.web_service_dispatching_mode == :layered - klass.class_eval 'def api; dispatch_web_service_request; end' - end - end - base.send(:include, ActionWebService::Dispatcher::ActionController::InstanceMethods) - end - - module ClassMethods # :nodoc: - def inherited_with_action_controller(child) - inherited_without_action_controller(child) - child.send(:include, ActionWebService::Dispatcher::ActionController::WsdlAction) - end - end - - module InstanceMethods # :nodoc: - private - def dispatch_web_service_request - method = request.method.to_s.upcase - allowed_methods = self.class.web_service_api ? (self.class.web_service_api.allowed_http_methods || []) : [ :post ] - allowed_methods = allowed_methods.map{|m| m.to_s.upcase } - if !allowed_methods.include?(method) - render :text => "#{method} not supported", :status=>500 - return - end - exception = nil - begin - ws_request = discover_web_service_request(request) - rescue Exception => e - exception = e - end - if ws_request - ws_response = nil - exception = nil - bm = Benchmark.measure do - begin - ws_response = invoke_web_service_request(ws_request) - rescue Exception => e - exception = e - end - end - log_request(ws_request, request.raw_post) - if exception - log_error(exception) unless logger.nil? - send_web_service_error_response(ws_request, exception) - else - send_web_service_response(ws_response, bm.real) - end - else - exception ||= DispatcherError.new("Malformed SOAP or XML-RPC protocol message") - log_error(exception) unless logger.nil? - send_web_service_error_response(ws_request, exception) - end - rescue Exception => e - log_error(e) unless logger.nil? - send_web_service_error_response(ws_request, e) - end - - def send_web_service_response(ws_response, elapsed=nil) - log_response(ws_response, elapsed) - options = { :type => ws_response.content_type, :disposition => 'inline' } - send_data(ws_response.body, options) - end - - def send_web_service_error_response(ws_request, exception) - if ws_request - unless self.class.web_service_exception_reporting - exception = DispatcherError.new("Internal server error (exception raised)") - end - api_method = ws_request.api_method - public_method_name = api_method ? api_method.public_name : ws_request.method_name - return_type = ActionWebService::SignatureTypes.canonical_signature_entry(Exception, 0) - ws_response = ws_request.protocol.encode_response(public_method_name + 'Response', exception, return_type, ws_request.protocol_options) - send_web_service_response(ws_response) - else - if self.class.web_service_exception_reporting - message = exception.message - backtrace = "\nBacktrace:\n#{exception.backtrace.join("\n")}" - else - message = "Exception raised" - backtrace = "" - end - render :status => 500, :text => "Internal protocol error: #{message}#{backtrace}" - end - end - - def web_service_direct_invoke(invocation) - invocation.method_named_params.each do |name, value| - params[name] = value - end - web_service_direct_invoke_without_controller(invocation) - end - - def log_request(ws_request, body) - unless logger.nil? - name = ws_request.method_name - api_method = ws_request.api_method - params = ws_request.method_params - if api_method && api_method.expects - params = api_method.expects.zip(params).map{ |type, param| "#{type.name}=>#{param.inspect}" } - else - params = params.map{ |param| param.inspect } - end - service = ws_request.service_name - logger.debug("\nWeb Service Request: #{name}(#{params.join(", ")}) Entrypoint: #{service}") - logger.debug(indent(body)) - end - end - - def log_response(ws_response, elapsed=nil) - unless logger.nil? - elapsed = (elapsed ? " (%f):" % elapsed : ":") - logger.debug("\nWeb Service Response" + elapsed + " => #{ws_response.return_value.inspect}") - logger.debug(indent(ws_response.body)) - end - end - - def indent(body) - body.split(/\n/).map{|x| " #{x}"}.join("\n") - end - end - - module WsdlAction # :nodoc: - XsdNs = 'http://www.w3.org/2001/XMLSchema' - WsdlNs = 'http://schemas.xmlsoap.org/wsdl/' - SoapNs = 'http://schemas.xmlsoap.org/wsdl/soap/' - SoapEncodingNs = 'http://schemas.xmlsoap.org/soap/encoding/' - SoapHttpTransport = 'http://schemas.xmlsoap.org/soap/http' - - def wsdl - case request.method - when :get - begin - options = { :type => 'text/xml', :disposition => 'inline' } - send_data(to_wsdl, options) - rescue Exception => e - log_error(e) unless logger.nil? - end - when :post - render :status => 500, :text => 'POST not supported' - end - end - - private - def base_uri - host = request.host_with_port - relative_url_root = ::ActionController::Base.relative_url_root - scheme = request.ssl? ? 'https' : 'http' - '%s://%s%s/%s/' % [scheme, host, relative_url_root, self.class.controller_path] - end - - def to_wsdl - xml = '' - dispatching_mode = web_service_dispatching_mode - global_service_name = wsdl_service_name - namespace = wsdl_namespace || 'urn:ActionWebService' - soap_action_base = "/#{controller_name}" - - marshaler = ActionWebService::Protocol::Soap::SoapMarshaler.new(namespace) - apis = {} - case dispatching_mode - when :direct - api = self.class.web_service_api - web_service_name = controller_class_name.sub(/Controller$/, '').underscore - apis[web_service_name] = [api, register_api(api, marshaler)] - when :delegated, :layered - self.class.web_services.each do |web_service_name, info| - service = web_service_object(web_service_name) - api = service.class.web_service_api - apis[web_service_name] = [api, register_api(api, marshaler)] - end - end - custom_types = [] - apis.values.each do |api, bindings| - bindings.each do |b| - custom_types << b unless custom_types.include?(b) - end - end - - xm = Builder::XmlMarkup.new(:target => xml, :indent => 2) - xm.instruct! - xm.definitions('name' => wsdl_service_name, - 'targetNamespace' => namespace, - 'xmlns:typens' => namespace, - 'xmlns:xsd' => XsdNs, - 'xmlns:soap' => SoapNs, - 'xmlns:soapenc' => SoapEncodingNs, - 'xmlns:wsdl' => WsdlNs, - 'xmlns' => WsdlNs) do - # Generate XSD - if custom_types.size > 0 - xm.types do - xm.xsd(:schema, 'xmlns' => XsdNs, 'targetNamespace' => namespace) do - custom_types.each do |binding| - case - when binding.type.array? - xm.xsd(:complexType, 'name' => binding.type_name) do - xm.xsd(:complexContent) do - xm.xsd(:restriction, 'base' => 'soapenc:Array') do - xm.xsd(:attribute, 'ref' => 'soapenc:arrayType', - 'wsdl:arrayType' => binding.element_binding.qualified_type_name('typens') + '[]') - end - end - end - when binding.type.structured? - xm.xsd(:complexType, 'name' => binding.type_name) do - xm.xsd(:all) do - binding.type.each_member do |name, type| - b = marshaler.register_type(type) - xm.xsd(:element, 'name' => name, 'type' => b.qualified_type_name('typens')) - end - end - end - end - end - end - end - end - - # APIs - apis.each do |api_name, values| - api = values[0] - api.api_methods.each do |name, method| - gen = lambda do |msg_name, direction| - xm.message('name' => message_name_for(api_name, msg_name)) do - sym = nil - if direction == :out - returns = method.returns - if returns - binding = marshaler.register_type(returns[0]) - xm.part('name' => 'return', 'type' => binding.qualified_type_name('typens')) - end - else - expects = method.expects - expects.each do |type| - binding = marshaler.register_type(type) - xm.part('name' => type.name, 'type' => binding.qualified_type_name('typens')) - end if expects - end - end - end - public_name = method.public_name - gen.call(public_name, :in) - gen.call("#{public_name}Response", :out) - end - - # Port - port_name = port_name_for(global_service_name, api_name) - xm.portType('name' => port_name) do - api.api_methods.each do |name, method| - xm.operation('name' => method.public_name) do - xm.input('message' => "typens:" + message_name_for(api_name, method.public_name)) - xm.output('message' => "typens:" + message_name_for(api_name, "#{method.public_name}Response")) - end - end - end - - # Bind it - binding_name = binding_name_for(global_service_name, api_name) - xm.binding('name' => binding_name, 'type' => "typens:#{port_name}") do - xm.soap(:binding, 'style' => 'rpc', 'transport' => SoapHttpTransport) - api.api_methods.each do |name, method| - xm.operation('name' => method.public_name) do - case web_service_dispatching_mode - when :direct - soap_action = soap_action_base + "/api/" + method.public_name - when :delegated, :layered - soap_action = soap_action_base \ - + "/" + api_name.to_s \ - + "/" + method.public_name - end - xm.soap(:operation, 'soapAction' => soap_action) - xm.input do - xm.soap(:body, - 'use' => 'encoded', - 'namespace' => namespace, - 'encodingStyle' => SoapEncodingNs) - end - xm.output do - xm.soap(:body, - 'use' => 'encoded', - 'namespace' => namespace, - 'encodingStyle' => SoapEncodingNs) - end - end - end - end - end - - # Define it - xm.service('name' => "#{global_service_name}Service") do - apis.each do |api_name, values| - port_name = port_name_for(global_service_name, api_name) - binding_name = binding_name_for(global_service_name, api_name) - case web_service_dispatching_mode - when :direct, :layered - binding_target = 'api' - when :delegated - binding_target = api_name.to_s - end - xm.port('name' => port_name, 'binding' => "typens:#{binding_name}") do - xm.soap(:address, 'location' => "#{base_uri}#{binding_target}") - end - end - end - end - end - - def port_name_for(global_service, service) - "#{global_service}#{service.to_s.camelize}Port" - end - - def binding_name_for(global_service, service) - "#{global_service}#{service.to_s.camelize}Binding" - end - - def message_name_for(api_name, message_name) - mode = web_service_dispatching_mode - if mode == :layered || mode == :delegated - api_name.to_s + '-' + message_name - else - message_name - end - end - - def register_api(api, marshaler) - bindings = {} - traverse_custom_types(api, marshaler, bindings) do |binding| - bindings[binding] = nil unless bindings.has_key?(binding) - element_binding = binding.element_binding - bindings[element_binding] = nil if element_binding && !bindings.has_key?(element_binding) - end - bindings.keys - end - - def traverse_custom_types(api, marshaler, bindings, &block) - api.api_methods.each do |name, method| - expects, returns = method.expects, method.returns - expects.each{ |type| traverse_type(marshaler, type, bindings, &block) if type.custom? } if expects - returns.each{ |type| traverse_type(marshaler, type, bindings, &block) if type.custom? } if returns - end - end - - def traverse_type(marshaler, type, bindings, &block) - binding = marshaler.register_type(type) - return if bindings.has_key?(binding) - bindings[binding] = nil - yield binding - if type.array? - yield marshaler.register_type(type.element_type) - type = type.element_type - end - type.each_member{ |name, type| traverse_type(marshaler, type, bindings, &block) } if type.structured? - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/invocation.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/invocation.rb deleted file mode 100644 index 2a9121ee..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/invocation.rb +++ /dev/null @@ -1,202 +0,0 @@ -module ActionWebService # :nodoc: - module Invocation # :nodoc: - class InvocationError < ActionWebService::ActionWebServiceError # :nodoc: - end - - def self.included(base) # :nodoc: - base.extend(ClassMethods) - base.send(:include, ActionWebService::Invocation::InstanceMethods) - end - - # Invocation interceptors provide a means to execute custom code before - # and after method invocations on ActionWebService::Base objects. - # - # When running in _Direct_ dispatching mode, ActionController filters - # should be used for this functionality instead. - # - # The semantics of invocation interceptors are the same as ActionController - # filters, and accept the same parameters and options. - # - # A _before_ interceptor can also cancel execution by returning +false+, - # or returning a [false, "cancel reason"] array if it wishes to supply - # a reason for canceling the request. - # - # === Example - # - # class CustomService < ActionWebService::Base - # before_invocation :intercept_add, :only => [:add] - # - # def add(a, b) - # a + b - # end - # - # private - # def intercept_add - # return [false, "permission denied"] # cancel it - # end - # end - # - # Options: - # [:except] A list of methods for which the interceptor will NOT be called - # [:only] A list of methods for which the interceptor WILL be called - module ClassMethods - # Appends the given +interceptors+ to be called - # _before_ method invocation. - def append_before_invocation(*interceptors, &block) - conditions = extract_conditions!(interceptors) - interceptors << block if block_given? - add_interception_conditions(interceptors, conditions) - append_interceptors_to_chain("before", interceptors) - end - - # Prepends the given +interceptors+ to be called - # _before_ method invocation. - def prepend_before_invocation(*interceptors, &block) - conditions = extract_conditions!(interceptors) - interceptors << block if block_given? - add_interception_conditions(interceptors, conditions) - prepend_interceptors_to_chain("before", interceptors) - end - - alias :before_invocation :append_before_invocation - - # Appends the given +interceptors+ to be called - # _after_ method invocation. - def append_after_invocation(*interceptors, &block) - conditions = extract_conditions!(interceptors) - interceptors << block if block_given? - add_interception_conditions(interceptors, conditions) - append_interceptors_to_chain("after", interceptors) - end - - # Prepends the given +interceptors+ to be called - # _after_ method invocation. - def prepend_after_invocation(*interceptors, &block) - conditions = extract_conditions!(interceptors) - interceptors << block if block_given? - add_interception_conditions(interceptors, conditions) - prepend_interceptors_to_chain("after", interceptors) - end - - alias :after_invocation :append_after_invocation - - def before_invocation_interceptors # :nodoc: - read_inheritable_attribute("before_invocation_interceptors") - end - - def after_invocation_interceptors # :nodoc: - read_inheritable_attribute("after_invocation_interceptors") - end - - def included_intercepted_methods # :nodoc: - read_inheritable_attribute("included_intercepted_methods") || {} - end - - def excluded_intercepted_methods # :nodoc: - read_inheritable_attribute("excluded_intercepted_methods") || {} - end - - private - def append_interceptors_to_chain(condition, interceptors) - write_inheritable_array("#{condition}_invocation_interceptors", interceptors) - end - - def prepend_interceptors_to_chain(condition, interceptors) - interceptors = interceptors + read_inheritable_attribute("#{condition}_invocation_interceptors") - write_inheritable_attribute("#{condition}_invocation_interceptors", interceptors) - end - - def extract_conditions!(interceptors) - return nil unless interceptors.last.is_a? Hash - interceptors.pop - end - - def add_interception_conditions(interceptors, conditions) - return unless conditions - included, excluded = conditions[:only], conditions[:except] - write_inheritable_hash("included_intercepted_methods", condition_hash(interceptors, included)) && return if included - write_inheritable_hash("excluded_intercepted_methods", condition_hash(interceptors, excluded)) if excluded - end - - def condition_hash(interceptors, *methods) - interceptors.inject({}) {|hash, interceptor| hash.merge(interceptor => methods.flatten.map {|method| method.to_s})} - end - end - - module InstanceMethods # :nodoc: - def self.included(base) - base.class_eval do - alias_method_chain :perform_invocation, :interception - end - end - - def perform_invocation_with_interception(method_name, params, &block) - return if before_invocation(method_name, params, &block) == false - return_value = perform_invocation_without_interception(method_name, params) - after_invocation(method_name, params, return_value) - return_value - end - - def perform_invocation(method_name, params) - send(method_name, *params) - end - - def before_invocation(name, args, &block) - call_interceptors(self.class.before_invocation_interceptors, [name, args], &block) - end - - def after_invocation(name, args, result) - call_interceptors(self.class.after_invocation_interceptors, [name, args, result]) - end - - private - - def call_interceptors(interceptors, interceptor_args, &block) - if interceptors and not interceptors.empty? - interceptors.each do |interceptor| - next if method_exempted?(interceptor, interceptor_args[0].to_s) - result = case - when interceptor.is_a?(Symbol) - self.send(interceptor, *interceptor_args) - when interceptor_block?(interceptor) - interceptor.call(self, *interceptor_args) - when interceptor_class?(interceptor) - interceptor.intercept(self, *interceptor_args) - else - raise( - InvocationError, - "Interceptors need to be either a symbol, proc/method, or a class implementing a static intercept method" - ) - end - reason = nil - if result.is_a?(Array) - reason = result[1] if result[1] - result = result[0] - end - if result == false - block.call(reason) if block && reason - return false - end - end - end - end - - def interceptor_block?(interceptor) - interceptor.respond_to?("call") && (interceptor.arity == 3 || interceptor.arity == -1) - end - - def interceptor_class?(interceptor) - interceptor.respond_to?("intercept") - end - - def method_exempted?(interceptor, method_name) - case - when self.class.included_intercepted_methods[interceptor] - !self.class.included_intercepted_methods[interceptor].include?(method_name) - when self.class.excluded_intercepted_methods[interceptor] - self.class.excluded_intercepted_methods[interceptor].include?(method_name) - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol.rb deleted file mode 100644 index 053e9cb4..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'action_web_service/protocol/abstract' -require 'action_web_service/protocol/discovery' -require 'action_web_service/protocol/soap_protocol' -require 'action_web_service/protocol/xmlrpc_protocol' diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/abstract.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/abstract.rb deleted file mode 100644 index 5c837bc8..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/abstract.rb +++ /dev/null @@ -1,112 +0,0 @@ -module ActionWebService # :nodoc: - module Protocol # :nodoc: - class ProtocolError < ActionWebServiceError # :nodoc: - end - - class AbstractProtocol # :nodoc: - def setup(controller) - end - - def decode_action_pack_request(action_pack_request) - end - - def encode_action_pack_request(service_name, public_method_name, raw_body, options={}) - klass = options[:request_class] || SimpleActionPackRequest - request = klass.new({}) - request.request_parameters['action'] = service_name.to_s - request.env['RAW_POST_DATA'] = raw_body - request.env['REQUEST_METHOD'] = 'POST' - request.env['HTTP_CONTENT_TYPE'] = 'text/xml' - request - end - - def decode_request(raw_request, service_name, protocol_options={}) - end - - def encode_request(method_name, params, param_types) - end - - def decode_response(raw_response) - end - - def encode_response(method_name, return_value, return_type, protocol_options={}) - end - - def protocol_client(api, protocol_name, endpoint_uri, options) - end - - def register_api(api) - end - end - - class Request # :nodoc: - attr :protocol - attr_accessor :method_name - attr_accessor :method_params - attr :service_name - attr_accessor :api - attr_accessor :api_method - attr :protocol_options - - def initialize(protocol, method_name, method_params, service_name, api=nil, api_method=nil, protocol_options=nil) - @protocol = protocol - @method_name = method_name - @method_params = method_params - @service_name = service_name - @api = api - @api_method = api_method - @protocol_options = protocol_options || {} - end - end - - class Response # :nodoc: - attr :body - attr :content_type - attr :return_value - - def initialize(body, content_type, return_value) - @body = body - @content_type = content_type - @return_value = return_value - end - end - - class SimpleActionPackRequest < ActionController::Request # :nodoc: - def initialize(env = {}) - @env = env - @qparams = {} - @rparams = {} - @cookies = {} - reset_session - end - - def query_parameters - @qparams - end - - def request_parameters - @rparams - end - - def env - @env - end - - def host - '' - end - - def cookies - @cookies - end - - def session - @session - end - - def reset_session - @session = {} - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/discovery.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/discovery.rb deleted file mode 100644 index 3d4e0818..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/discovery.rb +++ /dev/null @@ -1,37 +0,0 @@ -module ActionWebService # :nodoc: - module Protocol # :nodoc: - module Discovery # :nodoc: - def self.included(base) - base.extend(ClassMethods) - base.send(:include, ActionWebService::Protocol::Discovery::InstanceMethods) - end - - module ClassMethods # :nodoc: - def register_protocol(klass) - write_inheritable_array("web_service_protocols", [klass]) - end - end - - module InstanceMethods # :nodoc: - private - def discover_web_service_request(action_pack_request) - (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol| - protocol = protocol.create(self) - request = protocol.decode_action_pack_request(action_pack_request) - return request unless request.nil? - end - nil - end - - def create_web_service_client(api, protocol_name, endpoint_uri, options) - (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol| - protocol = protocol.create(self) - client = protocol.protocol_client(api, protocol_name, endpoint_uri, options) - return client unless client.nil? - end - nil - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/soap_protocol.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/soap_protocol.rb deleted file mode 100644 index 1bce496a..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/soap_protocol.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'action_web_service/protocol/soap_protocol/marshaler' -require 'soap/streamHandler' -require 'action_web_service/client/soap_client' - -module ActionWebService # :nodoc: - module API # :nodoc: - class Base # :nodoc: - def self.soap_client(endpoint_uri, options={}) - ActionWebService::Client::Soap.new self, endpoint_uri, options - end - end - end - - module Protocol # :nodoc: - module Soap # :nodoc: - def self.included(base) - base.register_protocol(SoapProtocol) - base.class_inheritable_option(:wsdl_service_name) - base.class_inheritable_option(:wsdl_namespace) - end - - class SoapProtocol < AbstractProtocol # :nodoc: - AWSEncoding = 'UTF-8' - XSDEncoding = 'UTF8' - - attr :marshaler - - def initialize(namespace=nil) - namespace ||= 'urn:ActionWebService' - @marshaler = SoapMarshaler.new namespace - end - - def self.create(controller) - SoapProtocol.new(controller.wsdl_namespace) - end - - def decode_action_pack_request(action_pack_request) - return nil unless soap_action = has_valid_soap_action?(action_pack_request) - service_name = action_pack_request.parameters['action'] - input_encoding = parse_charset(action_pack_request.env['HTTP_CONTENT_TYPE']) - protocol_options = { - :soap_action => soap_action, - :charset => input_encoding - } - decode_request(action_pack_request.raw_post, service_name, protocol_options) - end - - def encode_action_pack_request(service_name, public_method_name, raw_body, options={}) - request = super - request.env['HTTP_SOAPACTION'] = '/soap/%s/%s' % [service_name, public_method_name] - request - end - - def decode_request(raw_request, service_name, protocol_options={}) - envelope = SOAP::Processor.unmarshal(raw_request, :charset => protocol_options[:charset]) - unless envelope - raise ProtocolError, "Failed to parse SOAP request message" - end - request = envelope.body.request - method_name = request.elename.name - params = request.collect{ |k, v| marshaler.soap_to_ruby(request[k]) } - Request.new(self, method_name, params, service_name, nil, nil, protocol_options) - end - - def encode_request(method_name, params, param_types) - param_types.each{ |type| marshaler.register_type(type) } if param_types - qname = XSD::QName.new(marshaler.namespace, method_name) - param_def = [] - if param_types - params = param_types.zip(params).map do |type, param| - param_def << ['in', type.name, marshaler.lookup_type(type).mapping] - [type.name, marshaler.ruby_to_soap(param)] - end - else - params = [] - end - request = SOAP::RPC::SOAPMethodRequest.new(qname, param_def) - request.set_param(params) - envelope = create_soap_envelope(request) - SOAP::Processor.marshal(envelope) - end - - def decode_response(raw_response) - envelope = SOAP::Processor.unmarshal(raw_response) - unless envelope - raise ProtocolError, "Failed to parse SOAP request message" - end - method_name = envelope.body.request.elename.name - return_value = envelope.body.response - return_value = marshaler.soap_to_ruby(return_value) unless return_value.nil? - [method_name, return_value] - end - - def encode_response(method_name, return_value, return_type, protocol_options={}) - if return_type - return_binding = marshaler.register_type(return_type) - marshaler.annotate_arrays(return_binding, return_value) - end - qname = XSD::QName.new(marshaler.namespace, method_name) - if return_value.nil? - response = SOAP::RPC::SOAPMethodResponse.new(qname, nil) - else - if return_value.is_a?(Exception) - detail = SOAP::Mapping::SOAPException.new(return_value) - response = SOAP::SOAPFault.new( - SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']), - SOAP::SOAPString.new(return_value.to_s), - SOAP::SOAPString.new(self.class.name), - marshaler.ruby_to_soap(detail)) - else - if return_type - param_def = [['retval', 'return', marshaler.lookup_type(return_type).mapping]] - response = SOAP::RPC::SOAPMethodResponse.new(qname, param_def) - response.retval = marshaler.ruby_to_soap(return_value) - else - response = SOAP::RPC::SOAPMethodResponse.new(qname, nil) - end - end - end - envelope = create_soap_envelope(response) - - # FIXME: This is not thread-safe, but StringFactory_ in SOAP4R only - # reads target encoding from the XSD::Charset.encoding variable. - # This is required to ensure $KCODE strings are converted - # correctly to UTF-8 for any values of $KCODE. - previous_encoding = XSD::Charset.encoding - XSD::Charset.encoding = XSDEncoding - response_body = SOAP::Processor.marshal(envelope, :charset => AWSEncoding) - XSD::Charset.encoding = previous_encoding - - Response.new(response_body, "text/xml; charset=#{AWSEncoding}", return_value) - end - - def protocol_client(api, protocol_name, endpoint_uri, options={}) - return nil unless protocol_name == :soap - ActionWebService::Client::Soap.new(api, endpoint_uri, options) - end - - def register_api(api) - api.api_methods.each do |name, method| - method.expects.each{ |type| marshaler.register_type(type) } if method.expects - method.returns.each{ |type| marshaler.register_type(type) } if method.returns - end - end - - private - def has_valid_soap_action?(request) - return nil unless request.method == :post - soap_action = request.env['HTTP_SOAPACTION'] - return nil unless soap_action - soap_action = soap_action.dup - soap_action.gsub!(/^"/, '') - soap_action.gsub!(/"$/, '') - soap_action.strip! - return nil if soap_action.empty? - soap_action - end - - def create_soap_envelope(body) - header = SOAP::SOAPHeader.new - body = SOAP::SOAPBody.new(body) - SOAP::SOAPEnvelope.new(header, body) - end - - def parse_charset(content_type) - return AWSEncoding if content_type.nil? - if /^text\/xml(?:\s*;\s*charset=([^"]+|"[^"]+"))$/i =~ content_type - $1 - else - AWSEncoding - end - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/soap_protocol/marshaler.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/soap_protocol/marshaler.rb deleted file mode 100644 index 6a2f3d3e..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/soap_protocol/marshaler.rb +++ /dev/null @@ -1,242 +0,0 @@ -require 'soap/mapping' - -# hack to improve the .Net interoperability -class SOAP::Mapping::Object - def each_pair - self.__xmlele.each { |n, v| yield n.name, v.to_s } - end -end - -module ActionWebService - module Protocol - module Soap - # Workaround for SOAP4R return values changing - class Registry < SOAP::Mapping::Registry - if SOAP::Version >= "1.5.4" - def find_mapped_soap_class(obj_class) - return @map.instance_eval { @obj2soap[obj_class][0] } - end - - def find_mapped_obj_class(soap_class) - return @map.instance_eval { @soap2obj[soap_class][0] } - end - end - end - - class SoapMarshaler - attr :namespace - attr :registry - - def initialize(namespace=nil) - @namespace = namespace || 'urn:ActionWebService' - @registry = Registry.new - @type2binding = {} - register_static_factories - end - - def soap_to_ruby(obj) - SOAP::Mapping.soap2obj(obj, @registry) - end - - def ruby_to_soap(obj) - soap = SOAP::Mapping.obj2soap(obj, @registry) - soap.elename = XSD::QName.new if SOAP::Version >= "1.5.5" && soap.elename == XSD::QName::EMPTY - soap - end - - def register_type(type) - return @type2binding[type] if @type2binding.has_key?(type) - - if type.array? - array_mapping = @registry.find_mapped_soap_class(Array) - qname = XSD::QName.new(@namespace, soap_type_name(type.element_type.type_class.name) + 'Array') - element_type_binding = register_type(type.element_type) - @type2binding[type] = SoapBinding.new(self, qname, type, array_mapping, element_type_binding) - elsif (mapping = @registry.find_mapped_soap_class(type.type_class) rescue nil) - qname = mapping[2] ? mapping[2][:type] : nil - qname ||= soap_base_type_name(mapping[0]) - @type2binding[type] = SoapBinding.new(self, qname, type, mapping) - else - qname = XSD::QName.new(@namespace, soap_type_name(type.type_class.name)) - @registry.add(type.type_class, - SOAP::SOAPStruct, - typed_struct_factory(type.type_class), - { :type => qname }) - mapping = @registry.find_mapped_soap_class(type.type_class) - @type2binding[type] = SoapBinding.new(self, qname, type, mapping) - end - - if type.structured? - type.each_member do |m_name, m_type| - register_type(m_type) - end - end - - @type2binding[type] - end - alias :lookup_type :register_type - - def annotate_arrays(binding, value) - if value.nil? - return - elsif binding.type.array? - mark_typed_array(value, binding.element_binding.qname) - if binding.element_binding.type.custom? - value.each do |element| - annotate_arrays(binding.element_binding, element) - end - end - elsif binding.type.structured? - binding.type.each_member do |name, type| - member_binding = register_type(type) - member_value = value.respond_to?('[]') ? value[name] : value.send(name) - annotate_arrays(member_binding, member_value) if type.custom? - end - end - end - - private - def typed_struct_factory(type_class) - if Object.const_defined?('ActiveRecord') - if type_class.ancestors.include?(ActiveRecord::Base) - qname = XSD::QName.new(@namespace, soap_type_name(type_class.name)) - type_class.instance_variable_set('@qname', qname) - return SoapActiveRecordStructFactory.new - end - end - SOAP::Mapping::Registry::TypedStructFactory - end - - def mark_typed_array(array, qname) - (class << array; self; end).class_eval do - define_method(:arytype) do - qname - end - end - end - - def soap_base_type_name(type) - xsd_type = type.ancestors.find{ |c| c.const_defined? 'Type' } - xsd_type ? xsd_type.const_get('Type') : XSD::XSDAnySimpleType::Type - end - - def soap_type_name(type_name) - type_name.gsub(/::/, '..') - end - - def register_static_factories - @registry.add(ActionWebService::Base64, SOAP::SOAPBase64, SoapBase64Factory.new, nil) - mapping = @registry.find_mapped_soap_class(ActionWebService::Base64) - @type2binding[ActionWebService::Base64] = - SoapBinding.new(self, SOAP::SOAPBase64::Type, ActionWebService::Base64, mapping) - @registry.add(Array, SOAP::SOAPArray, SoapTypedArrayFactory.new, nil) - @registry.add(::BigDecimal, SOAP::SOAPDouble, SOAP::Mapping::Registry::BasetypeFactory, {:derived_class => true}) - end - end - - class SoapBinding - attr :qname - attr :type - attr :mapping - attr :element_binding - - def initialize(marshaler, qname, type, mapping, element_binding=nil) - @marshaler = marshaler - @qname = qname - @type = type - @mapping = mapping - @element_binding = element_binding - end - - def type_name - @type.custom? ? @qname.name : nil - end - - def qualified_type_name(ns=nil) - if @type.custom? - "#{ns ? ns : @qname.namespace}:#{@qname.name}" - else - ns = XSD::NS.new - ns.assign(XSD::Namespace, SOAP::XSDNamespaceTag) - ns.assign(SOAP::EncodingNamespace, "soapenc") - xsd_klass = mapping[0].ancestors.find{|c| c.const_defined?('Type')} - return ns.name(XSD::AnyTypeName) unless xsd_klass - ns.name(xsd_klass.const_get('Type')) - end - end - - def eql?(other) - @qname == other.qname - end - alias :== :eql? - - def hash - @qname.hash - end - end - - class SoapActiveRecordStructFactory < SOAP::Mapping::Factory - def obj2soap(soap_class, obj, info, map) - unless obj.is_a?(ActiveRecord::Base) - return nil - end - soap_obj = soap_class.new(obj.class.instance_variable_get('@qname')) - obj.class.columns.each do |column| - key = column.name.to_s - value = obj.send(key) - soap_obj[key] = SOAP::Mapping._obj2soap(value, map) - end - soap_obj - end - - def soap2obj(obj_class, node, info, map) - unless node.type == obj_class.instance_variable_get('@qname') - return false - end - obj = obj_class.new - node.each do |key, value| - obj[key] = value.data - end - obj.instance_variable_set('@new_record', false) - return true, obj - end - end - - class SoapTypedArrayFactory < SOAP::Mapping::Factory - def obj2soap(soap_class, obj, info, map) - unless obj.respond_to?(:arytype) - return nil - end - soap_obj = soap_class.new(SOAP::ValueArrayName, 1, obj.arytype) - mark_marshalled_obj(obj, soap_obj) - obj.each do |item| - child = SOAP::Mapping._obj2soap(item, map) - soap_obj.add(child) - end - soap_obj - end - - def soap2obj(obj_class, node, info, map) - return false - end - end - - class SoapBase64Factory < SOAP::Mapping::Factory - def obj2soap(soap_class, obj, info, map) - unless obj.is_a?(ActionWebService::Base64) - return nil - end - return soap_class.new(obj) - end - - def soap2obj(obj_class, node, info, map) - unless node.type == SOAP::SOAPBase64::Type - return false - end - return true, obj_class.new(node.string) - end - end - - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/xmlrpc_protocol.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/xmlrpc_protocol.rb deleted file mode 100644 index dfa4afc6..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/protocol/xmlrpc_protocol.rb +++ /dev/null @@ -1,122 +0,0 @@ -require 'xmlrpc/marshal' -require 'action_web_service/client/xmlrpc_client' - -module XMLRPC # :nodoc: - class FaultException # :nodoc: - alias :message :faultString - end - - class Create - def wrong_type(value) - if BigDecimal === value - [true, value.to_f] - else - false - end - end - end -end - -module ActionWebService # :nodoc: - module API # :nodoc: - class Base # :nodoc: - def self.xmlrpc_client(endpoint_uri, options={}) - ActionWebService::Client::XmlRpc.new self, endpoint_uri, options - end - end - end - - module Protocol # :nodoc: - module XmlRpc # :nodoc: - def self.included(base) - base.register_protocol(XmlRpcProtocol) - end - - class XmlRpcProtocol < AbstractProtocol # :nodoc: - def self.create(controller) - XmlRpcProtocol.new - end - - def decode_action_pack_request(action_pack_request) - service_name = action_pack_request.parameters['action'] - decode_request(action_pack_request.raw_post, service_name) - end - - def decode_request(raw_request, service_name) - method_name, params = XMLRPC::Marshal.load_call(raw_request) - Request.new(self, method_name, params, service_name) - rescue - return nil - end - - def encode_request(method_name, params, param_types) - if param_types - params = params.dup - param_types.each_with_index{ |type, i| params[i] = value_to_xmlrpc_wire_format(params[i], type) } - end - XMLRPC::Marshal.dump_call(method_name, *params) - end - - def decode_response(raw_response) - [nil, XMLRPC::Marshal.load_response(raw_response)] - end - - def encode_response(method_name, return_value, return_type, protocol_options={}) - if return_value && return_type - return_value = value_to_xmlrpc_wire_format(return_value, return_type) - end - return_value = false if return_value.nil? - raw_response = XMLRPC::Marshal.dump_response(return_value) - Response.new(raw_response, 'text/xml', return_value) - end - - def encode_multicall_response(responses, protocol_options={}) - result = responses.map do |return_value, return_type| - if return_value && return_type - return_value = value_to_xmlrpc_wire_format(return_value, return_type) - return_value = [return_value] unless return_value.nil? - end - return_value = false if return_value.nil? - return_value - end - raw_response = XMLRPC::Marshal.dump_response(result) - Response.new(raw_response, 'text/xml', result) - end - - def protocol_client(api, protocol_name, endpoint_uri, options={}) - return nil unless protocol_name == :xmlrpc - ActionWebService::Client::XmlRpc.new(api, endpoint_uri, options) - end - - def value_to_xmlrpc_wire_format(value, value_type) - if value_type.array? - value.map{ |val| value_to_xmlrpc_wire_format(val, value_type.element_type) } - else - if value.is_a?(ActionWebService::Struct) - struct = {} - value.class.members.each do |name, type| - member_value = value[name] - next if member_value.nil? - struct[name.to_s] = value_to_xmlrpc_wire_format(member_value, type) - end - struct - elsif value.is_a?(ActiveRecord::Base) - struct = {} - value.attributes.each do |key, member_value| - next if member_value.nil? - struct[key.to_s] = member_value - end - struct - elsif value.is_a?(ActionWebService::Base64) - XMLRPC::Base64.new(value) - elsif value.is_a?(Exception) && !value.is_a?(XMLRPC::FaultException) - XMLRPC::FaultException.new(2, value.message) - else - value - end - end - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/scaffolding.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/scaffolding.rb deleted file mode 100644 index 60f73d21..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/scaffolding.rb +++ /dev/null @@ -1,281 +0,0 @@ -require 'benchmark' -require 'pathname' - -module ActionWebService - module Scaffolding # :nodoc: - class ScaffoldingError < ActionWebServiceError # :nodoc: - end - - def self.included(base) - base.extend(ClassMethods) - end - - # Web service invocation scaffolding provides a way to quickly invoke web service methods in a controller. The - # generated scaffold actions have default views to let you enter the method parameters and view the - # results. - # - # Example: - # - # class ApiController < ActionController - # web_service_scaffold :invoke - # end - # - # This example generates an +invoke+ action in the +ApiController+ that you can navigate to from - # your browser, select the API method, enter its parameters, and perform the invocation. - # - # If you want to customize the default views, create the following views in "app/views": - # - # * action_name/methods.html.erb - # * action_name/parameters.html.erb - # * action_name/result.html.erb - # * action_name/layout.html.erb - # - # Where action_name is the name of the action you gave to ClassMethods#web_service_scaffold. - # - # You can use the default views in RAILS_DIR/lib/action_web_service/templates/scaffolds as - # a guide. - module ClassMethods - # Generates web service invocation scaffolding for the current controller. The given action name - # can then be used as the entry point for invoking API methods from a web browser. - def web_service_scaffold(action_name) - add_template_helper(Helpers) - module_eval <<-"end_eval", __FILE__, __LINE__ + 1 - def #{action_name} - if request.method == :get - setup_invocation_assigns - render_invocation_scaffold 'methods' - end - end - - def #{action_name}_method_params - if request.method == :get - setup_invocation_assigns - render_invocation_scaffold 'parameters' - end - end - - def #{action_name}_submit - if request.method == :post - setup_invocation_assigns - protocol_name = params['protocol'] ? params['protocol'].to_sym : :soap - case protocol_name - when :soap - @protocol = Protocol::Soap::SoapProtocol.create(self) - when :xmlrpc - @protocol = Protocol::XmlRpc::XmlRpcProtocol.create(self) - end - bm = Benchmark.measure do - @protocol.register_api(@scaffold_service.api) - post_params = params['method_params'] ? params['method_params'].dup : nil - params = [] - @scaffold_method.expects.each_with_index do |spec, i| - params << post_params[i.to_s] - end if @scaffold_method.expects - params = @scaffold_method.cast_expects(params) - method_name = public_method_name(@scaffold_service.name, @scaffold_method.public_name) - @method_request_xml = @protocol.encode_request(method_name, params, @scaffold_method.expects) - new_request = @protocol.encode_action_pack_request(@scaffold_service.name, @scaffold_method.public_name, @method_request_xml) - prepare_request(new_request, @scaffold_service.name, @scaffold_method.public_name) - self.request = new_request - if @scaffold_container.dispatching_mode != :direct - request.parameters['action'] = @scaffold_service.name - end - dispatch_web_service_request - @method_response_xml = response.body - method_name, obj = @protocol.decode_response(@method_response_xml) - return if handle_invocation_exception(obj) - @method_return_value = @scaffold_method.cast_returns(obj) - end - @method_elapsed = bm.real - reset_invocation_response - render_invocation_scaffold 'result' - end - end - - private - def setup_invocation_assigns - @scaffold_class = self.class - @scaffold_action_name = "#{action_name}" - @scaffold_container = WebServiceModel::Container.new(self) - if params['service'] && params['method'] - @scaffold_service = @scaffold_container.services.find{ |x| x.name == params['service'] } - @scaffold_method = @scaffold_service.api_methods[params['method']] - end - end - - def render_invocation_scaffold(action) - customized_template = "\#{self.class.controller_path}/#{action_name}/\#{action}" - default_template = scaffold_path(action) - begin - content = @template.render(:file => customized_template) - rescue ActionView::MissingTemplate - content = @template.render(:file => default_template) - end - @template.instance_variable_set("@content_for_layout", content) - if self.active_layout.nil? - render :file => scaffold_path("layout") - else - render :file => self.active_layout, :use_full_path => true - end - end - - def scaffold_path(template_name) - File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".html.erb" - end - - def reset_invocation_response - erase_render_results - response.instance_variable_set :@header, Rack::Utils::HeaderHash.new(::ActionController::Response::DEFAULT_HEADERS.merge("cookie" => [])) - end - - def public_method_name(service_name, method_name) - if web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol) - service_name + '.' + method_name - else - method_name - end - end - - def prepare_request(new_request, service_name, method_name) - new_request.parameters.update(request.parameters) - request.env.each{ |k, v| new_request.env[k] = v unless new_request.env.has_key?(k) } - if web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::Soap::SoapProtocol) - new_request.env['HTTP_SOAPACTION'] = "/\#{controller_name()}/\#{service_name}/\#{method_name}" - end - end - - def handle_invocation_exception(obj) - exception = nil - if obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && obj.detail.cause.is_a?(Exception) - exception = obj.detail.cause - elsif obj.is_a?(XMLRPC::FaultException) - exception = obj - end - return unless exception - reset_invocation_response - rescue_action(exception) - true - end - end_eval - end - end - - module Helpers # :nodoc: - def method_parameter_input_fields(method, type, field_name_base, idx, was_structured=false) - if type.array? - return content_tag('em', "Typed array input fields not supported yet (#{type.name})") - end - if type.structured? - return content_tag('em', "Nested structural types not supported yet (#{type.name})") if was_structured - parameters = "" - type.each_member do |member_name, member_type| - label = method_parameter_label(member_name, member_type) - nested_content = method_parameter_input_fields( - method, - member_type, - "#{field_name_base}[#{idx}][#{member_name}]", - idx, - true) - if member_type.custom? - parameters << content_tag('li', label) - parameters << content_tag('ul', nested_content) - else - parameters << content_tag('li', label + ' ' + nested_content) - end - end - content_tag('ul', parameters) - else - # If the data source was structured previously we already have the index set - field_name_base = "#{field_name_base}[#{idx}]" unless was_structured - - case type.type - when :int - text_field_tag "#{field_name_base}" - when :string - text_field_tag "#{field_name_base}" - when :base64 - text_area_tag "#{field_name_base}", nil, :size => "40x5" - when :bool - radio_button_tag("#{field_name_base}", "true") + " True" + - radio_button_tag("#{field_name_base}", "false") + "False" - when :float - text_field_tag "#{field_name_base}" - when :time, :datetime - time = Time.now - i = 0 - %w|year month day hour minute second|.map do |name| - i += 1 - send("select_#{name}", time, :prefix => "#{field_name_base}[#{i}]", :discard_type => true) - end.join - when :date - date = Date.today - i = 0 - %w|year month day|.map do |name| - i += 1 - send("select_#{name}", date, :prefix => "#{field_name_base}[#{i}]", :discard_type => true) - end.join - end - end - end - - def method_parameter_label(name, type) - name.to_s.capitalize + ' (' + type.human_name(false) + ')' - end - - def service_method_list(service) - action = @scaffold_action_name + '_method_params' - methods = service.api_methods_full.map do |desc, name| - content_tag("li", link_to(desc, :action => action, :service => service.name, :method => name)) - end - content_tag("ul", methods.join("\n")) - end - end - - module WebServiceModel # :nodoc: - class Container # :nodoc: - attr :services - attr :dispatching_mode - - def initialize(real_container) - @real_container = real_container - @dispatching_mode = @real_container.class.web_service_dispatching_mode - @services = [] - if @dispatching_mode == :direct - @services << Service.new(@real_container.controller_name, @real_container) - else - @real_container.class.web_services.each do |name, obj| - @services << Service.new(name, @real_container.instance_eval{ web_service_object(name) }) - end - end - end - end - - class Service # :nodoc: - attr :name - attr :object - attr :api - attr :api_methods - attr :api_methods_full - - def initialize(name, real_service) - @name = name.to_s - @object = real_service - @api = @object.class.web_service_api - if @api.nil? - raise ScaffoldingError, "No web service API attached to #{object.class}" - end - @api_methods = {} - @api_methods_full = [] - @api.api_methods.each do |name, method| - @api_methods[method.public_name.to_s] = method - @api_methods_full << [method.to_s, method.public_name.to_s] - end - end - - def to_s - self.name.camelize - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/struct.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/struct.rb deleted file mode 100644 index 00eafc16..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/struct.rb +++ /dev/null @@ -1,64 +0,0 @@ -module ActionWebService - # To send structured types across the wire, derive from ActionWebService::Struct, - # and use +member+ to declare structure members. - # - # ActionWebService::Struct should be used in method signatures when you want to accept or return - # structured types that have no Active Record model class representations, or you don't - # want to expose your entire Active Record model to remote callers. - # - # === Example - # - # class Person < ActionWebService::Struct - # member :id, :int - # member :firstnames, [:string] - # member :lastname, :string - # member :email, :string - # end - # person = Person.new(:id => 5, :firstname => 'john', :lastname => 'doe') - # - # Active Record model classes are already implicitly supported in method - # signatures. - class Struct - # If a Hash is given as argument to an ActionWebService::Struct constructor, - # it can contain initial values for the structure member. - def initialize(values={}) - if values.is_a?(Hash) - values.map{|k,v| __send__('%s=' % k.to_s, v)} - end - end - - # The member with the given name - def [](name) - send(name.to_s) - end - - # Iterates through each member - def each_pair(&block) - self.class.members.each do |name, type| - yield name, self.__send__(name) - end - end - - class << self - # Creates a structure member with the specified +name+ and +type+. Generates - # accessor methods for reading and writing the member value. - def member(name, type) - name = name.to_sym - type = ActionWebService::SignatureTypes.canonical_signature_entry({ name => type }, 0) - write_inheritable_hash("struct_members", name => type) - class_eval <<-END - def #{name}; @#{name}; end - def #{name}=(value); @#{name} = value; end - END - end - - def members # :nodoc: - read_inheritable_attribute("struct_members") || {} - end - - def member_type(name) # :nodoc: - members[name.to_sym] - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/support/class_inheritable_options.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/support/class_inheritable_options.rb deleted file mode 100644 index 4d1c2ed4..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/support/class_inheritable_options.rb +++ /dev/null @@ -1,26 +0,0 @@ -class Class # :nodoc: - def class_inheritable_option(sym, default_value=nil) - write_inheritable_attribute sym, default_value - class_eval <<-EOS - def self.#{sym}(value=nil) - if !value.nil? - write_inheritable_attribute(:#{sym}, value) - else - read_inheritable_attribute(:#{sym}) - end - end - - def self.#{sym}=(value) - write_inheritable_attribute(:#{sym}, value) - end - - def #{sym} - self.class.#{sym} - end - - def #{sym}=(value) - self.class.#{sym} = value - end - EOS - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/support/signature_types.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/support/signature_types.rb deleted file mode 100644 index 66c86bf6..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/support/signature_types.rb +++ /dev/null @@ -1,226 +0,0 @@ -module ActionWebService # :nodoc: - # Action Web Service supports the following base types in a signature: - # - # [:int] Represents an integer value, will be cast to an integer using Integer(value) - # [:string] Represents a string value, will be cast to an string using the to_s method on an object - # [:base64] Represents a Base 64 value, will contain the binary bytes of a Base 64 value sent by the caller - # [:bool] Represents a boolean value, whatever is passed will be cast to boolean (true, '1', 'true', 'y', 'yes' are taken to represent true; false, '0', 'false', 'n', 'no' and nil represent false) - # [:float] Represents a floating point value, will be cast to a float using Float(value) - # [:time] Represents a timestamp, will be cast to a Time object - # [:datetime] Represents a timestamp, will be cast to a DateTime object - # [:date] Represents a date, will be cast to a Date object - # - # For structured types, you'll need to pass in the Class objects of - # ActionWebService::Struct and ActiveRecord::Base derivatives. - module SignatureTypes - def canonical_signature(signature) # :nodoc: - return nil if signature.nil? - unless signature.is_a?(Array) - raise(ActionWebServiceError, "Expected signature to be an Array") - end - i = -1 - signature.map{ |spec| canonical_signature_entry(spec, i += 1) } - end - - def canonical_signature_entry(spec, i) # :nodoc: - orig_spec = spec - name = "param#{i}" - if spec.is_a?(Hash) - name, spec = spec.keys.first, spec.values.first - end - type = spec - if spec.is_a?(Array) - ArrayType.new(orig_spec, canonical_signature_entry(spec[0], 0), name) - else - type = canonical_type(type) - if type.is_a?(Symbol) - BaseType.new(orig_spec, type, name) - else - StructuredType.new(orig_spec, type, name) - end - end - end - - def canonical_type(type) # :nodoc: - type_name = symbol_name(type) || class_to_type_name(type) - type = type_name || type - return canonical_type_name(type) if type.is_a?(Symbol) - type - end - - def canonical_type_name(name) # :nodoc: - name = name.to_sym - case name - when :int, :integer, :fixnum, :bignum - :int - when :string, :text - :string - when :base64, :binary - :base64 - when :bool, :boolean - :bool - when :float, :double - :float - when :decimal - :decimal - when :time, :timestamp - :time - when :datetime - :datetime - when :date - :date - else - raise(TypeError, "#{name} is not a valid base type") - end - end - - def canonical_type_class(type) # :nodoc: - type = canonical_type(type) - type.is_a?(Symbol) ? type_name_to_class(type) : type - end - - def symbol_name(name) # :nodoc: - return name.to_sym if name.is_a?(Symbol) || name.is_a?(String) - nil - end - - def class_to_type_name(klass) # :nodoc: - klass = klass.class unless klass.is_a?(Class) - if derived_from?(Integer, klass) || derived_from?(Fixnum, klass) || derived_from?(Bignum, klass) - :int - elsif klass == String - :string - elsif klass == Base64 - :base64 - elsif klass == TrueClass || klass == FalseClass - :bool - elsif derived_from?(Float, klass) || derived_from?(Precision, klass) || derived_from?(Numeric, klass) - :float - elsif klass == Time - :time - elsif klass == DateTime - :datetime - elsif klass == Date - :date - else - nil - end - end - - def type_name_to_class(name) # :nodoc: - case canonical_type_name(name) - when :int - Integer - when :string - String - when :base64 - Base64 - when :bool - TrueClass - when :float - Float - when :decimal - BigDecimal - when :time - Time - when :date - Date - when :datetime - DateTime - else - nil - end - end - - def derived_from?(ancestor, child) # :nodoc: - child.ancestors.include?(ancestor) - end - - module_function :type_name_to_class - module_function :class_to_type_name - module_function :symbol_name - module_function :canonical_type_class - module_function :canonical_type_name - module_function :canonical_type - module_function :canonical_signature_entry - module_function :canonical_signature - module_function :derived_from? - end - - class BaseType # :nodoc: - include SignatureTypes - - attr :spec - attr :type - attr :type_class - attr :name - - def initialize(spec, type, name) - @spec = spec - @type = canonical_type(type) - @type_class = canonical_type_class(@type) - @name = name - end - - def custom? - false - end - - def array? - false - end - - def structured? - false - end - - def human_name(show_name=true) - type_type = array? ? element_type.type.to_s : self.type.to_s - str = array? ? (type_type + '[]') : type_type - show_name ? (str + " " + name.to_s) : str - end - end - - class ArrayType < BaseType # :nodoc: - attr :element_type - - def initialize(spec, element_type, name) - super(spec, Array, name) - @element_type = element_type - end - - def custom? - true - end - - def array? - true - end - end - - class StructuredType < BaseType # :nodoc: - def each_member - if @type_class.respond_to?(:members) - @type_class.members.each do |name, type| - yield name, type - end - elsif @type_class.respond_to?(:columns) - i = -1 - @type_class.columns.each do |column| - yield column.name, canonical_signature_entry(column.type, i += 1) - end - end - end - - def custom? - true - end - - def structured? - true - end - end - - class Base64 < String # :nodoc: - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/layout.html.erb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/layout.html.erb deleted file mode 100644 index 167613f6..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/layout.html.erb +++ /dev/null @@ -1,65 +0,0 @@ - - - <%= @scaffold_class.wsdl_service_name %> Web Service - - - - -<%= @content_for_layout %> - - - diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/methods.html.erb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/methods.html.erb deleted file mode 100644 index 60dfe23f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/methods.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<% @scaffold_container.services.each do |service| %> - -

API Methods for <%= service %>

- <%= service_method_list(service) %> - -<% end %> diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/parameters.html.erb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/parameters.html.erb deleted file mode 100644 index 767284e0..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/parameters.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -

Method Invocation Details for <%= @scaffold_service %>#<%= @scaffold_method.public_name %>

- -<% form_tag(:action => @scaffold_action_name + '_submit') do -%> -<%= hidden_field_tag "service", @scaffold_service.name %> -<%= hidden_field_tag "method", @scaffold_method.public_name %> - -

-
-<%= select_tag 'protocol', options_for_select([['SOAP', 'soap'], ['XML-RPC', 'xmlrpc']], params['protocol']) %> -

- -<% if @scaffold_method.expects %> - -Method Parameters:
-<% @scaffold_method.expects.each_with_index do |type, i| %> -

-
- <%= method_parameter_input_fields(@scaffold_method, type, "method_params", i) %> -

-<% end %> - -<% end %> - -<%= submit_tag "Invoke" %> -<% end -%> - -

-<%= link_to "Back", :action => @scaffold_action_name %> -

diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/result.html.erb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/result.html.erb deleted file mode 100644 index 5317688f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/templates/scaffolds/result.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -

Method Invocation Result for <%= @scaffold_service %>#<%= @scaffold_method.public_name %>

- -

-Invocation took <%= '%f' % @method_elapsed %> seconds -

- -

-Return Value:
-

-<%= h @method_return_value.inspect %>
-
-

- -

-Request XML:
-

-<%= h @method_request_xml %>
-
-

- -

-Response XML:
-

-<%= h @method_response_xml %>
-
-

- -

-<%= link_to "Back", :action => @scaffold_action_name + '_method_params', :method => @scaffold_method.public_name, :service => @scaffold_service.name %> -

diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/test_invoke.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/test_invoke.rb deleted file mode 100644 index 7e714c94..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/test_invoke.rb +++ /dev/null @@ -1,110 +0,0 @@ -require 'test/unit' - -module Test # :nodoc: - module Unit # :nodoc: - class TestCase # :nodoc: - private - # invoke the specified API method - def invoke_direct(method_name, *args) - prepare_request('api', 'api', method_name, *args) - @controller.process(@request, @response) - decode_rpc_response - end - alias_method :invoke, :invoke_direct - - # invoke the specified API method on the specified service - def invoke_delegated(service_name, method_name, *args) - prepare_request(service_name.to_s, service_name, method_name, *args) - @controller.process(@request, @response) - decode_rpc_response - end - - # invoke the specified layered API method on the correct service - def invoke_layered(service_name, method_name, *args) - prepare_request('api', service_name, method_name, *args) - @controller.process(@request, @response) - decode_rpc_response - end - - # ---------------------- internal --------------------------- - - def prepare_request(action, service_name, api_method_name, *args) - @request.recycle! - @request.request_parameters['action'] = action - @request.env['REQUEST_METHOD'] = 'POST' - @request.env['HTTP_CONTENT_TYPE'] = 'text/xml' - @request.env['RAW_POST_DATA'] = encode_rpc_call(service_name, api_method_name, *args) - case protocol - when ActionWebService::Protocol::Soap::SoapProtocol - soap_action = "/#{@controller.controller_name}/#{service_name}/#{public_method_name(service_name, api_method_name)}" - @request.env['HTTP_SOAPACTION'] = soap_action - when ActionWebService::Protocol::XmlRpc::XmlRpcProtocol - @request.env.delete('HTTP_SOAPACTION') - end - end - - def encode_rpc_call(service_name, api_method_name, *args) - case @controller.web_service_dispatching_mode - when :direct - api = @controller.class.web_service_api - when :delegated, :layered - api = @controller.web_service_object(service_name.to_sym).class.web_service_api - end - protocol.register_api(api) - method = api.api_methods[api_method_name.to_sym] - raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" if method && method.expects && args.length != method.expects.length - protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects) - end - - def decode_rpc_response - public_method_name, return_value = protocol.decode_response(@response.body) - exception = is_exception?(return_value) - raise exception if exception - return_value - end - - def public_method_name(service_name, api_method_name) - public_name = service_api(service_name).public_api_method_name(api_method_name) - if @controller.web_service_dispatching_mode == :layered && protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol) - '%s.%s' % [service_name.to_s, public_name] - else - public_name - end - end - - def service_api(service_name) - case @controller.web_service_dispatching_mode - when :direct - @controller.class.web_service_api - when :delegated, :layered - @controller.web_service_object(service_name.to_sym).class.web_service_api - end - end - - def protocol - if @protocol.nil? - @protocol ||= ActionWebService::Protocol::Soap::SoapProtocol.create(@controller) - else - case @protocol - when :xmlrpc - @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@controller) - when :soap - @protocol = ActionWebService::Protocol::Soap::SoapProtocol.create(@controller) - else - @protocol - end - end - end - - def is_exception?(obj) - case protocol - when :soap, ActionWebService::Protocol::Soap::SoapProtocol - (obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \ - obj.detail.cause.is_a?(Exception)) ? obj.detail.cause : nil - when :xmlrpc, ActionWebService::Protocol::XmlRpc::XmlRpcProtocol - obj.is_a?(XMLRPC::FaultException) ? obj : nil - end - end - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/version.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/version.rb deleted file mode 100644 index 482b11dc..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActionWebService - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 11 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/actionwebservice.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/lib/actionwebservice.rb deleted file mode 100644 index 25e3aa8e..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/lib/actionwebservice.rb +++ /dev/null @@ -1 +0,0 @@ -require 'action_web_service' diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/setup.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/setup.rb deleted file mode 100644 index aeef0d10..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/setup.rb +++ /dev/null @@ -1,1379 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2004 Minero Aoki -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Note: Originally licensed under LGPL v2+. Using MIT license for Rails -# with permission of Minero Aoki. - -# - -unless Enumerable.method_defined?(:map) # Ruby 1.4.6 - module Enumerable - alias map collect - end -end - -unless File.respond_to?(:read) # Ruby 1.6 - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted windows stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - - -class SetupError < StandardError; end - -def setup_rb_error(msg) - raise SetupError, msg -end - -# -# Config -# - -if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - require arg.split(/=/, 2)[1] - $".push 'rbconfig.rb' -else - require 'rbconfig' -end - -def multipackage_install? - FileTest.directory?(File.dirname($0) + '/packages') -end - - -class ConfigItem - def initialize(name, template, default, desc) - @name = name.freeze - @template = template - @value = default - @default = default.dup.freeze - @description = desc - end - - attr_reader :name - attr_reader :description - - attr_accessor :default - alias help_default default - - def help_opt - "--#{@name}=#{@template}" - end - - def value - @value - end - - def eval(table) - @value.gsub(%r<\$([^/]+)>) { table[$1] } - end - - def set(val) - @value = check(val) - end - - private - - def check(val) - setup_rb_error "config: --#{name} requires argument" unless val - val - end -end - -class BoolItem < ConfigItem - def config_type - 'bool' - end - - def help_opt - "--#{@name}" - end - - private - - def check(val) - return 'yes' unless val - unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val - setup_rb_error "config: --#{@name} accepts only yes/no for argument" - end - (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no' - end -end - -class PathItem < ConfigItem - def config_type - 'path' - end - - private - - def check(path) - setup_rb_error "config: --#{@name} requires argument" unless path - path[0,1] == '$' ? path : File.expand_path(path) - end -end - -class ProgramItem < ConfigItem - def config_type - 'program' - end -end - -class SelectItem < ConfigItem - def initialize(name, template, default, desc) - super - @ok = template.split('/') - end - - def config_type - 'select' - end - - private - - def check(val) - unless @ok.include?(val.strip) - setup_rb_error "config: use --#{@name}=#{@template} (#{val})" - end - val.strip - end -end - -class PackageSelectionItem < ConfigItem - def initialize(name, template, default, help_default, desc) - super name, template, default, desc - @help_default = help_default - end - - attr_reader :help_default - - def config_type - 'package' - end - - private - - def check(val) - unless File.dir?("packages/#{val}") - setup_rb_error "config: no such package: #{val}" - end - val - end -end - -class ConfigTable_class - - def initialize(items) - @items = items - @table = {} - items.each do |i| - @table[i.name] = i - end - ALIASES.each do |ali, name| - @table[ali] = @table[name] - end - end - - include Enumerable - - def each(&block) - @items.each(&block) - end - - def key?(name) - @table.key?(name) - end - - def lookup(name) - @table[name] or raise ArgumentError, "no such config item: #{name}" - end - - def add(item) - @items.push item - @table[item.name] = item - end - - def remove(name) - item = lookup(name) - @items.delete_if {|i| i.name == name } - @table.delete_if {|name, i| i.name == name } - item - end - - def new - dup() - end - - def savefile - '.config' - end - - def load - begin - t = dup() - File.foreach(savefile()) do |line| - k, v = *line.split(/=/, 2) - t[k] = v.strip - end - t - rescue Errno::ENOENT - setup_rb_error $!.message + "#{File.basename($0)} config first" - end - end - - def save - @items.each {|i| i.value } - File.open(savefile(), 'w') {|f| - @items.each do |i| - f.printf "%s=%s\n", i.name, i.value if i.value - end - } - end - - def [](key) - lookup(key).eval(self) - end - - def []=(key, val) - lookup(key).set val - end - -end - -c = ::Config::CONFIG - -rubypath = c['bindir'] + '/' + c['ruby_install_name'] - -major = c['MAJOR'].to_i -minor = c['MINOR'].to_i -teeny = c['TEENY'].to_i -version = "#{major}.#{minor}" - -# ruby ver. >= 1.4.4? -newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - -if c['rubylibdir'] - # V < 1.6.3 - _stdruby = c['rubylibdir'] - _siteruby = c['sitedir'] - _siterubyver = c['sitelibdir'] - _siterubyverarch = c['sitearchdir'] -elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - _stdruby = "$prefix/lib/ruby/#{version}" - _siteruby = c['sitedir'] - _siterubyver = "$siteruby/#{version}" - _siterubyverarch = "$siterubyver/#{c['arch']}" -else - # V < 1.4.4 - _stdruby = "$prefix/lib/ruby/#{version}" - _siteruby = "$prefix/lib/ruby/#{version}/site_ruby" - _siterubyver = _siteruby - _siterubyverarch = "$siterubyver/#{c['arch']}" -end -libdir = '-* dummy libdir *-' -stdruby = '-* dummy rubylibdir *-' -siteruby = '-* dummy site_ruby *-' -siterubyver = '-* dummy site_ruby version *-' -parameterize = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')\ - .sub(/\A#{Regexp.quote(libdir)}/, '$libdir')\ - .sub(/\A#{Regexp.quote(stdruby)}/, '$stdruby')\ - .sub(/\A#{Regexp.quote(siteruby)}/, '$siteruby')\ - .sub(/\A#{Regexp.quote(siterubyver)}/, '$siterubyver') -} -libdir = parameterize.call(c['libdir']) -stdruby = parameterize.call(_stdruby) -siteruby = parameterize.call(_siteruby) -siterubyver = parameterize.call(_siterubyver) -siterubyverarch = parameterize.call(_siterubyverarch) - -if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] -else - makeprog = 'make' -end - -common_conf = [ - PathItem.new('prefix', 'path', c['prefix'], - 'path prefix of target environment'), - PathItem.new('bindir', 'path', parameterize.call(c['bindir']), - 'the directory for commands'), - PathItem.new('libdir', 'path', libdir, - 'the directory for libraries'), - PathItem.new('datadir', 'path', parameterize.call(c['datadir']), - 'the directory for shared data'), - PathItem.new('mandir', 'path', parameterize.call(c['mandir']), - 'the directory for man pages'), - PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), - 'the directory for man pages'), - PathItem.new('stdruby', 'path', stdruby, - 'the directory for standard ruby libraries'), - PathItem.new('siteruby', 'path', siteruby, - 'the directory for version-independent aux ruby libraries'), - PathItem.new('siterubyver', 'path', siterubyver, - 'the directory for aux ruby libraries'), - PathItem.new('siterubyverarch', 'path', siterubyverarch, - 'the directory for aux ruby binaries'), - PathItem.new('rbdir', 'path', '$siterubyver', - 'the directory for ruby scripts'), - PathItem.new('sodir', 'path', '$siterubyverarch', - 'the directory for ruby extentions'), - PathItem.new('rubypath', 'path', rubypath, - 'the path to set to #! line'), - ProgramItem.new('rubyprog', 'name', rubypath, - 'the ruby program using for installation'), - ProgramItem.new('makeprog', 'name', makeprog, - 'the make program to compile ruby extentions'), - SelectItem.new('shebang', 'all/ruby/never', 'ruby', - 'shebang line (#!) editing mode'), - BoolItem.new('without-ext', 'yes/no', 'no', - 'does not compile/install ruby extentions') -] -class ConfigTable_class # open again - ALIASES = { - 'std-ruby' => 'stdruby', - 'site-ruby-common' => 'siteruby', # For backward compatibility - 'site-ruby' => 'siterubyver', # For backward compatibility - 'bin-dir' => 'bindir', - 'bin-dir' => 'bindir', - 'rb-dir' => 'rbdir', - 'so-dir' => 'sodir', - 'data-dir' => 'datadir', - 'ruby-path' => 'rubypath', - 'ruby-prog' => 'rubyprog', - 'ruby' => 'rubyprog', - 'make-prog' => 'makeprog', - 'make' => 'makeprog' - } -end -multipackage_conf = [ - PackageSelectionItem.new('with', 'name,name...', '', 'ALL', - 'package names that you want to install'), - PackageSelectionItem.new('without', 'name,name...', '', 'NONE', - 'package names that you do not want to install') -] -if multipackage_install? - ConfigTable = ConfigTable_class.new(common_conf + multipackage_conf) -else - ConfigTable = ConfigTable_class.new(common_conf) -end - - -module MetaConfigAPI - - def eval_file_ifexist(fname) - instance_eval File.read(fname), fname, 1 if File.file?(fname) - end - - def config_names - ConfigTable.map {|i| i.name } - end - - def config?(name) - ConfigTable.key?(name) - end - - def bool_config?(name) - ConfigTable.lookup(name).config_type == 'bool' - end - - def path_config?(name) - ConfigTable.lookup(name).config_type == 'path' - end - - def value_config?(name) - case ConfigTable.lookup(name).config_type - when 'bool', 'path' - true - else - false - end - end - - def add_config(item) - ConfigTable.add item - end - - def add_bool_config(name, default, desc) - ConfigTable.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) - end - - def add_path_config(name, default, desc) - ConfigTable.add PathItem.new(name, 'path', default, desc) - end - - def set_config_default(name, default) - ConfigTable.lookup(name).default = default - end - - def remove_config(name) - ConfigTable.remove(name) - end - -end - - -# -# File Operations -# - -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + File.expand_path(dirname) if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # does not check '/'... it's too abnormal case - dirs = File.expand_path(dirname).split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(fname) - $stderr.puts "rm -f #{fname}" if verbose? - return if no_harm? - - if File.exist?(fname) or File.symlink?(fname) - File.chmod 0777, fname - File.unlink fname - end - end - - def rm_rf(dn) - $stderr.puts "rm -rf #{dn}" if verbose? - return if no_harm? - - Dir.chdir dn - Dir.foreach('.') do |fn| - next if fn == '.' - next if fn == '..' - if File.dir?(fn) - verbose_off { - rm_rf fn - } - else - verbose_off { - rm_f fn - } - end - end - Dir.chdir '..' - Dir.rmdir dn - end - - def move_file(src, dest) - File.unlink dest if File.exist?(dest) - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| f.write File.binread(src) } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix ? prefix + File.expand_path(dest) : dest - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(str) - $stderr.puts str if verbose? - system str or raise RuntimeError, "'system #{str}' failed" - end - - def ruby(str) - command config('rubyprog') + ' ' + str - end - - def make(task = '') - command config('makeprog') + ' ' + task - end - - def extdir?(dir) - File.exist?(dir + '/MANIFEST') - end - - def all_files_in(dirname) - Dir.open(dirname) {|d| - return d.select {|ent| File.file?("#{dirname}/#{ent}") } - } - end - - REJECT_DIRS = %w( - CVS SCCS RCS CVS.adm .svn - ) - - def all_dirs_in(dirname) - Dir.open(dirname) {|d| - return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS - } - end - -end - - -# -# Main Installer -# - -module HookUtils - - def run_hook(name) - try_run_hook "#{curr_srcdir()}/#{name}" or - try_run_hook "#{curr_srcdir()}/#{name}.rb" - end - - def try_run_hook(fname) - return false unless File.file?(fname) - begin - instance_eval File.read(fname), fname, 1 - rescue - setup_rb_error "hook #{fname} failed:\n" + $!.message - end - true - end - -end - - -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - #abstract srcdir_root - #abstract objdir_root - #abstract relpath - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file? srcfile(path) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.3.1' - Copyright = 'Copyright (c) 2000-2004 Minero Aoki' - - TASKS = [ - [ 'all', 'do config, setup, then install' ], - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - instance().invoke - end - - @singleton = nil - - def ToplevelInstaller.instance - @singleton ||= new(File.dirname($0)) - @singleton - end - - include MetaConfigAPI - - def initialize(ardir_root) - @config = nil - @options = { 'verbose' => true } - @ardir = File.expand_path(ardir_root) - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - case task = parsearg_global() - when nil, 'all' - @config = load_config('config') - parsearg_config - init_installers - exec_config - exec_setup - exec_install - else - @config = load_config(task) - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - end - - def load_config(task) - case task - when 'config' - ConfigTable.new - when 'clean', 'distclean' - if File.exist?(ConfigTable.savefile) - then ConfigTable.load - else ConfigTable.new - end - else - ConfigTable.load - end - end - - def init_installers - @installer = Installer.new(@config, @options, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/ - - while arg = ARGV.shift - case arg - when /\A\w+\z/ - setup_rb_error "invalid task: #{arg}" unless valid_task =~ arg - return arg - - when '-q', '--quiet' - @options['verbose'] = false - - when '--verbose' - @options['verbose'] = true - - when '-h', '--help' - print_usage $stdout - exit 0 - - when '-v', '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - - when '--copyright' - puts Copyright - exit 0 - - else - setup_rb_error "unknown global option '#{arg}'" - end - end - - nil - end - - - def parsearg_no_options - unless ARGV.empty? - setup_rb_error "#{task}: unknown options: #{ARGV.join ' '}" - end - end - - alias parsearg_show parsearg_no_options - alias parsearg_setup parsearg_no_options - alias parsearg_clean parsearg_no_options - alias parsearg_distclean parsearg_no_options - - def parsearg_config - re = /\A--(#{ConfigTable.map {|i| i.name }.join('|')})(?:=(.*))?\z/ - @options['config-opt'] = [] - - while i = ARGV.shift - if /\A--?\z/ =~ i - @options['config-opt'] = ARGV.dup - break - end - m = re.match(i) or setup_rb_error "config: unknown option #{i}" - name, value = *m.to_a[1,2] - @config[name] = value - end - end - - def parsearg_install - @options['no-harm'] = false - @options['install-prefix'] = '' - while a = ARGV.shift - case a - when /\A--no-harm\z/ - @options['no-harm'] = true - when /\A--prefix=(.*)\z/ - path = $1 - path = File.expand_path(path) unless path[0,1] == '/' - @options['install-prefix'] = path - else - setup_rb_error "install: unknown option #{a}" - end - end - end - - def print_usage(out) - out.puts 'Typical Installation Procedure:' - out.puts " $ ruby #{File.basename $0} config" - out.puts " $ ruby #{File.basename $0} setup" - out.puts " # ruby #{File.basename $0} install (may require root privilege)" - out.puts - out.puts 'Detailed Usage:' - out.puts " ruby #{File.basename $0} " - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-24s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, '-h,--help', 'print this message' - out.printf fmt, '-v,--version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf fmt, name, desc - end - - fmt = " %-24s %s [%s]\n" - out.puts - out.puts 'Options for CONFIG or ALL:' - ConfigTable.each do |item| - out.printf fmt, item.help_opt, item.description, item.help_default - end - out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" - out.puts - out.puts 'Options for INSTALL:' - out.printf fmt, '--no-harm', 'only display what to do if given', 'off' - out.printf fmt, '--prefix=path', 'install path prefix', '$prefix' - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_show - ConfigTable.each do |i| - printf "%-20s %s\n", i.name, i.value - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end - - -class ToplevelInstallerMulti < ToplevelInstaller - - include HookUtils - include HookScriptAPI - include FileOperations - - def initialize(ardir) - super - @packages = all_dirs_in("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - @packages.each do |name| - eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig" - end - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, @options, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - setup_rb_error "no such package: #{name}" unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Included packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # multi-package metaconfig API - # - - attr_reader :packages - - def declare_packages(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_clean - rm_f ConfigTable.savefile - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f ConfigTable.savefile - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose'] - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def verbose? - @options['verbose'] - end - - def no_harm? - @options['no-harm'] - end - -end - - -class Installer - - FILETYPES = %w( bin lib ext data ) - - include HookScriptAPI - include HookUtils - include FileOperations - - def initialize(config, opt, srcroot, objroot) - @config = config - @options = opt - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - # - # Hook Script API base methods - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # configs/options - # - - def no_harm? - @options['no-harm'] - end - - def verbose? - @options['verbose'] - end - - def verbose_off - begin - save, @options['verbose'] = @options['verbose'], false - yield - ensure - @options['verbose'] = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - def config_dir_bin(rel) - end - - def config_dir_lib(rel) - end - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - def extconf - opt = @options['config-opt'].join(' ') - command "#{config('rubyprog')} #{curr_srcdir()}/extconf.rb #{opt}" - end - - def config_dir_data(rel) - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - all_files_in(curr_srcdir()).each do |fname| - adjust_shebang "#{curr_srcdir()}/#{fname}" - end - end - - def adjust_shebang(path) - return if no_harm? - tmpfile = File.basename(path) + '.tmp' - begin - File.open(path, 'rb') {|r| - first = r.gets - return unless File.basename(config('rubypath')) == 'ruby' - return unless File.basename(first.sub(/\A\#!/, '').split[0]) == 'ruby' - $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose? - File.open(tmpfile, 'wb') {|w| - w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath')) - w.write r.read - } - move_file tmpfile, File.basename(path) - } - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def setup_dir_lib(rel) - end - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - def setup_dir_data(rel) - end - - # - # TASK install - # - - def exec_install - rm_f 'InstalledFiles' - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files collect_filenames_auto(), "#{config('bindir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files ruby_scripts(), "#{config('rbdir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files ruby_extentions('.'), - "#{config('sodir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files collect_filenames_auto(), "#{config('datadir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - install fname, dest, mode, @options['install-prefix'] - end - end - - def ruby_scripts - collect_filenames_auto().select {|n| /\.rb\z/ =~ n } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - reject_patterns = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - mapping = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - REJECT_PATTERNS = Regexp.new('\A(?:' + - reject_patterns.map {|pat| - pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] } - }.join('|') + - ')\z') - - def collect_filenames_auto - mapdir((existfiles() - hookfiles()).reject {|fname| - REJECT_PATTERNS =~ fname - }) - end - - def existfiles - all_files_in(curr_srcdir()) | all_files_in('.') - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def mapdir(filelist) - filelist.map {|fname| - if File.exist?(fname) # objdir - fname - else # srcdir - File.join(curr_srcdir(), fname) - end - } - end - - def ruby_extentions(dir) - Dir.open(dir) {|d| - ents = d.select {|fname| /\.#{::Config::CONFIG['DLEXT']}\z/ =~ fname } - if ents.empty? - setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" - end - return ents - } - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f ConfigTable.savefile - rm_f 'InstalledFiles' - end - - def clean_dir_bin(rel) - end - - def clean_dir_lib(rel) - end - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - def clean_dir_data(rel) - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f ConfigTable.savefile - rm_f 'InstalledFiles' - end - - def distclean_dir_bin(rel) - end - - def distclean_dir_lib(rel) - end - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - # - # lib - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if config('without-ext') == 'yes' and type == 'ext' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - all_dirs_in(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - -end - - -if $0 == __FILE__ - begin - if multipackage_install? - ToplevelInstallerMulti.invoke - else - ToplevelInstaller.invoke - end - rescue SetupError - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_client.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_client.rb deleted file mode 100644 index ff958f64..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_client.rb +++ /dev/null @@ -1,183 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' -require 'webrick' -require 'webrick/log' -require 'singleton' - -module ClientTest - class Person < ActionWebService::Struct - member :firstnames, [:string] - member :lastname, :string - - def ==(other) - firstnames == other.firstnames && lastname == other.lastname - end - end - - class Inner < ActionWebService::Struct - member :name, :string - end - - class Outer < ActionWebService::Struct - member :name, :string - member :inner, Inner - end - - class User < ActiveRecord::Base - end - - module Accounting - class User < ActiveRecord::Base - end - end - - class WithModel < ActionWebService::Struct - member :user, User - member :users, [User] - end - - class WithMultiDimArray < ActionWebService::Struct - member :pref, [[:string]] - end - - class API < ActionWebService::API::Base - api_method :void - api_method :normal, :expects => [:int, :int], :returns => [:int] - api_method :array_return, :returns => [[Person]] - api_method :struct_pass, :expects => [[Person]], :returns => [:bool] - api_method :nil_struct_return, :returns => [Person] - api_method :inner_nil, :returns => [Outer] - api_method :client_container, :returns => [:int] - api_method :named_parameters, :expects => [{:key=>:string}, {:id=>:int}] - api_method :thrower - api_method :user_return, :returns => [User] - api_method :with_model_return, :returns => [WithModel] - api_method :scoped_model_return, :returns => [Accounting::User] - api_method :multi_dim_return, :returns => [WithMultiDimArray] - end - - class NullLogOut - def <<(*args); end - end - - class Container < ActionController::Base - web_service_api API - - attr_accessor :value_void - attr_accessor :value_normal - attr_accessor :value_array_return - attr_accessor :value_struct_pass - attr_accessor :value_named_parameters - - def initialize - @value_void = nil - @value_normal = nil - @value_array_return = nil - @value_struct_pass = nil - @value_named_parameters = nil - end - - def void - @value_void = @method_params - end - - def normal - @value_normal = @method_params - 5 - end - - def array_return - person = Person.new - person.firstnames = ["one", "two"] - person.lastname = "last" - @value_array_return = [person] - end - - def struct_pass - @value_struct_pass = @method_params - true - end - - def nil_struct_return - nil - end - - def inner_nil - Outer.new :name => 'outer', :inner => nil - end - - def client_container - 50 - end - - def named_parameters - @value_named_parameters = @method_params - end - - def thrower - raise "Hi" - end - - def user_return - User.find(1) - end - - def with_model_return - WithModel.new :user => User.find(1), :users => User.find(:all) - end - - def scoped_model_return - Accounting::User.find(1) - end - - def multi_dim_return - WithMultiDimArray.new :pref => [%w{pref1 value1}, %w{pref2 value2}] - end - end - - class AbstractClientLet < WEBrick::HTTPServlet::AbstractServlet - def initialize(controller) - @controller = controller - end - - def get_instance(*args) - self - end - - def require_path_info? - false - end - - def do_GET(req, res) - raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed." - end - - def do_POST(req, res) - raise NotImplementedError - end - end - - class AbstractServer - include ClientTest - include Singleton - attr :container - def initialize - @container = Container.new - @clientlet = create_clientlet(@container) - log = WEBrick::BasicLog.new(NullLogOut.new) - @server = WEBrick::HTTPServer.new(:Port => server_port, :Logger => log, :AccessLog => []) - @server.mount('/', @clientlet) - @thr = Thread.new { @server.start } - until @server.status == :Running; end - at_exit { @server.stop; @thr.join } - end - - protected - def create_clientlet - raise NotImplementedError - end - - def server_port - raise NotImplementedError - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_dispatcher.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_dispatcher.rb deleted file mode 100644 index dbb3580a..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_dispatcher.rb +++ /dev/null @@ -1,548 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' -require 'stringio' - -class ActionController::Base; def rescue_action(e) raise e end; end - -module DispatcherTest - Utf8String = "One World Caf\303\251" - WsdlNamespace = 'http://rubyonrails.com/some/namespace' - - class Node < ActiveRecord::Base - def initialize(*args) - super(*args) - @new_record = false - end - - class << self - def name - "DispatcherTest::Node" - end - - def columns(*args) - [ - ActiveRecord::ConnectionAdapters::Column.new('id', 0, 'int'), - ActiveRecord::ConnectionAdapters::Column.new('name', nil, 'string'), - ActiveRecord::ConnectionAdapters::Column.new('description', nil, 'string'), - ] - end - - def connection - self - end - end - end - - class Person < ActionWebService::Struct - member :id, :int - member :name, :string - - def ==(other) - self.id == other.id && self.name == other.name - end - end - - class API < ActionWebService::API::Base - api_method :add, :expects => [:int, :int], :returns => [:int] - api_method :interceptee - api_method :struct_return, :returns => [[Node]] - api_method :void - end - - class DirectAPI < ActionWebService::API::Base - api_method :add, :expects => [{:a=>:int}, {:b=>:int}], :returns => [:int] - api_method :add2, :expects => [{:a=>:int}, {:b=>:int}], :returns => [:int] - api_method :before_filtered - api_method :after_filtered, :returns => [[:int]] - api_method :struct_return, :returns => [[Node]] - api_method :struct_pass, :expects => [{:person => Person}] - api_method :base_struct_return, :returns => [[Person]] - api_method :hash_struct_return, :returns => [[Person]] - api_method :thrower - api_method :void - api_method :test_utf8, :returns => [:string] - api_method :hex, :expects => [:base64], :returns => [:string] - api_method :unhex, :expects => [:string], :returns => [:base64] - api_method :time, :expects => [:time], :returns => [:time] - end - - class VirtualAPI < ActionWebService::API::Base - default_api_method :fallback - end - - class Service < ActionWebService::Base - web_service_api API - - before_invocation :do_intercept, :only => [:interceptee] - - attr :added - attr :intercepted - attr :void_called - - def initialize - @void_called = false - end - - def add(a, b) - @added = a + b - end - - def interceptee - @intercepted = false - end - - def struct_return - n1 = Node.new('id' => 1, 'name' => 'node1', 'description' => 'Node 1') - n2 = Node.new('id' => 2, 'name' => 'node2', 'description' => 'Node 2') - [n1, n2] - end - - def void(*args) - @void_called = args - end - - def do_intercept(name, args) - [false, "permission denied"] - end - end - - class MTAPI < ActionWebService::API::Base - inflect_names false - api_method :getCategories, :returns => [[:string]] - api_method :bool, :returns => [:bool] - api_method :alwaysFail - api_method :person, :returns => [Person] - end - - class BloggerAPI < ActionWebService::API::Base - inflect_names false - api_method :getCategories, :returns => [[:string]] - api_method :str, :expects => [:int], :returns => [:string] - api_method :alwaysFail - end - - class MTService < ActionWebService::Base - web_service_api MTAPI - - def getCategories - ["mtCat1", "mtCat2"] - end - - def bool - 'y' - end - - def alwaysFail - raise "MT AlwaysFail" - end - - def person - Person.new('id' => 1, 'name' => 'person1') - end - end - - class BloggerService < ActionWebService::Base - web_service_api BloggerAPI - - def getCategories - ["bloggerCat1", "bloggerCat2"] - end - - def str(int) - unless int.is_a?(Integer) - raise "Not an integer!" - end - 500 + int - end - - def alwaysFail - raise "Blogger AlwaysFail" - end - end - - class AbstractController < ActionController::Base - def generate_wsdl - self.request ||= ::ActionController::TestRequest.new - to_wsdl - end - end - - class DelegatedController < AbstractController - web_service_dispatching_mode :delegated - wsdl_namespace WsdlNamespace - - web_service(:test_service) { @service ||= Service.new; @service } - end - - class LayeredController < AbstractController - web_service_dispatching_mode :layered - wsdl_namespace WsdlNamespace - - web_service(:mt) { @mt_service ||= MTService.new; @mt_service } - web_service(:blogger) { @blogger_service ||= BloggerService.new; @blogger_service } - end - - class DirectController < AbstractController - web_service_api DirectAPI - web_service_dispatching_mode :direct - wsdl_namespace WsdlNamespace - - before_invocation :alwaysfail, :only => [:before_filtered] - after_invocation :alwaysok, :only => [:after_filtered] - - attr :added - attr :added2 - attr :before_filter_called - attr :before_filter_target_called - attr :after_filter_called - attr :after_filter_target_called - attr :void_called - attr :struct_pass_value - - def initialize - @before_filter_called = false - @before_filter_target_called = false - @after_filter_called = false - @after_filter_target_called = false - @void_called = false - @struct_pass_value = false - end - - def add - @added = params['a'] + params['b'] - end - - def add2(a, b) - @added2 = a + b - end - - def before_filtered - @before_filter_target_called = true - end - - def after_filtered - @after_filter_target_called = true - [5, 6, 7] - end - - def thrower - raise "Hi, I'm an exception" - end - - def struct_return - n1 = Node.new('id' => 1, 'name' => 'node1', 'description' => 'Node 1') - n2 = Node.new('id' => 2, 'name' => 'node2', 'description' => 'Node 2') - [n1, n2] - end - - def struct_pass(person) - @struct_pass_value = person - end - - def base_struct_return - p1 = Person.new('id' => 1, 'name' => 'person1') - p2 = Person.new('id' => 2, 'name' => 'person2') - [p1, p2] - end - - def hash_struct_return - p1 = { :id => '1', 'name' => 'test' } - p2 = { 'id' => '2', :name => 'person2' } - [p1, p2] - end - - def void - @void_called = @method_params - end - - def test_utf8 - Utf8String - end - - def hex(s) - return s.unpack("H*")[0] - end - - def unhex(s) - return [s].pack("H*") - end - - def time(t) - t - end - - protected - def alwaysfail(method_name, params) - @before_filter_called = true - false - end - - def alwaysok(method_name, params, return_value) - @after_filter_called = true - end - end - - class VirtualController < AbstractController - web_service_api VirtualAPI - wsdl_namespace WsdlNamespace - - def fallback - "fallback!" - end - end -end - -module DispatcherCommonTests - def test_direct_dispatching - assert_equal(70, do_method_call(@direct_controller, 'Add', 20, 50)) - assert_equal(70, @direct_controller.added) - assert_equal(50, do_method_call(@direct_controller, 'Add2', 25, 25)) - assert_equal(50, @direct_controller.added2) - assert(@direct_controller.void_called == false) - assert(do_method_call(@direct_controller, 'Void', 3, 4, 5).nil?) - assert(@direct_controller.void_called == []) - result = do_method_call(@direct_controller, 'BaseStructReturn') - assert(result[0].is_a?(DispatcherTest::Person)) - assert(result[1].is_a?(DispatcherTest::Person)) - assert_equal("cafe", do_method_call(@direct_controller, 'Hex', "\xca\xfe")) - assert_equal("\xca\xfe", do_method_call(@direct_controller, 'Unhex', "cafe")) - time = Time.gm(1998, "Feb", 02, 15, 12, 01) - assert_equal(time, do_method_call(@direct_controller, 'Time', time)) - end - - def test_direct_entrypoint - assert(@direct_controller.respond_to?(:api)) - end - - def test_virtual_dispatching - assert_equal("fallback!", do_method_call(@virtual_controller, 'VirtualOne')) - assert_equal("fallback!", do_method_call(@virtual_controller, 'VirtualTwo')) - end - - def test_direct_filtering - assert_equal(false, @direct_controller.before_filter_called) - assert_equal(false, @direct_controller.before_filter_target_called) - do_method_call(@direct_controller, 'BeforeFiltered') - assert_equal(true, @direct_controller.before_filter_called) - assert_equal(false, @direct_controller.before_filter_target_called) - assert_equal(false, @direct_controller.after_filter_called) - assert_equal(false, @direct_controller.after_filter_target_called) - assert_equal([5, 6, 7], do_method_call(@direct_controller, 'AfterFiltered')) - assert_equal(true, @direct_controller.after_filter_called) - assert_equal(true, @direct_controller.after_filter_target_called) - end - - def test_delegated_dispatching - assert_equal(130, do_method_call(@delegated_controller, 'Add', 50, 80)) - service = @delegated_controller.web_service_object(:test_service) - assert_equal(130, service.added) - @delegated_controller.web_service_exception_reporting = true - assert(service.intercepted.nil?) - result = do_method_call(@delegated_controller, 'Interceptee') - assert(service.intercepted.nil?) - assert(is_exception?(result)) - assert_match(/permission denied/, exception_message(result)) - result = do_method_call(@delegated_controller, 'NonExistentMethod') - assert(is_exception?(result)) - assert_match(/NonExistentMethod/, exception_message(result)) - assert(service.void_called == false) - assert(do_method_call(@delegated_controller, 'Void', 3, 4, 5).nil?) - assert(service.void_called == []) - end - - def test_garbage_request - [@direct_controller, @delegated_controller].each do |controller| - controller.class.web_service_exception_reporting = true - send_garbage_request = lambda do - service_name = service_name(controller) - request = protocol.encode_action_pack_request(service_name, 'broken, method, name!', 'broken request body', :request_class => ActionController::TestRequest) - response = ActionController::TestResponse.new - controller.process(request, response) - # puts response.body - assert(response.status =~ /^500/) - end - send_garbage_request.call - controller.class.web_service_exception_reporting = false - send_garbage_request.call - end - end - - def test_exception_marshaling - @direct_controller.web_service_exception_reporting = true - result = do_method_call(@direct_controller, 'Thrower') - assert(is_exception?(result)) - assert_equal("Hi, I'm an exception", exception_message(result)) - @direct_controller.web_service_exception_reporting = false - result = do_method_call(@direct_controller, 'Thrower') - assert(exception_message(result) != "Hi, I'm an exception") - end - - def test_ar_struct_return - [@direct_controller, @delegated_controller].each do |controller| - result = do_method_call(controller, 'StructReturn') - assert(result[0].is_a?(DispatcherTest::Node)) - assert(result[1].is_a?(DispatcherTest::Node)) - assert_equal('node1', result[0].name) - assert_equal('node2', result[1].name) - end - end - - def test_casting - assert_equal 70, do_method_call(@direct_controller, 'Add', "50", "20") - assert_equal false, @direct_controller.struct_pass_value - person = DispatcherTest::Person.new(:id => 1, :name => 'test') - result = do_method_call(@direct_controller, 'StructPass', person) - assert(nil == result || true == result) - assert_equal person, @direct_controller.struct_pass_value - assert !person.equal?(@direct_controller.struct_pass_value) - result = do_method_call(@direct_controller, 'StructPass', {'id' => '1', 'name' => 'test'}) - case - when soap? - assert_equal(person, @direct_controller.struct_pass_value) - assert !person.equal?(@direct_controller.struct_pass_value) - when xmlrpc? - assert_equal(person, @direct_controller.struct_pass_value) - assert !person.equal?(@direct_controller.struct_pass_value) - end - assert_equal person, do_method_call(@direct_controller, 'HashStructReturn')[0] - result = do_method_call(@direct_controller, 'StructPass', {'id' => '1', 'name' => 'test', 'nonexistent_attribute' => 'value'}) - case - when soap? - assert_equal(person, @direct_controller.struct_pass_value) - assert !person.equal?(@direct_controller.struct_pass_value) - when xmlrpc? - assert_equal(person, @direct_controller.struct_pass_value) - assert !person.equal?(@direct_controller.struct_pass_value) - end - end - - def test_logging - buf = "" - ActionController::Base.logger = Logger.new(StringIO.new(buf)) - test_casting - test_garbage_request - test_exception_marshaling - ActionController::Base.logger = nil - assert_match /Web Service Response/, buf - assert_match /Web Service Request/, buf - end - - def test_allowed_http_methods - webservice_api = @direct_controller.class.web_service_api - original_allowed_http_methods = webservice_api.allowed_http_methods - - # check defaults - assert_equal false, http_method_allowed?(:get) - assert_equal false, http_method_allowed?(:head) - assert_equal false, http_method_allowed?(:put) - assert_equal false, http_method_allowed?(:delete) - assert_equal true, http_method_allowed?(:post) - - # allow get and post - webservice_api.allowed_http_methods = [ :get, :post ] - assert_equal true, http_method_allowed?(:get) - assert_equal true, http_method_allowed?(:post) - - # allow get only - webservice_api.allowed_http_methods = [ :get ] - assert_equal true, http_method_allowed?(:get) - assert_equal false, http_method_allowed?(:post) - - # allow delete only - webservice_api.allowed_http_methods = [ 'DELETE' ] - assert_equal false, http_method_allowed?(:get) - assert_equal false, http_method_allowed?(:head) - assert_equal false, http_method_allowed?(:post) - assert_equal false, http_method_allowed?(:put) - assert_equal true, http_method_allowed?(:delete) - - ensure - webservice_api.allowed_http_methods = original_allowed_http_methods - end - - protected - def service_name(container) - raise NotImplementedError - end - - def exception_message(obj) - raise NotImplementedError - end - - def is_exception?(obj) - raise NotImplementedError - end - - def protocol - @protocol - end - - def soap? - protocol.is_a? ActionWebService::Protocol::Soap::SoapProtocol - end - - def xmlrpc? - protocol.is_a? ActionWebService::Protocol::XmlRpc::XmlRpcProtocol - end - - def do_method_call(container, public_method_name, *params) - request_env = {} - mode = container.web_service_dispatching_mode - case mode - when :direct - service_name = service_name(container) - api = container.class.web_service_api - method = api.public_api_method_instance(public_method_name) - when :delegated - service_name = service_name(container) - api = container.web_service_object(service_name).class.web_service_api - method = api.public_api_method_instance(public_method_name) - when :layered - service_name = nil - real_method_name = nil - if public_method_name =~ /^([^\.]+)\.(.*)$/ - service_name = $1 - real_method_name = $2 - end - if soap? - public_method_name = real_method_name - request_env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{real_method_name}" - end - api = container.web_service_object(service_name.to_sym).class.web_service_api rescue nil - method = api.public_api_method_instance(real_method_name) rescue nil - service_name = self.service_name(container) - end - protocol.register_api(api) - virtual = false - unless method - virtual = true - method ||= ActionWebService::API::Method.new(public_method_name.underscore.to_sym, public_method_name, nil, nil) - end - body = protocol.encode_request(public_method_name, params.dup, method.expects) - # puts body - ap_request = protocol.encode_action_pack_request(service_name, public_method_name, body, :request_class => ActionController::TestRequest) - ap_request.env.update(request_env) - ap_response = ActionController::TestResponse.new - container.process(ap_request, ap_response) - # puts ap_response.body - @response_body = ap_response.body - public_method_name, return_value = protocol.decode_response(ap_response.body) - unless is_exception?(return_value) || virtual - return_value = method.cast_returns(return_value) - end - if soap? - # http://dev.rubyonrails.com/changeset/920 - assert_match(/Response$/, public_method_name) unless public_method_name == "fault" - end - return_value - end - - def http_method_allowed?(method) - method = method.to_s.upcase - test_request = ActionController::TestRequest.new - test_request.action = 'api' - test_response = ActionController::TestResponse.new - test_request.env['REQUEST_METHOD'] = method - result = @direct_controller.process(test_request, test_response) - result.body =~ /(GET|POST|PUT|DELETE|TRACE|CONNECT) not supported/ ? false : true - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_unit.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_unit.rb deleted file mode 100644 index 69468e9c..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/abstract_unit.rb +++ /dev/null @@ -1,39 +0,0 @@ -$: << "#{File.dirname(__FILE__)}/../lib" -ENV["RAILS_ENV"] = "test" -require 'rubygems' -require 'test/unit' -require 'action_web_service' -require 'action_controller' -require 'action_controller/test_case' -require 'action_view' -require 'action_view/test_case' - -# Show backtraces for deprecated behavior for quicker cleanup. -ActiveSupport::Deprecation.debug = true - - -ActiveRecord::Base.logger = ActionController::Base.logger = Logger.new("debug.log") - -begin - require 'activerecord' - require "active_record/test_case" - require "active_record/fixtures" unless Object.const_defined?(:Fixtures) -rescue LoadError => e - fail "\nFailed to load activerecord: #{e}" -end - -ActiveRecord::Base.configurations = { - 'mysql' => { - :adapter => "mysql", - :username => "root", - :encoding => "utf8", - :database => "actionwebservice_unittest" - } -} - -ActiveRecord::Base.establish_connection 'mysql' - -class ActiveSupport::TestCase - include ActiveRecord::TestFixtures - self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/" -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/api_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/api_test.rb deleted file mode 100644 index 0be672c8..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/api_test.rb +++ /dev/null @@ -1,102 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -module APITest - class API < ActionWebService::API::Base - api_method :void - api_method :expects_and_returns, :expects_and_returns => [:string] - api_method :expects, :expects => [:int, :bool] - api_method :returns, :returns => [:int, [:string]] - api_method :named_signature, :expects => [{:appkey=>:int}, {:publish=>:bool}] - api_method :string_types, :expects => ['int', 'string', 'bool', 'base64'] - api_method :class_types, :expects => [TrueClass, Bignum, String] - end -end - -class TC_API < ActiveSupport::TestCase - API = APITest::API - - def test_api_method_declaration - %w( - void - expects_and_returns - expects - returns - named_signature - string_types - class_types - ).each do |name| - name = name.to_sym - public_name = API.public_api_method_name(name) - assert(API.has_api_method?(name)) - assert(API.has_public_api_method?(public_name)) - assert(API.api_method_name(public_name) == name) - assert(API.api_methods.has_key?(name)) - end - end - - def test_signature_canonicalization - assert_equal(nil, API.api_methods[:void].expects) - assert_equal(nil, API.api_methods[:void].returns) - assert_equal([String], API.api_methods[:expects_and_returns].expects.map{|x| x.type_class}) - assert_equal([String], API.api_methods[:expects_and_returns].returns.map{|x| x.type_class}) - assert_equal([Integer, TrueClass], API.api_methods[:expects].expects.map{|x| x.type_class}) - assert_equal(nil, API.api_methods[:expects].returns) - assert_equal(nil, API.api_methods[:returns].expects) - assert_equal([Integer, [String]], API.api_methods[:returns].returns.map{|x| x.array?? [x.element_type.type_class] : x.type_class}) - assert_equal([[:appkey, Integer], [:publish, TrueClass]], API.api_methods[:named_signature].expects.map{|x| [x.name, x.type_class]}) - assert_equal(nil, API.api_methods[:named_signature].returns) - assert_equal([Integer, String, TrueClass, ActionWebService::Base64], API.api_methods[:string_types].expects.map{|x| x.type_class}) - assert_equal(nil, API.api_methods[:string_types].returns) - assert_equal([TrueClass, Integer, String], API.api_methods[:class_types].expects.map{|x| x.type_class}) - assert_equal(nil, API.api_methods[:class_types].returns) - end - - def test_not_instantiable - assert_raises(NoMethodError) do - API.new - end - end - - def test_api_errors - assert_raises(ActionWebService::ActionWebServiceError) do - klass = Class.new(ActionWebService::API::Base) do - api_method :test, :expects => [ActiveRecord::Base] - end - end - klass = Class.new(ActionWebService::API::Base) do - allow_active_record_expects true - api_method :test2, :expects => [ActiveRecord::Base] - end - assert_raises(ActionWebService::ActionWebServiceError) do - klass = Class.new(ActionWebService::API::Base) do - api_method :test, :invalid => [:int] - end - end - end - - def test_parameter_names - method = API.api_methods[:named_signature] - assert_equal 0, method.expects_index_of(:appkey) - assert_equal 1, method.expects_index_of(:publish) - assert_equal 1, method.expects_index_of('publish') - assert_equal 0, method.expects_index_of('appkey') - assert_equal -1, method.expects_index_of('blah') - assert_equal -1, method.expects_index_of(:missing) - assert_equal -1, API.api_methods[:void].expects_index_of('test') - end - - def test_parameter_hash - method = API.api_methods[:named_signature] - hash = method.expects_to_hash([5, false]) - assert_equal({:appkey => 5, :publish => false}, hash) - end - - def test_api_methods_compat - sig = API.api_methods[:named_signature][:expects] - assert_equal [{:appkey=>Integer}, {:publish=>TrueClass}], sig - end - - def test_to_s - assert_equal 'void Expects(int param0, bool param1)', APITest::API.api_methods[:expects].to_s - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/apis/auto_load_api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/apis/auto_load_api.rb deleted file mode 100644 index a35bbe3f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/apis/auto_load_api.rb +++ /dev/null @@ -1,3 +0,0 @@ -class AutoLoadAPI < ActionWebService::API::Base - api_method :void -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/apis/broken_auto_load_api.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/apis/broken_auto_load_api.rb deleted file mode 100644 index 139597f9..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/apis/broken_auto_load_api.rb +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/base_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/base_test.rb deleted file mode 100644 index 06aa33ea..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/base_test.rb +++ /dev/null @@ -1,42 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -module BaseTest - class API < ActionWebService::API::Base - api_method :add, :expects => [:int, :int], :returns => [:int] - api_method :void - end - - class PristineAPI < ActionWebService::API::Base - inflect_names false - - api_method :add - api_method :under_score - end - - class Service < ActionWebService::Base - web_service_api API - - def add(a, b) - end - - def void - end - end - - class PristineService < ActionWebService::Base - web_service_api PristineAPI - - def add - end - - def under_score - end - end -end - -class TC_Base < ActiveSupport::TestCase - def test_options - assert(BaseTest::PristineService.web_service_api.inflect_names == false) - assert(BaseTest::Service.web_service_api.inflect_names == true) - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/casting_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/casting_test.rb deleted file mode 100644 index 93ca383f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/casting_test.rb +++ /dev/null @@ -1,94 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -module CastingTest - class A < ActionWebService::Struct; end - class B < A; end - class API < ActionWebService::API::Base - api_method :int, :expects => [:int] - api_method :str, :expects => [:string] - api_method :base64, :expects => [:base64] - api_method :bool, :expects => [:bool] - api_method :float, :expects => [:float] - api_method :time, :expects => [:time] - api_method :datetime, :expects => [:datetime] - api_method :date, :expects => [:date] - - api_method :int_array, :expects => [[:int]] - api_method :str_array, :expects => [[:string]] - api_method :bool_array, :expects => [[:bool]] - - api_method :a, :expects => [A] - end -end - -class TC_Casting < Test::Unit::TestCase - include CastingTest - - def test_base_type_casting_valid - assert_equal 10000, cast_expects(:int, '10000')[0] - assert_equal '10000', cast_expects(:str, 10000)[0] - base64 = cast_expects(:base64, 10000)[0] - assert_equal '10000', base64 - assert_instance_of ActionWebService::Base64, base64 - [1, '1', 'true', 'y', 'yes'].each do |val| - assert_equal true, cast_expects(:bool, val)[0] - end - [0, '0', 'false', 'n', 'no'].each do |val| - assert_equal false, cast_expects(:bool, val)[0] - end - assert_equal 3.14159, cast_expects(:float, '3.14159')[0] - now = Time.at(Time.now.tv_sec) - casted = cast_expects(:time, now.to_s)[0] - assert_equal now, casted - now = DateTime.now - assert_equal now.to_s, cast_expects(:datetime, now.to_s)[0].to_s - today = Date.today - assert_equal today, cast_expects(:date, today.to_s)[0] - end - - def test_base_type_casting_invalid - assert_raises ArgumentError do - cast_expects(:int, 'this is not a number') - end - assert_raises ActionWebService::Casting::CastingError do - # neither true or false ;) - cast_expects(:bool, 'i always lie') - end - assert_raises ArgumentError do - cast_expects(:float, 'not a float') - end - assert_raises ArgumentError do - cast_expects(:time, '111111111111111111111111111111111') - end - assert_raises ArgumentError do - cast_expects(:datetime, '-1') - end - assert_raises ArgumentError do - cast_expects(:date, '') - end - end - - def test_array_type_casting - assert_equal [1, 2, 3213992, 4], cast_expects(:int_array, ['1', '2', '3213992', '4'])[0] - assert_equal ['one', 'two', '5.0', '200', nil, 'true'], cast_expects(:str_array, [:one, 'two', 5.0, 200, nil, true])[0] - assert_equal [true, nil, true, true, false], cast_expects(:bool_array, ['1', nil, 'y', true, 'false'])[0] - end - - def test_array_type_casting_failure - assert_raises ActionWebService::Casting::CastingError do - cast_expects(:bool_array, ['false', 'blahblah']) - end - assert_raises ArgumentError do - cast_expects(:int_array, ['1', '2.021', '4']) - end - end - - def test_structured_type_casting_with_polymorphism - assert cast_expects(:a, B.new)[0].is_a?(B) - end - - private - def cast_expects(method_name, *args) - API.api_method_instance(method_name.to_sym).cast_expects([*args]) - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/client_soap_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/client_soap_test.rb deleted file mode 100644 index a6ffe7f8..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/client_soap_test.rb +++ /dev/null @@ -1,155 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_client' - - -module ClientSoapTest - PORT = 8998 - - class SoapClientLet < ClientTest::AbstractClientLet - def do_POST(req, res) - test_request = ActionController::TestRequest.new - test_request.request_parameters['action'] = req.path.gsub(/^\//, '').split(/\//)[1] - test_request.env['REQUEST_METHOD'] = "POST" - test_request.env['HTTP_CONTENTTYPE'] = 'text/xml' - test_request.env['HTTP_SOAPACTION'] = req.header['soapaction'][0] - test_request.env['RAW_POST_DATA'] = req.body - response = ActionController::TestResponse.new - @controller.process(test_request, response) - res.header['content-type'] = 'text/xml' - res.body = response.body - rescue Exception => e - $stderr.puts e.message - $stderr.puts e.backtrace.join("\n") - ensure - ActiveRecord::Base.clear_active_connections! - end - end - - class ClientContainer < ActionController::Base - web_client_api :client, :soap, "http://localhost:#{PORT}/client/api", :api => ClientTest::API - web_client_api :invalid, :null, "", :api => true - - def get_client - client - end - - def get_invalid - invalid - end - end - - class SoapServer < ClientTest::AbstractServer - def create_clientlet(controller) - SoapClientLet.new(controller) - end - - def server_port - PORT - end - end -end - -class TC_ClientSoap < ActiveSupport::TestCase - include ClientTest - include ClientSoapTest - - fixtures :users - - def setup - @server = SoapServer.instance - @container = @server.container - @client = ActionWebService::Client::Soap.new(API, "http://localhost:#{@server.server_port}/client/api") - end - - def test_void - assert(@container.value_void.nil?) - @client.void - assert(!@container.value_void.nil?) - end - - def test_normal - assert(@container.value_normal.nil?) - assert_equal(5, @client.normal(5, 6)) - assert_equal([5, 6], @container.value_normal) - assert_equal(5, @client.normal("7", "8")) - assert_equal([7, 8], @container.value_normal) - assert_equal(5, @client.normal(true, false)) - end - - def test_array_return - assert(@container.value_array_return.nil?) - new_person = Person.new - new_person.firstnames = ["one", "two"] - new_person.lastname = "last" - assert_equal([new_person], @client.array_return) - assert_equal([new_person], @container.value_array_return) - end - - def test_struct_pass - assert(@container.value_struct_pass.nil?) - new_person = Person.new - new_person.firstnames = ["one", "two"] - new_person.lastname = "last" - assert_equal(true, @client.struct_pass([new_person])) - assert_equal([[new_person]], @container.value_struct_pass) - end - - def test_nil_struct_return - assert_nil @client.nil_struct_return - end - - def test_inner_nil - outer = @client.inner_nil - assert_equal 'outer', outer.name - assert_nil outer.inner - end - - def test_client_container - assert_equal(50, ClientContainer.new.get_client.client_container) - assert(ClientContainer.new.get_invalid.nil?) - end - - def test_named_parameters - assert(@container.value_named_parameters.nil?) - assert(@client.named_parameters("key", 5).nil?) - assert_equal(["key", 5], @container.value_named_parameters) - end - - def test_capitalized_method_name - @container.value_normal = nil - assert_equal(5, @client.Normal(5, 6)) - assert_equal([5, 6], @container.value_normal) - @container.value_normal = nil - end - - def test_model_return - user = @client.user_return - assert_equal 1, user.id - assert_equal 'Kent', user.name - assert user.active? - assert_kind_of Date, user.created_on - assert_equal Date.today, user.created_on - assert_equal BigDecimal('12.2'), user.balance - end - - def test_with_model - with_model = @client.with_model_return - assert_equal 'Kent', with_model.user.name - assert_equal 2, with_model.users.size - with_model.users.each do |user| - assert_kind_of User, user - end - end - - def test_scoped_model_return - scoped_model = @client.scoped_model_return - assert_kind_of Accounting::User, scoped_model - assert_equal 'Kent', scoped_model.name - end - - def test_multi_dim_return - md_struct = @client.multi_dim_return - assert_kind_of Array, md_struct.pref - assert_equal 2, md_struct.pref.size - assert_kind_of Array, md_struct.pref[0] - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/client_xmlrpc_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/client_xmlrpc_test.rb deleted file mode 100644 index da524a8b..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/client_xmlrpc_test.rb +++ /dev/null @@ -1,153 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_client' - - -module ClientXmlRpcTest - PORT = 8999 - - class XmlRpcClientLet < ClientTest::AbstractClientLet - def do_POST(req, res) - test_request = ActionController::TestRequest.new - test_request.request_parameters['action'] = req.path.gsub(/^\//, '').split(/\//)[1] - test_request.env['REQUEST_METHOD'] = "POST" - test_request.env['HTTP_CONTENT_TYPE'] = 'text/xml' - test_request.env['RAW_POST_DATA'] = req.body - response = ActionController::TestResponse.new - @controller.process(test_request, response) - res.header['content-type'] = 'text/xml' - res.body = response.body - rescue Exception => e - $stderr.puts e.message - $stderr.puts e.backtrace.join("\n") - ensure - ActiveRecord::Base.clear_active_connections! - end - end - - class ClientContainer < ActionController::Base - web_client_api :client, :xmlrpc, "http://localhost:#{PORT}/client/api", :api => ClientTest::API - - def get_client - client - end - end - - class XmlRpcServer < ClientTest::AbstractServer - def create_clientlet(controller) - XmlRpcClientLet.new(controller) - end - - def server_port - PORT - end - end -end - -class TC_ClientXmlRpc < ActiveSupport::TestCase - include ClientTest - include ClientXmlRpcTest - - fixtures :users - - def setup - @server = XmlRpcServer.instance - @container = @server.container - @client = ActionWebService::Client::XmlRpc.new(API, "http://localhost:#{@server.server_port}/client/api") - end - - def test_void - assert(@container.value_void.nil?) - @client.void - assert(!@container.value_void.nil?) - end - - def test_normal - assert(@container.value_normal.nil?) - assert_equal(5, @client.normal(5, 6)) - assert_equal([5, 6], @container.value_normal) - assert_equal(5, @client.normal("7", "8")) - assert_equal([7, 8], @container.value_normal) - assert_equal(5, @client.normal(true, false)) - end - - def test_array_return - assert(@container.value_array_return.nil?) - new_person = Person.new - new_person.firstnames = ["one", "two"] - new_person.lastname = "last" - assert_equal([new_person], @client.array_return) - assert_equal([new_person], @container.value_array_return) - end - - def test_struct_pass - assert(@container.value_struct_pass.nil?) - new_person = Person.new - new_person.firstnames = ["one", "two"] - new_person.lastname = "last" - assert_equal(true, @client.struct_pass([new_person])) - assert_equal([[new_person]], @container.value_struct_pass) - end - - def test_nil_struct_return - assert_equal false, @client.nil_struct_return - end - - def test_inner_nil - outer = @client.inner_nil - assert_equal 'outer', outer.name - assert_nil outer.inner - end - - def test_client_container - assert_equal(50, ClientContainer.new.get_client.client_container) - end - - def test_named_parameters - assert(@container.value_named_parameters.nil?) - assert_equal(false, @client.named_parameters("xxx", 7)) - assert_equal(["xxx", 7], @container.value_named_parameters) - end - - def test_exception - assert_raises(ActionWebService::Client::ClientError) do - assert(@client.thrower) - end - end - - def test_invalid_signature - assert_raises(ArgumentError) do - @client.normal - end - end - - def test_model_return - user = @client.user_return - assert_equal 1, user.id - assert_equal 'Kent', user.name - assert user.active? - assert_kind_of Time, user.created_on - assert_equal Time.utc(Time.now.year, Time.now.month, Time.now.day), user.created_on - assert_equal BigDecimal('12.2'), user.balance - end - - def test_with_model - with_model = @client.with_model_return - assert_equal 'Kent', with_model.user.name - assert_equal 2, with_model.users.size - with_model.users.each do |user| - assert_kind_of User, user - end - end - - def test_scoped_model_return - scoped_model = @client.scoped_model_return - assert_kind_of Accounting::User, scoped_model - assert_equal 'Kent', scoped_model.name - end - - def test_multi_dim_return - md_struct = @client.multi_dim_return - assert_kind_of Array, md_struct.pref - assert_equal 2, md_struct.pref.size - assert_kind_of Array, md_struct.pref[0] - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/container_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/container_test.rb deleted file mode 100644 index 325d420f..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/container_test.rb +++ /dev/null @@ -1,73 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -module ContainerTest - $immediate_service = Object.new - $deferred_service = Object.new - - class DelegateContainer < ActionController::Base - web_service_dispatching_mode :delegated - - attr :flag - attr :previous_flag - - def initialize - @previous_flag = nil - @flag = true - end - - web_service :immediate_service, $immediate_service - web_service(:deferred_service) { @previous_flag = @flag; @flag = false; $deferred_service } - end - - class DirectContainer < ActionController::Base - web_service_dispatching_mode :direct - end - - class InvalidContainer - include ActionWebService::Container::Direct - end -end - -class TC_Container < Test::Unit::TestCase - include ContainerTest - - def setup - @delegate_container = DelegateContainer.new - @direct_container = DirectContainer.new - end - - def test_registration - assert(DelegateContainer.has_web_service?(:immediate_service)) - assert(DelegateContainer.has_web_service?(:deferred_service)) - assert(!DelegateContainer.has_web_service?(:fake_service)) - assert_raises(ActionWebService::Container::Delegated::ContainerError) do - DelegateContainer.web_service('invalid') - end - end - - def test_service_object - assert_raises(ActionWebService::Container::Delegated::ContainerError) do - @delegate_container.web_service_object(:nonexistent) - end - assert(@delegate_container.flag == true) - assert(@delegate_container.web_service_object(:immediate_service) == $immediate_service) - assert(@delegate_container.previous_flag.nil?) - assert(@delegate_container.flag == true) - assert(@delegate_container.web_service_object(:deferred_service) == $deferred_service) - assert(@delegate_container.previous_flag == true) - assert(@delegate_container.flag == false) - end - - def test_direct_container - assert(DirectContainer.web_service_dispatching_mode == :direct) - end - - def test_validity - assert_raises(ActionWebService::Container::Direct::ContainerError) do - InvalidContainer.web_service_api :test - end - assert_raises(ActionWebService::Container::Direct::ContainerError) do - InvalidContainer.web_service_api 50.0 - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/dispatcher_action_controller_soap_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/dispatcher_action_controller_soap_test.rb deleted file mode 100644 index bd9fc19d..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/dispatcher_action_controller_soap_test.rb +++ /dev/null @@ -1,138 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/apis') -require File.dirname(__FILE__) + '/abstract_dispatcher' -require 'wsdl/parser' - -class ActionController::Base - class << self - alias :inherited_without_name_error :inherited - def inherited(child) - begin - inherited_without_name_error(child) - rescue NameError => e - end - end - end -end - -class AutoLoadController < ActionController::Base; end -class FailingAutoLoadController < ActionController::Base; end -class BrokenAutoLoadController < ActionController::Base; end - -class TC_DispatcherActionControllerSoap < Test::Unit::TestCase - include DispatcherTest - include DispatcherCommonTests - - def setup - @direct_controller = DirectController.new - @delegated_controller = DelegatedController.new - @virtual_controller = VirtualController.new - @layered_controller = LayeredController.new - @protocol = ActionWebService::Protocol::Soap::SoapProtocol.create(@direct_controller) - end - - def test_wsdl_generation - ensure_valid_wsdl_generation DelegatedController.new, DispatcherTest::WsdlNamespace - ensure_valid_wsdl_generation DirectController.new, DispatcherTest::WsdlNamespace - end - - def test_wsdl_action - delegated_types = ensure_valid_wsdl_action DelegatedController.new - delegated_names = delegated_types.map{|x| x.name.name} - assert(delegated_names.include?('DispatcherTest..NodeArray')) - assert(delegated_names.include?('DispatcherTest..Node')) - direct_types = ensure_valid_wsdl_action DirectController.new - direct_names = direct_types.map{|x| x.name.name} - assert(direct_names.include?('DispatcherTest..NodeArray')) - assert(direct_names.include?('DispatcherTest..Node')) - assert(direct_names.include?('IntegerArray')) - end - - def test_autoloading - assert(!AutoLoadController.web_service_api.nil?) - assert(AutoLoadController.web_service_api.has_public_api_method?('Void')) - assert(FailingAutoLoadController.web_service_api.nil?) - assert_raises(MissingSourceFile) do - FailingAutoLoadController.require_web_service_api :blah - end - assert_raises(ArgumentError) do - FailingAutoLoadController.require_web_service_api 50.0 - end - assert(BrokenAutoLoadController.web_service_api.nil?) - end - - def test_layered_dispatching - mt_cats = do_method_call(@layered_controller, 'mt.getCategories') - assert_equal(["mtCat1", "mtCat2"], mt_cats) - blogger_cats = do_method_call(@layered_controller, 'blogger.getCategories') - assert_equal(["bloggerCat1", "bloggerCat2"], blogger_cats) - end - - def test_utf8 - @direct_controller.web_service_exception_reporting = true - $KCODE = 'u' - assert_equal(Utf8String, do_method_call(@direct_controller, 'TestUtf8')) - retval = SOAP::Processor.unmarshal(@response_body).body.response - assert retval.is_a?(SOAP::SOAPString) - - # If $KCODE is not set to UTF-8, any strings with non-ASCII UTF-8 data - # will be sent back as base64 by SOAP4R. By the time we get it here though, - # it will be decoded back into a string. So lets read the base64 value - # from the message body directly. - $KCODE = 'NONE' - do_method_call(@direct_controller, 'TestUtf8') - retval = SOAP::Processor.unmarshal(@response_body).body.response - assert retval.is_a?(SOAP::SOAPBase64) - assert_equal "T25lIFdvcmxkIENhZsOp", retval.data.to_s - end - - protected - def exception_message(soap_fault_exception) - soap_fault_exception.detail.cause.message - end - - def is_exception?(obj) - obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \ - obj.detail.cause.is_a?(Exception) - end - - def service_name(container) - container.is_a?(DelegatedController) ? 'test_service' : 'api' - end - - def ensure_valid_wsdl_generation(controller, expected_namespace) - wsdl = controller.generate_wsdl - ensure_valid_wsdl(controller, wsdl, expected_namespace) - end - - def ensure_valid_wsdl(controller, wsdl, expected_namespace) - definitions = WSDL::Parser.new.parse(wsdl) - assert(definitions.is_a?(WSDL::Definitions)) - definitions.bindings.each do |binding| - assert(binding.name.name.index(':').nil?) - end - definitions.services.each do |service| - service.ports.each do |port| - assert(port.name.name.index(':').nil?) - end - end - types = definitions.collect_complextypes.map{|x| x.name} - types.each do |type| - assert(type.namespace == expected_namespace) - end - location = definitions.services[0].ports[0].soap_address.location - if controller.is_a?(DelegatedController) - assert_match %r{http://test.host/dispatcher_test/delegated/test_service$}, location - elsif controller.is_a?(DirectController) - assert_match %r{http://test.host/dispatcher_test/direct/api$}, location - end - definitions.collect_complextypes - end - - def ensure_valid_wsdl_action(controller) - test_request = ActionController::TestRequest.new - test_request.action = 'wsdl' - test_response = ActionController::TestResponse.new - wsdl = controller.process(test_request, test_response).body - ensure_valid_wsdl(controller, wsdl, DispatcherTest::WsdlNamespace) - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/dispatcher_action_controller_xmlrpc_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/dispatcher_action_controller_xmlrpc_test.rb deleted file mode 100644 index 8add5766..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/dispatcher_action_controller_xmlrpc_test.rb +++ /dev/null @@ -1,59 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_dispatcher' - -class TC_DispatcherActionControllerXmlRpc < Test::Unit::TestCase - include DispatcherTest - include DispatcherCommonTests - - def setup - @direct_controller = DirectController.new - @delegated_controller = DelegatedController.new - @layered_controller = LayeredController.new - @virtual_controller = VirtualController.new - @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@direct_controller) - end - - def test_layered_dispatching - mt_cats = do_method_call(@layered_controller, 'mt.getCategories') - assert_equal(["mtCat1", "mtCat2"], mt_cats) - blogger_cats = do_method_call(@layered_controller, 'blogger.getCategories') - assert_equal(["bloggerCat1", "bloggerCat2"], blogger_cats) - end - - def test_multicall - response = do_method_call(@layered_controller, 'system.multicall', [ - {'methodName' => 'mt.getCategories'}, - {'methodName' => 'blogger.getCategories'}, - {'methodName' => 'mt.bool'}, - {'methodName' => 'blogger.str', 'params' => ['2000']}, - {'methodName' => 'mt.alwaysFail'}, - {'methodName' => 'blogger.alwaysFail'}, - {'methodName' => 'mt.blah'}, - {'methodName' => 'blah.blah'}, - {'methodName' => 'mt.person'} - ]) - assert_equal [ - [["mtCat1", "mtCat2"]], - [["bloggerCat1", "bloggerCat2"]], - [true], - ["2500"], - {"faultCode" => 3, "faultString" => "MT AlwaysFail"}, - {"faultCode" => 3, "faultString" => "Blogger AlwaysFail"}, - {"faultCode" => 4, "faultMessage" => "no such method 'blah' on API DispatcherTest::MTAPI"}, - {"faultCode" => 4, "faultMessage" => "no such web service 'blah'"}, - [{"name"=>"person1", "id"=>1}] - ], response - end - - protected - def exception_message(xmlrpc_fault_exception) - xmlrpc_fault_exception.faultString - end - - def is_exception?(obj) - obj.is_a?(XMLRPC::FaultException) - end - - def service_name(container) - container.is_a?(DelegatedController) ? 'test_service' : 'api' - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/fixtures/db_definitions/mysql.sql b/vendor/gems/datanoise-actionwebservice-2.3.2/test/fixtures/db_definitions/mysql.sql deleted file mode 100644 index 8e01eef4..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/fixtures/db_definitions/mysql.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE `users` ( - `id` int(11) NOT NULL auto_increment, - `name` varchar(30) default NULL, - `active` tinyint(4) default NULL, - `balance` decimal(5, 2) default NULL, - `created_on` date default NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/fixtures/users.yml b/vendor/gems/datanoise-actionwebservice-2.3.2/test/fixtures/users.yml deleted file mode 100644 index 926d6015..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/fixtures/users.yml +++ /dev/null @@ -1,12 +0,0 @@ -user1: - id: 1 - name: Kent - active: 1 - balance: 12.2 - created_on: <%= Date.today %> -user2: - id: 2 - name: David - active: 1 - balance: 16.4 - created_on: <%= Date.today %> diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/gencov b/vendor/gems/datanoise-actionwebservice-2.3.2/test/gencov deleted file mode 100644 index 1faab34c..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/gencov +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -rcov -x '.*_test\.rb,rubygems,abstract_,/run,/apis' ./run diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/invocation_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/invocation_test.rb deleted file mode 100644 index 3ef22faf..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/invocation_test.rb +++ /dev/null @@ -1,185 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -module InvocationTest - class API < ActionWebService::API::Base - api_method :add, :expects => [:int, :int], :returns => [:int] - api_method :transmogrify, :expects_and_returns => [:string] - api_method :fail_with_reason - api_method :fail_generic - api_method :no_before - api_method :no_after - api_method :only_one - api_method :only_two - end - - class Interceptor - attr :args - - def initialize - @args = nil - end - - def intercept(*args) - @args = args - end - end - - InterceptorClass = Interceptor.new - - class Service < ActionController::Base - web_service_api API - - before_invocation :intercept_before, :except => [:no_before] - after_invocation :intercept_after, :except => [:no_after] - prepend_after_invocation :intercept_after_first, :except => [:no_after] - prepend_before_invocation :intercept_only, :only => [:only_one, :only_two] - after_invocation(:only => [:only_one]) do |*args| - args[0].instance_variable_set('@block_invoked', args[1]) - end - after_invocation InterceptorClass, :only => [:only_one] - - attr_accessor :before_invoked - attr_accessor :after_invoked - attr_accessor :after_first_invoked - attr_accessor :only_invoked - attr_accessor :block_invoked - attr_accessor :invocation_result - - def initialize - @before_invoked = nil - @after_invoked = nil - @after_first_invoked = nil - @only_invoked = nil - @invocation_result = nil - @block_invoked = nil - end - - def add(a, b) - a + b - end - - def transmogrify(str) - str.upcase - end - - def fail_with_reason - end - - def fail_generic - end - - def no_before - 5 - end - - def no_after - end - - def only_one - end - - def only_two - end - - protected - def intercept_before(name, args) - @before_invoked = name - return [false, "permission denied"] if name == :fail_with_reason - return false if name == :fail_generic - end - - def intercept_after(name, args, result) - @after_invoked = name - @invocation_result = result - end - - def intercept_after_first(name, args, result) - @after_first_invoked = name - end - - def intercept_only(name, args) - raise "Interception error" unless name == :only_one || name == :only_two - @only_invoked = name - end - end -end - -class TC_Invocation < Test::Unit::TestCase - include ActionWebService::Invocation - - def setup - @service = InvocationTest::Service.new - end - - def test_invocation - assert(perform_invocation(:add, 5, 10) == 15) - assert(perform_invocation(:transmogrify, "hello") == "HELLO") - assert_raises(NoMethodError) do - perform_invocation(:nonexistent_method_xyzzy) - end - end - - def test_interceptor_registration - assert(InvocationTest::Service.before_invocation_interceptors.length == 2) - assert(InvocationTest::Service.after_invocation_interceptors.length == 4) - assert_equal(:intercept_only, InvocationTest::Service.before_invocation_interceptors[0]) - assert_equal(:intercept_after_first, InvocationTest::Service.after_invocation_interceptors[0]) - end - - def test_interception - assert(@service.before_invoked.nil?) - assert(@service.after_invoked.nil?) - assert(@service.only_invoked.nil?) - assert(@service.block_invoked.nil?) - assert(@service.invocation_result.nil?) - perform_invocation(:add, 20, 50) - assert(@service.before_invoked == :add) - assert(@service.after_invoked == :add) - assert(@service.invocation_result == 70) - end - - def test_interception_canceling - reason = nil - perform_invocation(:fail_with_reason){|r| reason = r} - assert(@service.before_invoked == :fail_with_reason) - assert(@service.after_invoked.nil?) - assert(@service.invocation_result.nil?) - assert(reason == "permission denied") - reason = true - @service.before_invoked = @service.after_invoked = @service.invocation_result = nil - perform_invocation(:fail_generic){|r| reason = r} - assert(@service.before_invoked == :fail_generic) - assert(@service.after_invoked.nil?) - assert(@service.invocation_result.nil?) - assert(reason == true) - end - - def test_interception_except_conditions - perform_invocation(:no_before) - assert(@service.before_invoked.nil?) - assert(@service.after_first_invoked == :no_before) - assert(@service.after_invoked == :no_before) - assert(@service.invocation_result == 5) - @service.before_invoked = @service.after_invoked = @service.invocation_result = nil - perform_invocation(:no_after) - assert(@service.before_invoked == :no_after) - assert(@service.after_invoked.nil?) - assert(@service.invocation_result.nil?) - end - - def test_interception_only_conditions - assert(@service.only_invoked.nil?) - perform_invocation(:only_one) - assert(@service.only_invoked == :only_one) - assert(@service.block_invoked == :only_one) - assert(InvocationTest::InterceptorClass.args[1] == :only_one) - @service.only_invoked = nil - perform_invocation(:only_two) - assert(@service.only_invoked == :only_two) - end - - private - def perform_invocation(method_name, *args, &block) - @service.perform_invocation(method_name, args, &block) - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/run b/vendor/gems/datanoise-actionwebservice-2.3.2/test/run deleted file mode 100644 index c8c03727..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/run +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -require 'test/unit' -$:.unshift(File.dirname(__FILE__) + '/../lib') -args = Dir[File.join(File.dirname(__FILE__), '*_test.rb')] + Dir[File.join(File.dirname(__FILE__), 'ws/*_test.rb')] -(r = Test::Unit::AutoRunner.new(true)).process_args(args) -exit r.run diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/scaffolded_controller_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/scaffolded_controller_test.rb deleted file mode 100644 index 19e21a21..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/scaffolded_controller_test.rb +++ /dev/null @@ -1,146 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -ActionController::Routing::Routes.draw do |map| - map.connect '', :controller => 'scaffolded' - map.connect ':controller/:action/:id' -end - -ActionController::Base.view_paths = [ '.' ] - -class ScaffoldPerson < ActionWebService::Struct - member :id, :int - member :name, :string - member :birth, :date - - def ==(other) - self.id == other.id && self.name == other.name - end -end - -class ScaffoldedControllerTestAPI < ActionWebService::API::Base - api_method :hello, :expects => [{:integer=>:int}, :string], :returns => [:bool] - api_method :hello_struct_param, :expects => [{:person => ScaffoldPerson}], :returns => [:bool] - api_method :date_of_birth, :expects => [ScaffoldPerson], :returns => [:string] - api_method :bye, :returns => [[ScaffoldPerson]] - api_method :date_diff, :expects => [{:start_date => :date}, {:end_date => :date}], :returns => [:int] - api_method :time_diff, :expects => [{:start_time => :time}, {:end_time => :time}], :returns => [:int] - api_method :base64_upcase, :expects => [:base64], :returns => [:base64] -end - -class ScaffoldedController < ActionController::Base - web_service_api ScaffoldedControllerTestAPI - web_service_scaffold :scaffold_invoke - - def hello(int, string) - 0 - end - - def hello_struct_param(person) - 0 - end - - def date_of_birth(person) - person.birth.to_s - end - - def bye - [ScaffoldPerson.new(:id => 1, :name => "leon"), ScaffoldPerson.new(:id => 2, :name => "paul")] - end - - def rescue_action(e) - raise e - end - - def date_diff(start_date, end_date) - end_date - start_date - end - - def time_diff(start_time, end_time) - end_time - start_time - end - - def base64_upcase(data) - data.upcase - end -end - -class ScaffoldedControllerTest < ActionController::TestCase - # def setup - # @controller = ScaffoldedController.new - # @request = ActionController::TestRequest.new - # @response = ActionController::TestResponse.new - # end - - def test_scaffold_invoke - get :scaffold_invoke - assert_template 'methods.html.erb' - end - - def test_scaffold_invoke_method_params - get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'Hello' - assert_template 'parameters.html.erb' - end - - def test_scaffold_invoke_method_params_with_struct - get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'HelloStructParam' - assert_template 'parameters.html.erb' - assert_tag :tag => 'form' - assert_tag :tag => 'input', :attributes => {:name => "method_params[0][name]"} - end - - def test_scaffold_invoke_submit_hello - post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'Hello', :method_params => {'0' => '5', '1' => 'hello world'} - assert_template 'result.html.erb' - assert_equal false, @controller.instance_eval{ @method_return_value } - end - - def test_scaffold_invoke_submit_bye - post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'Bye' - assert_template 'result.html.erb' - persons = [ScaffoldPerson.new(:id => 1, :name => "leon"), ScaffoldPerson.new(:id => 2, :name => "paul")] - assert_equal persons, @controller.instance_eval{ @method_return_value } - end - - def test_scaffold_date_params - get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'DateDiff' - (0..1).each do |param| - (1..3).each do |date_part| - assert_tag :tag => 'select', :attributes => {:name => "method_params[#{param}][#{date_part}]"}, - :children => {:greater_than => 1, :only => {:tag => 'option'}} - end - end - - post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'DateDiff', - :method_params => {'0' => {'1' => '2006', '2' => '2', '3' => '1'}, '1' => {'1' => '2006', '2' => '2', '3' => '2'}} - assert_equal 1, @controller.instance_eval{ @method_return_value } - end - - def test_scaffold_struct_date_params - post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'DateOfBirth', - :method_params => {'0' => {'birth' => {'1' => '2006', '2' => '2', '3' => '1'}, 'id' => '1', 'name' => 'person'}} - assert_equal '2006-02-01', @controller.instance_eval{ @method_return_value } - end - - def test_scaffold_time_params - get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'TimeDiff' - (0..1).each do |param| - (1..6).each do |date_part| - assert_tag :tag => 'select', :attributes => {:name => "method_params[#{param}][#{date_part}]"}, - :children => {:greater_than => 1, :only => {:tag => 'option'}} - end - end - - post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'TimeDiff', - :method_params => {'0' => {'1' => '2006', '2' => '2', '3' => '1', '4' => '1', '5' => '1', '6' => '1'}, - '1' => {'1' => '2006', '2' => '2', '3' => '2', '4' => '1', '5' => '1', '6' => '1'}} - assert_equal 86400, @controller.instance_eval{ @method_return_value } - end - - def test_scaffold_base64 - get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'Base64Upcase' - assert_tag :tag => 'textarea', :attributes => {:name => 'method_params[0]'} - - post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'Base64Upcase', :method_params => {'0' => 'scaffold'} - assert_equal 'SCAFFOLD', @controller.instance_eval{ @method_return_value } - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/struct_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/struct_test.rb deleted file mode 100644 index f689746e..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/struct_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -module StructTest - class Struct < ActionWebService::Struct - member :id, Integer - member :name, String - member :items, [String] - member :deleted, :bool - member :emails, [:string] - end -end - -class TC_Struct < Test::Unit::TestCase - include StructTest - - def setup - @struct = Struct.new(:id => 5, - :name => 'hello', - :items => ['one', 'two'], - :deleted => true, - :emails => ['test@test.com']) - end - - def test_members - assert_equal(5, Struct.members.size) - assert_equal(Integer, Struct.members[:id].type_class) - assert_equal(String, Struct.members[:name].type_class) - assert_equal(String, Struct.members[:items].element_type.type_class) - assert_equal(TrueClass, Struct.members[:deleted].type_class) - assert_equal(String, Struct.members[:emails].element_type.type_class) - end - - def test_initializer_and_lookup - assert_equal(5, @struct.id) - assert_equal('hello', @struct.name) - assert_equal(['one', 'two'], @struct.items) - assert_equal(true, @struct.deleted) - assert_equal(['test@test.com'], @struct.emails) - assert_equal(5, @struct['id']) - assert_equal('hello', @struct['name']) - assert_equal(['one', 'two'], @struct['items']) - assert_equal(true, @struct['deleted']) - assert_equal(['test@test.com'], @struct['emails']) - end - - def test_each_pair - @struct.each_pair do |name, value| - assert_equal @struct.__send__(name), value - assert_equal @struct[name], value - end - end -end diff --git a/vendor/gems/datanoise-actionwebservice-2.3.2/test/test_invoke_test.rb b/vendor/gems/datanoise-actionwebservice-2.3.2/test/test_invoke_test.rb deleted file mode 100644 index 7291797a..00000000 --- a/vendor/gems/datanoise-actionwebservice-2.3.2/test/test_invoke_test.rb +++ /dev/null @@ -1,112 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' -require 'action_web_service/test_invoke' - -class TestInvokeAPI < ActionWebService::API::Base - api_method :null - api_method :add, :expects => [:int, :int], :returns => [:int] -end - -class TestInvokeService < ActionWebService::Base - web_service_api TestInvokeAPI - - attr :invoked - - def add(a, b) - @invoked = true - a + b - end - - def null - end -end - -class TestController < ActionController::Base - def rescue_action(e); raise e; end -end - -class TestInvokeDirectController < TestController - web_service_api TestInvokeAPI - - attr :invoked - - def add - @invoked = true - @method_params[0] + @method_params[1] - end - - def null - end -end - -class TestInvokeDelegatedController < TestController - web_service_dispatching_mode :delegated - web_service :service, TestInvokeService.new -end - -class TestInvokeLayeredController < TestController - web_service_dispatching_mode :layered - web_service(:one) { @service_one ||= TestInvokeService.new } - web_service(:two) { @service_two ||= TestInvokeService.new } -end - -class TestInvokeTest < ActiveSupport::TestCase - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_direct_add - @controller = TestInvokeDirectController.new - assert_equal nil, @controller.invoked - result = invoke :add, 25, 25 - assert_equal 50, result - assert_equal true, @controller.invoked - end - - def test_delegated_add - @controller = TestInvokeDelegatedController.new - assert_equal nil, @controller.web_service_object(:service).invoked - result = invoke_delegated :service, :add, 100, 50 - assert_equal 150, result - assert_equal true, @controller.web_service_object(:service).invoked - end - - def test_layered_add - [:soap, :xmlrpc].each do |protocol| - @protocol = protocol - [:one, :two].each do |service| - @controller = TestInvokeLayeredController.new - assert_equal nil, @controller.web_service_object(service).invoked - result = invoke_layered service, :add, 200, -50 - assert_equal 150, result - assert_equal true, @controller.web_service_object(service).invoked - end - end - end - - def test_layered_fail_with_wrong_number_of_arguments - [:soap, :xmlrpc].each do |protocol| - @protocol = protocol - [:one, :two].each do |service| - @controller = TestInvokeLayeredController.new - assert_raise(ArgumentError) { invoke_layered service, :add, 1 } - end - end - end - - def test_delegated_fail_with_wrong_number_of_arguments - @controller = TestInvokeDelegatedController.new - assert_raise(ArgumentError) { invoke_delegated :service, :add, 1 } - end - - def test_direct_fail_with_wrong_number_of_arguments - @controller = TestInvokeDirectController.new - assert_raise(ArgumentError) { invoke :add, 1 } - end - - def test_with_no_parameters_declared - @controller = TestInvokeDirectController.new - assert_nil invoke(:null) - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/.specification b/vendor/gems/has_many_polymorphs-2.13/.specification deleted file mode 100644 index 6cf0d84b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/.specification +++ /dev/null @@ -1,309 +0,0 @@ ---- !ruby/object:Gem::Specification -name: has_many_polymorphs -version: !ruby/object:Gem::Version - hash: 25 - prerelease: false - segments: - - 2 - - 13 - version: "2.13" -platform: ruby -authors: -- "" -autorequire: -bindir: bin -cert_chain: -- | - -----BEGIN CERTIFICATE----- - MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARldmFu - MRgwFgYKCZImiZPyLGQBGRYIY2xvdWRidXIxEjAQBgoJkiaJk/IsZAEZFgJzdDAe - Fw0wNzA5MTYxMDMzMDBaFw0wODA5MTUxMDMzMDBaMD0xDTALBgNVBAMMBGV2YW4x - GDAWBgoJkiaJk/IsZAEZFghjbG91ZGJ1cjESMBAGCgmSJomT8ixkARkWAnN0MIIB - IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C0Io89nyApnr+PvbNFge9Vs - yRWAlGBUEMahpXp28VrrfXZT0rAW7JBo4PlCE3jl4nE4dzE6gAdItSycjTosrw7A - Ir5+xoyl4Vb35adv56TIQQXvNz+BzlqnkAY5JN0CSBRTQb6mxS3hFyD/h4qgDosj - R2RFVzHqSxCS8xq4Ny8uzOwOi+Xyu4w67fI5JvnPvMxqrlR1eaIQHmxnf76RzC46 - QO5QhufjAYGGXd960XzbQsQyTDUYJzrvT7AdOfiyZzKQykKt8dEpDn+QPjFTnGnT - QmgJBX5WJN0lHF2l1sbv3gh4Kn1tZu+kTUqeXY6ShAoDTyvZRiFqQdwh8w2lTQID - AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU+WqJz3xQ - XSea1hRvvHWcIMgeeC4wDQYJKoZIhvcNAQEFBQADggEBAGLZ75jfOEW8Nsl26CTt - JFrWxQTcQT/UljeefVE3xYr7lc9oQjbqO3FOyued3qW7TaNEtZfSHoYeUSMYbpw1 - XAwocIPuSRFDGM4B+hgQGVDx8PMGiJKom4qLXjO40UZsR7QyN/u869Vj45LURm6h - MBcPeqCASI+WNprj9+uZa2kmHiitrFqqfMBNlm5IFbn9XeYSta9AHVvs5QQqV2m5 - hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr - x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+ - yZ0= - -----END CERTIFICATE----- - -date: 2009-02-02 00:00:00 +01:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: activerecord - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :runtime - version_requirements: *id001 -- !ruby/object:Gem::Dependency - name: echoe - prerelease: false - requirement: &id002 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id002 -description: An ActiveRecord plugin for self-referential and double-sided polymorphic associations. -email: "" -executables: [] - -extensions: [] - -extra_rdoc_files: -- CHANGELOG -- generators/tagging/templates/migration.rb -- generators/tagging/templates/tag.rb -- generators/tagging/templates/tagging.rb -- generators/tagging/templates/tagging_extensions.rb -- lib/has_many_polymorphs/association.rb -- lib/has_many_polymorphs/autoload.rb -- lib/has_many_polymorphs/class_methods.rb -- lib/has_many_polymorphs/configuration.rb -- lib/has_many_polymorphs/reflection.rb -- LICENSE -- README -- test/integration/app/doc/README_FOR_APP -- test/integration/app/README -- TODO -files: -- CHANGELOG -- examples/hmph.rb -- generators/tagging/tagging_generator.rb -- generators/tagging/templates/migration.rb -- generators/tagging/templates/tag.rb -- generators/tagging/templates/tag_test.rb -- generators/tagging/templates/tagging.rb -- generators/tagging/templates/tagging_extensions.rb -- generators/tagging/templates/tagging_test.rb -- generators/tagging/templates/taggings.yml -- generators/tagging/templates/tags.yml -- init.rb -- lib/has_many_polymorphs/association.rb -- lib/has_many_polymorphs/autoload.rb -- lib/has_many_polymorphs/base.rb -- lib/has_many_polymorphs/class_methods.rb -- lib/has_many_polymorphs/configuration.rb -- lib/has_many_polymorphs/debugging_tools.rb -- lib/has_many_polymorphs/rake_task_redefine_task.rb -- lib/has_many_polymorphs/reflection.rb -- lib/has_many_polymorphs/support_methods.rb -- lib/has_many_polymorphs.rb -- LICENSE -- Manifest -- Rakefile -- README -- test/fixtures/bow_wows.yml -- test/fixtures/cats.yml -- test/fixtures/eaters_foodstuffs.yml -- test/fixtures/fish.yml -- test/fixtures/frogs.yml -- test/fixtures/keep_your_enemies_close.yml -- test/fixtures/little_whale_pupils.yml -- test/fixtures/people.yml -- test/fixtures/petfoods.yml -- test/fixtures/whales.yml -- test/fixtures/wild_boars.yml -- test/generator/tagging_generator_test.rb -- test/integration/app/app/controllers/application.rb -- test/integration/app/app/controllers/bones_controller.rb -- test/integration/app/app/helpers/addresses_helper.rb -- test/integration/app/app/helpers/application_helper.rb -- test/integration/app/app/helpers/bones_helper.rb -- test/integration/app/app/helpers/sellers_helper.rb -- test/integration/app/app/helpers/states_helper.rb -- test/integration/app/app/helpers/users_helper.rb -- test/integration/app/app/models/bone.rb -- test/integration/app/app/models/double_sti_parent.rb -- test/integration/app/app/models/double_sti_parent_relationship.rb -- test/integration/app/app/models/organic_substance.rb -- test/integration/app/app/models/single_sti_parent.rb -- test/integration/app/app/models/single_sti_parent_relationship.rb -- test/integration/app/app/models/stick.rb -- test/integration/app/app/models/stone.rb -- test/integration/app/app/views/addresses/edit.html.erb -- test/integration/app/app/views/addresses/index.html.erb -- test/integration/app/app/views/addresses/new.html.erb -- test/integration/app/app/views/addresses/show.html.erb -- test/integration/app/app/views/bones/index.rhtml -- test/integration/app/app/views/layouts/addresses.html.erb -- test/integration/app/app/views/layouts/sellers.html.erb -- test/integration/app/app/views/layouts/states.html.erb -- test/integration/app/app/views/layouts/users.html.erb -- test/integration/app/app/views/sellers/edit.html.erb -- test/integration/app/app/views/sellers/index.html.erb -- test/integration/app/app/views/sellers/new.html.erb -- test/integration/app/app/views/sellers/show.html.erb -- test/integration/app/app/views/states/edit.html.erb -- test/integration/app/app/views/states/index.html.erb -- test/integration/app/app/views/states/new.html.erb -- test/integration/app/app/views/states/show.html.erb -- test/integration/app/app/views/users/edit.html.erb -- test/integration/app/app/views/users/index.html.erb -- test/integration/app/app/views/users/new.html.erb -- test/integration/app/app/views/users/show.html.erb -- test/integration/app/config/boot.rb -- test/integration/app/config/database.yml -- test/integration/app/config/environment.rb -- test/integration/app/config/environment.rb.canonical -- test/integration/app/config/environments/development.rb -- test/integration/app/config/environments/production.rb -- test/integration/app/config/environments/test.rb -- test/integration/app/config/locomotive.yml -- test/integration/app/config/routes.rb -- test/integration/app/config/ultrasphinx/default.base -- test/integration/app/config/ultrasphinx/development.conf.canonical -- test/integration/app/db/migrate/001_create_sticks.rb -- test/integration/app/db/migrate/002_create_stones.rb -- test/integration/app/db/migrate/003_create_organic_substances.rb -- test/integration/app/db/migrate/004_create_bones.rb -- test/integration/app/db/migrate/005_create_single_sti_parents.rb -- test/integration/app/db/migrate/006_create_double_sti_parents.rb -- test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb -- test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb -- test/integration/app/db/migrate/009_create_library_model.rb -- test/integration/app/doc/README_FOR_APP -- test/integration/app/generators/commenting_generator_test.rb -- test/integration/app/lib/library_model.rb -- test/integration/app/public/404.html -- test/integration/app/public/500.html -- test/integration/app/public/dispatch.cgi -- test/integration/app/public/dispatch.fcgi -- test/integration/app/public/dispatch.rb -- test/integration/app/public/favicon.ico -- test/integration/app/public/images/rails.png -- test/integration/app/public/index.html -- test/integration/app/public/javascripts/application.js -- test/integration/app/public/javascripts/controls.js -- test/integration/app/public/javascripts/dragdrop.js -- test/integration/app/public/javascripts/effects.js -- test/integration/app/public/javascripts/prototype.js -- test/integration/app/public/robots.txt -- test/integration/app/public/stylesheets/scaffold.css -- test/integration/app/Rakefile -- test/integration/app/README -- test/integration/app/script/about -- test/integration/app/script/breakpointer -- test/integration/app/script/console -- test/integration/app/script/destroy -- test/integration/app/script/generate -- test/integration/app/script/performance/benchmarker -- test/integration/app/script/performance/profiler -- test/integration/app/script/plugin -- test/integration/app/script/process/inspector -- test/integration/app/script/process/reaper -- test/integration/app/script/process/spawner -- test/integration/app/script/runner -- test/integration/app/script/server -- test/integration/app/test/fixtures/double_sti_parent_relationships.yml -- test/integration/app/test/fixtures/double_sti_parents.yml -- test/integration/app/test/fixtures/organic_substances.yml -- test/integration/app/test/fixtures/single_sti_parent_relationships.yml -- test/integration/app/test/fixtures/single_sti_parents.yml -- test/integration/app/test/fixtures/sticks.yml -- test/integration/app/test/fixtures/stones.yml -- test/integration/app/test/functional/addresses_controller_test.rb -- test/integration/app/test/functional/bones_controller_test.rb -- test/integration/app/test/functional/sellers_controller_test.rb -- test/integration/app/test/functional/states_controller_test.rb -- test/integration/app/test/functional/users_controller_test.rb -- test/integration/app/test/test_helper.rb -- test/integration/app/test/unit/bone_test.rb -- test/integration/app/test/unit/double_sti_parent_relationship_test.rb -- test/integration/app/test/unit/double_sti_parent_test.rb -- test/integration/app/test/unit/organic_substance_test.rb -- test/integration/app/test/unit/single_sti_parent_relationship_test.rb -- test/integration/app/test/unit/single_sti_parent_test.rb -- test/integration/app/test/unit/stick_test.rb -- test/integration/app/test/unit/stone_test.rb -- test/integration/server_test.rb -- test/models/aquatic/fish.rb -- test/models/aquatic/pupils_whale.rb -- test/models/aquatic/whale.rb -- test/models/beautiful_fight_relationship.rb -- test/models/canine.rb -- test/models/cat.rb -- test/models/dog.rb -- test/models/eaters_foodstuff.rb -- test/models/frog.rb -- test/models/kitten.rb -- test/models/parentship.rb -- test/models/person.rb -- test/models/petfood.rb -- test/models/tabby.rb -- test/models/wild_boar.rb -- test/modules/extension_module.rb -- test/modules/other_extension_module.rb -- test/patches/symlinked_plugins_1.2.6.diff -- test/schema.rb -- test/setup.rb -- test/test_helper.rb -- test/unit/has_many_polymorphs_test.rb -- TODO -- has_many_polymorphs.gemspec -has_rdoc: true -homepage: http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/ -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --inline-source -- --title -- Has_many_polymorphs -- --main -- README -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" -required_rubygems_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 11 - segments: - - 1 - - 2 - version: "1.2" -requirements: [] - -rubyforge_project: fauna -rubygems_version: 1.3.7 -signing_key: -specification_version: 2 -summary: An ActiveRecord plugin for self-referential and double-sided polymorphic associations. -test_files: -- test/generator/tagging_generator_test.rb -- test/integration/server_test.rb -- test/unit/has_many_polymorphs_test.rb diff --git a/vendor/gems/has_many_polymorphs-2.13/CHANGELOG b/vendor/gems/has_many_polymorphs-2.13/CHANGELOG deleted file mode 100644 index ec8ef45f..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/CHANGELOG +++ /dev/null @@ -1,84 +0,0 @@ -v2.13. Merge various fixes for Rails 2.2.2. - -v2.12. Improvements to the test suite; bugfixes for STI children (rsl). Remove fancy dependency system in favor of using Dispatcher::to_prepare every time. - -v2.11. Rails 1.2.6 tagging generator compatibility; change test suite to use included integration app. - -v2.10. Add :parent_conditions option; bugfix for nullified conditions; bugfix for self-referential tagging generator; allow setting of has_many_polymorphs_options hash in Configuration's after_initialize if you need to adjust the autoload behavior; clear error message on missing or improperly namespaced models; fix .build on double-sided relationships; add :namespace key for easier set up of Camping apps or other unusual class structures. - -v2.9. Gem version renumbering; my apologies if this messes anyone up. - -v2.8. RDoc documentation; repository relocation; Rakefile cleanup; remove deprecated plugin-specific class caching. - -v2.7.5. Various bugfixes; Postgres problems may remain on edge. - -v2.7.3. Use new :source and :source_type options in 1.2.3 (David Lemstra); fix pluralization bug; add some tests; experimental tagging generator. - -v2.7.2. Deprecate has_many_polymorphs_cache_classes= option because it doesn't really work. Use config.cache_classes= instead to cache all reloadable items. - -v2.7.1. Dispatcher.to_prepare didn't fire in the console; now using a config.after_initialize wrapper instead. - -v2.7. Dependency injection framework elimates having to care about load order. - -v2.6. Make the logger act sane for the gem version. - -v2.5.2. Allow :skip_duplicates on double relationships. - -v2.5.1. Renamed :ignore_duplicates to :skip_duplicates to better express its non-passive behavior; made sure not to load target set on push unless necessary. - -v2.5. Activerecord compatibility branch becomes trunk: extra options now supported for double polymorphism; conditions nulled-out and propogated to child relationships; more tests; new :ignore_duplicates option on macro can be set to false if you want << to push duplicate associations. - -v2.4.1. Code split into multiple files; tests added for pluralization check; Rails 1.1.6 no longer supported. - -v2.4. Unlimited mixed class association extensions for both single and double targets and joins. - -v2.3. Gem version - -v2.2. API change; prefix on methods is now singular when using :rename_individual_collections. - -v2.1. Add configuration option to cache polymorphic classes in development mode. - -v2.0. Collection methods (push, delete, clear) now on individual collections. - -v1.9.2. Disjoint collection sides bugfix, don't raise on new records. - -v1.9.1. Double classify bugfix. - -v1.9. Large changes to properly support double polymorphism. - -v1.8.2. Bugfix to make sure the type gets checked on doubly polymorphic parents. - -v1.8.1. Bugfix for sqlite3 child attribute retrieval. - -v1.8. Bugfix for instantiating attributes of namespaced models. - -v1.7.1. Bugfix for double polymorphic relationships. - -v1.7. Double polymorphic relationships (includes new API method). - -v1.6. Namespaced model support. - -v1.5. Bugfix for Postgres and Mysql under 1.1.6; refactored tests (hildofur); properly handles legacy table names set with set_table_name(). - -v1.4. STI support added (use the child class names, not the base class). - -v1.3. Bug regarding table names with underscores in SQL query fixed. - -v1.2. License change, again. - -v1.1. File_column bug fixed. - -v1.0. Tests written; after_find and after_initialize now correctly called. - -v0.5. SQL performance enhancements added. - -v0.4. Rewrote singletons as full-fledged proxy class so that marshalling works (e.g. in the session). - -v0.3. Caching added. - -v0.2. Fixed dependency reloading problem in development mode. - -v0.1. License change. - -v0. Added :dependent support on the join table; no changelog before this version. - diff --git a/vendor/gems/has_many_polymorphs-2.13/LICENSE b/vendor/gems/has_many_polymorphs-2.13/LICENSE deleted file mode 100644 index 90eec26b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/LICENSE +++ /dev/null @@ -1,184 +0,0 @@ -Academic Free License (AFL) v. 3.0 - -This Academic Free License (the "License") applies to any original work -of authorship (the "Original Work") whose owner (the "Licensor") has -placed the following licensing notice adjacent to the copyright notice -for the Original Work: - -Licensed under the Academic Free License version 3.0 - -1) Grant of Copyright License. Licensor grants You a worldwide, -royalty-free, non-exclusive, sublicensable license, for the duration of -the copyright, to do the following: - -a) to reproduce the Original Work in copies, either alone or as part of -a collective work; - -b) to translate, adapt, alter, transform, modify, or arrange the -Original Work, thereby creating derivative works ("Derivative Works") -based upon the Original Work; - -c) to distribute or communicate copies of the Original Work and -Derivative Works to the public, under any license of your choice that -does not contradict the terms and conditions, including Licensor's -reserved rights and remedies, in this Academic Free License; - -d) to perform the Original Work publicly; and - -e) to display the Original Work publicly. - -2) Grant of Patent License. Licensor grants You a worldwide, -royalty-free, non-exclusive, sublicensable license, under patent claims -owned or controlled by the Licensor that are embodied in the Original -Work as furnished by the Licensor, for the duration of the patents, to -make, use, sell, offer for sale, have made, and import the Original Work -and Derivative Works. - -3) Grant of Source Code License. The term "Source Code" means the -preferred form of the Original Work for making modifications to it and -all available documentation describing how to modify the Original Work. -Licensor agrees to provide a machine-readable copy of the Source Code of -the Original Work along with each copy of the Original Work that -Licensor distributes. Licensor reserves the right to satisfy this -obligation by placing a machine-readable copy of the Source Code in an -information repository reasonably calculated to permit inexpensive and -convenient access by You for as long as Licensor continues to distribute -the Original Work. - -4) Exclusions From License Grant. Neither the names of Licensor, nor the -names of any contributors to the Original Work, nor any of their -trademarks or service marks, may be used to endorse or promote products -derived from this Original Work without express prior permission of the -Licensor. Except as expressly stated herein, nothing in this License -grants any license to Licensor's trademarks, copyrights, patents, trade -secrets or any other intellectual property. No patent license is granted -to make, use, sell, offer for sale, have made, or import embodiments of -any patent claims other than the licensed claims defined in Section 2. -No license is granted to the trademarks of Licensor even if such marks -are included in the Original Work. Nothing in this License shall be -interpreted to prohibit Licensor from licensing under terms different -from this License any Original Work that Licensor otherwise would have a -right to license. - -5) External Deployment. The term "External Deployment" means the use, -distribution, or communication of the Original Work or Derivative Works -in any way such that the Original Work or Derivative Works may be used -by anyone other than You, whether those works are distributed or -communicated to those persons or made available as an application -intended for use over a network. As an express condition for the grants -of license hereunder, You must treat any External Deployment by You of -the Original Work or a Derivative Work as a distribution under section -1(c). - -6) Attribution Rights. You must retain, in the Source Code of any -Derivative Works that You create, all copyright, patent, or trademark -notices from the Source Code of the Original Work, as well as any -notices of licensing and any descriptive text identified therein as an -"Attribution Notice." You must cause the Source Code for any Derivative -Works that You create to carry a prominent Attribution Notice reasonably -calculated to inform recipients that You have modified the Original -Work. - -7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants -that the copyright in and to the Original Work and the patent rights -granted herein by Licensor are owned by the Licensor or are sublicensed -to You under the terms of this License with the permission of the -contributor(s) of those copyrights and patent rights. Except as -expressly stated in the immediately preceding sentence, the Original -Work is provided under this License on an "AS IS" BASIS and WITHOUT -WARRANTY, either express or implied, including, without limitation, the -warranties of non-infringement, merchantability or fitness for a -particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL -WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential -part of this License. No license to the Original Work is granted by this -License except under this disclaimer. - -8) Limitation of Liability. Under no circumstances and under no legal -theory, whether in tort (including negligence), contract, or otherwise, -shall the Licensor be liable to anyone for any indirect, special, -incidental, or consequential damages of any character arising as a -result of this License or the use of the Original Work including, -without limitation, damages for loss of goodwill, work stoppage, -computer failure or malfunction, or any and all other commercial damages -or losses. This limitation of liability shall not apply to the extent -applicable law prohibits such limitation. - -9) Acceptance and Termination. If, at any time, You expressly assented -to this License, that assent indicates your clear and irrevocable -acceptance of this License and all of its terms and conditions. If You -distribute or communicate copies of the Original Work or a Derivative -Work, You must make a reasonable effort under the circumstances to -obtain the express assent of recipients to the terms of this License. -This License conditions your rights to undertake the activities listed -in Section 1, including your right to create Derivative Works based upon -the Original Work, and doing so without honoring these terms and -conditions is prohibited by copyright law and international treaty. -Nothing in this License is intended to affect copyright exceptions and -limitations (including "fair use" or "fair dealing"). This License shall -terminate immediately and You may no longer exercise any of the rights -granted to You by this License upon your failure to honor the conditions -in Section 1(c). - -10) Termination for Patent Action. This License shall terminate -automatically and You may no longer exercise any of the rights granted -to You by this License as of the date You commence an action, including -a cross-claim or counterclaim, against Licensor or any licensee alleging -that the Original Work infringes a patent. This termination provision -shall not apply for an action alleging patent infringement by -combinations of the Original Work with other software or hardware. - -11) Jurisdiction, Venue and Governing Law. Any action or suit relating -to this License may be brought only in the courts of a jurisdiction -wherein the Licensor resides or in which Licensor conducts its primary -business, and under the laws of that jurisdiction excluding its -conflict-of-law provisions. The application of the United Nations -Convention on Contracts for the International Sale of Goods is expressly -excluded. Any use of the Original Work outside the scope of this License -or after its termination shall be subject to the requirements and -penalties of copyright or patent law in the appropriate jurisdiction. -This section shall survive the termination of this License. - -12) Attorneys' Fees. In any action to enforce the terms of this License -or seeking damages relating thereto, the prevailing party shall be -entitled to recover its costs and expenses, including, without -limitation, reasonable attorneys' fees and costs incurred in connection -with such action, including any appeal of such action. This section -shall survive the termination of this License. - -13) Miscellaneous. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. - -14) Definition of "You" in This License. "You" throughout this License, -whether in upper or lower case, means an individual or a legal entity -exercising rights under, and complying with all of the terms of, this -License. For legal entities, "You" includes any entity that controls, is -controlled by, or is under common control with you. For purposes of this -definition, "control" means (i) the power, direct or indirect, to cause -the direction or management of such entity, whether by contract or -otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -15) Right to Use. You may use the Original Work in all ways not -otherwise restricted or conditioned by this License or by law, and -Licensor promises not to interfere with or be responsible for such uses -by You. - -16) Modification of This License. This License is Copyright (c) 2005 -Lawrence Rosen. Permission is granted to copy, distribute, or -communicate this License without modification. Nothing in this License -permits You to modify this License as applied to the Original Work or to -Derivative Works. However, You may modify the text of this License and -copy, distribute or communicate your modified version (the "Modified -License") and apply it to other original works of authorship subject to -the following conditions: (i) You may not indicate in any way that your -Modified License is the "Academic Free License" or "AFL" and you may not -use those names in the name of your Modified License; (ii) You must -replace the notice specified in the first paragraph above with the -notice "Licensed under " or with a notice -of your own that is not confusingly similar to the notice in this -License; and (iii) You may not claim that your original works are open -source software unless your Modified License has been approved by Open -Source Initiative (OSI) and You comply with its license review and -certification process. - diff --git a/vendor/gems/has_many_polymorphs-2.13/Manifest b/vendor/gems/has_many_polymorphs-2.13/Manifest deleted file mode 100644 index c0555eff..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/Manifest +++ /dev/null @@ -1,173 +0,0 @@ -CHANGELOG -examples/hmph.rb -generators/tagging/tagging_generator.rb -generators/tagging/templates/migration.rb -generators/tagging/templates/tag.rb -generators/tagging/templates/tag_test.rb -generators/tagging/templates/tagging.rb -generators/tagging/templates/tagging_extensions.rb -generators/tagging/templates/tagging_test.rb -generators/tagging/templates/taggings.yml -generators/tagging/templates/tags.yml -init.rb -lib/has_many_polymorphs/association.rb -lib/has_many_polymorphs/autoload.rb -lib/has_many_polymorphs/base.rb -lib/has_many_polymorphs/class_methods.rb -lib/has_many_polymorphs/configuration.rb -lib/has_many_polymorphs/debugging_tools.rb -lib/has_many_polymorphs/rake_task_redefine_task.rb -lib/has_many_polymorphs/reflection.rb -lib/has_many_polymorphs/support_methods.rb -lib/has_many_polymorphs.rb -LICENSE -Manifest -Rakefile -README -test/fixtures/bow_wows.yml -test/fixtures/cats.yml -test/fixtures/eaters_foodstuffs.yml -test/fixtures/fish.yml -test/fixtures/frogs.yml -test/fixtures/keep_your_enemies_close.yml -test/fixtures/little_whale_pupils.yml -test/fixtures/people.yml -test/fixtures/petfoods.yml -test/fixtures/whales.yml -test/fixtures/wild_boars.yml -test/generator/tagging_generator_test.rb -test/integration/app/app/controllers/application.rb -test/integration/app/app/controllers/bones_controller.rb -test/integration/app/app/helpers/addresses_helper.rb -test/integration/app/app/helpers/application_helper.rb -test/integration/app/app/helpers/bones_helper.rb -test/integration/app/app/helpers/sellers_helper.rb -test/integration/app/app/helpers/states_helper.rb -test/integration/app/app/helpers/users_helper.rb -test/integration/app/app/models/bone.rb -test/integration/app/app/models/double_sti_parent.rb -test/integration/app/app/models/double_sti_parent_relationship.rb -test/integration/app/app/models/organic_substance.rb -test/integration/app/app/models/single_sti_parent.rb -test/integration/app/app/models/single_sti_parent_relationship.rb -test/integration/app/app/models/stick.rb -test/integration/app/app/models/stone.rb -test/integration/app/app/views/addresses/edit.html.erb -test/integration/app/app/views/addresses/index.html.erb -test/integration/app/app/views/addresses/new.html.erb -test/integration/app/app/views/addresses/show.html.erb -test/integration/app/app/views/bones/index.rhtml -test/integration/app/app/views/layouts/addresses.html.erb -test/integration/app/app/views/layouts/sellers.html.erb -test/integration/app/app/views/layouts/states.html.erb -test/integration/app/app/views/layouts/users.html.erb -test/integration/app/app/views/sellers/edit.html.erb -test/integration/app/app/views/sellers/index.html.erb -test/integration/app/app/views/sellers/new.html.erb -test/integration/app/app/views/sellers/show.html.erb -test/integration/app/app/views/states/edit.html.erb -test/integration/app/app/views/states/index.html.erb -test/integration/app/app/views/states/new.html.erb -test/integration/app/app/views/states/show.html.erb -test/integration/app/app/views/users/edit.html.erb -test/integration/app/app/views/users/index.html.erb -test/integration/app/app/views/users/new.html.erb -test/integration/app/app/views/users/show.html.erb -test/integration/app/config/boot.rb -test/integration/app/config/database.yml -test/integration/app/config/environment.rb -test/integration/app/config/environment.rb.canonical -test/integration/app/config/environments/development.rb -test/integration/app/config/environments/production.rb -test/integration/app/config/environments/test.rb -test/integration/app/config/locomotive.yml -test/integration/app/config/routes.rb -test/integration/app/config/ultrasphinx/default.base -test/integration/app/config/ultrasphinx/development.conf.canonical -test/integration/app/db/migrate/001_create_sticks.rb -test/integration/app/db/migrate/002_create_stones.rb -test/integration/app/db/migrate/003_create_organic_substances.rb -test/integration/app/db/migrate/004_create_bones.rb -test/integration/app/db/migrate/005_create_single_sti_parents.rb -test/integration/app/db/migrate/006_create_double_sti_parents.rb -test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb -test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb -test/integration/app/db/migrate/009_create_library_model.rb -test/integration/app/doc/README_FOR_APP -test/integration/app/generators/commenting_generator_test.rb -test/integration/app/lib/library_model.rb -test/integration/app/public/404.html -test/integration/app/public/500.html -test/integration/app/public/dispatch.cgi -test/integration/app/public/dispatch.fcgi -test/integration/app/public/dispatch.rb -test/integration/app/public/favicon.ico -test/integration/app/public/images/rails.png -test/integration/app/public/index.html -test/integration/app/public/javascripts/application.js -test/integration/app/public/javascripts/controls.js -test/integration/app/public/javascripts/dragdrop.js -test/integration/app/public/javascripts/effects.js -test/integration/app/public/javascripts/prototype.js -test/integration/app/public/robots.txt -test/integration/app/public/stylesheets/scaffold.css -test/integration/app/Rakefile -test/integration/app/README -test/integration/app/script/about -test/integration/app/script/breakpointer -test/integration/app/script/console -test/integration/app/script/destroy -test/integration/app/script/generate -test/integration/app/script/performance/benchmarker -test/integration/app/script/performance/profiler -test/integration/app/script/plugin -test/integration/app/script/process/inspector -test/integration/app/script/process/reaper -test/integration/app/script/process/spawner -test/integration/app/script/runner -test/integration/app/script/server -test/integration/app/test/fixtures/double_sti_parent_relationships.yml -test/integration/app/test/fixtures/double_sti_parents.yml -test/integration/app/test/fixtures/organic_substances.yml -test/integration/app/test/fixtures/single_sti_parent_relationships.yml -test/integration/app/test/fixtures/single_sti_parents.yml -test/integration/app/test/fixtures/sticks.yml -test/integration/app/test/fixtures/stones.yml -test/integration/app/test/functional/addresses_controller_test.rb -test/integration/app/test/functional/bones_controller_test.rb -test/integration/app/test/functional/sellers_controller_test.rb -test/integration/app/test/functional/states_controller_test.rb -test/integration/app/test/functional/users_controller_test.rb -test/integration/app/test/test_helper.rb -test/integration/app/test/unit/bone_test.rb -test/integration/app/test/unit/double_sti_parent_relationship_test.rb -test/integration/app/test/unit/double_sti_parent_test.rb -test/integration/app/test/unit/organic_substance_test.rb -test/integration/app/test/unit/single_sti_parent_relationship_test.rb -test/integration/app/test/unit/single_sti_parent_test.rb -test/integration/app/test/unit/stick_test.rb -test/integration/app/test/unit/stone_test.rb -test/integration/server_test.rb -test/models/aquatic/fish.rb -test/models/aquatic/pupils_whale.rb -test/models/aquatic/whale.rb -test/models/beautiful_fight_relationship.rb -test/models/canine.rb -test/models/cat.rb -test/models/dog.rb -test/models/eaters_foodstuff.rb -test/models/frog.rb -test/models/kitten.rb -test/models/parentship.rb -test/models/person.rb -test/models/petfood.rb -test/models/tabby.rb -test/models/wild_boar.rb -test/modules/extension_module.rb -test/modules/other_extension_module.rb -test/patches/symlinked_plugins_1.2.6.diff -test/schema.rb -test/setup.rb -test/test_helper.rb -test/unit/has_many_polymorphs_test.rb -TODO diff --git a/vendor/gems/has_many_polymorphs-2.13/README b/vendor/gems/has_many_polymorphs-2.13/README deleted file mode 100644 index 2f3f73f9..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/README +++ /dev/null @@ -1,205 +0,0 @@ -Has_many_polymorphs - -An ActiveRecord plugin for self-referential and double-sided polymorphic associations. - -== License - -Copyright 2006-2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. - -The public certificate for the gem is here[http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem]. - -If you use this software, please {make a donation}[http://blog.evanweaver.com/donate/], or {recommend Evan}[http://www.workingwithrails.com/person/7739-evan-weaver] at Working with Rails. - -== Description - -This plugin lets you define self-referential and double-sided polymorphic associations in your models. It is an extension of has_many :through. - -“Polymorphic” means an association can freely point to any of several unrelated model classes, instead of being tied to one particular class. - -== Features - -* self-references -* double-sided polymorphism -* efficient database usage -* STI support -* namespace support -* automatic individual and reverse associations - -The plugin also includes a generator for a tagging system, a common use case (see below). - -== Requirements - -* Rails 2.2.2 or greater - -= Usage - -== Installation - -To install the Rails plugin, run: - script/plugin install git://github.com/fauna/has_many_polymorphs.git - -There's also a gem version. To install it instead, run: - sudo gem install has_many_polymorphs - -If you are using the gem, make sure to add require 'has_many_polymorphs' to environment.rb, before Rails::Initializer block. - -== Configuration - -Setup the parent model as so: - - class Kennel < ActiveRecord::Base - has_many_polymorphs :guests, :from => [:dogs, :cats, :birds] - end - -The join model: - - class GuestsKennel < ActiveRecord::Base - belongs_to :kennel - belongs_to :guest, :polymorphic => true - end - -One of the child models: - - class Dog < ActiveRecord::Base - # nothing - end - -For your parent and child models, you don't need any special fields in your migration. For the join model (GuestsKennel), use a migration like so: - - class CreateGuestsKennels < ActiveRecord::Migration - def self.up - create_table :guests_kennels do |t| - t.references :guest, :polymorphic => true - t.references :kennel - end - end - - def self.down - drop_table :guests_kennels - end - end - -See ActiveRecord::Associations::PolymorphicClassMethods for more configuration options. - -== Helper methods example - - >> k = Kennel.find(1) - # - >> k.guests.map(&:class) - [Dog, Cat, Cat, Bird] - - >> k.guests.push(Cat.create); k.cats.size - 3 - >> k.guests << Cat.create; k.cats.size - 4 - >> k.guests.size - 6 - - >> d = k.dogs.first - # - >> d.kennels - [#] - - >> k.guests.delete(d); k.dogs.size - 0 - >> k.guests.size - 5 - -Note that the parent method is always plural, even if there is only one parent (Dog#kennels, not Dog#kennel). - -See ActiveRecord::Associations::PolymorphicAssociation for more helper method details. - -= Extras - -== Double-sided polymorphism - -Double-sided relationships are defined on the join model: - - class Devouring < ActiveRecord::Base - belongs_to :guest, :polymorphic => true - belongs_to :eaten, :polymorphic => true - - acts_as_double_polymorphic_join( - :guests =>[:dogs, :cats], - :eatens => [:cats, :birds] - ) - end - -Now, dogs and cats can eat birds and cats. Birds can't eat anything (they aren't guests) and dogs can't be eaten by anything (since they aren't eatens). The keys stand for what the models are, not what they do. - -In this case, each guest/eaten relationship is called a Devouring. - -In your migration, you need to declare both sides as polymorphic: - - class CreateDevourings < ActiveRecord::Migration - def self.up - create_table :devourings do |t| - t.references :guest, :polymorphic => true - t.references :eaten, :polymorphic => true - end - end - - def self.down - drop_table :devourings - end - end - -See ActiveRecord::Associations::PolymorphicClassMethods for more. - -== Tagging generator - -Has_many_polymorphs includes a tagging system generator. Run: - script/generate tagging Dog Cat [...MoreModels...] - -This adds a migration and new Tag and Tagging models in app/models. It configures Tag with an appropriate has_many_polymorphs call against the models you list at the command line. It also adds the file lib/tagging_extensions.rb and requires it in environment.rb. - -Tests will also be generated. - -Once you've run the generator, you can tag records as follows: - - >> d = Dog.create(:name => "Rover") - # - >> d.tag_list - "" - >> d.tag_with "fierce loud" - # - >> d.tag_list - "fierce loud" - >> c = Cat.create(:name => "Chloe") - # - >> c.tag_with "fierce cute" - # - >> c.tag_list - "cute fierce" - >> Tag.find_by_name("fierce").taggables - [#, #] - -The generator accepts the optional flag --skip-migration to skip generating a migration (for example, if you are converting from acts_as_taggable). It also accepts the flag --self-referential if you want to be able to tag tags. - -See ActiveRecord::Base::TaggingExtensions, Tag, and Tagging for more. - -== Troubleshooting - -Some debugging tools are available in lib/has_many_polymorphs/debugging_tools.rb. - -If you are having trouble, think very carefully about how your model classes, key columns, and table names relate. You may have to explicitly specify options on your join model such as :class_name, :foreign_key, or :as. The included tests are a good place to look for examples. - -Note that because of the way Rails reloads model classes, the plugin can sometimes bog down your development server. Set config.cache_classes = true in config/environments/development.rb to avoid this. - -== Reporting problems - -The support forum is here[http://rubyforge.org/forum/forum.php?forum_id=16450]. - -Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC. - -== Further resources - -* http://blog.evanweaver.com/articles/2007/08/15/polymorphs-tutorial -* http://blog.evanweaver.com/articles/2007/02/22/polymorphs-25-total-insanity-branch -* http://blog.evanweaver.com/articles/2007/02/09/how-to-find-the-most-popular-tags -* http://blog.evanweaver.com/articles/2007/01/13/growing-up-your-acts_as_taggable -* http://blog.evanweaver.com/articles/2006/12/02/polymorphs-19 -* http://blog.evanweaver.com/articles/2006/11/05/directed-double-polymorphic-associations -* http://blog.evanweaver.com/articles/2006/11/04/namespaced-model-support-in-has_many_polymorphs -* http://blog.evanweaver.com/articles/2006/09/26/sti-support-in-has_many_polymorphs -* http://blog.evanweaver.com/articles/2006/09/11/make-polymorphic-children-belong-to-only-one-parent diff --git a/vendor/gems/has_many_polymorphs-2.13/Rakefile b/vendor/gems/has_many_polymorphs-2.13/Rakefile deleted file mode 100644 index b93a94f5..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ - -require 'echoe' - -Echoe.new("has_many_polymorphs") do |p| - p.project = "fauna" - p.summary = "An ActiveRecord plugin for self-referential and double-sided polymorphic associations." - p.url = "http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/" - p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/" - p.dependencies = ["activerecord"] - p.rdoc_pattern = /polymorphs\/association|polymorphs\/class_methods|polymorphs\/reflection|polymorphs\/autoload|polymorphs\/configuration|README|CHANGELOG|TODO|LICENSE|templates\/migration\.rb|templates\/tag\.rb|templates\/tagging\.rb|templates\/tagging_extensions\.rb/ - p.require_signed = true - p.clean_pattern += ["**/ruby_sess*", "**/generated_models/**"] - p.test_pattern = ["test/unit/*_test.rb", "test/integration/*_test.rb", "test/generator/*_test.rb"] -end - -desc "Run all the tests for every database adapter" -task "test_all" do - ['mysql', 'postgresql', 'sqlite3'].each do |adapter| - ENV['DB'] = adapter - ENV['PRODUCTION'] = nil - STDERR.puts "#{'='*80}\nDevelopment mode for #{adapter}\n#{'='*80}" - system("rake test:multi_rails:all") - - ENV['PRODUCTION'] = '1' - STDERR.puts "#{'='*80}\nProduction mode for #{adapter}\n#{'='*80}" - system("rake test:multi_rails:all") - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/TODO b/vendor/gems/has_many_polymorphs-2.13/TODO deleted file mode 100644 index b06e28f2..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/TODO +++ /dev/null @@ -1,2 +0,0 @@ - -* Tag cloud method diff --git a/vendor/gems/has_many_polymorphs-2.13/examples/hmph.rb b/vendor/gems/has_many_polymorphs-2.13/examples/hmph.rb deleted file mode 100644 index 67017505..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/examples/hmph.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'camping' -require 'has_many_polymorphs' - -Camping.goes :Hmph - -module Hmph::Models - class GuestsKennel < Base - belongs_to :kennel - belongs_to :guest, :polymorphic => true - end - - class Dog < Base - end - - class Cat < Base - end - - class Bird < Base - end - - class Kennel < Base - has_many_polymorphs :guests, - :from => [:dogs, :cats, :birds], - :through => :guests_kennels, - :namespace => :"hmph/models/" - end - - class InitialSchema < V 1.0 - def self.up - create_table :hmph_kennels do |t| - t.column :created_at, :datetime - t.column :modified_at, :datetime - t.column :name, :string, :default => 'Anonymous Kennel' - end - - create_table :hmph_guests_kennels do |t| - t.column :guest_id, :integer - t.column :guest_type, :string - t.column :kennel_id, :integer - end - - create_table :hmph_dogs do |t| - t.column :name, :string, :default => 'Fido' - end - - create_table :hmph_cats do |t| - t.column :name, :string, :default => 'Morris' - end - - create_table :hmph_birds do |t| - t.column :name, :string, :default => 'Polly' - end - end - - def self.down - drop_table :hmph_kennels - drop_table :hmph_guests_kennels - drop_table :hmph_dogs - drop_table :hmph_cats - drop_table :hmph_birds - end - end -end - -module Hmph::Controllers -end - -module Hmph::Views -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/tagging_generator.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/tagging_generator.rb deleted file mode 100644 index d99b10f8..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/tagging_generator.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'ruby-debug' and Debugger.start if ENV['USER'] == 'eweaver' - -class TaggingGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false - default_options :self_referential => false - attr_reader :parent_association_name - attr_reader :taggable_models - - def initialize(runtime_args, runtime_options = {}) - parse!(runtime_args, runtime_options) - - @parent_association_name = (runtime_args.include?("--self-referential") ? "tagger" : "tag") - @taggable_models = runtime_args.reject{|opt| opt =~ /^--/}.map do |taggable| - ":" + taggable.underscore.pluralize - end - @taggable_models += [":tags"] if runtime_args.include?("--self-referential") - @taggable_models.uniq! - - verify @taggable_models - hacks - runtime_args.unshift("placeholder") - super - end - - def verify models - puts "** Warning: only one taggable model specified; tests may not run properly." if models.size < 2 - models.each do |model| - model = model[1..-1].classify - next if model == "Tag" # don't load ourselves when --self-referential is used - self.class.const_get(model) rescue puts "** Error: model #{model[1..-1].classify} could not be loaded." or exit - end - end - - def hacks - # add the extension require in environment.rb - phrase = "require 'tagging_extensions'" - filename = "#{RAILS_ROOT}/config/environment.rb" - unless (open(filename) do |file| - file.grep(/#{Regexp.escape phrase}/).any? - end) - open(filename, 'a+') do |file| - file.puts "\n" + phrase + "\n" - end - end - end - - def manifest - record do |m| - m.class_collisions class_path, class_name, "#{class_name}Test" - - m.directory File.join('app/models', class_path) - m.directory File.join('test/unit', class_path) - m.directory File.join('test/fixtures', class_path) - m.directory File.join('test/fixtures', class_path) - m.directory File.join('lib') - - m.template 'tag.rb', File.join('app/models', class_path, "tag.rb") - m.template 'tag_test.rb', File.join('test/unit', class_path, "tag_test.rb") - m.template 'tags.yml', File.join('test/fixtures', class_path, "tags.yml") - - m.template 'tagging.rb', File.join('app/models', class_path, "tagging.rb") - m.template 'tagging_test.rb', File.join('test/unit', class_path, "tagging_test.rb") - m.template 'taggings.yml', File.join('test/fixtures', class_path, "taggings.yml") - - m.template 'tagging_extensions.rb', File.join('lib', 'tagging_extensions.rb') - - unless options[:skip_migration] - m.migration_template 'migration.rb', 'db/migrate', - :migration_file_name => "create_tags_and_taggings" - end - - end - end - - protected - def banner - "Usage: #{$0} generate tagging [TaggableModelA TaggableModelB ...]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - opt.on("--self-referential", - "Allow tags to tag themselves.") { |v| options[:self_referential] = v } - end - - # Useful for generating tests/fixtures - def model_one - taggable_models[0][1..-1].classify - end - - def model_two - taggable_models[1][1..-1].classify rescue model_one - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/migration.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/migration.rb deleted file mode 100644 index 582b54c6..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/migration.rb +++ /dev/null @@ -1,28 +0,0 @@ - -# A migration to add tables for Tag and Tagging. This file is automatically generated and added to your app if you run the tagging generator included with has_many_polymorphs. - -class CreateTagsAndTaggings < ActiveRecord::Migration - - # Add the new tables. - def self.up - create_table :tags do |t| - t.column :name, :string, :null => false - end - add_index :tags, :name, :unique => true - - create_table :taggings do |t| - t.column :<%= parent_association_name -%>_id, :integer, :null => false - t.column :taggable_id, :integer, :null => false - t.column :taggable_type, :string, :null => false - # t.column :position, :integer # Uncomment this if you need to use acts_as_list. - end - add_index :taggings, [:<%= parent_association_name -%>_id, :taggable_id, :taggable_type], :unique => true - end - - # Remove the tables. - def self.down - drop_table :tags - drop_table :taggings - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tag.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tag.rb deleted file mode 100644 index 1966a76b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tag.rb +++ /dev/null @@ -1,39 +0,0 @@ - -# The Tag model. This model is automatically generated and added to your app if you run the tagging generator included with has_many_polymorphs. - -class Tag < ActiveRecord::Base - - DELIMITER = " " # Controls how to split and join tagnames from strings. You may need to change the validates_format_of parameters if you change this. - - # If database speed becomes an issue, you could remove these validations and rescue the ActiveRecord database constraint errors instead. - validates_presence_of :name - validates_uniqueness_of :name, :case_sensitive => false - - # Change this validation if you need more complex tag names. - validates_format_of :name, :with => /^[a-zA-Z0-9\_\-]+$/, :message => "can not contain special characters" - - # Set up the polymorphic relationship. - has_many_polymorphs :taggables, - :from => [<%= taggable_models.join(", ") %>], - :through => :taggings, - :dependent => :destroy, -<% if options[:self_referential] -%> :as => :<%= parent_association_name -%>, -<% end -%> - :skip_duplicates => false, - :parent_extend => proc { - # Defined on the taggable models, not on Tag itself. Return the tagnames associated with this record as a string. - def to_s - self.map(&:name).sort.join(Tag::DELIMITER) - end - } - - # Callback to strip extra spaces from the tagname before saving it. If you allow tags to be renamed later, you might want to use the before_save callback instead. - def before_create - self.name = name.downcase.strip.squeeze(" ") - end - - # Tag::Error class. Raised by ActiveRecord::Base::TaggingExtensions if something goes wrong. - class Error < StandardError - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tag_test.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tag_test.rb deleted file mode 100644 index f4ab543a..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tag_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class TagTest < Test::Unit::TestCase - fixtures <%= taggable_models[0..1].join(", ") -%> - - def setup - @obj = <%= model_two %>.find(:first) - @obj.tag_with "pale imperial" - end - - def test_to_s - assert_equal "imperial pale", <%= model_two -%>.find(:first).tags.to_s - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging.rb deleted file mode 100644 index bb5ea28f..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging.rb +++ /dev/null @@ -1,16 +0,0 @@ - -# The Tagging join model. This model is automatically generated and added to your app if you run the tagging generator included with has_many_polymorphs. - -class Tagging < ActiveRecord::Base - - belongs_to :<%= parent_association_name -%><%= ", :foreign_key => \"#{parent_association_name}_id\", :class_name => \"Tag\"" if options[:self_referential] %> - belongs_to :taggable, :polymorphic => true - - # If you also need to use acts_as_list, you will have to manage the tagging positions manually by creating decorated join records when you associate Tags with taggables. - # acts_as_list :scope => :taggable - - # This callback makes sure that an orphaned Tag is deleted if it no longer tags anything. - def after_destroy - <%= parent_association_name -%>.destroy_without_callbacks if <%= parent_association_name -%> and <%= parent_association_name -%>.taggings.count == 0 - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging_extensions.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging_extensions.rb deleted file mode 100644 index ca7e6add..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging_extensions.rb +++ /dev/null @@ -1,203 +0,0 @@ -class ActiveRecord::Base #:nodoc: - - # These extensions make models taggable. This file is automatically generated and required by your app if you run the tagging generator included with has_many_polymorphs. - module TaggingExtensions - - # Add tags to self. Accepts a string of tagnames, an array of tagnames, an array of ids, or an array of Tags. - # - # We need to avoid name conflicts with the built-in ActiveRecord association methods, thus the underscores. - def _add_tags incoming - taggable?(true) - tag_cast_to_string(incoming).each do |tag_name| - begin - tag = Tag.find_or_create_by_name(tag_name) - raise Tag::Error, "tag could not be saved: #{tag_name}" if tag.new_record? - tags << tag - rescue ActiveRecord::StatementInvalid => e - raise unless e.to_s =~ /duplicate/i - end - end - end - - # Removes tags from self. Accepts a string of tagnames, an array of tagnames, an array of ids, or an array of Tags. - def _remove_tags outgoing - taggable?(true) - outgoing = tag_cast_to_string(outgoing) - <% if options[:self_referential] %> - # because of http://dev.rubyonrails.org/ticket/6466 - taggings.destroy(*(taggings.find(:all, :include => :<%= parent_association_name -%>).select do |tagging| - outgoing.include? tagging.<%= parent_association_name -%>.name - end)) - <% else -%> - <%= parent_association_name -%>s.delete(*(<%= parent_association_name -%>s.select do |tag| - outgoing.include? tag.name - end)) - <% end -%> - end - - # Returns the tags on self as a string. - def tag_list - # Redefined later to avoid an RDoc parse error. - end - - # Replace the existing tags on self. Accepts a string of tagnames, an array of tagnames, an array of ids, or an array of Tags. - def tag_with list - #:stopdoc: - taggable?(true) - list = tag_cast_to_string(list) - - # Transactions may not be ideal for you here; be aware. - Tag.transaction do - current = <%= parent_association_name -%>s.map(&:name) - _add_tags(list - current) - _remove_tags(current - list) - end - - self - #:startdoc: - end - - # Returns the tags on self as a string. - def tag_list #:nodoc: - #:stopdoc: - taggable?(true) - <%= parent_association_name -%>s.reload - <%= parent_association_name -%>s.to_s - #:startdoc: - end - - def tag_list=(value) - tag_with(value) - end - - private - - def tag_cast_to_string obj #:nodoc: - case obj - when Array - obj.map! do |item| - case item - when /^\d+$/, Fixnum then Tag.find(item).name # This will be slow if you use ids a lot. - when Tag then item.name - when String then item - else - raise "Invalid type" - end - end - when String - obj = obj.split(Tag::DELIMITER).map do |tag_name| - tag_name.strip.squeeze(" ") - end - else - raise "Invalid object of class #{obj.class} as tagging method parameter" - end.flatten.compact.map(&:downcase).uniq - end - - # Check if a model is in the :taggables target list. The alternative to this check is to explicitly include a TaggingMethods module (which you would create) in each target model. - def taggable?(should_raise = false) #:nodoc: - unless flag = respond_to?(:<%= parent_association_name -%>s) - raise "#{self.class} is not a taggable model" if should_raise - end - flag - end - - end - - module TaggingFinders - # Find all the objects tagged with the supplied list of tags - # - # Usage : Model.tagged_with("ruby") - # Model.tagged_with("hello", "world") - # Model.tagged_with("hello", "world", :limit => 10) - # - # XXX This query strategy is not performant, and needs to be rewritten as an inverted join or a series of unions - # - def tagged_with(*tag_list) - options = tag_list.last.is_a?(Hash) ? tag_list.pop : {} - tag_list = parse_tags(tag_list) - - scope = scope(:find) - options[:select] ||= "#{table_name}.*" - options[:from] ||= "#{table_name}, tags, taggings" - - sql = "SELECT #{(scope && scope[:select]) || options[:select]} " - sql << "FROM #{(scope && scope[:from]) || options[:from]} " - - add_joins!(sql, options[:joins], scope) - - sql << "WHERE #{table_name}.#{primary_key} = taggings.taggable_id " - sql << "AND taggings.taggable_type = '#{ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s}' " - sql << "AND taggings.tag_id = tags.id " - - tag_list_condition = tag_list.map {|name| "'#{name}'"}.join(", ") - - sql << "AND (tags.name IN (#{sanitize_sql(tag_list_condition)})) " - sql << "AND #{sanitize_sql(options[:conditions])} " if options[:conditions] - - columns = column_names.map do |column| - "#{table_name}.#{column}" - end.join(", ") - - sql << "GROUP BY #{columns} " - sql << "HAVING COUNT(taggings.tag_id) = #{tag_list.size}" - - add_order!(sql, options[:order], scope) - add_limit!(sql, options, scope) - add_lock!(sql, options, scope) - - find_by_sql(sql) - end - - def self.tagged_with_any(*tag_list) - options = tag_list.last.is_a?(Hash) ? tag_list.pop : {} - tag_list = parse_tags(tag_list) - - scope = scope(:find) - options[:select] ||= "#{table_name}.*" - options[:from] ||= "#{table_name}, meta_tags, taggings" - - sql = "SELECT #{(scope && scope[:select]) || options[:select]} " - sql << "FROM #{(scope && scope[:from]) || options[:from]} " - - add_joins!(sql, options, scope) - - sql << "WHERE #{table_name}.#{primary_key} = taggings.taggable_id " - sql << "AND taggings.taggable_type = '#{ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s}' " - sql << "AND taggings.meta_tag_id = meta_tags.id " - - sql << "AND (" - or_options = [] - tag_list.each do |name| - or_options << "meta_tags.name = '#{name}'" - end - or_options_joined = or_options.join(" OR ") - sql << "#{or_options_joined}) " - - - sql << "AND #{sanitize_sql(options[:conditions])} " if options[:conditions] - - columns = column_names.map do |column| - "#{table_name}.#{column}" - end.join(", ") - - sql << "GROUP BY #{columns} " - - add_order!(sql, options[:order], scope) - add_limit!(sql, options, scope) - add_lock!(sql, options, scope) - - find_by_sql(sql) - end - - def parse_tags(tags) - return [] if tags.blank? - tags = Array(tags).first - tags = tags.respond_to?(:flatten) ? tags.flatten : tags.split(Tag::DELIMITER) - tags.map { |tag| tag.strip.squeeze(" ") }.flatten.compact.map(&:downcase).uniq - end - - end - - include TaggingExtensions - extend TaggingFinders -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging_test.rb b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging_test.rb deleted file mode 100644 index f055d381..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tagging_test.rb +++ /dev/null @@ -1,85 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class TaggingTest < Test::Unit::TestCase - fixtures :tags, :taggings, <%= taggable_models[0..1].join(", ") -%> - - def setup - @objs = <%= model_two %>.find(:all, :limit => 2) - - @obj1 = @objs[0] - @obj1.tag_with("pale") - @obj1.reload - - @obj2 = @objs[1] - @obj2.tag_with("pale imperial") - @obj2.reload - -<% if taggable_models.size > 1 -%> - @obj3 = <%= model_one -%>.find(:first) -<% end -%> - @tag1 = Tag.find(1) - @tag2 = Tag.find(2) - @tagging1 = Tagging.find(1) - end - - def test_tag_with - @obj2.tag_with "hoppy pilsner" - assert_equal "hoppy pilsner", @obj2.tag_list - end - - def test_find_tagged_with - @obj1.tag_with "seasonal lager ipa" - @obj2.tag_with ["lager", "stout", "fruity", "seasonal"] - - result1 = [@obj1] - assert_equal <%= model_two %>.tagged_with("ipa"), result1 - assert_equal <%= model_two %>.tagged_with("ipa lager"), result1 - assert_equal <%= model_two %>.tagged_with("ipa", "lager"), result1 - - result2 = [@obj1.id, @obj2.id].sort - assert_equal <%= model_two %>.tagged_with("seasonal").map(&:id).sort, result2 - assert_equal <%= model_two %>.tagged_with("seasonal lager").map(&:id).sort, result2 - assert_equal <%= model_two %>.tagged_with("seasonal", "lager").map(&:id).sort, result2 - end - -<% if options[:self_referential] -%> - def test_self_referential_tag_with - @tag1.tag_with [1, 2] - assert @tag1.tags.include?(@tag1) - assert !@tag2.tags.include?(@tag1) - end - -<% end -%> - def test__add_tags - @obj1._add_tags "porter longneck" - assert Tag.find_by_name("porter").taggables.include?(@obj1) - assert Tag.find_by_name("longneck").taggables.include?(@obj1) - assert_equal "longneck pale porter", @obj1.tag_list - - @obj1._add_tags [2] - assert_equal "imperial longneck pale porter", @obj1.tag_list - end - - def test__remove_tags - @obj2._remove_tags ["2", @tag1] - assert @obj2.tags.empty? - end - - def test_tag_list - assert_equal "imperial pale", @obj2.tag_list - end - - def test_taggable - assert_raises(RuntimeError) do - @tagging1.send(:taggable?, true) - end - assert !@tagging1.send(:taggable?) -<% if taggable_models.size > 1 -%> - assert @obj3.send(:taggable?) -<% end -%> -<% if options[:self_referential] -%> - assert @tag1.send(:taggable?) -<% end -%> - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/taggings.yml b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/taggings.yml deleted file mode 100644 index 0cf13b9d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/taggings.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -<% if taggable_models.size > 1 -%> -taggings_003: - <%= parent_association_name -%>_id: "2" - id: "3" - taggable_type: <%= model_one %> - taggable_id: "1" -<% end -%> -taggings_004: - <%= parent_association_name -%>_id: "2" - id: "4" - taggable_type: <%= model_two %> - taggable_id: "2" -taggings_001: - <%= parent_association_name -%>_id: "1" - id: "1" - taggable_type: <%= model_two %> - taggable_id: "1" -taggings_002: - <%= parent_association_name -%>_id: "1" - id: "2" - taggable_type: <%= model_two %> - taggable_id: "2" diff --git a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tags.yml b/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tags.yml deleted file mode 100644 index 517a8ce5..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/generators/tagging/templates/tags.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -tags_001: - name: pale - id: "1" -tags_002: - name: imperial - id: "2" diff --git a/vendor/gems/has_many_polymorphs-2.13/has_many_polymorphs.gemspec b/vendor/gems/has_many_polymorphs-2.13/has_many_polymorphs.gemspec deleted file mode 100644 index 3e1a69b7..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/has_many_polymorphs.gemspec +++ /dev/null @@ -1,40 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{has_many_polymorphs} - s.version = "2.13" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = [""] - s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"] - s.date = %q{2009-02-02} - s.description = %q{An ActiveRecord plugin for self-referential and double-sided polymorphic associations.} - s.email = %q{} - s.extra_rdoc_files = ["CHANGELOG", "generators/tagging/templates/migration.rb", "generators/tagging/templates/tag.rb", "generators/tagging/templates/tagging.rb", "generators/tagging/templates/tagging_extensions.rb", "lib/has_many_polymorphs/association.rb", "lib/has_many_polymorphs/autoload.rb", "lib/has_many_polymorphs/class_methods.rb", "lib/has_many_polymorphs/configuration.rb", "lib/has_many_polymorphs/reflection.rb", "LICENSE", "README", "test/integration/app/doc/README_FOR_APP", "test/integration/app/README", "TODO"] - s.files = ["CHANGELOG", "examples/hmph.rb", "generators/tagging/tagging_generator.rb", "generators/tagging/templates/migration.rb", "generators/tagging/templates/tag.rb", "generators/tagging/templates/tag_test.rb", "generators/tagging/templates/tagging.rb", "generators/tagging/templates/tagging_extensions.rb", "generators/tagging/templates/tagging_test.rb", "generators/tagging/templates/taggings.yml", "generators/tagging/templates/tags.yml", "init.rb", "lib/has_many_polymorphs/association.rb", "lib/has_many_polymorphs/autoload.rb", "lib/has_many_polymorphs/base.rb", "lib/has_many_polymorphs/class_methods.rb", "lib/has_many_polymorphs/configuration.rb", "lib/has_many_polymorphs/debugging_tools.rb", "lib/has_many_polymorphs/rake_task_redefine_task.rb", "lib/has_many_polymorphs/reflection.rb", "lib/has_many_polymorphs/support_methods.rb", "lib/has_many_polymorphs.rb", "LICENSE", "Manifest", "Rakefile", "README", "test/fixtures/bow_wows.yml", "test/fixtures/cats.yml", "test/fixtures/eaters_foodstuffs.yml", "test/fixtures/fish.yml", "test/fixtures/frogs.yml", "test/fixtures/keep_your_enemies_close.yml", "test/fixtures/little_whale_pupils.yml", "test/fixtures/people.yml", "test/fixtures/petfoods.yml", "test/fixtures/whales.yml", "test/fixtures/wild_boars.yml", "test/generator/tagging_generator_test.rb", "test/integration/app/app/controllers/application.rb", "test/integration/app/app/controllers/bones_controller.rb", "test/integration/app/app/helpers/addresses_helper.rb", "test/integration/app/app/helpers/application_helper.rb", "test/integration/app/app/helpers/bones_helper.rb", "test/integration/app/app/helpers/sellers_helper.rb", "test/integration/app/app/helpers/states_helper.rb", "test/integration/app/app/helpers/users_helper.rb", "test/integration/app/app/models/bone.rb", "test/integration/app/app/models/double_sti_parent.rb", "test/integration/app/app/models/double_sti_parent_relationship.rb", "test/integration/app/app/models/organic_substance.rb", "test/integration/app/app/models/single_sti_parent.rb", "test/integration/app/app/models/single_sti_parent_relationship.rb", "test/integration/app/app/models/stick.rb", "test/integration/app/app/models/stone.rb", "test/integration/app/app/views/addresses/edit.html.erb", "test/integration/app/app/views/addresses/index.html.erb", "test/integration/app/app/views/addresses/new.html.erb", "test/integration/app/app/views/addresses/show.html.erb", "test/integration/app/app/views/bones/index.rhtml", "test/integration/app/app/views/layouts/addresses.html.erb", "test/integration/app/app/views/layouts/sellers.html.erb", "test/integration/app/app/views/layouts/states.html.erb", "test/integration/app/app/views/layouts/users.html.erb", "test/integration/app/app/views/sellers/edit.html.erb", "test/integration/app/app/views/sellers/index.html.erb", "test/integration/app/app/views/sellers/new.html.erb", "test/integration/app/app/views/sellers/show.html.erb", "test/integration/app/app/views/states/edit.html.erb", "test/integration/app/app/views/states/index.html.erb", "test/integration/app/app/views/states/new.html.erb", "test/integration/app/app/views/states/show.html.erb", "test/integration/app/app/views/users/edit.html.erb", "test/integration/app/app/views/users/index.html.erb", "test/integration/app/app/views/users/new.html.erb", "test/integration/app/app/views/users/show.html.erb", "test/integration/app/config/boot.rb", "test/integration/app/config/database.yml", "test/integration/app/config/environment.rb", "test/integration/app/config/environment.rb.canonical", "test/integration/app/config/environments/development.rb", "test/integration/app/config/environments/production.rb", "test/integration/app/config/environments/test.rb", "test/integration/app/config/locomotive.yml", "test/integration/app/config/routes.rb", "test/integration/app/config/ultrasphinx/default.base", "test/integration/app/config/ultrasphinx/development.conf.canonical", "test/integration/app/db/migrate/001_create_sticks.rb", "test/integration/app/db/migrate/002_create_stones.rb", "test/integration/app/db/migrate/003_create_organic_substances.rb", "test/integration/app/db/migrate/004_create_bones.rb", "test/integration/app/db/migrate/005_create_single_sti_parents.rb", "test/integration/app/db/migrate/006_create_double_sti_parents.rb", "test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb", "test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb", "test/integration/app/db/migrate/009_create_library_model.rb", "test/integration/app/doc/README_FOR_APP", "test/integration/app/generators/commenting_generator_test.rb", "test/integration/app/lib/library_model.rb", "test/integration/app/public/404.html", "test/integration/app/public/500.html", "test/integration/app/public/dispatch.cgi", "test/integration/app/public/dispatch.fcgi", "test/integration/app/public/dispatch.rb", "test/integration/app/public/favicon.ico", "test/integration/app/public/images/rails.png", "test/integration/app/public/index.html", "test/integration/app/public/javascripts/application.js", "test/integration/app/public/javascripts/controls.js", "test/integration/app/public/javascripts/dragdrop.js", "test/integration/app/public/javascripts/effects.js", "test/integration/app/public/javascripts/prototype.js", "test/integration/app/public/robots.txt", "test/integration/app/public/stylesheets/scaffold.css", "test/integration/app/Rakefile", "test/integration/app/README", "test/integration/app/script/about", "test/integration/app/script/breakpointer", "test/integration/app/script/console", "test/integration/app/script/destroy", "test/integration/app/script/generate", "test/integration/app/script/performance/benchmarker", "test/integration/app/script/performance/profiler", "test/integration/app/script/plugin", "test/integration/app/script/process/inspector", "test/integration/app/script/process/reaper", "test/integration/app/script/process/spawner", "test/integration/app/script/runner", "test/integration/app/script/server", "test/integration/app/test/fixtures/double_sti_parent_relationships.yml", "test/integration/app/test/fixtures/double_sti_parents.yml", "test/integration/app/test/fixtures/organic_substances.yml", "test/integration/app/test/fixtures/single_sti_parent_relationships.yml", "test/integration/app/test/fixtures/single_sti_parents.yml", "test/integration/app/test/fixtures/sticks.yml", "test/integration/app/test/fixtures/stones.yml", "test/integration/app/test/functional/addresses_controller_test.rb", "test/integration/app/test/functional/bones_controller_test.rb", "test/integration/app/test/functional/sellers_controller_test.rb", "test/integration/app/test/functional/states_controller_test.rb", "test/integration/app/test/functional/users_controller_test.rb", "test/integration/app/test/test_helper.rb", "test/integration/app/test/unit/bone_test.rb", "test/integration/app/test/unit/double_sti_parent_relationship_test.rb", "test/integration/app/test/unit/double_sti_parent_test.rb", "test/integration/app/test/unit/organic_substance_test.rb", "test/integration/app/test/unit/single_sti_parent_relationship_test.rb", "test/integration/app/test/unit/single_sti_parent_test.rb", "test/integration/app/test/unit/stick_test.rb", "test/integration/app/test/unit/stone_test.rb", "test/integration/server_test.rb", "test/models/aquatic/fish.rb", "test/models/aquatic/pupils_whale.rb", "test/models/aquatic/whale.rb", "test/models/beautiful_fight_relationship.rb", "test/models/canine.rb", "test/models/cat.rb", "test/models/dog.rb", "test/models/eaters_foodstuff.rb", "test/models/frog.rb", "test/models/kitten.rb", "test/models/parentship.rb", "test/models/person.rb", "test/models/petfood.rb", "test/models/tabby.rb", "test/models/wild_boar.rb", "test/modules/extension_module.rb", "test/modules/other_extension_module.rb", "test/patches/symlinked_plugins_1.2.6.diff", "test/schema.rb", "test/setup.rb", "test/test_helper.rb", "test/unit/has_many_polymorphs_test.rb", "TODO", "has_many_polymorphs.gemspec"] - s.has_rdoc = true - s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Has_many_polymorphs", "--main", "README"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{fauna} - s.rubygems_version = %q{1.3.1} - s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem} - s.summary = %q{An ActiveRecord plugin for self-referential and double-sided polymorphic associations.} - s.test_files = ["test/generator/tagging_generator_test.rb", "test/integration/server_test.rb", "test/unit/has_many_polymorphs_test.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/init.rb b/vendor/gems/has_many_polymorphs-2.13/init.rb deleted file mode 100644 index 3939a253..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/init.rb +++ /dev/null @@ -1,2 +0,0 @@ - -require 'has_many_polymorphs' diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs.rb deleted file mode 100644 index 03c600cc..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs.rb +++ /dev/null @@ -1,27 +0,0 @@ - -require 'active_record' - -RAILS_DEFAULT_LOGGER = nil unless defined? RAILS_DEFAULT_LOGGER - -require 'has_many_polymorphs/reflection' -require 'has_many_polymorphs/association' -require 'has_many_polymorphs/class_methods' - -require 'has_many_polymorphs/support_methods' -require 'has_many_polymorphs/base' - -class ActiveRecord::Base - extend ActiveRecord::Associations::PolymorphicClassMethods -end - -if ENV['HMP_DEBUG'] || ENV['RAILS_ENV'] =~ /development|test/ && ENV['USER'] == 'eweaver' - require 'has_many_polymorphs/debugging_tools' -end - -if defined? Rails and RAILS_ENV and RAILS_ROOT - _logger_warn "rails environment detected" - require 'has_many_polymorphs/configuration' - require 'has_many_polymorphs/autoload' -end - -_logger_debug "loaded ok" diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/association.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/association.rb deleted file mode 100644 index a2b2d81a..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/association.rb +++ /dev/null @@ -1,159 +0,0 @@ -module ActiveRecord #:nodoc: - module Associations #:nodoc: - - class PolymorphicError < ActiveRecordError #:nodoc: - end - - class PolymorphicMethodNotSupportedError < ActiveRecordError #:nodoc: - end - - # The association class for a has_many_polymorphs association. - class PolymorphicAssociation < HasManyThroughAssociation - - # Push a record onto the association. Triggers a database load for a uniqueness check only if :skip_duplicates is true. Return value is undefined. - def <<(*records) - return if records.empty? - - if @reflection.options[:skip_duplicates] - _logger_debug "Loading instances for polymorphic duplicate push check; use :skip_duplicates => false and perhaps a database constraint to avoid this possible performance issue" - load_target - end - - @reflection.klass.transaction do - flatten_deeper(records).each do |record| - if @owner.new_record? or not record.respond_to?(:new_record?) or record.new_record? - raise PolymorphicError, "You can't associate unsaved records." - end - next if @reflection.options[:skip_duplicates] and @target.include? record - @owner.send(@reflection.through_reflection.name).proxy_target << @reflection.klass.create!(construct_join_attributes(record)) - @target << record if loaded? - end - end - - self - end - - alias :push :<< - alias :concat :<< - - # Runs a find against the association contents, returning the matched records. All regular find options except :include are supported. - def find(*args) - opts = args._extract_options! - opts.delete :include - super(*(args + [opts])) - end - - def construct_scope - _logger_warn "Warning; not all usage scenarios for polymorphic scopes are supported yet." - super - end - - # Deletes a record from the association. Return value is undefined. - def delete(*records) - records = flatten_deeper(records) - records.reject! {|record| @target.delete(record) if record.new_record?} - return if records.empty? - - @reflection.klass.transaction do - records.each do |record| - joins = @reflection.through_reflection.name - @owner.send(joins).delete(@owner.send(joins).select do |join| - join.send(@reflection.options[:polymorphic_key]) == record.id and - join.send(@reflection.options[:polymorphic_type_key]) == "#{record.class.base_class}" - end) - @target.delete(record) - end - end - end - - # Clears all records from the association. Returns an empty array. - def clear(klass = nil) - load_target - return if @target.empty? - - if klass - delete(@target.select {|r| r.is_a? klass }) - else - @owner.send(@reflection.through_reflection.name).clear - @target.clear - end - [] - end - - protected - -# undef :sum -# undef :create! - - def construct_quoted_owner_attributes(*args) #:nodoc: - # no access to returning() here? why not? - type_key = @reflection.options[:foreign_type_key] - {@reflection.primary_key_name => @owner.id, - type_key=> (@owner.class.base_class.name if type_key)} - end - - def construct_from #:nodoc: - # build the FROM part of the query, in this case, the polymorphic join table - @reflection.klass.table_name - end - - def construct_owner #:nodoc: - # the table name for the owner object's class - @owner.class.table_name - end - - def construct_owner_key #:nodoc: - # the primary key field for the owner object - @owner.class.primary_key - end - - def construct_select(custom_select = nil) #:nodoc: - # build the select query - selected = custom_select || @reflection.options[:select] - end - - def construct_joins(custom_joins = nil) #:nodoc: - # build the string of default joins - "JOIN #{construct_owner} polymorphic_parent ON #{construct_from}.#{@reflection.options[:foreign_key]} = polymorphic_parent.#{construct_owner_key} " + - @reflection.options[:from].map do |plural| - klass = plural._as_class - "LEFT JOIN #{klass.table_name} ON #{construct_from}.#{@reflection.options[:polymorphic_key]} = #{klass.table_name}.#{klass.primary_key} AND #{construct_from}.#{@reflection.options[:polymorphic_type_key]} = #{@reflection.klass.quote_value(klass.base_class.name)}" - end.uniq.join(" ") + " #{custom_joins}" - end - - def construct_conditions #:nodoc: - # build the fully realized condition string - conditions = construct_quoted_owner_attributes.map do |field, value| - "#{construct_from}.#{field} = #{@reflection.klass.quote_value(value)}" if value - end - conditions << custom_conditions if custom_conditions - "(" + conditions.compact.join(') AND (') + ")" - end - - def custom_conditions #:nodoc: - # custom conditions... not as messy as has_many :through because our joins are a little smarter - if @reflection.options[:conditions] - "(" + interpolate_sql(@reflection.klass.send(:sanitize_sql, @reflection.options[:conditions])) + ")" - end - end - - alias :construct_owner_attributes :construct_quoted_owner_attributes - alias :conditions :custom_conditions # XXX possibly not necessary - alias :sql_conditions :custom_conditions # XXX ditto - - # construct attributes for join for a particular record - def construct_join_attributes(record) #:nodoc: - {@reflection.options[:polymorphic_key] => record.id, - @reflection.options[:polymorphic_type_key] => "#{record.class.base_class}", - @reflection.options[:foreign_key] => @owner.id}.merge(@reflection.options[:foreign_type_key] ? - {@reflection.options[:foreign_type_key] => "#{@owner.class.base_class}"} : {}) # for double-sided relationships - end - - def build(attrs = nil) #:nodoc: - raise PolymorphicMethodNotSupportedError, "You can't associate new records." - end - - end - - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/autoload.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/autoload.rb deleted file mode 100644 index f05c9dc8..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/autoload.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'initializer' unless defined? ::Rails::Initializer -require 'action_controller/dispatcher' unless defined? ::ActionController::Dispatcher - -module HasManyPolymorphs - -=begin rdoc -Searches for models that use has_many_polymorphs or acts_as_double_polymorphic_join and makes sure that they get loaded during app initialization. This ensures that helper methods are injected into the target classes. - -Note that you can override DEFAULT_OPTIONS via Rails::Configuration#has_many_polymorphs_options. For example, if you need an application extension to be required before has_many_polymorphs loads your models, add an after_initialize block in config/environment.rb that appends to the 'requirements' key: - Rails::Initializer.run do |config| - # your other configuration here - - config.after_initialize do - config.has_many_polymorphs_options['requirements'] << 'lib/my_extension' - end - end - -=end - - DEFAULT_OPTIONS = { - :file_pattern => "#{RAILS_ROOT}/app/models/**/*.rb", - :file_exclusions => ['svn', 'CVS', 'bzr'], - :methods => ['has_many_polymorphs', 'acts_as_double_polymorphic_join'], - :requirements => []} - - mattr_accessor :options - @@options = HashWithIndifferentAccess.new(DEFAULT_OPTIONS) - - # Dispatcher callback to load polymorphic relationships from the top down. - def self.autoload - - _logger_debug "autoload hook invoked" - - options[:requirements].each do |requirement| - _logger_warn "forcing requirement load of #{requirement}" - require requirement - end - - Dir.glob(options[:file_pattern]).each do |filename| - next if filename =~ /#{options[:file_exclusions].join("|")}/ - open filename do |file| - if file.grep(/#{options[:methods].join("|")}/).any? - begin - model = File.basename(filename)[0..-4].camelize - _logger_warn "preloading parent model #{model}" - model.constantize - rescue Object => e - _logger_warn "#{model} could not be preloaded: #{e.inspect}" - end - end - end - end - end - -end - -class Rails::Initializer #:nodoc: - # Make sure it gets loaded in the console, tests, and migrations - def after_initialize_with_autoload - after_initialize_without_autoload - HasManyPolymorphs.autoload - end - alias_method_chain :after_initialize, :autoload -end - -ActionController::Dispatcher.to_prepare(:has_many_polymorphs_autoload) do - # Make sure it gets loaded in the app - HasManyPolymorphs.autoload -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/base.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/base.rb deleted file mode 100644 index f7055724..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/base.rb +++ /dev/null @@ -1,60 +0,0 @@ - -module ActiveRecord - class Base - - class << self - - # Interprets a polymorphic row from a unified SELECT, returning the appropriate ActiveRecord instance. Overrides ActiveRecord::Base.instantiate_without_callbacks. - def instantiate_with_polymorphic_checks(record) - if record['polymorphic_parent_class'] - reflection = record['polymorphic_parent_class'].constantize.reflect_on_association(record['polymorphic_association_id'].to_sym) -# _logger_debug "Instantiating a polymorphic row for #{record['polymorphic_parent_class']}.reflect_on_association(:#{record['polymorphic_association_id']})" - - # rewrite the record with the right column names - table_aliases = reflection.options[:table_aliases].dup - record = Hash[*table_aliases.keys.map {|key| [key, record[table_aliases[key]]] }.flatten] - - # find the real child class - klass = record["#{self.table_name}.#{reflection.options[:polymorphic_type_key]}"].constantize - if sti_klass = record["#{klass.table_name}.#{klass.inheritance_column}"] - klass = klass.class_eval do compute_type(sti_klass) end # in case of namespaced STI models - end - - # check that the join actually joined to something - unless (child_id = record["#{self.table_name}.#{reflection.options[:polymorphic_key]}"]) == record["#{klass.table_name}.#{klass.primary_key}"] - raise ActiveRecord::Associations::PolymorphicError, - "Referential integrity violation; child <#{klass.name}:#{child_id}> was not found for #{reflection.name.inspect}" - end - - # eject the join keys - # XXX not very readable - record = Hash[*record._select do |column, value| - column[/^#{klass.table_name}/] - end.map do |column, value| - [column[/\.(.*)/, 1], value] - end.flatten] - - # allocate and assign values - klass.allocate.tap do |obj| - obj.instance_variable_set("@attributes", record) - obj.instance_variable_set("@attributes_cache", Hash.new) - - if obj.respond_to_without_attributes?(:after_find) - obj.send(:callback, :after_find) - end - - if obj.respond_to_without_attributes?(:after_initialize) - obj.send(:callback, :after_initialize) - end - - end - else - instantiate_without_polymorphic_checks(record) - end - end - - alias_method_chain :instantiate, :polymorphic_checks - end - - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/class_methods.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/class_methods.rb deleted file mode 100644 index 1db66969..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/class_methods.rb +++ /dev/null @@ -1,600 +0,0 @@ - -module ActiveRecord #:nodoc: - module Associations #:nodoc: - -=begin rdoc - -Class methods added to ActiveRecord::Base for setting up polymorphic associations. - -== Notes - -STI association targets must enumerated and named. For example, if Dog and Cat both inherit from Animal, you still need to say [:dogs, :cats], and not [:animals]. - -Namespaced models follow the Rails underscore convention. ZooAnimal::Lion becomes :'zoo_animal/lion'. - -You do not need to set up any other associations other than for either the regular method or the double. The join associations and all individual and reverse associations are generated for you. However, a join model and table are required. - -There is a tentative report that you can make the parent model be its own join model, but this is untested. - -=end - - module PolymorphicClassMethods - - RESERVED_DOUBLES_KEYS = [:conditions, :order, :limit, :offset, :extend, :skip_duplicates, - :join_extend, :dependent, :rename_individual_collections, - :namespace] #:nodoc: - -=begin rdoc - -This method creates a doubled-sided polymorphic relationship. It must be called on the join model: - - class Devouring < ActiveRecord::Base - belongs_to :eater, :polymorphic => true - belongs_to :eaten, :polymorphic => true - - acts_as_double_polymorphic_join( - :eaters => [:dogs, :cats], - :eatens => [:cats, :birds] - ) - end - -The method works by defining one or more special has_many_polymorphs association on every model in the target lists, depending on which side of the association it is on. Double self-references will work. - -The two association names and their value arrays are the only required parameters. - -== Available options - -These options are passed through to targets on both sides of the association. If you want to affect only one side, prepend the key with the name of that side. For example, :eaters_extend. - -:dependent:: Accepts :destroy, :nullify, or :delete_all. Controls how the join record gets treated on any association delete (whether from the polymorph or from an individual collection); defaults to :destroy. -:skip_duplicates:: If true, will check to avoid pushing already associated records (but also triggering a database load). Defaults to true. -:rename_individual_collections:: If true, all individual collections are prepended with the polymorph name, and the children's parent collection is appended with "\_of_#{association_name}". -:extend:: One or an array of mixed modules and procs, which are applied to the polymorphic association (usually to define custom methods). -:join_extend:: One or an array of mixed modules and procs, which are applied to the join association. -:conditions:: An array or string of conditions for the SQL WHERE clause. -:order:: A string for the SQL ORDER BY clause. -:limit:: An integer. Affects the polymorphic and individual associations. -:offset:: An integer. Only affects the polymorphic association. -:namespace:: A symbol. Prepended to all the models in the :from and :through keys. This is especially useful for Camping, which namespaces models by default. - -=end - - def acts_as_double_polymorphic_join options={}, &extension - - collections, options = extract_double_collections(options) - - # handle the block - options[:extend] = (if options[:extend] - Array(options[:extend]) + [extension] - else - extension - end) if extension - - collection_option_keys = make_general_option_keys_specific!(options, collections) - - join_name = self.name.tableize.to_sym - collections.each do |association_id, children| - parent_hash_key = (collections.keys - [association_id]).first # parents are the entries in the _other_ children array - - begin - parent_foreign_key = self.reflect_on_association(parent_hash_key._singularize).primary_key_name - rescue NoMethodError - raise PolymorphicError, "Couldn't find 'belongs_to' association for :#{parent_hash_key._singularize} in #{self.name}." unless parent_foreign_key - end - - parents = collections[parent_hash_key] - conflicts = (children & parents) # set intersection - parents.each do |plural_parent_name| - - parent_class = plural_parent_name._as_class - singular_reverse_association_id = parent_hash_key._singularize - - internal_options = { - :is_double => true, - :from => children, - :as => singular_reverse_association_id, - :through => join_name.to_sym, - :foreign_key => parent_foreign_key, - :foreign_type_key => parent_foreign_key.to_s.sub(/_id$/, '_type'), - :singular_reverse_association_id => singular_reverse_association_id, - :conflicts => conflicts - } - - general_options = Hash[*options._select do |key, value| - collection_option_keys[association_id].include? key and !value.nil? - end.map do |key, value| - [key.to_s[association_id.to_s.length+1..-1].to_sym, value] - end._flatten_once] # rename side-specific options to general names - - general_options.each do |key, value| - # avoid clobbering keys that appear in both option sets - if internal_options[key] - general_options[key] = Array(value) + Array(internal_options[key]) - end - end - - parent_class.send(:has_many_polymorphs, association_id, internal_options.merge(general_options)) - - if conflicts.include? plural_parent_name - # unify the alternate sides of the conflicting children - (conflicts).each do |method_name| - unless parent_class.instance_methods.include?(method_name) - parent_class.send(:define_method, method_name) do - (self.send("#{singular_reverse_association_id}_#{method_name}") + - self.send("#{association_id._singularize}_#{method_name}")).freeze - end - end - end - - # unify the join model... join model is always renamed for doubles, unlike child associations - unless parent_class.instance_methods.include?(join_name) - parent_class.send(:define_method, join_name) do - (self.send("#{join_name}_as_#{singular_reverse_association_id}") + - self.send("#{join_name}_as_#{association_id._singularize}")).freeze - end - end - else - unless parent_class.instance_methods.include?(join_name) - parent_class.send(:alias_method, join_name, "#{join_name}_as_#{singular_reverse_association_id}") - end - end - - end - end - end - - private - - def extract_double_collections(options) - collections = options._select do |key, value| - value.is_a? Array and key.to_s !~ /(#{RESERVED_DOUBLES_KEYS.map(&:to_s).join('|')})$/ - end - - raise PolymorphicError, "Couldn't understand options in acts_as_double_polymorphic_join. Valid parameters are your two class collections, and then #{RESERVED_DOUBLES_KEYS.inspect[1..-2]}, with optionally your collection names prepended and joined with an underscore." unless collections.size == 2 - - options = options._select do |key, value| - !collections[key] - end - - [collections, options] - end - - def make_general_option_keys_specific!(options, collections) - collection_option_keys = Hash[*collections.keys.map do |key| - [key, RESERVED_DOUBLES_KEYS.map{|option| "#{key}_#{option}".to_sym}] - end._flatten_once] - - collections.keys.each do |collection| - options.each do |key, value| - next if collection_option_keys.values.flatten.include? key - # shift the general options to the individual sides - collection_key = "#{collection}_#{key}".to_sym - collection_value = options[collection_key] - case key - when :conditions - collection_value, value = sanitize_sql(collection_value), sanitize_sql(value) - options[collection_key] = (collection_value ? "(#{collection_value}) AND (#{value})" : value) - when :order - options[collection_key] = (collection_value ? "#{collection_value}, #{value}" : value) - when :extend, :join_extend - options[collection_key] = Array(collection_value) + Array(value) - else - options[collection_key] ||= value - end - end - end - - collection_option_keys - end - - - - public - -=begin rdoc - -This method createds a single-sided polymorphic relationship. - - class Petfood < ActiveRecord::Base - has_many_polymorphs :eaters, :from => [:dogs, :cats, :birds] - end - -The only required parameter, aside from the association name, is :from. - -The method generates a number of associations aside from the polymorphic one. In this example Petfood also gets dogs, cats, and birds, and Dog, Cat, and Bird get petfoods. (The reverse association to the parents is always plural.) - -== Available options - -:from:: An array of symbols representing the target models. Required. -:as:: A symbol for the parent's interface in the join--what the parent 'acts as'. -:through:: A symbol representing the class of the join model. Follows Rails defaults if not supplied (the parent and the association names, alphabetized, concatenated with an underscore, and singularized). -:dependent:: Accepts :destroy, :nullify, :delete_all. Controls how the join record gets treated on any associate delete (whether from the polymorph or from an individual collection); defaults to :destroy. -:skip_duplicates:: If true, will check to avoid pushing already associated records (but also triggering a database load). Defaults to true. -:rename_individual_collections:: If true, all individual collections are prepended with the polymorph name, and the children's parent collection is appended with "_of_#{association_name}". For example, zoos becomes zoos_of_animals. This is to help avoid method name collisions in crowded classes. -:extend:: One or an array of mixed modules and procs, which are applied to the polymorphic association (usually to define custom methods). -:join_extend:: One or an array of mixed modules and procs, which are applied to the join association. -:parent_extend:: One or an array of mixed modules and procs, which are applied to the target models' association to the parents. -:conditions:: An array or string of conditions for the SQL WHERE clause. -:parent_conditions:: An array or string of conditions which are applied to the target models' association to the parents. -:order:: A string for the SQL ORDER BY clause. -:parent_order:: A string for the SQL ORDER BY which is applied to the target models' association to the parents. -:group:: An array or string of conditions for the SQL GROUP BY clause. Affects the polymorphic and individual associations. -:limit:: An integer. Affects the polymorphic and individual associations. -:offset:: An integer. Only affects the polymorphic association. -:namespace:: A symbol. Prepended to all the models in the :from and :through keys. This is especially useful for Camping, which namespaces models by default. -:uniq:: If true, the records returned are passed through a pure-Ruby uniq before they are returned. Rarely needed. -:foreign_key:: The column name for the parent's id in the join. -:foreign_type_key:: The column name for the parent's class name in the join, if the parent itself is polymorphic. Rarely needed--if you're thinking about using this, you almost certainly want to use acts_as_double_polymorphic_join() instead. -:polymorphic_key:: The column name for the child's id in the join. -:polymorphic_type_key:: The column name for the child's class name in the join. - -If you pass a block, it gets converted to a Proc and added to :extend. - -== On condition nullification - -When you request an individual association, non-applicable but fully-qualified fields in the polymorphic association's :conditions, :order, and :group options get changed to NULL. For example, if you set :conditions => "dogs.name != 'Spot'", when you request .cats, the conditions string is changed to NULL != 'Spot'. - -Be aware, however, that NULL != 'Spot' returns false due to SQL's 3-value logic. Instead, you need to use the :conditions string "dogs.name IS NULL OR dogs.name != 'Spot'" to get the behavior you probably expect for negative matches. - -=end - - def has_many_polymorphs (association_id, options = {}, &extension) - _logger_debug "associating #{self}.#{association_id}" - reflection = create_has_many_polymorphs_reflection(association_id, options, &extension) - # puts "Created reflection #{reflection.inspect}" - # configure_dependency_for_has_many(reflection) - collection_reader_method(reflection, PolymorphicAssociation) - end - - # Composed method that assigns option defaults, builds the reflection object, and sets up all the related associations on the parent, join, and targets. - def create_has_many_polymorphs_reflection(association_id, options, &extension) #:nodoc: - options.assert_valid_keys( - :from, - :as, - :through, - :foreign_key, - :foreign_type_key, - :polymorphic_key, # same as :association_foreign_key - :polymorphic_type_key, - :dependent, # default :destroy, only affects the join table - :skip_duplicates, # default true, only affects the polymorphic collection - :ignore_duplicates, # deprecated - :is_double, - :rename_individual_collections, - :reverse_association_id, # not used - :singular_reverse_association_id, - :conflicts, - :extend, - :join_class_name, - :join_extend, - :parent_extend, - :table_aliases, - :select, # applies to the polymorphic relationship - :conditions, # applies to the polymorphic relationship, the children, and the join - # :include, - :parent_conditions, - :parent_order, - :order, # applies to the polymorphic relationship, the children, and the join - :group, # only applies to the polymorphic relationship and the children - :limit, # only applies to the polymorphic relationship and the children - :offset, # only applies to the polymorphic relationship - :parent_order, - :parent_group, - :parent_limit, - :parent_offset, - # :source, - :namespace, - :uniq, # XXX untested, only applies to the polymorphic relationship - # :finder_sql, - # :counter_sql, - # :before_add, - # :after_add, - # :before_remove, - # :after_remove - :dummy) - - # validate against the most frequent configuration mistakes - verify_pluralization_of(association_id) - raise PolymorphicError, ":from option must be an array" unless options[:from].is_a? Array - options[:from].each{|plural| verify_pluralization_of(plural)} - - options[:as] ||= self.name.demodulize.underscore.to_sym - options[:conflicts] = Array(options[:conflicts]) - options[:foreign_key] ||= "#{options[:as]}_id" - - options[:association_foreign_key] = - options[:polymorphic_key] ||= "#{association_id._singularize}_id" - options[:polymorphic_type_key] ||= "#{association_id._singularize}_type" - - if options.has_key? :ignore_duplicates - _logger_warn "DEPRECATION WARNING: please use :skip_duplicates instead of :ignore_duplicates" - options[:skip_duplicates] = options[:ignore_duplicates] - end - options[:skip_duplicates] = true unless options.has_key? :skip_duplicates - options[:dependent] = :destroy unless options.has_key? :dependent - options[:conditions] = sanitize_sql(options[:conditions]) - - # options[:finder_sql] ||= "(options[:polymorphic_key] - - options[:through] ||= build_join_table_symbol(association_id, (options[:as]._pluralize or self.table_name)) - - # set up namespaces if we have a namespace key - # XXX needs test coverage - if options[:namespace] - namespace = options[:namespace].to_s.chomp("/") + "/" - options[:from].map! do |child| - "#{namespace}#{child}".to_sym - end - options[:through] = "#{namespace}#{options[:through]}".to_sym - end - - options[:join_class_name] ||= options[:through]._classify - options[:table_aliases] ||= build_table_aliases([options[:through]] + options[:from]) - options[:select] ||= build_select(association_id, options[:table_aliases]) - - options[:through] = "#{options[:through]}_as_#{options[:singular_reverse_association_id]}" if options[:singular_reverse_association_id] - options[:through] = demodulate(options[:through]).to_sym - - options[:extend] = spiked_create_extension_module(association_id, Array(options[:extend]) + Array(extension)) - options[:join_extend] = spiked_create_extension_module(association_id, Array(options[:join_extend]), "Join") - options[:parent_extend] = spiked_create_extension_module(association_id, Array(options[:parent_extend]), "Parent") - - # create the reflection object - create_reflection(:has_many_polymorphs, association_id, options, self).tap do |reflection| - # set up the other related associations - create_join_association(association_id, reflection) - create_has_many_through_associations_for_parent_to_children(association_id, reflection) - create_has_many_through_associations_for_children_to_parent(association_id, reflection) - end - end - - private - - - # table mapping for use at the instantiation point - - def build_table_aliases(from) - # for the targets - {}.tap do |aliases| - from.map(&:to_s).sort.map(&:to_sym).each_with_index do |plural, t_index| - begin - table = plural._as_class.table_name - rescue NameError => e - raise PolymorphicError, "Could not find a valid class for #{plural.inspect} (tried #{plural.to_s._classify}). If it's namespaced, be sure to specify it as :\"module/#{plural}\" instead." - end - begin - plural._as_class.columns.map(&:name).each_with_index do |field, f_index| - aliases["#{table}.#{field}"] = "t#{t_index}_r#{f_index}" - end - rescue ActiveRecord::StatementInvalid => e - _logger_warn "Looks like your table doesn't exist for #{plural.to_s._classify}.\nError #{e}\nSkipping..." - end - end - end - end - - def build_select(association_id, aliases) - # instantiate has to know which reflection the results are coming from - (["\'#{self.name}\' AS polymorphic_parent_class", - "\'#{association_id}\' AS polymorphic_association_id"] + - aliases.map do |table, _alias| - "#{table} AS #{_alias}" - end.sort).join(", ") - end - - # method sub-builders - - def create_join_association(association_id, reflection) - - options = { - :foreign_key => reflection.options[:foreign_key], - :dependent => reflection.options[:dependent], - :class_name => reflection.klass.name, - :extend => reflection.options[:join_extend] - # :limit => reflection.options[:limit], - # :offset => reflection.options[:offset], - # :order => devolve(association_id, reflection, reflection.options[:order], reflection.klass, true), - # :conditions => devolve(association_id, reflection, reflection.options[:conditions], reflection.klass, true) - } - - if reflection.options[:foreign_type_key] - type_check = "#{reflection.options[:foreign_type_key]} = #{quote_value(self.base_class.name)}" - conjunction = options[:conditions] ? " AND " : nil - options[:conditions] = "#{options[:conditions]}#{conjunction}#{type_check}" - options[:as] = reflection.options[:as] - end - - has_many(reflection.options[:through], options) - - inject_before_save_into_join_table(association_id, reflection) - end - - def inject_before_save_into_join_table(association_id, reflection) - sti_hook = "sti_class_rewrite" - rewrite_procedure = %[self.send(:#{reflection.options[:polymorphic_type_key]}=, self.#{reflection.options[:polymorphic_type_key]}.constantize.base_class.name)] - - # XXX should be abstracted? - reflection.klass.class_eval %[ - unless instance_methods.include? "before_save_with_#{sti_hook}" - if instance_methods.include? "before_save" - alias_method :before_save_without_#{sti_hook}, :before_save - def before_save_with_#{sti_hook} - before_save_without_#{sti_hook} - #{rewrite_procedure} - end - else - def before_save_with_#{sti_hook} - #{rewrite_procedure} - end - end - alias_method :before_save, :before_save_with_#{sti_hook} - end - ] - end - - def create_has_many_through_associations_for_children_to_parent(association_id, reflection) - - child_pluralization_map(association_id, reflection).each do |plural, singular| - if singular == reflection.options[:as] - raise PolymorphicError, if reflection.options[:is_double] - "You can't give either of the sides in a double-polymorphic join the same name as any of the individual target classes." - else - "You can't have a self-referential polymorphic has_many :through without renaming the non-polymorphic foreign key in the join model." - end - end - - parent = self - plural._as_class.instance_eval do - # this shouldn't be called at all during doubles; there is no way to traverse to a double polymorphic parent (XXX is that right?) - unless reflection.options[:is_double] or reflection.options[:conflicts].include? self.name.tableize.to_sym - - # the join table - through = "#{reflection.options[:through]}#{'_as_child' if parent == self}".to_sym - has_many(through, - :as => association_id._singularize, -# :source => association_id._singularize, -# :source_type => reflection.options[:polymorphic_type_key], - :class_name => reflection.klass.name, - :dependent => reflection.options[:dependent], - :extend => reflection.options[:join_extend], - # :limit => reflection.options[:limit], - # :offset => reflection.options[:offset], - :order => devolve(association_id, reflection, reflection.options[:parent_order], reflection.klass), - :conditions => devolve(association_id, reflection, reflection.options[:parent_conditions], reflection.klass) - ) - - # the association to the target's parents - association = "#{reflection.options[:as]._pluralize}#{"_of_#{association_id}" if reflection.options[:rename_individual_collections]}".to_sym - has_many(association, - :through => through, - :class_name => parent.name, - :source => reflection.options[:as], - :foreign_key => reflection.options[:foreign_key], - :extend => reflection.options[:parent_extend], - :conditions => reflection.options[:parent_conditions], - :order => reflection.options[:parent_order], - :offset => reflection.options[:parent_offset], - :limit => reflection.options[:parent_limit], - :group => reflection.options[:parent_group]) - -# debugger if association == :parents -# -# nil - - end - end - end - end - - def create_has_many_through_associations_for_parent_to_children(association_id, reflection) - child_pluralization_map(association_id, reflection).each do |plural, singular| - #puts ":source => #{child}" - current_association = demodulate(child_association_map(association_id, reflection)[plural]) - source = demodulate(singular) - - if reflection.options[:conflicts].include? plural - # XXX check this - current_association = "#{association_id._singularize}_#{current_association}" if reflection.options[:conflicts].include? self.name.tableize.to_sym - source = "#{source}_as_#{association_id._singularize}".to_sym - end - - # make push/delete accessible from the individual collections but still operate via the general collection - extension_module = self.class_eval %[ - module #{self.name + current_association._classify + "PolymorphicChildAssociationExtension"} - def push *args; proxy_owner.send(:#{association_id}).send(:push, *args); self; end - alias :<< :push - def delete *args; proxy_owner.send(:#{association_id}).send(:delete, *args); end - def clear; proxy_owner.send(:#{association_id}).send(:clear, #{singular._classify}); end - self - end] - - has_many(current_association.to_sym, - :through => reflection.options[:through], - :source => association_id._singularize, - :source_type => plural._as_class.base_class.name, - :class_name => plural._as_class.name, # make STI not conflate subtypes - :extend => (Array(extension_module) + reflection.options[:extend]), - :limit => reflection.options[:limit], - # :offset => reflection.options[:offset], - :order => devolve(association_id, reflection, reflection.options[:order], plural._as_class), - :conditions => devolve(association_id, reflection, reflection.options[:conditions], plural._as_class), - :group => devolve(association_id, reflection, reflection.options[:group], plural._as_class) - ) - - end - end - - # some support methods - - def child_pluralization_map(association_id, reflection) - Hash[*reflection.options[:from].map do |plural| - [plural, plural._singularize] - end.flatten] - end - - def child_association_map(association_id, reflection) - Hash[*reflection.options[:from].map do |plural| - [plural, "#{association_id._singularize.to_s + "_" if reflection.options[:rename_individual_collections]}#{plural}".to_sym] - end.flatten] - end - - def demodulate(s) - s.to_s.gsub('/', '_').to_sym - end - - def build_join_table_symbol(association_id, name) - [name.to_s, association_id.to_s].sort.join("_").to_sym - end - - def all_classes_for(association_id, reflection) - klasses = [self, reflection.klass, *child_pluralization_map(association_id, reflection).keys.map(&:_as_class)] - klasses += klasses.map(&:base_class) - klasses.uniq - end - - def devolve(association_id, reflection, string, klass, remove_inappropriate_clauses = false) - # XXX remove_inappropriate_clauses is not implemented; we'll wait until someone actually needs it - return unless string - string = string.dup - # _logger_debug "devolving #{string} for #{klass}" - inappropriate_classes = (all_classes_for(association_id, reflection) - # the join class must always be preserved - [klass, klass.base_class, reflection.klass, reflection.klass.base_class]) - inappropriate_classes.map do |klass| - klass.columns.map do |column| - [klass.table_name, column.name] - end.map do |table, column| - ["#{table}.#{column}", "`#{table}`.#{column}", "#{table}.`#{column}`", "`#{table}`.`#{column}`"] - end - end.flatten.sort_by(&:size).reverse.each do |quoted_reference| - # _logger_debug "devolved #{quoted_reference} to NULL" - # XXX clause removal would go here - string.gsub!(quoted_reference, "NULL") - end - # _logger_debug "altered to #{string}" - string - end - - def verify_pluralization_of(sym) - sym = sym.to_s - singular = sym.singularize - plural = singular.pluralize - raise PolymorphicError, "Pluralization rules not set up correctly. You passed :#{sym}, which singularizes to :#{singular}, but that pluralizes to :#{plural}, which is different. Maybe you meant :#{plural} to begin with?" unless sym == plural - end - - def spiked_create_extension_module(association_id, extensions, identifier = nil) - module_extensions = extensions.select{|e| e.is_a? Module} - proc_extensions = extensions.select{|e| e.is_a? Proc } - - # support namespaced anonymous blocks as well as multiple procs - proc_extensions.each_with_index do |proc_extension, index| - module_name = "#{self.to_s}#{association_id._classify}Polymorphic#{identifier}AssociationExtension#{index}" - the_module = self.class_eval "module #{module_name}; self; end" # XXX hrm - the_module.class_eval &proc_extension - module_extensions << the_module - end - module_extensions - end - - end - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/configuration.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/configuration.rb deleted file mode 100644 index 9de21617..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/configuration.rb +++ /dev/null @@ -1,19 +0,0 @@ - -=begin rdoc -Access the has_many_polymorphs_options hash in your Rails::Initializer.run#after_initialize block if you need to modify the behavior of Rails::Initializer::HasManyPolymorphsAutoload. -=end - -module Rails #:nodoc: - class Configuration - - def has_many_polymorphs_options - ::HasManyPolymorphs.options - end - - def has_many_polymorphs_options=(hash) - ::HasManyPolymorphs.options = HashWithIndifferentAccess.new(hash) - end - - end -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/debugging_tools.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/debugging_tools.rb deleted file mode 100644 index 22c9af38..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/debugging_tools.rb +++ /dev/null @@ -1,103 +0,0 @@ - -=begin rdoc - -Debugging tools for Has_many_polymorphs. - -Enable the different tools by setting the environment variable HMP_DEBUG. Settings with special meaning are "ruby-debug", "trace", and "dependencies". - -== Code generation - -Enabled by default when HMP_DEBUG is set. - -Ouputs a folder generated_models/ in RAILS_ROOT containing valid Ruby files explaining all the ActiveRecord relationships set up by the plugin, as well as listing the line in the plugin that called each particular association method. - -== Ruby-debug - -Enable by setting HMP_DEBUG to "ruby-debug". - -Starts ruby-debug for the life of the process. - -== Trace - -Enable by setting HMP_DEBUG to "ruby-debug". - -Outputs an indented trace of relevant method calls as they occur. - -== Dependencies - -Enable by setting HMP_DEBUG to "dependencies". - -Turns on Rails' default dependency logging. - -=end - -_logger_warn "debug mode enabled" - -class << ActiveRecord::Base - COLLECTION_METHODS = [:belongs_to, :has_many, :has_and_belongs_to_many, :has_one, - :has_many_polymorphs, :acts_as_double_polymorphic_join].each do |method_name| - alias_method "original_#{method_name}".to_sym, method_name - undef_method method_name - end - - unless defined? GENERATED_CODE_DIR - GENERATED_CODE_DIR = "#{RAILS_ROOT}/generated_models" - - begin - system "rm -rf #{GENERATED_CODE_DIR}" - Dir.mkdir GENERATED_CODE_DIR - rescue Errno::EACCES - _logger_warn "no permissions for generated code dir: #{GENERATED_CODE_DIR}" - end - - if File.exist? GENERATED_CODE_DIR - alias :original_method_missing :method_missing - def method_missing(method_name, *args, &block) - if COLLECTION_METHODS.include? method_name.to_sym - Dir.chdir GENERATED_CODE_DIR do - filename = "#{demodulate(self.name.underscore)}.rb" - contents = File.open(filename).read rescue "\nclass #{self.name}\n\nend\n" - line = caller[1][/\:(\d+)\:/, 1] - contents[-5..-5] = "\n #{method_name} #{args[0..-2].inspect[1..-2]},\n #{args[-1].inspect[1..-2].gsub(" :", "\n :").gsub("=>", " => ")}\n#{ block ? " #{block.inspect.sub(/\@.*\//, '@')}\n" : ""} # called from line #{line}\n\n" - File.open(filename, "w") do |file| - file.puts contents - end - end - # doesn't actually display block contents - self.send("original_#{method_name}", *args, &block) - else - self.send(:original_method_missing, method_name, *args, &block) - end - end - end - - end -end - -case ENV['HMP_DEBUG'] - - when "ruby-debug" - require 'rubygems' - require 'ruby-debug' - Debugger.start - _logger_warn "ruby-debug enabled." - - when "trace" - _logger_warn "method tracing enabled" - $debug_trace_indent = 0 - set_trace_func (proc do |event, file, line, id, binding, classname| - if id.to_s =~ /instantiate/ #/IRB|Wirble|RubyLex|RubyToken|Logger|ConnectionAdapters|SQLite3|MonitorMixin|Benchmark|Inflector|Inflections/ - if event == 'call' - puts (" " * $debug_trace_indent) + "#{event}ed #{classname}\##{id} from #{file.split('/').last}::#{line}" - $debug_trace_indent += 1 - elsif event == 'return' - $debug_trace_indent -= 1 unless $debug_trace_indent == 0 - puts (" " * $debug_trace_indent) + "#{event}ed #{classname}\##{id}" - end - end - end) - - when "dependencies" - _logger_warn "dependency activity being logged" - (::Dependencies.log_activity = true) rescue nil -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/rake_task_redefine_task.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/rake_task_redefine_task.rb deleted file mode 100644 index 217d2590..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/rake_task_redefine_task.rb +++ /dev/null @@ -1,35 +0,0 @@ - -# Redefine instead of chain a Rake task -# http://www.bigbold.com/snippets/posts/show/2032 - -module Rake - module TaskManager - def redefine_task(task_class, args, &block) - task_name, deps = resolve_args(args) - task_name = task_class.scope_name(@scope, task_name) - deps = [deps] unless deps.respond_to?(:to_ary) - deps = deps.collect {|d| d.to_s } - task = @tasks[task_name.to_s] = task_class.new(task_name, self) - task.application = self - task.add_comment(@last_comment) - @last_comment = nil - task.enhance(deps, &block) - task - end - end - class Task - class << self - def redefine_task(args, &block) - Rake.application.redefine_task(self, args, &block) - end - end - end -end - -class Object - def silently - stderr, stdout, $stderr, $stdout = $stderr, $stdout, StringIO.new, StringIO.new - yield - $stderr, $stdout = stderr, stdout - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/reflection.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/reflection.rb deleted file mode 100644 index 0091397d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/reflection.rb +++ /dev/null @@ -1,58 +0,0 @@ -module ActiveRecord #:nodoc: - module Reflection #:nodoc: - - module ClassMethods #:nodoc: - - # Update the default reflection switch so that :has_many_polymorphs types get instantiated. - # It's not a composed method so we have to override the whole thing. - def create_reflection(macro, name, options, active_record) - case macro - when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many - klass = options[:through] ? ThroughReflection : AssociationReflection - reflection = klass.new(macro, name, options, active_record) - when :composed_of - reflection = AggregateReflection.new(macro, name, options, active_record) - # added by has_many_polymorphs # - when :has_many_polymorphs - reflection = PolymorphicReflection.new(macro, name, options, active_record) - end - write_inheritable_hash :reflections, name => reflection - reflection - end - - end - - class PolymorphicError < ActiveRecordError #:nodoc: - end - -=begin rdoc - -The reflection built by the has_many_polymorphs method. - -Inherits from ActiveRecord::Reflection::AssociationReflection. - -=end - - class PolymorphicReflection < ThroughReflection - # Stub out the validity check. Has_many_polymorphs checks validity on macro creation, not on reflection. - def check_validity! - # nothing - end - - # Return the source reflection. - def source_reflection - # normally is the has_many to the through model, but we return ourselves, - # since there isn't a real source class for a polymorphic target - self - end - - # Set the classname of the target. Uses the join class name. - def class_name - # normally is the classname of the association target - @class_name ||= options[:join_class_name] - end - - end - - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/support_methods.rb b/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/support_methods.rb deleted file mode 100644 index 89ca52a4..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/support_methods.rb +++ /dev/null @@ -1,84 +0,0 @@ - -class String - - # Changes an underscored string into a class reference. - def _as_class - # classify expects self to be plural - self.classify.constantize - end - - # For compatibility with the Symbol extensions. - alias :_singularize :singularize - alias :_pluralize :pluralize - alias :_classify :classify -end - -class Symbol - - # Changes an underscored symbol into a class reference. - def _as_class; self.to_s._as_class; end - - # Changes a plural symbol into a singular symbol. - def _singularize; self.to_s.singularize.to_sym; end - - # Changes a singular symbol into a plural symbol. - def _pluralize; self.to_s.pluralize.to_sym; end - - # Changes a symbol into a class name string. - def _classify; self.to_s.classify; end -end - -class Array - - # Flattens the first level of self. - def _flatten_once - self.inject([]){|r, el| r + Array(el)} - end - - # Rails 1.2.3 compatibility method. Copied from http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/core_ext/array/extract_options.rb?rev=7217 - def _extract_options! - last.is_a?(::Hash) ? pop : {} - end -end - -class Hash - - # An implementation of select that returns a Hash. - def _select - Hash[*self.select do |key, value| - yield key, value - end._flatten_once] - end -end - -class Object - - # Returns the metaclass of self. - def _metaclass; (class << self; self; end); end - - # Logger shortcut. - def _logger_debug s - s = "** has_many_polymorphs: #{s}" - RAILS_DEFAULT_LOGGER.debug(s) if RAILS_DEFAULT_LOGGER - end - - # Logger shortcut. - def _logger_warn s - s = "** has_many_polymorphs: #{s}" - if RAILS_DEFAULT_LOGGER - RAILS_DEFAULT_LOGGER.warn(s) - else - $stderr.puts(s) - end - end - -end - -class ActiveRecord::Base - - # Return the base class name as a string. - def _base_class_name - self.class.base_class.name.to_s - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/bow_wows.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/bow_wows.yml deleted file mode 100644 index 00be9d88..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/bow_wows.yml +++ /dev/null @@ -1,10 +0,0 @@ -rover: - id: 1 - name: Rover - created_at: "2007-01-01 12:00:00" - updated_at: "2007-01-04 10:00:00" -spot: - id: 2 - name: Spot - created_at: "2007-01-02 12:00:00" - updated_at: "2007-01-03 10:00:00" diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/cats.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/cats.yml deleted file mode 100644 index aed894f9..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/cats.yml +++ /dev/null @@ -1,18 +0,0 @@ -chloe: - id: 1 - cat_type: Kitten - name: Chloe - created_at: "2007-04-01 12:00:00" - updated_at: "2007-04-04 10:00:00" -alice: - id: 2 - cat_type: Kitten - name: Alice - created_at: "2007-04-02 12:00:00" - updated_at: "2007-04-03 10:00:00" -toby: - id: 3 - cat_type: Tabby - name: Toby - created_at: "2007-04-02 12:00:00" - updated_at: "2007-04-03 10:00:00" diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/eaters_foodstuffs.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/eaters_foodstuffs.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/fish.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/fish.yml deleted file mode 100644 index 3974a672..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/fish.yml +++ /dev/null @@ -1,12 +0,0 @@ -swimmy: - id: 1 - name: Swimmy - speed: 10 - created_at: "2007-02-01 12:00:00" - updated_at: "2007-02-04 10:00:00" -jaws: - id: 2 - name: Jaws - speed: 20 - created_at: "2007-02-02 12:00:00" - updated_at: "2007-02-03 10:00:00" diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/frogs.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/frogs.yml deleted file mode 100644 index e9d37d7c..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/frogs.yml +++ /dev/null @@ -1,5 +0,0 @@ -froggy: - id: 1 - name: Froggy - created_at: "2007-05-01 12:00:00" - updated_at: "2007-05-04 10:00:00" diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/keep_your_enemies_close.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/keep_your_enemies_close.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/little_whale_pupils.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/little_whale_pupils.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/people.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/people.yml deleted file mode 100644 index 085d2172..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/people.yml +++ /dev/null @@ -1,7 +0,0 @@ -bob: - id: 1 - name: Bob - age: 45 - created_at: "2007-04-01 12:00:00" - updated_at: "2007-04-04 10:00:00" - \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/petfoods.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/petfoods.yml deleted file mode 100644 index a117d294..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/petfoods.yml +++ /dev/null @@ -1,11 +0,0 @@ -kibbles: - the_petfood_primary_key: 1 - name: Kibbles - created_at: "2007-06-01 12:00:00" - updated_at: "2007-06-04 10:00:00" -bits: - the_petfood_primary_key: 2 - name: Bits - created_at: "2007-06-02 12:00:00" - updated_at: "2007-06-03 10:00:00" - \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/whales.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/whales.yml deleted file mode 100644 index bded734e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/whales.yml +++ /dev/null @@ -1,5 +0,0 @@ -shamu: - id: 1 - name: Shamu - created_at: "2007-03-01 12:00:00" - updated_at: "2007-03-04 10:00:00" diff --git a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/wild_boars.yml b/vendor/gems/has_many_polymorphs-2.13/test/fixtures/wild_boars.yml deleted file mode 100644 index 73fd3e2e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/fixtures/wild_boars.yml +++ /dev/null @@ -1,10 +0,0 @@ -puma: - id: 1 - name: Puma - created_at: "2007-07-01 12:00:00" - updated_at: "2007-07-04 10:00:00" -jacrazy: - id: 2 - name: Jacrazy - created_at: "2007-07-02 12:00:00" - updated_at: "2007-07-03 10:00:00" diff --git a/vendor/gems/has_many_polymorphs-2.13/test/generator/tagging_generator_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/generator/tagging_generator_test.rb deleted file mode 100644 index 34e20c4f..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/generator/tagging_generator_test.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'fileutils' -require File.dirname(__FILE__) + '/../test_helper' - -class TaggingGeneratorTest < Test::Unit::TestCase - - def setup - Dir.chdir RAILS_ROOT do - truncate - - # Revert environment lib requires - FileUtils.cp "config/environment.rb.canonical", "config/environment.rb" - - # Delete generator output - ["app/models/tag.rb", "app/models/tagging.rb", - "test/unit/tag_test.rb", "test/unit/tagging_test.rb", - "test/fixtures/tags.yml", "test/fixtures/taggings.yml", - "lib/tagging_extensions.rb", - "db/migrate/010_create_tags_and_taggings.rb"].each do |file| - File.delete file if File.exist? file - end - - # Rebuild database - Echoe.silence do - system("ruby #{HERE}/setup.rb") - end - end - end - - alias :teardown :setup - - def test_generator - Dir.chdir RAILS_ROOT do - Echoe.silence do - assert system("script/generate tagging Stick Stone -q -f") - assert system("rake db:migrate") - assert system("rake db:fixtures:load") - assert system("rake test:units") - end - end - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/README b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/README deleted file mode 100644 index 0d6affdd..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/README +++ /dev/null @@ -1,182 +0,0 @@ -== Welcome to Rails - -Rails is a web-application and persistence framework that includes everything -needed to create database-backed web-applications according to the -Model-View-Control pattern of separation. This pattern splits the view (also -called the presentation) into "dumb" templates that are primarily responsible -for inserting pre-built data in between HTML tags. The model contains the -"smart" domain objects (such as Account, Product, Person, Post) that holds all -the business logic and knows how to persist themselves to a database. The -controller handles the incoming requests (such as Save New Account, Update -Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting started - -1. At the command prompt, start a new rails application using the rails command - and your application name. Ex: rails myapp - (If you've downloaded rails in a complete tgz or zip, this step is already done) -2. Change directory into myapp and start the web server: script/server (run with --help for options) -3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!" -4. Follow the guidelines to start developing your application - - -== Web Servers - -By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise -Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server, -Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures -that you can always get up and running quickly. - -Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is -suitable for development and deployment of Rails applications. If you have Ruby Gems installed, -getting up and running with mongrel is as easy as: gem install mongrel. -More info at: http://mongrel.rubyforge.org - -If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than -Mongrel and WEBrick and also suited for production use, but requires additional -installation and currently only works well on OS X/Unix (Windows users are encouraged -to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from -http://www.lighttpd.net. - -And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby -web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not -for production. - -But of course its also possible to run Rails on any platform that supports FCGI. -Apache, LiteSpeed, IIS are just a few. For more information on FCGI, -please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI - - -== Debugging Rails - -Have "tail -f" commands running on the server.log and development.log. Rails will -automatically display debugging and runtime information to these files. Debugging -info will also be shown in the browser on requests from 127.0.0.1. - - -== Breakpoints - -Breakpoint support is available through the script/breakpointer client. This -means that you can break out of execution at any point in the code, investigate -and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find(:all) - breakpoint "Breaking out from the list" - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the breakpointer window. Here you can do things like: - -Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you press CTRL-D - - -== Console - -You can interact with the domain model by starting the console through script/console. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like script/console production. - -To reload your controllers and models after launching the console run reload! - -To reload your controllers and models after launching the console run reload! - - - -== Description of contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from ApplicationController - which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby - syntax. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the common - header/footer method of wrapping views. In your views, define a layout using the - layout :default and create a file named default.rhtml. Inside default.rhtml, - call <% yield %> to render the view using this layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are generated - for you automatically when using script/generate for controllers. Helpers can be used to - wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -components - Self-contained mini-applications that can bundle together controllers, models, and views. - -db - Contains the database schema in schema.rb. db/migrate contains all - the sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when generated - using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. This should be - set as the DOCUMENT_ROOT of your web server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the script/generate scripts, template - test files will be generated for you and placed in this directory. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - This directory is in the load path. diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/Rakefile b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/Rakefile deleted file mode 100644 index 2573c13c..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/Rakefile +++ /dev/null @@ -1,19 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require(File.join(File.dirname(__FILE__), 'config', 'boot')) - -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -require 'tasks/rails' - -namespace :test do - desc "a new rake task to include generators" - Rake::TestTask.new(:generators) do |t| - t.libs << 'lib' - t.test_files = FileList['test/generators/*_test.rb'] - t.verbose = true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/controllers/application.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/controllers/application.rb deleted file mode 100644 index 057f4f7e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/controllers/application.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - -class ApplicationController < ActionController::Base - # Pick a unique cookie name to distinguish our session data from others' - session :session_key => '_testapp_session_id' -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/controllers/bones_controller.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/controllers/bones_controller.rb deleted file mode 100644 index 29bfe0c0..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/controllers/bones_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class BonesController < ApplicationController - def index - @bones = Bone.find(:all) - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/addresses_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/addresses_helper.rb deleted file mode 100644 index 5f4dc138..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/addresses_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module AddressesHelper -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/application_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/application_helper.rb deleted file mode 100644 index 22a7940e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/application_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Methods added to this helper will be available to all templates in the application. -module ApplicationHelper -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/bones_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/bones_helper.rb deleted file mode 100644 index c188f669..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/bones_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module BonesHelper -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/sellers_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/sellers_helper.rb deleted file mode 100644 index 4bdecd54..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/sellers_helper.rb +++ /dev/null @@ -1,28 +0,0 @@ -module SellersHelper - - def display_address(seller) - logger.info "Seller Data ====================" - logger.info seller.inspect - logger.info "Seller responds to address " + seller.respond_to?("address").to_s - logger.info "Seller responds to address= " + seller.respond_to?("address=").to_s - # logger.info seller.methods.sort.inspect - logger.info "User Data ====================" - logger.info seller.user.inspect - logger.info "User responds to address " + seller.user.respond_to?("address").to_s - logger.info "User responds to address= " + seller.user.respond_to?("address=").to_s - # logger.info seller.user.methods.sort.inspect - display_address = Array.new - if seller.address - display_address << seller.address.city if seller.address.city - display_address << seller.address.state.abbreviation if seller.address.state && seller.address.state.abbreviation - display_address << seller.address.zip_postal_code if seller.address.zip_postal_code - end - - unless display_address.empty? - "Location: " + display_address.join(", ") - else - "Location: unknown" - end - end - -end \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/states_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/states_helper.rb deleted file mode 100644 index f98bdc7c..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/states_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module StatesHelper -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/users_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/users_helper.rb deleted file mode 100644 index 2310a240..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/helpers/users_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UsersHelper -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/bone.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/bone.rb deleted file mode 100644 index f9268612..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/bone.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Bone < OrganicSubstance -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/double_sti_parent.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/double_sti_parent.rb deleted file mode 100644 index 5bc344f7..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/double_sti_parent.rb +++ /dev/null @@ -1,2 +0,0 @@ -class DoubleStiParent < ActiveRecord::Base -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/double_sti_parent_relationship.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/double_sti_parent_relationship.rb deleted file mode 100644 index 10b6255b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/double_sti_parent_relationship.rb +++ /dev/null @@ -1,2 +0,0 @@ -class DoubleStiParentRelationship < ActiveRecord::Base -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/organic_substance.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/organic_substance.rb deleted file mode 100644 index e9a080d9..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/organic_substance.rb +++ /dev/null @@ -1,2 +0,0 @@ -class OrganicSubstance < ActiveRecord::Base -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/single_sti_parent.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/single_sti_parent.rb deleted file mode 100644 index 5e4410bb..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/single_sti_parent.rb +++ /dev/null @@ -1,4 +0,0 @@ - -class SingleStiParent < ActiveRecord::Base - has_many_polymorphs :the_bones, :from => [:bones], :through => :single_sti_parent_relationship -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/single_sti_parent_relationship.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/single_sti_parent_relationship.rb deleted file mode 100644 index 7f783c15..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/single_sti_parent_relationship.rb +++ /dev/null @@ -1,4 +0,0 @@ -class SingleStiParentRelationship < ActiveRecord::Base - belongs_to :single_sti_parent - belongs_to :the_bone, :polymorphic => true -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/stick.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/stick.rb deleted file mode 100644 index 4992506a..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/stick.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Stick < ActiveRecord::Base -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/stone.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/stone.rb deleted file mode 100644 index 8617396e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/models/stone.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Stone < ActiveRecord::Base -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/edit.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/edit.html.erb deleted file mode 100644 index 6b6a3894..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

Editing address

- -<%= error_messages_for :address %> - -<% form_for(@address) do |f| %> -

- <%= f.submit "Update" %> -

-<% end %> - -<%= link_to 'Show', @address %> | -<%= link_to 'Back', addresses_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/index.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/index.html.erb deleted file mode 100644 index 86d0d387..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/index.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -

Listing addresses

- - - - - -<% for address in @addresses %> - - - - - -<% end %> -
<%= link_to 'Show', address %><%= link_to 'Edit', edit_address_path(address) %><%= link_to 'Destroy', address, :confirm => 'Are you sure?', :method => :delete %>
- -
- -<%= link_to 'New address', new_address_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/new.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/new.html.erb deleted file mode 100644 index 1fae44cf..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -

New address

- -<%= error_messages_for :address %> - -<% form_for(@address) do |f| %> -

- <%= f.submit "Create" %> -

-<% end %> - -<%= link_to 'Back', addresses_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/show.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/show.html.erb deleted file mode 100644 index a75ddbd5..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/addresses/show.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - -<%= link_to 'Edit', edit_address_path(@address) %> | -<%= link_to 'Back', addresses_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/bones/index.rhtml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/bones/index.rhtml deleted file mode 100644 index 06f1dad3..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/bones/index.rhtml +++ /dev/null @@ -1,5 +0,0 @@ - -

Bones: index

-<% @bones.each do |bone| %> -

ID: <%= bone.id %>

-<% end %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/addresses.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/addresses.html.erb deleted file mode 100644 index 84583552..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/addresses.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Addresses: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> - - - -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/sellers.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/sellers.html.erb deleted file mode 100644 index bc08e9be..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/sellers.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Sellers: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> - - - -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/states.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/states.html.erb deleted file mode 100644 index b2b086fd..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/states.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - States: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> - - - -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/users.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/users.html.erb deleted file mode 100644 index 23757aa6..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/layouts/users.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Users: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> - - - -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/edit.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/edit.html.erb deleted file mode 100644 index 14c41036..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

Editing seller

- -<%= error_messages_for :seller %> - -<% form_for(@seller) do |f| %> -

- <%= f.submit "Update" %> -

-<% end %> - -<%= link_to 'Show', @seller %> | -<%= link_to 'Back', sellers_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/index.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/index.html.erb deleted file mode 100644 index 97ef0457..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/index.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -

Listing sellers

- - - - - -<% for seller in @sellers %> - - - - - - - -<% end %> -
<%= h(seller.company_name) %><%= h(display_address(seller)) %><%= link_to 'Show', seller %><%= link_to 'Edit', edit_seller_path(seller) %><%= link_to 'Destroy', seller, :confirm => 'Are you sure?', :method => :delete %>
- -
- -<%= link_to 'New seller', new_seller_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/new.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/new.html.erb deleted file mode 100644 index 6814338d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -

New seller

- -<%= error_messages_for :seller %> - -<% form_for(@seller) do |f| %> -

- <%= f.submit "Create" %> -

-<% end %> - -<%= link_to 'Back', sellers_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/show.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/show.html.erb deleted file mode 100644 index f21dcfa7..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/sellers/show.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - -<%= link_to 'Edit', edit_seller_path(@seller) %> | -<%= link_to 'Back', sellers_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/edit.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/edit.html.erb deleted file mode 100644 index dc59d08b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

Editing state

- -<%= error_messages_for :state %> - -<% form_for(@state) do |f| %> -

- <%= f.submit "Update" %> -

-<% end %> - -<%= link_to 'Show', @state %> | -<%= link_to 'Back', states_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/index.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/index.html.erb deleted file mode 100644 index 07c11ae1..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/index.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -

Listing states

- - - - - -<% for state in @states %> - - - - - - -<% end %> -
<%= state.name %><%= link_to 'Show', state %><%= link_to 'Edit', edit_state_path(state) %><%= link_to 'Destroy', state, :confirm => 'Are you sure?', :method => :delete %>
- -
- -<%= link_to 'New state', new_state_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/new.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/new.html.erb deleted file mode 100644 index 5caacd5d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -

New state

- -<%= error_messages_for :state %> - -<% form_for(@state) do |f| %> -

- <%= f.submit "Create" %> -

-<% end %> - -<%= link_to 'Back', states_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/show.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/show.html.erb deleted file mode 100644 index ba5c32fb..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/states/show.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - -<%= link_to 'Edit', edit_state_path(@state) %> | -<%= link_to 'Back', states_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/edit.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/edit.html.erb deleted file mode 100644 index b497ec93..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

Editing user

- -<%= error_messages_for :user %> - -<% form_for(@user) do |f| %> -

- <%= f.submit "Update" %> -

-<% end %> - -<%= link_to 'Show', @user %> | -<%= link_to 'Back', users_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/index.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/index.html.erb deleted file mode 100644 index 6397e64e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/index.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -

Listing users

- - - - - -<% for user in @users %> - - - - - - - - - -<% end %> -
<%= h(user.login) %><%= h(user.address.line_1) %><%= h(user.address.city) %><%= h(user.address.state.name) %><%= link_to 'Show', user %><%= link_to 'Edit', edit_user_path(user) %><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %>
- -
- -<%= link_to 'New user', new_user_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/new.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/new.html.erb deleted file mode 100644 index bc76aa6b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -

New user

- -<%= error_messages_for :user %> - -<% form_for(@user) do |f| %> -

- <%= f.submit "Create" %> -

-<% end %> - -<%= link_to 'Back', users_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/show.html.erb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/show.html.erb deleted file mode 100644 index 3109a37d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/app/views/users/show.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - -<%= link_to 'Edit', edit_user_path(@user) %> | -<%= link_to 'Back', users_path %> diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/boot.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/boot.rb deleted file mode 100644 index cb9a72da..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/boot.rb +++ /dev/null @@ -1,110 +0,0 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb - -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) - -module Rails - class << self - def boot! - unless booted? - preinitialize - pick_boot.run - end - end - - def booted? - defined? Rails::Initializer - end - - def pick_boot - (vendor_rails? ? VendorBoot : GemBoot).new - end - - def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") - end - - def preinitialize - load(preinitializer_path) if File.exists?(preinitializer_path) - end - - def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" - end - end - - class Boot - def run - load_initializer - Rails::Initializer.run(:set_load_path) - end - end - - class VendorBoot < Boot - def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" - end - end - - class GemBoot < Boot - def load_initializer - self.class.load_rubygems - load_rails_gem - require 'initializer' - end - - def load_rails_gem - if version = self.class.gem_version - STDERR.puts "Boot.rb loading version #{version}" - gem 'rails', version - else - STDERR.puts "Boot.rb loading latest available version" - gem 'rails' - end - rescue Gem::LoadError => load_error - $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.) - exit 1 - end - - class << self - def rubygems_version - Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion - end - - def gem_version - if defined? RAILS_GEM_VERSION - RAILS_GEM_VERSION - elsif ENV.include?('RAILS_GEM_VERSION') - ENV['RAILS_GEM_VERSION'] - else - parse_gem_version(read_environment_rb) - end - end - - def load_rubygems - require 'rubygems' - - unless rubygems_version >= '0.9.4' - $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) - exit 1 - end - - rescue LoadError - $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) - exit 1 - end - - def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/ - end - - private - def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") - end - end - end -end - -# All that for this: -Rails.boot! diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/database.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/database.yml deleted file mode 100644 index c64a5d89..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/database.yml +++ /dev/null @@ -1,17 +0,0 @@ - -defaults: &defaults - adapter: <%= ENV['DB'] || 'mysql' %> - host: localhost - database: hmp_development - username: root - password: - -development: - <<: *defaults - -test: - <<: *defaults - -production: - <<: *defaults - \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environment.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environment.rb deleted file mode 100644 index 39f34dee..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environment.rb +++ /dev/null @@ -1,19 +0,0 @@ -require File.join(File.dirname(__FILE__), 'boot') -require 'action_controller' - -Rails::Initializer.run do |config| - - if ActionController::Base.respond_to? 'session=' - config.action_controller.session = {:session_key => '_app_session', :secret => '22cde4d5c1a61ba69a81795322cde4d5c1a61ba69a817953'} - end - - config.load_paths << "#{RAILS_ROOT}/app/models/person" # moduleless model path - - config.after_initialize do - config.has_many_polymorphs_options['requirements'] << "#{RAILS_ROOT}/lib/library_model" - end -end - -# Dependencies.log_activity = true - -ENV['RAILS_ASSET_ID'] = Time.now.to_i.to_s diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environment.rb.canonical b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environment.rb.canonical deleted file mode 100644 index 39f34dee..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environment.rb.canonical +++ /dev/null @@ -1,19 +0,0 @@ -require File.join(File.dirname(__FILE__), 'boot') -require 'action_controller' - -Rails::Initializer.run do |config| - - if ActionController::Base.respond_to? 'session=' - config.action_controller.session = {:session_key => '_app_session', :secret => '22cde4d5c1a61ba69a81795322cde4d5c1a61ba69a817953'} - end - - config.load_paths << "#{RAILS_ROOT}/app/models/person" # moduleless model path - - config.after_initialize do - config.has_many_polymorphs_options['requirements'] << "#{RAILS_ROOT}/lib/library_model" - end -end - -# Dependencies.log_activity = true - -ENV['RAILS_ASSET_ID'] = Time.now.to_i.to_s diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/development.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/development.rb deleted file mode 100644 index 54ae4ed2..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/development.rb +++ /dev/null @@ -1,9 +0,0 @@ - -config.cache_classes = ENV['PRODUCTION'] -config.whiny_nils = true -config.action_controller.consider_all_requests_local = !ENV['PRODUCTION'] -config.action_controller.perform_caching = ENV['PRODUCTION'] -# The following has been deprecated in Rails 2.1 and removed in 2.2 -config.action_view.cache_template_extensions = ENV['PRODUCTION'] if Rails::VERSION::MAJOR < 2 or Rails::VERSION::MAJOR == 2 && Rails::VERSION::MINOR < 1 -config.action_view.debug_rjs = !ENV['PRODUCTION'] -config.action_mailer.raise_delivery_errors = false diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/production.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/production.rb deleted file mode 100644 index cb295b83..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/production.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true - -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new - -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true - -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" - -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/test.rb deleted file mode 100644 index f0689b92..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/environments/test.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = true - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false - -# Tell ActionMailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/locomotive.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/locomotive.yml deleted file mode 100644 index 01d79773..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/locomotive.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -mode: development -runs_at_launch: 0 -identifier: testapp -port: 3005 -bundle: /Applications/Locomotive2/Bundles/rmagickRailsMar2007_i386.locobundle \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/routes.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/routes.rb deleted file mode 100644 index b83b6f4d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/routes.rb +++ /dev/null @@ -1,33 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - map.resources :states - - map.resources :states - - map.resources :addresses - - map.resources :sellers - - map.resources :users - - # The priority is based upon order of creation: first created -> highest priority. - - # Sample of regular route: - # map.connect 'products/:id', :controller => 'catalog', :action => 'view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' - # This route can be invoked with purchase_url(:id => product.id) - - # You can have the root of your site routed by hooking up '' - # -- just remember to delete public/index.html. - # map.connect '', :controller => "welcome" - - # Allow downloading Web Service WSDL as a file with an extension - # instead of a file named 'wsdl' - map.connect ':controller/service.wsdl', :action => 'wsdl' - - # Install the default route as the lowest priority. - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/ultrasphinx/default.base b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/ultrasphinx/default.base deleted file mode 100644 index 2886ccdc..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/ultrasphinx/default.base +++ /dev/null @@ -1,56 +0,0 @@ -# -# Sphinx/Ultrasphinx user-configurable options. -# -# Copy this file to RAILS_ROOT/config/ultrasphinx. -# You can use individual namespaces if you want (e.g. "development.base"). -# - -indexer -{ - # Indexer running options - mem_limit = 256M -} - -searchd -{ - # Daemon options - # What interface the search daemon should listen on and where to store its logs - address = 0.0.0.0 - port = 3313 - log = /tmp/sphinx/searchd.log - query_log = /tmp/sphinx/query.log - read_timeout = 5 - max_children = 300 - pid_file = /tmp/sphinx/searchd.pid - max_matches = 100000 -} - -client -{ - # Client options - dictionary_name = ts - # How your application connects to the search daemon (not necessarily the same as above) - server_host = localhost - server_port = 3313 -} - -source -{ - # Individual SQL source options - sql_range_step = 20000 - strip_html = 0 - index_html_attrs = - sql_query_post = -} - -index -{ - # Index building options - path = /tmp/sphinx/ - docinfo = extern # just leave this alone - morphology = stem_en - stopwords = # /path/to/stopwords.txt - min_word_len = 1 - charset_type = utf-8 # or sbcs (Single Byte Character Set) - charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F,U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, U+D6->U+F6, U+F6, U+16B, U+0c1->a, U+0c4->a, U+0c9->e, U+0cd->i, U+0d3->o, U+0d4->o, U+0da->u, U+0dd->y, U+0e1->a, U+0e4->a, U+0e9->e, U+0ed->i, U+0f3->o, U+0f4->o, U+0fa->u, U+0fd->y, U+104->U+105, U+105, U+106->U+107, U+10c->c, U+10d->c, U+10e->d, U+10f->d, U+116->U+117, U+117, U+118->U+119, U+11a->e, U+11b->e, U+12E->U+12F, U+12F, U+139->l, U+13a->l, U+13d->l, U+13e->l, U+141->U+142, U+142, U+143->U+144, U+144,U+147->n, U+148->n, U+154->r, U+155->r, U+158->r, U+159->r, U+15A->U+15B, U+15B, U+160->s, U+160->U+161, U+161->s, U+164->t, U+165->t, U+16A->U+16B, U+16B, U+16e->u, U+16f->u, U+172->U+173, U+173, U+179->U+17A, U+17A, U+17B->U+17C, U+17C, U+17d->z, U+17e->z, -} diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/ultrasphinx/development.conf.canonical b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/ultrasphinx/development.conf.canonical deleted file mode 100644 index f08e8ed4..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/config/ultrasphinx/development.conf.canonical +++ /dev/null @@ -1,155 +0,0 @@ - -# Auto-generated at Wed Oct 03 03:57:12 -0400 2007. -# Hand modifications will be overwritten. -# /Users/eweaver/Desktop/projects/chow/vendor/plugins/ultrasphinx/test/integration/app/config/ultrasphinx/default.base -indexer { - mem_limit = 256M -} -searchd { - read_timeout = 5 - max_children = 300 - log = /tmp/sphinx/searchd.log - port = 3313 - max_matches = 100000 - query_log = /tmp/sphinx/query.log - pid_file = /tmp/sphinx/searchd.pid - address = 0.0.0.0 -} - -# Source configuration - -source geo__states -{ - strip_html = 0 - sql_range_step = 20000 - index_html_attrs = - sql_query_post = - -type = mysql -sql_query_pre = SET SESSION group_concat_max_len = 65535 -sql_query_pre = SET NAMES utf8 - -sql_db = app_development -sql_host = localhost -sql_pass = -sql_user = root -sql_query_range = SELECT MIN(id), MAX(id) FROM states -sql_query = SELECT (states.id * 4 + 0) AS id, CAST(GROUP_CONCAT(addresses.name SEPARATOR ' ') AS CHAR) AS address_name, 0 AS capitalization, 'Geo::State' AS class, 0 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS content, UNIX_TIMESTAMP('1970-01-01 00:00:00') AS created_at, 0 AS deleted, '' AS email, '__empty_searchable__' AS empty_searchable, '' AS login, '' AS name, '' AS state, 0 AS user_id FROM states LEFT OUTER JOIN addresses ON states.id = addresses.state_id WHERE states.id >= $start AND states.id <= $end GROUP BY id - -sql_group_column = capitalization -sql_group_column = class_id -sql_group_column = company_name_facet -sql_date_column = created_at -sql_group_column = deleted -sql_group_column = user_id -sql_query_info = SELECT * FROM states WHERE states.id = (($id - 0) / 4) -} - - -# Source configuration - -source sellers -{ - strip_html = 0 - sql_range_step = 20000 - index_html_attrs = - sql_query_post = - -type = mysql -sql_query_pre = SET SESSION group_concat_max_len = 65535 -sql_query_pre = SET NAMES utf8 - -sql_db = app_development -sql_host = localhost -sql_pass = -sql_user = root -sql_query_range = SELECT MIN(id), MAX(id) FROM sellers -sql_query = SELECT (sellers.id * 4 + 1) AS id, '' AS address_name, sellers.capitalization AS capitalization, 'Seller' AS class, 1 AS class_id, '' AS company, sellers.company_name AS company_name, CRC32(sellers.company_name) AS company_name_facet, '' AS content, UNIX_TIMESTAMP(sellers.created_at) AS created_at, 0 AS deleted, '' AS email, '__empty_searchable__' AS empty_searchable, '' AS login, '' AS name, '' AS state, sellers.user_id AS user_id FROM sellers WHERE sellers.id >= $start AND sellers.id <= $end GROUP BY id - -sql_group_column = capitalization -sql_group_column = class_id -sql_group_column = company_name_facet -sql_date_column = created_at -sql_group_column = deleted -sql_group_column = user_id -sql_query_info = SELECT * FROM sellers WHERE sellers.id = (($id - 1) / 4) -} - - -# Source configuration - -source geo__addresses -{ - strip_html = 0 - sql_range_step = 20000 - index_html_attrs = - sql_query_post = - -type = mysql -sql_query_pre = SET SESSION group_concat_max_len = 65535 -sql_query_pre = SET NAMES utf8 - -sql_db = app_development -sql_host = localhost -sql_pass = -sql_user = root -sql_query_range = SELECT MIN(id), MAX(id) FROM addresses -sql_query = SELECT (addresses.id * 4 + 2) AS id, '' AS address_name, 0 AS capitalization, 'Geo::Address' AS class, 2 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, CONCAT_WS(' ', addresses.line_1, addresses.line_2, addresses.city, addresses.province_region, addresses.zip_postal_code) AS content, UNIX_TIMESTAMP('1970-01-01 00:00:00') AS created_at, 0 AS deleted, '' AS email, '__empty_searchable__' AS empty_searchable, '' AS login, addresses.name AS name, states.name AS state, 0 AS user_id FROM addresses LEFT OUTER JOIN states ON states.id = addresses.state_id WHERE addresses.id >= $start AND addresses.id <= $end GROUP BY id - -sql_group_column = capitalization -sql_group_column = class_id -sql_group_column = company_name_facet -sql_date_column = created_at -sql_group_column = deleted -sql_group_column = user_id -sql_query_info = SELECT * FROM addresses WHERE addresses.id = (($id - 2) / 4) -} - - -# Source configuration - -source users -{ - strip_html = 0 - sql_range_step = 20000 - index_html_attrs = - sql_query_post = - -type = mysql -sql_query_pre = SET SESSION group_concat_max_len = 65535 -sql_query_pre = SET NAMES utf8 - -sql_db = app_development -sql_host = localhost -sql_pass = -sql_user = root -sql_query_range = SELECT MIN(id), MAX(id) FROM users -sql_query = SELECT (users.id * 4 + 3) AS id, '' AS address_name, 0 AS capitalization, 'User' AS class, 3 AS class_id, sellers.company_name AS company, '' AS company_name, 0 AS company_name_facet, '' AS content, UNIX_TIMESTAMP('1970-01-01 00:00:00') AS created_at, users.deleted AS deleted, users.email AS email, '__empty_searchable__' AS empty_searchable, users.login AS login, '' AS name, '' AS state, 0 AS user_id FROM users LEFT OUTER JOIN sellers ON users.id = sellers.user_id WHERE users.id >= $start AND users.id <= $end AND (deleted = 0) GROUP BY id - -sql_group_column = capitalization -sql_group_column = class_id -sql_group_column = company_name_facet -sql_date_column = created_at -sql_group_column = deleted -sql_group_column = user_id -sql_query_info = SELECT * FROM users WHERE users.id = (($id - 3) / 4) -} - - -# Index configuration - -index complete -{ - source = geo__addresses - source = geo__states - source = sellers - source = users - charset_type = utf-8 - charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F,U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, U+D6->U+F6, U+F6, U+16B, U+0c1->a, U+0c4->a, U+0c9->e, U+0cd->i, U+0d3->o, U+0d4->o, U+0da->u, U+0dd->y, U+0e1->a, U+0e4->a, U+0e9->e, U+0ed->i, U+0f3->o, U+0f4->o, U+0fa->u, U+0fd->y, U+104->U+105, U+105, U+106->U+107, U+10c->c, U+10d->c, U+10e->d, U+10f->d, U+116->U+117, U+117, U+118->U+119, U+11a->e, U+11b->e, U+12E->U+12F, U+12F, U+139->l, U+13a->l, U+13d->l, U+13e->l, U+141->U+142, U+142, U+143->U+144, U+144,U+147->n, U+148->n, U+154->r, U+155->r, U+158->r, U+159->r, U+15A->U+15B, U+15B, U+160->s, U+160->U+161, U+161->s, U+164->t, U+165->t, U+16A->U+16B, U+16B, U+16e->u, U+16f->u, U+172->U+173, U+173, U+179->U+17A, U+17A, U+17B->U+17C, U+17C, U+17d->z, U+17e->z, - min_word_len = 1 - stopwords = - path = /tmp/sphinx//sphinx_index_complete - docinfo = extern - morphology = stem_en -} - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/001_create_sticks.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/001_create_sticks.rb deleted file mode 100644 index 6193c313..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/001_create_sticks.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateSticks < ActiveRecord::Migration - def self.up - create_table :sticks do |t| - t.column :name, :string - end - end - - def self.down - drop_table :sticks - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/002_create_stones.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/002_create_stones.rb deleted file mode 100644 index 4c1ec154..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/002_create_stones.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateStones < ActiveRecord::Migration - def self.up - create_table :stones do |t| - t.column :name, :string - end - end - - def self.down - drop_table :stones - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/003_create_organic_substances.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/003_create_organic_substances.rb deleted file mode 100644 index 1bf82da6..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/003_create_organic_substances.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateOrganicSubstances < ActiveRecord::Migration - def self.up - create_table :organic_substances do |t| - t.column :type, :string - end - end - - def self.down - drop_table :organic_substances - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/004_create_bones.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/004_create_bones.rb deleted file mode 100644 index 6faa0aa1..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/004_create_bones.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateBones < ActiveRecord::Migration - def self.up - # Using STI - end - - def self.down - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/005_create_single_sti_parents.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/005_create_single_sti_parents.rb deleted file mode 100644 index eef14621..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/005_create_single_sti_parents.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateSingleStiParents < ActiveRecord::Migration - def self.up - create_table :single_sti_parents do |t| - t.column :name, :string - end - end - - def self.down - drop_table :single_sti_parents - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/006_create_double_sti_parents.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/006_create_double_sti_parents.rb deleted file mode 100644 index 2a28f4ab..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/006_create_double_sti_parents.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateDoubleStiParents < ActiveRecord::Migration - def self.up - create_table :double_sti_parents do |t| - t.column :name, :string - end - end - - def self.down - drop_table :double_sti_parents - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb deleted file mode 100644 index deceeec7..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateSingleStiParentRelationships < ActiveRecord::Migration - def self.up - create_table :single_sti_parent_relationships do |t| - t.column :the_bone_type, :string, :null => false - t.column :the_bone_id, :integer, :null => false - t.column :single_sti_parent_id, :integer, :null => false - end - end - - def self.down - drop_table :single_sti_parent_relationships - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb deleted file mode 100644 index 46605d9b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateDoubleStiParentRelationships < ActiveRecord::Migration - def self.up - create_table :double_sti_parent_relationships do |t| - t.column :the_bone_type, :string, :null => false - t.column :the_bone_id, :integer, :null => false - t.column :parent_type, :string, :null => false - t.column :parent_id, :integer, :null => false - end - end - - def self.down - drop_table :double_sti_parent_relationships - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/009_create_library_model.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/009_create_library_model.rb deleted file mode 100644 index bdf7cf46..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/db/migrate/009_create_library_model.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateLibraryModel < ActiveRecord::Migration - def self.up - create_table :library_models do |t| - t.column :name, :string - end - end - - def self.down - drop_table :library_models - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/doc/README_FOR_APP b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/doc/README_FOR_APP deleted file mode 100644 index ac6c1491..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -Use this README file to introduce your application and point to useful places in the API for learning more. -Run "rake appdoc" to generate API documentation for your models and controllers. \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/generators/commenting_generator_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/generators/commenting_generator_test.rb deleted file mode 100644 index 96c6a799..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/generators/commenting_generator_test.rb +++ /dev/null @@ -1,83 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'fileutils' - -class CommentingGeneratorTest < Test::Unit::TestCase - - def test_ensure_comments_dont_exist - # make sure the comments are already defined - assert_equal false, Object.send(:const_defined?, :Comment) - assert_equal false, Object.send(:const_defined?, :Commenting) - end - - def test_ensure_files_exist_after_generator_runs - run_generator - - # make sure the files are there - for generated_file in generated_files do - assert File.exists?(File.expand_path(generated_file)) - end - end - - def test_classes_exist_with_associations - run_generator - assert_nothing_raised { Commenting } - assert_nothing_raised { Comment } - citation = Citation.find(:first) - assert !citation.nil? - assert citation.respond_to?(:comments) - user = User.find(:first) - assert !user.nil? - assert user.respond_to?(:comments) - end - - def teardown - Object.send(:remove_const, :Comment) if Object.send(:const_defined?, :Comment) - Object.send(:remove_const, :Commenting) if Object.send(:const_defined?, :Commenting) - remove_all_generated_files - remove_require_for_commenting_extensions - end - - def generated_files - generated_files = [File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'comment.rb')] - generated_files << File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'commenting.rb') - generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'unit', 'commenting_test.rb') - generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'unit', 'comment_test.rb') - generated_files << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'commenting_extensions.rb') - generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'fixtures', 'comments.yml') - generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'fixtures', 'commentings.yml') - end - - def remove_all_generated_files - for generated_file in generated_files do - if File.exists?(generated_file) - assert FileUtils.rm(generated_file) - end - end - end - - def run_migrate - `rake db:migrate RAILS_ENV=test` - end - - def run_generator - command = File.join(File.dirname(__FILE__), '..', '..', 'script', 'generate') - `#{command} commenting Citation User` - run_migrate - end - - def remove_require_for_commenting_extensions - environment = File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment.rb') - new_environment = '' - if File.exists?(environment) - if (open(environment) { |file| file.grep(/Rails/).any? }) - IO.readlines(environment).each do |line| - new_environment += line unless line.match(/commenting_extensions/i) - end - File.open(environment, "w+") do |f| - f.pos = 0 - f.print new_environment - end - end - end - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/lib/library_model.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/lib/library_model.rb deleted file mode 100644 index e27106fa..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/lib/library_model.rb +++ /dev/null @@ -1,2 +0,0 @@ -class LibraryModel < ActiveRecord::Base -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/404.html b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/404.html deleted file mode 100644 index eff660b9..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/404.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - The page you were looking for doesn't exist (404) - - - - - -
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
- - \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/500.html b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/500.html deleted file mode 100644 index f0aee0e9..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/500.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - We're sorry, but something went wrong - - - - - -
-

We're sorry, but something went wrong.

-

We've been notified about this issue and we'll take a look at it shortly.

-
- - \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.cgi b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.cgi deleted file mode 100755 index 9b5ae760..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.cgi +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/local/bin/ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.fcgi b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.fcgi deleted file mode 100755 index 664dbbbe..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.fcgi +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby -# -# You may specify the path to the FastCGI crash log (a log of unhandled -# exceptions which forced the FastCGI instance to exit, great for debugging) -# and the number of requests to process before running garbage collection. -# -# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log -# and the GC period is nil (turned off). A reasonable number of requests -# could range from 10-100 depending on the memory footprint of your app. -# -# Example: -# # Default log path, normal GC behavior. -# RailsFCGIHandler.process! -# -# # Default log path, 50 requests between GC. -# RailsFCGIHandler.process! nil, 50 -# -# # Custom log path, normal GC behavior. -# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' -# -require File.dirname(__FILE__) + "/../config/environment" -require 'fcgi_handler' - -RailsFCGIHandler.process! diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.rb deleted file mode 100755 index 9b5ae760..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/dispatch.rb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/local/bin/ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/favicon.ico b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/images/rails.png b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/images/rails.png deleted file mode 100644 index b8441f18..00000000 Binary files a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/images/rails.png and /dev/null differ diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/index.html b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/index.html deleted file mode 100644 index a2daab72..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/index.html +++ /dev/null @@ -1,277 +0,0 @@ - - - - - Ruby on Rails: Welcome aboard - - - - - - -
- - -
- - - - -
-

Getting started

-

Here’s how to get rolling:

- -
    -
  1. -

    Create your databases and edit config/database.yml

    -

    Rails needs to know your login and password.

    -
  2. - -
  3. -

    Use script/generate to create your models and controllers

    -

    To see all available options, run it without parameters.

    -
  4. - -
  5. -

    Set up a default route and remove or rename this file

    -

    Routes are setup in config/routes.rb.

    -
  6. -
-
-
- - -
- - \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/application.js b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/application.js deleted file mode 100644 index fe457769..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/application.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place your application-specific JavaScript functions and classes here -// This file is automatically included by javascript_include_tag :defaults diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/controls.js b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/controls.js deleted file mode 100644 index 8c273f87..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/controls.js +++ /dev/null @@ -1,833 +0,0 @@ -// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan) -// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) -// Contributors: -// Richard Livsey -// Rahul Bhargava -// Rob Wills -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -// Autocompleter.Base handles all the autocompletion functionality -// that's independent of the data source for autocompletion. This -// includes drawing the autocompletion menu, observing keyboard -// and mouse events, and similar. -// -// Specific autocompleters need to provide, at the very least, -// a getUpdatedChoices function that will be invoked every time -// the text inside the monitored textbox changes. This method -// should get the text for which to provide autocompletion by -// invoking this.getToken(), NOT by directly accessing -// this.element.value. This is to allow incremental tokenized -// autocompletion. Specific auto-completion logic (AJAX, etc) -// belongs in getUpdatedChoices. -// -// Tokenized incremental autocompletion is enabled automatically -// when an autocompleter is instantiated with the 'tokens' option -// in the options parameter, e.g.: -// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); -// will incrementally autocomplete with a comma as the token. -// Additionally, ',' in the above example can be replaced with -// a token array, e.g. { tokens: [',', '\n'] } which -// enables autocompletion on multiple tokens. This is most -// useful when one of the tokens is \n (a newline), as it -// allows smart autocompletion after linebreaks. - -if(typeof Effect == 'undefined') - throw("controls.js requires including script.aculo.us' effects.js library"); - -var Autocompleter = {} -Autocompleter.Base = function() {}; -Autocompleter.Base.prototype = { - baseInitialize: function(element, update, options) { - this.element = $(element); - this.update = $(update); - this.hasFocus = false; - this.changed = false; - this.active = false; - this.index = 0; - this.entryCount = 0; - - if(this.setOptions) - this.setOptions(options); - else - this.options = options || {}; - - this.options.paramName = this.options.paramName || this.element.name; - this.options.tokens = this.options.tokens || []; - this.options.frequency = this.options.frequency || 0.4; - this.options.minChars = this.options.minChars || 1; - this.options.onShow = this.options.onShow || - function(element, update){ - if(!update.style.position || update.style.position=='absolute') { - update.style.position = 'absolute'; - Position.clone(element, update, { - setHeight: false, - offsetTop: element.offsetHeight - }); - } - Effect.Appear(update,{duration:0.15}); - }; - this.options.onHide = this.options.onHide || - function(element, update){ new Effect.Fade(update,{duration:0.15}) }; - - if(typeof(this.options.tokens) == 'string') - this.options.tokens = new Array(this.options.tokens); - - this.observer = null; - - this.element.setAttribute('autocomplete','off'); - - Element.hide(this.update); - - Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); - Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); - }, - - show: function() { - if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); - if(!this.iefix && - (navigator.appVersion.indexOf('MSIE')>0) && - (navigator.userAgent.indexOf('Opera')<0) && - (Element.getStyle(this.update, 'position')=='absolute')) { - new Insertion.After(this.update, - ''); - this.iefix = $(this.update.id+'_iefix'); - } - if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); - }, - - fixIEOverlapping: function() { - Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); - this.iefix.style.zIndex = 1; - this.update.style.zIndex = 2; - Element.show(this.iefix); - }, - - hide: function() { - this.stopIndicator(); - if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); - if(this.iefix) Element.hide(this.iefix); - }, - - startIndicator: function() { - if(this.options.indicator) Element.show(this.options.indicator); - }, - - stopIndicator: function() { - if(this.options.indicator) Element.hide(this.options.indicator); - }, - - onKeyPress: function(event) { - if(this.active) - switch(event.keyCode) { - case Event.KEY_TAB: - case Event.KEY_RETURN: - this.selectEntry(); - Event.stop(event); - case Event.KEY_ESC: - this.hide(); - this.active = false; - Event.stop(event); - return; - case Event.KEY_LEFT: - case Event.KEY_RIGHT: - return; - case Event.KEY_UP: - this.markPrevious(); - this.render(); - if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); - return; - case Event.KEY_DOWN: - this.markNext(); - this.render(); - if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); - return; - } - else - if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || - (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return; - - this.changed = true; - this.hasFocus = true; - - if(this.observer) clearTimeout(this.observer); - this.observer = - setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); - }, - - activate: function() { - this.changed = false; - this.hasFocus = true; - this.getUpdatedChoices(); - }, - - onHover: function(event) { - var element = Event.findElement(event, 'LI'); - if(this.index != element.autocompleteIndex) - { - this.index = element.autocompleteIndex; - this.render(); - } - Event.stop(event); - }, - - onClick: function(event) { - var element = Event.findElement(event, 'LI'); - this.index = element.autocompleteIndex; - this.selectEntry(); - this.hide(); - }, - - onBlur: function(event) { - // needed to make click events working - setTimeout(this.hide.bind(this), 250); - this.hasFocus = false; - this.active = false; - }, - - render: function() { - if(this.entryCount > 0) { - for (var i = 0; i < this.entryCount; i++) - this.index==i ? - Element.addClassName(this.getEntry(i),"selected") : - Element.removeClassName(this.getEntry(i),"selected"); - - if(this.hasFocus) { - this.show(); - this.active = true; - } - } else { - this.active = false; - this.hide(); - } - }, - - markPrevious: function() { - if(this.index > 0) this.index-- - else this.index = this.entryCount-1; - this.getEntry(this.index).scrollIntoView(true); - }, - - markNext: function() { - if(this.index < this.entryCount-1) this.index++ - else this.index = 0; - this.getEntry(this.index).scrollIntoView(false); - }, - - getEntry: function(index) { - return this.update.firstChild.childNodes[index]; - }, - - getCurrentEntry: function() { - return this.getEntry(this.index); - }, - - selectEntry: function() { - this.active = false; - this.updateElement(this.getCurrentEntry()); - }, - - updateElement: function(selectedElement) { - if (this.options.updateElement) { - this.options.updateElement(selectedElement); - return; - } - var value = ''; - if (this.options.select) { - var nodes = document.getElementsByClassName(this.options.select, selectedElement) || []; - if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); - } else - value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - - var lastTokenPos = this.findLastToken(); - if (lastTokenPos != -1) { - var newValue = this.element.value.substr(0, lastTokenPos + 1); - var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); - if (whitespace) - newValue += whitespace[0]; - this.element.value = newValue + value; - } else { - this.element.value = value; - } - this.element.focus(); - - if (this.options.afterUpdateElement) - this.options.afterUpdateElement(this.element, selectedElement); - }, - - updateChoices: function(choices) { - if(!this.changed && this.hasFocus) { - this.update.innerHTML = choices; - Element.cleanWhitespace(this.update); - Element.cleanWhitespace(this.update.down()); - - if(this.update.firstChild && this.update.down().childNodes) { - this.entryCount = - this.update.down().childNodes.length; - for (var i = 0; i < this.entryCount; i++) { - var entry = this.getEntry(i); - entry.autocompleteIndex = i; - this.addObservers(entry); - } - } else { - this.entryCount = 0; - } - - this.stopIndicator(); - this.index = 0; - - if(this.entryCount==1 && this.options.autoSelect) { - this.selectEntry(); - this.hide(); - } else { - this.render(); - } - } - }, - - addObservers: function(element) { - Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); - Event.observe(element, "click", this.onClick.bindAsEventListener(this)); - }, - - onObserverEvent: function() { - this.changed = false; - if(this.getToken().length>=this.options.minChars) { - this.startIndicator(); - this.getUpdatedChoices(); - } else { - this.active = false; - this.hide(); - } - }, - - getToken: function() { - var tokenPos = this.findLastToken(); - if (tokenPos != -1) - var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); - else - var ret = this.element.value; - - return /\n/.test(ret) ? '' : ret; - }, - - findLastToken: function() { - var lastTokenPos = -1; - - for (var i=0; i lastTokenPos) - lastTokenPos = thisTokenPos; - } - return lastTokenPos; - } -} - -Ajax.Autocompleter = Class.create(); -Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { - initialize: function(element, update, url, options) { - this.baseInitialize(element, update, options); - this.options.asynchronous = true; - this.options.onComplete = this.onComplete.bind(this); - this.options.defaultParams = this.options.parameters || null; - this.url = url; - }, - - getUpdatedChoices: function() { - entry = encodeURIComponent(this.options.paramName) + '=' + - encodeURIComponent(this.getToken()); - - this.options.parameters = this.options.callback ? - this.options.callback(this.element, entry) : entry; - - if(this.options.defaultParams) - this.options.parameters += '&' + this.options.defaultParams; - - new Ajax.Request(this.url, this.options); - }, - - onComplete: function(request) { - this.updateChoices(request.responseText); - } - -}); - -// The local array autocompleter. Used when you'd prefer to -// inject an array of autocompletion options into the page, rather -// than sending out Ajax queries, which can be quite slow sometimes. -// -// The constructor takes four parameters. The first two are, as usual, -// the id of the monitored textbox, and id of the autocompletion menu. -// The third is the array you want to autocomplete from, and the fourth -// is the options block. -// -// Extra local autocompletion options: -// - choices - How many autocompletion choices to offer -// -// - partialSearch - If false, the autocompleter will match entered -// text only at the beginning of strings in the -// autocomplete array. Defaults to true, which will -// match text at the beginning of any *word* in the -// strings in the autocomplete array. If you want to -// search anywhere in the string, additionally set -// the option fullSearch to true (default: off). -// -// - fullSsearch - Search anywhere in autocomplete array strings. -// -// - partialChars - How many characters to enter before triggering -// a partial match (unlike minChars, which defines -// how many characters are required to do any match -// at all). Defaults to 2. -// -// - ignoreCase - Whether to ignore case when autocompleting. -// Defaults to true. -// -// It's possible to pass in a custom function as the 'selector' -// option, if you prefer to write your own autocompletion logic. -// In that case, the other options above will not apply unless -// you support them. - -Autocompleter.Local = Class.create(); -Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), { - initialize: function(element, update, array, options) { - this.baseInitialize(element, update, options); - this.options.array = array; - }, - - getUpdatedChoices: function() { - this.updateChoices(this.options.selector(this)); - }, - - setOptions: function(options) { - this.options = Object.extend({ - choices: 10, - partialSearch: true, - partialChars: 2, - ignoreCase: true, - fullSearch: false, - selector: function(instance) { - var ret = []; // Beginning matches - var partial = []; // Inside matches - var entry = instance.getToken(); - var count = 0; - - for (var i = 0; i < instance.options.array.length && - ret.length < instance.options.choices ; i++) { - - var elem = instance.options.array[i]; - var foundPos = instance.options.ignoreCase ? - elem.toLowerCase().indexOf(entry.toLowerCase()) : - elem.indexOf(entry); - - while (foundPos != -1) { - if (foundPos == 0 && elem.length != entry.length) { - ret.push("
  • " + elem.substr(0, entry.length) + "" + - elem.substr(entry.length) + "
  • "); - break; - } else if (entry.length >= instance.options.partialChars && - instance.options.partialSearch && foundPos != -1) { - if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) { - partial.push("
  • " + elem.substr(0, foundPos) + "" + - elem.substr(foundPos, entry.length) + "" + elem.substr( - foundPos + entry.length) + "
  • "); - break; - } - } - - foundPos = instance.options.ignoreCase ? - elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : - elem.indexOf(entry, foundPos + 1); - - } - } - if (partial.length) - ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) - return "
      " + ret.join('') + "
    "; - } - }, options || {}); - } -}); - -// AJAX in-place editor -// -// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor - -// Use this if you notice weird scrolling problems on some browsers, -// the DOM might be a bit confused when this gets called so do this -// waits 1 ms (with setTimeout) until it does the activation -Field.scrollFreeActivate = function(field) { - setTimeout(function() { - Field.activate(field); - }, 1); -} - -Ajax.InPlaceEditor = Class.create(); -Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99"; -Ajax.InPlaceEditor.prototype = { - initialize: function(element, url, options) { - this.url = url; - this.element = $(element); - - this.options = Object.extend({ - paramName: "value", - okButton: true, - okText: "ok", - cancelLink: true, - cancelText: "cancel", - savingText: "Saving...", - clickToEditText: "Click to edit", - okText: "ok", - rows: 1, - onComplete: function(transport, element) { - new Effect.Highlight(element, {startcolor: this.options.highlightcolor}); - }, - onFailure: function(transport) { - alert("Error communicating with the server: " + transport.responseText.stripTags()); - }, - callback: function(form) { - return Form.serialize(form); - }, - handleLineBreaks: true, - loadingText: 'Loading...', - savingClassName: 'inplaceeditor-saving', - loadingClassName: 'inplaceeditor-loading', - formClassName: 'inplaceeditor-form', - highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, - highlightendcolor: "#FFFFFF", - externalControl: null, - submitOnBlur: false, - ajaxOptions: {}, - evalScripts: false - }, options || {}); - - if(!this.options.formId && this.element.id) { - this.options.formId = this.element.id + "-inplaceeditor"; - if ($(this.options.formId)) { - // there's already a form with that name, don't specify an id - this.options.formId = null; - } - } - - if (this.options.externalControl) { - this.options.externalControl = $(this.options.externalControl); - } - - this.originalBackground = Element.getStyle(this.element, 'background-color'); - if (!this.originalBackground) { - this.originalBackground = "transparent"; - } - - this.element.title = this.options.clickToEditText; - - this.onclickListener = this.enterEditMode.bindAsEventListener(this); - this.mouseoverListener = this.enterHover.bindAsEventListener(this); - this.mouseoutListener = this.leaveHover.bindAsEventListener(this); - Event.observe(this.element, 'click', this.onclickListener); - Event.observe(this.element, 'mouseover', this.mouseoverListener); - Event.observe(this.element, 'mouseout', this.mouseoutListener); - if (this.options.externalControl) { - Event.observe(this.options.externalControl, 'click', this.onclickListener); - Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener); - Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener); - } - }, - enterEditMode: function(evt) { - if (this.saving) return; - if (this.editing) return; - this.editing = true; - this.onEnterEditMode(); - if (this.options.externalControl) { - Element.hide(this.options.externalControl); - } - Element.hide(this.element); - this.createForm(); - this.element.parentNode.insertBefore(this.form, this.element); - if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); - // stop the event to avoid a page refresh in Safari - if (evt) { - Event.stop(evt); - } - return false; - }, - createForm: function() { - this.form = document.createElement("form"); - this.form.id = this.options.formId; - Element.addClassName(this.form, this.options.formClassName) - this.form.onsubmit = this.onSubmit.bind(this); - - this.createEditField(); - - if (this.options.textarea) { - var br = document.createElement("br"); - this.form.appendChild(br); - } - - if (this.options.okButton) { - okButton = document.createElement("input"); - okButton.type = "submit"; - okButton.value = this.options.okText; - okButton.className = 'editor_ok_button'; - this.form.appendChild(okButton); - } - - if (this.options.cancelLink) { - cancelLink = document.createElement("a"); - cancelLink.href = "#"; - cancelLink.appendChild(document.createTextNode(this.options.cancelText)); - cancelLink.onclick = this.onclickCancel.bind(this); - cancelLink.className = 'editor_cancel'; - this.form.appendChild(cancelLink); - } - }, - hasHTMLLineBreaks: function(string) { - if (!this.options.handleLineBreaks) return false; - return string.match(/
    /i); - }, - convertHTMLLineBreaks: function(string) { - return string.replace(/
    /gi, "\n").replace(//gi, "\n").replace(/<\/p>/gi, "\n").replace(/

    /gi, ""); - }, - createEditField: function() { - var text; - if(this.options.loadTextURL) { - text = this.options.loadingText; - } else { - text = this.getText(); - } - - var obj = this; - - if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) { - this.options.textarea = false; - var textField = document.createElement("input"); - textField.obj = this; - textField.type = "text"; - textField.name = this.options.paramName; - textField.value = text; - textField.style.backgroundColor = this.options.highlightcolor; - textField.className = 'editor_field'; - var size = this.options.size || this.options.cols || 0; - if (size != 0) textField.size = size; - if (this.options.submitOnBlur) - textField.onblur = this.onSubmit.bind(this); - this.editField = textField; - } else { - this.options.textarea = true; - var textArea = document.createElement("textarea"); - textArea.obj = this; - textArea.name = this.options.paramName; - textArea.value = this.convertHTMLLineBreaks(text); - textArea.rows = this.options.rows; - textArea.cols = this.options.cols || 40; - textArea.className = 'editor_field'; - if (this.options.submitOnBlur) - textArea.onblur = this.onSubmit.bind(this); - this.editField = textArea; - } - - if(this.options.loadTextURL) { - this.loadExternalText(); - } - this.form.appendChild(this.editField); - }, - getText: function() { - return this.element.innerHTML; - }, - loadExternalText: function() { - Element.addClassName(this.form, this.options.loadingClassName); - this.editField.disabled = true; - new Ajax.Request( - this.options.loadTextURL, - Object.extend({ - asynchronous: true, - onComplete: this.onLoadedExternalText.bind(this) - }, this.options.ajaxOptions) - ); - }, - onLoadedExternalText: function(transport) { - Element.removeClassName(this.form, this.options.loadingClassName); - this.editField.disabled = false; - this.editField.value = transport.responseText.stripTags(); - Field.scrollFreeActivate(this.editField); - }, - onclickCancel: function() { - this.onComplete(); - this.leaveEditMode(); - return false; - }, - onFailure: function(transport) { - this.options.onFailure(transport); - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - this.oldInnerHTML = null; - } - return false; - }, - onSubmit: function() { - // onLoading resets these so we need to save them away for the Ajax call - var form = this.form; - var value = this.editField.value; - - // do this first, sometimes the ajax call returns before we get a chance to switch on Saving... - // which means this will actually switch on Saving... *after* we've left edit mode causing Saving... - // to be displayed indefinitely - this.onLoading(); - - if (this.options.evalScripts) { - new Ajax.Request( - this.url, Object.extend({ - parameters: this.options.callback(form, value), - onComplete: this.onComplete.bind(this), - onFailure: this.onFailure.bind(this), - asynchronous:true, - evalScripts:true - }, this.options.ajaxOptions)); - } else { - new Ajax.Updater( - { success: this.element, - // don't update on failure (this could be an option) - failure: null }, - this.url, Object.extend({ - parameters: this.options.callback(form, value), - onComplete: this.onComplete.bind(this), - onFailure: this.onFailure.bind(this) - }, this.options.ajaxOptions)); - } - // stop the event to avoid a page refresh in Safari - if (arguments.length > 1) { - Event.stop(arguments[0]); - } - return false; - }, - onLoading: function() { - this.saving = true; - this.removeForm(); - this.leaveHover(); - this.showSaving(); - }, - showSaving: function() { - this.oldInnerHTML = this.element.innerHTML; - this.element.innerHTML = this.options.savingText; - Element.addClassName(this.element, this.options.savingClassName); - this.element.style.backgroundColor = this.originalBackground; - Element.show(this.element); - }, - removeForm: function() { - if(this.form) { - if (this.form.parentNode) Element.remove(this.form); - this.form = null; - } - }, - enterHover: function() { - if (this.saving) return; - this.element.style.backgroundColor = this.options.highlightcolor; - if (this.effect) { - this.effect.cancel(); - } - Element.addClassName(this.element, this.options.hoverClassName) - }, - leaveHover: function() { - if (this.options.backgroundColor) { - this.element.style.backgroundColor = this.oldBackground; - } - Element.removeClassName(this.element, this.options.hoverClassName) - if (this.saving) return; - this.effect = new Effect.Highlight(this.element, { - startcolor: this.options.highlightcolor, - endcolor: this.options.highlightendcolor, - restorecolor: this.originalBackground - }); - }, - leaveEditMode: function() { - Element.removeClassName(this.element, this.options.savingClassName); - this.removeForm(); - this.leaveHover(); - this.element.style.backgroundColor = this.originalBackground; - Element.show(this.element); - if (this.options.externalControl) { - Element.show(this.options.externalControl); - } - this.editing = false; - this.saving = false; - this.oldInnerHTML = null; - this.onLeaveEditMode(); - }, - onComplete: function(transport) { - this.leaveEditMode(); - this.options.onComplete.bind(this)(transport, this.element); - }, - onEnterEditMode: function() {}, - onLeaveEditMode: function() {}, - dispose: function() { - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - } - this.leaveEditMode(); - Event.stopObserving(this.element, 'click', this.onclickListener); - Event.stopObserving(this.element, 'mouseover', this.mouseoverListener); - Event.stopObserving(this.element, 'mouseout', this.mouseoutListener); - if (this.options.externalControl) { - Event.stopObserving(this.options.externalControl, 'click', this.onclickListener); - Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener); - Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener); - } - } -}; - -Ajax.InPlaceCollectionEditor = Class.create(); -Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype); -Object.extend(Ajax.InPlaceCollectionEditor.prototype, { - createEditField: function() { - if (!this.cached_selectTag) { - var selectTag = document.createElement("select"); - var collection = this.options.collection || []; - var optionTag; - collection.each(function(e,i) { - optionTag = document.createElement("option"); - optionTag.value = (e instanceof Array) ? e[0] : e; - if((typeof this.options.value == 'undefined') && - ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true; - if(this.options.value==optionTag.value) optionTag.selected = true; - optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); - selectTag.appendChild(optionTag); - }.bind(this)); - this.cached_selectTag = selectTag; - } - - this.editField = this.cached_selectTag; - if(this.options.loadTextURL) this.loadExternalText(); - this.form.appendChild(this.editField); - this.options.callback = function(form, value) { - return "value=" + encodeURIComponent(value); - } - } -}); - -// Delayed observer, like Form.Element.Observer, -// but waits for delay after last key input -// Ideal for live-search fields - -Form.Element.DelayedObserver = Class.create(); -Form.Element.DelayedObserver.prototype = { - initialize: function(element, delay, callback) { - this.delay = delay || 0.5; - this.element = $(element); - this.callback = callback; - this.timer = null; - this.lastValue = $F(this.element); - Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); - }, - delayedListener: function(event) { - if(this.lastValue == $F(this.element)) return; - if(this.timer) clearTimeout(this.timer); - this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); - this.lastValue = $F(this.element); - }, - onTimerEvent: function() { - this.timer = null; - this.callback(this.element, $F(this.element)); - } -}; diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/dragdrop.js b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/dragdrop.js deleted file mode 100644 index c71ddb82..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/dragdrop.js +++ /dev/null @@ -1,942 +0,0 @@ -// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -if(typeof Effect == 'undefined') - throw("dragdrop.js requires including script.aculo.us' effects.js library"); - -var Droppables = { - drops: [], - - remove: function(element) { - this.drops = this.drops.reject(function(d) { return d.element==$(element) }); - }, - - add: function(element) { - element = $(element); - var options = Object.extend({ - greedy: true, - hoverclass: null, - tree: false - }, arguments[1] || {}); - - // cache containers - if(options.containment) { - options._containers = []; - var containment = options.containment; - if((typeof containment == 'object') && - (containment.constructor == Array)) { - containment.each( function(c) { options._containers.push($(c)) }); - } else { - options._containers.push($(containment)); - } - } - - if(options.accept) options.accept = [options.accept].flatten(); - - Element.makePositioned(element); // fix IE - options.element = element; - - this.drops.push(options); - }, - - findDeepestChild: function(drops) { - deepest = drops[0]; - - for (i = 1; i < drops.length; ++i) - if (Element.isParent(drops[i].element, deepest.element)) - deepest = drops[i]; - - return deepest; - }, - - isContained: function(element, drop) { - var containmentNode; - if(drop.tree) { - containmentNode = element.treeNode; - } else { - containmentNode = element.parentNode; - } - return drop._containers.detect(function(c) { return containmentNode == c }); - }, - - isAffected: function(point, element, drop) { - return ( - (drop.element!=element) && - ((!drop._containers) || - this.isContained(element, drop)) && - ((!drop.accept) || - (Element.classNames(element).detect( - function(v) { return drop.accept.include(v) } ) )) && - Position.within(drop.element, point[0], point[1]) ); - }, - - deactivate: function(drop) { - if(drop.hoverclass) - Element.removeClassName(drop.element, drop.hoverclass); - this.last_active = null; - }, - - activate: function(drop) { - if(drop.hoverclass) - Element.addClassName(drop.element, drop.hoverclass); - this.last_active = drop; - }, - - show: function(point, element) { - if(!this.drops.length) return; - var affected = []; - - if(this.last_active) this.deactivate(this.last_active); - this.drops.each( function(drop) { - if(Droppables.isAffected(point, element, drop)) - affected.push(drop); - }); - - if(affected.length>0) { - drop = Droppables.findDeepestChild(affected); - Position.within(drop.element, point[0], point[1]); - if(drop.onHover) - drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); - - Droppables.activate(drop); - } - }, - - fire: function(event, element) { - if(!this.last_active) return; - Position.prepare(); - - if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) - if (this.last_active.onDrop) - this.last_active.onDrop(element, this.last_active.element, event); - }, - - reset: function() { - if(this.last_active) - this.deactivate(this.last_active); - } -} - -var Draggables = { - drags: [], - observers: [], - - register: function(draggable) { - if(this.drags.length == 0) { - this.eventMouseUp = this.endDrag.bindAsEventListener(this); - this.eventMouseMove = this.updateDrag.bindAsEventListener(this); - this.eventKeypress = this.keyPress.bindAsEventListener(this); - - Event.observe(document, "mouseup", this.eventMouseUp); - Event.observe(document, "mousemove", this.eventMouseMove); - Event.observe(document, "keypress", this.eventKeypress); - } - this.drags.push(draggable); - }, - - unregister: function(draggable) { - this.drags = this.drags.reject(function(d) { return d==draggable }); - if(this.drags.length == 0) { - Event.stopObserving(document, "mouseup", this.eventMouseUp); - Event.stopObserving(document, "mousemove", this.eventMouseMove); - Event.stopObserving(document, "keypress", this.eventKeypress); - } - }, - - activate: function(draggable) { - if(draggable.options.delay) { - this._timeout = setTimeout(function() { - Draggables._timeout = null; - window.focus(); - Draggables.activeDraggable = draggable; - }.bind(this), draggable.options.delay); - } else { - window.focus(); // allows keypress events if window isn't currently focused, fails for Safari - this.activeDraggable = draggable; - } - }, - - deactivate: function() { - this.activeDraggable = null; - }, - - updateDrag: function(event) { - if(!this.activeDraggable) return; - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - // Mozilla-based browsers fire successive mousemove events with - // the same coordinates, prevent needless redrawing (moz bug?) - if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; - this._lastPointer = pointer; - - this.activeDraggable.updateDrag(event, pointer); - }, - - endDrag: function(event) { - if(this._timeout) { - clearTimeout(this._timeout); - this._timeout = null; - } - if(!this.activeDraggable) return; - this._lastPointer = null; - this.activeDraggable.endDrag(event); - this.activeDraggable = null; - }, - - keyPress: function(event) { - if(this.activeDraggable) - this.activeDraggable.keyPress(event); - }, - - addObserver: function(observer) { - this.observers.push(observer); - this._cacheObserverCallbacks(); - }, - - removeObserver: function(element) { // element instead of observer fixes mem leaks - this.observers = this.observers.reject( function(o) { return o.element==element }); - this._cacheObserverCallbacks(); - }, - - notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' - if(this[eventName+'Count'] > 0) - this.observers.each( function(o) { - if(o[eventName]) o[eventName](eventName, draggable, event); - }); - if(draggable.options[eventName]) draggable.options[eventName](draggable, event); - }, - - _cacheObserverCallbacks: function() { - ['onStart','onEnd','onDrag'].each( function(eventName) { - Draggables[eventName+'Count'] = Draggables.observers.select( - function(o) { return o[eventName]; } - ).length; - }); - } -} - -/*--------------------------------------------------------------------------*/ - -var Draggable = Class.create(); -Draggable._dragging = {}; - -Draggable.prototype = { - initialize: function(element) { - var defaults = { - handle: false, - reverteffect: function(element, top_offset, left_offset) { - var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; - new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, - queue: {scope:'_draggable', position:'end'} - }); - }, - endeffect: function(element) { - var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; - new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, - queue: {scope:'_draggable', position:'end'}, - afterFinish: function(){ - Draggable._dragging[element] = false - } - }); - }, - zindex: 1000, - revert: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } - delay: 0 - }; - - if(!arguments[1] || typeof arguments[1].endeffect == 'undefined') - Object.extend(defaults, { - starteffect: function(element) { - element._opacity = Element.getOpacity(element); - Draggable._dragging[element] = true; - new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); - } - }); - - var options = Object.extend(defaults, arguments[1] || {}); - - this.element = $(element); - - if(options.handle && (typeof options.handle == 'string')) - this.handle = this.element.down('.'+options.handle, 0); - - if(!this.handle) this.handle = $(options.handle); - if(!this.handle) this.handle = this.element; - - if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { - options.scroll = $(options.scroll); - this._isScrollChild = Element.childOf(this.element, options.scroll); - } - - Element.makePositioned(this.element); // fix IE - - this.delta = this.currentDelta(); - this.options = options; - this.dragging = false; - - this.eventMouseDown = this.initDrag.bindAsEventListener(this); - Event.observe(this.handle, "mousedown", this.eventMouseDown); - - Draggables.register(this); - }, - - destroy: function() { - Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); - Draggables.unregister(this); - }, - - currentDelta: function() { - return([ - parseInt(Element.getStyle(this.element,'left') || '0'), - parseInt(Element.getStyle(this.element,'top') || '0')]); - }, - - initDrag: function(event) { - if(typeof Draggable._dragging[this.element] != 'undefined' && - Draggable._dragging[this.element]) return; - if(Event.isLeftClick(event)) { - // abort on form elements, fixes a Firefox issue - var src = Event.element(event); - if(src.tagName && ( - src.tagName=='INPUT' || - src.tagName=='SELECT' || - src.tagName=='OPTION' || - src.tagName=='BUTTON' || - src.tagName=='TEXTAREA')) return; - - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var pos = Position.cumulativeOffset(this.element); - this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); - - Draggables.activate(this); - Event.stop(event); - } - }, - - startDrag: function(event) { - this.dragging = true; - - if(this.options.zindex) { - this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); - this.element.style.zIndex = this.options.zindex; - } - - if(this.options.ghosting) { - this._clone = this.element.cloneNode(true); - Position.absolutize(this.element); - this.element.parentNode.insertBefore(this._clone, this.element); - } - - if(this.options.scroll) { - if (this.options.scroll == window) { - var where = this._getWindowScroll(this.options.scroll); - this.originalScrollLeft = where.left; - this.originalScrollTop = where.top; - } else { - this.originalScrollLeft = this.options.scroll.scrollLeft; - this.originalScrollTop = this.options.scroll.scrollTop; - } - } - - Draggables.notify('onStart', this, event); - - if(this.options.starteffect) this.options.starteffect(this.element); - }, - - updateDrag: function(event, pointer) { - if(!this.dragging) this.startDrag(event); - Position.prepare(); - Droppables.show(pointer, this.element); - Draggables.notify('onDrag', this, event); - - this.draw(pointer); - if(this.options.change) this.options.change(this); - - if(this.options.scroll) { - this.stopScrolling(); - - var p; - if (this.options.scroll == window) { - with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } - } else { - p = Position.page(this.options.scroll); - p[0] += this.options.scroll.scrollLeft + Position.deltaX; - p[1] += this.options.scroll.scrollTop + Position.deltaY; - p.push(p[0]+this.options.scroll.offsetWidth); - p.push(p[1]+this.options.scroll.offsetHeight); - } - var speed = [0,0]; - if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity); - if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity); - if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity); - if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); - this.startScrolling(speed); - } - - // fix AppleWebKit rendering - if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); - - Event.stop(event); - }, - - finishDrag: function(event, success) { - this.dragging = false; - - if(this.options.ghosting) { - Position.relativize(this.element); - Element.remove(this._clone); - this._clone = null; - } - - if(success) Droppables.fire(event, this.element); - Draggables.notify('onEnd', this, event); - - var revert = this.options.revert; - if(revert && typeof revert == 'function') revert = revert(this.element); - - var d = this.currentDelta(); - if(revert && this.options.reverteffect) { - this.options.reverteffect(this.element, - d[1]-this.delta[1], d[0]-this.delta[0]); - } else { - this.delta = d; - } - - if(this.options.zindex) - this.element.style.zIndex = this.originalZ; - - if(this.options.endeffect) - this.options.endeffect(this.element); - - Draggables.deactivate(this); - Droppables.reset(); - }, - - keyPress: function(event) { - if(event.keyCode!=Event.KEY_ESC) return; - this.finishDrag(event, false); - Event.stop(event); - }, - - endDrag: function(event) { - if(!this.dragging) return; - this.stopScrolling(); - this.finishDrag(event, true); - Event.stop(event); - }, - - draw: function(point) { - var pos = Position.cumulativeOffset(this.element); - if(this.options.ghosting) { - var r = Position.realOffset(this.element); - pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; - } - - var d = this.currentDelta(); - pos[0] -= d[0]; pos[1] -= d[1]; - - if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { - pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; - pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; - } - - var p = [0,1].map(function(i){ - return (point[i]-pos[i]-this.offset[i]) - }.bind(this)); - - if(this.options.snap) { - if(typeof this.options.snap == 'function') { - p = this.options.snap(p[0],p[1],this); - } else { - if(this.options.snap instanceof Array) { - p = p.map( function(v, i) { - return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this)) - } else { - p = p.map( function(v) { - return Math.round(v/this.options.snap)*this.options.snap }.bind(this)) - } - }} - - var style = this.element.style; - if((!this.options.constraint) || (this.options.constraint=='horizontal')) - style.left = p[0] + "px"; - if((!this.options.constraint) || (this.options.constraint=='vertical')) - style.top = p[1] + "px"; - - if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering - }, - - stopScrolling: function() { - if(this.scrollInterval) { - clearInterval(this.scrollInterval); - this.scrollInterval = null; - Draggables._lastScrollPointer = null; - } - }, - - startScrolling: function(speed) { - if(!(speed[0] || speed[1])) return; - this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; - this.lastScrolled = new Date(); - this.scrollInterval = setInterval(this.scroll.bind(this), 10); - }, - - scroll: function() { - var current = new Date(); - var delta = current - this.lastScrolled; - this.lastScrolled = current; - if(this.options.scroll == window) { - with (this._getWindowScroll(this.options.scroll)) { - if (this.scrollSpeed[0] || this.scrollSpeed[1]) { - var d = delta / 1000; - this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] ); - } - } - } else { - this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; - this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; - } - - Position.prepare(); - Droppables.show(Draggables._lastPointer, this.element); - Draggables.notify('onDrag', this); - if (this._isScrollChild) { - Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); - Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; - Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; - if (Draggables._lastScrollPointer[0] < 0) - Draggables._lastScrollPointer[0] = 0; - if (Draggables._lastScrollPointer[1] < 0) - Draggables._lastScrollPointer[1] = 0; - this.draw(Draggables._lastScrollPointer); - } - - if(this.options.change) this.options.change(this); - }, - - _getWindowScroll: function(w) { - var T, L, W, H; - with (w.document) { - if (w.document.documentElement && documentElement.scrollTop) { - T = documentElement.scrollTop; - L = documentElement.scrollLeft; - } else if (w.document.body) { - T = body.scrollTop; - L = body.scrollLeft; - } - if (w.innerWidth) { - W = w.innerWidth; - H = w.innerHeight; - } else if (w.document.documentElement && documentElement.clientWidth) { - W = documentElement.clientWidth; - H = documentElement.clientHeight; - } else { - W = body.offsetWidth; - H = body.offsetHeight - } - } - return { top: T, left: L, width: W, height: H }; - } -} - -/*--------------------------------------------------------------------------*/ - -var SortableObserver = Class.create(); -SortableObserver.prototype = { - initialize: function(element, observer) { - this.element = $(element); - this.observer = observer; - this.lastValue = Sortable.serialize(this.element); - }, - - onStart: function() { - this.lastValue = Sortable.serialize(this.element); - }, - - onEnd: function() { - Sortable.unmark(); - if(this.lastValue != Sortable.serialize(this.element)) - this.observer(this.element) - } -} - -var Sortable = { - SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, - - sortables: {}, - - _findRootElement: function(element) { - while (element.tagName != "BODY") { - if(element.id && Sortable.sortables[element.id]) return element; - element = element.parentNode; - } - }, - - options: function(element) { - element = Sortable._findRootElement($(element)); - if(!element) return; - return Sortable.sortables[element.id]; - }, - - destroy: function(element){ - var s = Sortable.options(element); - - if(s) { - Draggables.removeObserver(s.element); - s.droppables.each(function(d){ Droppables.remove(d) }); - s.draggables.invoke('destroy'); - - delete Sortable.sortables[s.element.id]; - } - }, - - create: function(element) { - element = $(element); - var options = Object.extend({ - element: element, - tag: 'li', // assumes li children, override with tag: 'tagname' - dropOnEmpty: false, - tree: false, - treeTag: 'ul', - overlap: 'vertical', // one of 'vertical', 'horizontal' - constraint: 'vertical', // one of 'vertical', 'horizontal', false - containment: element, // also takes array of elements (or id's); or false - handle: false, // or a CSS class - only: false, - delay: 0, - hoverclass: null, - ghosting: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - format: this.SERIALIZE_RULE, - onChange: Prototype.emptyFunction, - onUpdate: Prototype.emptyFunction - }, arguments[1] || {}); - - // clear any old sortable with same element - this.destroy(element); - - // build options for the draggables - var options_for_draggable = { - revert: true, - scroll: options.scroll, - scrollSpeed: options.scrollSpeed, - scrollSensitivity: options.scrollSensitivity, - delay: options.delay, - ghosting: options.ghosting, - constraint: options.constraint, - handle: options.handle }; - - if(options.starteffect) - options_for_draggable.starteffect = options.starteffect; - - if(options.reverteffect) - options_for_draggable.reverteffect = options.reverteffect; - else - if(options.ghosting) options_for_draggable.reverteffect = function(element) { - element.style.top = 0; - element.style.left = 0; - }; - - if(options.endeffect) - options_for_draggable.endeffect = options.endeffect; - - if(options.zindex) - options_for_draggable.zindex = options.zindex; - - // build options for the droppables - var options_for_droppable = { - overlap: options.overlap, - containment: options.containment, - tree: options.tree, - hoverclass: options.hoverclass, - onHover: Sortable.onHover - } - - var options_for_tree = { - onHover: Sortable.onEmptyHover, - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass - } - - // fix for gecko engine - Element.cleanWhitespace(element); - - options.draggables = []; - options.droppables = []; - - // drop on empty handling - if(options.dropOnEmpty || options.tree) { - Droppables.add(element, options_for_tree); - options.droppables.push(element); - } - - (this.findElements(element, options) || []).each( function(e) { - // handles are per-draggable - var handle = options.handle ? - $(e).down('.'+options.handle,0) : e; - options.draggables.push( - new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); - Droppables.add(e, options_for_droppable); - if(options.tree) e.treeNode = element; - options.droppables.push(e); - }); - - if(options.tree) { - (Sortable.findTreeElements(element, options) || []).each( function(e) { - Droppables.add(e, options_for_tree); - e.treeNode = element; - options.droppables.push(e); - }); - } - - // keep reference - this.sortables[element.id] = options; - - // for onupdate - Draggables.addObserver(new SortableObserver(element, options.onUpdate)); - - }, - - // return all suitable-for-sortable elements in a guaranteed order - findElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.tag); - }, - - findTreeElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.treeTag); - }, - - onHover: function(element, dropon, overlap) { - if(Element.isParent(dropon, element)) return; - - if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) { - return; - } else if(overlap>0.5) { - Sortable.mark(dropon, 'before'); - if(dropon.previousSibling != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, dropon); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } else { - Sortable.mark(dropon, 'after'); - var nextElement = dropon.nextSibling || null; - if(nextElement != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, nextElement); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } - }, - - onEmptyHover: function(element, dropon, overlap) { - var oldParentNode = element.parentNode; - var droponOptions = Sortable.options(dropon); - - if(!Element.isParent(dropon, element)) { - var index; - - var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); - var child = null; - - if(children) { - var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); - - for (index = 0; index < children.length; index += 1) { - if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) { - offset -= Element.offsetSize (children[index], droponOptions.overlap); - } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { - child = index + 1 < children.length ? children[index + 1] : null; - break; - } else { - child = children[index]; - break; - } - } - } - - dropon.insertBefore(element, child); - - Sortable.options(oldParentNode).onChange(element); - droponOptions.onChange(element); - } - }, - - unmark: function() { - if(Sortable._marker) Sortable._marker.hide(); - }, - - mark: function(dropon, position) { - // mark on ghosting only - var sortable = Sortable.options(dropon.parentNode); - if(sortable && !sortable.ghosting) return; - - if(!Sortable._marker) { - Sortable._marker = - ($('dropmarker') || Element.extend(document.createElement('DIV'))). - hide().addClassName('dropmarker').setStyle({position:'absolute'}); - document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); - } - var offsets = Position.cumulativeOffset(dropon); - Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); - - if(position=='after') - if(sortable.overlap == 'horizontal') - Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); - else - Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); - - Sortable._marker.show(); - }, - - _tree: function(element, options, parent) { - var children = Sortable.findElements(element, options) || []; - - for (var i = 0; i < children.length; ++i) { - var match = children[i].id.match(options.format); - - if (!match) continue; - - var child = { - id: encodeURIComponent(match ? match[1] : null), - element: element, - parent: parent, - children: [], - position: parent.children.length, - container: $(children[i]).down(options.treeTag) - } - - /* Get the element containing the children and recurse over it */ - if (child.container) - this._tree(child.container, options, child) - - parent.children.push (child); - } - - return parent; - }, - - tree: function(element) { - element = $(element); - var sortableOptions = this.options(element); - var options = Object.extend({ - tag: sortableOptions.tag, - treeTag: sortableOptions.treeTag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format - }, arguments[1] || {}); - - var root = { - id: null, - parent: null, - children: [], - container: element, - position: 0 - } - - return Sortable._tree(element, options, root); - }, - - /* Construct a [i] index for a particular node */ - _constructIndex: function(node) { - var index = ''; - do { - if (node.id) index = '[' + node.position + ']' + index; - } while ((node = node.parent) != null); - return index; - }, - - sequence: function(element) { - element = $(element); - var options = Object.extend(this.options(element), arguments[1] || {}); - - return $(this.findElements(element, options) || []).map( function(item) { - return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; - }); - }, - - setSequence: function(element, new_sequence) { - element = $(element); - var options = Object.extend(this.options(element), arguments[2] || {}); - - var nodeMap = {}; - this.findElements(element, options).each( function(n) { - if (n.id.match(options.format)) - nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; - n.parentNode.removeChild(n); - }); - - new_sequence.each(function(ident) { - var n = nodeMap[ident]; - if (n) { - n[1].appendChild(n[0]); - delete nodeMap[ident]; - } - }); - }, - - serialize: function(element) { - element = $(element); - var options = Object.extend(Sortable.options(element), arguments[1] || {}); - var name = encodeURIComponent( - (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); - - if (options.tree) { - return Sortable.tree(element, arguments[1]).children.map( function (item) { - return [name + Sortable._constructIndex(item) + "[id]=" + - encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); - }).flatten().join('&'); - } else { - return Sortable.sequence(element, arguments[1]).map( function(item) { - return name + "[]=" + encodeURIComponent(item); - }).join('&'); - } - } -} - -// Returns true if child is contained within element -Element.isParent = function(child, element) { - if (!child.parentNode || child == element) return false; - if (child.parentNode == element) return true; - return Element.isParent(child.parentNode, element); -} - -Element.findChildren = function(element, only, recursive, tagName) { - if(!element.hasChildNodes()) return null; - tagName = tagName.toUpperCase(); - if(only) only = [only].flatten(); - var elements = []; - $A(element.childNodes).each( function(e) { - if(e.tagName && e.tagName.toUpperCase()==tagName && - (!only || (Element.classNames(e).detect(function(v) { return only.include(v) })))) - elements.push(e); - if(recursive) { - var grandchildren = Element.findChildren(e, only, recursive, tagName); - if(grandchildren) elements.push(grandchildren); - } - }); - - return (elements.length>0 ? elements.flatten() : []); -} - -Element.offsetSize = function (element, type) { - return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; -} diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/effects.js b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/effects.js deleted file mode 100644 index 3b02eda2..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/effects.js +++ /dev/null @@ -1,1088 +0,0 @@ -// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// Contributors: -// Justin Palmer (http://encytemedia.com/) -// Mark Pilgrim (http://diveintomark.org/) -// Martin Bialasinki -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -// converts rgb() and #xxx to #xxxxxx format, -// returns self (or first argument) if not convertable -String.prototype.parseColor = function() { - var color = '#'; - if(this.slice(0,4) == 'rgb(') { - var cols = this.slice(4,this.length-1).split(','); - var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); - } else { - if(this.slice(0,1) == '#') { - if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); - if(this.length==7) color = this.toLowerCase(); - } - } - return(color.length==7 ? color : (arguments[0] || this)); -} - -/*--------------------------------------------------------------------------*/ - -Element.collectTextNodes = function(element) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); - }).flatten().join(''); -} - -Element.collectTextNodesIgnoreClass = function(element, className) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? - Element.collectTextNodesIgnoreClass(node, className) : '')); - }).flatten().join(''); -} - -Element.setContentZoom = function(element, percent) { - element = $(element); - element.setStyle({fontSize: (percent/100) + 'em'}); - if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); - return element; -} - -Element.getOpacity = function(element){ - element = $(element); - var opacity; - if (opacity = element.getStyle('opacity')) - return parseFloat(opacity); - if (opacity = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if(opacity[1]) return parseFloat(opacity[1]) / 100; - return 1.0; -} - -Element.setOpacity = function(element, value){ - element= $(element); - if (value == 1){ - element.setStyle({ opacity: - (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? - 0.999999 : 1.0 }); - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.setStyle({filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); - } else { - if(value < 0.00001) value = 0; - element.setStyle({opacity: value}); - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.setStyle( - { filter: element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') + - 'alpha(opacity='+value*100+')' }); - } - return element; -} - -Element.getInlineOpacity = function(element){ - return $(element).style.opacity || ''; -} - -Element.forceRerendering = function(element) { - try { - element = $(element); - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch(e) { } -}; - -/*--------------------------------------------------------------------------*/ - -Array.prototype.call = function() { - var args = arguments; - this.each(function(f){ f.apply(this, args) }); -} - -/*--------------------------------------------------------------------------*/ - -var Effect = { - _elementDoesNotExistError: { - name: 'ElementDoesNotExistError', - message: 'The specified DOM element does not exist, but is required for this effect to operate' - }, - tagifyText: function(element) { - if(typeof Builder == 'undefined') - throw("Effect.tagifyText requires including script.aculo.us' builder.js library"); - - var tagifyStyle = 'position:relative'; - if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1'; - - element = $(element); - $A(element.childNodes).each( function(child) { - if(child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - Builder.node('span',{style: tagifyStyle}, - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if(((typeof element == 'object') || - (typeof element == 'function')) && - (element.length)) - elements = element; - else - elements = $(element).childNodes; - - var options = Object.extend({ - speed: 0.1, - delay: 0.0 - }, arguments[2] || {}); - var masterDelay = options.delay; - - $A(elements).each( function(element, index) { - new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); - }); - }, - PAIRS: { - 'slide': ['SlideDown','SlideUp'], - 'blind': ['BlindDown','BlindUp'], - 'appear': ['Appear','Fade'] - }, - toggle: function(element, effect) { - element = $(element); - effect = (effect || 'appear').toLowerCase(); - var options = Object.extend({ - queue: { position:'end', scope:(element.id || 'global'), limit: 1 } - }, arguments[2] || {}); - Effect[element.visible() ? - Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); - } -}; - -var Effect2 = Effect; // deprecated - -/* ------------- transitions ------------- */ - -Effect.Transitions = { - linear: Prototype.K, - sinoidal: function(pos) { - return (-Math.cos(pos*Math.PI)/2) + 0.5; - }, - reverse: function(pos) { - return 1-pos; - }, - flicker: function(pos) { - return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; - }, - wobble: function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; - }, - pulse: function(pos, pulses) { - pulses = pulses || 5; - return ( - Math.round((pos % (1/pulses)) * pulses) == 0 ? - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : - 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) - ); - }, - none: function(pos) { - return 0; - }, - full: function(pos) { - return 1; - } -}; - -/* ------------- core effects ------------- */ - -Effect.ScopedQueue = Class.create(); -Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), { - initialize: function() { - this.effects = []; - this.interval = null; - }, - _each: function(iterator) { - this.effects._each(iterator); - }, - add: function(effect) { - var timestamp = new Date().getTime(); - - var position = (typeof effect.options.queue == 'string') ? - effect.options.queue : effect.options.queue.position; - - switch(position) { - case 'front': - // move unstarted effects after this effect - this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - }); - break; - case 'with-last': - timestamp = this.effects.pluck('startOn').max() || timestamp; - break; - case 'end': - // start effect after last queued effect has finished - timestamp = this.effects.pluck('finishOn').max() || timestamp; - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - - if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) - this.effects.push(effect); - - if(!this.interval) - this.interval = setInterval(this.loop.bind(this), 40); - }, - remove: function(effect) { - this.effects = this.effects.reject(function(e) { return e==effect }); - if(this.effects.length == 0) { - clearInterval(this.interval); - this.interval = null; - } - }, - loop: function() { - var timePos = new Date().getTime(); - this.effects.invoke('loop', timePos); - } -}); - -Effect.Queues = { - instances: $H(), - get: function(queueName) { - if(typeof queueName != 'string') return queueName; - - if(!this.instances[queueName]) - this.instances[queueName] = new Effect.ScopedQueue(); - - return this.instances[queueName]; - } -} -Effect.Queue = Effect.Queues.get('global'); - -Effect.DefaultOptions = { - transition: Effect.Transitions.sinoidal, - duration: 1.0, // seconds - fps: 25.0, // max. 25fps due to Effect.Queue implementation - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' -} - -Effect.Base = function() {}; -Effect.Base.prototype = { - position: null, - start: function(options) { - this.options = Object.extend(Object.extend({},Effect.DefaultOptions), options || {}); - this.currentFrame = 0; - this.state = 'idle'; - this.startOn = this.options.delay*1000; - this.finishOn = this.startOn + (this.options.duration*1000); - this.event('beforeStart'); - if(!this.options.sync) - Effect.Queues.get(typeof this.options.queue == 'string' ? - 'global' : this.options.queue.scope).add(this); - }, - loop: function(timePos) { - if(timePos >= this.startOn) { - if(timePos >= this.finishOn) { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - if(this.finish) this.finish(); - this.event('afterFinish'); - return; - } - var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); - var frame = Math.round(pos * this.options.fps * this.options.duration); - if(frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - render: function(pos) { - if(this.state == 'idle') { - this.state = 'running'; - this.event('beforeSetup'); - if(this.setup) this.setup(); - this.event('afterSetup'); - } - if(this.state == 'running') { - if(this.options.transition) pos = this.options.transition(pos); - pos *= (this.options.to-this.options.from); - pos += this.options.from; - this.position = pos; - this.event('beforeUpdate'); - if(this.update) this.update(pos); - this.event('afterUpdate'); - } - }, - cancel: function() { - if(!this.options.sync) - Effect.Queues.get(typeof this.options.queue == 'string' ? - 'global' : this.options.queue.scope).remove(this); - this.state = 'finished'; - }, - event: function(eventName) { - if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); - if(this.options[eventName]) this.options[eventName](this); - }, - inspect: function() { - return '#'; - } -} - -Effect.Parallel = Class.create(); -Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), { - initialize: function(effects) { - this.effects = effects || []; - this.start(arguments[1]); - }, - update: function(position) { - this.effects.invoke('render', position); - }, - finish: function(position) { - this.effects.each( function(effect) { - effect.render(1.0); - effect.cancel(); - effect.event('beforeFinish'); - if(effect.finish) effect.finish(position); - effect.event('afterFinish'); - }); - } -}); - -Effect.Event = Class.create(); -Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), { - initialize: function() { - var options = Object.extend({ - duration: 0 - }, arguments[0] || {}); - this.start(options); - }, - update: Prototype.emptyFunction -}); - -Effect.Opacity = Class.create(); -Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - if(!this.element) throw(Effect._elementDoesNotExistError); - // make this work on IE on elements without 'layout' - if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - var options = Object.extend({ - from: this.element.getOpacity() || 0.0, - to: 1.0 - }, arguments[1] || {}); - this.start(options); - }, - update: function(position) { - this.element.setOpacity(position); - } -}); - -Effect.Move = Class.create(); -Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - if(!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - x: 0, - y: 0, - mode: 'relative' - }, arguments[1] || {}); - this.start(options); - }, - setup: function() { - // Bug in Opera: Opera returns the "real" position of a static element or - // relative element that does not have top/left explicitly set. - // ==> Always set top and left for position relative elements in your stylesheets - // (to 0 if you do not need them) - this.element.makePositioned(); - this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); - this.originalTop = parseFloat(this.element.getStyle('top') || '0'); - if(this.options.mode == 'absolute') { - // absolute movement, so we need to calc deltaX and deltaY - this.options.x = this.options.x - this.originalLeft; - this.options.y = this.options.y - this.originalTop; - } - }, - update: function(position) { - this.element.setStyle({ - left: Math.round(this.options.x * position + this.originalLeft) + 'px', - top: Math.round(this.options.y * position + this.originalTop) + 'px' - }); - } -}); - -// for backwards compatibility -Effect.MoveBy = function(element, toTop, toLeft) { - return new Effect.Move(element, - Object.extend({ x: toLeft, y: toTop }, arguments[3] || {})); -}; - -Effect.Scale = Class.create(); -Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { - initialize: function(element, percent) { - this.element = $(element); - if(!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or {} with provided values - scaleFrom: 100.0, - scaleTo: percent - }, arguments[2] || {}); - this.start(options); - }, - setup: function() { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = this.element.getStyle('position'); - - this.originalStyle = {}; - ['top','left','width','height','fontSize'].each( function(k) { - this.originalStyle[k] = this.element.style[k]; - }.bind(this)); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = this.element.getStyle('font-size') || '100%'; - ['em','px','%','pt'].each( function(fontSizeType) { - if(fontSize.indexOf(fontSizeType)>0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }.bind(this)); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - this.dims = null; - if(this.options.scaleMode=='box') - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - if(/^content/.test(this.options.scaleMode)) - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - if(!this.dims) - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - }, - update: function(position) { - var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); - if(this.options.scaleContent && this.fontSize) - this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType }); - this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); - }, - finish: function(position) { - if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle); - }, - setDimensions: function(height, width) { - var d = {}; - if(this.options.scaleX) d.width = Math.round(width) + 'px'; - if(this.options.scaleY) d.height = Math.round(height) + 'px'; - if(this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if(this.elementPositioning == 'absolute') { - if(this.options.scaleY) d.top = this.originalTop-topd + 'px'; - if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; - } else { - if(this.options.scaleY) d.top = -topd + 'px'; - if(this.options.scaleX) d.left = -leftd + 'px'; - } - } - this.element.setStyle(d); - } -}); - -Effect.Highlight = Class.create(); -Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - if(!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); - this.start(options); - }, - setup: function() { - // Prevent executing on elements not in the layout flow - if(this.element.getStyle('display')=='none') { this.cancel(); return; } - // Disable background image during the effect - this.oldStyle = { - backgroundImage: this.element.getStyle('background-image') }; - this.element.setStyle({backgroundImage: 'none'}); - if(!this.options.endcolor) - this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); - if(!this.options.restorecolor) - this.options.restorecolor = this.element.getStyle('background-color'); - // init color calculations - this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); - this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); - }, - update: function(position) { - this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){ - return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) }); - }, - finish: function() { - this.element.setStyle(Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = Class.create(); -Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - this.start(arguments[1] || {}); - }, - setup: function() { - Position.prepare(); - var offsets = Position.cumulativeOffset(this.element); - if(this.options.offset) offsets[1] += this.options.offset; - var max = window.innerHeight ? - window.height - window.innerHeight : - document.body.scrollHeight - - (document.documentElement.clientHeight ? - document.documentElement.clientHeight : document.body.clientHeight); - this.scrollStart = Position.deltaY; - this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart; - }, - update: function(position) { - Position.prepare(); - window.scrollTo(Position.deltaX, - this.scrollStart + (position*this.delta)); - } -}); - -/* ------------- combination effects ------------- */ - -Effect.Fade = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - var options = Object.extend({ - from: element.getOpacity() || 1.0, - to: 0.0, - afterFinishInternal: function(effect) { - if(effect.options.to!=0) return; - effect.element.hide().setStyle({opacity: oldOpacity}); - }}, arguments[1] || {}); - return new Effect.Opacity(element,options); -} - -Effect.Appear = function(element) { - element = $(element); - var options = Object.extend({ - from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0), - to: 1.0, - // force Safari to render floated elements properly - afterFinishInternal: function(effect) { - effect.element.forceRerendering(); - }, - beforeSetup: function(effect) { - effect.element.setOpacity(effect.options.from).show(); - }}, arguments[1] || {}); - return new Effect.Opacity(element,options); -} - -Effect.Puff = function(element) { - element = $(element); - var oldStyle = { - opacity: element.getInlineOpacity(), - position: element.getStyle('position'), - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height - }; - return new Effect.Parallel( - [ new Effect.Scale(element, 200, - { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], - Object.extend({ duration: 1.0, - beforeSetupInternal: function(effect) { - Position.absolutize(effect.effects[0].element) - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().setStyle(oldStyle); } - }, arguments[1] || {}) - ); -} - -Effect.BlindUp = function(element) { - element = $(element); - element.makeClipping(); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }, arguments[1] || {}) - ); -} - -Effect.BlindDown = function(element) { - element = $(element); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping(); - } - }, arguments[1] || {})); -} - -Effect.SwitchOff = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - return new Effect.Appear(element, Object.extend({ - duration: 0.4, - from: 0, - transition: Effect.Transitions.flicker, - afterFinishInternal: function(effect) { - new Effect.Scale(effect.element, 1, { - duration: 0.3, scaleFromCenter: true, - scaleX: false, scaleContent: false, restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); - } - }) - } - }, arguments[1] || {})); -} - -Effect.DropOut = function(element) { - element = $(element); - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left'), - opacity: element.getInlineOpacity() }; - return new Effect.Parallel( - [ new Effect.Move(element, {x: 0, y: 100, sync: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 }) ], - Object.extend( - { duration: 0.5, - beforeSetup: function(effect) { - effect.effects[0].element.makePositioned(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); - } - }, arguments[1] || {})); -} - -Effect.Shake = function(element) { - element = $(element); - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left') }; - return new Effect.Move(element, - { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { - effect.element.undoPositioned().setStyle(oldStyle); - }}) }}) }}) }}) }}) }}); -} - -Effect.SlideDown = function(element) { - element = $(element).cleanWhitespace(); - // SlideDown need to have the content of the element wrapped in a container element with fixed height! - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: window.opera ? 0 : 1, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if(window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } - }, arguments[1] || {}) - ); -} - -Effect.SlideUp = function(element) { - element = $(element).cleanWhitespace(); - var oldInnerBottom = element.down().getStyle('bottom'); - return new Effect.Scale(element, window.opera ? 0 : 1, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - restoreAfterFinish: true, - beforeStartInternal: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if(window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom}); - effect.element.down().undoPositioned(); - } - }, arguments[1] || {}) - ); -} - -// Bug in opera makes the TD containing this element expand for a instance after finish -Effect.Squish = function(element) { - return new Effect.Scale(element, window.opera ? 1 : 0, { - restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }); -} - -Effect.Grow = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.full - }, arguments[1] || {}); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.width; - initialMoveY = moveY = 0; - moveX = -dims.width; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.height; - moveY = -dims.height; - break; - case 'bottom-right': - initialMoveX = dims.width; - initialMoveY = dims.height; - moveX = -dims.width; - moveY = -dims.height; - break; - case 'center': - initialMoveX = dims.width / 2; - initialMoveY = dims.height / 2; - moveX = -dims.width / 2; - moveY = -dims.height / 2; - break; - } - - return new Effect.Move(element, { - x: initialMoveX, - y: initialMoveY, - duration: 0.01, - beforeSetup: function(effect) { - effect.element.hide().makeClipping().makePositioned(); - }, - afterFinishInternal: function(effect) { - new Effect.Parallel( - [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), - new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), - new Effect.Scale(effect.element, 100, { - scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, - sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) - ], Object.extend({ - beforeSetup: function(effect) { - effect.effects[0].element.setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); - } - }, options) - ) - } - }); -} - -Effect.Shrink = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.none - }, arguments[1] || {}); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.width; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.height; - break; - case 'bottom-right': - moveX = dims.width; - moveY = dims.height; - break; - case 'center': - moveX = dims.width / 2; - moveY = dims.height / 2; - break; - } - - return new Effect.Parallel( - [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), - new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), - new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) - ], Object.extend({ - beforeStartInternal: function(effect) { - effect.effects[0].element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } - }, options) - ); -} - -Effect.Pulsate = function(element) { - element = $(element); - var options = arguments[1] || {}; - var oldOpacity = element.getInlineOpacity(); - var transition = options.transition || Effect.Transitions.sinoidal; - var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) }; - reverser.bind(transition); - return new Effect.Opacity(element, - Object.extend(Object.extend({ duration: 2.0, from: 0, - afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } - }, options), {transition: reverser})); -} - -Effect.Fold = function(element) { - element = $(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height }; - element.makeClipping(); - return new Effect.Scale(element, 5, Object.extend({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function(effect) { - new Effect.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().setStyle(oldStyle); - } }); - }}, arguments[1] || {})); -}; - -Effect.Morph = Class.create(); -Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - if(!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - style: '' - }, arguments[1] || {}); - this.start(options); - }, - setup: function(){ - function parseColor(color){ - if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; - color = color.parseColor(); - return $R(0,2).map(function(i){ - return parseInt( color.slice(i*2+1,i*2+3), 16 ) - }); - } - this.transforms = this.options.style.parseStyle().map(function(property){ - var originalValue = this.element.getStyle(property[0]); - return $H({ - style: property[0], - originalValue: property[1].unit=='color' ? - parseColor(originalValue) : parseFloat(originalValue || 0), - targetValue: property[1].unit=='color' ? - parseColor(property[1].value) : property[1].value, - unit: property[1].unit - }); - }.bind(this)).reject(function(transform){ - return ( - (transform.originalValue == transform.targetValue) || - ( - transform.unit != 'color' && - (isNaN(transform.originalValue) || isNaN(transform.targetValue)) - ) - ) - }); - }, - update: function(position) { - var style = $H(), value = null; - this.transforms.each(function(transform){ - value = transform.unit=='color' ? - $R(0,2).inject('#',function(m,v,i){ - return m+(Math.round(transform.originalValue[i]+ - (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) : - transform.originalValue + Math.round( - ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit; - style[transform.style] = value; - }); - this.element.setStyle(style); - } -}); - -Effect.Transform = Class.create(); -Object.extend(Effect.Transform.prototype, { - initialize: function(tracks){ - this.tracks = []; - this.options = arguments[1] || {}; - this.addTracks(tracks); - }, - addTracks: function(tracks){ - tracks.each(function(track){ - var data = $H(track).values().first(); - this.tracks.push($H({ - ids: $H(track).keys().first(), - effect: Effect.Morph, - options: { style: data } - })); - }.bind(this)); - return this; - }, - play: function(){ - return new Effect.Parallel( - this.tracks.map(function(track){ - var elements = [$(track.ids) || $$(track.ids)].flatten(); - return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) }); - }).flatten(), - this.options - ); - } -}); - -Element.CSS_PROPERTIES = ['azimuth', 'backgroundAttachment', 'backgroundColor', 'backgroundImage', - 'backgroundPosition', 'backgroundRepeat', 'borderBottomColor', 'borderBottomStyle', - 'borderBottomWidth', 'borderCollapse', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', - 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderSpacing', 'borderTopColor', - 'borderTopStyle', 'borderTopWidth', 'bottom', 'captionSide', 'clear', 'clip', 'color', 'content', - 'counterIncrement', 'counterReset', 'cssFloat', 'cueAfter', 'cueBefore', 'cursor', 'direction', - 'display', 'elevation', 'emptyCells', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', - 'fontStyle', 'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight', - 'listStyleImage', 'listStylePosition', 'listStyleType', 'marginBottom', 'marginLeft', 'marginRight', - 'marginTop', 'markerOffset', 'marks', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'opacity', - 'orphans', 'outlineColor', 'outlineOffset', 'outlineStyle', 'outlineWidth', 'overflowX', 'overflowY', - 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'page', 'pageBreakAfter', 'pageBreakBefore', - 'pageBreakInside', 'pauseAfter', 'pauseBefore', 'pitch', 'pitchRange', 'position', 'quotes', - 'richness', 'right', 'size', 'speakHeader', 'speakNumeral', 'speakPunctuation', 'speechRate', 'stress', - 'tableLayout', 'textAlign', 'textDecoration', 'textIndent', 'textShadow', 'textTransform', 'top', - 'unicodeBidi', 'verticalAlign', 'visibility', 'voiceFamily', 'volume', 'whiteSpace', 'widows', - 'width', 'wordSpacing', 'zIndex']; - -Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -String.prototype.parseStyle = function(){ - var element = Element.extend(document.createElement('div')); - element.innerHTML = '

    '; - var style = element.down().style, styleRules = $H(); - - Element.CSS_PROPERTIES.each(function(property){ - if(style[property]) styleRules[property] = style[property]; - }); - - var result = $H(); - - styleRules.each(function(pair){ - var property = pair[0], value = pair[1], unit = null; - - if(value.parseColor('#zzzzzz') != '#zzzzzz') { - value = value.parseColor(); - unit = 'color'; - } else if(Element.CSS_LENGTH.test(value)) - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/), - value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null; - - result[property.underscore().dasherize()] = $H({ value:value, unit:unit }); - }.bind(this)); - - return result; -}; - -Element.morph = function(element, style) { - new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {})); - return element; -}; - -['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom', - 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each( - function(f) { Element.Methods[f] = Element[f]; } -); - -Element.Methods.visualEffect = function(element, effect, options) { - s = effect.gsub(/_/, '-').camelize(); - effect_class = s.charAt(0).toUpperCase() + s.substring(1); - new Effect[effect_class](element, options); - return $(element); -}; - -Element.addMethods(); \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/prototype.js b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/prototype.js deleted file mode 100644 index 50582217..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/javascripts/prototype.js +++ /dev/null @@ -1,2515 +0,0 @@ -/* Prototype JavaScript framework, version 1.5.0 - * (c) 2005-2007 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://prototype.conio.net/ - * -/*--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.5.0', - BrowserFeatures: { - XPath: !!document.evaluate - }, - - ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)', - emptyFunction: function() {}, - K: function(x) { return x } -} - -var Class = { - create: function() { - return function() { - this.initialize.apply(this, arguments); - } - } -} - -var Abstract = new Object(); - -Object.extend = function(destination, source) { - for (var property in source) { - destination[property] = source[property]; - } - return destination; -} - -Object.extend(Object, { - inspect: function(object) { - try { - if (object === undefined) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : object.toString(); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({}, object); - } -}); - -Function.prototype.bind = function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } -} - -Function.prototype.bindAsEventListener = function(object) { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); - } -} - -Object.extend(Number.prototype, { - toColorPart: function() { - var digits = this.toString(16); - if (this < 16) return '0' + digits; - return digits; - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator) { - $R(0, this, true).each(iterator); - return this; - } -}); - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) {} - } - - return returnValue; - } -} - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create(); -PeriodicalExecuter.prototype = { - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.callback(this); - } finally { - this.currentlyExecuting = false; - } - } - } -} -String.interpret = function(value){ - return value == null ? '' : String(value); -} - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = count === undefined ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return this; - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = truncation === undefined ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : this; - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var div = document.createElement('div'); - var text = document.createTextNode(this); - div.appendChild(text); - return div.innerHTML; - }, - - unescapeHTML: function() { - var div = document.createElement('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return {}; - - return match[1].split(separator || '&').inject({}, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var name = decodeURIComponent(pair[0]); - var value = pair[1] ? decodeURIComponent(pair[1]) : undefined; - - if (hash[name] !== undefined) { - if (hash[name].constructor != Array) - hash[name] = [hash[name]]; - if (value) hash[name].push(value); - } - else hash[name] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function(){ - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.replace(/\\/g, '\\\\'); - if (useDoubleQuotes) - return '"' + escapedString.replace(/"/g, '\\"') + '"'; - else - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (typeof replacement == 'function') return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -} - -String.prototype.parseQuery = String.prototype.toQueryParams; - -var Template = Class.create(); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; -Template.prototype = { - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - return this.template.gsub(this.pattern, function(match) { - var before = match[1]; - if (before == '\\') return match[2]; - return before + String.interpret(object[match[3]]); - }); - } -} - -var $break = new Object(); -var $continue = new Object(); - -var Enumerable = { - each: function(iterator) { - var index = 0; - try { - this._each(function(value) { - try { - iterator(value, index++); - } catch (e) { - if (e != $continue) throw e; - } - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator) { - var index = -number, slices = [], array = this.toArray(); - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.map(iterator); - }, - - all: function(iterator) { - var result = true; - this.each(function(value, index) { - result = result && !!(iterator || Prototype.K)(value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator) { - var result = false; - this.each(function(value, index) { - if (result = !!(iterator || Prototype.K)(value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator) { - var results = []; - this.each(function(value, index) { - results.push((iterator || Prototype.K)(value, index)); - }); - return results; - }, - - detect: function(iterator) { - var result; - this.each(function(value, index) { - if (iterator(value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator) { - var results = []; - this.each(function(value, index) { - if (iterator(value, index)) - results.push(value); - }); - return results; - }, - - grep: function(pattern, iterator) { - var results = []; - this.each(function(value, index) { - var stringValue = value.toString(); - if (stringValue.match(pattern)) - results.push((iterator || Prototype.K)(value, index)); - }) - return results; - }, - - include: function(object) { - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = fillWith === undefined ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator) { - this.each(function(value, index) { - memo = iterator(memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator) { - var result; - this.each(function(value, index) { - value = (iterator || Prototype.K)(value, index); - if (result == undefined || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator) { - var result; - this.each(function(value, index) { - value = (iterator || Prototype.K)(value, index); - if (result == undefined || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator) { - var trues = [], falses = []; - this.each(function(value, index) { - ((iterator || Prototype.K)(value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value, index) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator) { - var results = []; - this.each(function(value, index) { - if (!iterator(value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator) { - return this.map(function(value, index) { - return {value: value, criteria: iterator(value, index)}; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (typeof args.last() == 'function') - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#'; - } -} - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray -}); -var $A = Array.from = function(iterable) { - if (!iterable) return []; - if (iterable.toArray) { - return iterable.toArray(); - } else { - var results = []; - for (var i = 0, length = iterable.length; i < length; i++) - results.push(iterable[i]); - return results; - } -} - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) - Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(value && value.constructor == Array ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - indexOf: function(object) { - for (var i = 0, length = this.length; i < length; i++) - if (this[i] == object) return i; - return -1; - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function() { - return this.inject([], function(array, value) { - return array.include(value) ? array : array.concat([value]); - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - } -}); - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string){ - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if(window.opera){ - Array.prototype.concat = function(){ - var array = []; - for(var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for(var i = 0, length = arguments.length; i < length; i++) { - if(arguments[i].constructor == Array) { - for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - } -} -var Hash = function(obj) { - Object.extend(this, obj || {}); -}; - -Object.extend(Hash, { - toQueryString: function(obj) { - var parts = []; - - this.prototype._each.call(obj, function(pair) { - if (!pair.key) return; - - if (pair.value && pair.value.constructor == Array) { - var values = pair.value.compact(); - if (values.length < 2) pair.value = values.reduce(); - else { - key = encodeURIComponent(pair.key); - values.each(function(value) { - value = value != undefined ? encodeURIComponent(value) : ''; - parts.push(key + '=' + encodeURIComponent(value)); - }); - return; - } - } - if (pair.value == undefined) pair[1] = ''; - parts.push(pair.map(encodeURIComponent).join('=')); - }); - - return parts.join('&'); - } -}); - -Object.extend(Hash.prototype, Enumerable); -Object.extend(Hash.prototype, { - _each: function(iterator) { - for (var key in this) { - var value = this[key]; - if (value && value == Hash.prototype[key]) continue; - - var pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - merge: function(hash) { - return $H(hash).inject(this, function(mergedHash, pair) { - mergedHash[pair.key] = pair.value; - return mergedHash; - }); - }, - - remove: function() { - var result; - for(var i = 0, length = arguments.length; i < length; i++) { - var value = this[arguments[i]]; - if (value !== undefined){ - if (result === undefined) result = value; - else { - if (result.constructor != Array) result = [result]; - result.push(value) - } - } - delete this[arguments[i]]; - } - return result; - }, - - toQueryString: function() { - return Hash.toQueryString(this); - }, - - inspect: function() { - return '#'; - } -}); - -function $H(object) { - if (object && object.constructor == Hash) return object; - return new Hash(object); -}; -ObjectRange = Class.create(); -Object.extend(ObjectRange.prototype, Enumerable); -Object.extend(ObjectRange.prototype, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -} - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -} - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (typeof responder[callback] == 'function') { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) {} - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { - Ajax.activeRequestCount++; - }, - onComplete: function() { - Ajax.activeRequestCount--; - } -}); - -Ajax.Base = function() {}; -Ajax.Base.prototype = { - setOptions: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '' - } - Object.extend(this.options, options || {}); - - this.options.method = this.options.method.toLowerCase(); - if (typeof this.options.parameters == 'string') - this.options.parameters = this.options.parameters.toQueryParams(); - } -} - -Ajax.Request = Class.create(); -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Request.prototype = Object.extend(new Ajax.Base(), { - _complete: false, - - initialize: function(url, options) { - this.transport = Ajax.getTransport(); - this.setOptions(options); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = this.options.parameters; - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - params = Hash.toQueryString(params); - if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=' - - // when GET, append parameters to URL - if (this.method == 'get' && params) - this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params; - - try { - Ajax.Responders.dispatch('onCreate', this, this.transport); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) - setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - var body = this.method == 'post' ? (this.options.postBody || params) : null; - - this.transport.send(body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (typeof extras.push == 'function') - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - return !this.transport.status - || (this.transport.status >= 200 && this.transport.status < 300); - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState]; - var transport = this.transport, json = this.evalJSON(); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + this.transport.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(transport, json); - } catch (e) { - this.dispatchException(e); - } - - if ((this.getHeader('Content-type') || 'text/javascript').strip(). - match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(transport, json); - Ajax.Responders.dispatch('on' + state, this, transport, json); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name); - } catch (e) { return null } - }, - - evalJSON: function() { - try { - var json = this.getHeader('X-JSON'); - return json ? eval('(' + json + ')') : null; - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval(this.transport.responseText); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Updater = Class.create(); - -Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { - initialize: function(container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - } - - this.transport = Ajax.getTransport(); - this.setOptions(options); - - var onComplete = this.options.onComplete || Prototype.emptyFunction; - this.options.onComplete = (function(transport, param) { - this.updateContent(); - onComplete(transport, param); - }).bind(this); - - this.request(url); - }, - - updateContent: function() { - var receiver = this.container[this.success() ? 'success' : 'failure']; - var response = this.transport.responseText; - - if (!this.options.evalScripts) response = response.stripScripts(); - - if (receiver = $(receiver)) { - if (this.options.insertion) - new this.options.insertion(receiver, response); - else - receiver.update(response); - } - - if (this.success()) { - if (this.onComplete) - setTimeout(this.onComplete.bind(this), 10); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(); -Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { - initialize: function(container, url, options) { - this.setOptions(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = {}; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(request) { - if (this.options.decay) { - this.decay = (request.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = request.responseText; - } - this.timer = setTimeout(this.onTimerEvent.bind(this), - this.decay * this.frequency * 1000); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (typeof element == 'string') - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(query.snapshotItem(i)); - return results; - }; -} - -document.getElementsByClassName = function(className, parentElement) { - if (Prototype.BrowserFeatures.XPath) { - var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; - return document._getElementsByXPath(q, parentElement); - } else { - var children = ($(parentElement) || document.body).getElementsByTagName('*'); - var elements = [], child; - for (var i = 0, length = children.length; i < length; i++) { - child = children[i]; - if (Element.hasClassName(child, className)) - elements.push(Element.extend(child)); - } - return elements; - } -}; - -/*--------------------------------------------------------------------------*/ - -if (!window.Element) - var Element = new Object(); - -Element.extend = function(element) { - if (!element || _nativeExtensions || element.nodeType == 3) return element; - - if (!element._extended && element.tagName && element != window) { - var methods = Object.clone(Element.Methods), cache = Element.extend.cache; - - if (element.tagName == 'FORM') - Object.extend(methods, Form.Methods); - if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName)) - Object.extend(methods, Form.Element.Methods); - - Object.extend(methods, Element.Methods.Simulated); - - for (var property in methods) { - var value = methods[property]; - if (typeof value == 'function' && !(property in element)) - element[property] = cache.findOrStore(value); - } - } - - element._extended = true; - return element; -}; - -Element.extend.cache = { - findOrStore: function(value) { - return this[value] = this[value] || function() { - return value.apply(null, [this].concat($A(arguments))); - } - } -}; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - $(element).style.display = 'none'; - return element; - }, - - show: function(element) { - $(element).style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, html) { - html = typeof html == 'undefined' ? '' : html.toString(); - $(element).innerHTML = html.stripScripts(); - setTimeout(function() {html.evalScripts()}, 10); - return element; - }, - - replace: function(element, html) { - element = $(element); - html = typeof html == 'undefined' ? '' : html.toString(); - if (element.outerHTML) { - element.outerHTML = html.stripScripts(); - } else { - var range = element.ownerDocument.createRange(); - range.selectNodeContents(element); - element.parentNode.replaceChild( - range.createContextualFragment(html.stripScripts()), element); - } - setTimeout(function() {html.evalScripts()}, 10); - return element; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $A($(element).getElementsByTagName('*')); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (typeof selector == 'string') - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - return Selector.findElement($(element).ancestors(), expression, index); - }, - - down: function(element, expression, index) { - return Selector.findElement($(element).descendants(), expression, index); - }, - - previous: function(element, expression, index) { - return Selector.findElement($(element).previousSiblings(), expression, index); - }, - - next: function(element, expression, index) { - return Selector.findElement($(element).nextSiblings(), expression, index); - }, - - getElementsBySelector: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - getElementsByClassName: function(element, className) { - return document.getElementsByClassName(className, element); - }, - - readAttribute: function(element, name) { - element = $(element); - if (document.all && !window.opera) { - var t = Element._attributeTranslations; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - var attribute = element.attributes[name]; - if(attribute) return attribute.nodeValue; - } - return element.getAttribute(name); - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - if (elementClassName.length == 0) return false; - if (elementClassName == className || - elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) - return true; - return false; - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - Element.classNames(element).add(className); - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - Element.classNames(element).remove(className); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); - return element; - }, - - observe: function() { - Event.observe.apply(Event, arguments); - return $A(arguments).first(); - }, - - stopObserving: function() { - Event.stopObserving.apply(Event, arguments); - return $A(arguments).first(); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.match(/^\s*$/); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - while (element = element.parentNode) - if (element == ancestor) return true; - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = Position.cumulativeOffset(element); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - if (['float','cssFloat'].include(style)) - style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); - style = style.camelize(); - var value = element.style[style]; - if (!value) { - if (document.defaultView && document.defaultView.getComputedStyle) { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } else if (element.currentStyle) { - value = element.currentStyle[style]; - } - } - - if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) - value = element['offset'+style.capitalize()] + 'px'; - - if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) - if (Element.getStyle(element, 'position') == 'static') value = 'auto'; - if(style == 'opacity') { - if(value) return parseFloat(value); - if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if(value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - return value == 'auto' ? null : value; - }, - - setStyle: function(element, style) { - element = $(element); - for (var name in style) { - var value = style[name]; - if(name == 'opacity') { - if (value == 1) { - value = (/Gecko/.test(navigator.userAgent) && - !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0; - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); - } else if(value == '') { - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); - } else { - if(value < 0.00001) value = 0; - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') + - 'alpha(opacity='+value*100+')'; - } - } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat'; - element.style[name.camelize()] = value; - } - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = $(element).getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (window.opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = element.style.overflow || 'auto'; - if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - } -}; - -Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); - -Element._attributeTranslations = {}; - -Element._attributeTranslations.names = { - colspan: "colSpan", - rowspan: "rowSpan", - valign: "vAlign", - datetime: "dateTime", - accesskey: "accessKey", - tabindex: "tabIndex", - enctype: "encType", - maxlength: "maxLength", - readonly: "readOnly", - longdesc: "longDesc" -}; - -Element._attributeTranslations.values = { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - - title: function(element) { - var node = element.getAttributeNode('title'); - return node.specified ? node.nodeValue : null; - } -}; - -Object.extend(Element._attributeTranslations.values, { - href: Element._attributeTranslations.values._getAttr, - src: Element._attributeTranslations.values._getAttr, - disabled: Element._attributeTranslations.values._flag, - checked: Element._attributeTranslations.values._flag, - readonly: Element._attributeTranslations.values._flag, - multiple: Element._attributeTranslations.values._flag -}); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - var t = Element._attributeTranslations; - attribute = t.names[attribute] || attribute; - return $(element).getAttributeNode(attribute).specified; - } -}; - -// IE is missing .innerHTML support for TABLE-related elements -if (document.all && !window.opera){ - Element.Methods.update = function(element, html) { - element = $(element); - html = typeof html == 'undefined' ? '' : html.toString(); - var tagName = element.tagName.toUpperCase(); - if (['THEAD','TBODY','TR','TD'].include(tagName)) { - var div = document.createElement('div'); - switch (tagName) { - case 'THEAD': - case 'TBODY': - div.innerHTML = '' + html.stripScripts() + '
    '; - depth = 2; - break; - case 'TR': - div.innerHTML = '' + html.stripScripts() + '
    '; - depth = 3; - break; - case 'TD': - div.innerHTML = '
    ' + html.stripScripts() + '
    '; - depth = 4; - } - $A(element.childNodes).each(function(node){ - element.removeChild(node) - }); - depth.times(function(){ div = div.firstChild }); - - $A(div.childNodes).each( - function(node){ element.appendChild(node) }); - } else { - element.innerHTML = html.stripScripts(); - } - setTimeout(function() {html.evalScripts()}, 10); - return element; - } -}; - -Object.extend(Element, Element.Methods); - -var _nativeExtensions = false; - -if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) { - var className = 'HTML' + tag + 'Element'; - if(window[className]) return; - var klass = window[className] = {}; - klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__; - }); - -Element.addMethods = function(methods) { - Object.extend(Element.Methods, methods || {}); - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - var cache = Element.extend.cache; - for (var property in methods) { - var value = methods[property]; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = cache.findOrStore(value); - } - } - - if (typeof HTMLElement != 'undefined') { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - copy(Form.Methods, HTMLFormElement.prototype); - [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { - copy(Form.Element.Methods, klass.prototype); - }); - _nativeExtensions = true; - } -} - -var Toggle = new Object(); -Toggle.display = Element.toggle; - -/*--------------------------------------------------------------------------*/ - -Abstract.Insertion = function(adjacency) { - this.adjacency = adjacency; -} - -Abstract.Insertion.prototype = { - initialize: function(element, content) { - this.element = $(element); - this.content = content.stripScripts(); - - if (this.adjacency && this.element.insertAdjacentHTML) { - try { - this.element.insertAdjacentHTML(this.adjacency, this.content); - } catch (e) { - var tagName = this.element.tagName.toUpperCase(); - if (['TBODY', 'TR'].include(tagName)) { - this.insertContent(this.contentFromAnonymousTable()); - } else { - throw e; - } - } - } else { - this.range = this.element.ownerDocument.createRange(); - if (this.initializeRange) this.initializeRange(); - this.insertContent([this.range.createContextualFragment(this.content)]); - } - - setTimeout(function() {content.evalScripts()}, 10); - }, - - contentFromAnonymousTable: function() { - var div = document.createElement('div'); - div.innerHTML = '' + this.content + '
    '; - return $A(div.childNodes[0].childNodes[0].childNodes); - } -} - -var Insertion = new Object(); - -Insertion.Before = Class.create(); -Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), { - initializeRange: function() { - this.range.setStartBefore(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.parentNode.insertBefore(fragment, this.element); - }).bind(this)); - } -}); - -Insertion.Top = Class.create(); -Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), { - initializeRange: function() { - this.range.selectNodeContents(this.element); - this.range.collapse(true); - }, - - insertContent: function(fragments) { - fragments.reverse(false).each((function(fragment) { - this.element.insertBefore(fragment, this.element.firstChild); - }).bind(this)); - } -}); - -Insertion.Bottom = Class.create(); -Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), { - initializeRange: function() { - this.range.selectNodeContents(this.element); - this.range.collapse(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.appendChild(fragment); - }).bind(this)); - } -}); - -Insertion.After = Class.create(); -Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), { - initializeRange: function() { - this.range.setStartAfter(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.parentNode.insertBefore(fragment, - this.element.nextSibling); - }).bind(this)); - } -}); - -/*--------------------------------------------------------------------------*/ - -Element.ClassNames = Class.create(); -Element.ClassNames.prototype = { - initialize: function(element) { - this.element = $(element); - }, - - _each: function(iterator) { - this.element.className.split(/\s+/).select(function(name) { - return name.length > 0; - })._each(iterator); - }, - - set: function(className) { - this.element.className = className; - }, - - add: function(classNameToAdd) { - if (this.include(classNameToAdd)) return; - this.set($A(this).concat(classNameToAdd).join(' ')); - }, - - remove: function(classNameToRemove) { - if (!this.include(classNameToRemove)) return; - this.set($A(this).without(classNameToRemove).join(' ')); - }, - - toString: function() { - return $A(this).join(' '); - } -}; - -Object.extend(Element.ClassNames.prototype, Enumerable); -var Selector = Class.create(); -Selector.prototype = { - initialize: function(expression) { - this.params = {classNames: []}; - this.expression = expression.toString().strip(); - this.parseExpression(); - this.compileMatcher(); - }, - - parseExpression: function() { - function abort(message) { throw 'Parse error in selector: ' + message; } - - if (this.expression == '') abort('empty expression'); - - var params = this.params, expr = this.expression, match, modifier, clause, rest; - while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { - params.attributes = params.attributes || []; - params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); - expr = match[1]; - } - - if (expr == '*') return this.params.wildcard = true; - - while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) { - modifier = match[1], clause = match[2], rest = match[3]; - switch (modifier) { - case '#': params.id = clause; break; - case '.': params.classNames.push(clause); break; - case '': - case undefined: params.tagName = clause.toUpperCase(); break; - default: abort(expr.inspect()); - } - expr = rest; - } - - if (expr.length > 0) abort(expr.inspect()); - }, - - buildMatchExpression: function() { - var params = this.params, conditions = [], clause; - - if (params.wildcard) - conditions.push('true'); - if (clause = params.id) - conditions.push('element.readAttribute("id") == ' + clause.inspect()); - if (clause = params.tagName) - conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); - if ((clause = params.classNames).length > 0) - for (var i = 0, length = clause.length; i < length; i++) - conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); - if (clause = params.attributes) { - clause.each(function(attribute) { - var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; - var splitValueBy = function(delimiter) { - return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; - } - - switch (attribute.operator) { - case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break; - case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break; - case '|=': conditions.push( - splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect() - ); break; - case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; - case '': - case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; - default: throw 'Unknown operator ' + attribute.operator + ' in selector'; - } - }); - } - - return conditions.join(' && '); - }, - - compileMatcher: function() { - this.match = new Function('element', 'if (!element.tagName) return false; \ - element = $(element); \ - return ' + this.buildMatchExpression()); - }, - - findElements: function(scope) { - var element; - - if (element = $(this.params.id)) - if (this.match(element)) - if (!scope || Element.childOf(element, scope)) - return [element]; - - scope = (scope || document).getElementsByTagName(this.params.tagName || '*'); - - var results = []; - for (var i = 0, length = scope.length; i < length; i++) - if (this.match(element = scope[i])) - results.push(Element.extend(element)); - - return results; - }, - - toString: function() { - return this.expression; - } -} - -Object.extend(Selector, { - matchElements: function(elements, expression) { - var selector = new Selector(expression); - return elements.select(selector.match.bind(selector)).map(Element.extend); - }, - - findElement: function(elements, expression, index) { - if (typeof expression == 'number') index = expression, expression = false; - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - return expressions.map(function(expression) { - return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) { - var selector = new Selector(expr); - return results.inject([], function(elements, result) { - return elements.concat(selector.findElements(result || element)); - }); - }); - }).flatten(); - } -}); - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, getHash) { - var data = elements.inject({}, function(result, element) { - if (!element.disabled && element.name) { - var key = element.name, value = $(element).getValue(); - if (value != undefined) { - if (result[key]) { - if (result[key].constructor != Array) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return getHash ? data : Hash.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, getHash) { - return Form.serializeElements(Form.getElements(form), getHash); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - form.getElements().each(function(element) { - element.blur(); - element.disabled = 'true'; - }); - return form; - }, - - enable: function(form) { - form = $(form); - form.getElements().each(function(element) { - element.disabled = ''; - }); - return form; - }, - - findFirstElement: function(form) { - return $(form).getElements().find(function(element) { - return element.type != 'hidden' && !element.disabled && - ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - } -} - -Object.extend(Form, Form.Methods); - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -} - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = {}; - pair[element.name] = value; - return Hash.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - element.focus(); - if (element.select && ( element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type) ) ) - element.select(); - return element; - }, - - disable: function(element) { - element = $(element); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.blur(); - element.disabled = false; - return element; - } -} - -Object.extend(Form.Element, Form.Element.Methods); -var Field = Form.Element; -var $F = Form.Element.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element); - default: - return Form.Element.Serializers.textarea(element); - } - }, - - inputSelector: function(element) { - return element.checked ? element.value : null; - }, - - textarea: function(element) { - return element.value; - }, - - select: function(element) { - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -} - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = function() {} -Abstract.TimedObserver.prototype = { - initialize: function(element, frequency, callback) { - this.frequency = frequency; - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - this.registerCallback(); - }, - - registerCallback: function() { - setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - onTimerEvent: function() { - var value = this.getValue(); - var changed = ('string' == typeof this.lastValue && 'string' == typeof value - ? this.lastValue != value : String(this.lastValue) != String(value)); - if (changed) { - this.callback(this.element, value); - this.lastValue = value; - } - } -} - -Form.Element.Observer = Class.create(); -Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(); -Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = function() {} -Abstract.EventObserver.prototype = { - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback.bind(this)); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -} - -Form.Element.EventObserver = Class.create(); -Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(); -Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) { - var Event = new Object(); -} - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - - element: function(event) { - return event.target || event.srcElement; - }, - - isLeftClick: function(event) { - return (((event.which) && (event.which == 1)) || - ((event.button) && (event.button == 1))); - }, - - pointerX: function(event) { - return event.pageX || (event.clientX + - (document.documentElement.scrollLeft || document.body.scrollLeft)); - }, - - pointerY: function(event) { - return event.pageY || (event.clientY + - (document.documentElement.scrollTop || document.body.scrollTop)); - }, - - stop: function(event) { - if (event.preventDefault) { - event.preventDefault(); - event.stopPropagation(); - } else { - event.returnValue = false; - event.cancelBubble = true; - } - }, - - // find the first node with the given tagName, starting from the - // node the event was triggered on; traverses the DOM upwards - findElement: function(event, tagName) { - var element = Event.element(event); - while (element.parentNode && (!element.tagName || - (element.tagName.toUpperCase() != tagName.toUpperCase()))) - element = element.parentNode; - return element; - }, - - observers: false, - - _observeAndCache: function(element, name, observer, useCapture) { - if (!this.observers) this.observers = []; - if (element.addEventListener) { - this.observers.push([element, name, observer, useCapture]); - element.addEventListener(name, observer, useCapture); - } else if (element.attachEvent) { - this.observers.push([element, name, observer, useCapture]); - element.attachEvent('on' + name, observer); - } - }, - - unloadCache: function() { - if (!Event.observers) return; - for (var i = 0, length = Event.observers.length; i < length; i++) { - Event.stopObserving.apply(this, Event.observers[i]); - Event.observers[i][0] = null; - } - Event.observers = false; - }, - - observe: function(element, name, observer, useCapture) { - element = $(element); - useCapture = useCapture || false; - - if (name == 'keypress' && - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) - || element.attachEvent)) - name = 'keydown'; - - Event._observeAndCache(element, name, observer, useCapture); - }, - - stopObserving: function(element, name, observer, useCapture) { - element = $(element); - useCapture = useCapture || false; - - if (name == 'keypress' && - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) - || element.detachEvent)) - name = 'keydown'; - - if (element.removeEventListener) { - element.removeEventListener(name, observer, useCapture); - } else if (element.detachEvent) { - try { - element.detachEvent('on' + name, observer); - } catch (e) {} - } - } -}); - -/* prevent memory leaks in IE */ -if (navigator.appVersion.match(/\bMSIE\b/)) - Event.observe(window, 'unload', Event.unloadCache, false); -var Position = { - // set to true if needed, warning: firefox performance problems - // NOT neeeded for page scrolling, only if draggable contained in - // scrollable elements - includeScrollOffsets: false, - - // must be called before calling withinIncludingScrolloffset, every time the - // page is scrolled - prepare: function() { - this.deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - this.deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - }, - - realOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return [valueL, valueT]; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return [valueL, valueT]; - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if(element.tagName=='BODY') break; - var p = Element.getStyle(element, 'position'); - if (p == 'relative' || p == 'absolute') break; - } - } while (element); - return [valueL, valueT]; - }, - - offsetParent: function(element) { - if (element.offsetParent) return element.offsetParent; - if (element == document.body) return element; - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return element; - - return document.body; - }, - - // caches x/y coordinate pair to use with overlap - within: function(element, x, y) { - if (this.includeScrollOffsets) - return this.withinIncludingScrolloffsets(element, x, y); - this.xcomp = x; - this.ycomp = y; - this.offset = this.cumulativeOffset(element); - - return (y >= this.offset[1] && - y < this.offset[1] + element.offsetHeight && - x >= this.offset[0] && - x < this.offset[0] + element.offsetWidth); - }, - - withinIncludingScrolloffsets: function(element, x, y) { - var offsetcache = this.realOffset(element); - - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.offset = this.cumulativeOffset(element); - - return (this.ycomp >= this.offset[1] && - this.ycomp < this.offset[1] + element.offsetHeight && - this.xcomp >= this.offset[0] && - this.xcomp < this.offset[0] + element.offsetWidth); - }, - - // within must be called directly before - overlap: function(mode, element) { - if (!mode) return 0; - if (mode == 'vertical') - return ((this.offset[1] + element.offsetHeight) - this.ycomp) / - element.offsetHeight; - if (mode == 'horizontal') - return ((this.offset[0] + element.offsetWidth) - this.xcomp) / - element.offsetWidth; - }, - - page: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent==document.body) - if (Element.getStyle(element,'position')=='absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!window.opera || element.tagName=='BODY') { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return [valueL, valueT]; - }, - - clone: function(source, target) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || {}) - - // find page position of source - source = $(source); - var p = Position.page(source); - - // find coordinate system to use - target = $(target); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(target,'position') == 'absolute') { - parent = Position.offsetParent(target); - delta = Position.page(parent); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if(options.setWidth) target.style.width = source.offsetWidth + 'px'; - if(options.setHeight) target.style.height = source.offsetHeight + 'px'; - }, - - absolutize: function(element) { - element = $(element); - if (element.style.position == 'absolute') return; - Position.prepare(); - - var offsets = Position.positionedOffset(element); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - }, - - relativize: function(element) { - element = $(element); - if (element.style.position == 'relative') return; - Position.prepare(); - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - } -} - -// Safari returns margins on body which is incorrect if the child is absolutely -// positioned. For performance reasons, redefine Position.cumulativeOffset for -// KHTML/WebKit only. -if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { - Position.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return [valueL, valueT]; - } -} - -Element.addMethods(); \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/robots.txt b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/robots.txt deleted file mode 100644 index 4ab9e89f..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/stylesheets/scaffold.css b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/stylesheets/scaffold.css deleted file mode 100644 index 8f239a35..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/public/stylesheets/scaffold.css +++ /dev/null @@ -1,74 +0,0 @@ -body { background-color: #fff; color: #333; } - -body, p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { color: #000; } -a:visited { color: #666; } -a:hover { color: #fff; background-color:#000; } - -.fieldWithErrors { - padding: 2px; - background-color: red; - display: table; -} - -#errorExplanation { - width: 400px; - border: 2px solid red; - padding: 7px; - padding-bottom: 12px; - margin-bottom: 20px; - background-color: #f0f0f0; -} - -#errorExplanation h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - background-color: #c00; - color: #fff; -} - -#errorExplanation p { - color: #333; - margin-bottom: 0; - padding: 5px; -} - -#errorExplanation ul li { - font-size: 12px; - list-style: square; -} - -div.uploadStatus { - margin: 5px; -} - -div.progressBar { - margin: 5px; -} - -div.progressBar div.border { - background-color: #fff; - border: 1px solid grey; - width: 100%; -} - -div.progressBar div.background { - background-color: #333; - height: 18px; - width: 0%; -} - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/about b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/about deleted file mode 100755 index 7b07d46a..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/about +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/about' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/breakpointer b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/breakpointer deleted file mode 100755 index 64af76ed..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/breakpointer +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/breakpointer' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/console b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/console deleted file mode 100755 index 42f28f7d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/console +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/console' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/destroy b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/destroy deleted file mode 100755 index fa0e6fcd..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/destroy +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/destroy' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/generate b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/generate deleted file mode 100755 index ef976e09..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/generate +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/generate' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/performance/benchmarker b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/performance/benchmarker deleted file mode 100755 index c842d35d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/performance/benchmarker +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/benchmarker' diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/performance/profiler b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/performance/profiler deleted file mode 100755 index d855ac8b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/performance/profiler +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/profiler' diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/plugin b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/plugin deleted file mode 100755 index 26ca64c0..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/plugin +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/plugin' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/inspector b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/inspector deleted file mode 100755 index bf25ad86..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/inspector +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/inspector' diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/reaper b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/reaper deleted file mode 100755 index c77f0453..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/reaper +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/reaper' diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/spawner b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/spawner deleted file mode 100755 index 7118f398..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/process/spawner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/spawner' diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/runner b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/runner deleted file mode 100755 index ccc30f9d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/runner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/runner' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/server b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/server deleted file mode 100755 index dfabcb88..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/script/server +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/server' \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/double_sti_parent_relationships.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/double_sti_parent_relationships.yml deleted file mode 100644 index 5bf02933..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/double_sti_parent_relationships.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -# one: -# column: value -# -# two: -# column: value diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/double_sti_parents.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/double_sti_parents.yml deleted file mode 100644 index 5bf02933..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/double_sti_parents.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -# one: -# column: value -# -# two: -# column: value diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/organic_substances.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/organic_substances.yml deleted file mode 100644 index 123ef537..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/organic_substances.yml +++ /dev/null @@ -1,5 +0,0 @@ -one: - type: Bone - -two: - type: Bone diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/single_sti_parent_relationships.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/single_sti_parent_relationships.yml deleted file mode 100644 index 5bf02933..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/single_sti_parent_relationships.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -# one: -# column: value -# -# two: -# column: value diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/single_sti_parents.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/single_sti_parents.yml deleted file mode 100644 index 5bf02933..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/single_sti_parents.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -# one: -# column: value -# -# two: -# column: value diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/sticks.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/sticks.yml deleted file mode 100644 index 157d7472..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/sticks.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -one: - name: MyString - -two: - name: MyString diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/stones.yml b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/stones.yml deleted file mode 100644 index 157d7472..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/fixtures/stones.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -one: - name: MyString - -two: - name: MyString diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/addresses_controller_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/addresses_controller_test.rb deleted file mode 100644 index 65284b5b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/addresses_controller_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'addresses_controller' - -# Re-raise errors caught by the controller. -class AddressesController; def rescue_action(e) raise e end; end - -class AddressesControllerTest < Test::Unit::TestCase - fixtures :addresses - - def setup - @controller = AddressesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_should_get_index - get :index - assert_response :success - assert assigns(:addresses) - end - - def test_should_get_new - get :new - assert_response :success - end - - def test_should_create_address - assert_difference('Address.count') do - post :create, :address => { :country_id => 1, :user_id => 1, :state_id => 1} - end - - assert_redirected_to address_path(assigns(:address)) - end - - def test_should_show_address - get :show, :id => 1 - assert_response :success - end - - def test_should_get_edit - get :edit, :id => 1 - assert_response :success - end - - def test_should_update_address - put :update, :id => 1, :address => { } - assert_redirected_to address_path(assigns(:address)) - end - - def test_should_destroy_address - assert_difference('Address.count', -1) do - delete :destroy, :id => 1 - end - - assert_redirected_to addresses_path - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/bones_controller_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/bones_controller_test.rb deleted file mode 100644 index fc0c7bd8..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/bones_controller_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class BonesControllerTest < ActionController::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/sellers_controller_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/sellers_controller_test.rb deleted file mode 100644 index fb992e5d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/sellers_controller_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'sellers_controller' - -# Re-raise errors caught by the controller. -class SellersController; def rescue_action(e) raise e end; end - -class SellersControllerTest < Test::Unit::TestCase - fixtures :sellers - - def setup - @controller = SellersController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_should_get_index - get :index - assert_response :success - assert assigns(:sellers) - end - - def test_should_get_new - get :new - assert_response :success - end - - def test_should_create_seller - assert_difference('Seller.count') do - post :create, :seller => { } - end - - assert_redirected_to seller_path(assigns(:seller)) - end - - def test_should_show_seller - get :show, :id => 1 - assert_response :success - end - - def test_should_get_edit - get :edit, :id => 1 - assert_response :success - end - - def test_should_update_seller - put :update, :id => 1, :seller => { } - assert_redirected_to seller_path(assigns(:seller)) - end - - def test_should_destroy_seller - assert_difference('Seller.count', -1) do - delete :destroy, :id => 1 - end - - assert_redirected_to sellers_path - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/states_controller_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/states_controller_test.rb deleted file mode 100644 index 2e93453b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/states_controller_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'states_controller' - -# Re-raise errors caught by the controller. -class StatesController; def rescue_action(e) raise e end; end - -class StatesControllerTest < Test::Unit::TestCase - fixtures :states - - def setup - @controller = StatesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_should_get_index - get :index - assert_response :success - assert assigns(:states) - end - - def test_should_get_new - get :new - assert_response :success - end - - def test_should_create_state - assert_difference('State.count') do - post :create, :state => { } - end - - assert_redirected_to state_path(assigns(:state)) - end - - def test_should_show_state - get :show, :id => 1 - assert_response :success - end - - def test_should_get_edit - get :edit, :id => 1 - assert_response :success - end - - def test_should_update_state - put :update, :id => 1, :state => { } - assert_redirected_to state_path(assigns(:state)) - end - - def test_should_destroy_state - assert_difference('State.count', -1) do - delete :destroy, :id => 1 - end - - assert_redirected_to states_path - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/users_controller_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/users_controller_test.rb deleted file mode 100644 index bc36751f..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/functional/users_controller_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'users_controller' - -# Re-raise errors caught by the controller. -class UsersController; def rescue_action(e) raise e end; end - -class UsersControllerTest < Test::Unit::TestCase - fixtures :users - - def setup - @controller = UsersController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_should_get_index - get :index - assert_response :success - assert assigns(:users) - end - - def test_should_get_new - get :new - assert_response :success - end - - def test_should_create_user - assert_difference('User.count') do - post :create, :user => { } - end - - assert_redirected_to user_path(assigns(:user)) - end - - def test_should_show_user - get :show, :id => 1 - assert_response :success - end - - def test_should_get_edit - get :edit, :id => 1 - assert_response :success - end - - def test_should_update_user - put :update, :id => 1, :user => { } - assert_redirected_to user_path(assigns(:user)) - end - - def test_should_destroy_user - assert_difference('User.count', -1) do - delete :destroy, :id => 1 - end - - assert_redirected_to users_path - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/test_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/test_helper.rb deleted file mode 100644 index 773c49de..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/test_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -ENV["RAILS_ENV"] = "development" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") -require 'test_help' - -class Test::Unit::TestCase - self.use_transactional_fixtures = true - self.use_instantiated_fixtures = false -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/bone_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/bone_test.rb deleted file mode 100644 index 8afcb87b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/bone_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class BoneTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/double_sti_parent_relationship_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/double_sti_parent_relationship_test.rb deleted file mode 100644 index dc20e74d..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/double_sti_parent_relationship_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class DoubleStiParentRelationshipTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/double_sti_parent_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/double_sti_parent_test.rb deleted file mode 100644 index 154383a2..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/double_sti_parent_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class DoubleStiParentTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/organic_substance_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/organic_substance_test.rb deleted file mode 100644 index af328b95..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/organic_substance_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class OrganicSubstanceTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/single_sti_parent_relationship_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/single_sti_parent_relationship_test.rb deleted file mode 100644 index d5563fd8..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/single_sti_parent_relationship_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SingleStiParentRelationshipTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/single_sti_parent_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/single_sti_parent_test.rb deleted file mode 100644 index 70a00ecb..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/single_sti_parent_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SingleStiParentTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/stick_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/stick_test.rb deleted file mode 100644 index 6729e0d6..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/stick_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class StickTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/stone_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/stone_test.rb deleted file mode 100644 index 76b518d7..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/app/test/unit/stone_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class StoneTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/integration/server_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/integration/server_test.rb deleted file mode 100644 index e53ea1aa..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/integration/server_test.rb +++ /dev/null @@ -1,43 +0,0 @@ - -require "#{File.dirname(__FILE__)}/../test_helper" -require 'open-uri' - -# Start the server - -class ServerTest < Test::Unit::TestCase - - PORT = 43040 - URL = "http://localhost:#{PORT}/" - - def setup - @pid = Process.fork do - Dir.chdir RAILS_ROOT do - # print "S" - exec("script/server -p #{PORT} &> #{LOG}") - end - end - sleep(5) - end - - def teardown - # Process.kill(9, @pid) doesn't work because Mongrel has double-forked itself away - `ps awx | grep #{PORT} | grep -v grep | awk '{print $1}'`.split("\n").each do |pid| - system("kill -9 #{pid}") - # print "K" - end - sleep(2) - @pid = nil - end - - def test_association_reloading - assert_match(/Bones: index/, open(URL + 'bones').read) - assert_match(/Bones: index/, open(URL + 'bones').read) - assert_match(/Bones: index/, open(URL + 'bones').read) - assert_match(/Bones: index/, open(URL + 'bones').read) - end - - def test_verify_autoload_gets_invoked_in_console - # XXX Probably can use script/runner to test this - end - -end \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/fish.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/fish.rb deleted file mode 100644 index 204642e9..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/fish.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Aquatic::Fish < ActiveRecord::Base - # set_table_name "fish" - # attr_accessor :after_find_test, :after_initialize_test -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/pupils_whale.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/pupils_whale.rb deleted file mode 100644 index ae4cbc18..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/pupils_whale.rb +++ /dev/null @@ -1,7 +0,0 @@ - -class Aquatic::PupilsWhale < ActiveRecord::Base - set_table_name "little_whale_pupils" - belongs_to :whale, :class_name => "Aquatic::Whale", :foreign_key => "whale_id" - belongs_to :aquatic_pupil, :polymorphic => true -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/whale.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/whale.rb deleted file mode 100644 index 0ca1b7fb..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/aquatic/whale.rb +++ /dev/null @@ -1,15 +0,0 @@ -# see http://dev.rubyonrails.org/ticket/5935 -module Aquatic; end -require 'aquatic/fish' -require 'aquatic/pupils_whale' - -class Aquatic::Whale < ActiveRecord::Base - # set_table_name "whales" - - has_many_polymorphs(:aquatic_pupils, :from => [:dogs, :"aquatic/fish"], - :through => "aquatic/pupils_whales") do - def a_method - :correct_block_result - end - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/beautiful_fight_relationship.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/beautiful_fight_relationship.rb deleted file mode 100644 index b678c982..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/beautiful_fight_relationship.rb +++ /dev/null @@ -1,26 +0,0 @@ - -require 'extension_module' - -class BeautifulFightRelationship < ActiveRecord::Base - set_table_name 'keep_your_enemies_close' - - belongs_to :enemy, :polymorphic => true - belongs_to :protector, :polymorphic => true - # polymorphic relationships with column names different from the relationship name - # are not supported by Rails - - acts_as_double_polymorphic_join :enemies => [:dogs, :kittens, :frogs], - :protectors => [:wild_boars, :kittens, :"aquatic/fish", :dogs], - :enemies_extend => [ExtensionModule, proc {}], - :protectors_extend => proc { - def a_method - :correct_proc_result - end - }, - :join_extend => proc { - def a_method - :correct_join_result - end - } -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/canine.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/canine.rb deleted file mode 100644 index b0010160..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/canine.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Canine < ActiveRecord::Base - self.abstract_class = true - - def an_abstract_method - :correct_abstract_method_response - end - -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/cat.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/cat.rb deleted file mode 100644 index 0c99ff08..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/cat.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Cat < ActiveRecord::Base - # STI base class - self.inheritance_column = 'cat_type' -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/dog.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/dog.rb deleted file mode 100644 index 7f027237..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/dog.rb +++ /dev/null @@ -1,18 +0,0 @@ - -require 'canine' - -class Dog < Canine - attr_accessor :after_find_test, :after_initialize_test - set_table_name "bow_wows" - - def after_find - @after_find_test = true -# puts "After find called on #{name}." - end - - def after_initialize - @after_initialize_test = true - end - -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/eaters_foodstuff.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/eaters_foodstuff.rb deleted file mode 100644 index d904bb16..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/eaters_foodstuff.rb +++ /dev/null @@ -1,10 +0,0 @@ - -class EatersFoodstuff < ActiveRecord::Base - belongs_to :foodstuff, :class_name => "Petfood", :foreign_key => "foodstuff_id" - belongs_to :eater, :polymorphic => true - - def before_save - self.some_attribute = 3 - end -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/frog.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/frog.rb deleted file mode 100644 index 5a0f4658..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/frog.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Frog < ActiveRecord::Base - -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/kitten.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/kitten.rb deleted file mode 100644 index 2a244c03..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/kitten.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Kitten < Cat -# has_many :eaters_parents, :dependent => true, :as => 'eater' -end \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/parentship.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/parentship.rb deleted file mode 100644 index e87b759b..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/parentship.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Parentship < ActiveRecord::Base - belongs_to :parent, :class_name => "Person", :foreign_key => "parent_id" - belongs_to :kid, :polymorphic => true, :foreign_type => "child_type" -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/person.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/person.rb deleted file mode 100644 index 5d019829..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/person.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'parentship' -class Person < ActiveRecord::Base - has_many_polymorphs :kids, - :through => :parentships, - :from => [:people], - :as => :parent, - :polymorphic_type_key => "child_type", - :conditions => "people.age < 10" -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/petfood.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/petfood.rb deleted file mode 100644 index df420ea8..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/petfood.rb +++ /dev/null @@ -1,39 +0,0 @@ -# see http://dev.rubyonrails.org/ticket/5935 -require 'eaters_foodstuff' -require 'petfood' -require 'cat' -module Aquatic; end -require 'aquatic/fish' -require 'dog' -require 'wild_boar' -require 'kitten' -require 'tabby' -require 'extension_module' -require 'other_extension_module' - -class Petfood < ActiveRecord::Base - set_primary_key 'the_petfood_primary_key' - has_many_polymorphs :eaters, - :from => [:dogs, :petfoods, :wild_boars, :kittens, - :tabbies, :"aquatic/fish"], -# :dependent => :destroy, :destroy is now the default - :rename_individual_collections => true, - :as => :foodstuff, - :foreign_key => "foodstuff_id", - :ignore_duplicates => false, - :conditions => "NULL IS NULL", - :order => "eaters_foodstuffs.updated_at ASC", - :parent_order => "petfoods.the_petfood_primary_key DESC", - :parent_conditions => "petfoods.name IS NULL OR petfoods.name != 'Snausages'", - :extend => [ExtensionModule, OtherExtensionModule, proc {}], - :join_extend => proc { - def a_method - :correct_join_result - end - }, - :parent_extend => proc { - def a_method - :correct_parent_proc_result - end - } - end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/tabby.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/tabby.rb deleted file mode 100644 index 3cd0f994..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/tabby.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Tabby < Cat -end \ No newline at end of file diff --git a/vendor/gems/has_many_polymorphs-2.13/test/models/wild_boar.rb b/vendor/gems/has_many_polymorphs-2.13/test/models/wild_boar.rb deleted file mode 100644 index 27d36a53..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/models/wild_boar.rb +++ /dev/null @@ -1,3 +0,0 @@ -class WildBoar < ActiveRecord::Base -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/modules/extension_module.rb b/vendor/gems/has_many_polymorphs-2.13/test/modules/extension_module.rb deleted file mode 100644 index 7cb4eff4..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/modules/extension_module.rb +++ /dev/null @@ -1,9 +0,0 @@ - -module ExtensionModule - def a_method - :correct_module_result - end - def self.a_method - :incorrect_module_result - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/modules/other_extension_module.rb b/vendor/gems/has_many_polymorphs-2.13/test/modules/other_extension_module.rb deleted file mode 100644 index 16313bd8..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/modules/other_extension_module.rb +++ /dev/null @@ -1,9 +0,0 @@ - -module OtherExtensionModule - def another_method - :correct_other_module_result - end - def self.another_method - :incorrect_other_module_result - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/patches/symlinked_plugins_1.2.6.diff b/vendor/gems/has_many_polymorphs-2.13/test/patches/symlinked_plugins_1.2.6.diff deleted file mode 100644 index 99e0df3e..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/patches/symlinked_plugins_1.2.6.diff +++ /dev/null @@ -1,46 +0,0 @@ -Index: /trunk/railties/lib/rails_generator/lookup.rb -=================================================================== ---- /trunk/railties/lib/rails_generator/lookup.rb (revision 4310) -+++ /trunk/railties/lib/rails_generator/lookup.rb (revision 6101) -@@ -101,5 +101,5 @@ - sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators") - sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators") -- sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/**/generators") -+ sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/generators") - end - sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators") -Index: /trunk/railties/lib/tasks/rails.rb -=================================================================== ---- /trunk/railties/lib/tasks/rails.rb (revision 5469) -+++ /trunk/railties/lib/tasks/rails.rb (revision 6101) -@@ -6,3 +6,3 @@ - # Load any custom rakefile extensions - Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } --Dir["#{RAILS_ROOT}/vendor/plugins/**/tasks/**/*.rake"].sort.each { |ext| load ext } -+Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext } -Index: /trunk/railties/lib/tasks/testing.rake -=================================================================== ---- /trunk/railties/lib/tasks/testing.rake (revision 5263) -+++ /trunk/railties/lib/tasks/testing.rake (revision 6101) -@@ -109,9 +109,9 @@ - t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb" - else -- t.pattern = 'vendor/plugins/**/test/**/*_test.rb' -+ t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb' - end - - t.verbose = true - end -- Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)" -+ Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)" - end -Index: /trunk/railties/CHANGELOG -=================================================================== ---- /trunk/railties/CHANGELOG (revision 6069) -+++ /trunk/railties/CHANGELOG (revision 6101) -@@ -1,3 +1,5 @@ - *SVN* -+ -+* Plugins may be symlinked in vendor/plugins. #4245 [brandon, progrium@gmail.com] - - * Resource generator depends on the model generator rather than duplicating it. #7269 [bscofield] diff --git a/vendor/gems/has_many_polymorphs-2.13/test/schema.rb b/vendor/gems/has_many_polymorphs-2.13/test/schema.rb deleted file mode 100644 index 39d869dc..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/schema.rb +++ /dev/null @@ -1,87 +0,0 @@ -ActiveRecord::Schema.define(:version => 0) do - create_table :petfoods, :force => true, :primary_key => :the_petfood_primary_key do |t| - t.column :name, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :bow_wows, :force => true do |t| - t.column :name, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :cats, :force => true do |t| - t.column :name, :string - t.column :cat_type, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :frogs, :force => true do |t| - t.column :name, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :wild_boars, :force => true do |t| - t.column :name, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :eaters_foodstuffs, :force => true do |t| - t.column :foodstuff_id, :integer - t.column :eater_id, :integer - t.column :some_attribute, :integer, :default => 0 - t.column :eater_type, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :fish, :force => true do |t| - t.column :name, :string - t.column :speed, :integer - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :whales, :force => true do |t| - t.column :name, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :little_whale_pupils, :force => true do |t| - t.column :whale_id, :integer - t.column :aquatic_pupil_id, :integer - t.column :aquatic_pupil_type, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :keep_your_enemies_close, :force => true do |t| - t.column :enemy_id, :integer - t.column :enemy_type, :string - t.column :protector_id, :integer - t.column :protector_type, :string - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :parentships, :force => true do |t| - t.column :parent_id, :integer - t.column :child_type, :string - t.column :kid_id, :integer - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - - create_table :people, :force => true do |t| - t.column :name, :string - t.column :age, :integer - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false - end - -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/setup.rb b/vendor/gems/has_many_polymorphs-2.13/test/setup.rb deleted file mode 100644 index 52535798..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/setup.rb +++ /dev/null @@ -1,14 +0,0 @@ - -# Setup integration system for the integration suite - -Dir.chdir "#{File.dirname(__FILE__)}/integration/app/" do - Dir.chdir "vendor/plugins" do - system("rm has_many_polymorphs; ln -s ../../../../../ has_many_polymorphs") - end - - system "rake db:drop --trace RAILS_GEM_VERSION=2.2.2 " - system "rake db:create --trace RAILS_GEM_VERSION=2.2.2 " - system "rake db:migrate --trace" - system "rake db:fixtures:load --trace" -end - diff --git a/vendor/gems/has_many_polymorphs-2.13/test/test_helper.rb b/vendor/gems/has_many_polymorphs-2.13/test/test_helper.rb deleted file mode 100644 index 363a6607..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/test_helper.rb +++ /dev/null @@ -1,51 +0,0 @@ - -$VERBOSE = nil -require 'rubygems' -require 'echoe' -require 'test/unit' -require 'multi_rails_init' -require 'ruby-debug' - -if defined? ENV['MULTIRAILS_RAILS_VERSION'] - ENV['RAILS_GEM_VERSION'] = ENV['MULTIRAILS_RAILS_VERSION'] -end - -Echoe.silence do - HERE = File.expand_path(File.dirname(__FILE__)) - $LOAD_PATH << HERE - # $LOAD_PATH << "#{HERE}/integration/app" -end - -LOG = "#{HERE}/integration/app/log/development.log" - -### For unit tests - -require 'integration/app/config/environment' -require 'test_help' - -ActiveSupport::Inflector.inflections {|i| i.irregular 'fish', 'fish' } - -$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path = HERE + "/fixtures") -$LOAD_PATH.unshift(HERE + "/models") -$LOAD_PATH.unshift(HERE + "/modules") - -class Test::Unit::TestCase - self.use_transactional_fixtures = !(ActiveRecord::Base.connection.is_a? ActiveRecord::ConnectionAdapters::MysqlAdapter rescue false) - self.use_instantiated_fixtures = false -end - -Echoe.silence do - load(HERE + "/schema.rb") -end - -### For integration tests - -def truncate - system("> #{LOG}") -end - -def log - File.open(LOG, 'r') do |f| - f.read - end -end diff --git a/vendor/gems/has_many_polymorphs-2.13/test/unit/has_many_polymorphs_test.rb b/vendor/gems/has_many_polymorphs-2.13/test/unit/has_many_polymorphs_test.rb deleted file mode 100644 index 7f4b05a4..00000000 --- a/vendor/gems/has_many_polymorphs-2.13/test/unit/has_many_polymorphs_test.rb +++ /dev/null @@ -1,714 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -require 'dog' -require 'wild_boar' -require 'frog' -require 'cat' -require 'kitten' -require 'aquatic/whale' -require 'aquatic/fish' -require 'aquatic/pupils_whale' -require 'beautiful_fight_relationship' - -class PolymorphTest < Test::Unit::TestCase - - set_fixture_class :bow_wows => Dog - set_fixture_class :keep_your_enemies_close => BeautifulFightRelationship - set_fixture_class :whales => Aquatic::Whale - set_fixture_class :fish => Aquatic::Fish - set_fixture_class :little_whale_pupils => Aquatic::PupilsWhale - - fixtures :cats, :bow_wows, :frogs, :wild_boars, :eaters_foodstuffs, :petfoods, - :fish, :whales, :little_whale_pupils, :keep_your_enemies_close, :people - - def setup - @association_error = ActiveRecord::Associations::PolymorphicError - @kibbles = Petfood.find(1) - @bits = Petfood.find(2) - @shamu = Aquatic::Whale.find(1) - @swimmy = Aquatic::Fish.find(1) - @rover = Dog.find(1) - @spot = Dog.find(2) - @puma = WildBoar.find(1) - @chloe = Kitten.find(1) - @alice = Kitten.find(2) - @toby = Tabby.find(3) - @froggy = Frog.find(1) - - @join_count = EatersFoodstuff.count - @kibbles_eaters_count = @kibbles.eaters.size - @bits_eaters_count = @bits.eaters.size - - @double_join_count = BeautifulFightRelationship.count - @alice_enemies_count = @alice.enemies.size - end - - def test_all_relationship_validities - # q = [] - # ObjectSpace.each_object(Class){|c| q << c if c.ancestors.include? ActiveRecord::Base } - # q.each{|c| puts "#{c.name}.reflect_on_all_associations.map(&:check_validity!)"} - Petfood.reflect_on_all_associations.map(&:check_validity!) - Tabby.reflect_on_all_associations.map(&:check_validity!) - Kitten.reflect_on_all_associations.map(&:check_validity!) - Dog.reflect_on_all_associations.map(&:check_validity!) - Canine.reflect_on_all_associations.map(&:check_validity!) - Aquatic::Fish.reflect_on_all_associations.map(&:check_validity!) - EatersFoodstuff.reflect_on_all_associations.map(&:check_validity!) - WildBoar.reflect_on_all_associations.map(&:check_validity!) - Frog.reflect_on_all_associations.map(&:check_validity!) - Cat.reflect_on_all_associations.map(&:check_validity!) - BeautifulFightRelationship.reflect_on_all_associations.map(&:check_validity!) - Person.reflect_on_all_associations.map(&:check_validity!) - Parentship.reflect_on_all_associations.map(&:check_validity!) - Aquatic::Whale.reflect_on_all_associations.map(&:check_validity!) - Aquatic::PupilsWhale.reflect_on_all_associations.map(&:check_validity!) - end - - def test_assignment - assert @kibbles.eaters.blank? - assert @kibbles.eaters.push(Cat.find_by_name('Chloe')) - assert_equal @kibbles_eaters_count += 1, @kibbles.eaters.count - - @kibbles.reload - assert_equal @kibbles_eaters_count, @kibbles.eaters.count - end - - def test_duplicate_assignment - # try to add a duplicate item when :ignore_duplicates is false - @kibbles.eaters.push(@alice) - assert @kibbles.eaters.include?(@alice) - @kibbles.eaters.push(@alice) - assert_equal @kibbles_eaters_count + 2, @kibbles.eaters.count - assert_equal @join_count + 2, EatersFoodstuff.count - end - - def test_create_and_push - assert @kibbles.eaters.push(@spot) - assert_equal @kibbles_eaters_count += 1, @kibbles.eaters.count - assert @kibbles.eaters << @rover - assert @kibbles.eaters << Kitten.create(:name => "Miranda") - assert_equal @kibbles_eaters_count += 2, @kibbles.eaters.length - - @kibbles.reload - assert_equal @kibbles_eaters_count, @kibbles.eaters.length - - # test that ids and new flags were set appropriately - assert_not_nil @kibbles.eaters[0].id - assert !@kibbles.eaters[1].new_record? - end - - def test_reload - assert @kibbles.reload - assert @kibbles.eaters.reload - end - - def test_add_join_record - assert_equal Kitten, @chloe.class - assert join = EatersFoodstuff.new(:foodstuff_id => @bits.id, :eater_id => @chloe.id, :eater_type => @chloe.class.name ) - assert join.save! - assert join.id - assert_equal @join_count + 1, EatersFoodstuff.count - - #assert_equal @bits_eaters_count, @bits.eaters.size # Doesn't behave this way on latest edge anymore - assert_equal @bits_eaters_count + 1, @bits.eaters.count # SQL - - # reload; is the new association there? - assert @bits.eaters.reload - assert @bits.eaters.include?(@chloe) - end - - def test_build_join_record_on_association - assert_equal Kitten, @chloe.class - assert join = @chloe.eaters_foodstuffs.build(:foodstuff => @bits) - # assert_equal join.eater_type, @chloe.class.name # will be STI parent type - assert join.save! - assert join.id - assert_equal @join_count + 1, EatersFoodstuff.count - - assert @bits.eaters.reload - assert @bits.eaters.include?(@chloe) - end - -# not supporting this, since has_many :through doesn't support it either -# def test_add_unsaved -# # add an unsaved item -# assert @bits.eaters << Kitten.new(:name => "Bridget") -# assert_nil Kitten.find_by_name("Bridget") -# assert_equal @bits_eaters_count + 1, @bits.eaters.count -# -# assert @bits.save -# @bits.reload -# assert_equal @bits_eaters_count + 1, @bits.eaters.count -# -# end - - def test_self_reference - assert @kibbles.eaters << @bits - assert_equal @kibbles_eaters_count += 1, @kibbles.eaters.count - assert @kibbles.eaters.include?(@bits) - @kibbles.reload - assert @kibbles.foodstuffs_of_eaters.blank? - - @bits.reload - assert @bits.foodstuffs_of_eaters.include?(@kibbles) - assert_equal [@kibbles], @bits.foodstuffs_of_eaters - end - - def test_remove - assert @kibbles.eaters << @chloe - @kibbles.reload - assert @kibbles.eaters.delete(@kibbles.eaters[0]) - assert_equal @kibbles_eaters_count, @kibbles.eaters.count - end - - def test_destroy - assert @kibbles.eaters.push(@chloe) - @kibbles.reload - assert @kibbles.eaters.length > 0 - assert @kibbles.eaters[0].destroy - @kibbles.reload - assert_equal @kibbles_eaters_count, @kibbles.eaters.count - end - - def test_clear - @kibbles.eaters << [@chloe, @spot, @rover] - @kibbles.reload - assert @kibbles.eaters.clear.blank? - assert @kibbles.eaters.blank? - @kibbles.reload - assert @kibbles.eaters.blank? - end - - def test_individual_collections - assert @kibbles.eaters.push(@chloe) - # check if individual collections work - assert_equal @kibbles.eater_kittens.length, 1 - assert @kibbles.eater_dogs - assert 1, @rover.eaters_foodstuffs.count - end - - def test_individual_collections_push - assert_equal [@chloe], (@kibbles.eater_kittens << @chloe) - @kibbles.reload - assert @kibbles.eaters.include?(@chloe) - assert @kibbles.eater_kittens.include?(@chloe) - assert !@kibbles.eater_dogs.include?(@chloe) - end - - def test_individual_collections_delete - @kibbles.eaters << [@chloe, @spot, @rover] - @kibbles.reload - assert_equal [@chloe], @kibbles.eater_kittens.delete(@chloe) - assert @kibbles.eater_kittens.empty? - @kibbles.eater_kittens.delete(@chloe) # what should this return? - - @kibbles.reload - assert @kibbles.eater_kittens.empty? - assert @kibbles.eater_dogs.include?(@spot) - end - - def test_individual_collections_clear - @kibbles.eaters << [@chloe, @spot, @rover] - @kibbles.reload - - assert_equal [], @kibbles.eater_kittens.clear - assert @kibbles.eater_kittens.empty? - assert_equal 2, @kibbles.eaters.size - - assert @kibbles.eater_kittens.empty? - assert_equal 2, @kibbles.eaters.size - assert !@kibbles.eater_kittens.include?(@chloe) - assert !@kibbles.eaters.include?(@chloe) - - @kibbles.reload - assert @kibbles.eater_kittens.empty? - assert_equal 2, @kibbles.eaters.size - assert !@kibbles.eater_kittens.include?(@chloe) - assert !@kibbles.eaters.include?(@chloe) - end - - def test_childrens_individual_collections - assert Cat.find_by_name('Chloe').eaters_foodstuffs - assert @kibbles.eaters_foodstuffs - end - - def test_self_referential_join_tables - # check that the self-reference join tables go the right ways - assert_equal @kibbles_eaters_count, @kibbles.eaters_foodstuffs.count - assert_equal @kibbles.eaters_foodstuffs.count, @kibbles.eaters_foodstuffs_as_child.count - end - - def test_dependent - assert @kibbles.eaters << @chloe - @kibbles.reload - - # delete ourself and see if :dependent was obeyed - dependent_rows = @kibbles.eaters_foodstuffs - assert_equal dependent_rows.length, @kibbles.eaters.count - @join_count = EatersFoodstuff.count - - @kibbles.destroy - assert_equal @join_count - dependent_rows.length, EatersFoodstuff.count - assert_equal 0, EatersFoodstuff.find(:all, :conditions => ['foodstuff_id = ?', 1] ).length - end - - def test_normal_callbacks - assert @rover.respond_to?(:after_initialize) - assert @rover.respond_to?(:after_find) - assert @rover.after_initialize_test - assert @rover.after_find_test - end - - def test_model_callbacks_not_overridden_by_plugin_callbacks - assert 0, @bits.eaters.count - assert @bits.eaters.push(@rover) - @bits.save - @bits2 = Petfood.find_by_name("Bits") - @bits.reload - assert rover = @bits2.eaters.select { |x| x.name == "Rover" }[0] - assert rover.after_initialize_test - assert rover.after_find_test - end - - def test_number_of_join_records - assert EatersFoodstuff.create(:foodstuff_id => 1, :eater_id => 1, :eater_type => "Cat") - @join_count = EatersFoodstuff.count - assert @join_count > 0 - end - - def test_number_of_regular_records - dogs = Dog.count - assert Dog.new(:name => "Auggie").save! - assert dogs + 1, Dog.count - end - - def test_attributes_come_through_when_child_has_underscore_in_table_name - join = EatersFoodstuff.new(:foodstuff_id => @bits.id, :eater_id => @puma.id, :eater_type => @puma.class.name) - join.save! - - @bits.eaters.reload - - assert_equal "Puma", @puma.name - assert_equal "Puma", @bits.eaters.first.name - end - - - def test_before_save_on_join_table_is_not_clobbered_by_sti_base_class_fix - assert @kibbles.eaters << @chloe - assert_equal 3, @kibbles.eaters_foodstuffs.first.some_attribute - end - - def test_sti_type_counts_are_correct - @kibbles.eaters << [@chloe, @alice, @toby] - assert_equal 2, @kibbles.eater_kittens.count - assert_equal 1, @kibbles.eater_tabbies.count - assert !@kibbles.respond_to?(:eater_cats) - end - - - def test_creating_namespaced_relationship - assert @shamu.aquatic_pupils.empty? - @shamu.aquatic_pupils << @swimmy - assert_equal 1, @shamu.aquatic_pupils.length - @shamu.reload - assert_equal 1, @shamu.aquatic_pupils.length - end - - def test_namespaced_polymorphic_collection - @shamu.aquatic_pupils << @swimmy - assert @shamu.aquatic_pupils.include?(@swimmy) - @shamu.reload - assert @shamu.aquatic_pupils.include?(@swimmy) - - @shamu.aquatic_pupils << @spot - assert @shamu.dogs.include?(@spot) - assert @shamu.aquatic_pupils.include?(@swimmy) - assert_equal @swimmy, @shamu.aquatic_fish.first - assert_equal 10, @shamu.aquatic_fish.first.speed - end - - def test_deleting_namespaced_relationship - @shamu.aquatic_pupils << @swimmy - @shamu.aquatic_pupils << @spot - - @shamu.reload - @shamu.aquatic_pupils.delete @spot - assert !@shamu.dogs.include?(@spot) - assert !@shamu.aquatic_pupils.include?(@spot) - assert_equal 1, @shamu.aquatic_pupils.length - end - - def test_unrenamed_parent_of_namespaced_child - @shamu.aquatic_pupils << @swimmy - assert_equal [@shamu], @swimmy.whales - end - - def test_empty_double_collections - assert @puma.enemies.empty? - assert @froggy.protectors.empty? - assert @alice.enemies.empty? - assert @spot.protectors.empty? - assert @alice.beautiful_fight_relationships_as_enemy.empty? - assert @alice.beautiful_fight_relationships_as_protector.empty? - assert @alice.beautiful_fight_relationships.empty? - end - - def test_double_collection_assignment - @alice.enemies << @spot - @alice.reload - @spot.reload - assert @spot.protectors.include?(@alice) - assert @alice.enemies.include?(@spot) - assert !@alice.protectors.include?(@alice) - assert_equal 1, @alice.beautiful_fight_relationships_as_protector.size - assert_equal 0, @alice.beautiful_fight_relationships_as_enemy.size - assert_equal 1, @alice.beautiful_fight_relationships.size - - # self reference - assert_equal 1, @alice.enemies.length - @alice.enemies.push @alice - assert @alice.enemies.include?(@alice) - assert_equal 2, @alice.enemies.length - @alice.reload - assert_equal 2, @alice.beautiful_fight_relationships_as_protector.size - assert_equal 1, @alice.beautiful_fight_relationships_as_enemy.size - assert_equal 3, @alice.beautiful_fight_relationships.size - end - - def test_double_collection_build_join_record_on_association - - join = @alice.beautiful_fight_relationships_as_protector.build(:enemy => @spot) - - assert_equal @alice.class.base_class.name, join.protector_type - assert_nothing_raised { join.save! } - - assert join.id - assert_equal @double_join_count + 1, BeautifulFightRelationship.count - - assert @alice.enemies.reload - assert @alice.enemies.include?(@spot) - end - - def test_double_dependency_injection -# breakpoint - end - - def test_double_collection_deletion - @alice.enemies << @spot - @alice.reload - assert @alice.enemies.include?(@spot) - @alice.enemies.delete(@spot) - assert !@alice.enemies.include?(@spot) - assert @alice.enemies.empty? - @alice.reload - assert !@alice.enemies.include?(@spot) - assert @alice.enemies.empty? - assert_equal 0, @alice.beautiful_fight_relationships.size - end - - def test_double_collection_deletion_from_opposite_side - @alice.protectors << @puma - @alice.reload - assert @alice.protectors.include?(@puma) - @alice.protectors.delete(@puma) - assert !@alice.protectors.include?(@puma) - assert @alice.protectors.empty? - @alice.reload - assert !@alice.protectors.include?(@puma) - assert @alice.protectors.empty? - assert_equal 0, @alice.beautiful_fight_relationships.size - end - - def test_individual_collections_created_for_double_relationship - assert @alice.dogs.empty? - @alice.enemies << @spot - - assert @alice.enemies.include?(@spot) - assert !@alice.kittens.include?(@alice) - - assert !@alice.dogs.include?(@spot) - @alice.reload - assert @alice.dogs.include?(@spot) - assert !WildBoar.find(@alice.id).dogs.include?(@spot) # make sure the parent type is checked - end - - def test_individual_collections_created_for_double_relationship_from_opposite_side - assert @alice.wild_boars.empty? - @alice.protectors << @puma - - assert @alice.protectors.include?(@puma) - assert !@alice.wild_boars.include?(@puma) - @alice.reload - assert @alice.wild_boars.include?(@puma) - - assert !Dog.find(@alice.id).wild_boars.include?(@puma) # make sure the parent type is checked - end - - def test_self_referential_individual_collections_created_for_double_relationship - @alice.enemies << @alice - @alice.reload - assert @alice.enemy_kittens.include?(@alice) - assert @alice.protector_kittens.include?(@alice) - assert @alice.kittens.include?(@alice) - assert_equal 2, @alice.kittens.size - - @alice.enemies << (@chloe = Kitten.find_by_name('Chloe')) - @alice.reload - assert @alice.enemy_kittens.include?(@chloe) - assert !@alice.protector_kittens.include?(@chloe) - assert @alice.kittens.include?(@chloe) - assert_equal 3, @alice.kittens.size - end - - def test_child_of_polymorphic_join_can_reach_parent - @alice.enemies << @spot - @alice.reload - assert @spot.protectors.include?(@alice) - end - - def test_double_collection_deletion_from_child_polymorphic_join - @alice.enemies << @spot - @spot.protectors.delete(@alice) - assert !@spot.protectors.include?(@alice) - @alice.reload - assert !@alice.enemies.include?(@spot) - BeautifulFightRelationship.create(:protector_id => 2, :protector_type => "Dog", :enemy_id => @spot.id, :enemy_type => @spot.class.name) - @alice.enemies << @spot - @spot.protectors.delete(@alice) - assert !@spot.protectors.include?(@alice) - end - - def test_collection_query_on_unsaved_record - assert Dog.new.enemies.empty? - assert Dog.new.foodstuffs_of_eaters.empty? - end - - def test_double_individual_collections_push - assert_equal [@chloe], (@spot.protector_kittens << @chloe) - @spot.reload - assert @spot.protectors.include?(@chloe) - assert @spot.protector_kittens.include?(@chloe) - assert !@spot.protector_dogs.include?(@chloe) - - assert_equal [@froggy], (@spot.frogs << @froggy) - @spot.reload - assert @spot.enemies.include?(@froggy) - assert @spot.frogs.include?(@froggy) - assert !@spot.enemy_dogs.include?(@froggy) - end - - def test_double_individual_collections_delete - @spot.protectors << [@chloe, @puma] - @spot.reload - assert_equal [@chloe], @spot.protector_kittens.delete(@chloe) - assert @spot.protector_kittens.empty? - @spot.protector_kittens.delete(@chloe) # again, unclear what .delete should return - - @spot.reload - assert @spot.protector_kittens.empty? - assert @spot.wild_boars.include?(@puma) - end - - def test_double_individual_collections_clear - @spot.protectors << [@chloe, @puma, @alice] - @spot.reload - assert_equal [], @spot.protector_kittens.clear - assert @spot.protector_kittens.empty? - assert_equal 1, @spot.protectors.size - @spot.reload - assert @spot.protector_kittens.empty? - assert_equal 1, @spot.protectors.size - assert !@spot.protector_kittens.include?(@chloe) - assert !@spot.protectors.include?(@chloe) - assert !@spot.protector_kittens.include?(@alice) - assert !@spot.protectors.include?(@alice) - assert @spot.protectors.include?(@puma) - assert @spot.wild_boars.include?(@puma) - end - - def test_single_extensions - assert_equal :correct_block_result, @shamu.aquatic_pupils.a_method - @kibbles.eaters.push(@alice) - @kibbles.eaters.push(@spot) - assert_equal :correct_join_result, @kibbles.eaters_foodstuffs.a_method - assert_equal :correct_module_result, @kibbles.eaters.a_method - assert_equal :correct_other_module_result, @kibbles.eaters.another_method - @kibbles.eaters.each do |eater| - assert_equal :correct_join_result, eater.eaters_foodstuffs.a_method - end - assert_equal :correct_parent_proc_result, @kibbles.foodstuffs_of_eaters.a_method - assert_equal :correct_parent_proc_result, @kibbles.eaters.first.foodstuffs_of_eaters.a_method - end - - def test_double_extensions - assert_equal :correct_proc_result, @spot.protectors.a_method - assert_equal :correct_module_result, @spot.enemies.a_method - assert_equal :correct_join_result, @spot.beautiful_fight_relationships_as_enemy.a_method - assert_equal :correct_join_result, @spot.beautiful_fight_relationships_as_protector.a_method - assert_equal :correct_join_result, @froggy.beautiful_fight_relationships.a_method - assert_equal :correct_join_result, @froggy.beautiful_fight_relationships_as_enemy.a_method - assert_raises(NoMethodError) {@froggy.beautiful_fight_relationships_as_protector.a_method} - end - - def test_pluralization_checks - assert_raises(@association_error) { - eval "class SomeModel < ActiveRecord::Base - has_many_polymorphs :polymorphs, :from => [:dog, :cats] - end" } - assert_raises(@association_error) { - eval "class SomeModel < ActiveRecord::Base - has_many_polymorphs :polymorph, :from => [:dogs, :cats] - end" } - assert_raises(@association_error) { - eval "class SomeModel < ActiveRecord::Base - acts_as_double_polymorphic_join :polymorph => [:dogs, :cats], :unimorphs => [:dogs, :cats] - end" } - end - - def test_error_message_on_namespaced_targets - assert_raises(@association_error) { - eval "class SomeModel < ActiveRecord::Base - has_many_polymorphs :polymorphs, :from => [:fish] - end" } - end - - def test_single_custom_finders - [@kibbles, @alice, @puma, @spot, @bits].each {|record| @kibbles.eaters << record; sleep 1} # XXX yeah i know - assert_equal @kibbles.eaters, @kibbles.eaters.find(:all, :order => "eaters_foodstuffs.created_at ASC") - assert_equal @kibbles.eaters.reverse, @kibbles.eaters.find(:all, :order => "eaters_foodstuffs.created_at DESC") - if (ActiveRecord::Base.connection.is_a? ActiveRecord::ConnectionAdapters::MysqlAdapter rescue false) - assert_equal @kibbles.eaters.sort_by(&:created_at), @kibbles.eaters.find(:all, :order => "IFNULL(bow_wows.created_at,(IFNULL(petfoods.created_at,(IFNULL(wild_boars.created_at,(IFNULL(cats.created_at,fish.created_at))))))) ASC") - end - assert_equal @kibbles.eaters.select{|x| x.is_a? Petfood}, @kibbles.eater_petfoods.find(:all, :order => "eaters_foodstuffs.created_at ASC") - end - - def test_double_custom_finders - @spot.protectors << [@chloe, @puma, @alice] - assert_equal [@chloe], @spot.protectors.find(:all, :conditions => ["cats.name = ?", @chloe.name], :limit => 1) - assert_equal [], @spot.protectors.find(:all, :conditions => ["cats.name = ?", @chloe.name], :limit => 1, :offset => 1) - assert_equal 2, @spot.protectors.find(:all, :limit => 100, :offset => 1).size - end - - def test_single_custom_finder_parameters_carry_to_individual_relationships - # XXX test nullout here - end - - def test_double_custom_finder_parameters_carry_to_individual_relationships - # XXX test nullout here - end - - def test_include_doesnt_fail - assert_nothing_raised do - @spot.protectors.find(:all, :include => :wild_boars) - end - end - - def test_abstract_method - assert_equal :correct_abstract_method_response, @spot.an_abstract_method - end - - def test_missing_target_should_raise - @kibbles.eaters << [@kibbles, @alice, @puma, @spot, @bits] - @spot.destroy_without_callbacks - assert_raises(@association_error) { @kibbles.eaters.reload } -# assert_raises(@association_error) { @kibbles.eater_dogs.reload } # bah AR - end - - def test_lazy_loading_is_lazy - # XXX - end - - def test_push_with_skip_duplicates_false_doesnt_load_target - # Loading kibbles locally again because setup calls .size which loads target - kibbles = Petfood.find(1) - assert !kibbles.eaters.loaded? - assert !(kibbles.eater_dogs << Dog.create!(:name => "Mongy")).loaded? - assert !kibbles.eaters.loaded? - end - - def test_association_foreign_key_is_sane - assert_equal "eater_id", Petfood.reflect_on_association(:eaters).association_foreign_key - end - - def test_reflection_instance_methods_are_sane - assert_equal EatersFoodstuff, Petfood.reflect_on_association(:eaters).klass - assert_equal EatersFoodstuff.name, Petfood.reflect_on_association(:eaters).class_name - end - - def test_parent_order - @alice.foodstuffs_of_eaters << Petfood.find(:all, :order => "the_petfood_primary_key ASC") - @alice.reload #not necessary - assert_equal [2,1], @alice.foodstuffs_of_eaters.map(&:id) - end - - def test_parent_conditions - @kibbles.eaters << @alice - assert_equal [@alice], @kibbles.eaters - - @snausages = Petfood.create(:name => 'Snausages') - @snausages.eaters << @alice - assert_equal [@alice], @snausages.eaters - - assert_equal [@kibbles], @alice.foodstuffs_of_eaters - end - - def test_self_referential_hmp_with_conditions - p = Person.find(:first) - kid = Person.create(:name => "Tim", :age => 3) - p.kids << kid - - kid.reload; p.reload - - # assert_equal [p], kid.parents - # assert Rails.has_one? Bug - # non-standard foreign_type key is not set properly when you are the polymorphic interface of a has_many going to a :through - - assert_equal [kid], p.kids - assert_equal [kid], p.people - end - -# def test_polymorphic_include -# @kibbles.eaters << [@kibbles, @alice, @puma, @spot, @bits] -# assert @kibbles.eaters.include?(@kibbles.eaters_foodstuffs.find(:all, :include => :eater).first.eater) -# end -# -# def test_double_polymorphic_include -# end -# -# def test_single_child_include -# end -# -# def test_double_child_include -# end -# -# def test_single_include_from_parent -# end -# -# def test_double_include_from_parent -# end -# -# def test_meta_referential_single_include -# end -# -# def test_meta_referential_double_include -# end -# -# def test_meta_referential_single_include -# end -# -# def test_meta_referential_single_double_multi_include -# end -# -# def test_dont_ignore_duplicates -# end -# -# def test_ignore_duplicates -# end -# -# def test_tagging_system_generator -# end -# -# def test_tagging_system_library -# end - -end diff --git a/vendor/gems/highline-1.5.0/.specification b/vendor/gems/highline-1.5.0/.specification deleted file mode 100644 index 2ebbb33c..00000000 --- a/vendor/gems/highline-1.5.0/.specification +++ /dev/null @@ -1,87 +0,0 @@ ---- !ruby/object:Gem::Specification -name: highline -version: !ruby/object:Gem::Version - version: 1.5.0 -platform: ruby -authors: -- James Edward Gray II -autorequire: -bindir: bin -cert_chain: [] - -date: 2008-11-05 00:00:00 +01:00 -default_executable: -dependencies: [] - -description: A high-level IO library that provides validation, type conversion, and more for command-line interfaces. HighLine also includes a complete menu system that can crank out anything from simple list selection to complete shells with just minutes of work. -email: james@grayproductions.net -executables: [] - -extensions: [] - -extra_rdoc_files: -- README -- INSTALL -- TODO -- CHANGELOG -- LICENSE -files: -- examples/ansi_colors.rb -- examples/asking_for_arrays.rb -- examples/basic_usage.rb -- examples/color_scheme.rb -- examples/menus.rb -- examples/overwrite.rb -- examples/page_and_wrap.rb -- examples/password.rb -- examples/trapping_eof.rb -- examples/using_readline.rb -- lib/highline/color_scheme.rb -- lib/highline/import.rb -- lib/highline/menu.rb -- lib/highline/question.rb -- lib/highline/system_extensions.rb -- lib/highline.rb -- test/tc_color_scheme.rb -- test/tc_highline.rb -- test/tc_import.rb -- test/tc_menu.rb -- test/ts_all.rb -- Rakefile -- setup.rb -- README -- INSTALL -- TODO -- CHANGELOG -- LICENSE -has_rdoc: true -homepage: http://highline.rubyforge.org -post_install_message: -rdoc_options: -- --title -- HighLine Documentation -- --main -- README -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: highline -rubygems_version: 1.3.1 -signing_key: -specification_version: 2 -summary: HighLine is a high-level command-line IO library. -test_files: -- test/ts_all.rb diff --git a/vendor/gems/highline-1.5.0/CHANGELOG b/vendor/gems/highline-1.5.0/CHANGELOG deleted file mode 100644 index 3d04911e..00000000 --- a/vendor/gems/highline-1.5.0/CHANGELOG +++ /dev/null @@ -1,211 +0,0 @@ -= Change Log - -Below is a complete listing of changes for each revision of HighLine. - -== 1.5.0 - -* Fixed a bug that would prevent Readline from showing all completions. - (reported by Yaohan Chen) -* Added the ability to pass a block to HighLine#agree(). - (patch by Yaohan Chen) - -== 1.4.0 - -* Made the code grabbing terminal size a little more cross-platform by - adding support for Solaris. (patch by Ronald Braswell and Coey Minear) - -== 1.2.9 - -* Additional work on the backspacing issue. (patch by Jeremy Hinegardner) -* Fixed Readline prompt bug. (patch by Jeremy Hinegardner) - -== 1.2.8 - -* Fixed backspacing past the prompt and interrupting a prompt bugs. - (patch by Jeremy Hinegardner) - -== 1.2.7 - -* Fixed the stty indent bug. -* Fixed the echo backspace bug. -* Added HighLine::track_eof=() setting to work are threaded eof?() calls. - -== 1.2.6 - -Patch by Jeremy Hinegardner: - -* Added ColorScheme support. -* Added HighLine::Question.overwrite mode. -* Various documentation fixes. - -== 1.2.5 - -* Really fixed the bug I tried to fix in 1.2.4. - -== 1.2.4 - -* Fixed a crash causing bug when using menus, reported by Patrick Hof. - -== 1.2.3 - -* Treat Cygwin like a Posix OS, instead of a native Windows environment. - -== 1.2.2 - -* Minor documentation corrections. -* Applied Thomas Werschleiln's patch to fix termio buffering on Solaris. -* Applied Justin Bailey's patch to allow canceling paged output. -* Fixed a documentation bug in the description of character case settings. -* Added a notice about termios in HighLine::Question#echo. -* Finally working around the infamous "fast typing" bug - -== 1.2.1 - -* Applied Justin Bailey's fix for the page_print() infinite loop bug. -* Made a SystemExtensions module to expose OS level functionality other - libraries may want to access. -* Publicly exposed the get_character() method, per user requests. -* Added terminal_size(), output_cols(), and output_rows() methods. -* Added :auto setting for warp_at=() and page_at=(). - -== 1.2.0 - -* Improved RubyForge and gem spec project descriptions. -* Added basic examples to README. -* Added a VERSION constant. -* Added support for hidden menu commands. -* Added Object.or_ask() when using highline/import. - -== 1.0.4 - -* Moved the HighLine project to Subversion. -* HighLine's color escapes can now be disabled. -* Fixed EOF bug introduced in the last release. -* Updated HighLine web page. -* Moved to a forked development/stable version numbering. - -== 1.0.2 - -* Removed old and broken help tests. -* Fixed test case typo found by David A. Black. -* Added ERb escapes processing to lists, for coloring list items. Color escapes - do not add to list element size. -* HighLine now throws EOFError when input is exhausted. - -== 1.0.1 - -* Minor bug fix: Moved help initialization to before response building, so help - would show up in the default responses. - -== 1.0.0 - -* Fixed documentation typo pointed out by Gavin Kistner. -* Added gather = ... option to question for fetching entire Arrays or - Hashes filled with answers. You can set +gather+ to a count of answers to - collect, a String or Regexp matching the end of input, or a Hash where each - key can be used in a new question. -* Added File support to HighLine.ask(). You can specify a _directory_ and a - _glob_ pattern that combine into a list of file choices the user can select - from. You can choose to receive the user's answer as an open filehandle or as - a Pathname object. -* Added Readline support for history and editing. -* Added tab completion for menu and file selection selection (requires - Readline). -* Added an optional character limit for input. -* Added a complete help system to HighLine's shell menu creation tools. - -== 0.6.1 - -* Removed termios dependancy in gem, to fix Windows' install. - -== 0.6.0 - -* Implemented HighLine.choose() for menu handling. - * Provided shortcut choose(item1, item2, ...) for simple menus. - * Allowed Ruby code to be attached to each menu item, to create a complete - menu solution. - * Provided for total customization of the menu layout. - * Allowed for menu selection by index, name or both. - * Added a _shell_ mode to allow menu selection with additional details - following the name. -* Added a list() utility method that can be invoked just like color(). It can - layout Arrays for you in any output in the modes :columns_across, - :columns_down, :inline and :rows -* Added support for echo = "*" style settings. User code can now - choose the echo character this way. -* Modified HighLine to user the "termios" library for character input, if - available. Will return to old behavior (using "stty"), if "termios" cannot be - loaded. -* Improved "stty" state restoring code. -* Fixed "stty" code to handle interrupt signals. -* Improved the default auto-complete error message and exposed this message - through the +responses+ interface as :no_completion. - -== 0.5.0 - -* Implemented echo = false for HighLine::Question objects, primarily to - make fetching passwords trivial. -* Fixed an auto-complete bug that could cause a crash when the user gave an - answer that didn't complete to any valid choice. -* Implemented +case+ for HighLine::Question objects to provide character case - conversions on given answers. Can be set to :up, :down, or - :capitalize. -* Exposed @answer to the response system, to allow response that are - aware of incorrect input. -* Implemented +confirm+ for HighLine::Question objects to allow for verification - for sensitive user choices. If set to +true+, user will have to answer an - "Are you sure? " question. Can also be set to the question to confirm with - the user. - -== 0.4.0 - -* Added @wrap_at and @page_at settings and accessors to - HighLine, to control text flow. -* Implemented line wrapping with adjustable limit. -* Implemented paged printing with adjustable limit. - -== 0.3.0 - -* Added support for installing with setup.rb. -* All output is now treated as an ERb sequence, allowing Ruby code to be - embedded in output strings. -* Added support for ANSI color sequences in say(). (And everything else - by extension.) -* Added whitespace handling for answers. Can be set to :strip, - :chomp, :collapse, :strip_and_collapse, - :chomp_and_collapse, :remove, or :none. -* Exposed question details to ERb completion through @question, to allow for - intelligent responses. -* Simplified HighLine internals using @question. -* Added support for fetching single character input either with getc() or - HighLine's own cross-platform terminal input routine. -* Improved type conversion to handle user defined classes. - -== 0.2.0 - -* Added Unit Tests to cover an already fixed output bug in the future. -* Added Rakefile and setup test action (default). -* Renamed HighLine::Answer to HighLine::Question to better illustrate its role. -* Renamed fetch_line() to get_response() to better define its goal. -* Simplified explain_error in terms of the Question object. -* Renamed accept?() to in_range?() to better define purpose. -* Reworked valid?() into valid_answer?() to better fit Question object. -* Reworked @member into @in, to make it easier to remember and - switched implementation to include?(). -* Added range checks for @above and @below. -* Fixed the bug causing ask() to swallow NoMethodErrors. -* Rolled ask_on_error() into responses. -* Redirected imports to Kernel from Object. -* Added support for validate = lambda { ... }. -* Added default answer support. -* Fixed bug that caused ask() to die with an empty question. -* Added complete documentation. -* Improve the implemetation of agree() to be the intended "yes" or "no" only - question. -* Added Rake tasks for documentation and packaging. -* Moved project to RubyForge. - -== 0.1.0 - -* Initial release as the solution to - {Ruby Quiz #29}[http://www.rubyquiz.com/quiz29.html]. diff --git a/vendor/gems/highline-1.5.0/INSTALL b/vendor/gems/highline-1.5.0/INSTALL deleted file mode 100644 index c22f0414..00000000 --- a/vendor/gems/highline-1.5.0/INSTALL +++ /dev/null @@ -1,35 +0,0 @@ -= Installing HighLine - -RubyGems is the preferred easy install method for HighLine. However, you can -install HighLine manually as described below. - -== Installing the Gem - -HighLine is intended to be installed via the -RubyGems[http://rubyforge.org/projects/rubygems/] system. To get the latest -version, simply enter the following into your command prompt: - - $ sudo gem install highline - -You must have RubyGems[http://rubyforge.org/projects/rubygems/] installed for -the above to work. - -== Installing Manually - -Download the latest version of HighLine from the -{RubyForge project page}[http://rubyforge.org/frs/?group_id=683]. Navigate to -the root project directory and enter: - - $ sudo ruby setup.rb - -== Using termios - -While not a requirement, HighLine will take advantage of the termios library if -installed (on Unix). This slightly improves HighLine's character reading -capabilities and thus is recommended for all Unix users. - -If using the HighLine gem, you should be able to add termios as easily as: - - $ sudo gem install termios - -For manual installs, consult the termios documentation. diff --git a/vendor/gems/highline-1.5.0/LICENSE b/vendor/gems/highline-1.5.0/LICENSE deleted file mode 100644 index ff6f232c..00000000 --- a/vendor/gems/highline-1.5.0/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -= License Terms - -Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the -{Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt] by -James Edward Gray II and Greg Brown. - -Please email James[mailto:james@grayproductions.net] with any questions. diff --git a/vendor/gems/highline-1.5.0/README b/vendor/gems/highline-1.5.0/README deleted file mode 100644 index f28478bb..00000000 --- a/vendor/gems/highline-1.5.0/README +++ /dev/null @@ -1,63 +0,0 @@ -= Read Me - -by James Edward Gray II - -== Description - -Welcome to HighLine. - -HighLine was designed to ease the tedious tasks of doing console input and -output with low-level methods like gets() and puts(). HighLine provides a -robust system for requesting data from a user, without needing to code all the -error checking and validation rules and without needing to convert the typed -Strings into what your program really needs. Just tell HighLine what you're -after, and let it do all the work. - -== Documentation - -See HighLine and HighLine::Question for documentation. - -== Examples - -Basic usage: - - ask("Company? ") { |q| q.default = "none" } - -Validation: - - ask("Age? ", Integer) { |q| q.in = 0..105 } - ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ } - -Type conversion for answers: - - ask("Birthday? ", Date) - ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) }) - -Reading passwords: - - ask("Enter your password: ") { |q| q.echo = false } - ask("Enter your password: ") { |q| q.echo = "x" } - -ERb based output (with HighLine's ANSI color tools): - - say("This should be <%= color('bold', BOLD) %>!") - -Menus: - - choose do |menu| - menu.prompt = "Please choose your favorite programming language? " - - menu.choice(:ruby) { say("Good choice!") } - menu.choices(:python, :perl) { say("Not from around here, are you?") } - end - -For more examples see the examples/ directory of this project. - -== Installing - -See the INSTALL file for instructions. - -== Questions and/or Comments - -Feel free to email {James Edward Gray II}[mailto:james@grayproductions.net] or -{Gregory Brown}[mailto:gregory.t.brown@gmail.com] with any questions. diff --git a/vendor/gems/highline-1.5.0/Rakefile b/vendor/gems/highline-1.5.0/Rakefile deleted file mode 100644 index 26a68f00..00000000 --- a/vendor/gems/highline-1.5.0/Rakefile +++ /dev/null @@ -1,82 +0,0 @@ -require "rake/rdoctask" -require "rake/testtask" -require "rake/gempackagetask" - -require "rubygems" - -dir = File.dirname(__FILE__) -lib = File.join(dir, "lib", "highline.rb") -version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d\.\d\.\d)\1/, 2] - -task :default => [:test] - -Rake::TestTask.new do |test| - test.libs << "test" - test.test_files = [ "test/ts_all.rb" ] - test.verbose = true -end - -Rake::RDocTask.new do |rdoc| - rdoc.rdoc_files.include( "README", "INSTALL", - "TODO", "CHANGELOG", - "AUTHORS", "COPYING", - "LICENSE", "lib/" ) - rdoc.main = "README" - rdoc.rdoc_dir = "doc/html" - rdoc.title = "HighLine Documentation" -end - -desc "Upload current documentation to Rubyforge" -task :upload_docs => [:rdoc] do - sh "scp -r doc/html/* " + - "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/doc/" - sh "scp -r site/* " + - "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/" -end - -spec = Gem::Specification.new do |spec| - spec.name = "highline" - spec.version = version - spec.platform = Gem::Platform::RUBY - spec.summary = "HighLine is a high-level command-line IO library." - spec.files = Dir.glob("{examples,lib,test}/**/*.rb"). - delete_if { |item| item.include?("CVS") } + - ["Rakefile", "setup.rb"] - - spec.test_suite_file = "test/ts_all.rb" - spec.has_rdoc = true - spec.extra_rdoc_files = %w{README INSTALL TODO CHANGELOG LICENSE} - spec.rdoc_options << '--title' << 'HighLine Documentation' << - '--main' << 'README' - - spec.require_path = 'lib' - - spec.author = "James Edward Gray II" - spec.email = "james@grayproductions.net" - spec.rubyforge_project = "highline" - spec.homepage = "http://highline.rubyforge.org" - spec.description = <!") - if i == 0 - say( "This should be " + - "<%= color('white on #{c}', :white, :on_#{c}) %>!") - else - say( "This should be " + - "<%= color( '#{colors[i - 1]} on #{c}', - :#{colors[i - 1]}, :on_#{c} ) %>!") - end -end - -# Using color with constants. -say("This should be <%= color('bold', BOLD) %>!") -say("This should be <%= color('underlined', UNDERLINE) %>!") - -# Using constants only. -say("This might even <%= BLINK %>blink<%= CLEAR %>!") - -# It even works with list wrapping. -erb_digits = %w{Zero One Two Three Four} + - ["<%= color('Five', :blue) %%>"] + - %w{Six Seven Eight Nine} -say("<%= list(#{erb_digits.inspect}, :columns_down, 3) %>") diff --git a/vendor/gems/highline-1.5.0/examples/asking_for_arrays.rb b/vendor/gems/highline-1.5.0/examples/asking_for_arrays.rb deleted file mode 100644 index 6c62a0e4..00000000 --- a/vendor/gems/highline-1.5.0/examples/asking_for_arrays.rb +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/local/bin/ruby -w - -# asking_for_arrays.rb -# -# Created by James Edward Gray II on 2005-07-05. -# Copyright 2005 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" -require "pp" - -grades = ask( "Enter test scores (or a blank line to quit):", - lambda { |ans| ans =~ /^-?\d+$/ ? Integer(ans) : ans} ) do |q| - q.gather = "" -end - -say("Grades:") -pp grades diff --git a/vendor/gems/highline-1.5.0/examples/basic_usage.rb b/vendor/gems/highline-1.5.0/examples/basic_usage.rb deleted file mode 100644 index 60ecdc18..00000000 --- a/vendor/gems/highline-1.5.0/examples/basic_usage.rb +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/local/bin/ruby -w - -# basic_usage.rb -# -# Created by James Edward Gray II on 2005-04-28. -# Copyright 2005 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" -require "yaml" - -contacts = [ ] - -class NameClass - def self.parse( string ) - if string =~ /^\s*(\w+),\s*(\w+)\s*$/ - self.new($2, $1) - else - raise ArgumentError, "Invalid name format." - end - end - - def initialize(first, last) - @first, @last = first, last - end - - attr_reader :first, :last -end - -begin - entry = Hash.new - - # basic output - say("Enter a contact:") - - # basic input - entry[:name] = ask("Name? (last, first) ", NameClass) do |q| - q.validate = /\A\w+, ?\w+\Z/ - end - entry[:company] = ask("Company? ") { |q| q.default = "none" } - entry[:address] = ask("Address? ") - entry[:city] = ask("City? ") - entry[:state] = ask("State? ") do |q| - q.case = :up - q.validate = /\A[A-Z]{2}\Z/ - end - entry[:zip] = ask("Zip? ") do |q| - q.validate = /\A\d{5}(?:-?\d{4})?\Z/ - end - entry[:phone] = ask( "Phone? ", - lambda { |p| p.delete("^0-9"). - sub(/\A(\d{3})/, '(\1) '). - sub(/(\d{4})\Z/, '-\1') } ) do |q| - q.validate = lambda { |p| p.delete("^0-9").length == 10 } - q.responses[:not_valid] = "Enter a phone numer with area code." - end - entry[:age] = ask("Age? ", Integer) { |q| q.in = 0..105 } - entry[:birthday] = ask("Birthday? ", Date) - entry[:interests] = ask( "Interests? (comma separated list) ", - lambda { |str| str.split(/,\s*/) } ) - entry[:description] = ask("Enter a description for this contact.") do |q| - q.whitespace = :strip_and_collapse - end - - contacts << entry -# shortcut for yes and no questions -end while agree("Enter another contact? ", true) - -if agree("Save these contacts? ", true) - file_name = ask("Enter a file name: ") do |q| - q.validate = /\A\w+\Z/ - q.confirm = true - end - File.open("#{file_name}.yaml", "w") { |file| YAML.dump(contacts, file) } -end diff --git a/vendor/gems/highline-1.5.0/examples/color_scheme.rb b/vendor/gems/highline-1.5.0/examples/color_scheme.rb deleted file mode 100644 index 6d1e0a76..00000000 --- a/vendor/gems/highline-1.5.0/examples/color_scheme.rb +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env ruby -w - -# color_scheme.rb -# -# Created by Jeremy Hinegardner on 2007-01-24 -# Copyright 2007 Jeremy Hinegardner. All rights reserved - -require 'rubygems' -require 'highline/import' - -# Create a color scheme, naming color patterns with symbol names. -ft = HighLine::ColorScheme.new do |cs| - cs[:headline] = [ :bold, :yellow, :on_black ] - cs[:horizontal_line] = [ :bold, :white, :on_blue] - cs[:even_row] = [ :green ] - cs[:odd_row] = [ :magenta ] - end - -# Assign that color scheme to HighLine... -HighLine.color_scheme = ft - -# ...and use it. -say("<%= color('Headline', :headline) %>") -say("<%= color('-'*20, :horizontal_line) %>") - -# Setup a toggle for rows. -i = true -("A".."D").each do |row| - row_color = i ? :even_row : :odd_row - say("<%= color('#{row}', '#{row_color}') %>") - i = !i -end diff --git a/vendor/gems/highline-1.5.0/examples/menus.rb b/vendor/gems/highline-1.5.0/examples/menus.rb deleted file mode 100644 index e31c11df..00000000 --- a/vendor/gems/highline-1.5.0/examples/menus.rb +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/local/bin/ruby -w - -require "rubygems" -require "highline/import" - -# The old way, using ask() and say()... -choices = %w{ruby python perl} -say("This is the old way using ask() and say()...") -say("Please choose your favorite programming language:") -say(choices.map { |c| " #{c}\n" }.join) - -case ask("? ", choices) -when "ruby" - say("Good choice!") -else - say("Not from around here, are you?") -end - -# The new and improved choose()... -say("\nThis is the new mode (default)...") -choose do |menu| - menu.prompt = "Please choose your favorite programming language? " - - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end -end - -say("\nThis is letter indexing...") -choose do |menu| - menu.index = :letter - menu.index_suffix = ") " - - menu.prompt = "Please choose your favorite programming language? " - - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end -end - -say("\nThis is with a different layout...") -choose do |menu| - menu.layout = :one_line - - menu.header = "Languages" - menu.prompt = "Favorite? " - - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end -end - -say("\nYou can even build shells...") -loop do - choose do |menu| - menu.layout = :menu_only - - menu.shell = true - - menu.choice(:load, "Load a file.") do |command, details| - say("Loading file with options: #{details}...") - end - menu.choice(:save, "Save a file.") do |command, details| - say("Saving file with options: #{details}...") - end - menu.choice(:quit, "Exit program.") { exit } - end -end diff --git a/vendor/gems/highline-1.5.0/examples/overwrite.rb b/vendor/gems/highline-1.5.0/examples/overwrite.rb deleted file mode 100644 index 1ca2db52..00000000 --- a/vendor/gems/highline-1.5.0/examples/overwrite.rb +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/local/bin/ruby -w - -# overwrite.rb -# -# Created by Jeremy Hinegardner on 2007-01-24 -# Copyright 2007 Jeremy Hinegardner. All rights reserved - -require 'rubygems' -require 'highline/import' - -prompt = "here is your password:" -ask( - "#{prompt} <%= color('mypassword', RED, BOLD) %> (Press Any Key to blank) " -) do |q| - q.overwrite = true - q.echo = false # overwrite works best when echo is false. - q.character = true # if this is set to :getc then overwrite does not work -end -say("<%= color('Look! blanked out!', GREEN) %>") diff --git a/vendor/gems/highline-1.5.0/examples/page_and_wrap.rb b/vendor/gems/highline-1.5.0/examples/page_and_wrap.rb deleted file mode 100644 index 3209a4ab..00000000 --- a/vendor/gems/highline-1.5.0/examples/page_and_wrap.rb +++ /dev/null @@ -1,322 +0,0 @@ -#!/usr/local/bin/ruby -w - -# page_and_wrap.rb -# -# Created by James Edward Gray II on 2005-05-07. -# Copyright 2005 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" - -$terminal.wrap_at = 80 -$terminal.page_at = 22 - -say(<@question is set before ask() is called, parameters are - # ignored and that object (must be a HighLine::Question) is used to drive - # the process instead. - # - # Raises EOFError if input is exhausted. - # - def ask( question, answer_type = String, &details ) # :yields: question - @question ||= Question.new(question, answer_type, &details) - - return gather if @question.gather - - # readline() needs to handle it's own output, but readline only supports - # full line reading. Therefore if @question.echo is anything but true, - # the prompt will not be issued. And we have to account for that now. - say(@question) unless (@question.readline and @question.echo == true) - begin - @answer = @question.answer_or_default(get_response) - unless @question.valid_answer?(@answer) - explain_error(:not_valid) - raise QuestionError - end - - @answer = @question.convert(@answer) - - if @question.in_range?(@answer) - if @question.confirm - # need to add a layer of scope to ask a question inside a - # question, without destroying instance data - context_change = self.class.new(@input, @output, @wrap_at, @page_at) - if @question.confirm == true - confirm_question = "Are you sure? " - else - # evaluate ERb under initial scope, so it will have - # access to @question and @answer - template = ERB.new(@question.confirm, nil, "%") - confirm_question = template.result(binding) - end - unless context_change.agree(confirm_question) - explain_error(nil) - raise QuestionError - end - end - - @answer - else - explain_error(:not_in_range) - raise QuestionError - end - rescue QuestionError - retry - rescue ArgumentError - explain_error(:invalid_type) - retry - rescue Question::NoAutoCompleteMatch - explain_error(:no_completion) - retry - rescue NameError - raise if $!.is_a?(NoMethodError) - explain_error(:ambiguous_completion) - retry - ensure - @question = nil # Reset Question object. - end - end - - # - # This method is HighLine's menu handler. For simple usage, you can just - # pass all the menu items you wish to display. At that point, choose() will - # build and display a menu, walk the user through selection, and return - # their choice amoung the provided items. You might use this in a case - # statement for quick and dirty menus. - # - # However, choose() is capable of much more. If provided, a block will be - # passed a HighLine::Menu object to configure. Using this method, you can - # customize all the details of menu handling from index display, to building - # a complete shell-like menuing system. See HighLine::Menu for all the - # methods it responds to. - # - # Raises EOFError if input is exhausted. - # - def choose( *items, &details ) - @menu = @question = Menu.new(&details) - @menu.choices(*items) unless items.empty? - - # Set _answer_type_ so we can double as the Question for ask(). - @menu.answer_type = if @menu.shell - lambda do |command| # shell-style selection - first_word = command.to_s.split.first || "" - - options = @menu.options - options.extend(OptionParser::Completion) - answer = options.complete(first_word) - - if answer.nil? - raise Question::NoAutoCompleteMatch - end - - [answer.last, command.sub(/^\s*#{first_word}\s*/, "")] - end - else - @menu.options # normal menu selection, by index or name - end - - # Provide hooks for ERb layouts. - @header = @menu.header - @prompt = @menu.prompt - - if @menu.shell - selected = ask("Ignored", @menu.answer_type) - @menu.select(self, *selected) - else - selected = ask("Ignored", @menu.answer_type) - @menu.select(self, selected) - end - end - - # - # This method provides easy access to ANSI color sequences, without the user - # needing to remember to CLEAR at the end of each sequence. Just pass the - # _string_ to color, followed by a list of _colors_ you would like it to be - # affected by. The _colors_ can be HighLine class constants, or symbols - # (:blue for BLUE, for example). A CLEAR will automatically be embedded to - # the end of the returned String. - # - # This method returns the original _string_ unchanged if HighLine::use_color? - # is +false+. - # - def color( string, *colors ) - return string unless self.class.use_color? - - colors.map! do |c| - if self.class.using_color_scheme? and self.class.color_scheme.include? c - self.class.color_scheme[c] - elsif c.is_a? Symbol - self.class.const_get(c.to_s.upcase) - else - c - end - end - "#{colors.flatten.join}#{string}#{CLEAR}" - end - - # - # This method is a utility for quickly and easily laying out lists. It can - # be accessed within ERb replacements of any text that will be sent to the - # user. - # - # The only required parameter is _items_, which should be the Array of items - # to list. A specified _mode_ controls how that list is formed and _option_ - # has different effects, depending on the _mode_. Recognized modes are: - # - # :columns_across:: _items_ will be placed in columns, flowing - # from left to right. If given, _option_ is the - # number of columns to be used. When absent, - # columns will be determined based on _wrap_at_ - # or a default of 80 characters. - # :columns_down:: Identical to :columns_across, save - # flow goes down. - # :inline:: All _items_ are placed on a single line. The - # last two _items_ are separated by _option_ or - # a default of " or ". All other _items_ are - # separated by ", ". - # :rows:: The default mode. Each of the _items_ is - # placed on it's own line. The _option_ - # parameter is ignored in this mode. - # - # Each member of the _items_ Array is passed through ERb and thus can contain - # their own expansions. Color escape expansions do not contribute to the - # final field width. - # - def list( items, mode = :rows, option = nil ) - items = items.to_ary.map do |item| - ERB.new(item, nil, "%").result(binding) - end - - case mode - when :inline - option = " or " if option.nil? - - case items.size - when 0 - "" - when 1 - items.first - when 2 - "#{items.first}#{option}#{items.last}" - else - items[0..-2].join(", ") + "#{option}#{items.last}" - end - when :columns_across, :columns_down - max_length = actual_length( - items.max { |a, b| actual_length(a) <=> actual_length(b) } - ) - - if option.nil? - limit = @wrap_at || 80 - option = (limit + 2) / (max_length + 2) - end - - items = items.map do |item| - pad = max_length + (item.length - actual_length(item)) - "%-#{pad}s" % item - end - row_count = (items.size / option.to_f).ceil - - if mode == :columns_across - rows = Array.new(row_count) { Array.new } - items.each_with_index do |item, index| - rows[index / option] << item - end - - rows.map { |row| row.join(" ") + "\n" }.join - else - columns = Array.new(option) { Array.new } - items.each_with_index do |item, index| - columns[index / row_count] << item - end - - list = "" - columns.first.size.times do |index| - list << columns.map { |column| column[index] }. - compact.join(" ") + "\n" - end - list - end - else - items.map { |i| "#{i}\n" }.join - end - end - - # - # The basic output method for HighLine objects. If the provided _statement_ - # ends with a space or tab character, a newline will not be appended (output - # will be flush()ed). All other cases are passed straight to Kernel.puts(). - # - # The _statement_ parameter is processed as an ERb template, supporting - # embedded Ruby code. The template is evaluated with a binding inside - # the HighLine instance, providing easy access to the ANSI color constants - # and the HighLine.color() method. - # - def say( statement ) - statement = statement.to_str - return unless statement.length > 0 - - template = ERB.new(statement, nil, "%") - statement = template.result(binding) - - statement = wrap(statement) unless @wrap_at.nil? - statement = page_print(statement) unless @page_at.nil? - - if statement[-1, 1] == " " or statement[-1, 1] == "\t" - @output.print(statement) - @output.flush - else - @output.puts(statement) - end - end - - # - # Set to an integer value to cause HighLine to wrap output lines at the - # indicated character limit. When +nil+, the default, no wrapping occurs. If - # set to :auto, HighLine will attempt to determing the columns - # available for the @output or use a sensible default. - # - def wrap_at=( setting ) - @wrap_at = setting == :auto ? output_cols : setting - end - - # - # Set to an integer value to cause HighLine to page output lines over the - # indicated line limit. When +nil+, the default, no paging occurs. If - # set to :auto, HighLine will attempt to determing the rows available - # for the @output or use a sensible default. - # - def page_at=( setting ) - @page_at = setting == :auto ? output_rows : setting - end - - # - # Returns the number of columns for the console, or a default it they cannot - # be determined. - # - def output_cols - return 80 unless @output.tty? - terminal_size.first - rescue - return 80 - end - - # - # Returns the number of rows for the console, or a default if they cannot be - # determined. - # - def output_rows - return 24 unless @output.tty? - terminal_size.last - rescue - return 24 - end - - private - - # - # A helper method for sending the output stream and error and repeat - # of the question. - # - def explain_error( error ) - say(@question.responses[error]) unless error.nil? - if @question.responses[:ask_on_error] == :question - say(@question) - elsif @question.responses[:ask_on_error] - say(@question.responses[:ask_on_error]) - end - end - - # - # Collects an Array/Hash full of answers as described in - # HighLine::Question.gather(). - # - # Raises EOFError if input is exhausted. - # - def gather( ) - @gather = @question.gather - @answers = [ ] - original_question = @question - - @question.gather = false - - case @gather - when Integer - @answers << ask(@question) - @gather -= 1 - - original_question.question = "" - until @gather.zero? - @question = original_question - @answers << ask(@question) - @gather -= 1 - end - when String, Regexp - @answers << ask(@question) - - original_question.question = "" - until (@gather.is_a?(String) and @answers.last.to_s == @gather) or - (@gather.is_a?(Regexp) and @answers.last.to_s =~ @gather) - @question = original_question - @answers << ask(@question) - end - - @answers.pop - when Hash - @answers = { } - @gather.keys.sort.each do |key| - @question = original_question - @key = key - @answers[key] = ask(@question) - end - end - - @answers - end - - # - # Read a line of input from the input stream and process whitespace as - # requested by the Question object. - # - # If Question's _readline_ property is set, that library will be used to - # fetch input. *WARNING*: This ignores the currently set input stream. - # - # Raises EOFError if input is exhausted. - # - def get_line( ) - if @question.readline - require "readline" # load only if needed - - # capture say()'s work in a String to feed to readline() - old_output = @output - @output = StringIO.new - say(@question) - question = @output.string - @output = old_output - - # prep auto-completion - Readline.completion_proc = lambda do |string| - @question.selection.grep(/\A#{Regexp.escape(string)}/) - end - - # work-around ugly readline() warnings - old_verbose = $VERBOSE - $VERBOSE = nil - answer = @question.change_case( - @question.remove_whitespace( - Readline.readline(question, true) ) ) - $VERBOSE = old_verbose - - answer - else - raise EOFError, "The input stream is exhausted." if @@track_eof and - @input.eof? - - @question.change_case(@question.remove_whitespace(@input.gets)) - end - end - - # - # Return a line or character of input, as requested for this question. - # Character input will be returned as a single character String, - # not an Integer. - # - # This question's _first_answer_ will be returned instead of input, if set. - # - # Raises EOFError if input is exhausted. - # - def get_response( ) - return @question.first_answer if @question.first_answer? - - if @question.character.nil? - if @question.echo == true and @question.limit.nil? - get_line - else - raw_no_echo_mode if stty = CHARACTER_MODE == "stty" - - line = "" - backspace_limit = 0 - begin - - while character = (stty ? @input.getc : get_character(@input)) - # honor backspace and delete - if character == 127 or character == 8 - line.slice!(-1, 1) - backspace_limit -= 1 - else - line << character.chr - backspace_limit = line.size - end - # looking for carriage return (decimal 13) or - # newline (decimal 10) in raw input - break if character == 13 or character == 10 or - (@question.limit and line.size == @question.limit) - if @question.echo != false - if character == 127 or character == 8 - # only backspace if we have characters on the line to - # eliminate, otherwise we'll tromp over the prompt - if backspace_limit >= 0 then - @output.print("\b#{ERASE_CHAR}") - else - # do nothing - end - else - @output.print(@question.echo) - end - @output.flush - end - end - ensure - restore_mode if stty - end - if @question.overwrite - @output.print("\r#{ERASE_LINE}") - @output.flush - else - say("\n") - end - - @question.change_case(@question.remove_whitespace(line)) - end - elsif @question.character == :getc - @question.change_case(@input.getc.chr) - else - response = get_character(@input).chr - if @question.overwrite - @output.print("\r#{ERASE_LINE}") - @output.flush - else - echo = if @question.echo == true - response - elsif @question.echo != false - @question.echo - else - "" - end - say("#{echo}\n") - end - @question.change_case(response) - end - end - - # - # Page print a series of at most _page_at_ lines for _output_. After each - # page is printed, HighLine will pause until the user presses enter/return - # then display the next page of data. - # - # Note that the final page of _output_ is *not* printed, but returned - # instead. This is to support any special handling for the final sequence. - # - def page_print( output ) - lines = output.scan(/[^\n]*\n?/) - while lines.size > @page_at - @output.puts lines.slice!(0...@page_at).join - @output.puts - # Return last line if user wants to abort paging - return (["...\n"] + lines.slice(-2,1)).join unless continue_paging? - end - return lines.join - end - - # - # Ask user if they wish to continue paging output. Allows them to type "q" to - # cancel the paging process. - # - def continue_paging? - command = HighLine.new(@input, @output).ask( - "-- press enter/return to continue or q to stop -- " - ) { |q| q.character = true } - command !~ /\A[qQ]\Z/ # Only continue paging if Q was not hit. - end - - # - # Wrap a sequence of _lines_ at _wrap_at_ characters per line. Existing - # newlines will not be affected by this process, but additional newlines - # may be added. - # - def wrap( lines ) - wrapped = [ ] - lines.each do |line| - while line =~ /([^\n]{#{@wrap_at + 1},})/ - search = $1.dup - replace = $1.dup - if index = replace.rindex(" ", @wrap_at) - replace[index, 1] = "\n" - replace.sub!(/\n[ \t]+/, "\n") - line.sub!(search, replace) - else - line[@wrap_at, 0] = "\n" - end - end - wrapped << line - end - return wrapped.join - end - - # - # Returns the length of the passed +string_with_escapes+, minus and color - # sequence escapes. - # - def actual_length( string_with_escapes ) - string_with_escapes.gsub(/\e\[\d{1,2}m/, "").length - end -end diff --git a/vendor/gems/highline-1.5.0/lib/highline/color_scheme.rb b/vendor/gems/highline-1.5.0/lib/highline/color_scheme.rb deleted file mode 100644 index e7cbdf99..00000000 --- a/vendor/gems/highline-1.5.0/lib/highline/color_scheme.rb +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/local/bin/ruby -w - -# color_scheme.rb -# -# Created by Jeremy Hinegardner on 2007-01-24 -# Copyright 2007. All rights reserved -# -# This is Free Software. See LICENSE and COPYING for details - -require 'highline' - -class HighLine - # - # ColorScheme objects encapsulate a named set of colors to be used in the - # HighLine.colors() method call. For example, by applying a ColorScheme that - # has a :warning color then the following could be used: - # - # colors("This is a warning", :warning) - # - # A ColorScheme contains named sets of HighLine color constants. - # - # Example: Instantiating a color scheme, applying it to HighLine, - # and using it: - # - # ft = HighLine::ColorScheme.new do |cs| - # cs[:headline] = [ :bold, :yellow, :on_black ] - # cs[:horizontal_line] = [ :bold, :white ] - # cs[:even_row] = [ :green ] - # cs[:odd_row] = [ :magenta ] - # end - # - # HighLine.color_scheme = ft - # say("<%= color('Headline', :headline) %>") - # say("<%= color('-'*20, :horizontal_line) %>") - # i = true - # ("A".."D").each do |row| - # if i then - # say("<%= color('#{row}', :even_row ) %>") - # else - # say("<%= color('#{row}', :odd_row) %>") - # end - # i = !i - # end - # - # - class ColorScheme - # - # Create an instance of HighLine::ColorScheme. The customization can - # happen as a passed in Hash or via the yielded block. Key's are - # converted to :symbols and values are converted to HighLine - # constants. - # - def initialize( h = nil ) - @scheme = Hash.new - load_from_hash(h) unless h.nil? - yield self if block_given? - end - - # Load multiple colors from key/value pairs. - def load_from_hash( h ) - h.each_pair do |color_tag, constants| - self[color_tag] = constants - end - end - - # Does this color scheme include the given tag name? - def include?( color_tag ) - @scheme.keys.include?(to_symbol(color_tag)) - end - - # Allow the scheme to be accessed like a Hash. - def []( color_tag ) - @scheme[to_symbol(color_tag)] - end - - # Allow the scheme to be set like a Hash. - def []=( color_tag, constants ) - @scheme[to_symbol(color_tag)] = constants.map { |c| to_constant(c) } - end - - private - - # Return a normalized representation of a color name. - def to_symbol( t ) - t.to_s.downcase - end - - # Return a normalized representation of a color setting. - def to_constant( v ) - v = v.to_s if v.is_a?(Symbol) - if v.is_a?(String) then - HighLine.const_get(v.upcase) - else - v - end - end - end - - # A sample ColorScheme. - class SampleColorScheme < ColorScheme - # - # Builds the sample scheme with settings for :critical, - # :error, :warning, :notice, :info, - # :debug, :row_even, and :row_odd colors. - # - def initialize( h = nil ) - scheme = { - :critical => [ :yellow, :on_red ], - :error => [ :bold, :red ], - :warning => [ :bold, :yellow ], - :notice => [ :bold, :magenta ], - :info => [ :bold, :cyan ], - :debug => [ :bold, :green ], - :row_even => [ :cyan ], - :row_odd => [ :magenta ] - } - super(scheme) - end - end -end diff --git a/vendor/gems/highline-1.5.0/lib/highline/import.rb b/vendor/gems/highline-1.5.0/lib/highline/import.rb deleted file mode 100644 index 579a9734..00000000 --- a/vendor/gems/highline-1.5.0/lib/highline/import.rb +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/local/bin/ruby -w - -# import.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "highline" -require "forwardable" - -$terminal = HighLine.new - -# -# require "highline/import" adds shortcut methods to Kernel, making -# agree(), ask(), choose() and say() globally available. This is handy for -# quick and dirty input and output. These methods use the HighLine object in -# the global variable $terminal, which is initialized to used -# $stdin and $stdout (you are free to change this). -# Otherwise, these methods are identical to their HighLine counterparts, see that -# class for detailed explanations. -# -module Kernel - extend Forwardable - def_delegators :$terminal, :agree, :ask, :choose, :say -end - -class Object - # - # Tries this object as a _first_answer_ for a HighLine::Question. See that - # attribute for details. - # - # *Warning*: This Object will be passed to String() before set. - # - def or_ask( *args, &details ) - ask(*args) do |question| - question.first_answer = String(self) unless nil? - - details.call(question) unless details.nil? - end - end -end diff --git a/vendor/gems/highline-1.5.0/lib/highline/menu.rb b/vendor/gems/highline-1.5.0/lib/highline/menu.rb deleted file mode 100644 index ad992ac0..00000000 --- a/vendor/gems/highline-1.5.0/lib/highline/menu.rb +++ /dev/null @@ -1,395 +0,0 @@ -#!/usr/local/bin/ruby -w - -# menu.rb -# -# Created by Gregory Thomas Brown on 2005-05-10. -# Copyright 2005. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "highline/question" - -class HighLine - # - # Menu objects encapsulate all the details of a call to HighLine.choose(). - # Using the accessors and Menu.choice() and Menu.choices(), the block passed - # to HighLine.choose() can detail all aspects of menu display and control. - # - class Menu < Question - # - # Create an instance of HighLine::Menu. All customization is done - # through the passed block, which should call accessors and choice() and - # choices() as needed to define the Menu. Note that Menus are also - # Questions, so all that functionality is available to the block as - # well. - # - def initialize( ) - # - # Initialize Question objects with ignored values, we'll - # adjust ours as needed. - # - super("Ignored", [ ], &nil) # avoiding passing the block along - - @items = [ ] - @hidden_items = [ ] - @help = Hash.new("There's no help for that topic.") - - @index = :number - @index_suffix = ". " - @select_by = :index_or_name - @flow = :rows - @list_option = nil - @header = nil - @prompt = "? " - @layout = :list - @shell = false - @nil_on_handled = false - - # Override Questions responses, we'll set our own. - @responses = { } - # Context for action code. - @highline = nil - - yield self if block_given? - - init_help if @shell and not @help.empty? - update_responses # rebuild responses based on our settings - end - - # - # An _index_ to append to each menu item in display. See - # Menu.index=() for details. - # - attr_reader :index - # - # The String placed between an _index_ and a menu item. Defaults to - # ". ". Switches to " ", when _index_ is set to a String (like "-"). - # - attr_accessor :index_suffix - # - # The _select_by_ attribute controls how the user is allowed to pick a - # menu item. The available choices are: - # - # :index:: The user is allowed to type the numerical - # or alphetical index for their selection. - # :index_or_name:: Allows both methods from the - # :index option and the - # :name option. - # :name:: Menu items are selected by typing a portion - # of the item name that will be - # auto-completed. - # - attr_accessor :select_by - # - # This attribute is passed directly on as the mode to HighLine.list() by - # all the preset layouts. See that method for appropriate settings. - # - attr_accessor :flow - # - # This setting is passed on as the third parameter to HighLine.list() - # by all the preset layouts. See that method for details of its - # effects. Defaults to +nil+. - # - attr_accessor :list_option - # - # Used by all the preset layouts to display title and/or introductory - # information, when set. Defaults to +nil+. - # - attr_accessor :header - # - # Used by all the preset layouts to ask the actual question to fetch a - # menu selection from the user. Defaults to "? ". - # - attr_accessor :prompt - # - # An ERb _layout_ to use when displaying this Menu object. See - # Menu.layout=() for details. - # - attr_reader :layout - # - # When set to +true+, responses are allowed to be an entire line of - # input, including details beyond the command itself. Only the first - # "word" of input will be matched against the menu choices, but both the - # command selected and the rest of the line will be passed to provided - # action blocks. Defaults to +false+. - # - attr_accessor :shell - # - # When +true+, any selected item handled by provided action code, will - # return +nil+, instead of the results to the action code. This may - # prove handy when dealing with mixed menus where only the names of - # items without any code (and +nil+, of course) will be returned. - # Defaults to +false+. - # - attr_accessor :nil_on_handled - - # - # Adds _name_ to the list of available menu items. Menu items will be - # displayed in the order they are added. - # - # An optional _action_ can be associated with this name and if provided, - # it will be called if the item is selected. The result of the method - # will be returned, unless _nil_on_handled_ is set (when you would get - # +nil+ instead). In _shell_ mode, a provided block will be passed the - # command chosen and any details that followed the command. Otherwise, - # just the command is passed. The @highline variable is set to - # the current HighLine context before the action code is called and can - # thus be used for adding output and the like. - # - def choice( name, help = nil, &action ) - @items << [name, action] - - @help[name.to_s.downcase] = help unless help.nil? - end - - # - # A shortcut for multiple calls to the sister method choice(). Be - # warned: An _action_ set here will apply to *all* provided - # _names_. This is considered to be a feature, so you can easily - # hand-off interface processing to a different chunk of code. - # - def choices( *names, &action ) - names.each { |n| choice(n, &action) } - end - - # Identical to choice(), but the item will not be listed for the user. - def hidden( name, help = nil, &action ) - @hidden_items << [name, action] - - @help[name.to_s.downcase] = help unless help.nil? - end - - # - # Sets the indexing style for this Menu object. Indexes are appended to - # menu items, when displayed in list form. The available settings are: - # - # :number:: Menu items will be indexed numerically, starting - # with 1. This is the default method of indexing. - # :letter:: Items will be indexed alphabetically, starting - # with a. - # :none:: No index will be appended to menu items. - # any String:: Will be used as the literal _index_. - # - # Setting the _index_ to :none a literal String, also adjusts - # _index_suffix_ to a single space and _select_by_ to :none. - # Because of this, you should make a habit of setting the _index_ first. - # - def index=( style ) - @index = style - - # Default settings. - if @index == :none or @index.is_a?(String) - @index_suffix = " " - @select_by = :name - end - end - - # - # Initializes the help system by adding a :help choice, some - # action code, and the default help listing. - # - def init_help( ) - return if @items.include?(:help) - - topics = @help.keys.sort - help_help = @help.include?("help") ? @help["help"] : - "This command will display helpful messages about " + - "functionality, like this one. To see the help for " + - "a specific topic enter:\n\thelp [TOPIC]\nTry asking " + - "for help on any of the following:\n\n" + - "<%= list(#{topics.inspect}, :columns_across) %>" - choice(:help, help_help) do |command, topic| - topic.strip! - topic.downcase! - if topic.empty? - @highline.say(@help["help"]) - else - @highline.say("= #{topic}\n\n#{@help[topic]}") - end - end - end - - # - # Used to set help for arbitrary topics. Use the topic "help" - # to override the default message. - # - def help( topic, help ) - @help[topic] = help - end - - # - # Setting a _layout_ with this method also adjusts some other attributes - # of the Menu object, to ideal defaults for the chosen _layout_. To - # account for that, you probably want to set a _layout_ first in your - # configuration block, if needed. - # - # Accepted settings for _layout_ are: - # - # :list:: The default _layout_. The _header_ if set - # will appear at the top on its own line with - # a trailing colon. Then the list of menu - # items will follow. Finally, the _prompt_ - # will be used as the ask()-like question. - # :one_line:: A shorter _layout_ that fits on one line. - # The _header_ comes first followed by a - # colon and spaces, then the _prompt_ with menu - # items between trailing parenthesis. - # :menu_only:: Just the menu items, followed up by a likely - # short _prompt_. - # any ERb String:: Will be taken as the literal _layout_. This - # String can access @header, - # @menu and @prompt, but is - # otherwise evaluated in the typical HighLine - # context, to provide access to utilities like - # HighLine.list() primarily. - # - # If set to either :one_line, or :menu_only, _index_ - # will default to :none and _flow_ will default to - # :inline. - # - def layout=( new_layout ) - @layout = new_layout - - # Default settings. - case @layout - when :one_line, :menu_only - self.index = :none - @flow = :inline - end - end - - # - # This method returns all possible options for auto-completion, based - # on the settings of _index_ and _select_by_. - # - def options( ) - # add in any hidden menu commands - @items.concat(@hidden_items) - - by_index = if @index == :letter - l_index = "`" - @items.map { "#{l_index.succ!}" } - else - (1 .. @items.size).collect { |s| String(s) } - end - by_name = @items.collect { |c| c.first } - - case @select_by - when :index then - by_index - when :name - by_name - else - by_index + by_name - end - ensure - # make sure the hidden items are removed, before we return - @items.slice!(@items.size - @hidden_items.size, @hidden_items.size) - end - - # - # This method processes the auto-completed user selection, based on the - # rules for this Menu object. If an action was provided for the - # selection, it will be executed as described in Menu.choice(). - # - def select( highline_context, selection, details = nil ) - # add in any hidden menu commands - @items.concat(@hidden_items) - - # Find the selected action. - name, action = if selection =~ /^\d+$/ - @items[selection.to_i - 1] - else - l_index = "`" - index = @items.map { "#{l_index.succ!}" }.index(selection) - @items.find { |c| c.first == selection } or @items[index] - end - - # Run or return it. - if not @nil_on_handled and not action.nil? - @highline = highline_context - if @shell - action.call(name, details) - else - action.call(name) - end - elsif action.nil? - name - else - nil - end - ensure - # make sure the hidden items are removed, before we return - @items.slice!(@items.size - @hidden_items.size, @hidden_items.size) - end - - # - # Allows Menu objects to pass as Arrays, for use with HighLine.list(). - # This method returns all menu items to be displayed, complete with - # indexes. - # - def to_ary( ) - case @index - when :number - @items.map { |c| "#{@items.index(c) + 1}#{@index_suffix}#{c.first}" } - when :letter - l_index = "`" - @items.map { |c| "#{l_index.succ!}#{@index_suffix}#{c.first}" } - when :none - @items.map { |c| "#{c.first}" } - else - @items.map { |c| "#{index}#{@index_suffix}#{c.first}" } - end - end - - # - # Allows Menu to behave as a String, just like Question. Returns the - # _layout_ to be rendered, which is used by HighLine.say(). - # - def to_str( ) - case @layout - when :list - '<%= if @header.nil? then '' else "#{@header}:\n" end %>' + - "<%= list( @menu, #{@flow.inspect}, - #{@list_option.inspect} ) %>" + - "<%= @prompt %>" - when :one_line - '<%= if @header.nil? then '' else "#{@header}: " end %>' + - "<%= @prompt %>" + - "(<%= list( @menu, #{@flow.inspect}, - #{@list_option.inspect} ) %>)" + - "<%= @prompt[/\s*$/] %>" - when :menu_only - "<%= list( @menu, #{@flow.inspect}, - #{@list_option.inspect} ) %><%= @prompt %>" - else - @layout - end - end - - # - # This method will update the intelligent responses to account for - # Menu specific differences. This overrides the work done by - # Question.build_responses(). - # - def update_responses( ) - append_default unless default.nil? - @responses = { :ambiguous_completion => - "Ambiguous choice. " + - "Please choose one of #{options.inspect}.", - :ask_on_error => - "? ", - :invalid_type => - "You must enter a valid #{options}.", - :no_completion => - "You must choose one of " + - "#{options.inspect}.", - :not_in_range => - "Your answer isn't within the expected range " + - "(#{expected_range}).", - :not_valid => - "Your answer isn't valid (must match " + - "#{@validate.inspect})." }.merge(@responses) - end - end -end diff --git a/vendor/gems/highline-1.5.0/lib/highline/question.rb b/vendor/gems/highline-1.5.0/lib/highline/question.rb deleted file mode 100644 index a3d89cc6..00000000 --- a/vendor/gems/highline-1.5.0/lib/highline/question.rb +++ /dev/null @@ -1,462 +0,0 @@ -#!/usr/local/bin/ruby -w - -# question.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "optparse" -require "date" -require "pathname" - -class HighLine - # - # Question objects contain all the details of a single invocation of - # HighLine.ask(). The object is initialized by the parameters passed to - # HighLine.ask() and then queried to make sure each step of the input - # process is handled according to the users wishes. - # - class Question - # An internal HighLine error. User code does not need to trap this. - class NoAutoCompleteMatch < StandardError - # do nothing, just creating a unique error type - end - - # - # Create an instance of HighLine::Question. Expects a _question_ to ask - # (can be "") and an _answer_type_ to convert the answer to. - # The _answer_type_ parameter must be a type recongnized by - # Question.convert(). If given, a block is yeilded the new Question - # object to allow custom initializaion. - # - def initialize( question, answer_type ) - # initialize instance data - @question = question - @answer_type = answer_type - - @character = nil - @limit = nil - @echo = true - @readline = false - @whitespace = :strip - @case = nil - @default = nil - @validate = nil - @above = nil - @below = nil - @in = nil - @confirm = nil - @gather = false - @first_answer = nil - @directory = Pathname.new(File.expand_path(File.dirname($0))) - @glob = "*" - @responses = Hash.new - @overwrite = false - - # allow block to override settings - yield self if block_given? - - # finalize responses based on settings - build_responses - end - - # The ERb template of the question to be asked. - attr_accessor :question - # The type that will be used to convert this answer. - attr_accessor :answer_type - # - # Can be set to +true+ to use HighLine's cross-platform character reader - # instead of fetching an entire line of input. (Note: HighLine's - # character reader *ONLY* supports STDIN on Windows and Unix.) Can also - # be set to :getc to use that method on the input stream. - # - # *WARNING*: The _echo_ and _overwrite_ attributes for a question are - # ignored when using the :getc method. - # - attr_accessor :character - # - # Allows you to set a character limit for input. - # - # *WARNING*: This option forces a character by character read. - # - attr_accessor :limit - # - # Can be set to +true+ or +false+ to control whether or not input will - # be echoed back to the user. A setting of +true+ will cause echo to - # match input, but any other true value will be treated as to String to - # echo for each character typed. - # - # This requires HighLine's character reader. See the _character_ - # attribute for details. - # - # *Note*: When using HighLine to manage echo on Unix based systems, we - # recommend installing the termios gem. Without it, it's possible to type - # fast enough to have letters still show up (when reading character by - # character only). - # - attr_accessor :echo - # - # Use the Readline library to fetch input. This allows input editing as - # well as keeping a history. In addition, tab will auto-complete - # within an Array of choices or a file listing. - # - # *WARNING*: This option is incompatible with all of HighLine's - # character reading modes and it causes HighLine to ignore the - # specified _input_ stream. - # - attr_accessor :readline - # - # Used to control whitespace processing for the answer to this question. - # See HighLine::Question.remove_whitespace() for acceptable settings. - # - attr_accessor :whitespace - # - # Used to control character case processing for the answer to this question. - # See HighLine::Question.change_case() for acceptable settings. - # - attr_accessor :case - # Used to provide a default answer to this question. - attr_accessor :default - # - # If set to a Regexp, the answer must match (before type conversion). - # Can also be set to a Proc which will be called with the provided - # answer to validate with a +true+ or +false+ return. - # - attr_accessor :validate - # Used to control range checks for answer. - attr_accessor :above, :below - # If set, answer must pass an include?() check on this object. - attr_accessor :in - # - # Asks a yes or no confirmation question, to ensure a user knows what - # they have just agreed to. If set to +true+ the question will be, - # "Are you sure? " Any other true value for this attribute is assumed - # to be the question to ask. When +false+ or +nil+ (the default), - # answers are not confirmed. - # - attr_accessor :confirm - # - # When set, the user will be prompted for multiple answers which will - # be collected into an Array or Hash and returned as the final answer. - # - # You can set _gather_ to an Integer to have an Array of exactly that - # many answers collected, or a String/Regexp to match an end input which - # will not be returned in the Array. - # - # Optionally _gather_ can be set to a Hash. In this case, the question - # will be asked once for each key and the answers will be returned in a - # Hash, mapped by key. The @key variable is set before each - # question is evaluated, so you can use it in your question. - # - attr_accessor :gather - # - # When set to a non *nil* value, this will be tried as an answer to the - # question. If this answer passes validations, it will become the result - # without the user ever being prompted. Otherwise this value is discarded, - # and this Question is resolved as a normal call to HighLine.ask(). - # - attr_writer :first_answer - # - # The directory from which a user will be allowed to select files, when - # File or Pathname is specified as an _answer_type_. Initially set to - # Pathname.new(File.expand_path(File.dirname($0))). - # - attr_accessor :directory - # - # The glob pattern used to limit file selection when File or Pathname is - # specified as an _answer_type_. Initially set to "*". - # - attr_accessor :glob - # - # A Hash that stores the various responses used by HighLine to notify - # the user. The currently used responses and their purpose are as - # follows: - # - # :ambiguous_completion:: Used to notify the user of an - # ambiguous answer the auto-completion - # system cannot resolve. - # :ask_on_error:: This is the question that will be - # redisplayed to the user in the event - # of an error. Can be set to - # :question to repeat the - # original question. - # :invalid_type:: The error message shown when a type - # conversion fails. - # :no_completion:: Used to notify the user that their - # selection does not have a valid - # auto-completion match. - # :not_in_range:: Used to notify the user that a - # provided answer did not satisfy - # the range requirement tests. - # :not_valid:: The error message shown when - # validation checks fail. - # - attr_reader :responses - # - # When set to +true+ the question is asked, but output does not progress to - # the next line. The Cursor is moved back to the beginning of the question - # line and it is cleared so that all the contents of the line disappear from - # the screen. - # - attr_accessor :overwrite - - # - # Returns the provided _answer_string_ or the default answer for this - # Question if a default was set and the answer is empty. - # - def answer_or_default( answer_string ) - if answer_string.length == 0 and not @default.nil? - @default - else - answer_string - end - end - - # - # Called late in the initialization process to build intelligent - # responses based on the details of this Question object. - # - def build_responses( ) - ### WARNING: This code is quasi-duplicated in ### - ### Menu.update_responses(). Check there too when ### - ### making changes! ### - append_default unless default.nil? - @responses = { :ambiguous_completion => - "Ambiguous choice. " + - "Please choose one of #{@answer_type.inspect}.", - :ask_on_error => - "? ", - :invalid_type => - "You must enter a valid #{@answer_type}.", - :no_completion => - "You must choose one of " + - "#{@answer_type.inspect}.", - :not_in_range => - "Your answer isn't within the expected range " + - "(#{expected_range}).", - :not_valid => - "Your answer isn't valid (must match " + - "#{@validate.inspect})." }.merge(@responses) - ### WARNING: This code is quasi-duplicated in ### - ### Menu.update_responses(). Check there too when ### - ### making changes! ### - end - - # - # Returns the provided _answer_string_ after changing character case by - # the rules of this Question. Valid settings for whitespace are: - # - # +nil+:: Do not alter character case. - # (Default.) - # :up:: Calls upcase(). - # :upcase:: Calls upcase(). - # :down:: Calls downcase(). - # :downcase:: Calls downcase(). - # :capitalize:: Calls capitalize(). - # - # An unrecognized choice (like :none) is treated as +nil+. - # - def change_case( answer_string ) - if [:up, :upcase].include?(@case) - answer_string.upcase - elsif [:down, :downcase].include?(@case) - answer_string.downcase - elsif @case == :capitalize - answer_string.capitalize - else - answer_string - end - end - - # - # Transforms the given _answer_string_ into the expected type for this - # Question. Currently supported conversions are: - # - # [...]:: Answer must be a member of the passed Array. - # Auto-completion is used to expand partial - # answers. - # lambda {...}:: Answer is passed to lambda for conversion. - # Date:: Date.parse() is called with answer. - # DateTime:: DateTime.parse() is called with answer. - # File:: The entered file name is auto-completed in - # terms of _directory_ + _glob_, opened, and - # returned. - # Float:: Answer is converted with Kernel.Float(). - # Integer:: Answer is converted with Kernel.Integer(). - # +nil+:: Answer is left in String format. (Default.) - # Pathname:: Same as File, save that a Pathname object is - # returned. - # String:: Answer is converted with Kernel.String(). - # Regexp:: Answer is fed to Regexp.new(). - # Symbol:: The method to_sym() is called on answer and - # the result returned. - # any other Class:: The answer is passed on to - # Class.parse(). - # - # This method throws ArgumentError, if the conversion cannot be - # completed for any reason. - # - def convert( answer_string ) - if @answer_type.nil? - answer_string - elsif [Float, Integer, String].include?(@answer_type) - Kernel.send(@answer_type.to_s.to_sym, answer_string) - elsif @answer_type == Symbol - answer_string.to_sym - elsif @answer_type == Regexp - Regexp.new(answer_string) - elsif @answer_type.is_a?(Array) or [File, Pathname].include?(@answer_type) - # cheating, using OptionParser's Completion module - choices = selection - choices.extend(OptionParser::Completion) - answer = choices.complete(answer_string) - if answer.nil? - raise NoAutoCompleteMatch - end - if @answer_type.is_a?(Array) - answer.last - elsif @answer_type == File - File.open(File.join(@directory.to_s, answer.last)) - else - Pathname.new(File.join(@directory.to_s, answer.last)) - end - elsif [Date, DateTime].include?(@answer_type) or @answer_type.is_a?(Class) - @answer_type.parse(answer_string) - elsif @answer_type.is_a?(Proc) - @answer_type[answer_string] - end - end - - # Returns a english explination of the current range settings. - def expected_range( ) - expected = [ ] - - expected << "above #{@above}" unless @above.nil? - expected << "below #{@below}" unless @below.nil? - expected << "included in #{@in.inspect}" unless @in.nil? - - case expected.size - when 0 then "" - when 1 then expected.first - when 2 then expected.join(" and ") - else expected[0..-2].join(", ") + ", and #{expected.last}" - end - end - - # Returns _first_answer_, which will be unset following this call. - def first_answer( ) - @first_answer - ensure - @first_answer = nil - end - - # Returns true if _first_answer_ is set. - def first_answer?( ) - not @first_answer.nil? - end - - # - # Returns +true+ if the _answer_object_ is greater than the _above_ - # attribute, less than the _below_ attribute and included?()ed in the - # _in_ attribute. Otherwise, +false+ is returned. Any +nil+ attributes - # are not checked. - # - def in_range?( answer_object ) - (@above.nil? or answer_object > @above) and - (@below.nil? or answer_object < @below) and - (@in.nil? or @in.include?(answer_object)) - end - - # - # Returns the provided _answer_string_ after processing whitespace by - # the rules of this Question. Valid settings for whitespace are: - # - # +nil+:: Do not alter whitespace. - # :strip:: Calls strip(). (Default.) - # :chomp:: Calls chomp(). - # :collapse:: Collapses all whitspace runs to a - # single space. - # :strip_and_collapse:: Calls strip(), then collapses all - # whitspace runs to a single space. - # :chomp_and_collapse:: Calls chomp(), then collapses all - # whitspace runs to a single space. - # :remove:: Removes all whitespace. - # - # An unrecognized choice (like :none) is treated as +nil+. - # - # This process is skipped, for single character input. - # - def remove_whitespace( answer_string ) - if @whitespace.nil? - answer_string - elsif [:strip, :chomp].include?(@whitespace) - answer_string.send(@whitespace) - elsif @whitespace == :collapse - answer_string.gsub(/\s+/, " ") - elsif [:strip_and_collapse, :chomp_and_collapse].include?(@whitespace) - result = answer_string.send(@whitespace.to_s[/^[a-z]+/]) - result.gsub(/\s+/, " ") - elsif @whitespace == :remove - answer_string.gsub(/\s+/, "") - else - answer_string - end - end - - # - # Returns an Array of valid answers to this question. These answers are - # only known when _answer_type_ is set to an Array of choices, File, or - # Pathname. Any other time, this method will return an empty Array. - # - def selection( ) - if @answer_type.is_a?(Array) - @answer_type - elsif [File, Pathname].include?(@answer_type) - Dir[File.join(@directory.to_s, @glob)].map do |file| - File.basename(file) - end - else - [ ] - end - end - - # Stringifies the question to be asked. - def to_str( ) - @question - end - - # - # Returns +true+ if the provided _answer_string_ is accepted by the - # _validate_ attribute or +false+ if it's not. - # - # It's important to realize that an answer is validated after whitespace - # and case handling. - # - def valid_answer?( answer_string ) - @validate.nil? or - (@validate.is_a?(Regexp) and answer_string =~ @validate) or - (@validate.is_a?(Proc) and @validate[answer_string]) - end - - private - - # - # Adds the default choice to the end of question between |...|. - # Trailing whitespace is preserved so the function of HighLine.say() is - # not affected. - # - def append_default( ) - if @question =~ /([\t ]+)\Z/ - @question << "|#{@default}|#{$1}" - elsif @question == "" - @question << "|#{@default}| " - elsif @question[-1, 1] == "\n" - @question[-2, 0] = " |#{@default}|" - else - @question << " |#{@default}|" - end - end - end -end diff --git a/vendor/gems/highline-1.5.0/lib/highline/system_extensions.rb b/vendor/gems/highline-1.5.0/lib/highline/system_extensions.rb deleted file mode 100644 index e08b4772..00000000 --- a/vendor/gems/highline-1.5.0/lib/highline/system_extensions.rb +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/local/bin/ruby -w - -# system_extensions.rb -# -# Created by James Edward Gray II on 2006-06-14. -# Copyright 2006 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -class HighLine - module SystemExtensions - module_function - - # - # This section builds character reading and terminal size functions - # to suit the proper platform we're running on. Be warned: Here be - # dragons! - # - begin - # Cygwin will look like Windows, but we want to treat it like a Posix OS: - raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i - - require "Win32API" # See if we're on Windows. - - CHARACTER_MODE = "Win32API" # For Debugging purposes only. - - # - # Windows savvy getc(). - # - # *WARNING*: This method ignores input and reads one - # character from +STDIN+! - # - def get_character( input = STDIN ) - Win32API.new("crtdll", "_getch", [ ], "L").Call - end - - # A Windows savvy method to fetch the console columns, and rows. - def terminal_size - m_GetStdHandle = Win32API.new( 'kernel32', - 'GetStdHandle', - ['L'], - 'L' ) - m_GetConsoleScreenBufferInfo = Win32API.new( - 'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L' - ) - - format = 'SSSSSssssSS' - buf = ([0] * format.size).pack(format) - stdout_handle = m_GetStdHandle.call(0xFFFFFFF5) - - m_GetConsoleScreenBufferInfo.call(stdout_handle, buf) - bufx, bufy, curx, cury, wattr, - left, top, right, bottom, maxx, maxy = buf.unpack(format) - return right - left + 1, bottom - top + 1 - end - rescue LoadError # If we're not on Windows try... - begin - require "termios" # Unix, first choice. - - CHARACTER_MODE = "termios" # For Debugging purposes only. - - # - # Unix savvy getc(). (First choice.) - # - # *WARNING*: This method requires the "termios" library! - # - def get_character( input = STDIN ) - old_settings = Termios.getattr(input) - - new_settings = old_settings.dup - new_settings.c_lflag &= ~(Termios::ECHO | Termios::ICANON) - new_settings.c_cc[Termios::VMIN] = 1 - - begin - Termios.setattr(input, Termios::TCSANOW, new_settings) - input.getc - ensure - Termios.setattr(input, Termios::TCSANOW, old_settings) - end - end - rescue LoadError # If our first choice fails, default. - CHARACTER_MODE = "stty" # For Debugging purposes only. - - # - # Unix savvy getc(). (Second choice.) - # - # *WARNING*: This method requires the external "stty" program! - # - def get_character( input = STDIN ) - raw_no_echo_mode - - begin - input.getc - ensure - restore_mode - end - end - - # - # Switched the input mode to raw and disables echo. - # - # *WARNING*: This method requires the external "stty" program! - # - def raw_no_echo_mode - @state = `stty -g` - system "stty raw -echo cbreak isig" - end - - # - # Restores a previously saved input mode. - # - # *WARNING*: This method requires the external "stty" program! - # - def restore_mode - system "stty #{@state}" - end - end - - # A Unix savvy method to fetch the console columns, and rows. - def terminal_size - if /solaris/ =~ RUBY_PLATFORM and - `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/ - [$2, $1].map { |c| x.to_i } - else - `stty size`.split.map { |x| x.to_i }.reverse - end - end - end - end -end diff --git a/vendor/gems/highline-1.5.0/setup.rb b/vendor/gems/highline-1.5.0/setup.rb deleted file mode 100644 index 0807023d..00000000 --- a/vendor/gems/highline-1.5.0/setup.rb +++ /dev/null @@ -1,1360 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2004 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU LGPL, Lesser General Public License version 2.1. -# - -unless Enumerable.method_defined?(:map) # Ruby 1.4.6 - module Enumerable - alias map collect - end -end - -unless File.respond_to?(:read) # Ruby 1.6 - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted windows stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - - -class SetupError < StandardError; end - -def setup_rb_error(msg) - raise SetupError, msg -end - -# -# Config -# - -if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - require arg.split(/=/, 2)[1] - $".push 'rbconfig.rb' -else - require 'rbconfig' -end - -def multipackage_install? - FileTest.directory?(File.dirname($0) + '/packages') -end - - -class ConfigItem - def initialize(name, template, default, desc) - @name = name.freeze - @template = template - @value = default - @default = default.dup.freeze - @description = desc - end - - attr_reader :name - attr_reader :description - - attr_accessor :default - alias help_default default - - def help_opt - "--#{@name}=#{@template}" - end - - def value - @value - end - - def eval(table) - @value.gsub(%r<\$([^/]+)>) { table[$1] } - end - - def set(val) - @value = check(val) - end - - private - - def check(val) - setup_rb_error "config: --#{name} requires argument" unless val - val - end -end - -class BoolItem < ConfigItem - def config_type - 'bool' - end - - def help_opt - "--#{@name}" - end - - private - - def check(val) - return 'yes' unless val - unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val - setup_rb_error "config: --#{@name} accepts only yes/no for argument" - end - (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no' - end -end - -class PathItem < ConfigItem - def config_type - 'path' - end - - private - - def check(path) - setup_rb_error "config: --#{@name} requires argument" unless path - path[0,1] == '$' ? path : File.expand_path(path) - end -end - -class ProgramItem < ConfigItem - def config_type - 'program' - end -end - -class SelectItem < ConfigItem - def initialize(name, template, default, desc) - super - @ok = template.split('/') - end - - def config_type - 'select' - end - - private - - def check(val) - unless @ok.include?(val.strip) - setup_rb_error "config: use --#{@name}=#{@template} (#{val})" - end - val.strip - end -end - -class PackageSelectionItem < ConfigItem - def initialize(name, template, default, help_default, desc) - super name, template, default, desc - @help_default = help_default - end - - attr_reader :help_default - - def config_type - 'package' - end - - private - - def check(val) - unless File.dir?("packages/#{val}") - setup_rb_error "config: no such package: #{val}" - end - val - end -end - -class ConfigTable_class - - def initialize(items) - @items = items - @table = {} - items.each do |i| - @table[i.name] = i - end - ALIASES.each do |ali, name| - @table[ali] = @table[name] - end - end - - include Enumerable - - def each(&block) - @items.each(&block) - end - - def key?(name) - @table.key?(name) - end - - def lookup(name) - @table[name] or raise ArgumentError, "no such config item: #{name}" - end - - def add(item) - @items.push item - @table[item.name] = item - end - - def remove(name) - item = lookup(name) - @items.delete_if {|i| i.name == name } - @table.delete_if {|name, i| i.name == name } - item - end - - def new - dup() - end - - def savefile - '.config' - end - - def load - begin - t = dup() - File.foreach(savefile()) do |line| - k, v = *line.split(/=/, 2) - t[k] = v.strip - end - t - rescue Errno::ENOENT - setup_rb_error $!.message + "#{File.basename($0)} config first" - end - end - - def save - @items.each {|i| i.value } - File.open(savefile(), 'w') {|f| - @items.each do |i| - f.printf "%s=%s\n", i.name, i.value if i.value - end - } - end - - def [](key) - lookup(key).eval(self) - end - - def []=(key, val) - lookup(key).set val - end - -end - -c = ::Config::CONFIG - -rubypath = c['bindir'] + '/' + c['ruby_install_name'] - -major = c['MAJOR'].to_i -minor = c['MINOR'].to_i -teeny = c['TEENY'].to_i -version = "#{major}.#{minor}" - -# ruby ver. >= 1.4.4? -newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - -if c['rubylibdir'] - # V < 1.6.3 - _stdruby = c['rubylibdir'] - _siteruby = c['sitedir'] - _siterubyver = c['sitelibdir'] - _siterubyverarch = c['sitearchdir'] -elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - _stdruby = "$prefix/lib/ruby/#{version}" - _siteruby = c['sitedir'] - _siterubyver = "$siteruby/#{version}" - _siterubyverarch = "$siterubyver/#{c['arch']}" -else - # V < 1.4.4 - _stdruby = "$prefix/lib/ruby/#{version}" - _siteruby = "$prefix/lib/ruby/#{version}/site_ruby" - _siterubyver = _siteruby - _siterubyverarch = "$siterubyver/#{c['arch']}" -end -libdir = '-* dummy libdir *-' -stdruby = '-* dummy rubylibdir *-' -siteruby = '-* dummy site_ruby *-' -siterubyver = '-* dummy site_ruby version *-' -parameterize = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')\ - .sub(/\A#{Regexp.quote(libdir)}/, '$libdir')\ - .sub(/\A#{Regexp.quote(stdruby)}/, '$stdruby')\ - .sub(/\A#{Regexp.quote(siteruby)}/, '$siteruby')\ - .sub(/\A#{Regexp.quote(siterubyver)}/, '$siterubyver') -} -libdir = parameterize.call(c['libdir']) -stdruby = parameterize.call(_stdruby) -siteruby = parameterize.call(_siteruby) -siterubyver = parameterize.call(_siterubyver) -siterubyverarch = parameterize.call(_siterubyverarch) - -if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] -else - makeprog = 'make' -end - -common_conf = [ - PathItem.new('prefix', 'path', c['prefix'], - 'path prefix of target environment'), - PathItem.new('bindir', 'path', parameterize.call(c['bindir']), - 'the directory for commands'), - PathItem.new('libdir', 'path', libdir, - 'the directory for libraries'), - PathItem.new('datadir', 'path', parameterize.call(c['datadir']), - 'the directory for shared data'), - PathItem.new('mandir', 'path', parameterize.call(c['mandir']), - 'the directory for man pages'), - PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), - 'the directory for man pages'), - PathItem.new('stdruby', 'path', stdruby, - 'the directory for standard ruby libraries'), - PathItem.new('siteruby', 'path', siteruby, - 'the directory for version-independent aux ruby libraries'), - PathItem.new('siterubyver', 'path', siterubyver, - 'the directory for aux ruby libraries'), - PathItem.new('siterubyverarch', 'path', siterubyverarch, - 'the directory for aux ruby binaries'), - PathItem.new('rbdir', 'path', '$siterubyver', - 'the directory for ruby scripts'), - PathItem.new('sodir', 'path', '$siterubyverarch', - 'the directory for ruby extentions'), - PathItem.new('rubypath', 'path', rubypath, - 'the path to set to #! line'), - ProgramItem.new('rubyprog', 'name', rubypath, - 'the ruby program using for installation'), - ProgramItem.new('makeprog', 'name', makeprog, - 'the make program to compile ruby extentions'), - SelectItem.new('shebang', 'all/ruby/never', 'ruby', - 'shebang line (#!) editing mode'), - BoolItem.new('without-ext', 'yes/no', 'no', - 'does not compile/install ruby extentions') -] -class ConfigTable_class # open again - ALIASES = { - 'std-ruby' => 'stdruby', - 'site-ruby-common' => 'siteruby', # For backward compatibility - 'site-ruby' => 'siterubyver', # For backward compatibility - 'bin-dir' => 'bindir', - 'bin-dir' => 'bindir', - 'rb-dir' => 'rbdir', - 'so-dir' => 'sodir', - 'data-dir' => 'datadir', - 'ruby-path' => 'rubypath', - 'ruby-prog' => 'rubyprog', - 'ruby' => 'rubyprog', - 'make-prog' => 'makeprog', - 'make' => 'makeprog' - } -end -multipackage_conf = [ - PackageSelectionItem.new('with', 'name,name...', '', 'ALL', - 'package names that you want to install'), - PackageSelectionItem.new('without', 'name,name...', '', 'NONE', - 'package names that you do not want to install') -] -if multipackage_install? - ConfigTable = ConfigTable_class.new(common_conf + multipackage_conf) -else - ConfigTable = ConfigTable_class.new(common_conf) -end - - -module MetaConfigAPI - - def eval_file_ifexist(fname) - instance_eval File.read(fname), fname, 1 if File.file?(fname) - end - - def config_names - ConfigTable.map {|i| i.name } - end - - def config?(name) - ConfigTable.key?(name) - end - - def bool_config?(name) - ConfigTable.lookup(name).config_type == 'bool' - end - - def path_config?(name) - ConfigTable.lookup(name).config_type == 'path' - end - - def value_config?(name) - case ConfigTable.lookup(name).config_type - when 'bool', 'path' - true - else - false - end - end - - def add_config(item) - ConfigTable.add item - end - - def add_bool_config(name, default, desc) - ConfigTable.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) - end - - def add_path_config(name, default, desc) - ConfigTable.add PathItem.new(name, 'path', default, desc) - end - - def set_config_default(name, default) - ConfigTable.lookup(name).default = default - end - - def remove_config(name) - ConfigTable.remove(name) - end - -end - - -# -# File Operations -# - -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + File.expand_path(dirname) if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # does not check '/'... it's too abnormal case - dirs = File.expand_path(dirname).split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(fname) - $stderr.puts "rm -f #{fname}" if verbose? - return if no_harm? - - if File.exist?(fname) or File.symlink?(fname) - File.chmod 0777, fname - File.unlink fname - end - end - - def rm_rf(dn) - $stderr.puts "rm -rf #{dn}" if verbose? - return if no_harm? - - Dir.chdir dn - Dir.foreach('.') do |fn| - next if fn == '.' - next if fn == '..' - if File.dir?(fn) - verbose_off { - rm_rf fn - } - else - verbose_off { - rm_f fn - } - end - end - Dir.chdir '..' - Dir.rmdir dn - end - - def move_file(src, dest) - File.unlink dest if File.exist?(dest) - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| f.write File.binread(src) } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix ? prefix + File.expand_path(dest) : dest - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(str) - $stderr.puts str if verbose? - system str or raise RuntimeError, "'system #{str}' failed" - end - - def ruby(str) - command config('rubyprog') + ' ' + str - end - - def make(task = '') - command config('makeprog') + ' ' + task - end - - def extdir?(dir) - File.exist?(dir + '/MANIFEST') - end - - def all_files_in(dirname) - Dir.open(dirname) {|d| - return d.select {|ent| File.file?("#{dirname}/#{ent}") } - } - end - - REJECT_DIRS = %w( - CVS SCCS RCS CVS.adm .svn - ) - - def all_dirs_in(dirname) - Dir.open(dirname) {|d| - return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS - } - end - -end - - -# -# Main Installer -# - -module HookUtils - - def run_hook(name) - try_run_hook "#{curr_srcdir()}/#{name}" or - try_run_hook "#{curr_srcdir()}/#{name}.rb" - end - - def try_run_hook(fname) - return false unless File.file?(fname) - begin - instance_eval File.read(fname), fname, 1 - rescue - setup_rb_error "hook #{fname} failed:\n" + $!.message - end - true - end - -end - - -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - #abstract srcdir_root - #abstract objdir_root - #abstract relpath - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file? srcfile(path) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.3.1' - Copyright = 'Copyright (c) 2000-2004 Minero Aoki' - - TASKS = [ - [ 'all', 'do config, setup, then install' ], - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - instance().invoke - end - - @singleton = nil - - def ToplevelInstaller.instance - @singleton ||= new(File.dirname($0)) - @singleton - end - - include MetaConfigAPI - - def initialize(ardir_root) - @config = nil - @options = { 'verbose' => true } - @ardir = File.expand_path(ardir_root) - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - case task = parsearg_global() - when nil, 'all' - @config = load_config('config') - parsearg_config - init_installers - exec_config - exec_setup - exec_install - else - @config = load_config(task) - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - end - - def load_config(task) - case task - when 'config' - ConfigTable.new - when 'clean', 'distclean' - if File.exist?(ConfigTable.savefile) - then ConfigTable.load - else ConfigTable.new - end - else - ConfigTable.load - end - end - - def init_installers - @installer = Installer.new(@config, @options, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/ - - while arg = ARGV.shift - case arg - when /\A\w+\z/ - setup_rb_error "invalid task: #{arg}" unless valid_task =~ arg - return arg - - when '-q', '--quiet' - @options['verbose'] = false - - when '--verbose' - @options['verbose'] = true - - when '-h', '--help' - print_usage $stdout - exit 0 - - when '-v', '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - - when '--copyright' - puts Copyright - exit 0 - - else - setup_rb_error "unknown global option '#{arg}'" - end - end - - nil - end - - - def parsearg_no_options - unless ARGV.empty? - setup_rb_error "#{task}: unknown options: #{ARGV.join ' '}" - end - end - - alias parsearg_show parsearg_no_options - alias parsearg_setup parsearg_no_options - alias parsearg_clean parsearg_no_options - alias parsearg_distclean parsearg_no_options - - def parsearg_config - re = /\A--(#{ConfigTable.map {|i| i.name }.join('|')})(?:=(.*))?\z/ - @options['config-opt'] = [] - - while i = ARGV.shift - if /\A--?\z/ =~ i - @options['config-opt'] = ARGV.dup - break - end - m = re.match(i) or setup_rb_error "config: unknown option #{i}" - name, value = *m.to_a[1,2] - @config[name] = value - end - end - - def parsearg_install - @options['no-harm'] = false - @options['install-prefix'] = '' - while a = ARGV.shift - case a - when /\A--no-harm\z/ - @options['no-harm'] = true - when /\A--prefix=(.*)\z/ - path = $1 - path = File.expand_path(path) unless path[0,1] == '/' - @options['install-prefix'] = path - else - setup_rb_error "install: unknown option #{a}" - end - end - end - - def print_usage(out) - out.puts 'Typical Installation Procedure:' - out.puts " $ ruby #{File.basename $0} config" - out.puts " $ ruby #{File.basename $0} setup" - out.puts " # ruby #{File.basename $0} install (may require root privilege)" - out.puts - out.puts 'Detailed Usage:' - out.puts " ruby #{File.basename $0} " - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-24s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, '-h,--help', 'print this message' - out.printf fmt, '-v,--version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf fmt, name, desc - end - - fmt = " %-24s %s [%s]\n" - out.puts - out.puts 'Options for CONFIG or ALL:' - ConfigTable.each do |item| - out.printf fmt, item.help_opt, item.description, item.help_default - end - out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" - out.puts - out.puts 'Options for INSTALL:' - out.printf fmt, '--no-harm', 'only display what to do if given', 'off' - out.printf fmt, '--prefix=path', 'install path prefix', '$prefix' - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_show - ConfigTable.each do |i| - printf "%-20s %s\n", i.name, i.value - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end - - -class ToplevelInstallerMulti < ToplevelInstaller - - include HookUtils - include HookScriptAPI - include FileOperations - - def initialize(ardir) - super - @packages = all_dirs_in("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - @packages.each do |name| - eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig" - end - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, @options, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - setup_rb_error "no such package: #{name}" unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # multi-package metaconfig API - # - - attr_reader :packages - - def declare_packages(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_clean - rm_f ConfigTable.savefile - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f ConfigTable.savefile - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose'] - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def verbose? - @options['verbose'] - end - - def no_harm? - @options['no-harm'] - end - -end - - -class Installer - - FILETYPES = %w( bin lib ext data ) - - include HookScriptAPI - include HookUtils - include FileOperations - - def initialize(config, opt, srcroot, objroot) - @config = config - @options = opt - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - # - # Hook Script API base methods - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # configs/options - # - - def no_harm? - @options['no-harm'] - end - - def verbose? - @options['verbose'] - end - - def verbose_off - begin - save, @options['verbose'] = @options['verbose'], false - yield - ensure - @options['verbose'] = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - def config_dir_bin(rel) - end - - def config_dir_lib(rel) - end - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - def extconf - opt = @options['config-opt'].join(' ') - command "#{config('rubyprog')} #{curr_srcdir()}/extconf.rb #{opt}" - end - - def config_dir_data(rel) - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - all_files_in(curr_srcdir()).each do |fname| - adjust_shebang "#{curr_srcdir()}/#{fname}" - end - end - - def adjust_shebang(path) - return if no_harm? - tmpfile = File.basename(path) + '.tmp' - begin - File.open(path, 'rb') {|r| - first = r.gets - return unless File.basename(config('rubypath')) == 'ruby' - return unless File.basename(first.sub(/\A\#!/, '').split[0]) == 'ruby' - $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose? - File.open(tmpfile, 'wb') {|w| - w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath')) - w.write r.read - } - move_file tmpfile, File.basename(path) - } - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def setup_dir_lib(rel) - end - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - def setup_dir_data(rel) - end - - # - # TASK install - # - - def exec_install - rm_f 'InstalledFiles' - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files collect_filenames_auto(), "#{config('bindir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files ruby_scripts(), "#{config('rbdir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files ruby_extentions('.'), - "#{config('sodir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files collect_filenames_auto(), "#{config('datadir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - install fname, dest, mode, @options['install-prefix'] - end - end - - def ruby_scripts - collect_filenames_auto().select {|n| /\.rb\z/ =~ n } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - reject_patterns = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - mapping = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - REJECT_PATTERNS = Regexp.new('\A(?:' + - reject_patterns.map {|pat| - pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] } - }.join('|') + - ')\z') - - def collect_filenames_auto - mapdir((existfiles() - hookfiles()).reject {|fname| - REJECT_PATTERNS =~ fname - }) - end - - def existfiles - all_files_in(curr_srcdir()) | all_files_in('.') - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def mapdir(filelist) - filelist.map {|fname| - if File.exist?(fname) # objdir - fname - else # srcdir - File.join(curr_srcdir(), fname) - end - } - end - - def ruby_extentions(dir) - Dir.open(dir) {|d| - ents = d.select {|fname| /\.#{::Config::CONFIG['DLEXT']}\z/ =~ fname } - if ents.empty? - setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" - end - return ents - } - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f ConfigTable.savefile - rm_f 'InstalledFiles' - end - - def clean_dir_bin(rel) - end - - def clean_dir_lib(rel) - end - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - def clean_dir_data(rel) - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f ConfigTable.savefile - rm_f 'InstalledFiles' - end - - def distclean_dir_bin(rel) - end - - def distclean_dir_lib(rel) - end - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - # - # lib - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if config('without-ext') == 'yes' and type == 'ext' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - all_dirs_in(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - -end - - -if $0 == __FILE__ - begin - if multipackage_install? - ToplevelInstallerMulti.invoke - else - ToplevelInstaller.invoke - end - rescue SetupError - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/highline-1.5.0/test/tc_color_scheme.rb b/vendor/gems/highline-1.5.0/test/tc_color_scheme.rb deleted file mode 100644 index cb5cbd0e..00000000 --- a/vendor/gems/highline-1.5.0/test/tc_color_scheme.rb +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_color_scheme.rb -# -# Created by Jeremy Hinegardner on 2007-01-24. -# Copyright 2007 Jeremy Hinegardner. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline" -require "stringio" - -class TestColorScheme < Test::Unit::TestCase - def setup - @input = StringIO.new - @output = StringIO.new - @terminal = HighLine.new(@input, @output) - - @old_color_scheme = HighLine.color_scheme - end - - def teardown - HighLine.color_scheme = @old_color_scheme - end - - def test_using_color_scheme - assert_equal(false,HighLine.using_color_scheme?) - - HighLine.color_scheme = HighLine::ColorScheme.new - assert_equal(true,HighLine.using_color_scheme?) - end - - def test_scheme - HighLine.color_scheme = HighLine::SampleColorScheme.new - - @terminal.say("This should be <%= color('warning yellow', :warning) %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) - @output.rewind - - @terminal.say("This should be <%= color('warning yellow', 'warning') %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) - @output.rewind - - @terminal.say("This should be <%= color('warning yellow', 'WarNing') %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) - @output.rewind - - # turn it back off, should raise an exception - HighLine.color_scheme = @old_color_scheme - assert_raises(NameError) { - @terminal.say("This should be <%= color('nothing at all', :error) %>.") - } - end -end diff --git a/vendor/gems/highline-1.5.0/test/tc_highline.rb b/vendor/gems/highline-1.5.0/test/tc_highline.rb deleted file mode 100644 index bbb8354e..00000000 --- a/vendor/gems/highline-1.5.0/test/tc_highline.rb +++ /dev/null @@ -1,823 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_highline.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline" -require "stringio" - -if HighLine::CHARACTER_MODE == "Win32API" - class HighLine - # Override Windows' character reading so it's not tied to STDIN. - def get_character( input = STDIN ) - input.getc - end - end -end - -class TestHighLine < Test::Unit::TestCase - def setup - @input = StringIO.new - @output = StringIO.new - @terminal = HighLine.new(@input, @output) - end - - def test_agree - @input << "y\nyes\nYES\nHell no!\nNo\n" - @input.rewind - - assert_equal(true, @terminal.agree("Yes or no? ")) - assert_equal(true, @terminal.agree("Yes or no? ")) - assert_equal(true, @terminal.agree("Yes or no? ")) - assert_equal(false, @terminal.agree("Yes or no? ")) - - @input.truncate(@input.rewind) - @input << "yellow" - @input.rewind - - assert_equal(true, @terminal.agree("Yes or no? ", :getc)) - end - - def test_agree_with_block - @input << "\n\n" - @input.rewind - - assert_equal(true, @terminal.agree("Yes or no? ") { |q| q.default = "y" }) - assert_equal(false, @terminal.agree("Yes or no? ") { |q| q.default = "n" }) - end - - def test_ask - name = "James Edward Gray II" - @input << name << "\n" - @input.rewind - - assert_equal(name, @terminal.ask("What is your name? ")) - - assert_raise(EOFError) { @terminal.ask("Any input left? ") } - end - - def test_bug_fixes - # auto-complete bug - @input << "ruby\nRuby\n" - @input.rewind - - languages = [:Perl, :Python, :Ruby] - answer = @terminal.ask( "What is your favorite programming language? ", - languages ) - assert_equal(languages.last, answer) - - @input.truncate(@input.rewind) - @input << "ruby\n" - @input.rewind - - answer = @terminal.ask( "What is your favorite programming language? ", - languages ) do |q| - q.case = :capitalize - end - assert_equal(languages.last, answer) - - # poor auto-complete error message - @input.truncate(@input.rewind) - @input << "lisp\nruby\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask( "What is your favorite programming language? ", - languages ) do |q| - q.case = :capitalize - end - assert_equal(languages.last, answer) - assert_equal( "What is your favorite programming language? " + - "You must choose one of [:Perl, :Python, :Ruby].\n" + - "? ", @output.string ) - end - - def test_case_changes - @input << "jeg2\n" - @input.rewind - - answer = @terminal.ask("Enter your initials ") do |q| - q.case = :up - end - assert_equal("JEG2", answer) - - @input.truncate(@input.rewind) - @input << "cRaZY\n" - @input.rewind - - answer = @terminal.ask("Enter a search string: ") do |q| - q.case = :down - end - assert_equal("crazy", answer) - end - - def test_character_echo - @input << "password\r" - @input.rewind - - answer = @terminal.ask("Please enter your password: ") do |q| - q.echo = "*" - end - assert_equal("password", answer) - assert_equal("Please enter your password: ********\n", @output.string) - - @input.truncate(@input.rewind) - @input << "2" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask( "Select an option (1, 2 or 3): ", - Integer ) do |q| - q.echo = "*" - q.character = true - end - assert_equal(2, answer) - assert_equal("Select an option (1, 2 or 3): *\n", @output.string) - end - - def test_backspace_does_not_enter_prompt - @input << "\b\b" - @input.rewind - answer = @terminal.ask("Please enter your password: ") do |q| - q.echo = "*" - end - assert_equal("", answer) - assert_equal("Please enter your password: \n",@output.string) - end - - def test_readline_on_non_echo_question_has_prompt - @input << "you can't see me" - @input.rewind - answer = @terminal.ask("Please enter some hidden text: ") do |q| - q.readline = true - q.echo = "*" - end - assert_equal("you can't see me", answer) - assert_equal("Please enter some hidden text: ****************\n",@output.string) - end - - def test_character_reading - # WARNING: This method does NOT cover Unix and Windows savvy testing! - @input << "12345" - @input.rewind - - answer = @terminal.ask("Enter a single digit: ", Integer) do |q| - q.character = :getc - end - assert_equal(1, answer) - end - - def test_color - @terminal.say("This should be <%= BLUE %>blue<%= CLEAR %>!") - assert_equal("This should be \e[34mblue\e[0m!\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say( "This should be " + - "<%= BOLD + ON_WHITE %>bold on white<%= CLEAR %>!" ) - assert_equal( "This should be \e[1m\e[47mbold on white\e[0m!\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("This should be <%= color('cyan', CYAN) %>!") - assert_equal("This should be \e[36mcyan\e[0m!\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say( "This should be " + - "<%= color('blinking on red', :blink, :on_red) %>!" ) - assert_equal( "This should be \e[5m\e[41mblinking on red\e[0m!\n", - @output.string ) - - @output.truncate(@output.rewind) - - # turn off color - old_setting = HighLine.use_color? - assert_nothing_raised(Exception) { HighLine.use_color = false } - @terminal.say("This should be <%= color('cyan', CYAN) %>!") - assert_equal("This should be cyan!\n", @output.string) - HighLine.use_color = old_setting - end - - def test_confirm - @input << "junk.txt\nno\nsave.txt\ny\n" - @input.rewind - - answer = @terminal.ask("Enter a filename: ") do |q| - q.confirm = "Are you sure you want to overwrite <%= @answer %>? " - q.responses[:ask_on_error] = :question - end - assert_equal("save.txt", answer) - assert_equal( "Enter a filename: " + - "Are you sure you want to overwrite junk.txt? " + - "Enter a filename: " + - "Are you sure you want to overwrite save.txt? ", - @output.string ) - - @input.truncate(@input.rewind) - @input << "junk.txt\nyes\nsave.txt\nn\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Enter a filename: ") do |q| - q.confirm = "Are you sure you want to overwrite <%= @answer %>? " - end - assert_equal("junk.txt", answer) - assert_equal( "Enter a filename: " + - "Are you sure you want to overwrite junk.txt? ", - @output.string ) - end - - def test_defaults - @input << "\nNo Comment\n" - @input.rewind - - answer = @terminal.ask("Are you sexually active? ") do |q| - q.validate = /\Ay(?:es)?|no?|no comment\Z/i - end - assert_equal("No Comment", answer) - - @input.truncate(@input.rewind) - @input << "\nYes\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Are you sexually active? ") do |q| - q.default = "No Comment" - q.validate = /\Ay(?:es)?|no?|no comment\Z/i - end - assert_equal("No Comment", answer) - assert_equal( "Are you sexually active? |No Comment| ", - @output.string ) - end - - def test_empty - @input << "\n" - @input.rewind - - answer = @terminal.ask("") do |q| - q.default = "yes" - q.validate = /\Ay(?:es)?|no?\Z/i - end - assert_equal("yes", answer) - end - - def test_erb - @terminal.say( "The integers from 1 to 10 are:\n" + - "% (1...10).each do |n|\n" + - "\t<%= n %>,\n" + - "% end\n" + - "\tand 10" ) - assert_equal( "The integers from 1 to 10 are:\n" + - "\t1,\n\t2,\n\t3,\n\t4,\n\t5,\n" + - "\t6,\n\t7,\n\t8,\n\t9,\n\tand 10\n", - @output.string ) - end - - def test_files - @input << "#{File.basename(__FILE__)[0, 5]}\n" - @input.rewind - - file = @terminal.ask("Select a file: ", File) do |q| - q.directory = File.expand_path(File.dirname(__FILE__)) - q.glob = "*.rb" - end - assert_instance_of(File, file) - assert_equal("#!/usr/local/bin/ruby -w\n", file.gets) - assert_equal("\n", file.gets) - assert_equal("# tc_highline.rb\n", file.gets) - file.close - - @input.rewind - - pathname = @terminal.ask("Select a file: ", Pathname) do |q| - q.directory = File.expand_path(File.dirname(__FILE__)) - q.glob = "*.rb" - end - assert_instance_of(Pathname, pathname) - assert_equal(File.size(__FILE__), pathname.size) - end - - def test_gather - @input << "James\nDana\nStorm\nGypsy\n\n" - @input.rewind - - answers = @terminal.ask("Enter four names:") do |q| - q.gather = 4 - end - assert_equal(%w{James Dana Storm Gypsy}, answers) - assert_equal("\n", @input.gets) - assert_equal("Enter four names:\n", @output.string) - - @input.rewind - - answers = @terminal.ask("Enter four names:") do |q| - q.gather = "" - end - assert_equal(%w{James Dana Storm Gypsy}, answers) - - @input.rewind - - answers = @terminal.ask("Enter four names:") do |q| - q.gather = /^\s*$/ - end - assert_equal(%w{James Dana Storm Gypsy}, answers) - - @input.truncate(@input.rewind) - @input << "29\n49\n30\n" - @input.rewind - @output.truncate(@output.rewind) - - answers = @terminal.ask("<%= @key %>: ", Integer) do |q| - q.gather = { "Age" => 0, "Wife's Age" => 0, "Father's Age" => 0} - end - assert_equal( { "Age" => 29, "Wife's Age" => 30, "Father's Age" => 49}, - answers ) - assert_equal("Age: Father's Age: Wife's Age: ", @output.string) - end - - def test_lists - digits = %w{Zero One Two Three Four Five Six Seven Eight Nine} - erb_digits = digits.dup - erb_digits[erb_digits.index("Five")] = "<%= color('Five', :blue) %%>" - - @terminal.say("<%= list(#{digits.inspect}) %>") - assert_equal(digits.map { |d| "#{d}\n" }.join, @output.string) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :inline) %>") - assert_equal( digits[0..-2].join(", ") + " or #{digits.last}\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :inline, ' and ') %>") - assert_equal( digits[0..-2].join(", ") + " and #{digits.last}\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :columns_down, 3) %>") - assert_equal( "Zero Four Eight\n" + - "One Five Nine \n" + - "Two Six \n" + - "Three Seven\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{erb_digits.inspect}, :columns_down, 3) %>") - assert_equal( "Zero Four Eight\n" + - "One \e[34mFive\e[0m Nine \n" + - "Two Six \n" + - "Three Seven\n", - @output.string ) - - colums_of_twenty = ["12345678901234567890"] * 5 - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{colums_of_twenty.inspect}, :columns_down) %>") - assert_equal( "12345678901234567890 12345678901234567890 " + - "12345678901234567890\n" + - "12345678901234567890 12345678901234567890\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :columns_across, 3) %>") - assert_equal( "Zero One Two \n" + - "Three Four Five \n" + - "Six Seven Eight\n" + - "Nine \n", - @output.string ) - - colums_of_twenty.pop - - @output.truncate(@output.rewind) - - @terminal.say("<%= list( #{colums_of_twenty.inspect}, :columns_across ) %>") - assert_equal( "12345678901234567890 12345678901234567890 " + - "12345678901234567890\n" + - "12345678901234567890\n", - @output.string ) - end - - def test_mode - assert(%w[Win32API termios stty].include?(HighLine::CHARACTER_MODE)) - end - - class NameClass - def self.parse( string ) - if string =~ /^\s*(\w+),\s*(\w+)\s+(\w+)\s*$/ - self.new($2, $3, $1) - else - raise ArgumentError, "Invalid name format." - end - end - - def initialize(first, middle, last) - @first, @middle, @last = first, middle, last - end - - attr_reader :first, :middle, :last - end - - def test_my_class_conversion - @input << "Gray, James Edward\n" - @input.rewind - - answer = @terminal.ask("Your name? ", NameClass) do |q| - q.validate = lambda do |name| - names = name.split(/,\s*/) - return false unless names.size == 2 - return false if names.first =~ /\s/ - names.last.split.size == 2 - end - end - assert_instance_of(NameClass, answer) - assert_equal("Gray", answer.last) - assert_equal("James", answer.first) - assert_equal("Edward", answer.middle) - end - - def test_no_echo - @input << "password\r" - @input.rewind - - answer = @terminal.ask("Please enter your password: ") do |q| - q.echo = false - end - assert_equal("password", answer) - assert_equal("Please enter your password: \n", @output.string) - - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Pick a letter or number: ") do |q| - q.character = true - q.echo = false - end - assert_equal("p", answer) - assert_equal("a", @input.getc.chr) - assert_equal("Pick a letter or number: \n", @output.string) - end - - def test_paging - @terminal.page_at = 22 - - @input << "\n\n" - @input.rewind - - @terminal.say((1..50).map { |n| "This is line #{n}.\n"}.join) - assert_equal( (1..22).map { |n| "This is line #{n}.\n"}.join + - "\n-- press enter/return to continue or q to stop -- \n\n" + - (23..44).map { |n| "This is line #{n}.\n"}.join + - "\n-- press enter/return to continue or q to stop -- \n\n" + - (45..50).map { |n| "This is line #{n}.\n"}.join, - @output.string ) - end - - def test_range_requirements - @input << "112\n-541\n28\n" - @input.rewind - - answer = @terminal.ask("Tell me your age.", Integer) do |q| - q.in = 0..105 - end - assert_equal(28, answer) - assert_equal( "Tell me your age.\n" + - "Your answer isn't within the expected range " + - "(included in 0..105).\n" + - "? " + - "Your answer isn't within the expected range " + - "(included in 0..105).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "1\n-541\n28\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Tell me your age.", Integer) do |q| - q.above = 3 - end - assert_equal(28, answer) - assert_equal( "Tell me your age.\n" + - "Your answer isn't within the expected range " + - "(above 3).\n" + - "? " + - "Your answer isn't within the expected range " + - "(above 3).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "1\n28\n-541\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Lowest numer you can think of?", Integer) do |q| - q.below = 0 - end - assert_equal(-541, answer) - assert_equal( "Lowest numer you can think of?\n" + - "Your answer isn't within the expected range " + - "(below 0).\n" + - "? " + - "Your answer isn't within the expected range " + - "(below 0).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "1\n-541\n6\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Enter a low even number: ", Integer) do |q| - q.above = 0 - q.below = 10 - q.in = [2, 4, 6, 8] - end - assert_equal(6, answer) - assert_equal( "Enter a low even number: " + - "Your answer isn't within the expected range " + - "(above 0, below 10, and included in [2, 4, 6, 8]).\n" + - "? " + - "Your answer isn't within the expected range " + - "(above 0, below 10, and included in [2, 4, 6, 8]).\n" + - "? ", @output.string ) - end - - def test_reask - number = 61676 - @input << "Junk!\n" << number << "\n" - @input.rewind - - answer = @terminal.ask("Favorite number? ", Integer) - assert_kind_of(Integer, number) - assert_instance_of(Fixnum, number) - assert_equal(number, answer) - assert_equal( "Favorite number? " + - "You must enter a valid Integer.\n" + - "? ", @output.string ) - - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Favorite number? ", Integer) do |q| - q.responses[:ask_on_error] = :question - q.responses[:invalid_type] = "Not a valid number!" - end - assert_kind_of(Integer, number) - assert_instance_of(Fixnum, number) - assert_equal(number, answer) - assert_equal( "Favorite number? " + - "Not a valid number!\n" + - "Favorite number? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "gen\ngene\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Select a mode: ", [:generate, :gentle]) - assert_instance_of(Symbol, answer) - assert_equal(:generate, answer) - assert_equal( "Select a mode: " + - "Ambiguous choice. " + - "Please choose one of [:generate, :gentle].\n" + - "? ", @output.string ) - end - - def test_response_embedding - @input << "112\n-541\n28\n" - @input.rewind - - answer = @terminal.ask("Tell me your age.", Integer) do |q| - q.in = 0..105 - q.responses[:not_in_range] = "Need a <%= @question.answer_type %>" + - " <%= @question.expected_range %>." - end - assert_equal(28, answer) - assert_equal( "Tell me your age.\n" + - "Need a Integer included in 0..105.\n" + - "? " + - "Need a Integer included in 0..105.\n" + - "? ", @output.string ) - end - - def test_say - @terminal.say("This will have a newline.") - assert_equal("This will have a newline.\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say("This will also have one newline.\n") - assert_equal("This will also have one newline.\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say("This will not have a newline. ") - assert_equal("This will not have a newline. ", @output.string) - end - - def test_type_conversion - number = 61676 - @input << number << "\n" - @input.rewind - - answer = @terminal.ask("Favorite number? ", Integer) - assert_kind_of(Integer, answer) - assert_instance_of(Fixnum, answer) - assert_equal(number, answer) - - @input.truncate(@input.rewind) - number = 1_000_000_000_000_000_000_000_000_000_000 - @input << number << "\n" - @input.rewind - - answer = @terminal.ask("Favorite number? ", Integer) - assert_kind_of(Integer, answer) - assert_instance_of(Bignum, answer) - assert_equal(number, answer) - - @input.truncate(@input.rewind) - number = 10.5002 - @input << number << "\n" - @input.rewind - - answer = @terminal.ask( "Favorite number? ", - lambda { |n| n.to_f.abs.round } ) - assert_kind_of(Integer, answer) - assert_instance_of(Fixnum, answer) - assert_equal(11, answer) - - @input.truncate(@input.rewind) - animal = :dog - @input << animal << "\n" - @input.rewind - - answer = @terminal.ask("Favorite animal? ", Symbol) - assert_instance_of(Symbol, answer) - assert_equal(animal, answer) - - @input.truncate(@input.rewind) - @input << "6/16/76\n" - @input.rewind - - answer = @terminal.ask("Enter your birthday.", Date) - assert_instance_of(Date, answer) - assert_equal(16, answer.day) - assert_equal(6, answer.month) - assert_equal(76, answer.year) - - @input.truncate(@input.rewind) - pattern = "^yes|no$" - @input << pattern << "\n" - @input.rewind - - answer = @terminal.ask("Give me a pattern to match with: ", Regexp) - assert_instance_of(Regexp, answer) - assert_equal(/#{pattern}/, answer) - - @input.truncate(@input.rewind) - @input << "gen\n" - @input.rewind - - answer = @terminal.ask("Select a mode: ", [:generate, :run]) - assert_instance_of(Symbol, answer) - assert_equal(:generate, answer) - end - - def test_validation - @input << "system 'rm -rf /'\n105\n0b101_001\n" - @input.rewind - - answer = @terminal.ask("Enter a binary number: ") do |q| - q.validate = /\A(?:0b)?[01_]+\Z/ - end - assert_equal("0b101_001", answer) - assert_equal( "Enter a binary number: " + - "Your answer isn't valid " + - "(must match /\\A(?:0b)?[01_]+\\Z/).\n" + - "? " + - "Your answer isn't valid " + - "(must match /\\A(?:0b)?[01_]+\\Z/).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "Gray II, James Edward\n" + - "Gray, Dana Ann Leslie\n" + - "Gray, James Edward\n" - @input.rewind - - answer = @terminal.ask("Your name? ") do |q| - q.validate = lambda do |name| - names = name.split(/,\s*/) - return false unless names.size == 2 - return false if names.first =~ /\s/ - names.last.split.size == 2 - end - end - assert_equal("Gray, James Edward", answer) - end - - def test_whitespace - @input << " A lot\tof \t space\t \there! \n" - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :chomp - end - assert_equal(" A lot\tof \t space\t \there! ", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") - assert_equal("A lot\tof \t space\t \there!", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :strip_and_collapse - end - assert_equal("A lot of space here!", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :remove - end - assert_equal("Alotofspacehere!", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :none - end - assert_equal(" A lot\tof \t space\t \there! \n", answer) - end - - def test_wrap - @terminal.wrap_at = 80 - - @terminal.say("This is a very short line.") - assert_equal("This is a very short line.\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say( "This is a long flowing paragraph meant to span " + - "several lines. This text should definitely be " + - "wrapped at the set limit, in the result. Your code " + - "does well with things like this.\n\n" + - " * This is a simple embedded list.\n" + - " * You're code should not mess with this...\n" + - " * Because it's already formatted correctly and " + - "does not\n" + - " exceed the limit!" ) - assert_equal( "This is a long flowing paragraph meant to span " + - "several lines. This text should\n" + - "definitely be wrapped at the set limit, in the " + - "result. Your code does well with\n" + - "things like this.\n\n" + - " * This is a simple embedded list.\n" + - " * You're code should not mess with this...\n" + - " * Because it's already formatted correctly and does " + - "not\n" + - " exceed the limit!\n", @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("-=" * 50) - assert_equal(("-=" * 40 + "\n") + ("-=" * 10 + "\n"), @output.string) - end - - def test_track_eof - assert_raise(EOFError) { @terminal.ask("Any input left? ") } - - # turn EOF tracking - old_setting = HighLine.track_eof? - assert_nothing_raised(Exception) { HighLine.track_eof = false } - begin - @terminal.ask("And now? ") # this will still blow up, nothing available - rescue - assert_not_equal(EOFError, $!.class) # but HighLine's safe guards are off - end - HighLine.track_eof = old_setting - end - - def test_version - assert_not_nil(HighLine::VERSION) - assert_instance_of(String, HighLine::VERSION) - assert(HighLine::VERSION.frozen?) - assert_match(/\A\d\.\d\.\d\Z/, HighLine::VERSION) - end -end diff --git a/vendor/gems/highline-1.5.0/test/tc_import.rb b/vendor/gems/highline-1.5.0/test/tc_import.rb deleted file mode 100644 index 005d5a92..00000000 --- a/vendor/gems/highline-1.5.0/test/tc_import.rb +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_import.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline/import" -require "stringio" - -class TestImport < Test::Unit::TestCase - def test_import - assert_respond_to(self, :agree) - assert_respond_to(self, :ask) - assert_respond_to(self, :choose) - assert_respond_to(self, :say) - end - - def test_or_ask - old_terminal = $terminal - - input = StringIO.new - output = StringIO.new - $terminal = HighLine.new(input, output) - - input << "10\n" - input.rewind - - assert_equal(10, nil.or_ask("How much? ", Integer)) - - input.rewind - - assert_equal(20, "20".or_ask("How much? ", Integer)) - assert_equal(20, 20.or_ask("How much? ", Integer)) - - assert_equal(10, 20.or_ask("How much? ", Integer) { |q| q.in = 1..10 }) - ensure - $terminal = old_terminal - end - - def test_redirection - old_terminal = $terminal - - $terminal = HighLine.new(nil, (output = StringIO.new)) - say("Testing...") - assert_equal("Testing...\n", output.string) - ensure - $terminal = old_terminal - end -end diff --git a/vendor/gems/highline-1.5.0/test/tc_menu.rb b/vendor/gems/highline-1.5.0/test/tc_menu.rb deleted file mode 100644 index fee18714..00000000 --- a/vendor/gems/highline-1.5.0/test/tc_menu.rb +++ /dev/null @@ -1,429 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_menu.rb -# -# Created by Gregory Thomas Brown on 2005-05-10. -# Copyright 2005. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline" -require "stringio" - -class TestMenu < Test::Unit::TestCase - def setup - @input = StringIO.new - @output = StringIO.new - @terminal = HighLine.new(@input, @output) - end - - def test_choices - @input << "2\n" - @input.rewind - - output = @terminal.choose do |menu| - menu.choices("Sample1", "Sample2", "Sample3") - end - assert_equal("Sample2", output) - end - - def test_flow - @input << "Sample1\n" - @input.rewind - - @terminal.choose do |menu| - # Default: menu.flow = :rows - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("1. Sample1\n2. Sample2\n3. Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.flow = :columns_across - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("1. Sample1 2. Sample2 3. Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.flow = :inline - menu.index = :none - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1, Sample2 or Sample3? ", @output.string) - end - - def test_help - @input << "help\nhelp load\nhelp rules\nhelp missing\n" - @input.rewind - - 4.times do - @terminal.choose do |menu| - menu.shell = true - - menu.choice(:load, "Load a file.") - menu.choice(:save, "Save data in file.") - menu.choice(:quit, "Exit program.") - - menu.help("rules", "The rules of this system are as follows...") - end - end - assert_equal( "1. load\n2. save\n3. quit\n4. help\n? " + - "This command will display helpful messages about " + - "functionality, like this one. To see the help for a " + - "specific topic enter:\n" + - "\thelp [TOPIC]\n" + - "Try asking for help on any of the following:\n" + - "\nload quit rules save \n" + - "1. load\n2. save\n3. quit\n4. help\n? " + - "= load\n\n" + - "Load a file.\n" + - "1. load\n2. save\n3. quit\n4. help\n? " + - "= rules\n\n" + - "The rules of this system are as follows...\n" + - "1. load\n2. save\n3. quit\n4. help\n? " + - "= missing\n\n" + - "There's no help for that topic.\n", @output.string ) - end - - def test_index - @input << "Sample1\n" - @input.rewind - - @terminal.choose do |menu| - # Default: menu.index = :number - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("1. Sample1\n2. Sample2\n3. Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.index = :letter - menu.index_suffix = ") " - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("a) Sample1\nb) Sample2\nc) Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.index = :none - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1\nSample2\nSample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.index = "*" - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("* Sample1\n* Sample2\n* Sample3\n? ", @output.string) - end - - def test_layouts - @input << "save\n" - @input.rewind - - @terminal.choose(:load, :save, :quit) # Default: layout = :list - assert_equal("1. load\n2. save\n3. quit\n? ", @output.string) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.header = "File Menu" - end - assert_equal( "File Menu:\n" + - "1. load\n2. save\n3. quit\n? ", @output.string ) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = :one_line - menu.header = "File Menu" - menu.prompt = "Operation? " - end - assert_equal( "File Menu: Operation? " + - "(load, save or quit) ", @output.string ) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = :menu_only - end - assert_equal("load, save or quit? ", @output.string) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = '<%= list(@menu) %>File Menu: ' - end - assert_equal("1. load\n2. save\n3. quit\nFile Menu: ", @output.string) - end - - def test_list_option - @input << "l\n" - @input.rewind - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = :menu_only - menu.list_option = ", or " - end - assert_equal("load, save, or quit? ", @output.string) - end - - def test_nil_on_handled - @input << "3\n3\n2\n" - @input.rewind - - # Shows that by default proc results are returned. - output = @terminal.choose do |menu| - menu.choice "Sample1" do "output1" end - menu.choice "Sample2" do "output2" end - menu.choice "Sample3" do "output3" end - end - assert_equal("output3", output) - - # - # Shows that they can be replaced with +nil+ by setting - # _nil_on_handled to +true+. - # - output = @terminal.choose do |menu| - menu.nil_on_handled = true - menu.choice "Sample1" do "output1" end - menu.choice "Sample2" do "output2" end - menu.choice "Sample3" do "output3" end - end - assert_equal(nil, output) - - # Shows that a menu item without a proc will be returned no matter what. - output = @terminal.choose do |menu| - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample2", output) - end - - def test_passed_command - @input << "q\n" - @input.rewind - - selected = nil - @terminal.choose do |menu| - menu.choices(:load, :save, :quit) { |command| selected = command } - end - assert_equal(:quit, selected) - end - - def test_question_options - @input << "save\n" - @input.rewind - - answer = @terminal.choose(:Load, :Save, :Quit) do |menu| - menu.case = :capitalize - end - assert_equal(:Save, answer) - - @input.rewind - - answer = @terminal.choose(:Load, :Save, :Quit) do |menu| - menu.case = :capitalize - menu.character = :getc - end - assert_equal(:Save, answer) - assert_equal(?a, @input.getc) - end - - def test_select_by - @input << "Sample1\n2\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1", selected) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :index - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample2", selected) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :name - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1", selected) - end - - def test_hidden - @input << "Hidden\n4\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - menu.hidden "Hidden!" - end - assert_equal("Hidden!", selected) - assert_equal("1. Sample1\n2. Sample2\n3. Sample3\n? ", @output.string) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :index - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - menu.hidden "Hidden!" - end - assert_equal("Hidden!", selected) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :name - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - menu.hidden "Hidden!" - end - assert_equal("Hidden!", selected) - - @input.rewind - end - - def test_select_by_letter - @input << "b\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.index = :letter - menu.choice :save - menu.choice :load - menu.choice :quit - end - assert_equal(:load, selected) - end - - def test_shell - @input << "save --some-option my_file.txt\n" - @input.rewind - - selected = nil - options = nil - answer = @terminal.choose do |menu| - menu.choices(:load, :quit) - menu.choice(:save) do |command, details| - selected = command - options = details - - "Saved!" - end - menu.shell = true - end - assert_equal("Saved!", answer) - assert_equal(:save, selected) - assert_equal("--some-option my_file.txt", options) - end - - def test_simple_menu_shortcut - @input << "3\n" - @input.rewind - - selected = @terminal.choose(:save, :load, :quit) - assert_equal(:quit, selected) - end - - def test_symbols - @input << "3\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.choices(:save, :load, :quit) - end - assert_equal(:quit, selected) - end - - def test_paged_print_infinite_loop_bug - @terminal.page_at = 5 - # Will page twice, so start with two new lines - @input << "\n\n3\n" - @input.rewind - - # Sadly this goes into an infinite loop without the fix to page_print - selected = @terminal.choose(* 1..10) - assert_equal(selected, 3) - end - - - def test_cancel_paging - # Tests that paging can be cancelled halfway through - @terminal.page_at = 5 - # Will page twice, so stop after first page and make choice 3 - @input << "q\n3\n" - @input.rewind - - selected = @terminal.choose(* 1..10) - assert_equal(selected, 3) - - # Make sure paging message appeared - assert( @output.string.index('press enter/return to continue or q to stop'), - "Paging message did not appear." ) - - # Make sure it only appeared once - assert( @output.string !~ /q to stop.*q to stop/m, - "Paging message appeared more than once." ) - end -end diff --git a/vendor/gems/highline-1.5.0/test/ts_all.rb b/vendor/gems/highline-1.5.0/test/ts_all.rb deleted file mode 100644 index 735dccee..00000000 --- a/vendor/gems/highline-1.5.0/test/ts_all.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/local/bin/ruby -w - -# ts_all.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "tc_highline" -require "tc_import" -require "tc_menu" -require "tc_color_scheme" diff --git a/vendor/gems/rack-1.1.0/.specification b/vendor/gems/rack-1.1.0/.specification deleted file mode 100644 index ef892653..00000000 --- a/vendor/gems/rack-1.1.0/.specification +++ /dev/null @@ -1,314 +0,0 @@ ---- !ruby/object:Gem::Specification -name: rack -version: !ruby/object:Gem::Version - hash: 19 - prerelease: false - segments: - - 1 - - 1 - - 0 - version: 1.1.0 -platform: ruby -authors: -- Christian Neukirchen -autorequire: -bindir: bin -cert_chain: [] - -date: 2010-01-04 00:00:00 +01:00 -default_executable: rackup -dependencies: -- !ruby/object:Gem::Dependency - name: test-spec - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id001 -- !ruby/object:Gem::Dependency - name: camping - prerelease: false - requirement: &id002 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id002 -- !ruby/object:Gem::Dependency - name: fcgi - prerelease: false - requirement: &id003 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id003 -- !ruby/object:Gem::Dependency - name: memcache-client - prerelease: false - requirement: &id004 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id004 -- !ruby/object:Gem::Dependency - name: mongrel - prerelease: false - requirement: &id005 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id005 -- !ruby/object:Gem::Dependency - name: thin - prerelease: false - requirement: &id006 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" - type: :development - version_requirements: *id006 -description: | - Rack provides minimal, modular and adaptable interface for developing - web applications in Ruby. By wrapping HTTP requests and responses in - the simplest way possible, it unifies and distills the API for web - servers, web frameworks, and software in between (the so-called - middleware) into a single method call. - - Also see http://rack.rubyforge.org. - -email: chneukirchen@gmail.com -executables: -- rackup -extensions: [] - -extra_rdoc_files: -- README -- SPEC -- KNOWN-ISSUES -files: -- bin/rackup -- contrib/rack_logo.svg -- example/lobster.ru -- example/protectedlobster.rb -- example/protectedlobster.ru -- lib/rack/adapter/camping.rb -- lib/rack/auth/abstract/handler.rb -- lib/rack/auth/abstract/request.rb -- lib/rack/auth/basic.rb -- lib/rack/auth/digest/md5.rb -- lib/rack/auth/digest/nonce.rb -- lib/rack/auth/digest/params.rb -- lib/rack/auth/digest/request.rb -- lib/rack/builder.rb -- lib/rack/cascade.rb -- lib/rack/chunked.rb -- lib/rack/commonlogger.rb -- lib/rack/conditionalget.rb -- lib/rack/config.rb -- lib/rack/content_length.rb -- lib/rack/content_type.rb -- lib/rack/deflater.rb -- lib/rack/directory.rb -- lib/rack/etag.rb -- lib/rack/file.rb -- lib/rack/handler/cgi.rb -- lib/rack/handler/evented_mongrel.rb -- lib/rack/handler/fastcgi.rb -- lib/rack/handler/lsws.rb -- lib/rack/handler/mongrel.rb -- lib/rack/handler/scgi.rb -- lib/rack/handler/swiftiplied_mongrel.rb -- lib/rack/handler/thin.rb -- lib/rack/handler/webrick.rb -- lib/rack/handler.rb -- lib/rack/head.rb -- lib/rack/lint.rb -- lib/rack/lobster.rb -- lib/rack/lock.rb -- lib/rack/logger.rb -- lib/rack/methodoverride.rb -- lib/rack/mime.rb -- lib/rack/mock.rb -- lib/rack/nulllogger.rb -- lib/rack/recursive.rb -- lib/rack/reloader.rb -- lib/rack/request.rb -- lib/rack/response.rb -- lib/rack/rewindable_input.rb -- lib/rack/runtime.rb -- lib/rack/sendfile.rb -- lib/rack/server.rb -- lib/rack/session/abstract/id.rb -- lib/rack/session/cookie.rb -- lib/rack/session/memcache.rb -- lib/rack/session/pool.rb -- lib/rack/showexceptions.rb -- lib/rack/showstatus.rb -- lib/rack/static.rb -- lib/rack/urlmap.rb -- lib/rack/utils.rb -- lib/rack.rb -- COPYING -- KNOWN-ISSUES -- rack.gemspec -- RDOX -- README -- SPEC -- test/spec_rack_auth_basic.rb -- test/spec_rack_auth_digest.rb -- test/spec_rack_builder.rb -- test/spec_rack_camping.rb -- test/spec_rack_cascade.rb -- test/spec_rack_cgi.rb -- test/spec_rack_chunked.rb -- test/spec_rack_commonlogger.rb -- test/spec_rack_conditionalget.rb -- test/spec_rack_config.rb -- test/spec_rack_content_length.rb -- test/spec_rack_content_type.rb -- test/spec_rack_deflater.rb -- test/spec_rack_directory.rb -- test/spec_rack_etag.rb -- test/spec_rack_fastcgi.rb -- test/spec_rack_file.rb -- test/spec_rack_handler.rb -- test/spec_rack_head.rb -- test/spec_rack_lint.rb -- test/spec_rack_lobster.rb -- test/spec_rack_lock.rb -- test/spec_rack_logger.rb -- test/spec_rack_methodoverride.rb -- test/spec_rack_mock.rb -- test/spec_rack_mongrel.rb -- test/spec_rack_nulllogger.rb -- test/spec_rack_recursive.rb -- test/spec_rack_request.rb -- test/spec_rack_response.rb -- test/spec_rack_rewindable_input.rb -- test/spec_rack_runtime.rb -- test/spec_rack_sendfile.rb -- test/spec_rack_session_cookie.rb -- test/spec_rack_session_memcache.rb -- test/spec_rack_session_pool.rb -- test/spec_rack_showexceptions.rb -- test/spec_rack_showstatus.rb -- test/spec_rack_static.rb -- test/spec_rack_thin.rb -- test/spec_rack_urlmap.rb -- test/spec_rack_utils.rb -- test/spec_rack_webrick.rb -- test/spec_rackup.rb -has_rdoc: true -homepage: http://rack.rubyforge.org -licenses: [] - -post_install_message: -rdoc_options: [] - -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" -required_rubygems_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" -requirements: [] - -rubyforge_project: rack -rubygems_version: 1.3.7 -signing_key: -specification_version: 3 -summary: a modular Ruby webserver interface -test_files: -- test/spec_rack_auth_basic.rb -- test/spec_rack_auth_digest.rb -- test/spec_rack_builder.rb -- test/spec_rack_camping.rb -- test/spec_rack_cascade.rb -- test/spec_rack_cgi.rb -- test/spec_rack_chunked.rb -- test/spec_rack_commonlogger.rb -- test/spec_rack_conditionalget.rb -- test/spec_rack_config.rb -- test/spec_rack_content_length.rb -- test/spec_rack_content_type.rb -- test/spec_rack_deflater.rb -- test/spec_rack_directory.rb -- test/spec_rack_etag.rb -- test/spec_rack_fastcgi.rb -- test/spec_rack_file.rb -- test/spec_rack_handler.rb -- test/spec_rack_head.rb -- test/spec_rack_lint.rb -- test/spec_rack_lobster.rb -- test/spec_rack_lock.rb -- test/spec_rack_logger.rb -- test/spec_rack_methodoverride.rb -- test/spec_rack_mock.rb -- test/spec_rack_mongrel.rb -- test/spec_rack_nulllogger.rb -- test/spec_rack_recursive.rb -- test/spec_rack_request.rb -- test/spec_rack_response.rb -- test/spec_rack_rewindable_input.rb -- test/spec_rack_runtime.rb -- test/spec_rack_sendfile.rb -- test/spec_rack_session_cookie.rb -- test/spec_rack_session_memcache.rb -- test/spec_rack_session_pool.rb -- test/spec_rack_showexceptions.rb -- test/spec_rack_showstatus.rb -- test/spec_rack_static.rb -- test/spec_rack_thin.rb -- test/spec_rack_urlmap.rb -- test/spec_rack_utils.rb -- test/spec_rack_webrick.rb -- test/spec_rackup.rb diff --git a/vendor/gems/rack-1.1.0/COPYING b/vendor/gems/rack-1.1.0/COPYING deleted file mode 100644 index 83b390bc..00000000 --- a/vendor/gems/rack-1.1.0/COPYING +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2007, 2008, 2009, 2010 Christian Neukirchen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/rack-1.1.0/KNOWN-ISSUES b/vendor/gems/rack-1.1.0/KNOWN-ISSUES deleted file mode 100644 index a1af5dc1..00000000 --- a/vendor/gems/rack-1.1.0/KNOWN-ISSUES +++ /dev/null @@ -1,21 +0,0 @@ -= Known issues with Rack and Web servers - -* Lighttpd sets wrong SCRIPT_NAME and PATH_INFO if you mount your - FastCGI app at "/". This can be fixed by using this middleware: - - class LighttpdScriptNameFix - def initialize(app) - @app = app - end - - def call(env) - env["PATH_INFO"] = env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s - env["SCRIPT_NAME"] = "" - @app.call(env) - end - end - - Of course, use this only when your app runs at "/". - - Since lighttpd 1.4.23, you also can use the "fix-root-scriptname" flag - in fastcgi.server. diff --git a/vendor/gems/rack-1.1.0/RDOX b/vendor/gems/rack-1.1.0/RDOX deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/gems/rack-1.1.0/README b/vendor/gems/rack-1.1.0/README deleted file mode 100644 index 777b12d3..00000000 --- a/vendor/gems/rack-1.1.0/README +++ /dev/null @@ -1,399 +0,0 @@ -= Rack, a modular Ruby webserver interface - -Rack provides a minimal, modular and adaptable interface for developing -web applications in Ruby. By wrapping HTTP requests and responses in -the simplest way possible, it unifies and distills the API for web -servers, web frameworks, and software in between (the so-called -middleware) into a single method call. - -The exact details of this are described in the Rack specification, -which all Rack applications should conform to. - -== Specification changes in this release - -With Rack 1.1, the Rack specification (found in SPEC) changed in the -following backward-incompatible ways. - -* Rack::VERSION has been pushed to [1,1]. -* rack.logger is now specified. -* The SPEC now allows subclasses of the required types. -* rack.input has to be opened in binary mode. - -== Supported web servers - -The included *handlers* connect all kinds of web servers to Rack: -* Mongrel -* EventedMongrel -* SwiftipliedMongrel -* WEBrick -* FCGI -* CGI -* SCGI -* LiteSpeed -* Thin - -These web servers include Rack handlers in their distributions: -* Ebb -* Fuzed -* Glassfish v3 -* Phusion Passenger (which is mod_rack for Apache and for nginx) -* Rainbows! -* Unicorn -* Zbatery - -Any valid Rack app will run the same on all these handlers, without -changing anything. - -== Supported web frameworks - -The included *adapters* connect Rack with existing Ruby web frameworks: -* Camping - -These frameworks include Rack adapters in their distributions: -* Camping -* Coset -* Halcyon -* Mack -* Maveric -* Merb -* Racktools::SimpleApplication -* Ramaze -* Ruby on Rails -* Rum -* Sinatra -* Sin -* Vintage -* Waves -* Wee -* ... and many others. - -Current links to these projects can be found at -http://wiki.ramaze.net/Home#other-frameworks - -== Available middleware - -Between the server and the framework, Rack can be customized to your -applications needs using middleware, for example: -* Rack::URLMap, to route to multiple applications inside the same process. -* Rack::CommonLogger, for creating Apache-style logfiles. -* Rack::ShowException, for catching unhandled exceptions and - presenting them in a nice and helpful way with clickable backtrace. -* Rack::File, for serving static files. -* ...many others! - -All these components use the same interface, which is described in -detail in the Rack specification. These optional components can be -used in any way you wish. - -== Convenience - -If you want to develop outside of existing frameworks, implement your -own ones, or develop middleware, Rack provides many helpers to create -Rack applications quickly and without doing the same web stuff all -over: -* Rack::Request, which also provides query string parsing and - multipart handling. -* Rack::Response, for convenient generation of HTTP replies and - cookie handling. -* Rack::MockRequest and Rack::MockResponse for efficient and quick - testing of Rack application without real HTTP round-trips. - -== rack-contrib - -The plethora of useful middleware created the need for a project that -collects fresh Rack middleware. rack-contrib includes a variety of -add-on components for Rack and it is easy to contribute new modules. - -* http://github.com/rack/rack-contrib - -== rackup - -rackup is a useful tool for running Rack applications, which uses the -Rack::Builder DSL to configure middleware and build up applications -easily. - -rackup automatically figures out the environment it is run in, and -runs your application as FastCGI, CGI, or standalone with Mongrel or -WEBrick---all from the same configuration. - -== Quick start - -Try the lobster! - -Either with the embedded WEBrick starter: - - ruby -Ilib lib/rack/lobster.rb - -Or with rackup: - - bin/rackup -Ilib example/lobster.ru - -By default, the lobster is found at http://localhost:9292. - -== Installing with RubyGems - -A Gem of Rack is available at gemcutter.org. You can install it with: - - gem install rack - -I also provide a local mirror of the gems (and development snapshots) -at my site: - - gem install rack --source http://chneukirchen.org/releases/gems/ - -== Running the tests - -Testing Rack requires the test/spec testing framework: - - gem install test-spec - -There are two rake-based test tasks: - - rake test tests all the fast tests (no Handlers or Adapters) - rake fulltest runs all the tests - -The fast testsuite has no dependencies outside of the core Ruby -installation and test-spec. - -To run the test suite completely, you need: - - * camping - * fcgi - * memcache-client - * mongrel - * thin - -The full set of tests test FCGI access with lighttpd (on port -9203) so you will need lighttpd installed as well as the FCGI -libraries and the fcgi gem: - -Download and install lighttpd: - - http://www.lighttpd.net/download - -Installing the FCGI libraries: - - curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz - tar xzvf fcgi-2.4.0.tar.gz - cd fcgi-2.4.0 - ./configure --prefix=/usr/local - make - sudo make install - cd .. - -Installing the Ruby fcgi gem: - - gem install fcgi - -Furthermore, to test Memcache sessions, you need memcached (will be -run on port 11211) and memcache-client installed. - -== History - -* March 3rd, 2007: First public release 0.1. - -* May 16th, 2007: Second public release 0.2. - * HTTP Basic authentication. - * Cookie Sessions. - * Static file handler. - * Improved Rack::Request. - * Improved Rack::Response. - * Added Rack::ShowStatus, for better default error messages. - * Bug fixes in the Camping adapter. - * Removed Rails adapter, was too alpha. - -* February 26th, 2008: Third public release 0.3. - * LiteSpeed handler, by Adrian Madrid. - * SCGI handler, by Jeremy Evans. - * Pool sessions, by blink. - * OpenID authentication, by blink. - * :Port and :File options for opening FastCGI sockets, by blink. - * Last-Modified HTTP header for Rack::File, by blink. - * Rack::Builder#use now accepts blocks, by Corey Jewett. - (See example/protectedlobster.ru) - * HTTP status 201 can contain a Content-Type and a body now. - * Many bugfixes, especially related to Cookie handling. - -* August 21st, 2008: Fourth public release 0.4. - * New middleware, Rack::Deflater, by Christoffer Sawicki. - * OpenID authentication now needs ruby-openid 2. - * New Memcache sessions, by blink. - * Explicit EventedMongrel handler, by Joshua Peek - * Rack::Reloader is not loaded in rackup development mode. - * rackup can daemonize with -D. - * Many bugfixes, especially for pool sessions, URLMap, thread safety - and tempfile handling. - * Improved tests. - * Rack moved to Git. - -* January 6th, 2009: Fifth public release 0.9. - * Rack is now managed by the Rack Core Team. - * Rack::Lint is stricter and follows the HTTP RFCs more closely. - * Added ConditionalGet middleware. - * Added ContentLength middleware. - * Added Deflater middleware. - * Added Head middleware. - * Added MethodOverride middleware. - * Rack::Mime now provides popular MIME-types and their extension. - * Mongrel Header now streams. - * Added Thin handler. - * Official support for swiftiplied Mongrel. - * Secure cookies. - * Made HeaderHash case-preserving. - * Many bugfixes and small improvements. - -* January 9th, 2009: Sixth public release 0.9.1. - * Fix directory traversal exploits in Rack::File and Rack::Directory. - -* April 25th, 2009: Seventh public release 1.0.0. - * SPEC change: Rack::VERSION has been pushed to [1,0]. - * SPEC change: header values must be Strings now, split on "\n". - * SPEC change: Content-Length can be missing, in this case chunked transfer - encoding is used. - * SPEC change: rack.input must be rewindable and support reading into - a buffer, wrap with Rack::RewindableInput if it isn't. - * SPEC change: rack.session is now specified. - * SPEC change: Bodies can now additionally respond to #to_path with - a filename to be served. - * NOTE: String bodies break in 1.9, use an Array consisting of a - single String instead. - * New middleware Rack::Lock. - * New middleware Rack::ContentType. - * Rack::Reloader has been rewritten. - * Major update to Rack::Auth::OpenID. - * Support for nested parameter parsing in Rack::Response. - * Support for redirects in Rack::Response. - * HttpOnly cookie support in Rack::Response. - * The Rakefile has been rewritten. - * Many bugfixes and small improvements. - -* October 18th, 2009: Eighth public release 1.0.1. - * Bump remainder of rack.versions. - * Support the pure Ruby FCGI implementation. - * Fix for form names containing "=": split first then unescape components - * Fixes the handling of the filename parameter with semicolons in names. - * Add anchor to nested params parsing regexp to prevent stack overflows - * Use more compatible gzip write api instead of "<<". - * Make sure that Reloader doesn't break when executed via ruby -e - * Make sure WEBrick respects the :Host option - * Many Ruby 1.9 fixes. - -* January 3rd, 2009: Ninth public release 1.1.0. - * Moved Auth::OpenID to rack-contrib. - * SPEC change that relaxes Lint slightly to allow subclasses of the - required types - * SPEC change to document rack.input binary mode in greator detail - * SPEC define optional rack.logger specification - * File servers support X-Cascade header - * Imported Config middleware - * Imported ETag middleware - * Imported Runtime middleware - * Imported Sendfile middleware - * New Logger and NullLogger middlewares - * Added mime type for .ogv and .manifest. - * Don't squeeze PATH_INFO slashes - * Use Content-Type to determine POST params parsing - * Update Rack::Utils::HTTP_STATUS_CODES hash - * Add status code lookup utility - * Response should call #to_i on the status - * Add Request#user_agent - * Request#host knows about forwared host - * Return an empty string for Request#host if HTTP_HOST and - SERVER_NAME are both missing - * Allow MockRequest to accept hash params - * Optimizations to HeaderHash - * Refactored rackup into Rack::Server - * Added Utils.build_nested_query to complement Utils.parse_nested_query - * Added Utils::Multipart.build_multipart to complement - Utils::Multipart.parse_multipart - * Extracted set and delete cookie helpers into Utils so they can be - used outside Response - * Extract parse_query and parse_multipart in Request so subclasses - can change their behavior - * Enforce binary encoding in RewindableInput - * Set correct external_encoding for handlers that don't use RewindableInput - -== Contact - -Please post bugs, suggestions and patches to -the bug tracker at . - -Mailing list archives are available at -. - -Git repository (send Git patches to the mailing list): -* http://github.com/rack/rack -* http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git - -You are also welcome to join the #rack channel on irc.freenode.net. - -== Thanks - -The Rack Core Team, consisting of - -* Christian Neukirchen (chneukirchen) -* James Tucker (raggi) -* Josh Peek (josh) -* Michael Fellinger (manveru) -* Ryan Tomayko (rtomayko) -* Scytrin dai Kinthra (scytrin) - -would like to thank: - -* Adrian Madrid, for the LiteSpeed handler. -* Christoffer Sawicki, for the first Rails adapter and Rack::Deflater. -* Tim Fletcher, for the HTTP authentication code. -* Luc Heinrich for the Cookie sessions, the static file handler and bugfixes. -* Armin Ronacher, for the logo and racktools. -* Aredridel, Ben Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd, - Tom Robinson, Phil Hagelberg, S. Brent Faulkner, Bosko Milekic, - Daniel Rodríguez Troitiño, Genki Takiuchi, Geoffrey Grosenbach, - Julien Sanchez, Kamal Fariz Mahyuddin, Masayoshi Takahashi, Patrick - Aljordm, Mig, and Kazuhiro Nishiyama for bug fixing and other - improvements. -* Eric Wong, Hongli Lai, Jeremy Kemper for their continuous support - and API improvements. -* Yehuda Katz and Carl Lerche for refactoring rackup. -* Brian Candler, for Rack::ContentType. -* Graham Batty, for improved handler loading. -* Stephen Bannasch, for bug reports and documentation. -* Gary Wright, for proposing a better Rack::Response interface. -* Jonathan Buch, for improvements regarding Rack::Response. -* Armin Röhrl, for tracking down bugs in the Cookie generator. -* Alexander Kellett for testing the Gem and reviewing the announcement. -* Marcus Rückert, for help with configuring and debugging lighttpd. -* The WSGI team for the well-done and documented work they've done and - Rack builds up on. -* All bug reporters and patch contributers not mentioned above. - -== Copyright - -Copyright (C) 2007, 2008, 2009, 2010 Christian Neukirchen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -== Links - -Rack:: -Rack's Rubyforge project:: -Official Rack repositories:: -Rack Lighthouse Bug Tracking:: -rack-devel mailing list:: - -Christian Neukirchen:: - diff --git a/vendor/gems/rack-1.1.0/SPEC b/vendor/gems/rack-1.1.0/SPEC deleted file mode 100644 index d2260cbe..00000000 --- a/vendor/gems/rack-1.1.0/SPEC +++ /dev/null @@ -1,171 +0,0 @@ -This specification aims to formalize the Rack protocol. You -can (and should) use Rack::Lint to enforce it. -When you develop middleware, be sure to add a Lint before and -after to catch all mistakes. -= Rack applications -A Rack application is an Ruby object (not a class) that -responds to +call+. -It takes exactly one argument, the *environment* -and returns an Array of exactly three values: -The *status*, -the *headers*, -and the *body*. -== The Environment -The environment must be an true instance of Hash (no -subclassing allowed) that includes CGI-like headers. -The application is free to modify the environment. -The environment is required to include these variables -(adopted from PEP333), except when they'd be empty, but see -below. -REQUEST_METHOD:: The HTTP request method, such as - "GET" or "POST". This cannot ever - be an empty string, and so is - always required. -SCRIPT_NAME:: The initial portion of the request - URL's "path" that corresponds to the - application object, so that the - application knows its virtual - "location". This may be an empty - string, if the application corresponds - to the "root" of the server. -PATH_INFO:: The remainder of the request URL's - "path", designating the virtual - "location" of the request's target - within the application. This may be an - empty string, if the request URL targets - the application root and does not have a - trailing slash. This value may be - percent-encoded when I originating from - a URL. -QUERY_STRING:: The portion of the request URL that - follows the ?, if any. May be - empty, but is always required! -SERVER_NAME, SERVER_PORT:: When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required. -HTTP_ Variables:: Variables corresponding to the - client-supplied HTTP request - headers (i.e., variables whose - names begin with HTTP_). The - presence or absence of these - variables should correspond with - the presence or absence of the - appropriate HTTP header in the - request. -In addition to this, the Rack environment must include these -Rack-specific variables: -rack.version:: The Array [1,1], representing this version of Rack. -rack.url_scheme:: +http+ or +https+, depending on the request URL. -rack.input:: See below, the input stream. -rack.errors:: See below, the error stream. -rack.multithread:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise. -rack.multiprocess:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise. -rack.run_once:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar). -Additional environment specifications have approved to -standardized middleware APIs. None of these are required to -be implemented by the server. -rack.session:: A hash like interface for storing request session data. - The store must implement: - store(key, value) (aliased as []=); - fetch(key, default = nil) (aliased as []); - delete(key); - clear; -rack.logger:: A common object interface for logging messages. - The object must implement: - info(message, &block) - debug(message, &block) - warn(message, &block) - error(message, &block) - fatal(message, &block) -The server or the application can store their own data in the -environment, too. The keys must contain at least one dot, -and should be prefixed uniquely. The prefix rack. -is reserved for use with the Rack core distribution and other -accepted specifications and must not be used otherwise. -The environment must not contain the keys -HTTP_CONTENT_TYPE or HTTP_CONTENT_LENGTH -(use the versions without HTTP_). -The CGI keys (named without a period) must have String values. -There are the following restrictions: -* rack.version must be an array of Integers. -* rack.url_scheme must either be +http+ or +https+. -* There must be a valid input stream in rack.input. -* There must be a valid error stream in rack.errors. -* The REQUEST_METHOD must be a valid token. -* The SCRIPT_NAME, if non-empty, must start with / -* The PATH_INFO, if non-empty, must start with / -* The CONTENT_LENGTH, if given, must consist of digits only. -* One of SCRIPT_NAME or PATH_INFO must be - set. PATH_INFO should be / if - SCRIPT_NAME is empty. - SCRIPT_NAME never should be /, but instead be empty. -=== The Input Stream -The input stream is an IO-like object which contains the raw HTTP -POST data. -When applicable, its external encoding must be "ASCII-8BIT" and it -must be opened in binary mode, for Ruby 1.9 compatibility. -The input stream must respond to +gets+, +each+, +read+ and +rewind+. -* +gets+ must be called without arguments and return a string, - or +nil+ on EOF. -* +read+ behaves like IO#read. Its signature is read([length, [buffer]]). - If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must - be a String and may not be nil. If +length+ is given and not nil, then this method - reads at most +length+ bytes from the input stream. If +length+ is not given or nil, - then this method reads all data until EOF. - When EOF is reached, this method returns nil if +length+ is given and not nil, or "" - if +length+ is not given or is nil. - If +buffer+ is given, then the read data will be placed into +buffer+ instead of a - newly created String object. -* +each+ must be called without arguments and only yield Strings. -* +rewind+ must be called without arguments. It rewinds the input - stream back to the beginning. It must not raise Errno::ESPIPE: - that is, it may not be a pipe or a socket. Therefore, handler - developers must buffer the input data into some rewindable object - if the underlying input stream is not rewindable. -* +close+ must never be called on the input stream. -=== The Error Stream -The error stream must respond to +puts+, +write+ and +flush+. -* +puts+ must be called with a single argument that responds to +to_s+. -* +write+ must be called with a single argument that is a String. -* +flush+ must be called without arguments and must be called - in order to make the error appear for sure. -* +close+ must never be called on the error stream. -== The Response -=== The Status -This is an HTTP status. When parsed as integer (+to_i+), it must be -greater than or equal to 100. -=== The Headers -The header must respond to +each+, and yield values of key and value. -The header keys must be Strings. -The header must not contain a +Status+ key, -contain keys with : or newlines in their name, -contain keys names that end in - or _, -but only contain keys that consist of -letters, digits, _ or - and start with a letter. -The values of the header must be Strings, -consisting of lines (for multiple header values, e.g. multiple -Set-Cookie values) seperated by "\n". -The lines must not contain characters below 037. -=== The Content-Type -There must be a Content-Type, except when the -+Status+ is 1xx, 204 or 304, in which case there must be none -given. -=== The Content-Length -There must not be a Content-Length header when the -+Status+ is 1xx, 204 or 304. -=== The Body -The Body must respond to +each+ -and must only yield String values. -The Body itself should not be an instance of String, as this will -break in Ruby 1.9. -If the Body responds to +close+, it will be called after iteration. -If the Body responds to +to_path+, it must return a String -identifying the location of a file whose contents are identical -to that produced by calling +each+; this may be used by the -server as an alternative, possibly more efficient way to -transport the response. -The Body commonly is an Array of Strings, the application -instance itself, or a File-like object. -== Thanks -Some parts of this specification are adopted from PEP333: Python -Web Server Gateway Interface -v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank -everyone involved in that effort. diff --git a/vendor/gems/rack-1.1.0/bin/rackup b/vendor/gems/rack-1.1.0/bin/rackup deleted file mode 100755 index ad94af4b..00000000 --- a/vendor/gems/rack-1.1.0/bin/rackup +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require "rack" -Rack::Server.start diff --git a/vendor/gems/rack-1.1.0/contrib/rack_logo.svg b/vendor/gems/rack-1.1.0/contrib/rack_logo.svg deleted file mode 100644 index 905dcd32..00000000 --- a/vendor/gems/rack-1.1.0/contrib/rack_logo.svg +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - diff --git a/vendor/gems/rack-1.1.0/example/lobster.ru b/vendor/gems/rack-1.1.0/example/lobster.ru deleted file mode 100644 index cc7ffcae..00000000 --- a/vendor/gems/rack-1.1.0/example/lobster.ru +++ /dev/null @@ -1,4 +0,0 @@ -require 'rack/lobster' - -use Rack::ShowExceptions -run Rack::Lobster.new diff --git a/vendor/gems/rack-1.1.0/example/protectedlobster.rb b/vendor/gems/rack-1.1.0/example/protectedlobster.rb deleted file mode 100644 index 108b9d05..00000000 --- a/vendor/gems/rack-1.1.0/example/protectedlobster.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rack' -require 'rack/lobster' - -lobster = Rack::Lobster.new - -protected_lobster = Rack::Auth::Basic.new(lobster) do |username, password| - 'secret' == password -end - -protected_lobster.realm = 'Lobster 2.0' - -pretty_protected_lobster = Rack::ShowStatus.new(Rack::ShowExceptions.new(protected_lobster)) - -Rack::Handler::WEBrick.run pretty_protected_lobster, :Port => 9292 diff --git a/vendor/gems/rack-1.1.0/example/protectedlobster.ru b/vendor/gems/rack-1.1.0/example/protectedlobster.ru deleted file mode 100644 index b0da62f0..00000000 --- a/vendor/gems/rack-1.1.0/example/protectedlobster.ru +++ /dev/null @@ -1,8 +0,0 @@ -require 'rack/lobster' - -use Rack::ShowExceptions -use Rack::Auth::Basic, "Lobster 2.0" do |username, password| - 'secret' == password -end - -run Rack::Lobster.new diff --git a/vendor/gems/rack-1.1.0/lib/rack.rb b/vendor/gems/rack-1.1.0/lib/rack.rb deleted file mode 100644 index c118fc07..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack.rb +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (C) 2007, 2008, 2009, 2010 Christian Neukirchen -# -# Rack is freely distributable under the terms of an MIT-style license. -# See COPYING or http://www.opensource.org/licenses/mit-license.php. - -# The Rack main module, serving as a namespace for all core Rack -# modules and classes. -# -# All modules meant for use in your application are autoloaded here, -# so it should be enough just to require rack.rb in your code. - -module Rack - # The Rack protocol version number implemented. - VERSION = [1,1] - - # Return the Rack protocol version as a dotted string. - def self.version - VERSION.join(".") - end - - # Return the Rack release as a dotted string. - def self.release - "1.1" - end - - autoload :Builder, "rack/builder" - autoload :Cascade, "rack/cascade" - autoload :Chunked, "rack/chunked" - autoload :CommonLogger, "rack/commonlogger" - autoload :ConditionalGet, "rack/conditionalget" - autoload :Config, "rack/config" - autoload :ContentLength, "rack/content_length" - autoload :ContentType, "rack/content_type" - autoload :ETag, "rack/etag" - autoload :File, "rack/file" - autoload :Deflater, "rack/deflater" - autoload :Directory, "rack/directory" - autoload :ForwardRequest, "rack/recursive" - autoload :Handler, "rack/handler" - autoload :Head, "rack/head" - autoload :Lint, "rack/lint" - autoload :Lock, "rack/lock" - autoload :Logger, "rack/logger" - autoload :MethodOverride, "rack/methodoverride" - autoload :Mime, "rack/mime" - autoload :NullLogger, "rack/nulllogger" - autoload :Recursive, "rack/recursive" - autoload :Reloader, "rack/reloader" - autoload :Runtime, "rack/runtime" - autoload :Sendfile, "rack/sendfile" - autoload :Server, "rack/server" - autoload :ShowExceptions, "rack/showexceptions" - autoload :ShowStatus, "rack/showstatus" - autoload :Static, "rack/static" - autoload :URLMap, "rack/urlmap" - autoload :Utils, "rack/utils" - - autoload :MockRequest, "rack/mock" - autoload :MockResponse, "rack/mock" - - autoload :Request, "rack/request" - autoload :Response, "rack/response" - - module Auth - autoload :Basic, "rack/auth/basic" - autoload :AbstractRequest, "rack/auth/abstract/request" - autoload :AbstractHandler, "rack/auth/abstract/handler" - module Digest - autoload :MD5, "rack/auth/digest/md5" - autoload :Nonce, "rack/auth/digest/nonce" - autoload :Params, "rack/auth/digest/params" - autoload :Request, "rack/auth/digest/request" - end - end - - module Session - autoload :Cookie, "rack/session/cookie" - autoload :Pool, "rack/session/pool" - autoload :Memcache, "rack/session/memcache" - end - - # *Adapters* connect Rack with third party web frameworks. - # - # Rack includes an adapter for Camping, see README for other - # frameworks supporting Rack in their code bases. - # - # Refer to the submodules for framework-specific calling details. - - module Adapter - autoload :Camping, "rack/adapter/camping" - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/adapter/camping.rb b/vendor/gems/rack-1.1.0/lib/rack/adapter/camping.rb deleted file mode 100644 index 63bc787f..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/adapter/camping.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Rack - module Adapter - class Camping - def initialize(app) - @app = app - end - - def call(env) - env["PATH_INFO"] ||= "" - env["SCRIPT_NAME"] ||= "" - controller = @app.run(env['rack.input'], env) - h = controller.headers - h.each_pair do |k,v| - if v.kind_of? URI - h[k] = v.to_s - end - end - [controller.status, controller.headers, [controller.body.to_s]] - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/abstract/handler.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/abstract/handler.rb deleted file mode 100644 index 214df629..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/abstract/handler.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Rack - module Auth - # Rack::Auth::AbstractHandler implements common authentication functionality. - # - # +realm+ should be set for all handlers. - - class AbstractHandler - - attr_accessor :realm - - def initialize(app, realm=nil, &authenticator) - @app, @realm, @authenticator = app, realm, authenticator - end - - - private - - def unauthorized(www_authenticate = challenge) - return [ 401, - { 'Content-Type' => 'text/plain', - 'Content-Length' => '0', - 'WWW-Authenticate' => www_authenticate.to_s }, - [] - ] - end - - def bad_request - return [ 400, - { 'Content-Type' => 'text/plain', - 'Content-Length' => '0' }, - [] - ] - end - - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/abstract/request.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/abstract/request.rb deleted file mode 100644 index 1d9ccec6..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/abstract/request.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Rack - module Auth - class AbstractRequest - - def initialize(env) - @env = env - end - - def provided? - !authorization_key.nil? - end - - def parts - @parts ||= @env[authorization_key].split(' ', 2) - end - - def scheme - @scheme ||= parts.first.downcase.to_sym - end - - def params - @params ||= parts.last - end - - - private - - AUTHORIZATION_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION'] - - def authorization_key - @authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.has_key?(key) } - end - - end - - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/basic.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/basic.rb deleted file mode 100644 index 95572246..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/basic.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'rack/auth/abstract/handler' -require 'rack/auth/abstract/request' - -module Rack - module Auth - # Rack::Auth::Basic implements HTTP Basic Authentication, as per RFC 2617. - # - # Initialize with the Rack application that you want protecting, - # and a block that checks if a username and password pair are valid. - # - # See also: example/protectedlobster.rb - - class Basic < AbstractHandler - - def call(env) - auth = Basic::Request.new(env) - - return unauthorized unless auth.provided? - - return bad_request unless auth.basic? - - if valid?(auth) - env['REMOTE_USER'] = auth.username - - return @app.call(env) - end - - unauthorized - end - - - private - - def challenge - 'Basic realm="%s"' % realm - end - - def valid?(auth) - @authenticator.call(*auth.credentials) - end - - class Request < Auth::AbstractRequest - def basic? - :basic == scheme - end - - def credentials - @credentials ||= params.unpack("m*").first.split(/:/, 2) - end - - def username - credentials.first - end - end - - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/md5.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/digest/md5.rb deleted file mode 100644 index e579dc96..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/md5.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'rack/auth/abstract/handler' -require 'rack/auth/digest/request' -require 'rack/auth/digest/params' -require 'rack/auth/digest/nonce' -require 'digest/md5' - -module Rack - module Auth - module Digest - # Rack::Auth::Digest::MD5 implements the MD5 algorithm version of - # HTTP Digest Authentication, as per RFC 2617. - # - # Initialize with the [Rack] application that you want protecting, - # and a block that looks up a plaintext password for a given username. - # - # +opaque+ needs to be set to a constant base64/hexadecimal string. - # - class MD5 < AbstractHandler - - attr_accessor :opaque - - attr_writer :passwords_hashed - - def initialize(*args) - super - @passwords_hashed = nil - end - - def passwords_hashed? - !!@passwords_hashed - end - - def call(env) - auth = Request.new(env) - - unless auth.provided? - return unauthorized - end - - if !auth.digest? || !auth.correct_uri? || !valid_qop?(auth) - return bad_request - end - - if valid?(auth) - if auth.nonce.stale? - return unauthorized(challenge(:stale => true)) - else - env['REMOTE_USER'] = auth.username - - return @app.call(env) - end - end - - unauthorized - end - - - private - - QOP = 'auth'.freeze - - def params(hash = {}) - Params.new do |params| - params['realm'] = realm - params['nonce'] = Nonce.new.to_s - params['opaque'] = H(opaque) - params['qop'] = QOP - - hash.each { |k, v| params[k] = v } - end - end - - def challenge(hash = {}) - "Digest #{params(hash)}" - end - - def valid?(auth) - valid_opaque?(auth) && valid_nonce?(auth) && valid_digest?(auth) - end - - def valid_qop?(auth) - QOP == auth.qop - end - - def valid_opaque?(auth) - H(opaque) == auth.opaque - end - - def valid_nonce?(auth) - auth.nonce.valid? - end - - def valid_digest?(auth) - digest(auth, @authenticator.call(auth.username)) == auth.response - end - - def md5(data) - ::Digest::MD5.hexdigest(data) - end - - alias :H :md5 - - def KD(secret, data) - H([secret, data] * ':') - end - - def A1(auth, password) - [ auth.username, auth.realm, password ] * ':' - end - - def A2(auth) - [ auth.method, auth.uri ] * ':' - end - - def digest(auth, password) - password_hash = passwords_hashed? ? password : H(A1(auth, password)) - - KD(password_hash, [ auth.nonce, auth.nc, auth.cnonce, QOP, H(A2(auth)) ] * ':') - end - - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/nonce.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/digest/nonce.rb deleted file mode 100644 index dbe109f2..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/nonce.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'digest/md5' - -module Rack - module Auth - module Digest - # Rack::Auth::Digest::Nonce is the default nonce generator for the - # Rack::Auth::Digest::MD5 authentication handler. - # - # +private_key+ needs to set to a constant string. - # - # +time_limit+ can be optionally set to an integer (number of seconds), - # to limit the validity of the generated nonces. - - class Nonce - - class << self - attr_accessor :private_key, :time_limit - end - - def self.parse(string) - new(*string.unpack("m*").first.split(' ', 2)) - end - - def initialize(timestamp = Time.now, given_digest = nil) - @timestamp, @given_digest = timestamp.to_i, given_digest - end - - def to_s - [([ @timestamp, digest ] * ' ')].pack("m*").strip - end - - def digest - ::Digest::MD5.hexdigest([ @timestamp, self.class.private_key ] * ':') - end - - def valid? - digest == @given_digest - end - - def stale? - !self.class.time_limit.nil? && (@timestamp - Time.now.to_i) < self.class.time_limit - end - - def fresh? - !stale? - end - - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/params.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/digest/params.rb deleted file mode 100644 index 730e2efd..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/params.rb +++ /dev/null @@ -1,55 +0,0 @@ -module Rack - module Auth - module Digest - class Params < Hash - - def self.parse(str) - split_header_value(str).inject(new) do |header, param| - k, v = param.split('=', 2) - header[k] = dequote(v) - header - end - end - - def self.dequote(str) # From WEBrick::HTTPUtils - ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup - ret.gsub!(/\\(.)/, "\\1") - ret - end - - def self.split_header_value(str) - str.scan( /(\w+\=(?:"[^\"]+"|[^,]+))/n ).collect{ |v| v[0] } - end - - def initialize - super - - yield self if block_given? - end - - def [](k) - super k.to_s - end - - def []=(k, v) - super k.to_s, v.to_s - end - - UNQUOTED = ['qop', 'nc', 'stale'] - - def to_s - inject([]) do |parts, (k, v)| - parts << "#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v)) - parts - end.join(', ') - end - - def quote(str) # From WEBrick::HTTPUtils - '"' << str.gsub(/[\\\"]/o, "\\\1") << '"' - end - - end - end - end -end - diff --git a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/request.rb b/vendor/gems/rack-1.1.0/lib/rack/auth/digest/request.rb deleted file mode 100644 index a8aa3bf9..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/auth/digest/request.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rack/auth/abstract/request' -require 'rack/auth/digest/params' -require 'rack/auth/digest/nonce' - -module Rack - module Auth - module Digest - class Request < Auth::AbstractRequest - - def method - @env['rack.methodoverride.original_method'] || @env['REQUEST_METHOD'] - end - - def digest? - :digest == scheme - end - - def correct_uri? - (@env['SCRIPT_NAME'].to_s + @env['PATH_INFO'].to_s) == uri - end - - def nonce - @nonce ||= Nonce.parse(params['nonce']) - end - - def params - @params ||= Params.parse(parts.last) - end - - def method_missing(sym) - if params.has_key? key = sym.to_s - return params[key] - end - super - end - - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/builder.rb b/vendor/gems/rack-1.1.0/lib/rack/builder.rb deleted file mode 100644 index 530f0aaf..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/builder.rb +++ /dev/null @@ -1,80 +0,0 @@ -module Rack - # Rack::Builder implements a small DSL to iteratively construct Rack - # applications. - # - # Example: - # - # app = Rack::Builder.new { - # use Rack::CommonLogger - # use Rack::ShowExceptions - # map "/lobster" do - # use Rack::Lint - # run Rack::Lobster.new - # end - # } - # - # Or - # - # app = Rack::Builder.app do - # use Rack::CommonLogger - # lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'OK'] } - # end - # - # +use+ adds a middleware to the stack, +run+ dispatches to an application. - # You can use +map+ to construct a Rack::URLMap in a convenient way. - - class Builder - def self.parse_file(config, opts = Server::Options.new) - options = {} - if config =~ /\.ru$/ - cfgfile = ::File.read(config) - if cfgfile[/^#\\(.*)/] && opts - options = opts.parse! $1.split(/\s+/) - end - cfgfile.sub!(/^__END__\n.*/, '') - app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app", - TOPLEVEL_BINDING, config - else - require config - app = Object.const_get(::File.basename(config, '.rb').capitalize) - end - return app, options - end - - def initialize(&block) - @ins = [] - instance_eval(&block) if block_given? - end - - def self.app(&block) - self.new(&block).to_app - end - - def use(middleware, *args, &block) - @ins << lambda { |app| middleware.new(app, *args, &block) } - end - - def run(app) - @ins << app #lambda { |nothing| app } - end - - def map(path, &block) - if @ins.last.kind_of? Hash - @ins.last[path] = self.class.new(&block).to_app - else - @ins << {} - map(path, &block) - end - end - - def to_app - @ins[-1] = Rack::URLMap.new(@ins.last) if Hash === @ins.last - inner_app = @ins.last - @ins[0...-1].reverse.inject(inner_app) { |a, e| e.call(a) } - end - - def call(env) - to_app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/cascade.rb b/vendor/gems/rack-1.1.0/lib/rack/cascade.rb deleted file mode 100644 index 14c3e54d..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/cascade.rb +++ /dev/null @@ -1,41 +0,0 @@ -module Rack - # Rack::Cascade tries an request on several apps, and returns the - # first response that is not 404 (or in a list of configurable - # status codes). - - class Cascade - NotFound = [404, {}, []] - - attr_reader :apps - - def initialize(apps, catch=404) - @apps = []; @has_app = {} - apps.each { |app| add app } - - @catch = {} - [*catch].each { |status| @catch[status] = true } - end - - def call(env) - result = NotFound - - @apps.each do |app| - result = app.call(env) - break unless @catch.include?(result[0].to_i) - end - - result - end - - def add app - @has_app[app] = true - @apps << app - end - - def include? app - @has_app.include? app - end - - alias_method :<<, :add - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/chunked.rb b/vendor/gems/rack-1.1.0/lib/rack/chunked.rb deleted file mode 100644 index dddf9694..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/chunked.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'rack/utils' - -module Rack - - # Middleware that applies chunked transfer encoding to response bodies - # when the response does not include a Content-Length header. - class Chunked - include Rack::Utils - - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - headers = HeaderHash.new(headers) - - if env['HTTP_VERSION'] == 'HTTP/1.0' || - STATUS_WITH_NO_ENTITY_BODY.include?(status) || - headers['Content-Length'] || - headers['Transfer-Encoding'] - [status, headers, body] - else - dup.chunk(status, headers, body) - end - end - - def chunk(status, headers, body) - @body = body - headers.delete('Content-Length') - headers['Transfer-Encoding'] = 'chunked' - [status, headers, self] - end - - def each - term = "\r\n" - @body.each do |chunk| - size = bytesize(chunk) - next if size == 0 - yield [size.to_s(16), term, chunk, term].join - end - yield ["0", term, "", term].join - end - - def close - @body.close if @body.respond_to?(:close) - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/commonlogger.rb b/vendor/gems/rack-1.1.0/lib/rack/commonlogger.rb deleted file mode 100644 index 1edc9b83..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/commonlogger.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Rack - # Rack::CommonLogger forwards every request to an +app+ given, and - # logs a line in the Apache common log format to the +logger+, or - # rack.errors by default. - class CommonLogger - # Common Log Format: http://httpd.apache.org/docs/1.3/logs.html#common - # lilith.local - - [07/Aug/2006 23:58:02] "GET / HTTP/1.1" 500 - - # %{%s - %s [%s] "%s %s%s %s" %d %s\n} % - FORMAT = %{%s - %s [%s] "%s %s%s %s" %d %s %0.4f\n} - - def initialize(app, logger=nil) - @app = app - @logger = logger - end - - def call(env) - began_at = Time.now - status, header, body = @app.call(env) - header = Utils::HeaderHash.new(header) - log(env, status, header, began_at) - [status, header, body] - end - - private - - def log(env, status, header, began_at) - now = Time.now - length = extract_content_length(header) - - logger = @logger || env['rack.errors'] - logger.write FORMAT % [ - env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-", - env["REMOTE_USER"] || "-", - now.strftime("%d/%b/%Y %H:%M:%S"), - env["REQUEST_METHOD"], - env["PATH_INFO"], - env["QUERY_STRING"].empty? ? "" : "?"+env["QUERY_STRING"], - env["HTTP_VERSION"], - status.to_s[0..3], - length, - now - began_at ] - end - - def extract_content_length(headers) - value = headers['Content-Length'] or return '-' - value.to_s == '0' ? '-' : value - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/conditionalget.rb b/vendor/gems/rack-1.1.0/lib/rack/conditionalget.rb deleted file mode 100644 index 046ebdb0..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/conditionalget.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'rack/utils' - -module Rack - - # Middleware that enables conditional GET using If-None-Match and - # If-Modified-Since. The application should set either or both of the - # Last-Modified or Etag response headers according to RFC 2616. When - # either of the conditions is met, the response body is set to be zero - # length and the response status is set to 304 Not Modified. - # - # Applications that defer response body generation until the body's each - # message is received will avoid response body generation completely when - # a conditional GET matches. - # - # Adapted from Michael Klishin's Merb implementation: - # http://github.com/wycats/merb-core/tree/master/lib/merb-core/rack/middleware/conditional_get.rb - class ConditionalGet - def initialize(app) - @app = app - end - - def call(env) - return @app.call(env) unless %w[GET HEAD].include?(env['REQUEST_METHOD']) - - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - if etag_matches?(env, headers) || modified_since?(env, headers) - status = 304 - headers.delete('Content-Type') - headers.delete('Content-Length') - body = [] - end - [status, headers, body] - end - - private - def etag_matches?(env, headers) - etag = headers['Etag'] and etag == env['HTTP_IF_NONE_MATCH'] - end - - def modified_since?(env, headers) - last_modified = headers['Last-Modified'] and - last_modified == env['HTTP_IF_MODIFIED_SINCE'] - end - end - -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/config.rb b/vendor/gems/rack-1.1.0/lib/rack/config.rb deleted file mode 100644 index c6d446c0..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/config.rb +++ /dev/null @@ -1,15 +0,0 @@ -module Rack - # Rack::Config modifies the environment using the block given during - # initialization. - class Config - def initialize(app, &block) - @app = app - @block = block - end - - def call(env) - @block.call(env) - @app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/content_length.rb b/vendor/gems/rack-1.1.0/lib/rack/content_length.rb deleted file mode 100644 index 1e56d438..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/content_length.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rack/utils' - -module Rack - # Sets the Content-Length header on responses with fixed-length bodies. - class ContentLength - include Rack::Utils - - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - headers = HeaderHash.new(headers) - - if !STATUS_WITH_NO_ENTITY_BODY.include?(status) && - !headers['Content-Length'] && - !headers['Transfer-Encoding'] && - (body.respond_to?(:to_ary) || body.respond_to?(:to_str)) - - body = [body] if body.respond_to?(:to_str) # rack 0.4 compat - length = body.to_ary.inject(0) { |len, part| len + bytesize(part) } - headers['Content-Length'] = length.to_s - end - - [status, headers, body] - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/content_type.rb b/vendor/gems/rack-1.1.0/lib/rack/content_type.rb deleted file mode 100644 index 874c28cd..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/content_type.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rack/utils' - -module Rack - - # Sets the Content-Type header on responses which don't have one. - # - # Builder Usage: - # use Rack::ContentType, "text/plain" - # - # When no content type argument is provided, "text/html" is assumed. - class ContentType - def initialize(app, content_type = "text/html") - @app, @content_type = app, content_type - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - headers['Content-Type'] ||= @content_type - [status, headers, body] - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/deflater.rb b/vendor/gems/rack-1.1.0/lib/rack/deflater.rb deleted file mode 100644 index ad0f5316..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/deflater.rb +++ /dev/null @@ -1,96 +0,0 @@ -require "zlib" -require "stringio" -require "time" # for Time.httpdate -require 'rack/utils' - -module Rack - class Deflater - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - - # Skip compressing empty entity body responses and responses with - # no-transform set. - if Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) || - headers['Cache-Control'].to_s =~ /\bno-transform\b/ - return [status, headers, body] - end - - request = Request.new(env) - - encoding = Utils.select_best_encoding(%w(gzip deflate identity), - request.accept_encoding) - - # Set the Vary HTTP header. - vary = headers["Vary"].to_s.split(",").map { |v| v.strip } - unless vary.include?("*") || vary.include?("Accept-Encoding") - headers["Vary"] = vary.push("Accept-Encoding").join(",") - end - - case encoding - when "gzip" - headers['Content-Encoding'] = "gzip" - headers.delete('Content-Length') - mtime = headers.key?("Last-Modified") ? - Time.httpdate(headers["Last-Modified"]) : Time.now - [status, headers, GzipStream.new(body, mtime)] - when "deflate" - headers['Content-Encoding'] = "deflate" - headers.delete('Content-Length') - [status, headers, DeflateStream.new(body)] - when "identity" - [status, headers, body] - when nil - message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found." - [406, {"Content-Type" => "text/plain", "Content-Length" => message.length.to_s}, [message]] - end - end - - class GzipStream - def initialize(body, mtime) - @body = body - @mtime = mtime - end - - def each(&block) - @writer = block - gzip =::Zlib::GzipWriter.new(self) - gzip.mtime = @mtime - @body.each { |part| gzip.write(part) } - @body.close if @body.respond_to?(:close) - gzip.close - @writer = nil - end - - def write(data) - @writer.call(data) - end - end - - class DeflateStream - DEFLATE_ARGS = [ - Zlib::DEFAULT_COMPRESSION, - # drop the zlib header which causes both Safari and IE to choke - -Zlib::MAX_WBITS, - Zlib::DEF_MEM_LEVEL, - Zlib::DEFAULT_STRATEGY - ] - - def initialize(body) - @body = body - end - - def each - deflater = ::Zlib::Deflate.new(*DEFLATE_ARGS) - @body.each { |part| yield deflater.deflate(part) } - @body.close if @body.respond_to?(:close) - yield deflater.finish - nil - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/directory.rb b/vendor/gems/rack-1.1.0/lib/rack/directory.rb deleted file mode 100644 index 927ac0c9..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/directory.rb +++ /dev/null @@ -1,157 +0,0 @@ -require 'time' -require 'rack/utils' -require 'rack/mime' - -module Rack - # Rack::Directory serves entries below the +root+ given, according to the - # path info of the Rack request. If a directory is found, the file's contents - # will be presented in an html based index. If a file is found, the env will - # be passed to the specified +app+. - # - # If +app+ is not specified, a Rack::File of the same +root+ will be used. - - class Directory - DIR_FILE = "%s%s%s%s" - DIR_PAGE = <<-PAGE - - %s - - - -

    %s

    -
    - - - - - - - -%s -
    NameSizeTypeLast Modified
    -
    - - PAGE - - attr_reader :files - attr_accessor :root, :path - - def initialize(root, app=nil) - @root = F.expand_path(root) - @app = app || Rack::File.new(@root) - end - - def call(env) - dup._call(env) - end - - F = ::File - - def _call(env) - @env = env - @script_name = env['SCRIPT_NAME'] - @path_info = Utils.unescape(env['PATH_INFO']) - - if forbidden = check_forbidden - forbidden - else - @path = F.join(@root, @path_info) - list_path - end - end - - def check_forbidden - return unless @path_info.include? ".." - - body = "Forbidden\n" - size = Rack::Utils.bytesize(body) - return [403, {"Content-Type" => "text/plain", - "Content-Length" => size.to_s, - "X-Cascade" => "pass"}, [body]] - end - - def list_directory - @files = [['../','Parent Directory','','','']] - glob = F.join(@path, '*') - - Dir[glob].sort.each do |node| - stat = stat(node) - next unless stat - basename = F.basename(node) - ext = F.extname(node) - - url = F.join(@script_name, @path_info, basename) - size = stat.size - type = stat.directory? ? 'directory' : Mime.mime_type(ext) - size = stat.directory? ? '-' : filesize_format(size) - mtime = stat.mtime.httpdate - url << '/' if stat.directory? - basename << '/' if stat.directory? - - @files << [ url, basename, size, type, mtime ] - end - - return [ 200, {'Content-Type'=>'text/html; charset=utf-8'}, self ] - end - - def stat(node, max = 10) - F.stat(node) - rescue Errno::ENOENT, Errno::ELOOP - return nil - end - - # TODO: add correct response if not readable, not sure if 404 is the best - # option - def list_path - @stat = F.stat(@path) - - if @stat.readable? - return @app.call(@env) if @stat.file? - return list_directory if @stat.directory? - else - raise Errno::ENOENT, 'No such file or directory' - end - - rescue Errno::ENOENT, Errno::ELOOP - return entity_not_found - end - - def entity_not_found - body = "Entity not found: #{@path_info}\n" - size = Rack::Utils.bytesize(body) - return [404, {"Content-Type" => "text/plain", - "Content-Length" => size.to_s, - "X-Cascade" => "pass"}, [body]] - end - - def each - show_path = @path.sub(/^#{@root}/,'') - files = @files.map{|f| DIR_FILE % f }*"\n" - page = DIR_PAGE % [ show_path, show_path , files ] - page.each_line{|l| yield l } - end - - # Stolen from Ramaze - - FILESIZE_FORMAT = [ - ['%.1fT', 1 << 40], - ['%.1fG', 1 << 30], - ['%.1fM', 1 << 20], - ['%.1fK', 1 << 10], - ] - - def filesize_format(int) - FILESIZE_FORMAT.each do |format, size| - return format % (int.to_f / size) if int >= size - end - - int.to_s + 'B' - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/etag.rb b/vendor/gems/rack-1.1.0/lib/rack/etag.rb deleted file mode 100644 index 06dbc6aa..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/etag.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'digest/md5' - -module Rack - # Automatically sets the ETag header on all String bodies - class ETag - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - - if !headers.has_key?('ETag') - parts = [] - body.each { |part| parts << part.to_s } - headers['ETag'] = %("#{Digest::MD5.hexdigest(parts.join(""))}") - [status, headers, parts] - else - [status, headers, body] - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/file.rb b/vendor/gems/rack-1.1.0/lib/rack/file.rb deleted file mode 100644 index 14af7b3b..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/file.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'time' -require 'rack/utils' -require 'rack/mime' - -module Rack - # Rack::File serves files below the +root+ given, according to the - # path info of the Rack request. - # - # Handlers can detect if bodies are a Rack::File, and use mechanisms - # like sendfile on the +path+. - - class File - attr_accessor :root - attr_accessor :path - - alias :to_path :path - - def initialize(root) - @root = root - end - - def call(env) - dup._call(env) - end - - F = ::File - - def _call(env) - @path_info = Utils.unescape(env["PATH_INFO"]) - return forbidden if @path_info.include? ".." - - @path = F.join(@root, @path_info) - - begin - if F.file?(@path) && F.readable?(@path) - serving - else - raise Errno::EPERM - end - rescue SystemCallError - not_found - end - end - - def forbidden - body = "Forbidden\n" - [403, {"Content-Type" => "text/plain", - "Content-Length" => body.size.to_s, - "X-Cascade" => "pass"}, - [body]] - end - - # NOTE: - # We check via File::size? whether this file provides size info - # via stat (e.g. /proc files often don't), otherwise we have to - # figure it out by reading the whole file into memory. And while - # we're at it we also use this as body then. - - def serving - if size = F.size?(@path) - body = self - else - body = [F.read(@path)] - size = Utils.bytesize(body.first) - end - - [200, { - "Last-Modified" => F.mtime(@path).httpdate, - "Content-Type" => Mime.mime_type(F.extname(@path), 'text/plain'), - "Content-Length" => size.to_s - }, body] - end - - def not_found - body = "File not found: #{@path_info}\n" - [404, {"Content-Type" => "text/plain", - "Content-Length" => body.size.to_s, - "X-Cascade" => "pass"}, - [body]] - end - - def each - F.open(@path, "rb") { |file| - while part = file.read(8192) - yield part - end - } - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler.rb b/vendor/gems/rack-1.1.0/lib/rack/handler.rb deleted file mode 100644 index 3c09883e..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler.rb +++ /dev/null @@ -1,88 +0,0 @@ -module Rack - # *Handlers* connect web servers with Rack. - # - # Rack includes Handlers for Mongrel, WEBrick, FastCGI, CGI, SCGI - # and LiteSpeed. - # - # Handlers usually are activated by calling MyHandler.run(myapp). - # A second optional hash can be passed to include server-specific - # configuration. - module Handler - def self.get(server) - return unless server - server = server.to_s - - if klass = @handlers[server] - obj = Object - klass.split("::").each { |x| obj = obj.const_get(x) } - obj - else - try_require('rack/handler', server) - const_get(server) - end - end - - def self.default(options = {}) - # Guess. - if ENV.include?("PHP_FCGI_CHILDREN") - # We already speak FastCGI - options.delete :File - options.delete :Port - - Rack::Handler::FastCGI - elsif ENV.include?("REQUEST_METHOD") - Rack::Handler::CGI - else - begin - Rack::Handler::Mongrel - rescue LoadError => e - Rack::Handler::WEBrick - end - end - end - - # Transforms server-name constants to their canonical form as filenames, - # then tries to require them but silences the LoadError if not found - # - # Naming convention: - # - # Foo # => 'foo' - # FooBar # => 'foo_bar.rb' - # FooBAR # => 'foobar.rb' - # FOObar # => 'foobar.rb' - # FOOBAR # => 'foobar.rb' - # FooBarBaz # => 'foo_bar_baz.rb' - def self.try_require(prefix, const_name) - file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }. - gsub(/[A-Z]+[^A-Z]/, '_\&').downcase - - require(::File.join(prefix, file)) - rescue LoadError - end - - def self.register(server, klass) - @handlers ||= {} - @handlers[server] = klass - end - - autoload :CGI, "rack/handler/cgi" - autoload :FastCGI, "rack/handler/fastcgi" - autoload :Mongrel, "rack/handler/mongrel" - autoload :EventedMongrel, "rack/handler/evented_mongrel" - autoload :SwiftipliedMongrel, "rack/handler/swiftiplied_mongrel" - autoload :WEBrick, "rack/handler/webrick" - autoload :LSWS, "rack/handler/lsws" - autoload :SCGI, "rack/handler/scgi" - autoload :Thin, "rack/handler/thin" - - register 'cgi', 'Rack::Handler::CGI' - register 'fastcgi', 'Rack::Handler::FastCGI' - register 'mongrel', 'Rack::Handler::Mongrel' - register 'emongrel', 'Rack::Handler::EventedMongrel' - register 'smongrel', 'Rack::Handler::SwiftipliedMongrel' - register 'webrick', 'Rack::Handler::WEBrick' - register 'lsws', 'Rack::Handler::LSWS' - register 'scgi', 'Rack::Handler::SCGI' - register 'thin', 'Rack::Handler::Thin' - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/cgi.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/cgi.rb deleted file mode 100644 index c6903f15..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/cgi.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'rack/content_length' - -module Rack - module Handler - class CGI - def self.run(app, options=nil) - serve app - end - - def self.serve(app) - app = ContentLength.new(app) - - env = ENV.to_hash - env.delete "HTTP_CONTENT_LENGTH" - - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - env.update({"rack.version" => [1,1], - "rack.input" => $stdin, - "rack.errors" => $stderr, - - "rack.multithread" => false, - "rack.multiprocess" => true, - "rack.run_once" => true, - - "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" - }) - - env["QUERY_STRING"] ||= "" - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["REQUEST_PATH"] ||= "/" - - status, headers, body = app.call(env) - begin - send_headers status, headers - send_body body - ensure - body.close if body.respond_to? :close - end - end - - def self.send_headers(status, headers) - STDOUT.print "Status: #{status}\r\n" - headers.each { |k, vs| - vs.split("\n").each { |v| - STDOUT.print "#{k}: #{v}\r\n" - } - } - STDOUT.print "\r\n" - STDOUT.flush - end - - def self.send_body(body) - body.each { |part| - STDOUT.print part - STDOUT.flush - } - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/evented_mongrel.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/evented_mongrel.rb deleted file mode 100644 index 0f5cbf72..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/evented_mongrel.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'swiftcore/evented_mongrel' - -module Rack - module Handler - class EventedMongrel < Handler::Mongrel - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/fastcgi.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/fastcgi.rb deleted file mode 100644 index b992a5f4..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/fastcgi.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'fcgi' -require 'socket' -require 'rack/content_length' -require 'rack/rewindable_input' - -if defined? FCGI::Stream - class FCGI::Stream - alias _rack_read_without_buffer read - - def read(n, buffer=nil) - buf = _rack_read_without_buffer n - buffer.replace(buf.to_s) if buffer - buf - end - end -end - -module Rack - module Handler - class FastCGI - def self.run(app, options={}) - file = options[:File] and STDIN.reopen(UNIXServer.new(file)) - port = options[:Port] and STDIN.reopen(TCPServer.new(port)) - FCGI.each { |request| - serve request, app - } - end - - def self.serve(request, app) - app = Rack::ContentLength.new(app) - - env = request.env - env.delete "HTTP_CONTENT_LENGTH" - - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - rack_input = RewindableInput.new(request.in) - - env.update({"rack.version" => [1,1], - "rack.input" => rack_input, - "rack.errors" => request.err, - - "rack.multithread" => false, - "rack.multiprocess" => true, - "rack.run_once" => false, - - "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http" - }) - - env["QUERY_STRING"] ||= "" - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["REQUEST_PATH"] ||= "/" - env.delete "CONTENT_TYPE" if env["CONTENT_TYPE"] == "" - env.delete "CONTENT_LENGTH" if env["CONTENT_LENGTH"] == "" - - begin - status, headers, body = app.call(env) - begin - send_headers request.out, status, headers - send_body request.out, body - ensure - body.close if body.respond_to? :close - end - ensure - rack_input.close - request.finish - end - end - - def self.send_headers(out, status, headers) - out.print "Status: #{status}\r\n" - headers.each { |k, vs| - vs.split("\n").each { |v| - out.print "#{k}: #{v}\r\n" - } - } - out.print "\r\n" - out.flush - end - - def self.send_body(out, body) - body.each { |part| - out.print part - out.flush - } - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/lsws.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/lsws.rb deleted file mode 100644 index eabc0bc9..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/lsws.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'lsapi' -require 'rack/content_length' -require 'rack/rewindable_input' - -module Rack - module Handler - class LSWS - def self.run(app, options=nil) - while LSAPI.accept != nil - serve app - end - end - def self.serve(app) - app = Rack::ContentLength.new(app) - - env = ENV.to_hash - env.delete "HTTP_CONTENT_LENGTH" - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - rack_input = RewindableInput.new($stdin.read.to_s) - - env.update( - "rack.version" => [1,1], - "rack.input" => rack_input, - "rack.errors" => $stderr, - "rack.multithread" => false, - "rack.multiprocess" => true, - "rack.run_once" => false, - "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" - ) - - env["QUERY_STRING"] ||= "" - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["REQUEST_PATH"] ||= "/" - status, headers, body = app.call(env) - begin - send_headers status, headers - send_body body - ensure - body.close if body.respond_to? :close - end - ensure - rack_input.close - end - def self.send_headers(status, headers) - print "Status: #{status}\r\n" - headers.each { |k, vs| - vs.split("\n").each { |v| - print "#{k}: #{v}\r\n" - } - } - print "\r\n" - STDOUT.flush - end - def self.send_body(body) - body.each { |part| - print part - STDOUT.flush - } - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/mongrel.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/mongrel.rb deleted file mode 100644 index b6b775ea..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/mongrel.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'mongrel' -require 'stringio' -require 'rack/content_length' -require 'rack/chunked' - -module Rack - module Handler - class Mongrel < ::Mongrel::HttpHandler - def self.run(app, options={}) - server = ::Mongrel::HttpServer.new( - options[:Host] || '0.0.0.0', - options[:Port] || 8080, - options[:num_processors] || 950, - options[:throttle] || 0, - options[:timeout] || 60) - # Acts like Rack::URLMap, utilizing Mongrel's own path finding methods. - # Use is similar to #run, replacing the app argument with a hash of - # { path=>app, ... } or an instance of Rack::URLMap. - if options[:map] - if app.is_a? Hash - app.each do |path, appl| - path = '/'+path unless path[0] == ?/ - server.register(path, Rack::Handler::Mongrel.new(appl)) - end - elsif app.is_a? URLMap - app.instance_variable_get(:@mapping).each do |(host, path, appl)| - next if !host.nil? && !options[:Host].nil? && options[:Host] != host - path = '/'+path unless path[0] == ?/ - server.register(path, Rack::Handler::Mongrel.new(appl)) - end - else - raise ArgumentError, "first argument should be a Hash or URLMap" - end - else - server.register('/', Rack::Handler::Mongrel.new(app)) - end - yield server if block_given? - server.run.join - end - - def initialize(app) - @app = Rack::Chunked.new(Rack::ContentLength.new(app)) - end - - def process(request, response) - env = {}.replace(request.params) - env.delete "HTTP_CONTENT_TYPE" - env.delete "HTTP_CONTENT_LENGTH" - - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - rack_input = request.body || StringIO.new('') - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - - env.update({"rack.version" => [1,1], - "rack.input" => rack_input, - "rack.errors" => $stderr, - - "rack.multithread" => true, - "rack.multiprocess" => false, # ??? - "rack.run_once" => false, - - "rack.url_scheme" => "http", - }) - env["QUERY_STRING"] ||= "" - - status, headers, body = @app.call(env) - - begin - response.status = status.to_i - response.send_status(nil) - - headers.each { |k, vs| - vs.split("\n").each { |v| - response.header[k] = v - } - } - response.send_header - - body.each { |part| - response.write part - response.socket.flush - } - ensure - body.close if body.respond_to? :close - end - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/scgi.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/scgi.rb deleted file mode 100644 index 79a6b2bd..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/scgi.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'scgi' -require 'stringio' -require 'rack/content_length' -require 'rack/chunked' - -module Rack - module Handler - class SCGI < ::SCGI::Processor - attr_accessor :app - - def self.run(app, options=nil) - new(options.merge(:app=>app, - :host=>options[:Host], - :port=>options[:Port], - :socket=>options[:Socket])).listen - end - - def initialize(settings = {}) - @app = Rack::Chunked.new(Rack::ContentLength.new(settings[:app])) - @log = Object.new - def @log.info(*args); end - def @log.error(*args); end - super(settings) - end - - def process_request(request, input_body, socket) - env = {}.replace(request) - env.delete "HTTP_CONTENT_TYPE" - env.delete "HTTP_CONTENT_LENGTH" - env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2) - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["PATH_INFO"] = env["REQUEST_PATH"] - env["QUERY_STRING"] ||= "" - env["SCRIPT_NAME"] = "" - - rack_input = StringIO.new(input_body) - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - - env.update({"rack.version" => [1,1], - "rack.input" => rack_input, - "rack.errors" => $stderr, - "rack.multithread" => true, - "rack.multiprocess" => true, - "rack.run_once" => false, - - "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http" - }) - status, headers, body = app.call(env) - begin - socket.write("Status: #{status}\r\n") - headers.each do |k, vs| - vs.split("\n").each { |v| socket.write("#{k}: #{v}\r\n")} - end - socket.write("\r\n") - body.each {|s| socket.write(s)} - ensure - body.close if body.respond_to? :close - end - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/swiftiplied_mongrel.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/swiftiplied_mongrel.rb deleted file mode 100644 index 4bafd0b9..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/swiftiplied_mongrel.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'swiftcore/swiftiplied_mongrel' - -module Rack - module Handler - class SwiftipliedMongrel < Handler::Mongrel - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/thin.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/thin.rb deleted file mode 100644 index 3d4fedff..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/thin.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "thin" -require "rack/content_length" -require "rack/chunked" - -module Rack - module Handler - class Thin - def self.run(app, options={}) - app = Rack::Chunked.new(Rack::ContentLength.new(app)) - server = ::Thin::Server.new(options[:Host] || '0.0.0.0', - options[:Port] || 8080, - app) - yield server if block_given? - server.start - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/handler/webrick.rb b/vendor/gems/rack-1.1.0/lib/rack/handler/webrick.rb deleted file mode 100644 index 8d7f5724..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/handler/webrick.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'webrick' -require 'stringio' -require 'rack/content_length' - -module Rack - module Handler - class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet - def self.run(app, options={}) - options[:BindAddress] = options.delete(:Host) if options[:Host] - server = ::WEBrick::HTTPServer.new(options) - server.mount "/", Rack::Handler::WEBrick, app - trap(:INT) { server.shutdown } - yield server if block_given? - server.start - end - - def initialize(server, app) - super server - @app = Rack::ContentLength.new(app) - end - - def service(req, res) - env = req.meta_vars - env.delete_if { |k, v| v.nil? } - - rack_input = StringIO.new(req.body.to_s) - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - - env.update({"rack.version" => [1,1], - "rack.input" => rack_input, - "rack.errors" => $stderr, - - "rack.multithread" => true, - "rack.multiprocess" => false, - "rack.run_once" => false, - - "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" - }) - - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["QUERY_STRING"] ||= "" - env["REQUEST_PATH"] ||= "/" - unless env["PATH_INFO"] == "" - path, n = req.request_uri.path, env["SCRIPT_NAME"].length - env["PATH_INFO"] = path[n, path.length-n] - end - - status, headers, body = @app.call(env) - begin - res.status = status.to_i - headers.each { |k, vs| - if k.downcase == "set-cookie" - res.cookies.concat vs.split("\n") - else - vs.split("\n").each { |v| - res[k] = v - } - end - } - body.each { |part| - res.body << part - } - ensure - body.close if body.respond_to? :close - end - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/head.rb b/vendor/gems/rack-1.1.0/lib/rack/head.rb deleted file mode 100644 index deab822a..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/head.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Rack - -class Head - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - - if env["REQUEST_METHOD"] == "HEAD" - [status, headers, []] - else - [status, headers, body] - end - end -end - -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/lint.rb b/vendor/gems/rack-1.1.0/lib/rack/lint.rb deleted file mode 100644 index 534375b9..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/lint.rb +++ /dev/null @@ -1,575 +0,0 @@ -require 'rack/utils' - -module Rack - # Rack::Lint validates your application and the requests and - # responses according to the Rack spec. - - class Lint - def initialize(app) - @app = app - end - - # :stopdoc: - - class LintError < RuntimeError; end - module Assertion - def assert(message, &block) - unless block.call - raise LintError, message - end - end - end - include Assertion - - ## This specification aims to formalize the Rack protocol. You - ## can (and should) use Rack::Lint to enforce it. - ## - ## When you develop middleware, be sure to add a Lint before and - ## after to catch all mistakes. - - ## = Rack applications - - ## A Rack application is an Ruby object (not a class) that - ## responds to +call+. - def call(env=nil) - dup._call(env) - end - - def _call(env) - ## It takes exactly one argument, the *environment* - assert("No env given") { env } - check_env env - - env['rack.input'] = InputWrapper.new(env['rack.input']) - env['rack.errors'] = ErrorWrapper.new(env['rack.errors']) - - ## and returns an Array of exactly three values: - status, headers, @body = @app.call(env) - ## The *status*, - check_status status - ## the *headers*, - check_headers headers - ## and the *body*. - check_content_type status, headers - check_content_length status, headers, env - [status, headers, self] - end - - ## == The Environment - def check_env(env) - ## The environment must be an true instance of Hash (no - ## subclassing allowed) that includes CGI-like headers. - ## The application is free to modify the environment. - assert("env #{env.inspect} is not a Hash, but #{env.class}") { - env.kind_of? Hash - } - - ## - ## The environment is required to include these variables - ## (adopted from PEP333), except when they'd be empty, but see - ## below. - - ## REQUEST_METHOD:: The HTTP request method, such as - ## "GET" or "POST". This cannot ever - ## be an empty string, and so is - ## always required. - - ## SCRIPT_NAME:: The initial portion of the request - ## URL's "path" that corresponds to the - ## application object, so that the - ## application knows its virtual - ## "location". This may be an empty - ## string, if the application corresponds - ## to the "root" of the server. - - ## PATH_INFO:: The remainder of the request URL's - ## "path", designating the virtual - ## "location" of the request's target - ## within the application. This may be an - ## empty string, if the request URL targets - ## the application root and does not have a - ## trailing slash. This value may be - ## percent-encoded when I originating from - ## a URL. - - ## QUERY_STRING:: The portion of the request URL that - ## follows the ?, if any. May be - ## empty, but is always required! - - ## SERVER_NAME, SERVER_PORT:: When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required. - - ## HTTP_ Variables:: Variables corresponding to the - ## client-supplied HTTP request - ## headers (i.e., variables whose - ## names begin with HTTP_). The - ## presence or absence of these - ## variables should correspond with - ## the presence or absence of the - ## appropriate HTTP header in the - ## request. - - ## In addition to this, the Rack environment must include these - ## Rack-specific variables: - - ## rack.version:: The Array [1,1], representing this version of Rack. - ## rack.url_scheme:: +http+ or +https+, depending on the request URL. - ## rack.input:: See below, the input stream. - ## rack.errors:: See below, the error stream. - ## rack.multithread:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise. - ## rack.multiprocess:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise. - ## rack.run_once:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar). - ## - - ## Additional environment specifications have approved to - ## standardized middleware APIs. None of these are required to - ## be implemented by the server. - - ## rack.session:: A hash like interface for storing request session data. - ## The store must implement: - if session = env['rack.session'] - ## store(key, value) (aliased as []=); - assert("session #{session.inspect} must respond to store and []=") { - session.respond_to?(:store) && session.respond_to?(:[]=) - } - - ## fetch(key, default = nil) (aliased as []); - assert("session #{session.inspect} must respond to fetch and []") { - session.respond_to?(:fetch) && session.respond_to?(:[]) - } - - ## delete(key); - assert("session #{session.inspect} must respond to delete") { - session.respond_to?(:delete) - } - - ## clear; - assert("session #{session.inspect} must respond to clear") { - session.respond_to?(:clear) - } - end - - ## rack.logger:: A common object interface for logging messages. - ## The object must implement: - if logger = env['rack.logger'] - ## info(message, &block) - assert("logger #{logger.inspect} must respond to info") { - logger.respond_to?(:info) - } - - ## debug(message, &block) - assert("logger #{logger.inspect} must respond to debug") { - logger.respond_to?(:debug) - } - - ## warn(message, &block) - assert("logger #{logger.inspect} must respond to warn") { - logger.respond_to?(:warn) - } - - ## error(message, &block) - assert("logger #{logger.inspect} must respond to error") { - logger.respond_to?(:error) - } - - ## fatal(message, &block) - assert("logger #{logger.inspect} must respond to fatal") { - logger.respond_to?(:fatal) - } - end - - ## The server or the application can store their own data in the - ## environment, too. The keys must contain at least one dot, - ## and should be prefixed uniquely. The prefix rack. - ## is reserved for use with the Rack core distribution and other - ## accepted specifications and must not be used otherwise. - ## - - %w[REQUEST_METHOD SERVER_NAME SERVER_PORT - QUERY_STRING - rack.version rack.input rack.errors - rack.multithread rack.multiprocess rack.run_once].each { |header| - assert("env missing required key #{header}") { env.include? header } - } - - ## The environment must not contain the keys - ## HTTP_CONTENT_TYPE or HTTP_CONTENT_LENGTH - ## (use the versions without HTTP_). - %w[HTTP_CONTENT_TYPE HTTP_CONTENT_LENGTH].each { |header| - assert("env contains #{header}, must use #{header[5,-1]}") { - not env.include? header - } - } - - ## The CGI keys (named without a period) must have String values. - env.each { |key, value| - next if key.include? "." # Skip extensions - assert("env variable #{key} has non-string value #{value.inspect}") { - value.kind_of? String - } - } - - ## - ## There are the following restrictions: - - ## * rack.version must be an array of Integers. - assert("rack.version must be an Array, was #{env["rack.version"].class}") { - env["rack.version"].kind_of? Array - } - ## * rack.url_scheme must either be +http+ or +https+. - assert("rack.url_scheme unknown: #{env["rack.url_scheme"].inspect}") { - %w[http https].include? env["rack.url_scheme"] - } - - ## * There must be a valid input stream in rack.input. - check_input env["rack.input"] - ## * There must be a valid error stream in rack.errors. - check_error env["rack.errors"] - - ## * The REQUEST_METHOD must be a valid token. - assert("REQUEST_METHOD unknown: #{env["REQUEST_METHOD"]}") { - env["REQUEST_METHOD"] =~ /\A[0-9A-Za-z!\#$%&'*+.^_`|~-]+\z/ - } - - ## * The SCRIPT_NAME, if non-empty, must start with / - assert("SCRIPT_NAME must start with /") { - !env.include?("SCRIPT_NAME") || - env["SCRIPT_NAME"] == "" || - env["SCRIPT_NAME"] =~ /\A\// - } - ## * The PATH_INFO, if non-empty, must start with / - assert("PATH_INFO must start with /") { - !env.include?("PATH_INFO") || - env["PATH_INFO"] == "" || - env["PATH_INFO"] =~ /\A\// - } - ## * The CONTENT_LENGTH, if given, must consist of digits only. - assert("Invalid CONTENT_LENGTH: #{env["CONTENT_LENGTH"]}") { - !env.include?("CONTENT_LENGTH") || env["CONTENT_LENGTH"] =~ /\A\d+\z/ - } - - ## * One of SCRIPT_NAME or PATH_INFO must be - ## set. PATH_INFO should be / if - ## SCRIPT_NAME is empty. - assert("One of SCRIPT_NAME or PATH_INFO must be set (make PATH_INFO '/' if SCRIPT_NAME is empty)") { - env["SCRIPT_NAME"] || env["PATH_INFO"] - } - ## SCRIPT_NAME never should be /, but instead be empty. - assert("SCRIPT_NAME cannot be '/', make it '' and PATH_INFO '/'") { - env["SCRIPT_NAME"] != "/" - } - end - - ## === The Input Stream - ## - ## The input stream is an IO-like object which contains the raw HTTP - ## POST data. - def check_input(input) - ## When applicable, its external encoding must be "ASCII-8BIT" and it - ## must be opened in binary mode, for Ruby 1.9 compatibility. - assert("rack.input #{input} does not have ASCII-8BIT as its external encoding") { - input.external_encoding.name == "ASCII-8BIT" - } if input.respond_to?(:external_encoding) - assert("rack.input #{input} is not opened in binary mode") { - input.binmode? - } if input.respond_to?(:binmode?) - - ## The input stream must respond to +gets+, +each+, +read+ and +rewind+. - [:gets, :each, :read, :rewind].each { |method| - assert("rack.input #{input} does not respond to ##{method}") { - input.respond_to? method - } - } - end - - class InputWrapper - include Assertion - - def initialize(input) - @input = input - end - - def size - @input.size - end - - ## * +gets+ must be called without arguments and return a string, - ## or +nil+ on EOF. - def gets(*args) - assert("rack.input#gets called with arguments") { args.size == 0 } - v = @input.gets - assert("rack.input#gets didn't return a String") { - v.nil? or v.kind_of? String - } - v - end - - ## * +read+ behaves like IO#read. Its signature is read([length, [buffer]]). - ## If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must - ## be a String and may not be nil. If +length+ is given and not nil, then this method - ## reads at most +length+ bytes from the input stream. If +length+ is not given or nil, - ## then this method reads all data until EOF. - ## When EOF is reached, this method returns nil if +length+ is given and not nil, or "" - ## if +length+ is not given or is nil. - ## If +buffer+ is given, then the read data will be placed into +buffer+ instead of a - ## newly created String object. - def read(*args) - assert("rack.input#read called with too many arguments") { - args.size <= 2 - } - if args.size >= 1 - assert("rack.input#read called with non-integer and non-nil length") { - args.first.kind_of?(Integer) || args.first.nil? - } - assert("rack.input#read called with a negative length") { - args.first.nil? || args.first >= 0 - } - end - if args.size >= 2 - assert("rack.input#read called with non-String buffer") { - args[1].kind_of?(String) - } - end - - v = @input.read(*args) - - assert("rack.input#read didn't return nil or a String") { - v.nil? or v.kind_of? String - } - if args[0].nil? - assert("rack.input#read(nil) returned nil on EOF") { - !v.nil? - } - end - - v - end - - ## * +each+ must be called without arguments and only yield Strings. - def each(*args) - assert("rack.input#each called with arguments") { args.size == 0 } - @input.each { |line| - assert("rack.input#each didn't yield a String") { - line.kind_of? String - } - yield line - } - end - - ## * +rewind+ must be called without arguments. It rewinds the input - ## stream back to the beginning. It must not raise Errno::ESPIPE: - ## that is, it may not be a pipe or a socket. Therefore, handler - ## developers must buffer the input data into some rewindable object - ## if the underlying input stream is not rewindable. - def rewind(*args) - assert("rack.input#rewind called with arguments") { args.size == 0 } - assert("rack.input#rewind raised Errno::ESPIPE") { - begin - @input.rewind - true - rescue Errno::ESPIPE - false - end - } - end - - ## * +close+ must never be called on the input stream. - def close(*args) - assert("rack.input#close must not be called") { false } - end - end - - ## === The Error Stream - def check_error(error) - ## The error stream must respond to +puts+, +write+ and +flush+. - [:puts, :write, :flush].each { |method| - assert("rack.error #{error} does not respond to ##{method}") { - error.respond_to? method - } - } - end - - class ErrorWrapper - include Assertion - - def initialize(error) - @error = error - end - - ## * +puts+ must be called with a single argument that responds to +to_s+. - def puts(str) - @error.puts str - end - - ## * +write+ must be called with a single argument that is a String. - def write(str) - assert("rack.errors#write not called with a String") { str.kind_of? String } - @error.write str - end - - ## * +flush+ must be called without arguments and must be called - ## in order to make the error appear for sure. - def flush - @error.flush - end - - ## * +close+ must never be called on the error stream. - def close(*args) - assert("rack.errors#close must not be called") { false } - end - end - - ## == The Response - - ## === The Status - def check_status(status) - ## This is an HTTP status. When parsed as integer (+to_i+), it must be - ## greater than or equal to 100. - assert("Status must be >=100 seen as integer") { status.to_i >= 100 } - end - - ## === The Headers - def check_headers(header) - ## The header must respond to +each+, and yield values of key and value. - assert("headers object should respond to #each, but doesn't (got #{header.class} as headers)") { - header.respond_to? :each - } - header.each { |key, value| - ## The header keys must be Strings. - assert("header key must be a string, was #{key.class}") { - key.kind_of? String - } - ## The header must not contain a +Status+ key, - assert("header must not contain Status") { key.downcase != "status" } - ## contain keys with : or newlines in their name, - assert("header names must not contain : or \\n") { key !~ /[:\n]/ } - ## contain keys names that end in - or _, - assert("header names must not end in - or _") { key !~ /[-_]\z/ } - ## but only contain keys that consist of - ## letters, digits, _ or - and start with a letter. - assert("invalid header name: #{key}") { key =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/ } - - ## The values of the header must be Strings, - assert("a header value must be a String, but the value of " + - "'#{key}' is a #{value.class}") { value.kind_of? String } - ## consisting of lines (for multiple header values, e.g. multiple - ## Set-Cookie values) seperated by "\n". - value.split("\n").each { |item| - ## The lines must not contain characters below 037. - assert("invalid header value #{key}: #{item.inspect}") { - item !~ /[\000-\037]/ - } - } - } - end - - ## === The Content-Type - def check_content_type(status, headers) - headers.each { |key, value| - ## There must be a Content-Type, except when the - ## +Status+ is 1xx, 204 or 304, in which case there must be none - ## given. - if key.downcase == "content-type" - assert("Content-Type header found in #{status} response, not allowed") { - not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - return - end - } - assert("No Content-Type header found") { - Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - end - - ## === The Content-Length - def check_content_length(status, headers, env) - headers.each { |key, value| - if key.downcase == 'content-length' - ## There must not be a Content-Length header when the - ## +Status+ is 1xx, 204 or 304. - assert("Content-Length header found in #{status} response, not allowed") { - not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - - bytes = 0 - string_body = true - - if @body.respond_to?(:to_ary) - @body.each { |part| - unless part.kind_of?(String) - string_body = false - break - end - - bytes += Rack::Utils.bytesize(part) - } - - if env["REQUEST_METHOD"] == "HEAD" - assert("Response body was given for HEAD request, but should be empty") { - bytes == 0 - } - else - if string_body - assert("Content-Length header was #{value}, but should be #{bytes}") { - value == bytes.to_s - } - end - end - end - - return - end - } - end - - ## === The Body - def each - @closed = false - ## The Body must respond to +each+ - @body.each { |part| - ## and must only yield String values. - assert("Body yielded non-string value #{part.inspect}") { - part.kind_of? String - } - yield part - } - ## - ## The Body itself should not be an instance of String, as this will - ## break in Ruby 1.9. - ## - ## If the Body responds to +close+, it will be called after iteration. - # XXX howto: assert("Body has not been closed") { @closed } - - - ## - ## If the Body responds to +to_path+, it must return a String - ## identifying the location of a file whose contents are identical - ## to that produced by calling +each+; this may be used by the - ## server as an alternative, possibly more efficient way to - ## transport the response. - - if @body.respond_to?(:to_path) - assert("The file identified by body.to_path does not exist") { - ::File.exist? @body.to_path - } - end - - ## - ## The Body commonly is an Array of Strings, the application - ## instance itself, or a File-like object. - end - - def close - @closed = true - @body.close if @body.respond_to?(:close) - end - - # :startdoc: - - end -end - -## == Thanks -## Some parts of this specification are adopted from PEP333: Python -## Web Server Gateway Interface -## v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank -## everyone involved in that effort. diff --git a/vendor/gems/rack-1.1.0/lib/rack/lobster.rb b/vendor/gems/rack-1.1.0/lib/rack/lobster.rb deleted file mode 100644 index f63f419a..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/lobster.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'zlib' - -require 'rack/request' -require 'rack/response' - -module Rack - # Paste has a Pony, Rack has a Lobster! - class Lobster - LobsterString = Zlib::Inflate.inflate("eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2 - P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0 - t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ - I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==".delete("\n ").unpack("m*")[0]) - - LambdaLobster = lambda { |env| - if env["QUERY_STRING"].include?("flip") - lobster = LobsterString.split("\n"). - map { |line| line.ljust(42).reverse }. - join("\n") - href = "?" - else - lobster = LobsterString - href = "?flip" - end - - content = ["Lobstericious!", - "
    ", lobster, "
    ", - "flip!"] - length = content.inject(0) { |a,e| a+e.size }.to_s - [200, {"Content-Type" => "text/html", "Content-Length" => length}, content] - } - - def call(env) - req = Request.new(env) - if req.GET["flip"] == "left" - lobster = LobsterString.split("\n"). - map { |line| line.ljust(42).reverse }. - join("\n") - href = "?flip=right" - elsif req.GET["flip"] == "crash" - raise "Lobster crashed" - else - lobster = LobsterString - href = "?flip=left" - end - - res = Response.new - res.write "Lobstericious!" - res.write "
    "
    -      res.write lobster
    -      res.write "
    " - res.write "

    flip!

    " - res.write "

    crash!

    " - res.finish - end - - end -end - -if $0 == __FILE__ - require 'rack' - require 'rack/showexceptions' - Rack::Handler::WEBrick.run \ - Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster.new)), - :Port => 9292 -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/lock.rb b/vendor/gems/rack-1.1.0/lib/rack/lock.rb deleted file mode 100644 index 93238528..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/lock.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Rack - class Lock - FLAG = 'rack.multithread'.freeze - - def initialize(app, lock = Mutex.new) - @app, @lock = app, lock - end - - def call(env) - old, env[FLAG] = env[FLAG], false - @lock.synchronize { @app.call(env) } - ensure - env[FLAG] = old - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/logger.rb b/vendor/gems/rack-1.1.0/lib/rack/logger.rb deleted file mode 100644 index d67d8ce2..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/logger.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'logger' - -module Rack - # Sets up rack.logger to write to rack.errors stream - class Logger - def initialize(app, level = ::Logger::INFO) - @app, @level = app, level - end - - def call(env) - logger = ::Logger.new(env['rack.errors']) - logger.level = @level - - env['rack.logger'] = logger - @app.call(env) - ensure - logger.close - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/methodoverride.rb b/vendor/gems/rack-1.1.0/lib/rack/methodoverride.rb deleted file mode 100644 index 0eed29f4..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/methodoverride.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Rack - class MethodOverride - HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS) - - METHOD_OVERRIDE_PARAM_KEY = "_method".freeze - HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze - - def initialize(app) - @app = app - end - - def call(env) - if env["REQUEST_METHOD"] == "POST" - req = Request.new(env) - method = req.POST[METHOD_OVERRIDE_PARAM_KEY] || - env[HTTP_METHOD_OVERRIDE_HEADER] - method = method.to_s.upcase - if HTTP_METHODS.include?(method) - env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"] - env["REQUEST_METHOD"] = method - end - end - - @app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/mime.rb b/vendor/gems/rack-1.1.0/lib/rack/mime.rb deleted file mode 100644 index 1414d19a..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/mime.rb +++ /dev/null @@ -1,206 +0,0 @@ -module Rack - module Mime - # Returns String with mime type if found, otherwise use +fallback+. - # +ext+ should be filename extension in the '.ext' format that - # File.extname(file) returns. - # +fallback+ may be any object - # - # Also see the documentation for MIME_TYPES - # - # Usage: - # Rack::Mime.mime_type('.foo') - # - # This is a shortcut for: - # Rack::Mime::MIME_TYPES.fetch('.foo', 'application/octet-stream') - - def mime_type(ext, fallback='application/octet-stream') - MIME_TYPES.fetch(ext.to_s.downcase, fallback) - end - module_function :mime_type - - # List of most common mime-types, selected various sources - # according to their usefulness in a webserving scope for Ruby - # users. - # - # To amend this list with your local mime.types list you can use: - # - # require 'webrick/httputils' - # list = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types') - # Rack::Mime::MIME_TYPES.merge!(list) - # - # To add the list mongrel provides, use: - # - # require 'mongrel/handlers' - # Rack::Mime::MIME_TYPES.merge!(Mongrel::DirHandler::MIME_TYPES) - - MIME_TYPES = { - ".3gp" => "video/3gpp", - ".a" => "application/octet-stream", - ".ai" => "application/postscript", - ".aif" => "audio/x-aiff", - ".aiff" => "audio/x-aiff", - ".asc" => "application/pgp-signature", - ".asf" => "video/x-ms-asf", - ".asm" => "text/x-asm", - ".asx" => "video/x-ms-asf", - ".atom" => "application/atom+xml", - ".au" => "audio/basic", - ".avi" => "video/x-msvideo", - ".bat" => "application/x-msdownload", - ".bin" => "application/octet-stream", - ".bmp" => "image/bmp", - ".bz2" => "application/x-bzip2", - ".c" => "text/x-c", - ".cab" => "application/vnd.ms-cab-compressed", - ".cc" => "text/x-c", - ".chm" => "application/vnd.ms-htmlhelp", - ".class" => "application/octet-stream", - ".com" => "application/x-msdownload", - ".conf" => "text/plain", - ".cpp" => "text/x-c", - ".crt" => "application/x-x509-ca-cert", - ".css" => "text/css", - ".csv" => "text/csv", - ".cxx" => "text/x-c", - ".deb" => "application/x-debian-package", - ".der" => "application/x-x509-ca-cert", - ".diff" => "text/x-diff", - ".djv" => "image/vnd.djvu", - ".djvu" => "image/vnd.djvu", - ".dll" => "application/x-msdownload", - ".dmg" => "application/octet-stream", - ".doc" => "application/msword", - ".dot" => "application/msword", - ".dtd" => "application/xml-dtd", - ".dvi" => "application/x-dvi", - ".ear" => "application/java-archive", - ".eml" => "message/rfc822", - ".eps" => "application/postscript", - ".exe" => "application/x-msdownload", - ".f" => "text/x-fortran", - ".f77" => "text/x-fortran", - ".f90" => "text/x-fortran", - ".flv" => "video/x-flv", - ".for" => "text/x-fortran", - ".gem" => "application/octet-stream", - ".gemspec" => "text/x-script.ruby", - ".gif" => "image/gif", - ".gz" => "application/x-gzip", - ".h" => "text/x-c", - ".hh" => "text/x-c", - ".htm" => "text/html", - ".html" => "text/html", - ".ico" => "image/vnd.microsoft.icon", - ".ics" => "text/calendar", - ".ifb" => "text/calendar", - ".iso" => "application/octet-stream", - ".jar" => "application/java-archive", - ".java" => "text/x-java-source", - ".jnlp" => "application/x-java-jnlp-file", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".js" => "application/javascript", - ".json" => "application/json", - ".log" => "text/plain", - ".m3u" => "audio/x-mpegurl", - ".m4v" => "video/mp4", - ".man" => "text/troff", - ".manifest"=> "text/cache-manifest", - ".mathml" => "application/mathml+xml", - ".mbox" => "application/mbox", - ".mdoc" => "text/troff", - ".me" => "text/troff", - ".mid" => "audio/midi", - ".midi" => "audio/midi", - ".mime" => "message/rfc822", - ".mml" => "application/mathml+xml", - ".mng" => "video/x-mng", - ".mov" => "video/quicktime", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mp4v" => "video/mp4", - ".mpeg" => "video/mpeg", - ".mpg" => "video/mpeg", - ".ms" => "text/troff", - ".msi" => "application/x-msdownload", - ".odp" => "application/vnd.oasis.opendocument.presentation", - ".ods" => "application/vnd.oasis.opendocument.spreadsheet", - ".odt" => "application/vnd.oasis.opendocument.text", - ".ogg" => "application/ogg", - ".ogv" => "video/ogg", - ".p" => "text/x-pascal", - ".pas" => "text/x-pascal", - ".pbm" => "image/x-portable-bitmap", - ".pdf" => "application/pdf", - ".pem" => "application/x-x509-ca-cert", - ".pgm" => "image/x-portable-graymap", - ".pgp" => "application/pgp-encrypted", - ".pkg" => "application/octet-stream", - ".pl" => "text/x-script.perl", - ".pm" => "text/x-script.perl-module", - ".png" => "image/png", - ".pnm" => "image/x-portable-anymap", - ".ppm" => "image/x-portable-pixmap", - ".pps" => "application/vnd.ms-powerpoint", - ".ppt" => "application/vnd.ms-powerpoint", - ".ps" => "application/postscript", - ".psd" => "image/vnd.adobe.photoshop", - ".py" => "text/x-script.python", - ".qt" => "video/quicktime", - ".ra" => "audio/x-pn-realaudio", - ".rake" => "text/x-script.ruby", - ".ram" => "audio/x-pn-realaudio", - ".rar" => "application/x-rar-compressed", - ".rb" => "text/x-script.ruby", - ".rdf" => "application/rdf+xml", - ".roff" => "text/troff", - ".rpm" => "application/x-redhat-package-manager", - ".rss" => "application/rss+xml", - ".rtf" => "application/rtf", - ".ru" => "text/x-script.ruby", - ".s" => "text/x-asm", - ".sgm" => "text/sgml", - ".sgml" => "text/sgml", - ".sh" => "application/x-sh", - ".sig" => "application/pgp-signature", - ".snd" => "audio/basic", - ".so" => "application/octet-stream", - ".svg" => "image/svg+xml", - ".svgz" => "image/svg+xml", - ".swf" => "application/x-shockwave-flash", - ".t" => "text/troff", - ".tar" => "application/x-tar", - ".tbz" => "application/x-bzip-compressed-tar", - ".tcl" => "application/x-tcl", - ".tex" => "application/x-tex", - ".texi" => "application/x-texinfo", - ".texinfo" => "application/x-texinfo", - ".text" => "text/plain", - ".tif" => "image/tiff", - ".tiff" => "image/tiff", - ".torrent" => "application/x-bittorrent", - ".tr" => "text/troff", - ".txt" => "text/plain", - ".vcf" => "text/x-vcard", - ".vcs" => "text/x-vcalendar", - ".vrml" => "model/vrml", - ".war" => "application/java-archive", - ".wav" => "audio/x-wav", - ".wma" => "audio/x-ms-wma", - ".wmv" => "video/x-ms-wmv", - ".wmx" => "video/x-ms-wmx", - ".wrl" => "model/vrml", - ".wsdl" => "application/wsdl+xml", - ".xbm" => "image/x-xbitmap", - ".xhtml" => "application/xhtml+xml", - ".xls" => "application/vnd.ms-excel", - ".xml" => "application/xml", - ".xpm" => "image/x-xpixmap", - ".xsl" => "application/xml", - ".xslt" => "application/xslt+xml", - ".yaml" => "text/yaml", - ".yml" => "text/yaml", - ".zip" => "application/zip", - } - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/mock.rb b/vendor/gems/rack-1.1.0/lib/rack/mock.rb deleted file mode 100644 index 23ecba17..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/mock.rb +++ /dev/null @@ -1,189 +0,0 @@ -require 'uri' -require 'stringio' -require 'rack/lint' -require 'rack/utils' -require 'rack/response' - -module Rack - # Rack::MockRequest helps testing your Rack application without - # actually using HTTP. - # - # After performing a request on a URL with get/post/put/delete, it - # returns a MockResponse with useful helper methods for effective - # testing. - # - # You can pass a hash with additional configuration to the - # get/post/put/delete. - # :input:: A String or IO-like to be used as rack.input. - # :fatal:: Raise a FatalWarning if the app writes to rack.errors. - # :lint:: If true, wrap the application in a Rack::Lint. - - class MockRequest - class FatalWarning < RuntimeError - end - - class FatalWarner - def puts(warning) - raise FatalWarning, warning - end - - def write(warning) - raise FatalWarning, warning - end - - def flush - end - - def string - "" - end - end - - DEFAULT_ENV = { - "rack.version" => [1,1], - "rack.input" => StringIO.new, - "rack.errors" => StringIO.new, - "rack.multithread" => true, - "rack.multiprocess" => true, - "rack.run_once" => false, - } - - def initialize(app) - @app = app - end - - def get(uri, opts={}) request("GET", uri, opts) end - def post(uri, opts={}) request("POST", uri, opts) end - def put(uri, opts={}) request("PUT", uri, opts) end - def delete(uri, opts={}) request("DELETE", uri, opts) end - - def request(method="GET", uri="", opts={}) - env = self.class.env_for(uri, opts.merge(:method => method)) - - if opts[:lint] - app = Rack::Lint.new(@app) - else - app = @app - end - - errors = env["rack.errors"] - MockResponse.new(*(app.call(env) + [errors])) - end - - # Return the Rack environment used for a request to +uri+. - def self.env_for(uri="", opts={}) - uri = URI(uri) - uri.path = "/#{uri.path}" unless uri.path[0] == ?/ - - env = DEFAULT_ENV.dup - - env["REQUEST_METHOD"] = opts[:method] ? opts[:method].to_s.upcase : "GET" - env["SERVER_NAME"] = uri.host || "example.org" - env["SERVER_PORT"] = uri.port ? uri.port.to_s : "80" - env["QUERY_STRING"] = uri.query.to_s - env["PATH_INFO"] = (!uri.path || uri.path.empty?) ? "/" : uri.path - env["rack.url_scheme"] = uri.scheme || "http" - env["HTTPS"] = env["rack.url_scheme"] == "https" ? "on" : "off" - - env["SCRIPT_NAME"] = opts[:script_name] || "" - - if opts[:fatal] - env["rack.errors"] = FatalWarner.new - else - env["rack.errors"] = StringIO.new - end - - if params = opts[:params] - if env["REQUEST_METHOD"] == "GET" - params = Utils.parse_nested_query(params) if params.is_a?(String) - params.update(Utils.parse_nested_query(env["QUERY_STRING"])) - env["QUERY_STRING"] = Utils.build_nested_query(params) - elsif !opts.has_key?(:input) - opts["CONTENT_TYPE"] = "application/x-www-form-urlencoded" - if params.is_a?(Hash) - if data = Utils::Multipart.build_multipart(params) - opts[:input] = data - opts["CONTENT_LENGTH"] ||= data.length.to_s - opts["CONTENT_TYPE"] = "multipart/form-data; boundary=#{Utils::Multipart::MULTIPART_BOUNDARY}" - else - opts[:input] = Utils.build_nested_query(params) - end - else - opts[:input] = params - end - end - end - - empty_str = "" - empty_str.force_encoding("ASCII-8BIT") if empty_str.respond_to? :force_encoding - opts[:input] ||= empty_str - if String === opts[:input] - rack_input = StringIO.new(opts[:input]) - else - rack_input = opts[:input] - end - - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - env['rack.input'] = rack_input - - env["CONTENT_LENGTH"] ||= env["rack.input"].length.to_s - - opts.each { |field, value| - env[field] = value if String === field - } - - env - end - end - - # Rack::MockResponse provides useful helpers for testing your apps. - # Usually, you don't create the MockResponse on your own, but use - # MockRequest. - - class MockResponse - def initialize(status, headers, body, errors=StringIO.new("")) - @status = status.to_i - - @original_headers = headers - @headers = Rack::Utils::HeaderHash.new - headers.each { |field, values| - @headers[field] = values - @headers[field] = "" if values.empty? - } - - @body = "" - body.each { |part| @body << part } - - @errors = errors.string if errors.respond_to?(:string) - end - - # Status - attr_reader :status - - # Headers - attr_reader :headers, :original_headers - - def [](field) - headers[field] - end - - - # Body - attr_reader :body - - def =~(other) - @body =~ other - end - - def match(other) - @body.match other - end - - - # Errors - attr_accessor :errors - - - include Response::Helpers - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/nulllogger.rb b/vendor/gems/rack-1.1.0/lib/rack/nulllogger.rb deleted file mode 100644 index 77fb637d..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/nulllogger.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Rack - class NullLogger - def initialize(app) - @app = app - end - - def call(env) - env['rack.logger'] = self - @app.call(env) - end - - def info(progname = nil, &block); end - def debug(progname = nil, &block); end - def warn(progname = nil, &block); end - def error(progname = nil, &block); end - def fatal(progname = nil, &block); end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/recursive.rb b/vendor/gems/rack-1.1.0/lib/rack/recursive.rb deleted file mode 100644 index bf8b9659..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/recursive.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'uri' - -module Rack - # Rack::ForwardRequest gets caught by Rack::Recursive and redirects - # the current request to the app at +url+. - # - # raise ForwardRequest.new("/not-found") - # - - class ForwardRequest < Exception - attr_reader :url, :env - - def initialize(url, env={}) - @url = URI(url) - @env = env - - @env["PATH_INFO"] = @url.path - @env["QUERY_STRING"] = @url.query if @url.query - @env["HTTP_HOST"] = @url.host if @url.host - @env["HTTP_PORT"] = @url.port if @url.port - @env["rack.url_scheme"] = @url.scheme if @url.scheme - - super "forwarding to #{url}" - end - end - - # Rack::Recursive allows applications called down the chain to - # include data from other applications (by using - # rack['rack.recursive.include'][...] or raise a - # ForwardRequest to redirect internally. - - class Recursive - def initialize(app) - @app = app - end - - def call(env) - @script_name = env["SCRIPT_NAME"] - @app.call(env.merge('rack.recursive.include' => method(:include))) - rescue ForwardRequest => req - call(env.merge(req.env)) - end - - def include(env, path) - unless path.index(@script_name) == 0 && (path[@script_name.size] == ?/ || - path[@script_name.size].nil?) - raise ArgumentError, "can only include below #{@script_name}, not #{path}" - end - - env = env.merge("PATH_INFO" => path, "SCRIPT_NAME" => @script_name, - "REQUEST_METHOD" => "GET", - "CONTENT_LENGTH" => "0", "CONTENT_TYPE" => "", - "rack.input" => StringIO.new("")) - @app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/reloader.rb b/vendor/gems/rack-1.1.0/lib/rack/reloader.rb deleted file mode 100644 index a06de23a..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/reloader.rb +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com -# Rack::Reloader is subject to the terms of an MIT-style license. -# See COPYING or http://www.opensource.org/licenses/mit-license.php. - -require 'pathname' - -module Rack - - # High performant source reloader - # - # This class acts as Rack middleware. - # - # What makes it especially suited for use in a production environment is that - # any file will only be checked once and there will only be made one system - # call stat(2). - # - # Please note that this will not reload files in the background, it does so - # only when actively called. - # - # It is performing a check/reload cycle at the start of every request, but - # also respects a cool down time, during which nothing will be done. - class Reloader - def initialize(app, cooldown = 10, backend = Stat) - @app = app - @cooldown = cooldown - @last = (Time.now - cooldown) - @cache = {} - @mtimes = {} - - extend backend - end - - def call(env) - if @cooldown and Time.now > @last + @cooldown - if Thread.list.size > 1 - Thread.exclusive{ reload! } - else - reload! - end - - @last = Time.now - end - - @app.call(env) - end - - def reload!(stderr = $stderr) - rotation do |file, mtime| - previous_mtime = @mtimes[file] ||= mtime - safe_load(file, mtime, stderr) if mtime > previous_mtime - end - end - - # A safe Kernel::load, issuing the hooks depending on the results - def safe_load(file, mtime, stderr = $stderr) - load(file) - stderr.puts "#{self.class}: reloaded `#{file}'" - file - rescue LoadError, SyntaxError => ex - stderr.puts ex - ensure - @mtimes[file] = mtime - end - - module Stat - def rotation - files = [$0, *$LOADED_FEATURES].uniq - paths = ['./', *$LOAD_PATH].uniq - - files.map{|file| - next if file =~ /\.(so|bundle)$/ # cannot reload compiled files - - found, stat = figure_path(file, paths) - next unless found && stat && mtime = stat.mtime - - @cache[file] = found - - yield(found, mtime) - }.compact - end - - # Takes a relative or absolute +file+ name, a couple possible +paths+ that - # the +file+ might reside in. Returns the full path and File::Stat for the - # path. - def figure_path(file, paths) - found = @cache[file] - found = file if !found and Pathname.new(file).absolute? - found, stat = safe_stat(found) - return found, stat if found - - paths.find do |possible_path| - path = ::File.join(possible_path, file) - found, stat = safe_stat(path) - return ::File.expand_path(found), stat if found - end - - return false, false - end - - def safe_stat(file) - return unless file - stat = ::File.stat(file) - return file, stat if stat.file? - rescue Errno::ENOENT, Errno::ENOTDIR - @cache.delete(file) and false - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/request.rb b/vendor/gems/rack-1.1.0/lib/rack/request.rb deleted file mode 100644 index b3de1ce4..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/request.rb +++ /dev/null @@ -1,271 +0,0 @@ -require 'rack/utils' - -module Rack - # Rack::Request provides a convenient interface to a Rack - # environment. It is stateless, the environment +env+ passed to the - # constructor will be directly modified. - # - # req = Rack::Request.new(env) - # req.post? - # req.params["data"] - # - # The environment hash passed will store a reference to the Request object - # instantiated so that it will only instantiate if an instance of the Request - # object doesn't already exist. - - class Request - # The environment of the request. - attr_reader :env - - def initialize(env) - @env = env - end - - def body; @env["rack.input"] end - def scheme; @env["rack.url_scheme"] end - def script_name; @env["SCRIPT_NAME"].to_s end - def path_info; @env["PATH_INFO"].to_s end - def port; @env["SERVER_PORT"].to_i end - def request_method; @env["REQUEST_METHOD"] end - def query_string; @env["QUERY_STRING"].to_s end - def content_length; @env['CONTENT_LENGTH'] end - def content_type; @env['CONTENT_TYPE'] end - def session; @env['rack.session'] ||= {} end - def session_options; @env['rack.session.options'] ||= {} end - def logger; @env['rack.logger'] end - - # The media type (type/subtype) portion of the CONTENT_TYPE header - # without any media type parameters. e.g., when CONTENT_TYPE is - # "text/plain;charset=utf-8", the media-type is "text/plain". - # - # For more information on the use of media types in HTTP, see: - # http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 - def media_type - content_type && content_type.split(/\s*[;,]\s*/, 2).first.downcase - end - - # The media type parameters provided in CONTENT_TYPE as a Hash, or - # an empty Hash if no CONTENT_TYPE or media-type parameters were - # provided. e.g., when the CONTENT_TYPE is "text/plain;charset=utf-8", - # this method responds with the following Hash: - # { 'charset' => 'utf-8' } - def media_type_params - return {} if content_type.nil? - content_type.split(/\s*[;,]\s*/)[1..-1]. - collect { |s| s.split('=', 2) }. - inject({}) { |hash,(k,v)| hash[k.downcase] = v ; hash } - end - - # The character set of the request body if a "charset" media type - # parameter was given, or nil if no "charset" was specified. Note - # that, per RFC2616, text/* media types that specify no explicit - # charset are to be considered ISO-8859-1. - def content_charset - media_type_params['charset'] - end - - def host_with_port - if forwarded = @env["HTTP_X_FORWARDED_HOST"] - forwarded.split(/,\s?/).last - else - @env['HTTP_HOST'] || "#{@env['SERVER_NAME'] || @env['SERVER_ADDR']}:#{@env['SERVER_PORT']}" - end - end - - def host - # Remove port number. - host_with_port.to_s.gsub(/:\d+\z/, '') - end - - def script_name=(s); @env["SCRIPT_NAME"] = s.to_s end - def path_info=(s); @env["PATH_INFO"] = s.to_s end - - def get?; request_method == "GET" end - def post?; request_method == "POST" end - def put?; request_method == "PUT" end - def delete?; request_method == "DELETE" end - def head?; request_method == "HEAD" end - - # The set of form-data media-types. Requests that do not indicate - # one of the media types presents in this list will not be eligible - # for form-data / param parsing. - FORM_DATA_MEDIA_TYPES = [ - 'application/x-www-form-urlencoded', - 'multipart/form-data' - ] - - # The set of media-types. Requests that do not indicate - # one of the media types presents in this list will not be eligible - # for param parsing like soap attachments or generic multiparts - PARSEABLE_DATA_MEDIA_TYPES = [ - 'multipart/related', - 'multipart/mixed' - ] - - # Determine whether the request body contains form-data by checking - # the request Content-Type for one of the media-types: - # "application/x-www-form-urlencoded" or "multipart/form-data". The - # list of form-data media types can be modified through the - # +FORM_DATA_MEDIA_TYPES+ array. - # - # A request body is also assumed to contain form-data when no - # Content-Type header is provided and the request_method is POST. - def form_data? - type = media_type - meth = env["rack.methodoverride.original_method"] || env['REQUEST_METHOD'] - (meth == 'POST' && type.nil?) || FORM_DATA_MEDIA_TYPES.include?(type) - end - - # Determine whether the request body contains data by checking - # the request media_type against registered parse-data media-types - def parseable_data? - PARSEABLE_DATA_MEDIA_TYPES.include?(media_type) - end - - # Returns the data recieved in the query string. - def GET - if @env["rack.request.query_string"] == query_string - @env["rack.request.query_hash"] - else - @env["rack.request.query_string"] = query_string - @env["rack.request.query_hash"] = parse_query(query_string) - end - end - - # Returns the data recieved in the request body. - # - # This method support both application/x-www-form-urlencoded and - # multipart/form-data. - def POST - if @env["rack.input"].nil? - raise "Missing rack.input" - elsif @env["rack.request.form_input"].eql? @env["rack.input"] - @env["rack.request.form_hash"] - elsif form_data? || parseable_data? - @env["rack.request.form_input"] = @env["rack.input"] - unless @env["rack.request.form_hash"] = parse_multipart(env) - form_vars = @env["rack.input"].read - - # Fix for Safari Ajax postings that always append \0 - form_vars.sub!(/\0\z/, '') - - @env["rack.request.form_vars"] = form_vars - @env["rack.request.form_hash"] = parse_query(form_vars) - - @env["rack.input"].rewind - end - @env["rack.request.form_hash"] - else - {} - end - end - - # The union of GET and POST data. - def params - self.GET.update(self.POST) - rescue EOFError => e - self.GET - end - - # shortcut for request.params[key] - def [](key) - params[key.to_s] - end - - # shortcut for request.params[key] = value - def []=(key, value) - params[key.to_s] = value - end - - # like Hash#values_at - def values_at(*keys) - keys.map{|key| params[key] } - end - - # the referer of the client or '/' - def referer - @env['HTTP_REFERER'] || '/' - end - alias referrer referer - - def user_agent - @env['HTTP_USER_AGENT'] - end - - def cookies - return {} unless @env["HTTP_COOKIE"] - - if @env["rack.request.cookie_string"] == @env["HTTP_COOKIE"] - @env["rack.request.cookie_hash"] - else - @env["rack.request.cookie_string"] = @env["HTTP_COOKIE"] - # According to RFC 2109: - # If multiple cookies satisfy the criteria above, they are ordered in - # the Cookie header such that those with more specific Path attributes - # precede those with less specific. Ordering with respect to other - # attributes (e.g., Domain) is unspecified. - @env["rack.request.cookie_hash"] = - Utils.parse_query(@env["rack.request.cookie_string"], ';,').inject({}) {|h,(k,v)| - h[k] = Array === v ? v.first : v - h - } - end - end - - def xhr? - @env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" - end - - # Tries to return a remake of the original request URL as a string. - def url - url = scheme + "://" - url << host - - if scheme == "https" && port != 443 || - scheme == "http" && port != 80 - url << ":#{port}" - end - - url << fullpath - - url - end - - def path - script_name + path_info - end - - def fullpath - query_string.empty? ? path : "#{path}?#{query_string}" - end - - def accept_encoding - @env["HTTP_ACCEPT_ENCODING"].to_s.split(/,\s*/).map do |part| - m = /^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$/.match(part) # From WEBrick - - if m - [m[1], (m[2] || 1.0).to_f] - else - raise "Invalid value for Accept-Encoding: #{part.inspect}" - end - end - end - - def ip - if addr = @env['HTTP_X_FORWARDED_FOR'] - addr.split(',').last.strip - else - @env['REMOTE_ADDR'] - end - end - - protected - def parse_query(qs) - Utils.parse_nested_query(qs) - end - - def parse_multipart(env) - Utils::Multipart.parse_multipart(env) - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/response.rb b/vendor/gems/rack-1.1.0/lib/rack/response.rb deleted file mode 100644 index a7f9bf2b..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/response.rb +++ /dev/null @@ -1,149 +0,0 @@ -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::Response provides a convenient interface to create a Rack - # response. - # - # It allows setting of headers and cookies, and provides useful - # defaults (a OK response containing HTML). - # - # You can use Response#write to iteratively generate your response, - # but note that this is buffered by Rack::Response until you call - # +finish+. +finish+ however can take a block inside which calls to - # +write+ are syncronous with the Rack response. - # - # Your application's +call+ should end returning Response#finish. - - class Response - attr_accessor :length - - def initialize(body=[], status=200, header={}, &block) - @status = status.to_i - @header = Utils::HeaderHash.new({"Content-Type" => "text/html"}. - merge(header)) - - @writer = lambda { |x| @body << x } - @block = nil - @length = 0 - - @body = [] - - if body.respond_to? :to_str - write body.to_str - elsif body.respond_to?(:each) - body.each { |part| - write part.to_s - } - else - raise TypeError, "stringable or iterable required" - end - - yield self if block_given? - end - - attr_reader :header - attr_accessor :status, :body - - def [](key) - header[key] - end - - def []=(key, value) - header[key] = value - end - - def set_cookie(key, value) - Utils.set_cookie_header!(header, key, value) - end - - def delete_cookie(key, value={}) - Utils.delete_cookie_header!(header, key, value) - end - - def redirect(target, status=302) - self.status = status - self["Location"] = target - end - - def finish(&block) - @block = block - - if [204, 304].include?(status.to_i) - header.delete "Content-Type" - [status.to_i, header, []] - else - [status.to_i, header, self] - end - end - alias to_a finish # For *response - - def each(&callback) - @body.each(&callback) - @writer = callback - @block.call(self) if @block - end - - # Append to body and update Content-Length. - # - # NOTE: Do not mix #write and direct #body access! - # - def write(str) - s = str.to_s - @length += Rack::Utils.bytesize(s) - @writer.call s - - header["Content-Length"] = @length.to_s - str - end - - def close - body.close if body.respond_to?(:close) - end - - def empty? - @block == nil && @body.empty? - end - - alias headers header - - module Helpers - def invalid?; @status < 100 || @status >= 600; end - - def informational?; @status >= 100 && @status < 200; end - def successful?; @status >= 200 && @status < 300; end - def redirection?; @status >= 300 && @status < 400; end - def client_error?; @status >= 400 && @status < 500; end - def server_error?; @status >= 500 && @status < 600; end - - def ok?; @status == 200; end - def forbidden?; @status == 403; end - def not_found?; @status == 404; end - - def redirect?; [301, 302, 303, 307].include? @status; end - def empty?; [201, 204, 304].include? @status; end - - # Headers - attr_reader :headers, :original_headers - - def include?(header) - !!headers[header] - end - - def content_type - headers["Content-Type"] - end - - def content_length - cl = headers["Content-Length"] - cl ? cl.to_i : cl - end - - def location - headers["Location"] - end - end - - include Helpers - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/rewindable_input.rb b/vendor/gems/rack-1.1.0/lib/rack/rewindable_input.rb deleted file mode 100644 index accd96be..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/rewindable_input.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'tempfile' - -module Rack - # Class which can make any IO object rewindable, including non-rewindable ones. It does - # this by buffering the data into a tempfile, which is rewindable. - # - # rack.input is required to be rewindable, so if your input stream IO is non-rewindable - # by nature (e.g. a pipe or a socket) then you can wrap it in an object of this class - # to easily make it rewindable. - # - # Don't forget to call #close when you're done. This frees up temporary resources that - # RewindableInput uses, though it does *not* close the original IO object. - class RewindableInput - def initialize(io) - @io = io - @rewindable_io = nil - @unlinked = false - end - - def gets - make_rewindable unless @rewindable_io - @rewindable_io.gets - end - - def read(*args) - make_rewindable unless @rewindable_io - @rewindable_io.read(*args) - end - - def each(&block) - make_rewindable unless @rewindable_io - @rewindable_io.each(&block) - end - - def rewind - make_rewindable unless @rewindable_io - @rewindable_io.rewind - end - - # Closes this RewindableInput object without closing the originally - # wrapped IO oject. Cleans up any temporary resources that this RewindableInput - # has created. - # - # This method may be called multiple times. It does nothing on subsequent calls. - def close - if @rewindable_io - if @unlinked - @rewindable_io.close - else - @rewindable_io.close! - end - @rewindable_io = nil - end - end - - private - - # Ruby's Tempfile class has a bug. Subclass it and fix it. - class Tempfile < ::Tempfile - def _close - @tmpfile.close if @tmpfile - @data[1] = nil if @data - @tmpfile = nil - end - end - - def make_rewindable - # Buffer all data into a tempfile. Since this tempfile is private to this - # RewindableInput object, we chmod it so that nobody else can read or write - # it. On POSIX filesystems we also unlink the file so that it doesn't - # even have a file entry on the filesystem anymore, though we can still - # access it because we have the file handle open. - @rewindable_io = Tempfile.new('RackRewindableInput') - @rewindable_io.chmod(0000) - @rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding) - @rewindable_io.binmode - if filesystem_has_posix_semantics? - @rewindable_io.unlink - @unlinked = true - end - - buffer = "" - while @io.read(1024 * 4, buffer) - entire_buffer_written_out = false - while !entire_buffer_written_out - written = @rewindable_io.write(buffer) - entire_buffer_written_out = written == buffer.size - if !entire_buffer_written_out - buffer.slice!(0 .. written - 1) - end - end - end - @rewindable_io.rewind - end - - def filesystem_has_posix_semantics? - RUBY_PLATFORM !~ /(mswin|mingw|cygwin|java)/ - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/runtime.rb b/vendor/gems/rack-1.1.0/lib/rack/runtime.rb deleted file mode 100644 index 1bd411fd..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/runtime.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Rack - # Sets an "X-Runtime" response header, indicating the response - # time of the request, in seconds - # - # You can put it right before the application to see the processing - # time, or before all the other middlewares to include time for them, - # too. - class Runtime - def initialize(app, name = nil) - @app = app - @header_name = "X-Runtime" - @header_name << "-#{name}" if name - end - - def call(env) - start_time = Time.now - status, headers, body = @app.call(env) - request_time = Time.now - start_time - - if !headers.has_key?(@header_name) - headers[@header_name] = "%0.6f" % request_time - end - - [status, headers, body] - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/sendfile.rb b/vendor/gems/rack-1.1.0/lib/rack/sendfile.rb deleted file mode 100644 index 4fa82946..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/sendfile.rb +++ /dev/null @@ -1,142 +0,0 @@ -require 'rack/file' - -module Rack - class File #:nodoc: - alias :to_path :path - end - - # = Sendfile - # - # The Sendfile middleware intercepts responses whose body is being - # served from a file and replaces it with a server specific X-Sendfile - # header. The web server is then responsible for writing the file contents - # to the client. This can dramatically reduce the amount of work required - # by the Ruby backend and takes advantage of the web servers optimized file - # delivery code. - # - # In order to take advantage of this middleware, the response body must - # respond to +to_path+ and the request must include an X-Sendfile-Type - # header. Rack::File and other components implement +to_path+ so there's - # rarely anything you need to do in your application. The X-Sendfile-Type - # header is typically set in your web servers configuration. The following - # sections attempt to document - # - # === Nginx - # - # Nginx supports the X-Accel-Redirect header. This is similar to X-Sendfile - # but requires parts of the filesystem to be mapped into a private URL - # hierarachy. - # - # The following example shows the Nginx configuration required to create - # a private "/files/" area, enable X-Accel-Redirect, and pass the special - # X-Sendfile-Type and X-Accel-Mapping headers to the backend: - # - # location /files/ { - # internal; - # alias /var/www/; - # } - # - # location / { - # proxy_redirect false; - # - # proxy_set_header Host $host; - # proxy_set_header X-Real-IP $remote_addr; - # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # - # proxy_set_header X-Sendfile-Type X-Accel-Redirect - # proxy_set_header X-Accel-Mapping /files/=/var/www/; - # - # proxy_pass http://127.0.0.1:8080/; - # } - # - # Note that the X-Sendfile-Type header must be set exactly as shown above. The - # X-Accel-Mapping header should specify the name of the private URL pattern, - # followed by an equals sign (=), followed by the location on the file system - # that it maps to. The middleware performs a simple substitution on the - # resulting path. - # - # See Also: http://wiki.codemongers.com/NginxXSendfile - # - # === lighttpd - # - # Lighttpd has supported some variation of the X-Sendfile header for some - # time, although only recent version support X-Sendfile in a reverse proxy - # configuration. - # - # $HTTP["host"] == "example.com" { - # proxy-core.protocol = "http" - # proxy-core.balancer = "round-robin" - # proxy-core.backends = ( - # "127.0.0.1:8000", - # "127.0.0.1:8001", - # ... - # ) - # - # proxy-core.allow-x-sendfile = "enable" - # proxy-core.rewrite-request = ( - # "X-Sendfile-Type" => (".*" => "X-Sendfile") - # ) - # } - # - # See Also: http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModProxyCore - # - # === Apache - # - # X-Sendfile is supported under Apache 2.x using a separate module: - # - # http://tn123.ath.cx/mod_xsendfile/ - # - # Once the module is compiled and installed, you can enable it using - # XSendFile config directive: - # - # RequestHeader Set X-Sendfile-Type X-Sendfile - # ProxyPassReverse / http://localhost:8001/ - # XSendFile on - - class Sendfile - F = ::File - - def initialize(app, variation=nil) - @app = app - @variation = variation - end - - def call(env) - status, headers, body = @app.call(env) - if body.respond_to?(:to_path) - case type = variation(env) - when 'X-Accel-Redirect' - path = F.expand_path(body.to_path) - if url = map_accel_path(env, path) - headers[type] = url - body = [] - else - env['rack.errors'] << "X-Accel-Mapping header missing" - end - when 'X-Sendfile', 'X-Lighttpd-Send-File' - path = F.expand_path(body.to_path) - headers[type] = path - body = [] - when '', nil - else - env['rack.errors'] << "Unknown x-sendfile variation: '#{variation}'.\n" - end - end - [status, headers, body] - end - - private - def variation(env) - @variation || - env['sendfile.type'] || - env['HTTP_X_SENDFILE_TYPE'] - end - - def map_accel_path(env, file) - if mapping = env['HTTP_X_ACCEL_MAPPING'] - internal, external = mapping.split('=', 2).map{ |p| p.strip } - file.sub(/^#{internal}/i, external) - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/server.rb b/vendor/gems/rack-1.1.0/lib/rack/server.rb deleted file mode 100644 index 2bb20aae..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/server.rb +++ /dev/null @@ -1,212 +0,0 @@ -require 'optparse' - -module Rack - class Server - class Options - def parse!(args) - options = {} - opt_parser = OptionParser.new("", 24, ' ') do |opts| - opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]" - - opts.separator "" - opts.separator "Ruby options:" - - lineno = 1 - opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line| - eval line, TOPLEVEL_BINDING, "-e", lineno - lineno += 1 - } - - opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") { - options[:debug] = true - } - opts.on("-w", "--warn", "turn warnings on for your script") { - options[:warn] = true - } - - opts.on("-I", "--include PATH", - "specify $LOAD_PATH (may be used more than once)") { |path| - options[:include] = path.split(":") - } - - opts.on("-r", "--require LIBRARY", - "require the library, before executing your script") { |library| - options[:require] = library - } - - opts.separator "" - opts.separator "Rack options:" - opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s| - options[:server] = s - } - - opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host| - options[:Host] = host - } - - opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port| - options[:Port] = port - } - - opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e| - options[:environment] = e - } - - opts.on("-D", "--daemonize", "run daemonized in the background") { |d| - options[:daemonize] = d ? true : false - } - - opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f| - options[:pid] = f - } - - opts.separator "" - opts.separator "Common options:" - - opts.on_tail("-h", "--help", "Show this message") do - puts opts - exit - end - - opts.on_tail("--version", "Show version") do - puts "Rack #{Rack.version}" - exit - end - end - opt_parser.parse! args - options[:config] = args.last if args.last - options - end - end - - def self.start - new.start - end - - attr_accessor :options - - def initialize(options = nil) - @options = options - end - - def options - @options ||= parse_options(ARGV) - end - - def default_options - { - :environment => "development", - :pid => nil, - :Port => 9292, - :Host => "0.0.0.0", - :AccessLog => [], - :config => "config.ru" - } - end - - def app - @app ||= begin - if !::File.exist? options[:config] - abort "configuration #{options[:config]} not found" - end - - app, options = Rack::Builder.parse_file(self.options[:config], opt_parser) - self.options.merge! options - app - end - end - - def self.middleware - @middleware ||= begin - m = Hash.new {|h,k| h[k] = []} - m["deployment"].concat [lambda {|server| server.server =~ /CGI/ ? nil : [Rack::CommonLogger, $stderr] }] - m["development"].concat m["deployment"] + [[Rack::ShowExceptions], [Rack::Lint]] - m - end - end - - def middleware - self.class.middleware - end - - def start - if options[:debug] - $DEBUG = true - require 'pp' - p options[:server] - pp wrapped_app - pp app - end - - if options[:warn] - $-w = true - end - - if includes = options[:include] - $LOAD_PATH.unshift *includes - end - - if library = options[:require] - require library - end - - daemonize_app if options[:daemonize] - write_pid if options[:pid] - server.run wrapped_app, options - end - - def server - @_server ||= Rack::Handler.get(options[:server]) || Rack::Handler.default - end - - private - def parse_options(args) - options = default_options - - # Don't evaluate CGI ISINDEX parameters. - # http://hoohoo.ncsa.uiuc.edu/cgi/cl.html - args.clear if ENV.include?("REQUEST_METHOD") - - options.merge! opt_parser.parse! args - options - end - - def opt_parser - Options.new - end - - def build_app(app) - middleware[options[:environment]].reverse_each do |middleware| - middleware = middleware.call(self) if middleware.respond_to?(:call) - next unless middleware - klass = middleware.shift - app = klass.new(app, *middleware) - end - app - end - - def wrapped_app - @wrapped_app ||= build_app app - end - - def daemonize_app - if RUBY_VERSION < "1.9" - exit if fork - Process.setsid - exit if fork - Dir.chdir "/" - ::File.umask 0000 - STDIN.reopen "/dev/null" - STDOUT.reopen "/dev/null", "a" - STDERR.reopen "/dev/null", "a" - else - Process.daemon - end - end - - def write_pid - ::File.open(options[:pid], 'w'){ |f| f.write("#{Process.pid}") } - at_exit { ::File.delete(options[:pid]) if ::File.exist?(options[:pid]) } - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/session/abstract/id.rb b/vendor/gems/rack-1.1.0/lib/rack/session/abstract/id.rb deleted file mode 100644 index 98746705..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/session/abstract/id.rb +++ /dev/null @@ -1,140 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net -# bugrep: Andreas Zehnder - -require 'time' -require 'rack/request' -require 'rack/response' - -module Rack - - module Session - - module Abstract - - # ID sets up a basic framework for implementing an id based sessioning - # service. Cookies sent to the client for maintaining sessions will only - # contain an id reference. Only #get_session and #set_session are - # required to be overwritten. - # - # All parameters are optional. - # * :key determines the name of the cookie, by default it is - # 'rack.session' - # * :path, :domain, :expire_after, :secure, and :httponly set the related - # cookie options as by Rack::Response#add_cookie - # * :defer will not set a cookie in the response. - # * :renew (implementation dependent) will prompt the generation of a new - # session id, and migration of data to be referenced at the new id. If - # :defer is set, it will be overridden and the cookie will be set. - # * :sidbits sets the number of bits in length that a generated session - # id will be. - # - # These options can be set on a per request basis, at the location of - # env['rack.session.options']. Additionally the id of the session can be - # found within the options hash at the key :id. It is highly not - # recommended to change its value. - # - # Is Rack::Utils::Context compatible. - - class ID - DEFAULT_OPTIONS = { - :path => '/', - :domain => nil, - :expire_after => nil, - :secure => false, - :httponly => true, - :defer => false, - :renew => false, - :sidbits => 128 - } - - attr_reader :key, :default_options - def initialize(app, options={}) - @app = app - @key = options[:key] || "rack.session" - @default_options = self.class::DEFAULT_OPTIONS.merge(options) - end - - def call(env) - context(env) - end - - def context(env, app=@app) - load_session(env) - status, headers, body = app.call(env) - commit_session(env, status, headers, body) - end - - private - - # Generate a new session id using Ruby #rand. The size of the - # session id is controlled by the :sidbits option. - # Monkey patch this to use custom methods for session id generation. - - def generate_sid - "%0#{@default_options[:sidbits] / 4}x" % - rand(2**@default_options[:sidbits] - 1) - end - - # Extracts the session id from provided cookies and passes it and the - # environment to #get_session. It then sets the resulting session into - # 'rack.session', and places options and session metadata into - # 'rack.session.options'. - - def load_session(env) - request = Rack::Request.new(env) - session_id = request.cookies[@key] - - begin - session_id, session = get_session(env, session_id) - env['rack.session'] = session - rescue - env['rack.session'] = Hash.new - end - - env['rack.session.options'] = @default_options. - merge(:id => session_id) - end - - # Acquires the session from the environment and the session id from - # the session options and passes them to #set_session. If successful - # and the :defer option is not true, a cookie will be added to the - # response with the session's id. - - def commit_session(env, status, headers, body) - session = env['rack.session'] - options = env['rack.session.options'] - session_id = options[:id] - - if not session_id = set_session(env, session_id, session, options) - env["rack.errors"].puts("Warning! #{self.class.name} failed to save session. Content dropped.") - elsif options[:defer] and not options[:renew] - env["rack.errors"].puts("Defering cookie for #{session_id}") if $VERBOSE - else - cookie = Hash.new - cookie[:value] = session_id - cookie[:expires] = Time.now + options[:expire_after] unless options[:expire_after].nil? - Utils.set_cookie_header!(headers, @key, cookie.merge(options)) - end - - [status, headers, body] - end - - # All thread safety and session retrival proceedures should occur here. - # Should return [session_id, session]. - # If nil is provided as the session id, generation of a new valid id - # should occur within. - - def get_session(env, sid) - raise '#get_session not implemented.' - end - - # All thread safety and session storage proceedures should occur here. - # Should return true or false dependant on whether or not the session - # was saved or not. - def set_session(env, sid, session, options) - raise '#set_session not implemented.' - end - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/session/cookie.rb b/vendor/gems/rack-1.1.0/lib/rack/session/cookie.rb deleted file mode 100644 index 240e6c8d..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/session/cookie.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'openssl' -require 'rack/request' -require 'rack/response' - -module Rack - - module Session - - # Rack::Session::Cookie provides simple cookie based session management. - # The session is a Ruby Hash stored as base64 encoded marshalled data - # set to :key (default: rack.session). - # When the secret key is set, cookie data is checked for data integrity. - # - # Example: - # - # use Rack::Session::Cookie, :key => 'rack.session', - # :domain => 'foo.com', - # :path => '/', - # :expire_after => 2592000, - # :secret => 'change_me' - # - # All parameters are optional. - - class Cookie - - def initialize(app, options={}) - @app = app - @key = options[:key] || "rack.session" - @secret = options[:secret] - @default_options = {:domain => nil, - :path => "/", - :expire_after => nil}.merge(options) - end - - def call(env) - load_session(env) - status, headers, body = @app.call(env) - commit_session(env, status, headers, body) - end - - private - - def load_session(env) - request = Rack::Request.new(env) - session_data = request.cookies[@key] - - if @secret && session_data - session_data, digest = session_data.split("--") - session_data = nil unless digest == generate_hmac(session_data) - end - - begin - session_data = session_data.unpack("m*").first - session_data = Marshal.load(session_data) - env["rack.session"] = session_data - rescue - env["rack.session"] = Hash.new - end - - env["rack.session.options"] = @default_options.dup - end - - def commit_session(env, status, headers, body) - session_data = Marshal.dump(env["rack.session"]) - session_data = [session_data].pack("m*") - - if @secret - session_data = "#{session_data}--#{generate_hmac(session_data)}" - end - - if session_data.size > (4096 - @key.size) - env["rack.errors"].puts("Warning! Rack::Session::Cookie data size exceeds 4K. Content dropped.") - else - options = env["rack.session.options"] - cookie = Hash.new - cookie[:value] = session_data - cookie[:expires] = Time.now + options[:expire_after] unless options[:expire_after].nil? - Utils.set_cookie_header!(headers, @key, cookie.merge(options)) - end - - [status, headers, body] - end - - def generate_hmac(data) - OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, @secret, data) - end - - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/session/memcache.rb b/vendor/gems/rack-1.1.0/lib/rack/session/memcache.rb deleted file mode 100644 index 44629da3..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/session/memcache.rb +++ /dev/null @@ -1,119 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net - -require 'rack/session/abstract/id' -require 'memcache' - -module Rack - module Session - # Rack::Session::Memcache provides simple cookie based session management. - # Session data is stored in memcached. The corresponding session key is - # maintained in the cookie. - # You may treat Session::Memcache as you would Session::Pool with the - # following caveats. - # - # * Setting :expire_after to 0 would note to the Memcache server to hang - # onto the session data until it would drop it according to it's own - # specifications. However, the cookie sent to the client would expire - # immediately. - # - # Note that memcache does drop data before it may be listed to expire. For - # a full description of behaviour, please see memcache's documentation. - - class Memcache < Abstract::ID - attr_reader :mutex, :pool - DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge \ - :namespace => 'rack:session', - :memcache_server => 'localhost:11211' - - def initialize(app, options={}) - super - - @mutex = Mutex.new - mserv = @default_options[:memcache_server] - mopts = @default_options. - reject{|k,v| MemCache::DEFAULT_OPTIONS.include? k } - @pool = MemCache.new mserv, mopts - unless @pool.active? and @pool.servers.any?{|c| c.alive? } - raise 'No memcache servers' - end - end - - def generate_sid - loop do - sid = super - break sid unless @pool.get(sid, true) - end - end - - def get_session(env, session_id) - @mutex.lock if env['rack.multithread'] - unless session_id and session = @pool.get(session_id) - session_id, session = generate_sid, {} - unless /^STORED/ =~ @pool.add(session_id, session) - raise "Session collision on '#{session_id.inspect}'" - end - end - session.instance_variable_set '@old', @pool.get(session_id, true) - return [session_id, session] - rescue MemCache::MemCacheError, Errno::ECONNREFUSED - # MemCache server cannot be contacted - warn "#{self} is unable to find memcached server." - warn $!.inspect - return [ nil, {} ] - ensure - @mutex.unlock if @mutex.locked? - end - - def set_session(env, session_id, new_session, options) - expiry = options[:expire_after] - expiry = expiry.nil? ? 0 : expiry + 1 - - @mutex.lock if env['rack.multithread'] - if options[:renew] or options[:drop] - @pool.delete session_id - return false if options[:drop] - session_id = generate_sid - @pool.add session_id, {} # so we don't worry about cache miss on #set - end - - session = @pool.get(session_id) || {} - old_session = new_session.instance_variable_get '@old' - old_session = old_session ? Marshal.load(old_session) : {} - - unless Hash === old_session and Hash === new_session - env['rack.errors']. - puts 'Bad old_session or new_session sessions provided.' - else # merge sessions - # alterations are either update or delete, making as few changes as - # possible to prevent possible issues. - - # removed keys - delete = old_session.keys - new_session.keys - if $VERBOSE and not delete.empty? - env['rack.errors']. - puts "//@#{session_id}: delete #{delete*','}" - end - delete.each{|k| session.delete k } - - # added or altered keys - update = new_session.keys. - select{|k| new_session[k] != old_session[k] } - if $VERBOSE and not update.empty? - env['rack.errors'].puts "//@#{session_id}: update #{update*','}" - end - update.each{|k| session[k] = new_session[k] } - end - - @pool.set session_id, session, expiry - return session_id - rescue MemCache::MemCacheError, Errno::ECONNREFUSED - # MemCache server cannot be contacted - warn "#{self} is unable to find memcached server." - warn $!.inspect - return false - ensure - @mutex.unlock if @mutex.locked? - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/session/pool.rb b/vendor/gems/rack-1.1.0/lib/rack/session/pool.rb deleted file mode 100644 index b3f8bd72..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/session/pool.rb +++ /dev/null @@ -1,100 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net -# THANKS: -# apeiros, for session id generation, expiry setup, and threadiness -# sergio, threadiness and bugreps - -require 'rack/session/abstract/id' -require 'thread' - -module Rack - module Session - # Rack::Session::Pool provides simple cookie based session management. - # Session data is stored in a hash held by @pool. - # In the context of a multithreaded environment, sessions being - # committed to the pool is done in a merging manner. - # - # The :drop option is available in rack.session.options if you wish to - # explicitly remove the session from the session cache. - # - # Example: - # myapp = MyRackApp.new - # sessioned = Rack::Session::Pool.new(myapp, - # :domain => 'foo.com', - # :expire_after => 2592000 - # ) - # Rack::Handler::WEBrick.run sessioned - - class Pool < Abstract::ID - attr_reader :mutex, :pool - DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge :drop => false - - def initialize(app, options={}) - super - @pool = Hash.new - @mutex = Mutex.new - end - - def generate_sid - loop do - sid = super - break sid unless @pool.key? sid - end - end - - def get_session(env, sid) - session = @pool[sid] if sid - @mutex.lock if env['rack.multithread'] - unless sid and session - env['rack.errors'].puts("Session '#{sid.inspect}' not found, initializing...") if $VERBOSE and not sid.nil? - session = {} - sid = generate_sid - @pool.store sid, session - end - session.instance_variable_set('@old', {}.merge(session)) - return [sid, session] - ensure - @mutex.unlock if env['rack.multithread'] - end - - def set_session(env, session_id, new_session, options) - @mutex.lock if env['rack.multithread'] - session = @pool[session_id] - if options[:renew] or options[:drop] - @pool.delete session_id - return false if options[:drop] - session_id = generate_sid - @pool.store session_id, 0 - end - old_session = new_session.instance_variable_get('@old') || {} - session = merge_sessions session_id, old_session, new_session, session - @pool.store session_id, session - return session_id - rescue - warn "#{new_session.inspect} has been lost." - warn $!.inspect - ensure - @mutex.unlock if env['rack.multithread'] - end - - private - - def merge_sessions sid, old, new, cur=nil - cur ||= {} - unless Hash === old and Hash === new - warn 'Bad old or new sessions provided.' - return cur - end - - delete = old.keys - new.keys - warn "//@#{sid}: dropping #{delete*','}" if $DEBUG and not delete.empty? - delete.each{|k| cur.delete k } - - update = new.keys.select{|k| new[k] != old[k] } - warn "//@#{sid}: updating #{update*','}" if $DEBUG and not update.empty? - update.each{|k| cur[k] = new[k] } - - cur - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/showexceptions.rb b/vendor/gems/rack-1.1.0/lib/rack/showexceptions.rb deleted file mode 100644 index 697bc41f..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/showexceptions.rb +++ /dev/null @@ -1,349 +0,0 @@ -require 'ostruct' -require 'erb' -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::ShowExceptions catches all exceptions raised from the app it - # wraps. It shows a useful backtrace with the sourcefile and - # clickable context, the whole Rack environment and the request - # data. - # - # Be careful when you use this on public-facing sites as it could - # reveal information helpful to attackers. - - class ShowExceptions - CONTEXT = 7 - - def initialize(app) - @app = app - @template = ERB.new(TEMPLATE) - end - - def call(env) - @app.call(env) - rescue StandardError, LoadError, SyntaxError => e - backtrace = pretty(env, e) - [500, - {"Content-Type" => "text/html", - "Content-Length" => backtrace.join.size.to_s}, - backtrace] - end - - def pretty(env, exception) - req = Rack::Request.new(env) - path = (req.script_name + req.path_info).squeeze("/") - - frames = exception.backtrace.map { |line| - frame = OpenStruct.new - if line =~ /(.*?):(\d+)(:in `(.*)')?/ - frame.filename = $1 - frame.lineno = $2.to_i - frame.function = $4 - - begin - lineno = frame.lineno-1 - lines = ::File.readlines(frame.filename) - frame.pre_context_lineno = [lineno-CONTEXT, 0].max - frame.pre_context = lines[frame.pre_context_lineno...lineno] - frame.context_line = lines[lineno].chomp - frame.post_context_lineno = [lineno+CONTEXT, lines.size].min - frame.post_context = lines[lineno+1..frame.post_context_lineno] - rescue - end - - frame - else - nil - end - }.compact - - env["rack.errors"].puts "#{exception.class}: #{exception.message}" - env["rack.errors"].puts exception.backtrace.map { |l| "\t" + l } - env["rack.errors"].flush - - [@template.result(binding)] - end - - def h(obj) # :nodoc: - case obj - when String - Utils.escape_html(obj) - else - Utils.escape_html(obj.inspect) - end - end - - # :stopdoc: - -# adapted from Django -# Copyright (c) 2005, the Lawrence Journal-World -# Used under the modified BSD license: -# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 -TEMPLATE = <<'HTML' - - - - - - <%=h exception.class %> at <%=h path %> - - - - - -
    -

    <%=h exception.class %> at <%=h path %>

    -

    <%=h exception.message %>

    - - - - - - -
    Ruby<%=h frames.first.filename %>: in <%=h frames.first.function %>, line <%=h frames.first.lineno %>
    Web<%=h req.request_method %> <%=h(req.host + path)%>
    - -

    Jump to:

    - -
    - -
    -

    Traceback (innermost first)

    -
      -<% frames.each { |frame| %> -
    • - <%=h frame.filename %>: in <%=h frame.function %> - - <% if frame.context_line %> -
      - <% if frame.pre_context %> -
        - <% frame.pre_context.each { |line| %> -
      1. <%=h line %>
      2. - <% } %> -
      - <% end %> - -
        -
      1. <%=h frame.context_line %>...
      - - <% if frame.post_context %> -
        - <% frame.post_context.each { |line| %> -
      1. <%=h line %>
      2. - <% } %> -
      - <% end %> -
      - <% end %> -
    • -<% } %> -
    -
    - -
    -

    Request information

    - -

    GET

    - <% unless req.GET.empty? %> - - - - - - - - - <% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val.inspect %>
    - <% else %> -

    No GET data.

    - <% end %> - -

    POST

    - <% unless req.POST.empty? %> - - - - - - - - - <% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val.inspect %>
    - <% else %> -

    No POST data.

    - <% end %> - - - - <% unless req.cookies.empty? %> - - - - - - - - - <% req.cookies.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val.inspect %>
    - <% else %> -

    No cookie data.

    - <% end %> - -

    Rack ENV

    - - - - - - - - - <% env.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val %>
    - -
    - -
    -

    - You're seeing this error because you use Rack::ShowExceptions. -

    -
    - - - -HTML - - # :startdoc: - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/showstatus.rb b/vendor/gems/rack-1.1.0/lib/rack/showstatus.rb deleted file mode 100644 index 28258c7c..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/showstatus.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'erb' -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::ShowStatus catches all empty responses the app it wraps and - # replaces them with a site explaining the error. - # - # Additional details can be put into rack.showstatus.detail - # and will be shown as HTML. If such details exist, the error page - # is always rendered, even if the reply was not empty. - - class ShowStatus - def initialize(app) - @app = app - @template = ERB.new(TEMPLATE) - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - empty = headers['Content-Length'].to_i <= 0 - - # client or server error, or explicit message - if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] - req = Rack::Request.new(env) - message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s - detail = env["rack.showstatus.detail"] || message - body = @template.result(binding) - size = Rack::Utils.bytesize(body) - [status, headers.merge("Content-Type" => "text/html", "Content-Length" => size.to_s), [body]] - else - [status, headers, body] - end - end - - def h(obj) # :nodoc: - case obj - when String - Utils.escape_html(obj) - else - Utils.escape_html(obj.inspect) - end - end - - # :stopdoc: - -# adapted from Django -# Copyright (c) 2005, the Lawrence Journal-World -# Used under the modified BSD license: -# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 -TEMPLATE = <<'HTML' - - - - - <%=h message %> at <%=h req.script_name + req.path_info %> - - - - -
    -

    <%=h message %> (<%= status.to_i %>)

    - - - - - - - - - -
    Request Method:<%=h req.request_method %>
    Request URL:<%=h req.url %>
    -
    -
    -

    <%= detail %>

    -
    - -
    -

    - You're seeing this error because you use Rack::ShowStatus. -

    -
    - - -HTML - - # :startdoc: - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/static.rb b/vendor/gems/rack-1.1.0/lib/rack/static.rb deleted file mode 100644 index 168e8f83..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/static.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Rack - - # The Rack::Static middleware intercepts requests for static files - # (javascript files, images, stylesheets, etc) based on the url prefixes - # passed in the options, and serves them using a Rack::File object. This - # allows a Rack stack to serve both static and dynamic content. - # - # Examples: - # use Rack::Static, :urls => ["/media"] - # will serve all requests beginning with /media from the "media" folder - # located in the current directory (ie media/*). - # - # use Rack::Static, :urls => ["/css", "/images"], :root => "public" - # will serve all requests beginning with /css or /images from the folder - # "public" in the current directory (ie public/css/* and public/images/*) - - class Static - - def initialize(app, options={}) - @app = app - @urls = options[:urls] || ["/favicon.ico"] - root = options[:root] || Dir.pwd - @file_server = Rack::File.new(root) - end - - def call(env) - path = env["PATH_INFO"] - can_serve = @urls.any? { |url| path.index(url) == 0 } - - if can_serve - @file_server.call(env) - else - @app.call(env) - end - end - - end -end diff --git a/vendor/gems/rack-1.1.0/lib/rack/urlmap.rb b/vendor/gems/rack-1.1.0/lib/rack/urlmap.rb deleted file mode 100644 index b699d35b..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/urlmap.rb +++ /dev/null @@ -1,56 +0,0 @@ -module Rack - # Rack::URLMap takes a hash mapping urls or paths to apps, and - # dispatches accordingly. Support for HTTP/1.1 host names exists if - # the URLs start with http:// or https://. - # - # URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part - # relevant for dispatch is in the SCRIPT_NAME, and the rest in the - # PATH_INFO. This should be taken care of when you need to - # reconstruct the URL in order to create links. - # - # URLMap dispatches in such a way that the longest paths are tried - # first, since they are most specific. - - class URLMap - def initialize(map = {}) - remap(map) - end - - def remap(map) - @mapping = map.map { |location, app| - if location =~ %r{\Ahttps?://(.*?)(/.*)} - host, location = $1, $2 - else - host = nil - end - - unless location[0] == ?/ - raise ArgumentError, "paths need to start with /" - end - location = location.chomp('/') - match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", nil, 'n') - - [host, location, match, app] - }.sort_by { |(h, l, m, a)| [h ? -h.size : (-1.0 / 0.0), -l.size] } # Longest path first - end - - def call(env) - path = env["PATH_INFO"].to_s - script_name = env['SCRIPT_NAME'] - hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT') - @mapping.each { |host, location, match, app| - next unless (hHost == host || sName == host \ - || (host.nil? && (hHost == sName || hHost == sName+':'+sPort))) - next unless path =~ match && rest = $1 - next unless rest.empty? || rest[0] == ?/ - - return app.call( - env.merge( - 'SCRIPT_NAME' => (script_name + location), - 'PATH_INFO' => rest)) - } - [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path}"]] - end - end -end - diff --git a/vendor/gems/rack-1.1.0/lib/rack/utils.rb b/vendor/gems/rack-1.1.0/lib/rack/utils.rb deleted file mode 100644 index 68fd6ace..00000000 --- a/vendor/gems/rack-1.1.0/lib/rack/utils.rb +++ /dev/null @@ -1,620 +0,0 @@ -# -*- encoding: binary -*- - -require 'set' -require 'tempfile' - -module Rack - # Rack::Utils contains a grab-bag of useful methods for writing web - # applications adopted from all kinds of Ruby libraries. - - module Utils - # Performs URI escaping so that you can construct proper - # query strings faster. Use this rather than the cgi.rb - # version since it's faster. (Stolen from Camping). - def escape(s) - s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) { - '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase - }.tr(' ', '+') - end - module_function :escape - - # Unescapes a URI escaped string. (Stolen from Camping). - def unescape(s) - s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){ - [$1.delete('%')].pack('H*') - } - end - module_function :unescape - - DEFAULT_SEP = /[&;] */n - - # Stolen from Mongrel, with some small modifications: - # Parses a query string by breaking it up at the '&' - # and ';' characters. You can also use this to parse - # cookies by changing the characters used in the second - # parameter (which defaults to '&;'). - def parse_query(qs, d = nil) - params = {} - - (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p| - k, v = p.split('=', 2).map { |x| unescape(x) } - if v =~ /^("|')(.*)\1$/ - v = $2.gsub('\\'+$1, $1) - end - if cur = params[k] - if cur.class == Array - params[k] << v - else - params[k] = [cur, v] - end - else - params[k] = v - end - end - - return params - end - module_function :parse_query - - def parse_nested_query(qs, d = nil) - params = {} - - (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p| - k, v = unescape(p).split('=', 2) - normalize_params(params, k, v) - end - - return params - end - module_function :parse_nested_query - - def normalize_params(params, name, v = nil) - if v and v =~ /^("|')(.*)\1$/ - v = $2.gsub('\\'+$1, $1) - end - name =~ %r(\A[\[\]]*([^\[\]]+)\]*) - k = $1 || '' - after = $' || '' - - return if k.empty? - - if after == "" - params[k] = v - elsif after == "[]" - params[k] ||= [] - raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array) - params[k] << v - elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$) - child_key = $1 - params[k] ||= [] - raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array) - if params[k].last.is_a?(Hash) && !params[k].last.key?(child_key) - normalize_params(params[k].last, child_key, v) - else - params[k] << normalize_params({}, child_key, v) - end - else - params[k] ||= {} - raise TypeError, "expected Hash (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Hash) - params[k] = normalize_params(params[k], after, v) - end - - return params - end - module_function :normalize_params - - def build_query(params) - params.map { |k, v| - if v.class == Array - build_query(v.map { |x| [k, x] }) - else - "#{escape(k)}=#{escape(v)}" - end - }.join("&") - end - module_function :build_query - - def build_nested_query(value, prefix = nil) - case value - when Array - value.map { |v| - build_nested_query(v, "#{prefix}[]") - }.join("&") - when Hash - value.map { |k, v| - build_nested_query(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k)) - }.join("&") - when String - raise ArgumentError, "value must be a Hash" if prefix.nil? - "#{prefix}=#{escape(value)}" - else - prefix - end - end - module_function :build_nested_query - - # Escape ampersands, brackets and quotes to their HTML/XML entities. - def escape_html(string) - string.to_s.gsub("&", "&"). - gsub("<", "<"). - gsub(">", ">"). - gsub("'", "'"). - gsub('"', """) - end - module_function :escape_html - - def select_best_encoding(available_encodings, accept_encoding) - # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - - expanded_accept_encoding = - accept_encoding.map { |m, q| - if m == "*" - (available_encodings - accept_encoding.map { |m2, _| m2 }).map { |m2| [m2, q] } - else - [[m, q]] - end - }.inject([]) { |mem, list| - mem + list - } - - encoding_candidates = expanded_accept_encoding.sort_by { |_, q| -q }.map { |m, _| m } - - unless encoding_candidates.include?("identity") - encoding_candidates.push("identity") - end - - expanded_accept_encoding.find_all { |m, q| - q == 0.0 - }.each { |m, _| - encoding_candidates.delete(m) - } - - return (encoding_candidates & available_encodings)[0] - end - module_function :select_best_encoding - - def set_cookie_header!(header, key, value) - case value - when Hash - domain = "; domain=" + value[:domain] if value[:domain] - path = "; path=" + value[:path] if value[:path] - # According to RFC 2109, we need dashes here. - # N.B.: cgi.rb uses spaces... - expires = "; expires=" + value[:expires].clone.gmtime. - strftime("%a, %d-%b-%Y %H:%M:%S GMT") if value[:expires] - secure = "; secure" if value[:secure] - httponly = "; HttpOnly" if value[:httponly] - value = value[:value] - end - value = [value] unless Array === value - cookie = escape(key) + "=" + - value.map { |v| escape v }.join("&") + - "#{domain}#{path}#{expires}#{secure}#{httponly}" - - case header["Set-Cookie"] - when Array - header["Set-Cookie"] << cookie - when String - header["Set-Cookie"] = [header["Set-Cookie"], cookie] - when nil - header["Set-Cookie"] = cookie - end - - nil - end - module_function :set_cookie_header! - - def delete_cookie_header!(header, key, value = {}) - unless Array === header["Set-Cookie"] - header["Set-Cookie"] = [header["Set-Cookie"]].compact - end - - header["Set-Cookie"].reject! { |cookie| - cookie =~ /\A#{escape(key)}=/ - } - - set_cookie_header!(header, key, - {:value => '', :path => nil, :domain => nil, - :expires => Time.at(0) }.merge(value)) - - nil - end - module_function :delete_cookie_header! - - # Return the bytesize of String; uses String#length under Ruby 1.8 and - # String#bytesize under 1.9. - if ''.respond_to?(:bytesize) - def bytesize(string) - string.bytesize - end - else - def bytesize(string) - string.size - end - end - module_function :bytesize - - # Context allows the use of a compatible middleware at different points - # in a request handling stack. A compatible middleware must define - # #context which should take the arguments env and app. The first of which - # would be the request environment. The second of which would be the rack - # application that the request would be forwarded to. - class Context - attr_reader :for, :app - - def initialize(app_f, app_r) - raise 'running context does not respond to #context' unless app_f.respond_to? :context - @for, @app = app_f, app_r - end - - def call(env) - @for.context(env, @app) - end - - def recontext(app) - self.class.new(@for, app) - end - - def context(env, app=@app) - recontext(app).call(env) - end - end - - # A case-insensitive Hash that preserves the original case of a - # header when set. - class HeaderHash < Hash - def self.new(hash={}) - HeaderHash === hash ? hash : super(hash) - end - - def initialize(hash={}) - super() - @names = {} - hash.each { |k, v| self[k] = v } - end - - def each - super do |k, v| - yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v) - end - end - - def to_hash - inject({}) do |hash, (k,v)| - if v.respond_to? :to_ary - hash[k] = v.to_ary.join("\n") - else - hash[k] = v - end - hash - end - end - - def [](k) - super(@names[k] ||= @names[k.downcase]) - end - - def []=(k, v) - delete k - @names[k] = @names[k.downcase] = k - super k, v - end - - def delete(k) - canonical = k.downcase - result = super @names.delete(canonical) - @names.delete_if { |name,| name.downcase == canonical } - result - end - - def include?(k) - @names.include?(k) || @names.include?(k.downcase) - end - - alias_method :has_key?, :include? - alias_method :member?, :include? - alias_method :key?, :include? - - def merge!(other) - other.each { |k, v| self[k] = v } - self - end - - def merge(other) - hash = dup - hash.merge! other - end - - def replace(other) - clear - other.each { |k, v| self[k] = v } - self - end - end - - # Every standard HTTP code mapped to the appropriate message. - # Generated with: - # curl -s http://www.iana.org/assignments/http-status-codes | \ - # ruby -ane 'm = /^(\d{3}) +(\S[^\[(]+)/.match($_) and - # puts " #{m[1]} => \x27#{m[2].strip}x27,"' - HTTP_STATUS_CODES = { - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', - 226 => 'IM Used', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 306 => 'Reserved', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 426 => 'Upgrade Required', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates', - 507 => 'Insufficient Storage', - 510 => 'Not Extended', - } - - # Responses with HTTP status codes that should not have an entity body - STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 304) - - SYMBOL_TO_STATUS_CODE = HTTP_STATUS_CODES.inject({}) { |hash, (code, message)| - hash[message.downcase.gsub(/\s|-/, '_').to_sym] = code - hash - } - - def status_code(status) - if status.is_a?(Symbol) - SYMBOL_TO_STATUS_CODE[status] || 500 - else - status.to_i - end - end - module_function :status_code - - # A multipart form data parser, adapted from IOWA. - # - # Usually, Rack::Request#POST takes care of calling this. - - module Multipart - class UploadedFile - # The filename, *not* including the path, of the "uploaded" file - attr_reader :original_filename - - # The content type of the "uploaded" file - attr_accessor :content_type - - def initialize(path, content_type = "text/plain", binary = false) - raise "#{path} file does not exist" unless ::File.exist?(path) - @content_type = content_type - @original_filename = ::File.basename(path) - @tempfile = Tempfile.new(@original_filename) - @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding) - @tempfile.binmode if binary - FileUtils.copy_file(path, @tempfile.path) - end - - def path - @tempfile.path - end - alias_method :local_path, :path - - def method_missing(method_name, *args, &block) #:nodoc: - @tempfile.__send__(method_name, *args, &block) - end - end - - EOL = "\r\n" - MULTIPART_BOUNDARY = "AaB03x" - - def self.parse_multipart(env) - unless env['CONTENT_TYPE'] =~ - %r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n - nil - else - boundary = "--#{$1}" - - params = {} - buf = "" - content_length = env['CONTENT_LENGTH'].to_i - input = env['rack.input'] - input.rewind - - boundary_size = Utils.bytesize(boundary) + EOL.size - bufsize = 16384 - - content_length -= boundary_size - - read_buffer = '' - - status = input.read(boundary_size, read_buffer) - raise EOFError, "bad content body" unless status == boundary + EOL - - rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/n - - loop { - head = nil - body = '' - filename = content_type = name = nil - - until head && buf =~ rx - if !head && i = buf.index(EOL+EOL) - head = buf.slice!(0, i+2) # First \r\n - buf.slice!(0, 2) # Second \r\n - - filename = head[/Content-Disposition:.* filename=(?:"((?:\\.|[^\"])*)"|([^;\s]*))/ni, 1] - content_type = head[/Content-Type: (.*)#{EOL}/ni, 1] - name = head[/Content-Disposition:.*\s+name="?([^\";]*)"?/ni, 1] || head[/Content-ID:\s*([^#{EOL}]*)/ni, 1] - - if content_type || filename - body = Tempfile.new("RackMultipart") - body.binmode if body.respond_to?(:binmode) - end - - next - end - - # Save the read body part. - if head && (boundary_size+4 < buf.size) - body << buf.slice!(0, buf.size - (boundary_size+4)) - end - - c = input.read(bufsize < content_length ? bufsize : content_length, read_buffer) - raise EOFError, "bad content body" if c.nil? || c.empty? - buf << c - content_length -= c.size - end - - # Save the rest. - if i = buf.index(rx) - body << buf.slice!(0, i) - buf.slice!(0, boundary_size+2) - - content_length = -1 if $1 == "--" - end - - if filename == "" - # filename is blank which means no file has been selected - data = nil - elsif filename - body.rewind - - # Take the basename of the upload's original filename. - # This handles the full Windows paths given by Internet Explorer - # (and perhaps other broken user agents) without affecting - # those which give the lone filename. - filename =~ /^(?:.*[:\\\/])?(.*)/m - filename = $1 - - data = {:filename => filename, :type => content_type, - :name => name, :tempfile => body, :head => head} - elsif !filename && content_type - body.rewind - - # Generic multipart cases, not coming from a form - data = {:type => content_type, - :name => name, :tempfile => body, :head => head} - else - data = body - end - - Utils.normalize_params(params, name, data) unless data.nil? - - # break if we're at the end of a buffer, but not if it is the end of a field - break if (buf.empty? && $1 != EOL) || content_length == -1 - } - - input.rewind - - params - end - end - - def self.build_multipart(params, first = true) - if first - unless params.is_a?(Hash) - raise ArgumentError, "value must be a Hash" - end - - multipart = false - query = lambda { |value| - case value - when Array - value.each(&query) - when Hash - value.values.each(&query) - when UploadedFile - multipart = true - end - } - params.values.each(&query) - return nil unless multipart - end - - flattened_params = Hash.new - - params.each do |key, value| - k = first ? key.to_s : "[#{key}]" - - case value - when Array - value.map { |v| - build_multipart(v, false).each { |subkey, subvalue| - flattened_params["#{k}[]#{subkey}"] = subvalue - } - } - when Hash - build_multipart(value, false).each { |subkey, subvalue| - flattened_params[k + subkey] = subvalue - } - else - flattened_params[k] = value - end - end - - if first - flattened_params.map { |name, file| - if file.respond_to?(:original_filename) - ::File.open(file.path, "rb") do |f| - f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding) -<<-EOF ---#{MULTIPART_BOUNDARY}\r -Content-Disposition: form-data; name="#{name}"; filename="#{Utils.escape(file.original_filename)}"\r -Content-Type: #{file.content_type}\r -Content-Length: #{::File.stat(file.path).size}\r -\r -#{f.read}\r -EOF - end - else -<<-EOF ---#{MULTIPART_BOUNDARY}\r -Content-Disposition: form-data; name="#{name}"\r -\r -#{file}\r -EOF - end - }.join + "--#{MULTIPART_BOUNDARY}--\r" - else - flattened_params - end - end - end - end -end diff --git a/vendor/gems/rack-1.1.0/rack.gemspec b/vendor/gems/rack-1.1.0/rack.gemspec deleted file mode 100644 index e28b9bb2..00000000 --- a/vendor/gems/rack-1.1.0/rack.gemspec +++ /dev/null @@ -1,38 +0,0 @@ -Gem::Specification.new do |s| - s.name = "rack" - s.version = "1.1.0" - s.platform = Gem::Platform::RUBY - s.summary = "a modular Ruby webserver interface" - - s.description = <<-EOF -Rack provides minimal, modular and adaptable interface for developing -web applications in Ruby. By wrapping HTTP requests and responses in -the simplest way possible, it unifies and distills the API for web -servers, web frameworks, and software in between (the so-called -middleware) into a single method call. - -Also see http://rack.rubyforge.org. -EOF - - s.files = Dir['{bin/*,contrib/*,example/*,lib/**/*}'] + - %w(COPYING KNOWN-ISSUES rack.gemspec RDOX README SPEC) - s.bindir = 'bin' - s.executables << 'rackup' - s.require_path = 'lib' - s.has_rdoc = true - s.extra_rdoc_files = ['README', 'SPEC', 'KNOWN-ISSUES'] - s.test_files = Dir['test/{test,spec}_*.rb'] - - s.author = 'Christian Neukirchen' - s.email = 'chneukirchen@gmail.com' - s.homepage = 'http://rack.rubyforge.org' - s.rubyforge_project = 'rack' - - s.add_development_dependency 'test-spec' - - s.add_development_dependency 'camping' - s.add_development_dependency 'fcgi' - s.add_development_dependency 'memcache-client' - s.add_development_dependency 'mongrel' - s.add_development_dependency 'thin' -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_auth_basic.rb b/vendor/gems/rack-1.1.0/test/spec_rack_auth_basic.rb deleted file mode 100644 index 0176efc8..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_auth_basic.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'test/spec' - -require 'rack/auth/basic' -require 'rack/mock' - -context 'Rack::Auth::Basic' do - - def realm - 'WallysWorld' - end - - def unprotected_app - lambda { |env| [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] } - end - - def protected_app - app = Rack::Auth::Basic.new(unprotected_app) { |username, password| 'Boss' == username } - app.realm = realm - app - end - - setup do - @request = Rack::MockRequest.new(protected_app) - end - - def request_with_basic_auth(username, password, &block) - request 'HTTP_AUTHORIZATION' => 'Basic ' + ["#{username}:#{password}"].pack("m*"), &block - end - - def request(headers = {}) - yield @request.get('/', headers) - end - - def assert_basic_auth_challenge(response) - response.should.be.a.client_error - response.status.should.equal 401 - response.should.include 'WWW-Authenticate' - response.headers['WWW-Authenticate'].should =~ /Basic realm="#{Regexp.escape(realm)}"/ - response.body.should.be.empty - end - - specify 'should challenge correctly when no credentials are specified' do - request do |response| - assert_basic_auth_challenge response - end - end - - specify 'should rechallenge if incorrect credentials are specified' do - request_with_basic_auth 'joe', 'password' do |response| - assert_basic_auth_challenge response - end - end - - specify 'should return application output if correct credentials are specified' do - request_with_basic_auth 'Boss', 'password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Boss' - end - end - - specify 'should return 400 Bad Request if different auth scheme used' do - request 'HTTP_AUTHORIZATION' => 'Digest params' do |response| - response.should.be.a.client_error - response.status.should.equal 400 - response.should.not.include 'WWW-Authenticate' - end - end - - specify 'realm as optional constructor arg' do - app = Rack::Auth::Basic.new(unprotected_app, realm) { true } - assert_equal realm, app.realm - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_auth_digest.rb b/vendor/gems/rack-1.1.0/test/spec_rack_auth_digest.rb deleted file mode 100644 index a980acc8..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_auth_digest.rb +++ /dev/null @@ -1,226 +0,0 @@ -require 'test/spec' - -require 'rack/auth/digest/md5' -require 'rack/mock' - -context 'Rack::Auth::Digest::MD5' do - - def realm - 'WallysWorld' - end - - def unprotected_app - lambda do |env| - [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] - end - end - - def protected_app - app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username| - { 'Alice' => 'correct-password' }[username] - end - app.realm = realm - app.opaque = 'this-should-be-secret' - app - end - - def protected_app_with_hashed_passwords - app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username| - username == 'Alice' ? Digest::MD5.hexdigest("Alice:#{realm}:correct-password") : nil - end - app.realm = realm - app.opaque = 'this-should-be-secret' - app.passwords_hashed = true - app - end - - def partially_protected_app - Rack::URLMap.new({ - '/' => unprotected_app, - '/protected' => protected_app - }) - end - - def protected_app_with_method_override - Rack::MethodOverride.new(protected_app) - end - - setup do - @request = Rack::MockRequest.new(protected_app) - end - - def request(method, path, headers = {}, &block) - response = @request.request(method, path, headers) - block.call(response) if block - return response - end - - class MockDigestRequest - def initialize(params) - @params = params - end - def method_missing(sym) - if @params.has_key? k = sym.to_s - return @params[k] - end - super - end - def method - @params['method'] - end - def response(password) - Rack::Auth::Digest::MD5.new(nil).send :digest, self, password - end - end - - def request_with_digest_auth(method, path, username, password, options = {}, &block) - request_options = {} - request_options[:input] = options.delete(:input) if options.include? :input - - response = request(method, path, request_options) - - return response unless response.status == 401 - - if wait = options.delete(:wait) - sleep wait - end - - challenge = response['WWW-Authenticate'].split(' ', 2).last - - params = Rack::Auth::Digest::Params.parse(challenge) - - params['username'] = username - params['nc'] = '00000001' - params['cnonce'] = 'nonsensenonce' - params['uri'] = path - - params['method'] = method - - params.update options - - params['response'] = MockDigestRequest.new(params).response(password) - - request(method, path, request_options.merge('HTTP_AUTHORIZATION' => "Digest #{params}"), &block) - end - - def assert_digest_auth_challenge(response) - response.should.be.a.client_error - response.status.should.equal 401 - response.should.include 'WWW-Authenticate' - response.headers['WWW-Authenticate'].should =~ /^Digest / - response.body.should.be.empty - end - - def assert_bad_request(response) - response.should.be.a.client_error - response.status.should.equal 400 - response.should.not.include 'WWW-Authenticate' - end - - specify 'should challenge when no credentials are specified' do - request 'GET', '/' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should return application output if correct credentials given' do - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should return application output if correct credentials given (hashed passwords)' do - @request = Rack::MockRequest.new(protected_app_with_hashed_passwords) - - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should rechallenge if incorrect username given' do - request_with_digest_auth 'GET', '/', 'Bob', 'correct-password' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should rechallenge if incorrect password given' do - request_with_digest_auth 'GET', '/', 'Alice', 'wrong-password' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should rechallenge with stale parameter if nonce is stale' do - begin - Rack::Auth::Digest::Nonce.time_limit = 1 - - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', :wait => 2 do |response| - assert_digest_auth_challenge response - response.headers['WWW-Authenticate'].should =~ /\bstale=true\b/ - end - ensure - Rack::Auth::Digest::Nonce.time_limit = nil - end - end - - specify 'should return 400 Bad Request if incorrect qop given' do - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'qop' => 'auth-int' do |response| - assert_bad_request response - end - end - - specify 'should return 400 Bad Request if incorrect uri given' do - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'uri' => '/foo' do |response| - assert_bad_request response - end - end - - specify 'should return 400 Bad Request if different auth scheme used' do - request 'GET', '/', 'HTTP_AUTHORIZATION' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' do |response| - assert_bad_request response - end - end - - specify 'should not require credentials for unprotected path' do - @request = Rack::MockRequest.new(partially_protected_app) - request 'GET', '/' do |response| - response.should.be.ok - end - end - - specify 'should challenge when no credentials are specified for protected path' do - @request = Rack::MockRequest.new(partially_protected_app) - request 'GET', '/protected' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should return application output if correct credentials given for protected path' do - @request = Rack::MockRequest.new(partially_protected_app) - request_with_digest_auth 'GET', '/protected', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should return application output if correct credentials given for POST' do - request_with_digest_auth 'POST', '/', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should return application output if correct credentials given for PUT (using method override of POST)' do - @request = Rack::MockRequest.new(protected_app_with_method_override) - request_with_digest_auth 'POST', '/', 'Alice', 'correct-password', :input => "_method=put" do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'realm as optional constructor arg' do - app = Rack::Auth::Digest::MD5.new(unprotected_app, realm) { true } - assert_equal realm, app.realm - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_builder.rb b/vendor/gems/rack-1.1.0/test/spec_rack_builder.rb deleted file mode 100644 index 3fad9810..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_builder.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'test/spec' - -require 'rack/builder' -require 'rack/mock' -require 'rack/showexceptions' -require 'rack/auth/basic' - -context "Rack::Builder" do - specify "chains apps by default" do - app = Rack::Builder.new do - use Rack::ShowExceptions - run lambda { |env| raise "bzzzt" } - end.to_app - - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - end - - specify "has implicit #to_app" do - app = Rack::Builder.new do - use Rack::ShowExceptions - run lambda { |env| raise "bzzzt" } - end - - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - end - - specify "supports blocks on use" do - app = Rack::Builder.new do - use Rack::ShowExceptions - use Rack::Auth::Basic do |username, password| - 'secret' == password - end - - run lambda { |env| [200, {}, ['Hi Boss']] } - end - - response = Rack::MockRequest.new(app).get("/") - response.should.be.client_error - response.status.should.equal 401 - - # with auth... - response = Rack::MockRequest.new(app).get("/", - 'HTTP_AUTHORIZATION' => 'Basic ' + ["joe:secret"].pack("m*")) - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Boss' - end - - specify "has explicit #to_app" do - app = Rack::Builder.app do - use Rack::ShowExceptions - run lambda { |env| raise "bzzzt" } - end - - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - end - - specify "apps are initialized once" do - app = Rack::Builder.new do - class AppClass - def initialize - @called = 0 - end - def call(env) - raise "bzzzt" if @called > 0 - @called += 1 - [200, {'Content-Type' => 'text/plain'}, ['OK']] - end - end - - use Rack::ShowExceptions - run AppClass.new - end - - Rack::MockRequest.new(app).get("/").status.should.equal 200 - Rack::MockRequest.new(app).get("/").should.be.server_error - end - -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_camping.rb b/vendor/gems/rack-1.1.0/test/spec_rack_camping.rb deleted file mode 100644 index bed11710..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_camping.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'test/spec' -require 'stringio' -require 'uri' - -begin - require 'rack/mock' - - $-w, w = nil, $-w # yuck - require 'camping' - require 'rack/adapter/camping' - - Camping.goes :CampApp - module CampApp - module Controllers - class HW < R('/') - def get - @headers["X-Served-By"] = URI("http://rack.rubyforge.org") - "Camping works!" - end - - def post - "Data: #{input.foo}" - end - end - end - end - $-w = w - - context "Rack::Adapter::Camping" do - specify "works with GET" do - res = Rack::MockRequest.new(Rack::Adapter::Camping.new(CampApp)). - get("/") - - res.should.be.ok - res["Content-Type"].should.equal "text/html" - res["X-Served-By"].should.equal "http://rack.rubyforge.org" - - res.body.should.equal "Camping works!" - end - - specify "works with POST" do - res = Rack::MockRequest.new(Rack::Adapter::Camping.new(CampApp)). - post("/", :input => "foo=bar") - - res.should.be.ok - res.body.should.equal "Data: bar" - end - end -rescue LoadError - $stderr.puts "Skipping Rack::Adapter::Camping tests (Camping is required). `gem install camping` and try again." -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_cascade.rb b/vendor/gems/rack-1.1.0/test/spec_rack_cascade.rb deleted file mode 100644 index cf3c29b4..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_cascade.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'test/spec' - -require 'rack/cascade' -require 'rack/mock' - -require 'rack/urlmap' -require 'rack/file' - -context "Rack::Cascade" do - docroot = File.expand_path(File.dirname(__FILE__)) - app1 = Rack::File.new(docroot) - - app2 = Rack::URLMap.new("/crash" => lambda { |env| raise "boom" }) - - app3 = Rack::URLMap.new("/foo" => lambda { |env| - [200, { "Content-Type" => "text/plain"}, [""]]}) - - specify "should dispatch onward on 404 by default" do - cascade = Rack::Cascade.new([app1, app2, app3]) - Rack::MockRequest.new(cascade).get("/cgi/test").should.be.ok - Rack::MockRequest.new(cascade).get("/foo").should.be.ok - Rack::MockRequest.new(cascade).get("/toobad").should.be.not_found - Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.forbidden - end - - specify "should dispatch onward on whatever is passed" do - cascade = Rack::Cascade.new([app1, app2, app3], [404, 403]) - Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.not_found - end - - specify "should return 404 if empty" do - Rack::MockRequest.new(Rack::Cascade.new([])).get('/').should.be.not_found - end - - specify "should append new app" do - cascade = Rack::Cascade.new([], [404, 403]) - Rack::MockRequest.new(cascade).get('/').should.be.not_found - cascade << app2 - Rack::MockRequest.new(cascade).get('/cgi/test').should.be.not_found - Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.not_found - cascade << app1 - Rack::MockRequest.new(cascade).get('/cgi/test').should.be.ok - Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.forbidden - Rack::MockRequest.new(cascade).get('/foo').should.be.not_found - cascade << app3 - Rack::MockRequest.new(cascade).get('/foo').should.be.ok - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_cgi.rb b/vendor/gems/rack-1.1.0/test/spec_rack_cgi.rb deleted file mode 100644 index 59500cd7..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_cgi.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'test/spec' -require 'testrequest' - -context "Rack::Handler::CGI" do - include TestRequest::Helpers - - setup do - @host = '0.0.0.0' - @port = 9203 - end - - # Keep this first. - specify "startup" do - $pid = fork { - Dir.chdir(File.join(File.dirname(__FILE__), "..", "test", "cgi")) - exec "lighttpd -D -f lighttpd.conf" - } - end - - specify "should respond" do - sleep 1 - lambda { - GET("/test") - }.should.not.raise - end - - specify "should be a lighttpd" do - GET("/test") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /lighttpd/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal @port.to_s - response["SERVER_NAME"].should =~ @host - end - - specify "should have rack headers" do - GET("/test") - response["rack.version"].should.equal [1,1] - response["rack.multithread"].should.be false - response["rack.multiprocess"].should.be true - response["rack.run_once"].should.be true - end - - specify "should have CGI headers on GET" do - GET("/test") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "" - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - # Keep this last. - specify "shutdown" do - Process.kill 15, $pid - Process.wait($pid).should.equal $pid - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_chunked.rb b/vendor/gems/rack-1.1.0/test/spec_rack_chunked.rb deleted file mode 100644 index 39eea482..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_chunked.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'rack/mock' -require 'rack/chunked' -require 'rack/utils' - -context "Rack::Chunked" do - - before do - @env = Rack::MockRequest. - env_for('/', 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET') - end - - specify 'chunks responses with no Content-Length' do - app = lambda { |env| [200, {}, ['Hello', ' ', 'World!']] } - response = Rack::MockResponse.new(*Rack::Chunked.new(app).call(@env)) - response.headers.should.not.include 'Content-Length' - response.headers['Transfer-Encoding'].should.equal 'chunked' - response.body.should.equal "5\r\nHello\r\n1\r\n \r\n6\r\nWorld!\r\n0\r\n\r\n" - end - - specify 'chunks empty bodies properly' do - app = lambda { |env| [200, {}, []] } - response = Rack::MockResponse.new(*Rack::Chunked.new(app).call(@env)) - response.headers.should.not.include 'Content-Length' - response.headers['Transfer-Encoding'].should.equal 'chunked' - response.body.should.equal "0\r\n\r\n" - end - - specify 'does not modify response when Content-Length header present' do - app = lambda { |env| [200, {'Content-Length'=>'12'}, ['Hello', ' ', 'World!']] } - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal 200 - headers.should.not.include 'Transfer-Encoding' - headers.should.include 'Content-Length' - body.join.should.equal 'Hello World!' - end - - specify 'does not modify response when client is HTTP/1.0' do - app = lambda { |env| [200, {}, ['Hello', ' ', 'World!']] } - @env['HTTP_VERSION'] = 'HTTP/1.0' - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal 200 - headers.should.not.include 'Transfer-Encoding' - body.join.should.equal 'Hello World!' - end - - specify 'does not modify response when Transfer-Encoding header already present' do - app = lambda { |env| [200, {'Transfer-Encoding' => 'identity'}, ['Hello', ' ', 'World!']] } - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal 200 - headers['Transfer-Encoding'].should.equal 'identity' - body.join.should.equal 'Hello World!' - end - - [100, 204, 304].each do |status_code| - specify "does not modify response when status code is #{status_code}" do - app = lambda { |env| [status_code, {}, []] } - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal status_code - headers.should.not.include 'Transfer-Encoding' - end - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_commonlogger.rb b/vendor/gems/rack-1.1.0/test/spec_rack_commonlogger.rb deleted file mode 100644 index 46a72e86..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_commonlogger.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test/spec' -require 'stringio' - -require 'rack/commonlogger' -require 'rack/lobster' -require 'rack/mock' - -context "Rack::CommonLogger" do - app = lambda { |env| - [200, - {"Content-Type" => "text/html", "Content-Length" => length.to_s}, - [obj]]} - app_without_length = lambda { |env| - [200, - {"Content-Type" => "text/html"}, - []]} - app_with_zero_length = lambda { |env| - [200, - {"Content-Type" => "text/html", "Content-Length" => "0"}, - []]} - - specify "should log to rack.errors by default" do - res = Rack::MockRequest.new(Rack::CommonLogger.new(app)).get("/") - - res.errors.should.not.be.empty - res.errors.should =~ /"GET \/ " 200 #{length} / - end - - specify "should log to anything with +write+" do - log = StringIO.new - res = Rack::MockRequest.new(Rack::CommonLogger.new(app, log)).get("/") - - log.string.should =~ /"GET \/ " 200 #{length} / - end - - specify "should log - content length if header is missing" do - res = Rack::MockRequest.new(Rack::CommonLogger.new(app_without_length)).get("/") - - res.errors.should.not.be.empty - res.errors.should =~ /"GET \/ " 200 - / - end - - specify "should log - content length if header is zero" do - res = Rack::MockRequest.new(Rack::CommonLogger.new(app_with_zero_length)).get("/") - - res.errors.should.not.be.empty - res.errors.should =~ /"GET \/ " 200 - / - end - - def length - self.class.length - end - - def self.length - 123 - end - - def self.obj - "hello world" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_conditionalget.rb b/vendor/gems/rack-1.1.0/test/spec_rack_conditionalget.rb deleted file mode 100644 index ca34cc92..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_conditionalget.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'test/spec' -require 'time' - -require 'rack/mock' -require 'rack/conditionalget' - -context "Rack::ConditionalGet" do - specify "should set a 304 status and truncate body when If-Modified-Since hits" do - timestamp = Time.now.httpdate - app = Rack::ConditionalGet.new(lambda { |env| - [200, {'Last-Modified'=>timestamp}, ['TEST']] }) - - response = Rack::MockRequest.new(app). - get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp) - - response.status.should.equal 304 - response.body.should.be.empty - end - - specify "should set a 304 status and truncate body when If-None-Match hits" do - app = Rack::ConditionalGet.new(lambda { |env| - [200, {'Etag'=>'1234'}, ['TEST']] }) - - response = Rack::MockRequest.new(app). - get("/", 'HTTP_IF_NONE_MATCH' => '1234') - - response.status.should.equal 304 - response.body.should.be.empty - end - - specify "should not affect non-GET/HEAD requests" do - app = Rack::ConditionalGet.new(lambda { |env| - [200, {'Etag'=>'1234'}, ['TEST']] }) - - response = Rack::MockRequest.new(app). - post("/", 'HTTP_IF_NONE_MATCH' => '1234') - - response.status.should.equal 200 - response.body.should.equal 'TEST' - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_config.rb b/vendor/gems/rack-1.1.0/test/spec_rack_config.rb deleted file mode 100644 index a508ea4b..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_config.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'test/spec' -require 'rack/mock' -require 'rack/builder' -require 'rack/content_length' -require 'rack/config' - -context "Rack::Config" do - - specify "should accept a block that modifies the environment" do - app = Rack::Builder.new do - use Rack::Lint - use Rack::ContentLength - use Rack::Config do |env| - env['greeting'] = 'hello' - end - run lambda { |env| - [200, {'Content-Type' => 'text/plain'}, [env['greeting'] || '']] - } - end - response = Rack::MockRequest.new(app).get('/') - response.body.should.equal('hello') - end - -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_content_length.rb b/vendor/gems/rack-1.1.0/test/spec_rack_content_length.rb deleted file mode 100644 index 7db9345f..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_content_length.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'rack/mock' -require 'rack/content_length' - -context "Rack::ContentLength" do - specify "sets Content-Length on String bodies if none is set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal '13' - end - - specify "sets Content-Length on Array bodies if none is set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal '13' - end - - specify "does not set Content-Length on variable length bodies" do - body = lambda { "Hello World!" } - def body.each ; yield call ; end - - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.be.nil - end - - specify "does not change Content-Length if it is already set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'Content-Length' => '1'}, "Hello, World!"] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal '1' - end - - specify "does not set Content-Length on 304 responses" do - app = lambda { |env| [304, {'Content-Type' => 'text/plain'}, []] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal nil - end - - specify "does not set Content-Length when Transfer-Encoding is chunked" do - app = lambda { |env| [200, {'Transfer-Encoding' => 'chunked'}, []] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal nil - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_content_type.rb b/vendor/gems/rack-1.1.0/test/spec_rack_content_type.rb deleted file mode 100644 index 9975b94d..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_content_type.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rack/mock' -require 'rack/content_type' - -context "Rack::ContentType" do - specify "sets Content-Type to default text/html if none is set" do - app = lambda { |env| [200, {}, "Hello, World!"] } - status, headers, body = Rack::ContentType.new(app).call({}) - headers['Content-Type'].should.equal 'text/html' - end - - specify "sets Content-Type to chosen default if none is set" do - app = lambda { |env| [200, {}, "Hello, World!"] } - status, headers, body = - Rack::ContentType.new(app, 'application/octet-stream').call({}) - headers['Content-Type'].should.equal 'application/octet-stream' - end - - specify "does not change Content-Type if it is already set" do - app = lambda { |env| [200, {'Content-Type' => 'foo/bar'}, "Hello, World!"] } - status, headers, body = Rack::ContentType.new(app).call({}) - headers['Content-Type'].should.equal 'foo/bar' - end - - specify "case insensitive detection of Content-Type" do - app = lambda { |env| [200, {'CONTENT-Type' => 'foo/bar'}, "Hello, World!"] } - status, headers, body = Rack::ContentType.new(app).call({}) - headers.to_a.select { |k,v| k.downcase == "content-type" }. - should.equal [["CONTENT-Type","foo/bar"]] - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_deflater.rb b/vendor/gems/rack-1.1.0/test/spec_rack_deflater.rb deleted file mode 100644 index c9bb3189..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_deflater.rb +++ /dev/null @@ -1,127 +0,0 @@ -require 'test/spec' - -require 'rack/mock' -require 'rack/deflater' -require 'stringio' -require 'time' # for Time#httpdate - -context "Rack::Deflater" do - def build_response(status, body, accept_encoding, headers = {}) - body = [body] if body.respond_to? :to_str - app = lambda { |env| [status, {}, body] } - request = Rack::MockRequest.env_for("", headers.merge("HTTP_ACCEPT_ENCODING" => accept_encoding)) - response = Rack::Deflater.new(app).call(request) - - return response - end - - specify "should be able to deflate bodies that respond to each" do - body = Object.new - class << body; def each; yield("foo"); yield("bar"); end; end - - response = build_response(200, body, "deflate") - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "deflate", - "Vary" => "Accept-Encoding" - }) - buf = '' - response[2].each { |part| buf << part } - buf.should.equal("K\313\317OJ,\002\000") - end - - # TODO: This is really just a special case of the above... - specify "should be able to deflate String bodies" do - response = build_response(200, "Hello world!", "deflate") - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "deflate", - "Vary" => "Accept-Encoding" - }) - buf = '' - response[2].each { |part| buf << part } - buf.should.equal("\363H\315\311\311W(\317/\312IQ\004\000") - end - - specify "should be able to gzip bodies that respond to each" do - body = Object.new - class << body; def each; yield("foo"); yield("bar"); end; end - - response = build_response(200, body, "gzip") - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "gzip", - "Vary" => "Accept-Encoding", - }) - - buf = '' - response[2].each { |part| buf << part } - io = StringIO.new(buf) - gz = Zlib::GzipReader.new(io) - gz.read.should.equal("foobar") - gz.close - end - - specify "should be able to fallback to no deflation" do - response = build_response(200, "Hello world!", "superzip") - - response[0].should.equal(200) - response[1].should.equal({ "Vary" => "Accept-Encoding" }) - response[2].should.equal(["Hello world!"]) - end - - specify "should be able to skip when there is no response entity body" do - response = build_response(304, [], "gzip") - - response[0].should.equal(304) - response[1].should.equal({}) - response[2].should.equal([]) - end - - specify "should handle the lack of an acceptable encoding" do - response1 = build_response(200, "Hello world!", "identity;q=0", "PATH_INFO" => "/") - response1[0].should.equal(406) - response1[1].should.equal({"Content-Type" => "text/plain", "Content-Length" => "71"}) - response1[2].should.equal(["An acceptable encoding for the requested resource / could not be found."]) - - response2 = build_response(200, "Hello world!", "identity;q=0", "SCRIPT_NAME" => "/foo", "PATH_INFO" => "/bar") - response2[0].should.equal(406) - response2[1].should.equal({"Content-Type" => "text/plain", "Content-Length" => "78"}) - response2[2].should.equal(["An acceptable encoding for the requested resource /foo/bar could not be found."]) - end - - specify "should handle gzip response with Last-Modified header" do - last_modified = Time.now.httpdate - - app = lambda { |env| [200, { "Last-Modified" => last_modified }, ["Hello World!"]] } - request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip") - response = Rack::Deflater.new(app).call(request) - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "gzip", - "Vary" => "Accept-Encoding", - "Last-Modified" => last_modified - }) - - buf = '' - response[2].each { |part| buf << part } - io = StringIO.new(buf) - gz = Zlib::GzipReader.new(io) - gz.read.should.equal("Hello World!") - gz.close - end - - specify "should do nothing when no-transform Cache-Control directive present" do - app = lambda { |env| [200, {'Cache-Control' => 'no-transform'}, ['Hello World!']] } - request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip") - response = Rack::Deflater.new(app).call(request) - - response[0].should.equal(200) - response[1].should.not.include "Content-Encoding" - response[2].join.should.equal("Hello World!") - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_directory.rb b/vendor/gems/rack-1.1.0/test/spec_rack_directory.rb deleted file mode 100644 index d255c91d..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_directory.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test/spec' - -require 'rack/directory' -require 'rack/lint' - -require 'rack/mock' - -context "Rack::Directory" do - DOCROOT = File.expand_path(File.dirname(__FILE__)) unless defined? DOCROOT - FILE_CATCH = proc{|env| [200, {'Content-Type'=>'text/plain', "Content-Length" => "7"}, ['passed!']] } - app = Rack::Directory.new DOCROOT, FILE_CATCH - - specify "serves directory indices" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/") - - res.should.be.ok - res.should =~ // - end - - specify "passes to app if file found" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/test") - - res.should.be.ok - res.should =~ /passed!/ - end - - specify "serves uri with URL encoded filenames" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/%63%67%69/") # "/cgi/test" - - res.should.be.ok - res.should =~ // - - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/%74%65%73%74") # "/cgi/test" - - res.should.be.ok - res.should =~ /passed!/ - end - - specify "does not allow directory traversal" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/../test") - - res.should.be.forbidden - - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/%2E%2E/test") - - res.should.be.forbidden - end - - specify "404s if it can't find the file" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/blubb") - - res.should.be.not_found - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_etag.rb b/vendor/gems/rack-1.1.0/test/spec_rack_etag.rb deleted file mode 100644 index 73cd31ac..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_etag.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'test/spec' -require 'rack/mock' -require 'rack/etag' - -context "Rack::ETag" do - specify "sets ETag if none is set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] } - response = Rack::ETag.new(app).call({}) - response[1]['ETag'].should.equal "\"65a8e27d8879283831b664bd8b7f0ad4\"" - end - - specify "does not change ETag if it is already set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'ETag' => '"abc"'}, ["Hello, World!"]] } - response = Rack::ETag.new(app).call({}) - response[1]['ETag'].should.equal "\"abc\"" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_fastcgi.rb b/vendor/gems/rack-1.1.0/test/spec_rack_fastcgi.rb deleted file mode 100644 index 1ae55ace..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_fastcgi.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'test/spec' -require 'testrequest' - -context "Rack::Handler::FastCGI" do - include TestRequest::Helpers - - setup do - @host = '0.0.0.0' - @port = 9203 - end - - # Keep this first. - specify "startup" do - $pid = fork { - Dir.chdir(File.join(File.dirname(__FILE__), "..", "test", "cgi")) - exec "lighttpd -D -f lighttpd.conf" - } - end - - specify "should respond" do - sleep 1 - lambda { - GET("/test.fcgi") - }.should.not.raise - end - - specify "should be a lighttpd" do - GET("/test.fcgi") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /lighttpd/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal @port.to_s - response["SERVER_NAME"].should =~ @host - end - - specify "should have rack headers" do - GET("/test.fcgi") - response["rack.version"].should.equal [1,1] - response["rack.multithread"].should.be false - response["rack.multiprocess"].should.be true - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/test.fcgi") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test.fcgi" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "" - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test.fcgi/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test.fcgi" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test.fcgi", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test.fcgi" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test.fcgi", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test.fcgi?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - # Keep this last. - specify "shutdown" do - Process.kill 15, $pid - Process.wait($pid).should.equal $pid - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_file.rb b/vendor/gems/rack-1.1.0/test/spec_rack_file.rb deleted file mode 100644 index 0a2f8ee8..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_file.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'test/spec' - -require 'rack/file' -require 'rack/lint' - -require 'rack/mock' - -context "Rack::File" do - DOCROOT = File.expand_path(File.dirname(__FILE__)) unless defined? DOCROOT - - specify "serves files" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/test") - - res.should.be.ok - res.should =~ /ruby/ - end - - specify "sets Last-Modified header" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/test") - - path = File.join(DOCROOT, "/cgi/test") - - res.should.be.ok - res["Last-Modified"].should.equal File.mtime(path).httpdate - end - - specify "serves files with URL encoded filenames" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/%74%65%73%74") # "/cgi/test" - - res.should.be.ok - res.should =~ /ruby/ - end - - specify "does not allow directory traversal" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/../test") - - res.should.be.forbidden - end - - specify "does not allow directory traversal with encoded periods" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/%2E%2E/README") - - res.should.be.forbidden - end - - specify "404s if it can't find the file" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/blubb") - - res.should.be.not_found - end - - specify "detects SystemCallErrors" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi") - - res.should.be.not_found - end - - specify "returns bodies that respond to #to_path" do - env = Rack::MockRequest.env_for("/cgi/test") - status, headers, body = Rack::File.new(DOCROOT).call(env) - - path = File.join(DOCROOT, "/cgi/test") - - status.should.equal 200 - body.should.respond_to :to_path - body.to_path.should.equal path - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_handler.rb b/vendor/gems/rack-1.1.0/test/spec_rack_handler.rb deleted file mode 100644 index fcf19b78..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_handler.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'test/spec' - -require 'rack/handler' - -class Rack::Handler::Lobster; end -class RockLobster; end - -context "Rack::Handler" do - specify "has registered default handlers" do - Rack::Handler.get('cgi').should.equal Rack::Handler::CGI - Rack::Handler.get('fastcgi').should.equal Rack::Handler::FastCGI - Rack::Handler.get('mongrel').should.equal Rack::Handler::Mongrel - Rack::Handler.get('webrick').should.equal Rack::Handler::WEBrick - end - - specify "handler that doesn't exist should raise a NameError" do - lambda { - Rack::Handler.get('boom') - }.should.raise(NameError) - end - - specify "should get unregistered, but already required, handler by name" do - Rack::Handler.get('Lobster').should.equal Rack::Handler::Lobster - end - - specify "should register custom handler" do - Rack::Handler.register('rock_lobster', 'RockLobster') - Rack::Handler.get('rock_lobster').should.equal RockLobster - end - - specify "should not need registration for properly coded handlers even if not already required" do - begin - $:.push "test/unregistered_handler" - Rack::Handler.get('Unregistered').should.equal Rack::Handler::Unregistered - lambda { - Rack::Handler.get('UnRegistered') - }.should.raise(NameError) - Rack::Handler.get('UnregisteredLongOne').should.equal Rack::Handler::UnregisteredLongOne - ensure - $:.delete "test/unregistered_handler" - end - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_head.rb b/vendor/gems/rack-1.1.0/test/spec_rack_head.rb deleted file mode 100644 index 48d3f81f..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_head.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rack/head' -require 'rack/mock' - -context "Rack::Head" do - def test_response(headers = {}) - app = lambda { |env| [200, {"Content-type" => "test/plain", "Content-length" => "3"}, ["foo"]] } - request = Rack::MockRequest.env_for("/", headers) - response = Rack::Head.new(app).call(request) - - return response - end - - specify "passes GET, POST, PUT, DELETE, OPTIONS, TRACE requests" do - %w[GET POST PUT DELETE OPTIONS TRACE].each do |type| - resp = test_response("REQUEST_METHOD" => type) - - resp[0].should.equal(200) - resp[1].should.equal({"Content-type" => "test/plain", "Content-length" => "3"}) - resp[2].should.equal(["foo"]) - end - end - - specify "removes body from HEAD requests" do - resp = test_response("REQUEST_METHOD" => "HEAD") - - resp[0].should.equal(200) - resp[1].should.equal({"Content-type" => "test/plain", "Content-length" => "3"}) - resp[2].should.equal([]) - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_lint.rb b/vendor/gems/rack-1.1.0/test/spec_rack_lint.rb deleted file mode 100644 index bbf75c17..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_lint.rb +++ /dev/null @@ -1,528 +0,0 @@ -require 'test/spec' -require 'stringio' - -require 'rack/lint' -require 'rack/mock' - -context "Rack::Lint" do - def env(*args) - Rack::MockRequest.env_for("/", *args) - end - - specify "passes valid request" do - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "test/plain", "Content-length" => "3"}, ["foo"]] - }).call(env({})) - }.should.not.raise - end - - specify "notices fatal errors" do - lambda { Rack::Lint.new(nil).call }.should.raise(Rack::Lint::LintError). - message.should.match(/No env given/) - end - - specify "notices environment errors" do - lambda { Rack::Lint.new(nil).call 5 }.should.raise(Rack::Lint::LintError). - message.should.match(/not a Hash/) - - lambda { - e = env - e.delete("REQUEST_METHOD") - Rack::Lint.new(nil).call(e) - }.should.raise(Rack::Lint::LintError). - message.should.match(/missing required key REQUEST_METHOD/) - - lambda { - e = env - e.delete("SERVER_NAME") - Rack::Lint.new(nil).call(e) - }.should.raise(Rack::Lint::LintError). - message.should.match(/missing required key SERVER_NAME/) - - - lambda { - Rack::Lint.new(nil).call(env("HTTP_CONTENT_TYPE" => "text/plain")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/contains HTTP_CONTENT_TYPE/) - - lambda { - Rack::Lint.new(nil).call(env("HTTP_CONTENT_LENGTH" => "42")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/contains HTTP_CONTENT_LENGTH/) - - lambda { - Rack::Lint.new(nil).call(env("FOO" => Object.new)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/non-string value/) - - lambda { - Rack::Lint.new(nil).call(env("rack.version" => "0.2")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must be an Array/) - - lambda { - Rack::Lint.new(nil).call(env("rack.url_scheme" => "gopher")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/url_scheme unknown/) - - lambda { - Rack::Lint.new(nil).call(env("rack.session" => [])) - }.should.raise(Rack::Lint::LintError). - message.should.equal("session [] must respond to store and []=") - - lambda { - Rack::Lint.new(nil).call(env("rack.logger" => [])) - }.should.raise(Rack::Lint::LintError). - message.should.equal("logger [] must respond to info") - - lambda { - Rack::Lint.new(nil).call(env("REQUEST_METHOD" => "FUCKUP?")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/REQUEST_METHOD/) - - lambda { - Rack::Lint.new(nil).call(env("SCRIPT_NAME" => "howdy")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must start with/) - - lambda { - Rack::Lint.new(nil).call(env("PATH_INFO" => "../foo")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must start with/) - - lambda { - Rack::Lint.new(nil).call(env("CONTENT_LENGTH" => "xcii")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Invalid CONTENT_LENGTH/) - - lambda { - e = env - e.delete("PATH_INFO") - e.delete("SCRIPT_NAME") - Rack::Lint.new(nil).call(e) - }.should.raise(Rack::Lint::LintError). - message.should.match(/One of .* must be set/) - - lambda { - Rack::Lint.new(nil).call(env("SCRIPT_NAME" => "/")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/cannot be .* make it ''/) - end - - specify "notices input errors" do - lambda { - Rack::Lint.new(nil).call(env("rack.input" => "")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/does not respond to #gets/) - - lambda { - input = Object.new - def input.binmode? - false - end - Rack::Lint.new(nil).call(env("rack.input" => input)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/is not opened in binary mode/) - - lambda { - input = Object.new - def input.external_encoding - result = Object.new - def result.name - "US-ASCII" - end - result - end - Rack::Lint.new(nil).call(env("rack.input" => input)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/does not have ASCII-8BIT as its external encoding/) - end - - specify "notices error errors" do - lambda { - Rack::Lint.new(nil).call(env("rack.errors" => "")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/does not respond to #puts/) - end - - specify "notices status errors" do - lambda { - Rack::Lint.new(lambda { |env| - ["cc", {}, ""] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must be >=100 seen as integer/) - - lambda { - Rack::Lint.new(lambda { |env| - [42, {}, ""] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must be >=100 seen as integer/) - end - - specify "notices header errors" do - lambda { - Rack::Lint.new(lambda { |env| - [200, Object.new, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("headers object should respond to #each, but doesn't (got Object as headers)") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {true=>false}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("header key must be a string, was TrueClass") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Status" => "404"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must not contain Status/) - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-Type:" => "text/plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must not contain :/) - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-" => "text/plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must not end/) - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"..%%quark%%.." => "text/plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("invalid header name: ..%%quark%%..") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo" => Object.new}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("a header value must be a String, but the value of 'Foo' is a Object") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo" => [1, 2, 3]}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("a header value must be a String, but the value of 'Foo' is a Array") - - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo-Bar" => "text\000plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/invalid header/) - - # line ends (010) should be allowed in header values. - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo-Bar" => "one\ntwo\nthree", "Content-Length" => "0", "Content-Type" => "text/plain" }, []] - }).call(env({})) - }.should.not.raise(Rack::Lint::LintError) - end - - specify "notices content-type errors" do - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/No Content-Type/) - - [100, 101, 204, 304].each do |status| - lambda { - Rack::Lint.new(lambda { |env| - [status, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Content-Type header found/) - end - end - - specify "notices content-length errors" do - [100, 101, 204, 304].each do |status| - lambda { - Rack::Lint.new(lambda { |env| - [status, {"Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Content-Length header found/) - end - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "text/plain", "Content-Length" => "1"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Content-Length header was 1, but should be 0/) - end - - specify "notices body errors" do - lambda { - status, header, body = Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "text/plain","Content-length" => "3"}, [1,2,3]] - }).call(env({})) - body.each { |part| } - }.should.raise(Rack::Lint::LintError). - message.should.match(/yielded non-string/) - end - - specify "notices input handling errors" do - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].gets("\r\n") - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/gets called with arguments/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(1, 2, 3) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with too many arguments/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read("foo") - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with non-integer and non-nil length/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(-1) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with a negative length/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil, nil) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with non-String buffer/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil, 1) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with non-String buffer/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].rewind(0) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/rewind called with arguments/) - - weirdio = Object.new - class << weirdio - def gets - 42 - end - - def read - 23 - end - - def each - yield 23 - yield 42 - end - - def rewind - raise Errno::ESPIPE, "Errno::ESPIPE" - end - end - - eof_weirdio = Object.new - class << eof_weirdio - def gets - nil - end - - def read(*args) - nil - end - - def each - end - - def rewind - end - end - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].gets - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/gets didn't return a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].each { |x| } - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/each didn't yield a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read didn't return nil or a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => eof_weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read\(nil\) returned nil on EOF/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].rewind - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/rewind raised Errno::ESPIPE/) - - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].close - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/close must not be called/) - end - - specify "notices error handling errors" do - lambda { - Rack::Lint.new(lambda { |env| - env["rack.errors"].write(42) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/write not called with a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.errors"].close - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/close must not be called/) - end - - specify "notices HEAD errors" do - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "test/plain", "Content-length" => "3"}, []] - }).call(env({"REQUEST_METHOD" => "HEAD"})) - }.should.not.raise - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "test/plain", "Content-length" => "3"}, ["foo"]] - }).call(env({"REQUEST_METHOD" => "HEAD"})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/body was given for HEAD/) - end - - specify "passes valid read calls" do - hello_str = "hello world" - hello_str.force_encoding("ASCII-8BIT") if hello_str.respond_to? :force_encoding - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new(hello_str)})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(0) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new(hello_str)})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(1) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new(hello_str)})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new(hello_str)})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil, '') - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new(hello_str)})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(1, '') - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new(hello_str)})) - }.should.not.raise(Rack::Lint::LintError) - end -end - -context "Rack::Lint::InputWrapper" do - specify "delegates :size to underlying IO object" do - class IOMock - def size - 101 - end - end - - wrapper = Rack::Lint::InputWrapper.new(IOMock.new) - wrapper.size.should == 101 - end - - specify "delegates :rewind to underlying IO object" do - io = StringIO.new("123") - wrapper = Rack::Lint::InputWrapper.new(io) - wrapper.read.should.equal "123" - wrapper.read.should.equal "" - wrapper.rewind - wrapper.read.should.equal "123" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_lobster.rb b/vendor/gems/rack-1.1.0/test/spec_rack_lobster.rb deleted file mode 100644 index 7be267a2..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_lobster.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test/spec' - -require 'rack/lobster' -require 'rack/mock' - -context "Rack::Lobster::LambdaLobster" do - specify "should be a single lambda" do - Rack::Lobster::LambdaLobster.should.be.kind_of Proc - end - - specify "should look like a lobster" do - res = Rack::MockRequest.new(Rack::Lobster::LambdaLobster).get("/") - res.should.be.ok - res.body.should.include "(,(,,(,,,(" - res.body.should.include "?flip" - end - - specify "should be flippable" do - res = Rack::MockRequest.new(Rack::Lobster::LambdaLobster).get("/?flip") - res.should.be.ok - res.body.should.include "(,,,(,,(,(" - end -end - -context "Rack::Lobster" do - specify "should look like a lobster" do - res = Rack::MockRequest.new(Rack::Lobster.new).get("/") - res.should.be.ok - res.body.should.include "(,(,,(,,,(" - res.body.should.include "?flip" - res.body.should.include "crash" - end - - specify "should be flippable" do - res = Rack::MockRequest.new(Rack::Lobster.new).get("/?flip=left") - res.should.be.ok - res.body.should.include "(,,,(,,(,(" - end - - specify "should provide crashing for testing purposes" do - lambda { - Rack::MockRequest.new(Rack::Lobster.new).get("/?flip=crash") - }.should.raise - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_lock.rb b/vendor/gems/rack-1.1.0/test/spec_rack_lock.rb deleted file mode 100644 index 18af2b23..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_lock.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'test/spec' - -require 'rack/mock' -require 'rack/lock' - -context "Rack::Lock" do - class Lock - attr_reader :synchronized - - def initialize - @synchronized = false - end - - def synchronize - @synchronized = true - yield - end - end - - specify "should call synchronize on lock" do - lock = Lock.new - env = Rack::MockRequest.env_for("/") - app = Rack::Lock.new(lambda { |env| }, lock) - lock.synchronized.should.equal false - app.call(env) - lock.synchronized.should.equal true - end - - specify "should set multithread flag to false" do - app = Rack::Lock.new(lambda { |env| env['rack.multithread'] }) - app.call(Rack::MockRequest.env_for("/")).should.equal false - end - - specify "should reset original multithread flag when exiting lock" do - app = Rack::Lock.new(lambda { |env| env }) - app.call(Rack::MockRequest.env_for("/"))['rack.multithread'].should.equal true - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_logger.rb b/vendor/gems/rack-1.1.0/test/spec_rack_logger.rb deleted file mode 100644 index d55b9c77..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_logger.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rack/logger' -require 'rack/lint' -require 'stringio' - -context "Rack::Logger" do - specify "logs to rack.errors" do - app = lambda { |env| - log = env['rack.logger'] - log.debug("Created logger") - log.info("Program started") - log.warn("Nothing to do!") - - [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] - } - - errors = StringIO.new - Rack::Logger.new(app).call({'rack.errors' => errors}) - errors.string.should.match "INFO -- : Program started" - errors.string.should.match "WARN -- : Nothing to do" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_methodoverride.rb b/vendor/gems/rack-1.1.0/test/spec_rack_methodoverride.rb deleted file mode 100644 index 57452394..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_methodoverride.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'test/spec' - -require 'rack/mock' -require 'rack/methodoverride' -require 'stringio' - -context "Rack::MethodOverride" do - specify "should not affect GET requests" do - env = Rack::MockRequest.env_for("/?_method=delete", :method => "GET") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "GET" - end - - specify "_method parameter should modify REQUEST_METHOD for POST requests" do - env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=put") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "PUT" - end - - specify "X-HTTP-Method-Override header should modify REQUEST_METHOD for POST requests" do - env = Rack::MockRequest.env_for("/", - :method => "POST", - "HTTP_X_HTTP_METHOD_OVERRIDE" => "PUT" - ) - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "PUT" - end - - specify "should not modify REQUEST_METHOD if the method is unknown" do - env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=foo") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "POST" - end - - specify "should not modify REQUEST_METHOD when _method is nil" do - env = Rack::MockRequest.env_for("/", :method => "POST", :input => "foo=bar") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "POST" - end - - specify "should store the original REQUEST_METHOD prior to overriding" do - env = Rack::MockRequest.env_for("/", - :method => "POST", - :input => "_method=options") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["rack.methodoverride.original_method"].should.equal "POST" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_mock.rb b/vendor/gems/rack-1.1.0/test/spec_rack_mock.rb deleted file mode 100644 index a03bedc2..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_mock.rb +++ /dev/null @@ -1,243 +0,0 @@ -require 'yaml' -require 'rack/mock' -require 'rack/request' -require 'rack/response' - -app = lambda { |env| - req = Rack::Request.new(env) - - env["mock.postdata"] = env["rack.input"].read - if req.GET["error"] - env["rack.errors"].puts req.GET["error"] - env["rack.errors"].flush - end - - Rack::Response.new(env.to_yaml, - req.GET["status"] || 200, - "Content-Type" => "text/yaml").finish -} - -context "Rack::MockRequest" do - specify "should return a MockResponse" do - res = Rack::MockRequest.new(app).get("") - res.should.be.kind_of Rack::MockResponse - end - - specify "should be able to only return the environment" do - env = Rack::MockRequest.env_for("") - env.should.be.kind_of Hash - env.should.include "rack.version" - end - - specify "should provide sensible defaults" do - res = Rack::MockRequest.new(app).request - - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["SERVER_NAME"].should.equal "example.org" - env["SERVER_PORT"].should.equal "80" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/" - env["SCRIPT_NAME"].should.equal "" - env["rack.url_scheme"].should.equal "http" - env["mock.postdata"].should.be.empty - end - - specify "should allow GET/POST/PUT/DELETE" do - res = Rack::MockRequest.new(app).get("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - - res = Rack::MockRequest.new(app).post("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "POST" - - res = Rack::MockRequest.new(app).put("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "PUT" - - res = Rack::MockRequest.new(app).delete("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "DELETE" - - Rack::MockRequest.env_for("/", :method => "OPTIONS")["REQUEST_METHOD"]. - should.equal "OPTIONS" - end - - specify "should set content length" do - env = Rack::MockRequest.env_for("/", :input => "foo") - env["CONTENT_LENGTH"].should.equal "3" - end - - specify "should allow posting" do - res = Rack::MockRequest.new(app).get("", :input => "foo") - env = YAML.load(res.body) - env["mock.postdata"].should.equal "foo" - - res = Rack::MockRequest.new(app).post("", :input => StringIO.new("foo")) - env = YAML.load(res.body) - env["mock.postdata"].should.equal "foo" - end - - specify "should use all parts of an URL" do - res = Rack::MockRequest.new(app). - get("https://bla.example.org:9292/meh/foo?bar") - res.should.be.kind_of Rack::MockResponse - - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["SERVER_NAME"].should.equal "bla.example.org" - env["SERVER_PORT"].should.equal "9292" - env["QUERY_STRING"].should.equal "bar" - env["PATH_INFO"].should.equal "/meh/foo" - env["rack.url_scheme"].should.equal "https" - end - - specify "should set SSL port and HTTP flag on when using https" do - res = Rack::MockRequest.new(app). - get("https://example.org/foo") - res.should.be.kind_of Rack::MockResponse - - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["SERVER_NAME"].should.equal "example.org" - env["SERVER_PORT"].should.equal "443" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/foo" - env["rack.url_scheme"].should.equal "https" - env["HTTPS"].should.equal "on" - end - - specify "should prepend slash to uri path" do - res = Rack::MockRequest.new(app). - get("foo") - res.should.be.kind_of Rack::MockResponse - - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["SERVER_NAME"].should.equal "example.org" - env["SERVER_PORT"].should.equal "80" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/foo" - env["rack.url_scheme"].should.equal "http" - end - - specify "should properly convert method name to an uppercase string" do - res = Rack::MockRequest.new(app).request(:get) - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - end - - specify "should accept params and build query string for GET requests" do - res = Rack::MockRequest.new(app).get("/foo?baz=2", :params => {:foo => {:bar => "1"}}) - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["QUERY_STRING"].should.match "baz=2" - env["QUERY_STRING"].should.match "foo[bar]=1" - env["PATH_INFO"].should.equal "/foo" - env["mock.postdata"].should.equal "" - end - - specify "should accept raw input in params for GET requests" do - res = Rack::MockRequest.new(app).get("/foo?baz=2", :params => "foo[bar]=1") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["QUERY_STRING"].should.match "baz=2" - env["QUERY_STRING"].should.match "foo[bar]=1" - env["PATH_INFO"].should.equal "/foo" - env["mock.postdata"].should.equal "" - end - - specify "should accept params and build url encoded params for POST requests" do - res = Rack::MockRequest.new(app).post("/foo", :params => {:foo => {:bar => "1"}}) - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "POST" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/foo" - env["CONTENT_TYPE"].should.equal "application/x-www-form-urlencoded" - env["mock.postdata"].should.equal "foo[bar]=1" - end - - specify "should accept raw input in params for POST requests" do - res = Rack::MockRequest.new(app).post("/foo", :params => "foo[bar]=1") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "POST" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/foo" - env["CONTENT_TYPE"].should.equal "application/x-www-form-urlencoded" - env["mock.postdata"].should.equal "foo[bar]=1" - end - - specify "should accept params and build multipart encoded params for POST requests" do - files = Rack::Utils::Multipart::UploadedFile.new(File.join(File.dirname(__FILE__), "multipart", "file1.txt")) - res = Rack::MockRequest.new(app).post("/foo", :params => { "submit-name" => "Larry", "files" => files }) - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "POST" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/foo" - env["CONTENT_TYPE"].should.equal "multipart/form-data; boundary=AaB03x" - env["mock.postdata"].length.should.equal 206 - end - - specify "should behave valid according to the Rack spec" do - lambda { - res = Rack::MockRequest.new(app). - get("https://bla.example.org:9292/meh/foo?bar", :lint => true) - }.should.not.raise(Rack::Lint::LintError) - end -end - -context "Rack::MockResponse" do - specify "should provide access to the HTTP status" do - res = Rack::MockRequest.new(app).get("") - res.should.be.successful - res.should.be.ok - - res = Rack::MockRequest.new(app).get("/?status=404") - res.should.not.be.successful - res.should.be.client_error - res.should.be.not_found - - res = Rack::MockRequest.new(app).get("/?status=501") - res.should.not.be.successful - res.should.be.server_error - - res = Rack::MockRequest.new(app).get("/?status=307") - res.should.be.redirect - - res = Rack::MockRequest.new(app).get("/?status=201", :lint => true) - res.should.be.empty - end - - specify "should provide access to the HTTP headers" do - res = Rack::MockRequest.new(app).get("") - res.should.include "Content-Type" - res.headers["Content-Type"].should.equal "text/yaml" - res.original_headers["Content-Type"].should.equal "text/yaml" - res["Content-Type"].should.equal "text/yaml" - res.content_type.should.equal "text/yaml" - res.content_length.should.be 414 # needs change often. - res.location.should.be.nil - end - - specify "should provide access to the HTTP body" do - res = Rack::MockRequest.new(app).get("") - res.body.should =~ /rack/ - res.should =~ /rack/ - res.should.match(/rack/) - res.should.satisfy { |r| r.match(/rack/) } - end - - specify "should provide access to the Rack errors" do - res = Rack::MockRequest.new(app).get("/?error=foo", :lint => true) - res.should.be.ok - res.errors.should.not.be.empty - res.errors.should.include "foo" - end - - specify "should optionally make Rack errors fatal" do - lambda { - Rack::MockRequest.new(app).get("/?error=foo", :fatal => true) - }.should.raise(Rack::MockRequest::FatalWarning) - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_mongrel.rb b/vendor/gems/rack-1.1.0/test/spec_rack_mongrel.rb deleted file mode 100644 index 4b386891..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_mongrel.rb +++ /dev/null @@ -1,189 +0,0 @@ -require 'test/spec' - -begin -require 'rack/handler/mongrel' -require 'rack/urlmap' -require 'rack/lint' -require 'testrequest' -require 'timeout' - -Thread.abort_on_exception = true -$tcp_defer_accept_opts = nil -$tcp_cork_opts = nil - -context "Rack::Handler::Mongrel" do - include TestRequest::Helpers - - setup do - server = Mongrel::HttpServer.new(@host='0.0.0.0', @port=9201) - server.register('/test', - Rack::Handler::Mongrel.new(Rack::Lint.new(TestRequest.new))) - server.register('/stream', - Rack::Handler::Mongrel.new(Rack::Lint.new(StreamingRequest))) - @acc = server.run - end - - specify "should respond" do - lambda { - GET("/test") - }.should.not.raise - end - - specify "should be a Mongrel" do - GET("/test") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /Mongrel/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal "9201" - response["SERVER_NAME"].should.equal "0.0.0.0" - end - - specify "should have rack headers" do - GET("/test") - response["rack.version"].should.equal [1,1] - response["rack.multithread"].should.be true - response["rack.multiprocess"].should.be false - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/test") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/test" - response["PATH_INFO"].should.be.equal "" - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/test/foo" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/test" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - specify "should provide a .run" do - block_ran = false - Thread.new { - Rack::Handler::Mongrel.run(lambda {}, {:Port => 9211}) { |server| - server.should.be.kind_of Mongrel::HttpServer - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should provide a .run that maps a hash" do - block_ran = false - Thread.new { - map = {'/'=>lambda{},'/foo'=>lambda{}} - Rack::Handler::Mongrel.run(map, :map => true, :Port => 9221) { |server| - server.should.be.kind_of Mongrel::HttpServer - server.classifier.uris.size.should.be 2 - server.classifier.uris.should.not.include '/arf' - server.classifier.uris.should.include '/' - server.classifier.uris.should.include '/foo' - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should provide a .run that maps a urlmap" do - block_ran = false - Thread.new { - map = Rack::URLMap.new({'/'=>lambda{},'/bar'=>lambda{}}) - Rack::Handler::Mongrel.run(map, {:map => true, :Port => 9231}) { |server| - server.should.be.kind_of Mongrel::HttpServer - server.classifier.uris.size.should.be 2 - server.classifier.uris.should.not.include '/arf' - server.classifier.uris.should.include '/' - server.classifier.uris.should.include '/bar' - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should provide a .run that maps a urlmap restricting by host" do - block_ran = false - Thread.new { - map = Rack::URLMap.new({ - '/' => lambda{}, - '/foo' => lambda{}, - '/bar' => lambda{}, - 'http://localhost/' => lambda{}, - 'http://localhost/bar' => lambda{}, - 'http://falsehost/arf' => lambda{}, - 'http://falsehost/qux' => lambda{} - }) - opt = {:map => true, :Port => 9241, :Host => 'localhost'} - Rack::Handler::Mongrel.run(map, opt) { |server| - server.should.be.kind_of Mongrel::HttpServer - server.classifier.uris.should.include '/' - server.classifier.handler_map['/'].size.should.be 2 - server.classifier.uris.should.include '/foo' - server.classifier.handler_map['/foo'].size.should.be 1 - server.classifier.uris.should.include '/bar' - server.classifier.handler_map['/bar'].size.should.be 2 - server.classifier.uris.should.not.include '/qux' - server.classifier.uris.should.not.include '/arf' - server.classifier.uris.size.should.be 3 - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should stream #each part of the response" do - body = '' - begin - Timeout.timeout(1) do - Net::HTTP.start(@host, @port) do |http| - get = Net::HTTP::Get.new('/stream') - http.request(get) do |response| - response.read_body { |part| body << part } - end - end - end - rescue Timeout::Error - end - body.should.not.be.empty - end - - teardown do - @acc.raise Mongrel::StopServer - end -end - -rescue LoadError - $stderr.puts "Skipping Rack::Handler::Mongrel tests (Mongrel is required). `gem install mongrel` and try again." -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_nulllogger.rb b/vendor/gems/rack-1.1.0/test/spec_rack_nulllogger.rb deleted file mode 100644 index b3c2bc9c..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_nulllogger.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'rack/nulllogger' -require 'rack/lint' -require 'rack/mock' - -context "Rack::NullLogger" do - specify "acks as a nop logger" do - app = lambda { |env| - env['rack.logger'].warn "b00m" - [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] - } - Rack::NullLogger.new(app).call({}) - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_recursive.rb b/vendor/gems/rack-1.1.0/test/spec_rack_recursive.rb deleted file mode 100644 index afc1a0d9..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_recursive.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'test/spec' - -require 'rack/recursive' -require 'rack/urlmap' -require 'rack/response' -require 'rack/mock' - -context "Rack::Recursive" do - setup do - - @app1 = lambda { |env| - res = Rack::Response.new - res["X-Path-Info"] = env["PATH_INFO"] - res["X-Query-String"] = env["QUERY_STRING"] - res.finish do |res| - res.write "App1" - end - } - - @app2 = lambda { |env| - Rack::Response.new.finish do |res| - res.write "App2" - _, _, body = env['rack.recursive.include'].call(env, "/app1") - body.each { |b| - res.write b - } - end - } - - @app3 = lambda { |env| - raise Rack::ForwardRequest.new("/app1") - } - - @app4 = lambda { |env| - raise Rack::ForwardRequest.new("http://example.org/app1/quux?meh") - } - - end - - specify "should allow for subrequests" do - res = Rack::MockRequest.new(Rack::Recursive.new( - Rack::URLMap.new("/app1" => @app1, - "/app2" => @app2))). - get("/app2") - - res.should.be.ok - res.body.should.equal "App2App1" - end - - specify "should raise error on requests not below the app" do - app = Rack::URLMap.new("/app1" => @app1, - "/app" => Rack::Recursive.new( - Rack::URLMap.new("/1" => @app1, - "/2" => @app2))) - - lambda { - Rack::MockRequest.new(app).get("/app/2") - }.should.raise(ArgumentError). - message.should =~ /can only include below/ - end - - specify "should support forwarding" do - app = Rack::Recursive.new(Rack::URLMap.new("/app1" => @app1, - "/app3" => @app3, - "/app4" => @app4)) - - res = Rack::MockRequest.new(app).get("/app3") - res.should.be.ok - res.body.should.equal "App1" - - res = Rack::MockRequest.new(app).get("/app4") - res.should.be.ok - res.body.should.equal "App1" - res["X-Path-Info"].should.equal "/quux" - res["X-Query-String"].should.equal "meh" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_request.rb b/vendor/gems/rack-1.1.0/test/spec_rack_request.rb deleted file mode 100644 index fcdeb484..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_request.rb +++ /dev/null @@ -1,545 +0,0 @@ -require 'test/spec' -require 'stringio' - -require 'rack/request' -require 'rack/mock' - -context "Rack::Request" do - specify "wraps the rack variables" do - req = Rack::Request.new(Rack::MockRequest.env_for("http://example.com:8080/")) - - req.body.should.respond_to? :gets - req.scheme.should.equal "http" - req.request_method.should.equal "GET" - - req.should.be.get - req.should.not.be.post - req.should.not.be.put - req.should.not.be.delete - req.should.not.be.head - - req.script_name.should.equal "" - req.path_info.should.equal "/" - req.query_string.should.equal "" - - req.host.should.equal "example.com" - req.port.should.equal 8080 - - req.content_length.should.equal "0" - req.content_type.should.be.nil - end - - specify "can figure out the correct host" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "HTTP_HOST" => "www2.example.org") - req.host.should.equal "www2.example.org" - - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "SERVER_NAME" => "example.org", "SERVER_PORT" => "9292") - req.host.should.equal "example.org" - - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "HTTP_HOST" => "localhost:81", "HTTP_X_FORWARDED_HOST" => "example.org:9292") - req.host.should.equal "example.org" - - env = Rack::MockRequest.env_for("/", "SERVER_ADDR" => "192.168.1.1", "SERVER_PORT" => "9292") - env.delete("SERVER_NAME") - req = Rack::Request.new(env) - req.host.should.equal "192.168.1.1" - - env = Rack::MockRequest.env_for("/") - env.delete("SERVER_NAME") - req = Rack::Request.new(env) - req.host.should.equal "" - end - - specify "can parse the query string" do - req = Rack::Request.new(Rack::MockRequest.env_for("/?foo=bar&quux=bla")) - req.query_string.should.equal "foo=bar&quux=bla" - req.GET.should.equal "foo" => "bar", "quux" => "bla" - req.POST.should.be.empty - req.params.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "raises if rack.input is missing" do - req = Rack::Request.new({}) - lambda { req.POST }.should.raise(RuntimeError) - end - - specify "can parse POST data when method is POST and no Content-Type given" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", - "REQUEST_METHOD" => 'POST', - :input => "foo=bar&quux=bla") - req.content_type.should.be.nil - req.media_type.should.be.nil - req.query_string.should.equal "foo=quux" - req.GET.should.equal "foo" => "quux" - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.params.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "can parse POST data with explicit content type regardless of method" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'application/x-www-form-urlencoded;foo=bar', - :input => "foo=bar&quux=bla") - req.content_type.should.equal 'application/x-www-form-urlencoded;foo=bar' - req.media_type.should.equal 'application/x-www-form-urlencoded' - req.media_type_params['foo'].should.equal 'bar' - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.params.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "does not parse POST data when media type is not form-data" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", - "REQUEST_METHOD" => 'POST', - "CONTENT_TYPE" => 'text/plain;charset=utf-8', - :input => "foo=bar&quux=bla") - req.content_type.should.equal 'text/plain;charset=utf-8' - req.media_type.should.equal 'text/plain' - req.media_type_params['charset'].should.equal 'utf-8' - req.POST.should.be.empty - req.params.should.equal "foo" => "quux" - req.body.read.should.equal "foo=bar&quux=bla" - end - - specify "can parse POST data on PUT when media type is form-data" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", - "REQUEST_METHOD" => 'PUT', - "CONTENT_TYPE" => 'application/x-www-form-urlencoded', - :input => "foo=bar&quux=bla") - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.body.read.should.equal "foo=bar&quux=bla" - end - - specify "rewinds input after parsing POST data" do - input = StringIO.new("foo=bar&quux=bla") - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'application/x-www-form-urlencoded;foo=bar', - :input => input) - req.params.should.equal "foo" => "bar", "quux" => "bla" - input.read.should.equal "foo=bar&quux=bla" - end - - specify "cleans up Safari's ajax POST body" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - 'REQUEST_METHOD' => 'POST', :input => "foo=bar&quux=bla\0") - req.POST.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "can get value by key from params with #[]" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("?foo=quux") - req['foo'].should.equal 'quux' - req[:foo].should.equal 'quux' - end - - specify "can set value to key on params with #[]=" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("?foo=duh") - req['foo'].should.equal 'duh' - req[:foo].should.equal 'duh' - req.params.should.equal 'foo' => 'duh' - - req['foo'] = 'bar' - req.params.should.equal 'foo' => 'bar' - req['foo'].should.equal 'bar' - req[:foo].should.equal 'bar' - - req[:foo] = 'jaz' - req.params.should.equal 'foo' => 'jaz' - req['foo'].should.equal 'jaz' - req[:foo].should.equal 'jaz' - end - - specify "values_at answers values by keys in order given" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("?foo=baz&wun=der&bar=ful") - req.values_at('foo').should.equal ['baz'] - req.values_at('foo', 'wun').should.equal ['baz', 'der'] - req.values_at('bar', 'foo', 'wun').should.equal ['ful', 'baz', 'der'] - end - - specify "referrer should be extracted correct" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "HTTP_REFERER" => "/some/path") - req.referer.should.equal "/some/path" - - req = Rack::Request.new \ - Rack::MockRequest.env_for("/") - req.referer.should.equal "/" - end - - specify "user agent should be extracted correct" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "HTTP_USER_AGENT" => "Mozilla/4.0 (compatible)") - req.user_agent.should.equal "Mozilla/4.0 (compatible)" - - req = Rack::Request.new \ - Rack::MockRequest.env_for("/") - req.user_agent.should.equal nil - end - - specify "can cache, but invalidates the cache" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", - "CONTENT_TYPE" => "application/x-www-form-urlencoded", - :input => "foo=bar&quux=bla") - req.GET.should.equal "foo" => "quux" - req.GET.should.equal "foo" => "quux" - req.env["QUERY_STRING"] = "bla=foo" - req.GET.should.equal "bla" => "foo" - req.GET.should.equal "bla" => "foo" - - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.env["rack.input"] = StringIO.new("foo=bla&quux=bar") - req.POST.should.equal "foo" => "bla", "quux" => "bar" - req.POST.should.equal "foo" => "bla", "quux" => "bar" - end - - specify "can figure out if called via XHR" do - req = Rack::Request.new(Rack::MockRequest.env_for("")) - req.should.not.be.xhr - - req = Rack::Request.new \ - Rack::MockRequest.env_for("", "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest") - req.should.be.xhr - end - - specify "can parse cookies" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("", "HTTP_COOKIE" => "foo=bar;quux=h&m") - req.cookies.should.equal "foo" => "bar", "quux" => "h&m" - req.cookies.should.equal "foo" => "bar", "quux" => "h&m" - req.env.delete("HTTP_COOKIE") - req.cookies.should.equal({}) - end - - specify "parses cookies according to RFC 2109" do - req = Rack::Request.new \ - Rack::MockRequest.env_for('', 'HTTP_COOKIE' => 'foo=bar;foo=car') - req.cookies.should.equal 'foo' => 'bar' - end - - specify "provides setters" do - req = Rack::Request.new(e=Rack::MockRequest.env_for("")) - req.script_name.should.equal "" - req.script_name = "/foo" - req.script_name.should.equal "/foo" - e["SCRIPT_NAME"].should.equal "/foo" - - req.path_info.should.equal "/" - req.path_info = "/foo" - req.path_info.should.equal "/foo" - e["PATH_INFO"].should.equal "/foo" - end - - specify "provides the original env" do - req = Rack::Request.new(e=Rack::MockRequest.env_for("")) - req.env.should.be e - end - - specify "can restore the URL" do - Rack::Request.new(Rack::MockRequest.env_for("")).url. - should.equal "http://example.org/" - Rack::Request.new(Rack::MockRequest.env_for("", "SCRIPT_NAME" => "/foo")).url. - should.equal "http://example.org/foo/" - Rack::Request.new(Rack::MockRequest.env_for("/foo")).url. - should.equal "http://example.org/foo" - Rack::Request.new(Rack::MockRequest.env_for("?foo")).url. - should.equal "http://example.org/?foo" - Rack::Request.new(Rack::MockRequest.env_for("http://example.org:8080/")).url. - should.equal "http://example.org:8080/" - Rack::Request.new(Rack::MockRequest.env_for("https://example.org/")).url. - should.equal "https://example.org/" - - Rack::Request.new(Rack::MockRequest.env_for("https://example.com:8080/foo?foo")).url. - should.equal "https://example.com:8080/foo?foo" - end - - specify "can restore the full path" do - Rack::Request.new(Rack::MockRequest.env_for("")).fullpath. - should.equal "/" - Rack::Request.new(Rack::MockRequest.env_for("", "SCRIPT_NAME" => "/foo")).fullpath. - should.equal "/foo/" - Rack::Request.new(Rack::MockRequest.env_for("/foo")).fullpath. - should.equal "/foo" - Rack::Request.new(Rack::MockRequest.env_for("?foo")).fullpath. - should.equal "/?foo" - Rack::Request.new(Rack::MockRequest.env_for("http://example.org:8080/")).fullpath. - should.equal "/" - Rack::Request.new(Rack::MockRequest.env_for("https://example.org/")).fullpath. - should.equal "/" - - Rack::Request.new(Rack::MockRequest.env_for("https://example.com:8080/foo?foo")).fullpath. - should.equal "/foo?foo" - end - - specify "can handle multiple media type parameters" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'text/plain; foo=BAR,baz=bizzle dizzle;BLING=bam') - req.should.not.be.form_data - req.media_type_params.should.include 'foo' - req.media_type_params['foo'].should.equal 'BAR' - req.media_type_params.should.include 'baz' - req.media_type_params['baz'].should.equal 'bizzle dizzle' - req.media_type_params.should.not.include 'BLING' - req.media_type_params.should.include 'bling' - req.media_type_params['bling'].should.equal 'bam' - end - - specify "can parse multipart form data" do - # Adapted from RFC 1867. - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - req.POST.should.include "fileupload" - req.POST.should.include "reply" - - req.should.be.form_data - req.content_length.should.equal input.size - req.media_type.should.equal 'multipart/form-data' - req.media_type_params.should.include 'boundary' - req.media_type_params['boundary'].should.equal 'AaB03x' - - req.POST["reply"].should.equal "yes" - - f = req.POST["fileupload"] - f.should.be.kind_of Hash - f[:type].should.equal "image/jpeg" - f[:filename].should.equal "dj.jpg" - f.should.include :tempfile - f[:tempfile].size.should.equal 76 - end - - specify "can parse big multipart form data" do - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - req.POST["huge"][:tempfile].size.should.equal 32768 - req.POST["mean"][:tempfile].size.should.equal 10 - req.POST["mean"][:tempfile].read.should.equal "--AaB03xha" - end - - specify "can detect invalid multipart form data" do - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda { req.POST }.should.raise(EOFError) - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda { req.POST }.should.raise(EOFError) - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda { req.POST }.should.raise(EOFError) - end - - specify "shouldn't try to interpret binary as utf8" do - begin - original_kcode = $KCODE - $KCODE='UTF8' - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda{req.POST}.should.not.raise(EOFError) - req.POST["fileupload"][:tempfile].size.should.equal 4 - ensure - $KCODE = original_kcode - end - end - - - specify "should work around buggy 1.8.* Tempfile equality" do - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => rack_input) - - lambda {req.POST}.should.not.raise - lambda {req.POST}.should.blaming("input re-processed!").not.raise - end - - specify "does conform to the Rack spec" do - app = lambda { |env| - content = Rack::Request.new(env).POST["file"].inspect - size = content.respond_to?(:bytesize) ? content.bytesize : content.size - [200, {"Content-Type" => "text/html", "Content-Length" => size.to_s}, [content]] - } - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size.to_s, "rack.input" => StringIO.new(input) - - res.should.be.ok - end - - specify "should parse Accept-Encoding correctly" do - parser = lambda do |x| - Rack::Request.new(Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => x)).accept_encoding - end - - parser.call(nil).should.equal([]) - - parser.call("compress, gzip").should.equal([["compress", 1.0], ["gzip", 1.0]]) - parser.call("").should.equal([]) - parser.call("*").should.equal([["*", 1.0]]) - parser.call("compress;q=0.5, gzip;q=1.0").should.equal([["compress", 0.5], ["gzip", 1.0]]) - parser.call("gzip;q=1.0, identity; q=0.5, *;q=0").should.equal([["gzip", 1.0], ["identity", 0.5], ["*", 0] ]) - - lambda { parser.call("gzip ; q=1.0") }.should.raise(RuntimeError) - end - - specify 'should provide ip information' do - app = lambda { |env| - request = Rack::Request.new(env) - response = Rack::Response.new - response.write request.ip - response.finish - } - - mock = Rack::MockRequest.new(Rack::Lint.new(app)) - res = mock.get '/', 'REMOTE_ADDR' => '123.123.123.123' - res.body.should.equal '123.123.123.123' - - res = mock.get '/', - 'REMOTE_ADDR' => '123.123.123.123', - 'HTTP_X_FORWARDED_FOR' => '234.234.234.234' - - res.body.should.equal '234.234.234.234' - - res = mock.get '/', - 'REMOTE_ADDR' => '123.123.123.123', - 'HTTP_X_FORWARDED_FOR' => '234.234.234.234,212.212.212.212' - - res.body.should.equal '212.212.212.212' - end - - class MyRequest < Rack::Request - def params - {:foo => "bar"} - end - end - - specify "should allow subclass request to be instantiated after parent request" do - env = Rack::MockRequest.env_for("/?foo=bar") - - req1 = Rack::Request.new(env) - req1.GET.should.equal "foo" => "bar" - req1.params.should.equal "foo" => "bar" - - req2 = MyRequest.new(env) - req2.GET.should.equal "foo" => "bar" - req2.params.should.equal :foo => "bar" - end - - specify "should allow parent request to be instantiated after subclass request" do - env = Rack::MockRequest.env_for("/?foo=bar") - - req1 = MyRequest.new(env) - req1.GET.should.equal "foo" => "bar" - req1.params.should.equal :foo => "bar" - - req2 = Rack::Request.new(env) - req2.GET.should.equal "foo" => "bar" - req2.params.should.equal "foo" => "bar" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_response.rb b/vendor/gems/rack-1.1.0/test/spec_rack_response.rb deleted file mode 100644 index 7989013d..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_response.rb +++ /dev/null @@ -1,221 +0,0 @@ -require 'test/spec' -require 'set' - -require 'rack/response' - -context "Rack::Response" do - specify "has sensible default values" do - response = Rack::Response.new - status, header, body = response.finish - status.should.equal 200 - header.should.equal "Content-Type" => "text/html" - body.each { |part| - part.should.equal "" - } - - response = Rack::Response.new - status, header, body = *response - status.should.equal 200 - header.should.equal "Content-Type" => "text/html" - body.each { |part| - part.should.equal "" - } - end - - specify "can be written to" do - response = Rack::Response.new - - status, header, body = response.finish do - response.write "foo" - response.write "bar" - response.write "baz" - end - - parts = [] - body.each { |part| parts << part } - - parts.should.equal ["foo", "bar", "baz"] - end - - specify "can set and read headers" do - response = Rack::Response.new - response["Content-Type"].should.equal "text/html" - response["Content-Type"] = "text/plain" - response["Content-Type"].should.equal "text/plain" - end - - specify "can set cookies" do - response = Rack::Response.new - - response.set_cookie "foo", "bar" - response["Set-Cookie"].should.equal "foo=bar" - response.set_cookie "foo2", "bar2" - response["Set-Cookie"].should.equal ["foo=bar", "foo2=bar2"] - response.set_cookie "foo3", "bar3" - response["Set-Cookie"].should.equal ["foo=bar", "foo2=bar2", "foo3=bar3"] - end - - specify "formats the Cookie expiration date accordingly to RFC 2109" do - response = Rack::Response.new - - response.set_cookie "foo", {:value => "bar", :expires => Time.now+10} - response["Set-Cookie"].should.match( - /expires=..., \d\d-...-\d\d\d\d \d\d:\d\d:\d\d .../) - end - - specify "can set secure cookies" do - response = Rack::Response.new - response.set_cookie "foo", {:value => "bar", :secure => true} - response["Set-Cookie"].should.equal "foo=bar; secure" - end - - specify "can set http only cookies" do - response = Rack::Response.new - response.set_cookie "foo", {:value => "bar", :httponly => true} - response["Set-Cookie"].should.equal "foo=bar; HttpOnly" - end - - specify "can delete cookies" do - response = Rack::Response.new - response.set_cookie "foo", "bar" - response.set_cookie "foo2", "bar2" - response.delete_cookie "foo" - response["Set-Cookie"].should.equal ["foo2=bar2", - "foo=; expires=Thu, 01-Jan-1970 00:00:00 GMT"] - end - - specify "can do redirects" do - response = Rack::Response.new - response.redirect "/foo" - status, header, body = response.finish - - status.should.equal 302 - header["Location"].should.equal "/foo" - - response = Rack::Response.new - response.redirect "/foo", 307 - status, header, body = response.finish - - status.should.equal 307 - end - - specify "has a useful constructor" do - r = Rack::Response.new("foo") - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foo" - - r = Rack::Response.new(["foo", "bar"]) - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foobar" - - r = Rack::Response.new(["foo", "bar"].to_set) - r.write "foo" - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foobarfoo" - - r = Rack::Response.new([], 500) - r.status.should.equal 500 - - r = Rack::Response.new([], "200 OK") - r.status.should.equal 200 - end - - specify "has a constructor that can take a block" do - r = Rack::Response.new { |res| - res.status = 404 - res.write "foo" - } - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foo" - status.should.equal 404 - end - - specify "doesn't return invalid responses" do - r = Rack::Response.new(["foo", "bar"], 204) - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.be.empty - header["Content-Type"].should.equal nil - - lambda { - Rack::Response.new(Object.new) - }.should.raise(TypeError). - message.should =~ /stringable or iterable required/ - end - - specify "knows if it's empty" do - r = Rack::Response.new - r.should.be.empty - r.write "foo" - r.should.not.be.empty - - r = Rack::Response.new - r.should.be.empty - r.finish - r.should.be.empty - - r = Rack::Response.new - r.should.be.empty - r.finish { } - r.should.not.be.empty - end - - specify "should provide access to the HTTP status" do - res = Rack::Response.new - res.status = 200 - res.should.be.successful - res.should.be.ok - - res.status = 404 - res.should.not.be.successful - res.should.be.client_error - res.should.be.not_found - - res.status = 501 - res.should.not.be.successful - res.should.be.server_error - - res.status = 307 - res.should.be.redirect - end - - specify "should provide access to the HTTP headers" do - res = Rack::Response.new - res["Content-Type"] = "text/yaml" - - res.should.include "Content-Type" - res.headers["Content-Type"].should.equal "text/yaml" - res["Content-Type"].should.equal "text/yaml" - res.content_type.should.equal "text/yaml" - res.content_length.should.be.nil - res.location.should.be.nil - end - - specify "does not add or change Content-Length when #finish()ing" do - res = Rack::Response.new - res.status = 200 - res.finish - res.headers["Content-Length"].should.be.nil - - res = Rack::Response.new - res.status = 200 - res.headers["Content-Length"] = "10" - res.finish - res.headers["Content-Length"].should.equal "10" - end - - specify "updates Content-Length when body appended to using #write" do - res = Rack::Response.new - res.status = 200 - res.headers["Content-Length"].should.be.nil - res.write "Hi" - res.headers["Content-Length"].should.equal "2" - res.write " there" - res.headers["Content-Length"].should.equal "8" - end - -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_rewindable_input.rb b/vendor/gems/rack-1.1.0/test/spec_rack_rewindable_input.rb deleted file mode 100644 index 78bebfc9..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_rewindable_input.rb +++ /dev/null @@ -1,118 +0,0 @@ -require 'test/spec' -require 'stringio' -require 'rack/rewindable_input' - -shared_context "a rewindable IO object" do - setup do - @rio = Rack::RewindableInput.new(@io) - end - - teardown do - @rio.close - end - - specify "should be able to handle to read()" do - @rio.read.should.equal "hello world" - end - - specify "should be able to handle to read(nil)" do - @rio.read(nil).should.equal "hello world" - end - - specify "should be able to handle to read(length)" do - @rio.read(1).should.equal "h" - end - - specify "should be able to handle to read(length, buffer)" do - buffer = "" - result = @rio.read(1, buffer) - result.should.equal "h" - result.object_id.should.equal buffer.object_id - end - - specify "should be able to handle to read(nil, buffer)" do - buffer = "" - result = @rio.read(nil, buffer) - result.should.equal "hello world" - result.object_id.should.equal buffer.object_id - end - - specify "should rewind to the beginning when #rewind is called" do - @rio.read(1) - @rio.rewind - @rio.read.should.equal "hello world" - end - - specify "should be able to handle gets" do - @rio.gets.should == "hello world" - end - - specify "should be able to handle each" do - array = [] - @rio.each do |data| - array << data - end - array.should.equal(["hello world"]) - end - - specify "should not buffer into a Tempfile if no data has been read yet" do - @rio.instance_variable_get(:@rewindable_io).should.be.nil - end - - specify "should buffer into a Tempfile when data has been consumed for the first time" do - @rio.read(1) - tempfile = @rio.instance_variable_get(:@rewindable_io) - tempfile.should.not.be.nil - @rio.read(1) - tempfile2 = @rio.instance_variable_get(:@rewindable_io) - tempfile2.should.equal tempfile - end - - specify "should close the underlying tempfile upon calling #close" do - @rio.read(1) - tempfile = @rio.instance_variable_get(:@rewindable_io) - @rio.close - tempfile.should.be.closed - end - - specify "should be possibel to call #close when no data has been buffered yet" do - @rio.close - end - - specify "should be possible to call #close multiple times" do - @rio.close - @rio.close - end -end - -context "Rack::RewindableInput" do - context "given an IO object that is already rewindable" do - setup do - @io = StringIO.new("hello world") - end - - it_should_behave_like "a rewindable IO object" - end - - context "given an IO object that is not rewindable" do - setup do - @io = StringIO.new("hello world") - @io.instance_eval do - undef :rewind - end - end - - it_should_behave_like "a rewindable IO object" - end - - context "given an IO object whose rewind method raises Errno::ESPIPE" do - setup do - @io = StringIO.new("hello world") - def @io.rewind - raise Errno::ESPIPE, "You can't rewind this!" - end - end - - it_should_behave_like "a rewindable IO object" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_runtime.rb b/vendor/gems/rack-1.1.0/test/spec_rack_runtime.rb deleted file mode 100644 index 62d80956..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_runtime.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'test/spec' -require 'rack/mock' -require 'rack/runtime' - -context "Rack::Runtime" do - specify "sets X-Runtime is none is set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] } - response = Rack::Runtime.new(app).call({}) - response[1]['X-Runtime'].should =~ /[\d\.]+/ - end - - specify "does not set the X-Runtime if it is already set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain', "X-Runtime" => "foobar"}, "Hello, World!"] } - response = Rack::Runtime.new(app).call({}) - response[1]['X-Runtime'].should == "foobar" - end - - specify "should allow a suffix to be set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] } - response = Rack::Runtime.new(app, "Test").call({}) - response[1]['X-Runtime-Test'].should =~ /[\d\.]+/ - end - - specify "should allow multiple timers to be set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] } - runtime1 = Rack::Runtime.new(app, "App") - runtime2 = Rack::Runtime.new(runtime1, "All") - response = runtime2.call({}) - - response[1]['X-Runtime-App'].should =~ /[\d\.]+/ - response[1]['X-Runtime-All'].should =~ /[\d\.]+/ - - Float(response[1]['X-Runtime-All']).should > Float(response[1]['X-Runtime-App']) - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_sendfile.rb b/vendor/gems/rack-1.1.0/test/spec_rack_sendfile.rb deleted file mode 100644 index 8cfe2017..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_sendfile.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'test/spec' -require 'rack/mock' -require 'rack/sendfile' - -context "Rack::File" do - specify "should respond to #to_path" do - Rack::File.new(Dir.pwd).should.respond_to :to_path - end -end - -context "Rack::Sendfile" do - def sendfile_body - res = ['Hello World'] - def res.to_path ; "/tmp/hello.txt" ; end - res - end - - def simple_app(body=sendfile_body) - lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] } - end - - def sendfile_app(body=sendfile_body) - Rack::Sendfile.new(simple_app(body)) - end - - setup do - @request = Rack::MockRequest.new(sendfile_app) - end - - def request(headers={}) - yield @request.get('/', headers) - end - - specify "does nothing when no X-Sendfile-Type header present" do - request do |response| - response.should.be.ok - response.body.should.equal 'Hello World' - response.headers.should.not.include 'X-Sendfile' - end - end - - specify "sets X-Sendfile response header and discards body" do - request 'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile' do |response| - response.should.be.ok - response.body.should.be.empty - response.headers['X-Sendfile'].should.equal '/tmp/hello.txt' - end - end - - specify "sets X-Lighttpd-Send-File response header and discards body" do - request 'HTTP_X_SENDFILE_TYPE' => 'X-Lighttpd-Send-File' do |response| - response.should.be.ok - response.body.should.be.empty - response.headers['X-Lighttpd-Send-File'].should.equal '/tmp/hello.txt' - end - end - - specify "sets X-Accel-Redirect response header and discards body" do - headers = { - 'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect', - 'HTTP_X_ACCEL_MAPPING' => '/tmp/=/foo/bar/' - } - request headers do |response| - response.should.be.ok - response.body.should.be.empty - response.headers['X-Accel-Redirect'].should.equal '/foo/bar/hello.txt' - end - end - - specify 'writes to rack.error when no X-Accel-Mapping is specified' do - request 'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect' do |response| - response.should.be.ok - response.body.should.equal 'Hello World' - response.headers.should.not.include 'X-Accel-Redirect' - response.errors.should.include 'X-Accel-Mapping' - end - end - - specify 'does nothing when body does not respond to #to_path' do - @request = Rack::MockRequest.new(sendfile_app(['Not a file...'])) - request 'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile' do |response| - response.body.should.equal 'Not a file...' - response.headers.should.not.include 'X-Sendfile' - end - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_session_cookie.rb b/vendor/gems/rack-1.1.0/test/spec_rack_session_cookie.rb deleted file mode 100644 index fba3f83b..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_session_cookie.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'test/spec' - -require 'rack/session/cookie' -require 'rack/mock' -require 'rack/response' - -context "Rack::Session::Cookie" do - incrementor = lambda { |env| - env["rack.session"]["counter"] ||= 0 - env["rack.session"]["counter"] += 1 - Rack::Response.new(env["rack.session"].inspect).to_a - } - - specify "creates a new cookie" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)).get("/") - res["Set-Cookie"].should.match("rack.session=") - res.body.should.equal '{"counter"=>1}' - end - - specify "loads from a cookie" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)).get("/") - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>2}' - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>3}' - end - - specify "survives broken cookies" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)). - get("/", "HTTP_COOKIE" => "rack.session=blarghfasel") - res.body.should.equal '{"counter"=>1}' - end - - bigcookie = lambda { |env| - env["rack.session"]["cookie"] = "big" * 3000 - Rack::Response.new(env["rack.session"].inspect).to_a - } - - specify "barks on too big cookies" do - lambda { - Rack::MockRequest.new(Rack::Session::Cookie.new(bigcookie)). - get("/", :fatal => true) - }.should.raise(Rack::MockRequest::FatalWarning) - end - - specify "loads from a cookie wih integrity hash" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')).get("/") - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>2}' - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>3}' - end - - specify "ignores tampered with session cookies" do - app = Rack::Session::Cookie.new(incrementor, :secret => 'test') - response1 = Rack::MockRequest.new(app).get("/") - _, digest = response1["Set-Cookie"].split("--") - tampered_with_cookie = "hackerman-was-here" + "--" + digest - response2 = Rack::MockRequest.new(app).get("/", "HTTP_COOKIE" => - tampered_with_cookie) - - # The tampered-with cookie is ignored, so we get back an identical Set-Cookie - response2["Set-Cookie"].should.equal(response1["Set-Cookie"]) - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_session_memcache.rb b/vendor/gems/rack-1.1.0/test/spec_rack_session_memcache.rb deleted file mode 100644 index faac796e..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_session_memcache.rb +++ /dev/null @@ -1,273 +0,0 @@ -require 'test/spec' - -begin - require 'rack/session/memcache' - require 'rack/mock' - require 'rack/response' - require 'thread' - - context "Rack::Session::Memcache" do - session_key = Rack::Session::Memcache::DEFAULT_OPTIONS[:key] - session_match = /#{session_key}=([0-9a-fA-F]+);/ - incrementor = lambda do |env| - env["rack.session"]["counter"] ||= 0 - env["rack.session"]["counter"] += 1 - Rack::Response.new(env["rack.session"].inspect).to_a - end - drop_session = proc do |env| - env['rack.session.options'][:drop] = true - incrementor.call(env) - end - renew_session = proc do |env| - env['rack.session.options'][:renew] = true - incrementor.call(env) - end - defer_session = proc do |env| - env['rack.session.options'][:defer] = true - incrementor.call(env) - end - - specify "faults on no connection" do - if RUBY_VERSION < "1.9" - lambda do - Rack::Session::Memcache.new incrementor, :memcache_server => 'nosuchserver' - end.should.raise - else - lambda do - Rack::Session::Memcache.new incrementor, :memcache_server => 'nosuchserver' - end.should.raise ArgumentError - end - end - - specify "connect to existing server" do - test_pool = MemCache.new incrementor, :namespace => 'test:rack:session' - end - - specify "creates a new cookie" do - pool = Rack::Session::Memcache.new(incrementor) - res = Rack::MockRequest.new(pool).get("/") - res["Set-Cookie"].should.match("#{session_key}=") - res.body.should.equal '{"counter"=>1}' - end - - specify "determines session from a cookie" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - res = req.get("/") - cookie = res["Set-Cookie"] - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>2}' - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>3}' - end - - specify "survives nonexistant cookies" do - bad_cookie = "rack.session=blarghfasel" - pool = Rack::Session::Memcache.new(incrementor) - res = Rack::MockRequest.new(pool). - get("/", "HTTP_COOKIE" => bad_cookie) - res.body.should.equal '{"counter"=>1}' - cookie = res["Set-Cookie"][session_match] - cookie.should.not.match(/#{bad_cookie}/) - end - - specify "maintains freshness" do - pool = Rack::Session::Memcache.new(incrementor, :expire_after => 3) - res = Rack::MockRequest.new(pool).get('/') - res.body.should.include '"counter"=>1' - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie) - res["Set-Cookie"].should.equal cookie - res.body.should.include '"counter"=>2' - puts 'Sleeping to expire session' if $DEBUG - sleep 4 - res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie) - res["Set-Cookie"].should.not.equal cookie - res.body.should.include '"counter"=>1' - end - - specify "deletes cookies with :drop option" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - drop = Rack::Utils::Context.new(pool, drop_session) - dreq = Rack::MockRequest.new(drop) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.not.equal session - res3.body.should.equal '{"counter"=>1}' - end - - specify "provides new session id with :renew option" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - renew = Rack::Utils::Context.new(pool, renew_session) - rreq = Rack::MockRequest.new(renew) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - - res2 = rreq.get("/", "HTTP_COOKIE" => cookie) - new_cookie = res2["Set-Cookie"] - new_session = new_cookie[session_match] - new_session.should.not.equal session - res2.body.should.equal '{"counter"=>3}' - - res3 = req.get("/", "HTTP_COOKIE" => new_cookie) - res3["Set-Cookie"][session_match].should.equal new_session - res3.body.should.equal '{"counter"=>4}' - end - - specify "omits cookie with :defer option" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - defer = Rack::Utils::Context.new(pool, defer_session) - dreq = Rack::MockRequest.new(defer) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.equal session - res3.body.should.equal '{"counter"=>4}' - end - - specify "deep hashes are correctly updated" do - store = nil - hash_check = proc do |env| - session = env['rack.session'] - unless session.include? 'test' - session.update :a => :b, :c => { :d => :e }, - :f => { :g => { :h => :i} }, 'test' => true - else - session[:f][:g][:h] = :j - end - [200, {}, session.inspect] - end - pool = Rack::Session::Memcache.new(hash_check) - req = Rack::MockRequest.new(pool) - - res0 = req.get("/") - session_id = (cookie = res0["Set-Cookie"])[session_match, 1] - ses0 = pool.pool.get(session_id, true) - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - ses1 = pool.pool.get(session_id, true) - - ses1.should.not.equal ses0 - end - - # anyone know how to do this better? - specify "multithread: should cleanly merge sessions" do - next unless $DEBUG - warn 'Running multithread test for Session::Memcache' - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - - res = req.get('/') - res.body.should.equal '{"counter"=>1}' - cookie = res["Set-Cookie"] - session_id = cookie[session_match, 1] - - delta_incrementor = lambda do |env| - # emulate disconjoinment of threading - env['rack.session'] = env['rack.session'].dup - Thread.stop - env['rack.session'][(Time.now.usec*rand).to_i] = true - incrementor.call(env) - end - tses = Rack::Utils::Context.new pool, delta_incrementor - treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 - r = Array.new(tnum) do - Thread.new(treq) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |request| - request['Set-Cookie'].should.equal cookie - request.body.should.include '"counter"=>2' - end - - session = pool.pool.get(session_id) - session.size.should.be tnum+1 # counter - session['counter'].should.be 2 # meeeh - - tnum = rand(7).to_i+5 - r = Array.new(tnum) do |i| - delta_time = proc do |env| - env['rack.session'][i] = Time.now - Thread.stop - env['rack.session'] = env['rack.session'].dup - env['rack.session'][i] -= Time.now - incrementor.call(env) - end - app = Rack::Utils::Context.new pool, time_delta - req = Rack::MockRequest.new app - Thread.new(req) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |request| - request['Set-Cookie'].should.equal cookie - request.body.should.include '"counter"=>3' - end - - session = pool.pool.get(session_id) - session.size.should.be tnum+1 - session['counter'].should.be 3 - - drop_counter = proc do |env| - env['rack.session'].delete 'counter' - env['rack.session']['foo'] = 'bar' - [200, {'Content-Type'=>'text/plain'}, env['rack.session'].inspect] - end - tses = Rack::Utils::Context.new pool, drop_counter - treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 - r = Array.new(tnum) do - Thread.new(treq) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |request| - request['Set-Cookie'].should.equal cookie - request.body.should.include '"foo"=>"bar"' - end - - session = pool.pool.get(session_id) - session.size.should.be r.size+1 - session['counter'].should.be.nil? - session['foo'].should.equal 'bar' - end - end -rescue RuntimeError - $stderr.puts "Skipping Rack::Session::Memcache tests. Start memcached and try again." -rescue LoadError - $stderr.puts "Skipping Rack::Session::Memcache tests (Memcache is required). `gem install memcache-client` and try again." -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_session_pool.rb b/vendor/gems/rack-1.1.0/test/spec_rack_session_pool.rb deleted file mode 100644 index 6be382ec..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_session_pool.rb +++ /dev/null @@ -1,172 +0,0 @@ -require 'test/spec' - -require 'rack/session/pool' -require 'rack/mock' -require 'rack/response' -require 'thread' - -context "Rack::Session::Pool" do - session_key = Rack::Session::Pool::DEFAULT_OPTIONS[:key] - session_match = /#{session_key}=[0-9a-fA-F]+;/ - incrementor = lambda do |env| - env["rack.session"]["counter"] ||= 0 - env["rack.session"]["counter"] += 1 - Rack::Response.new(env["rack.session"].inspect).to_a - end - drop_session = proc do |env| - env['rack.session.options'][:drop] = true - incrementor.call(env) - end - renew_session = proc do |env| - env['rack.session.options'][:renew] = true - incrementor.call(env) - end - defer_session = proc do |env| - env['rack.session.options'][:defer] = true - incrementor.call(env) - end - - specify "creates a new cookie" do - pool = Rack::Session::Pool.new(incrementor) - res = Rack::MockRequest.new(pool).get("/") - res["Set-Cookie"].should.match session_match - res.body.should.equal '{"counter"=>1}' - end - - specify "determines session from a cookie" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - cookie = req.get("/")["Set-Cookie"] - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>2}' - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>3}' - end - - specify "survives nonexistant cookies" do - pool = Rack::Session::Pool.new(incrementor) - res = Rack::MockRequest.new(pool). - get("/", "HTTP_COOKIE" => "#{session_key}=blarghfasel") - res.body.should.equal '{"counter"=>1}' - end - - specify "deletes cookies with :drop option" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - drop = Rack::Utils::Context.new(pool, drop_session) - dreq = Rack::MockRequest.new(drop) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - pool.pool.size.should.be 1 - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - pool.pool.size.should.be 0 - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.not.equal session - res3.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - end - - specify "provides new session id with :renew option" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - renew = Rack::Utils::Context.new(pool, renew_session) - rreq = Rack::MockRequest.new(renew) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - pool.pool.size.should.be 1 - - res2 = rreq.get("/", "HTTP_COOKIE" => cookie) - new_cookie = res2["Set-Cookie"] - new_session = new_cookie[session_match] - new_session.should.not.equal session - res2.body.should.equal '{"counter"=>3}' - pool.pool.size.should.be 1 - - res3 = req.get("/", "HTTP_COOKIE" => new_cookie) - res3["Set-Cookie"][session_match].should.equal new_session - res3.body.should.equal '{"counter"=>4}' - pool.pool.size.should.be 1 - end - - specify "omits cookie with :defer option" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - defer = Rack::Utils::Context.new(pool, defer_session) - dreq = Rack::MockRequest.new(defer) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - pool.pool.size.should.be 1 - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - pool.pool.size.should.be 1 - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.equal session - res3.body.should.equal '{"counter"=>4}' - pool.pool.size.should.be 1 - end - - # anyone know how to do this better? - specify "multithread: should merge sessions" do - next unless $DEBUG - warn 'Running multithread tests for Session::Pool' - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - - res = req.get('/') - res.body.should.equal '{"counter"=>1}' - cookie = res["Set-Cookie"] - sess_id = cookie[/#{pool.key}=([^,;]+)/,1] - - delta_incrementor = lambda do |env| - # emulate disconjoinment of threading - env['rack.session'] = env['rack.session'].dup - Thread.stop - env['rack.session'][(Time.now.usec*rand).to_i] = true - incrementor.call(env) - end - tses = Rack::Utils::Context.new pool, delta_incrementor - treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 - r = Array.new(tnum) do - Thread.new(treq) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |res| - res['Set-Cookie'].should.equal cookie - res.body.should.include '"counter"=>2' - end - - session = pool.pool[sess_id] - session.size.should.be tnum+1 # counter - session['counter'].should.be 2 # meeeh - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_showexceptions.rb b/vendor/gems/rack-1.1.0/test/spec_rack_showexceptions.rb deleted file mode 100644 index bdbc1201..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_showexceptions.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/spec' - -require 'rack/showexceptions' -require 'rack/mock' - -context "Rack::ShowExceptions" do - specify "catches exceptions" do - res = nil - req = Rack::MockRequest.new(Rack::ShowExceptions.new(lambda { |env| - raise RuntimeError - })) - lambda { - res = req.get("/") - }.should.not.raise - res.should.be.a.server_error - res.status.should.equal 500 - - res.should =~ /RuntimeError/ - res.should =~ /ShowExceptions/ - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_showstatus.rb b/vendor/gems/rack-1.1.0/test/spec_rack_showstatus.rb deleted file mode 100644 index 78700134..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_showstatus.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'test/spec' - -require 'rack/showstatus' -require 'rack/mock' - -context "Rack::ShowStatus" do - specify "should provide a default status message" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] - })) - - res = req.get("/", :lint => true) - res.should.be.not_found - res.should.be.not.empty - - res["Content-Type"].should.equal("text/html") - res.should =~ /404/ - res.should =~ /Not Found/ - end - - specify "should let the app provide additional information" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - env["rack.showstatus.detail"] = "gone too meta." - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] - })) - - res = req.get("/", :lint => true) - res.should.be.not_found - res.should.be.not.empty - - res["Content-Type"].should.equal("text/html") - res.should =~ /404/ - res.should =~ /Not Found/ - res.should =~ /too meta/ - end - - specify "should not replace existing messages" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - [404, {"Content-Type" => "text/plain", "Content-Length" => "4"}, ["foo!"]] - })) - res = req.get("/", :lint => true) - res.should.be.not_found - - res.body.should == "foo!" - end - - specify "should pass on original headers" do - headers = {"WWW-Authenticate" => "Basic blah"} - - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| [401, headers, []] })) - res = req.get("/", :lint => true) - - res["WWW-Authenticate"].should.equal("Basic blah") - end - - specify "should replace existing messages if there is detail" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - env["rack.showstatus.detail"] = "gone too meta." - [404, {"Content-Type" => "text/plain", "Content-Length" => "4"}, ["foo!"]] - })) - - res = req.get("/", :lint => true) - res.should.be.not_found - res.should.be.not.empty - - res["Content-Type"].should.equal("text/html") - res["Content-Length"].should.not.equal("4") - res.should =~ /404/ - res.should =~ /too meta/ - res.body.should.not =~ /foo/ - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_static.rb b/vendor/gems/rack-1.1.0/test/spec_rack_static.rb deleted file mode 100644 index 19d2ecb7..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_static.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'test/spec' - -require 'rack/static' -require 'rack/mock' - -class DummyApp - def call(env) - [200, {}, ["Hello World"]] - end -end - -context "Rack::Static" do - root = File.expand_path(File.dirname(__FILE__)) - OPTIONS = {:urls => ["/cgi"], :root => root} - - setup do - @request = Rack::MockRequest.new(Rack::Static.new(DummyApp.new, OPTIONS)) - end - - specify "serves files" do - res = @request.get("/cgi/test") - res.should.be.ok - res.body.should =~ /ruby/ - end - - specify "404s if url root is known but it can't find the file" do - res = @request.get("/cgi/foo") - res.should.be.not_found - end - - specify "calls down the chain if url root is not known" do - res = @request.get("/something/else") - res.should.be.ok - res.body.should == "Hello World" - end - -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_thin.rb b/vendor/gems/rack-1.1.0/test/spec_rack_thin.rb deleted file mode 100644 index 324f6498..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_thin.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'test/spec' - -begin -require 'rack/handler/thin' -require 'testrequest' -require 'timeout' - -context "Rack::Handler::Thin" do - include TestRequest::Helpers - - setup do - @app = Rack::Lint.new(TestRequest.new) - @server = nil - Thin::Logging.silent = true - @thread = Thread.new do - Rack::Handler::Thin.run(@app, :Host => @host='0.0.0.0', :Port => @port=9204) do |server| - @server = server - end - end - Thread.pass until @server && @server.running? - end - - specify "should respond" do - lambda { - GET("/") - }.should.not.raise - end - - specify "should be a Thin" do - GET("/") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /thin/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal "9204" - response["SERVER_NAME"].should.equal "0.0.0.0" - end - - specify "should have rack headers" do - GET("/") - response["rack.version"].should.equal [0,3] - response["rack.multithread"].should.be false - response["rack.multiprocess"].should.be false - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/") - response["REQUEST_METHOD"].should.equal "GET" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.be.equal "/" - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["REQUEST_PATH"].should.equal "/test/foo" - response["PATH_INFO"].should.equal "/test/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - teardown do - @server.stop! - @thread.kill - end -end - -rescue LoadError - $stderr.puts "Skipping Rack::Handler::Thin tests (Thin is required). `gem install thin` and try again." -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_urlmap.rb b/vendor/gems/rack-1.1.0/test/spec_rack_urlmap.rb deleted file mode 100644 index 3d8fe605..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_urlmap.rb +++ /dev/null @@ -1,215 +0,0 @@ -require 'test/spec' - -require 'rack/urlmap' -require 'rack/mock' - -context "Rack::URLMap" do - specify "dispatches paths correctly" do - app = lambda { |env| - [200, { - 'X-ScriptName' => env['SCRIPT_NAME'], - 'X-PathInfo' => env['PATH_INFO'], - 'Content-Type' => 'text/plain' - }, [""]] - } - map = Rack::URLMap.new({ - 'http://foo.org/bar' => app, - '/foo' => app, - '/foo/bar' => app - }) - - res = Rack::MockRequest.new(map).get("/") - res.should.be.not_found - - res = Rack::MockRequest.new(map).get("/qux") - res.should.be.not_found - - res = Rack::MockRequest.new(map).get("/foo") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo" - res["X-PathInfo"].should.equal "" - - res = Rack::MockRequest.new(map).get("/foo/") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo" - res["X-PathInfo"].should.equal "/" - - res = Rack::MockRequest.new(map).get("/foo/bar") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo/bar" - res["X-PathInfo"].should.equal "" - - res = Rack::MockRequest.new(map).get("/foo/bar/") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo/bar" - res["X-PathInfo"].should.equal "/" - - res = Rack::MockRequest.new(map).get("/foo///bar//quux") - res.status.should.equal 200 - res.should.be.ok - res["X-ScriptName"].should.equal "/foo/bar" - res["X-PathInfo"].should.equal "//quux" - - res = Rack::MockRequest.new(map).get("/foo/quux", "SCRIPT_NAME" => "/bleh") - res.should.be.ok - res["X-ScriptName"].should.equal "/bleh/foo" - res["X-PathInfo"].should.equal "/quux" - - res = Rack::MockRequest.new(map).get("/bar", 'HTTP_HOST' => 'foo.org') - res.should.be.ok - res["X-ScriptName"].should.equal "/bar" - res["X-PathInfo"].should.be.empty - - res = Rack::MockRequest.new(map).get("/bar/", 'HTTP_HOST' => 'foo.org') - res.should.be.ok - res["X-ScriptName"].should.equal "/bar" - res["X-PathInfo"].should.equal '/' - end - - - specify "dispatches hosts correctly" do - map = Rack::URLMap.new("http://foo.org/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "foo.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]}, - "http://subdomain.foo.org/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "subdomain.foo.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]}, - "http://bar.org/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "bar.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]}, - "/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "default.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]} - ) - - res = Rack::MockRequest.new(map).get("/") - res.should.be.ok - res["X-Position"].should.equal "default.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "bar.org") - res.should.be.ok - res["X-Position"].should.equal "bar.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "foo.org") - res.should.be.ok - res["X-Position"].should.equal "foo.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "subdomain.foo.org", "SERVER_NAME" => "foo.org") - res.should.be.ok - res["X-Position"].should.equal "subdomain.foo.org" - - res = Rack::MockRequest.new(map).get("http://foo.org/") - res.should.be.ok - res["X-Position"].should.equal "default.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org") - res.should.be.ok - res["X-Position"].should.equal "default.org" - - res = Rack::MockRequest.new(map).get("/", - "HTTP_HOST" => "example.org:9292", - "SERVER_PORT" => "9292") - res.should.be.ok - res["X-Position"].should.equal "default.org" - end - - specify "should be nestable" do - map = Rack::URLMap.new("/foo" => - Rack::URLMap.new("/bar" => - Rack::URLMap.new("/quux" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "/foo/bar/quux", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"], - }, [""]]} - ))) - - res = Rack::MockRequest.new(map).get("/foo/bar") - res.should.be.not_found - - res = Rack::MockRequest.new(map).get("/foo/bar/quux") - res.should.be.ok - res["X-Position"].should.equal "/foo/bar/quux" - res["X-PathInfo"].should.equal "" - res["X-ScriptName"].should.equal "/foo/bar/quux" - end - - specify "should route root apps correctly" do - map = Rack::URLMap.new("/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "root", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"] - }, [""]]}, - "/foo" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "foo", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"] - }, [""]]} - ) - - res = Rack::MockRequest.new(map).get("/foo/bar") - res.should.be.ok - res["X-Position"].should.equal "foo" - res["X-PathInfo"].should.equal "/bar" - res["X-ScriptName"].should.equal "/foo" - - res = Rack::MockRequest.new(map).get("/foo") - res.should.be.ok - res["X-Position"].should.equal "foo" - res["X-PathInfo"].should.equal "" - res["X-ScriptName"].should.equal "/foo" - - res = Rack::MockRequest.new(map).get("/bar") - res.should.be.ok - res["X-Position"].should.equal "root" - res["X-PathInfo"].should.equal "/bar" - res["X-ScriptName"].should.equal "" - - res = Rack::MockRequest.new(map).get("") - res.should.be.ok - res["X-Position"].should.equal "root" - res["X-PathInfo"].should.equal "/" - res["X-ScriptName"].should.equal "" - end - - specify "should not squeeze slashes" do - map = Rack::URLMap.new("/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "root", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"] - }, [""]]}, - "/foo" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "foo", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"] - }, [""]]} - ) - - res = Rack::MockRequest.new(map).get("/http://example.org/bar") - res.should.be.ok - res["X-Position"].should.equal "root" - res["X-PathInfo"].should.equal "/http://example.org/bar" - res["X-ScriptName"].should.equal "" - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_utils.rb b/vendor/gems/rack-1.1.0/test/spec_rack_utils.rb deleted file mode 100644 index 269a52bd..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_utils.rb +++ /dev/null @@ -1,552 +0,0 @@ -require 'test/spec' - -require 'rack/utils' -require 'rack/lint' -require 'rack/mock' - -context "Rack::Utils" do - specify "should escape correctly" do - Rack::Utils.escape("fobar").should.equal "fo%3Co%3Ebar" - Rack::Utils.escape("a space").should.equal "a+space" - Rack::Utils.escape("q1!2\"'w$5&7/z8)?\\"). - should.equal "q1%212%22%27w%245%267%2Fz8%29%3F%5C" - end - - specify "should escape correctly for multibyte characters" do - matz_name = "\xE3\x81\xBE\xE3\x81\xA4\xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0] # Matsumoto - matz_name.force_encoding("UTF-8") if matz_name.respond_to? :force_encoding - Rack::Utils.escape(matz_name).should.equal '%E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8' - matz_name_sep = "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0] # Matsu moto - matz_name_sep.force_encoding("UTF-8") if matz_name_sep.respond_to? :force_encoding - Rack::Utils.escape(matz_name_sep).should.equal '%E3%81%BE%E3%81%A4+%E3%82%82%E3%81%A8' - end - - specify "should unescape correctly" do - Rack::Utils.unescape("fo%3Co%3Ebar").should.equal "fobar" - Rack::Utils.unescape("a+space").should.equal "a space" - Rack::Utils.unescape("a%20space").should.equal "a space" - Rack::Utils.unescape("q1%212%22%27w%245%267%2Fz8%29%3F%5C"). - should.equal "q1!2\"'w$5&7/z8)?\\" - end - - specify "should parse query strings correctly" do - Rack::Utils.parse_query("foo=bar"). - should.equal "foo" => "bar" - Rack::Utils.parse_query("foo=\"bar\""). - should.equal "foo" => "bar" - Rack::Utils.parse_query("foo=bar&foo=quux"). - should.equal "foo" => ["bar", "quux"] - Rack::Utils.parse_query("foo=1&bar=2"). - should.equal "foo" => "1", "bar" => "2" - Rack::Utils.parse_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F"). - should.equal "my weird field" => "q1!2\"'w$5&7/z8)?" - Rack::Utils.parse_query("foo%3Dbaz=bar").should.equal "foo=baz" => "bar" - end - - specify "should parse nested query strings correctly" do - Rack::Utils.parse_nested_query("foo"). - should.equal "foo" => nil - Rack::Utils.parse_nested_query("foo="). - should.equal "foo" => "" - Rack::Utils.parse_nested_query("foo=bar"). - should.equal "foo" => "bar" - Rack::Utils.parse_nested_query("foo=\"bar\""). - should.equal "foo" => "bar" - - Rack::Utils.parse_nested_query("foo=bar&foo=quux"). - should.equal "foo" => "quux" - Rack::Utils.parse_nested_query("foo&foo="). - should.equal "foo" => "" - Rack::Utils.parse_nested_query("foo=1&bar=2"). - should.equal "foo" => "1", "bar" => "2" - Rack::Utils.parse_nested_query("&foo=1&&bar=2"). - should.equal "foo" => "1", "bar" => "2" - Rack::Utils.parse_nested_query("foo&bar="). - should.equal "foo" => nil, "bar" => "" - Rack::Utils.parse_nested_query("foo=bar&baz="). - should.equal "foo" => "bar", "baz" => "" - Rack::Utils.parse_nested_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F"). - should.equal "my weird field" => "q1!2\"'w$5&7/z8)?" - - Rack::Utils.parse_nested_query("foo[]"). - should.equal "foo" => [nil] - Rack::Utils.parse_nested_query("foo[]="). - should.equal "foo" => [""] - Rack::Utils.parse_nested_query("foo[]=bar"). - should.equal "foo" => ["bar"] - - Rack::Utils.parse_nested_query("foo[]=1&foo[]=2"). - should.equal "foo" => ["1", "2"] - Rack::Utils.parse_nested_query("foo=bar&baz[]=1&baz[]=2&baz[]=3"). - should.equal "foo" => "bar", "baz" => ["1", "2", "3"] - Rack::Utils.parse_nested_query("foo[]=bar&baz[]=1&baz[]=2&baz[]=3"). - should.equal "foo" => ["bar"], "baz" => ["1", "2", "3"] - - Rack::Utils.parse_nested_query("x[y][z]=1"). - should.equal "x" => {"y" => {"z" => "1"}} - Rack::Utils.parse_nested_query("x[y][z][]=1"). - should.equal "x" => {"y" => {"z" => ["1"]}} - Rack::Utils.parse_nested_query("x[y][z]=1&x[y][z]=2"). - should.equal "x" => {"y" => {"z" => "2"}} - Rack::Utils.parse_nested_query("x[y][z][]=1&x[y][z][]=2"). - should.equal "x" => {"y" => {"z" => ["1", "2"]}} - - Rack::Utils.parse_nested_query("x[y][][z]=1"). - should.equal "x" => {"y" => [{"z" => "1"}]} - Rack::Utils.parse_nested_query("x[y][][z][]=1"). - should.equal "x" => {"y" => [{"z" => ["1"]}]} - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][w]=2"). - should.equal "x" => {"y" => [{"z" => "1", "w" => "2"}]} - - Rack::Utils.parse_nested_query("x[y][][v][w]=1"). - should.equal "x" => {"y" => [{"v" => {"w" => "1"}}]} - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][v][w]=2"). - should.equal "x" => {"y" => [{"z" => "1", "v" => {"w" => "2"}}]} - - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][z]=2"). - should.equal "x" => {"y" => [{"z" => "1"}, {"z" => "2"}]} - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][w]=a&x[y][][z]=2&x[y][][w]=3"). - should.equal "x" => {"y" => [{"z" => "1", "w" => "a"}, {"z" => "2", "w" => "3"}]} - - lambda { Rack::Utils.parse_nested_query("x[y]=1&x[y]z=2") }. - should.raise(TypeError). - message.should.equal "expected Hash (got String) for param `y'" - - lambda { Rack::Utils.parse_nested_query("x[y]=1&x[]=1") }. - should.raise(TypeError). - message.should.equal "expected Array (got Hash) for param `x'" - - lambda { Rack::Utils.parse_nested_query("x[y]=1&x[y][][w]=2") }. - should.raise(TypeError). - message.should.equal "expected Array (got String) for param `y'" - end - - specify "should build query strings correctly" do - Rack::Utils.build_query("foo" => "bar").should.equal "foo=bar" - Rack::Utils.build_query("foo" => ["bar", "quux"]). - should.equal "foo=bar&foo=quux" - Rack::Utils.build_query("foo" => "1", "bar" => "2"). - should.equal "foo=1&bar=2" - Rack::Utils.build_query("my weird field" => "q1!2\"'w$5&7/z8)?"). - should.equal "my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F" - end - - specify "should build nested query strings correctly" do - Rack::Utils.build_nested_query("foo" => nil).should.equal "foo" - Rack::Utils.build_nested_query("foo" => "").should.equal "foo=" - Rack::Utils.build_nested_query("foo" => "bar").should.equal "foo=bar" - - Rack::Utils.build_nested_query("foo" => "1", "bar" => "2"). - should.equal "foo=1&bar=2" - Rack::Utils.build_nested_query("my weird field" => "q1!2\"'w$5&7/z8)?"). - should.equal "my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F" - - Rack::Utils.build_nested_query("foo" => [nil]). - should.equal "foo[]" - Rack::Utils.build_nested_query("foo" => [""]). - should.equal "foo[]=" - Rack::Utils.build_nested_query("foo" => ["bar"]). - should.equal "foo[]=bar" - - # The ordering of the output query string is unpredictable with 1.8's - # unordered hash. Test that build_nested_query performs the inverse - # function of parse_nested_query. - [{"foo" => nil, "bar" => ""}, - {"foo" => "bar", "baz" => ""}, - {"foo" => ["1", "2"]}, - {"foo" => "bar", "baz" => ["1", "2", "3"]}, - {"foo" => ["bar"], "baz" => ["1", "2", "3"]}, - {"foo" => ["1", "2"]}, - {"foo" => "bar", "baz" => ["1", "2", "3"]}, - {"x" => {"y" => {"z" => "1"}}}, - {"x" => {"y" => {"z" => ["1"]}}}, - {"x" => {"y" => {"z" => ["1", "2"]}}}, - {"x" => {"y" => [{"z" => "1"}]}}, - {"x" => {"y" => [{"z" => ["1"]}]}}, - {"x" => {"y" => [{"z" => "1", "w" => "2"}]}}, - {"x" => {"y" => [{"v" => {"w" => "1"}}]}}, - {"x" => {"y" => [{"z" => "1", "v" => {"w" => "2"}}]}}, - {"x" => {"y" => [{"z" => "1"}, {"z" => "2"}]}}, - {"x" => {"y" => [{"z" => "1", "w" => "a"}, {"z" => "2", "w" => "3"}]}} - ].each { |params| - qs = Rack::Utils.build_nested_query(params) - Rack::Utils.parse_nested_query(qs).should.equal params - } - - lambda { Rack::Utils.build_nested_query("foo=bar") }. - should.raise(ArgumentError). - message.should.equal "value must be a Hash" - end - - specify "should figure out which encodings are acceptable" do - helper = lambda do |a, b| - request = Rack::Request.new(Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => a)) - Rack::Utils.select_best_encoding(a, b) - end - - helper.call(%w(), [["x", 1]]).should.equal(nil) - helper.call(%w(identity), [["identity", 0.0]]).should.equal(nil) - helper.call(%w(identity), [["*", 0.0]]).should.equal(nil) - - helper.call(%w(identity), [["compress", 1.0], ["gzip", 1.0]]).should.equal("identity") - - helper.call(%w(compress gzip identity), [["compress", 1.0], ["gzip", 1.0]]).should.equal("compress") - helper.call(%w(compress gzip identity), [["compress", 0.5], ["gzip", 1.0]]).should.equal("gzip") - - helper.call(%w(foo bar identity), []).should.equal("identity") - helper.call(%w(foo bar identity), [["*", 1.0]]).should.equal("foo") - helper.call(%w(foo bar identity), [["*", 1.0], ["foo", 0.9]]).should.equal("bar") - - helper.call(%w(foo bar identity), [["foo", 0], ["bar", 0]]).should.equal("identity") - helper.call(%w(foo bar baz identity), [["*", 0], ["identity", 0.1]]).should.equal("identity") - end - - specify "should return the bytesize of String" do - Rack::Utils.bytesize("FOO\xE2\x82\xAC").should.equal 6 - end - - specify "should return status code for integer" do - Rack::Utils.status_code(200).should.equal 200 - end - - specify "should return status code for string" do - Rack::Utils.status_code("200").should.equal 200 - end - - specify "should return status code for symbol" do - Rack::Utils.status_code(:ok).should.equal 200 - end -end - -context "Rack::Utils::HeaderHash" do - specify "should retain header case" do - h = Rack::Utils::HeaderHash.new("Content-MD5" => "d5ff4e2a0 ...") - h['ETag'] = 'Boo!' - h.to_hash.should.equal "Content-MD5" => "d5ff4e2a0 ...", "ETag" => 'Boo!' - end - - specify "should check existence of keys case insensitively" do - h = Rack::Utils::HeaderHash.new("Content-MD5" => "d5ff4e2a0 ...") - h.should.include 'content-md5' - h.should.not.include 'ETag' - end - - specify "should merge case-insensitively" do - h = Rack::Utils::HeaderHash.new("ETag" => 'HELLO', "content-length" => '123') - merged = h.merge("Etag" => 'WORLD', 'Content-Length' => '321', "Foo" => 'BAR') - merged.should.equal "Etag"=>'WORLD', "Content-Length"=>'321', "Foo"=>'BAR' - end - - specify "should overwrite case insensitively and assume the new key's case" do - h = Rack::Utils::HeaderHash.new("Foo-Bar" => "baz") - h["foo-bar"] = "bizzle" - h["FOO-BAR"].should.equal "bizzle" - h.length.should.equal 1 - h.to_hash.should.equal "foo-bar" => "bizzle" - end - - specify "should be converted to real Hash" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.to_hash.should.be.instance_of Hash - end - - specify "should convert Array values to Strings when converting to Hash" do - h = Rack::Utils::HeaderHash.new("foo" => ["bar", "baz"]) - h.to_hash.should.equal({ "foo" => "bar\nbaz" }) - end - - specify "should replace hashes correctly" do - h = Rack::Utils::HeaderHash.new("Foo-Bar" => "baz") - j = {"foo" => "bar"} - h.replace(j) - h["foo"].should.equal "bar" - end - - specify "should be able to delete the given key case-sensitively" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("foo") - h["foo"].should.be.nil - h["FOO"].should.be.nil - end - - specify "should be able to delete the given key case-insensitively" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("FOO") - h["foo"].should.be.nil - h["FOO"].should.be.nil - end - - specify "should return the deleted value when #delete is called on an existing key" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("Foo").should.equal("bar") - end - - specify "should return nil when #delete is called on a non-existant key" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("Hello").should.be.nil - end - - specify "should avoid unnecessary object creation if possible" do - a = Rack::Utils::HeaderHash.new("foo" => "bar") - b = Rack::Utils::HeaderHash.new(a) - b.object_id.should.equal(a.object_id) - b.should.equal(a) - end - - specify "should convert Array values to Strings when responding to #each" do - h = Rack::Utils::HeaderHash.new("foo" => ["bar", "baz"]) - h.each do |k,v| - k.should.equal("foo") - v.should.equal("bar\nbaz") - end - end - -end - -context "Rack::Utils::Context" do - class ContextTest - attr_reader :app - def initialize app; @app=app; end - def call env; context env; end - def context env, app=@app; app.call(env); end - end - test_target1 = proc{|e| e.to_s+' world' } - test_target2 = proc{|e| e.to_i+2 } - test_target3 = proc{|e| nil } - test_target4 = proc{|e| [200,{'Content-Type'=>'text/plain', 'Content-Length'=>'0'},['']] } - test_app = ContextTest.new test_target4 - - specify "should set context correctly" do - test_app.app.should.equal test_target4 - c1 = Rack::Utils::Context.new(test_app, test_target1) - c1.for.should.equal test_app - c1.app.should.equal test_target1 - c2 = Rack::Utils::Context.new(test_app, test_target2) - c2.for.should.equal test_app - c2.app.should.equal test_target2 - end - - specify "should alter app on recontexting" do - c1 = Rack::Utils::Context.new(test_app, test_target1) - c2 = c1.recontext(test_target2) - c2.for.should.equal test_app - c2.app.should.equal test_target2 - c3 = c2.recontext(test_target3) - c3.for.should.equal test_app - c3.app.should.equal test_target3 - end - - specify "should run different apps" do - c1 = Rack::Utils::Context.new test_app, test_target1 - c2 = c1.recontext test_target2 - c3 = c2.recontext test_target3 - c4 = c3.recontext test_target4 - a4 = Rack::Lint.new c4 - a5 = Rack::Lint.new test_app - r1 = c1.call('hello') - r1.should.equal 'hello world' - r2 = c2.call(2) - r2.should.equal 4 - r3 = c3.call(:misc_symbol) - r3.should.be.nil - r4 = Rack::MockRequest.new(a4).get('/') - r4.status.should.be 200 - r5 = Rack::MockRequest.new(a5).get('/') - r5.status.should.be 200 - r4.body.should.equal r5.body - end -end - -context "Rack::Utils::Multipart" do - specify "should return nil if content type is not multipart" do - env = Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'application/x-www-form-urlencoded') - Rack::Utils::Multipart.parse_multipart(env).should.equal nil - end - - specify "should parse multipart upload with text file" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:text)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "file1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"file1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "should parse multipart upload with nested parameters" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:nested)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["foo"]["submit-name"].should.equal "Larry" - params["foo"]["files"][:type].should.equal "text/plain" - params["foo"]["files"][:filename].should.equal "file1.txt" - params["foo"]["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"foo[files]\"; filename=\"file1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["foo"]["files"][:name].should.equal "foo[files]" - params["foo"]["files"][:tempfile].read.should.equal "contents" - end - - specify "should parse multipart upload with binary file" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:binary)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:type].should.equal "image/png" - params["files"][:filename].should.equal "rack-logo.png" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"rack-logo.png\"\r\n" + - "Content-Type: image/png\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.length.should.equal 26473 - end - - specify "should parse multipart upload with empty file" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:empty)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "file1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"file1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "" - end - - specify "should parse multipart upload with filename with semicolons" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:semicolon)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "fi;le1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"fi;le1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "should not include file params if no file was selected" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:none)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"].should.equal nil - params.keys.should.not.include "files" - end - - specify "should parse IE multipart upload and clean up filename" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:ie)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "file1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; " + - 'filename="C:\Documents and Settings\Administrator\Desktop\file1.txt"' + - "\r\nContent-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "rewinds input after parsing upload" do - options = multipart_fixture(:text) - input = options[:input] - env = Rack::MockRequest.env_for("/", options) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:filename].should.equal "file1.txt" - input.read.length.should.equal 197 - end - - specify "builds multipart body" do - files = Rack::Utils::Multipart::UploadedFile.new(multipart_file("file1.txt")) - data = Rack::Utils::Multipart.build_multipart("submit-name" => "Larry", "files" => files) - - options = { - "CONTENT_TYPE" => "multipart/form-data; boundary=AaB03x", - "CONTENT_LENGTH" => data.length.to_s, - :input => StringIO.new(data) - } - env = Rack::MockRequest.env_for("/", options) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:filename].should.equal "file1.txt" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "builds nested multipart body" do - files = Rack::Utils::Multipart::UploadedFile.new(multipart_file("file1.txt")) - data = Rack::Utils::Multipart.build_multipart("people" => [{"submit-name" => "Larry", "files" => files}]) - - options = { - "CONTENT_TYPE" => "multipart/form-data; boundary=AaB03x", - "CONTENT_LENGTH" => data.length.to_s, - :input => StringIO.new(data) - } - env = Rack::MockRequest.env_for("/", options) - params = Rack::Utils::Multipart.parse_multipart(env) - params["people"][0]["submit-name"].should.equal "Larry" - params["people"][0]["files"][:filename].should.equal "file1.txt" - params["people"][0]["files"][:tempfile].read.should.equal "contents" - end - - specify "can parse fields that end at the end of the buffer" do - input = File.read(multipart_file("bad_robots")) - - req = Rack::Request.new Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => "multipart/form-data, boundary=1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon", - "CONTENT_LENGTH" => input.size, - :input => input) - - req.POST['file.path'].should.equal "/var/tmp/uploads/4/0001728414" - req.POST['addresses'].should.not.equal nil - end - - specify "builds complete params with the chunk size of 16384 slicing exactly on boundary" do - data = File.open(multipart_file("fail_16384_nofile")) { |f| f.read }.gsub(/\n/, "\r\n") - options = { - "CONTENT_TYPE" => "multipart/form-data; boundary=----WebKitFormBoundaryWsY0GnpbI5U7ztzo", - "CONTENT_LENGTH" => data.length.to_s, - :input => StringIO.new(data) - } - env = Rack::MockRequest.env_for("/", options) - params = Rack::Utils::Multipart.parse_multipart(env) - - params.should.not.equal nil - params.keys.should.include "AAAAAAAAAAAAAAAAAAA" - params["AAAAAAAAAAAAAAAAAAA"].keys.should.include "PLAPLAPLA_MEMMEMMEMM_ATTRATTRER" - params["AAAAAAAAAAAAAAAAAAA"]["PLAPLAPLA_MEMMEMMEMM_ATTRATTRER"].keys.should.include "new" - params["AAAAAAAAAAAAAAAAAAA"]["PLAPLAPLA_MEMMEMMEMM_ATTRATTRER"]["new"].keys.should.include "-2" - params["AAAAAAAAAAAAAAAAAAA"]["PLAPLAPLA_MEMMEMMEMM_ATTRATTRER"]["new"]["-2"].keys.should.include "ba_unit_id" - params["AAAAAAAAAAAAAAAAAAA"]["PLAPLAPLA_MEMMEMMEMM_ATTRATTRER"]["new"]["-2"]["ba_unit_id"].should.equal "1017" - end - - specify "should return nil if no UploadedFiles were used" do - data = Rack::Utils::Multipart.build_multipart("people" => [{"submit-name" => "Larry", "files" => "contents"}]) - data.should.equal nil - end - - specify "should raise ArgumentError if params is not a Hash" do - lambda { Rack::Utils::Multipart.build_multipart("foo=bar") }. - should.raise(ArgumentError). - message.should.equal "value must be a Hash" - end - - private - def multipart_fixture(name) - file = multipart_file(name) - data = File.open(file, 'rb') { |io| io.read } - - type = "multipart/form-data; boundary=AaB03x" - length = data.respond_to?(:bytesize) ? data.bytesize : data.size - - { "CONTENT_TYPE" => type, - "CONTENT_LENGTH" => length.to_s, - :input => StringIO.new(data) } - end - - def multipart_file(name) - File.join(File.dirname(__FILE__), "multipart", name.to_s) - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rack_webrick.rb b/vendor/gems/rack-1.1.0/test/spec_rack_webrick.rb deleted file mode 100644 index 599425c4..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rack_webrick.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'test/spec' - -require 'rack/handler/webrick' -require 'rack/lint' -require 'rack/response' -require 'testrequest' - -Thread.abort_on_exception = true - -context "Rack::Handler::WEBrick" do - include TestRequest::Helpers - - setup do - @server = WEBrick::HTTPServer.new(:Host => @host='0.0.0.0', - :Port => @port=9202, - :Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN), - :AccessLog => []) - @server.mount "/test", Rack::Handler::WEBrick, - Rack::Lint.new(TestRequest.new) - Thread.new { @server.start } - trap(:INT) { @server.shutdown } - end - - specify "should respond" do - lambda { - GET("/test") - }.should.not.raise - end - - specify "should be a WEBrick" do - GET("/test") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /WEBrick/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal "9202" - response["SERVER_NAME"].should.equal "0.0.0.0" - end - - specify "should have rack headers" do - GET("/test") - response["rack.version"].should.equal [1,1] - response["rack.multithread"].should.be true - response["rack.multiprocess"].should.be false - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/test") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.be.equal "" - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - - GET("/test/foo%25encoding?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo%25encoding" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - specify "should correctly set cookies" do - @server.mount "/cookie-test", Rack::Handler::WEBrick, - Rack::Lint.new(lambda { |req| - res = Rack::Response.new - res.set_cookie "one", "1" - res.set_cookie "two", "2" - res.finish - }) - - Net::HTTP.start(@host, @port) { |http| - res = http.get("/cookie-test") - res.code.to_i.should.equal 200 - res.get_fields("set-cookie").should.equal ["one=1", "two=2"] - } - end - - specify "should provide a .run" do - block_ran = false - catch(:done) { - Rack::Handler::WEBrick.run(lambda {}, - {:Port => 9210, - :Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN), - :AccessLog => []}) { |server| - block_ran = true - server.should.be.kind_of WEBrick::HTTPServer - @s = server - throw :done - } - } - block_ran.should.be true - @s.shutdown - end - - teardown do - @server.shutdown - end -end diff --git a/vendor/gems/rack-1.1.0/test/spec_rackup.rb b/vendor/gems/rack-1.1.0/test/spec_rackup.rb deleted file mode 100644 index d9926fda..00000000 --- a/vendor/gems/rack-1.1.0/test/spec_rackup.rb +++ /dev/null @@ -1,154 +0,0 @@ -require 'test/spec' -require 'testrequest' -require 'rack/server' -require 'open3' - -begin -require "mongrel" - -context "rackup" do - include TestRequest::Helpers - - def run_rackup(*args) - options = args.last.is_a?(Hash) ? args.pop : {} - flags = args.first - @host = options[:host] || "0.0.0.0" - @port = options[:port] || 9292 - - Dir.chdir("#{root}/test/rackup") do - @in, @rackup, @err = Open3.popen3("#{Gem.ruby} -S #{rackup} #{flags}") - end - - return if options[:port] == false - - # Wait until the server is available - begin - GET("/") - rescue - sleep 0.05 - retry - end - end - - def output - @rackup.read - end - - after do - # This doesn't actually return a response, so we rescue - GET "/die" rescue nil - - Dir["#{root}/**/*.pid"].each do |file| - File.delete(file) - end - - File.delete("#{root}/log_output") if File.exist?("#{root}/log_output") - end - - specify "rackup" do - run_rackup - response["PATH_INFO"].should.equal '/' - response["test.$DEBUG"].should.be false - response["test.$EVAL"].should.be nil - response["test.$VERBOSE"].should.be false - response["test.Ping"].should.be nil - response["SERVER_SOFTWARE"].should.not =~ /webrick/ - end - - specify "rackup --help" do - run_rackup "--help", :port => false - output.should.match /--port/ - end - - specify "rackup --port" do - run_rackup "--port 9000", :port => 9000 - response["SERVER_PORT"].should.equal "9000" - end - - specify "rackup --debug" do - run_rackup "--debug" - response["test.$DEBUG"].should.be true - end - - specify "rackup --eval" do - run_rackup %{--eval "BUKKIT = 'BUKKIT'"} - response["test.$EVAL"].should.equal "BUKKIT" - end - - specify "rackup --warn" do - run_rackup %{--warn} - response["test.$VERBOSE"].should.be true - end - - specify "rackup --include" do - run_rackup %{--include /foo/bar} - response["test.$LOAD_PATH"].should.include "/foo/bar" - end - - specify "rackup --require" do - run_rackup %{--require ping} - response["test.Ping"].should.equal "constant" - end - - specify "rackup --server" do - run_rackup %{--server webrick} - response["SERVER_SOFTWARE"].should =~ /webrick/i - end - - specify "rackup --host" do - run_rackup %{--host 127.0.0.1}, :host => "127.0.0.1" - response["REMOTE_ADDR"].should.equal "127.0.0.1" - end - - specify "rackup --daemonize --pid" do - run_rackup %{--daemonize --pid testing.pid} - status.should.be 200 - @rackup.should.be.eof? - Dir["#{root}/**/testing.pid"].should.not.be.empty? - end - - specify "rackup --pid" do - run_rackup %{--pid testing.pid} - status.should.be 200 - Dir["#{root}/**/testing.pid"].should.not.be.empty? - end - - specify "rackup --version" do - run_rackup %{--version}, :port => false - output.should =~ /1.0/ - end - - specify "rackup --env development includes lint" do - run_rackup - GET("/broken_lint") - status.should.be 500 - end - - specify "rackup --env deployment does not include lint" do - run_rackup %{--env deployment} - GET("/broken_lint") - status.should.be 200 - end - - specify "rackup --env none does not include lint" do - run_rackup %{--env none} - GET("/broken_lint") - status.should.be 200 - end - - specify "rackup --env deployment does log" do - run_rackup %{--env deployment} - log = File.read(response["test.stderr"]) - log.should.be.empty? - end - - specify "rackup --env none does not log" do - run_rackup %{--env none} - GET("/") - log = File.read(response["test.stderr"]) - log.should.be.empty? - end -end -rescue LoadError - $stderr.puts "Skipping rackup --server tests (mongrel is required). `gem install thin` and try again." -end \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/.specification b/vendor/gems/ruby-openid-2.1.2/.specification deleted file mode 100644 index 6a1a03db..00000000 --- a/vendor/gems/ruby-openid-2.1.2/.specification +++ /dev/null @@ -1,290 +0,0 @@ ---- !ruby/object:Gem::Specification -name: ruby-openid -version: !ruby/object:Gem::Version - version: 2.1.2 -platform: ruby -authors: -- JanRain, Inc -autorequire: openid -bindir: bin -cert_chain: -date: 2008-06-27 05:00:00 +01:00 -default_executable: -dependencies: [] - -description: -email: openid@janrain.com -executables: [] - -extensions: [] - -extra_rdoc_files: -- README -- INSTALL -- LICENSE -- UPGRADE -files: -- examples/README -- examples/active_record_openid_store -- examples/rails_openid -- examples/discover -- examples/active_record_openid_store/lib -- examples/active_record_openid_store/test -- examples/active_record_openid_store/init.rb -- examples/active_record_openid_store/README -- examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb -- examples/active_record_openid_store/XXX_upgrade_open_id_store.rb -- examples/active_record_openid_store/lib/association.rb -- examples/active_record_openid_store/lib/nonce.rb -- examples/active_record_openid_store/lib/open_id_setting.rb -- examples/active_record_openid_store/lib/openid_ar_store.rb -- examples/active_record_openid_store/test/store_test.rb -- examples/rails_openid/app -- examples/rails_openid/components -- examples/rails_openid/config -- examples/rails_openid/db -- examples/rails_openid/doc -- examples/rails_openid/lib -- examples/rails_openid/log -- examples/rails_openid/public -- examples/rails_openid/script -- examples/rails_openid/test -- examples/rails_openid/vendor -- examples/rails_openid/Rakefile -- examples/rails_openid/README -- examples/rails_openid/app/controllers -- examples/rails_openid/app/helpers -- examples/rails_openid/app/models -- examples/rails_openid/app/views -- examples/rails_openid/app/controllers/application.rb -- examples/rails_openid/app/controllers/login_controller.rb -- examples/rails_openid/app/controllers/server_controller.rb -- examples/rails_openid/app/controllers/consumer_controller.rb -- examples/rails_openid/app/helpers/application_helper.rb -- examples/rails_openid/app/helpers/login_helper.rb -- examples/rails_openid/app/helpers/server_helper.rb -- examples/rails_openid/app/views/layouts -- examples/rails_openid/app/views/login -- examples/rails_openid/app/views/server -- examples/rails_openid/app/views/consumer -- examples/rails_openid/app/views/layouts/server.rhtml -- examples/rails_openid/app/views/login/index.rhtml -- examples/rails_openid/app/views/server/decide.rhtml -- examples/rails_openid/app/views/consumer/index.rhtml -- examples/rails_openid/config/environments -- examples/rails_openid/config/database.yml -- examples/rails_openid/config/boot.rb -- examples/rails_openid/config/environment.rb -- examples/rails_openid/config/routes.rb -- examples/rails_openid/config/environments/development.rb -- examples/rails_openid/config/environments/production.rb -- examples/rails_openid/config/environments/test.rb -- examples/rails_openid/doc/README_FOR_APP -- examples/rails_openid/lib/tasks -- examples/rails_openid/public/images -- examples/rails_openid/public/javascripts -- examples/rails_openid/public/stylesheets -- examples/rails_openid/public/dispatch.cgi -- examples/rails_openid/public/404.html -- examples/rails_openid/public/500.html -- examples/rails_openid/public/dispatch.fcgi -- examples/rails_openid/public/dispatch.rb -- examples/rails_openid/public/favicon.ico -- examples/rails_openid/public/robots.txt -- examples/rails_openid/public/images/openid_login_bg.gif -- examples/rails_openid/public/javascripts/controls.js -- examples/rails_openid/public/javascripts/dragdrop.js -- examples/rails_openid/public/javascripts/effects.js -- examples/rails_openid/public/javascripts/prototype.js -- examples/rails_openid/script/performance -- examples/rails_openid/script/process -- examples/rails_openid/script/console -- examples/rails_openid/script/about -- examples/rails_openid/script/breakpointer -- examples/rails_openid/script/destroy -- examples/rails_openid/script/generate -- examples/rails_openid/script/plugin -- examples/rails_openid/script/runner -- examples/rails_openid/script/server -- examples/rails_openid/script/performance/benchmarker -- examples/rails_openid/script/performance/profiler -- examples/rails_openid/script/process/spawner -- examples/rails_openid/script/process/reaper -- examples/rails_openid/script/process/spinner -- examples/rails_openid/test/fixtures -- examples/rails_openid/test/functional -- examples/rails_openid/test/mocks -- examples/rails_openid/test/unit -- examples/rails_openid/test/test_helper.rb -- examples/rails_openid/test/functional/login_controller_test.rb -- examples/rails_openid/test/functional/server_controller_test.rb -- examples/rails_openid/test/mocks/development -- examples/rails_openid/test/mocks/test -- lib/openid -- lib/hmac -- lib/openid.rb -- lib/openid/cryptutil.rb -- lib/openid/extras.rb -- lib/openid/urinorm.rb -- lib/openid/util.rb -- lib/openid/trustroot.rb -- lib/openid/message.rb -- lib/openid/yadis -- lib/openid/consumer -- lib/openid/fetchers.rb -- lib/openid/dh.rb -- lib/openid/kvform.rb -- lib/openid/association.rb -- lib/openid/store -- lib/openid/kvpost.rb -- lib/openid/extensions -- lib/openid/protocolerror.rb -- lib/openid/server.rb -- lib/openid/extension.rb -- lib/openid/consumer.rb -- lib/openid/yadis/htmltokenizer.rb -- lib/openid/yadis/parsehtml.rb -- lib/openid/yadis/filters.rb -- lib/openid/yadis/xrds.rb -- lib/openid/yadis/accept.rb -- lib/openid/yadis/constants.rb -- lib/openid/yadis/discovery.rb -- lib/openid/yadis/xri.rb -- lib/openid/yadis/xrires.rb -- lib/openid/yadis/services.rb -- lib/openid/consumer/html_parse.rb -- lib/openid/consumer/idres.rb -- lib/openid/consumer/associationmanager.rb -- lib/openid/consumer/discovery.rb -- lib/openid/consumer/discovery_manager.rb -- lib/openid/consumer/checkid_request.rb -- lib/openid/consumer/responses.rb -- lib/openid/store/filesystem.rb -- lib/openid/store/interface.rb -- lib/openid/store/nonce.rb -- lib/openid/store/memory.rb -- lib/openid/extensions/sreg.rb -- lib/openid/extensions/ax.rb -- lib/openid/extensions/pape.rb -- lib/hmac/hmac.rb -- lib/hmac/sha1.rb -- lib/hmac/sha2.rb -- test/data -- test/test_association.rb -- test/test_urinorm.rb -- test/testutil.rb -- test/test_util.rb -- test/test_message.rb -- test/test_cryptutil.rb -- test/test_extras.rb -- test/util.rb -- test/test_trustroot.rb -- test/test_parsehtml.rb -- test/test_fetchers.rb -- test/test_dh.rb -- test/test_kvform.rb -- test/test_openid_yadis.rb -- test/test_linkparse.rb -- test/test_stores.rb -- test/test_filters.rb -- test/test_xrds.rb -- test/test_nonce.rb -- test/test_accept.rb -- test/test_kvpost.rb -- test/test_associationmanager.rb -- test/discoverdata.rb -- test/test_server.rb -- test/test_yadis_discovery.rb -- test/test_sreg.rb -- test/test_idres.rb -- test/test_ax.rb -- test/test_xri.rb -- test/test_xrires.rb -- test/test_discover.rb -- test/test_consumer.rb -- test/test_pape.rb -- test/test_checkid_request.rb -- test/test_discovery_manager.rb -- test/test_responses.rb -- test/test_extension.rb -- test/data/test_xrds -- test/data/urinorm.txt -- test/data/n2b64 -- test/data/trustroot.txt -- test/data/dh.txt -- test/data/test1-parsehtml.txt -- test/data/linkparse.txt -- test/data/accept.txt -- test/data/test_discover -- test/data/example-xrds.xml -- test/data/test1-discover.txt -- test/data/test_xrds/ref.xrds -- test/data/test_xrds/README -- test/data/test_xrds/delegated-20060809-r1.xrds -- test/data/test_xrds/delegated-20060809-r2.xrds -- test/data/test_xrds/delegated-20060809.xrds -- test/data/test_xrds/no-xrd.xml -- test/data/test_xrds/not-xrds.xml -- test/data/test_xrds/prefixsometimes.xrds -- test/data/test_xrds/sometimesprefix.xrds -- test/data/test_xrds/spoof1.xrds -- test/data/test_xrds/spoof2.xrds -- test/data/test_xrds/spoof3.xrds -- test/data/test_xrds/status222.xrds -- test/data/test_xrds/valid-populated-xrds.xml -- test/data/test_xrds/=j3h.2007.11.14.xrds -- test/data/test_xrds/subsegments.xrds -- test/data/test_discover/openid2_xrds.xml -- test/data/test_discover/openid.html -- test/data/test_discover/openid2.html -- test/data/test_discover/openid2_xrds_no_local_id.xml -- test/data/test_discover/openid_1_and_2.html -- test/data/test_discover/openid_1_and_2_xrds.xml -- test/data/test_discover/openid_and_yadis.html -- test/data/test_discover/openid_1_and_2_xrds_bad_delegate.xml -- test/data/test_discover/openid_no_delegate.html -- test/data/test_discover/yadis_0entries.xml -- test/data/test_discover/yadis_2_bad_local_id.xml -- test/data/test_discover/yadis_2entries_delegate.xml -- test/data/test_discover/yadis_2entries_idp.xml -- test/data/test_discover/yadis_another_delegate.xml -- test/data/test_discover/yadis_idp.xml -- test/data/test_discover/yadis_idp_delegate.xml -- test/data/test_discover/yadis_no_delegate.xml -- NOTICE -- CHANGELOG -- README -- INSTALL -- LICENSE -- UPGRADE -- admin/runtests.rb -has_rdoc: true -homepage: http://openidenabled.com/ruby-openid/ -post_install_message: -rdoc_options: -- --main -- README -require_paths: -- bin -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">" - - !ruby/object:Gem::Version - version: 0.0.0 - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: -rubygems_version: 1.0.1 -signing_key: -specification_version: 1 -summary: A library for consuming and serving OpenID identities. -test_files: -- admin/runtests.rb diff --git a/vendor/gems/ruby-openid-2.1.2/CHANGELOG b/vendor/gems/ruby-openid-2.1.2/CHANGELOG deleted file mode 100644 index deece367..00000000 --- a/vendor/gems/ruby-openid-2.1.2/CHANGELOG +++ /dev/null @@ -1,78 +0,0 @@ -Fri Jun 27 15:39:14 PDT 2008 Kevin Turner - tagged 2.1.2 - -Fri Jun 27 15:38:05 PDT 2008 Kevin Turner - * update version to 2.1.2 - -Fri Jun 27 15:01:35 PDT 2008 Kevin Turner - * util: remove call to srand - - From the Ruby FAQ: - - 9.2 How do random number seeds work? - - It depends. In Ruby versions prior to 1.5.2, the random number generator had - (by default) a constant seed, and so would produce the same series of numbers - each time a program was run. If you needed less deterministic behaviors, you - called srand to set up a less predictable seed. - - Newer Rubys (Rubies?) have a different behavior. If rand is called without a - prior call to srand, Ruby will generate its own random(ish) seed. Successive - runs of a program that does not use srand will generate different sequences of - random numbers. To get the old, predictable, behavior (perhaps for testing), - call srand with a constant seed. - -Fri Jun 27 13:34:43 PDT 2008 Kevin Turner - * LICENSE: htmltokenizer is (c) 2004 Ben Giddings - -Fri Jun 27 13:32:09 PDT 2008 Kevin Turner - * Yadis.html_yadis_location: catch HTMLTokenizerError - -Fri Jun 27 13:24:13 PDT 2008 Kevin Turner - * htmltokenizer: define HTMLTokenizerError to raise - -Fri Jun 27 13:18:38 PDT 2008 Kevin Turner - * htmltokenizer: Don't raise OpenIDError from htmltokenizer (it's not in the OpenID module namespace) #255 - -Wed Jun 25 17:31:26 PDT 2008 Kevin Turner - * OpenID::Server::CheckIDRequest.answer: document return type - -Wed Jun 25 17:06:35 PDT 2008 Kevin Turner - * TrustRoot.check_sanity: don't fail if the trust root is not parseable - -Wed Jun 25 16:31:30 PDT 2008 Kevin Turner - * Message.from_http_response: accept 206 code - -Wed Jun 25 14:14:05 PDT 2008 Kevin Turner - * move OpenID::VERSION definition in openid.rb, for #256 - -Wed Jun 25 13:55:18 PDT 2008 Kevin Turner - * Add admin/gettlds.py to ease updating of TLD list in trust root validation - -Wed Jun 25 13:50:22 PDT 2008 Kevin Turner - * TrustRoot.TOP_LEVEL_DOMAINS: updated - -Fri Jun 13 14:18:04 PDT 2008 Kevin Turner - * xrds.rb: fix stray colon - -Fri Jun 13 13:41:58 PDT 2008 Kevin Turner - * Yadis::get_canonical_id: case-insensitive comparison - - Porting a patch from =wil: - - 1. There should only be a single CanonicalID in each XRD (in the latest XRI - resolution spec), so I made it use the first CID found instead of the last. - - 2. Use case-insensitive comparison when comparing CanonicalIDs. - -Wed Jun 11 15:24:12 PDT 2008 Kevin Turner - * Accept response code 206 from fetcher results. Fixes #260 - -Wed Jun 11 11:27:25 PDT 2008 cygnus@janrain.com - * admin/fixperms: Fix stale entries - -Wed Jun 11 11:08:11 PDT 2008 cygnus@janrain.com - * Add test cases for trust roots with non-ASCII characters in path or hostname - -Fri Jun 6 15:50:12 PDT 2008 cygnus@janrain.com - tagged 2.1.1 diff --git a/vendor/gems/ruby-openid-2.1.2/INSTALL b/vendor/gems/ruby-openid-2.1.2/INSTALL deleted file mode 100644 index 89f1b9bd..00000000 --- a/vendor/gems/ruby-openid-2.1.2/INSTALL +++ /dev/null @@ -1,47 +0,0 @@ -= Ruby OpenID Library Installation - -== Rubygems Installation - -Rubygems is a tool for installing ruby libraries and their -dependancies. If you have rubygems installed, simply: - - gem install ruby-openid - -== Manual Installation - -Unpack the archive and run setup.rb to install: - - ruby setup.rb - -setup.rb installs the library into your system ruby. If don't want to -add openid to you system ruby, you may instead add the *lib* directory of -the extracted tarball to your RUBYLIB environment variable: - - $ export RUBYLIB=${RUBYLIB}:/path/to/ruby-openid/lib - - -== Testing the Installation - -Make sure everything installed ok: - $> irb - irb$> require "openid" - => true - -Or, if you installed via rubygems: - - $> irb - irb$> require "rubygems" - => true - irb$> require_gem "ruby-openid" - => true - -== Run the test suite - -Go into the test directory and execute the *runtests.rb* script. - -== Next steps - -* Run consumer.rb in the examples directory. -* Get started writing your own consumer using OpenID::Consumer -* Write your own server with OpenID::Server -* Use the OpenIDLoginGenerator! Read example/README for more info. diff --git a/vendor/gems/ruby-openid-2.1.2/LICENSE b/vendor/gems/ruby-openid-2.1.2/LICENSE deleted file mode 100644 index c1c57734..00000000 --- a/vendor/gems/ruby-openid-2.1.2/LICENSE +++ /dev/null @@ -1,210 +0,0 @@ -The code in lib/hmac/ is Copyright 2001 by Daiki Ueno, and distributed under -the terms of the Ruby license. See http://www.ruby-lang.org/en/LICENSE.txt - -lib/openid/yadis/htmltokenizer.rb is Copyright 2004 by Ben Giddings and -distributed under the terms of the Ruby license. - -The remainder of this package is Copyright 2006-2008 by JanRain, Inc. and -distributed under the terms of license below: - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/gems/ruby-openid-2.1.2/NOTICE b/vendor/gems/ruby-openid-2.1.2/NOTICE deleted file mode 100644 index 62df93be..00000000 --- a/vendor/gems/ruby-openid-2.1.2/NOTICE +++ /dev/null @@ -1,2 +0,0 @@ -This product includes software developed by JanRain, -available from http://openidenabled.com/ diff --git a/vendor/gems/ruby-openid-2.1.2/README b/vendor/gems/ruby-openid-2.1.2/README deleted file mode 100644 index c6e833b4..00000000 --- a/vendor/gems/ruby-openid-2.1.2/README +++ /dev/null @@ -1,82 +0,0 @@ -=Ruby OpenID - -A Ruby library for verifying and serving OpenID identities. - -==Features -* Easy to use API for verifying OpenID identites - OpenID::Consumer -* Support for serving OpenID identites - OpenID::Server -* Does not depend on underlying web framework -* Supports multiple storage mechanisms (Filesystem, ActiveRecord, Memory) -* Example code to help you get started, including: - * Ruby on Rails based consumer and server - * OpenIDLoginGenerator for quickly getting creating a rails app that uses - OpenID for authentication - * ActiveRecordOpenIDStore plugin -* Comprehensive test suite -* Supports both OpenID 1 and OpenID 2 transparently - -==Installing -Before running the examples or writing your own code you'll need to install -the library. See the INSTALL file or use rubygems: - - gem install ruby-openid - -Check the installation: - - $ irb - irb> require 'rubygems' - irb> require_gem 'ruby-openid' - => true - -The library is known to work with Ruby 1.8.4 on Unix, Max OSX and -Win32. Examples have been tested with Rails 1.1 and 1.2, and 2.0. - -==Getting Started -The best way to start is to look at the rails_openid example. -You can run it with: - cd examples/rails_openid - script/server - -If you are writing an OpenID Relying Party, a good place to start is: -examples/rails_openid/app/controllers/consumer_controller.rb - -And if you are writing an OpenID provider: -examples/rails_openid/app/controllers/server_controller.rb - -The library code is quite well documented, so don't be squeamish, and -look at the library itself if there's anything you don't understand in -the examples. - -==Homepage -http://openidenabled.com/ruby-openid/ - -See also: -http://openid.net/ -http://openidenabled.com/ - -==Community -Discussion regarding the Ruby OpenID library and other JanRain OpenID -libraries takes place on the the OpenID mailing list on -openidenabled.com. - -http://lists.openidenabled.com/mailman/listinfo/dev - -Please join this list to discuss, ask implementation questions, report -bugs, etc. Also check out the openid channel on the freenode IRC -network. - -If you have a bugfix or feature you'd like to contribute, don't -hesitate to send it to us. For more detailed information on how to -contribute, see - - http://openidenabled.com/contribute/ - -==Author -Copyright 2006-2008, JanRain, Inc. - -Contact openid@janrain.com or visit the OpenID channel on pibb.com: - -http://pibb.com/go/openid - -==License -Apache Software License. For more information see the LICENSE file. diff --git a/vendor/gems/ruby-openid-2.1.2/UPGRADE b/vendor/gems/ruby-openid-2.1.2/UPGRADE deleted file mode 100644 index b80e8232..00000000 --- a/vendor/gems/ruby-openid-2.1.2/UPGRADE +++ /dev/null @@ -1,127 +0,0 @@ -= Upgrading from the OpenID 1.x series library - -== Consumer Upgrade - -The flow is largely the same, however there are a number of significant -changes. The consumer example is helpful to look at: -examples/rails_openid/app/controllers/consumer_controller.rb - - -=== Stores - -You will need to require the file for the store that you are using. -For the filesystem store, this is 'openid/stores/filesystem' -They are also now in modules. The filesystem store is - OpenID::Store::Filesystem -The format has changed, and you should remove your old store directory. - -The ActiveRecord store ( examples/active_record_openid_store ) still needs -to be put in a plugin directory for your rails app. There's a migration -that needs to be run; examine the README in that directory. - -Also, note that the stores now can be garbage collected with the method - store.cleanup - - -=== Starting the OpenID transaction - -The OpenIDRequest object no longer has status codes. Instead, -consumer.begin raises an OpenID::OpenIDError if there is a problem -initiating the transaction, so you'll want something along the lines of: - - begin - openid_request = consumer.begin(params[:openid_identifier]) - rescue OpenID::OpenIDError => e - # display error e - return - end - #success case - -Data regarding the OpenID server once lived in - openid_request.service - -The corresponding object in the 2.0 lib can be retrieved with - openid_request.endpoint - -Getting the unverified identifier: Where you once had - openid_request.identity_url -you will now want - openid_request.endpoint.claimed_id -which might be different from what you get at the end of the transaction, -since it is now possible for users to enter their server's url directly. - -Arguments on the return_to URL are now verified, so if you want to add -additional arguments to the return_to url, use - openid_request.return_to_args['param'] = value - -Generating the redirect is the same as before, but add any extensions -first. - -If you need to set up an SSL certificate authority list for the fetcher, -use the 'ca_file' attr_accessor on the OpenID::StandardFetcher. This has -changed from 'ca_path' in the 1.x.x series library. That is, set -OpenID.fetcher.ca_file = '/path/to/ca.list' -before calling consumer.begin. - -=== Requesting Simple Registration Data - -You'll need to require the code for the extension - require 'openid/extensions/sreg' - -The new code for adding an SReg request now looks like: - - sreg_request = OpenID::SReg::Request.new - sreg_request.request_fields(['email', 'dob'], true) # required - sreg_request.request_fields(['nickname', 'fullname'], false) # optional - sreg_request.policy_url = policy_url - openid_request.add_extension(sreg_request) - -The code for adding other extensions is similar. Code for the Attribute -Exchange (AX) and Provider Authentication Policy Extension (PAPE) are -included with the library, and additional extensions can be implemented -subclassing OpenID::Extension. - - -=== Completing the transaction - -The return_to and its arguments are verified, so you need to pass in -the base URL and the arguments. With Rails, the params method mashes -together parameters from GET, POST, and the path, so you'll need to pull -off the path "parameters" with something like - - return_to = url_for(:only_path => false, - :controller => 'openid', - :action => 'complete') - parameters = params.reject{|k,v| request.path_parameters[k] } - openid_response = consumer.complete(parameters, return_to) - -The response still uses the status codes, but they are now namespaced -slightly differently, for example OpenID::Consumer::SUCCESS - -In the case of failure, the error message is now found in - openid_response.message - -The identifier to display to the user can be found in - openid_response.endpoint.display_identifier - -The Simple Registration response can be read from the OpenID response -with - sreg_response = OpenID::SReg::Response.from_success_response(openid_response) - nickname = sreg_response['nickname'] - # etc. - - -== Server Upgrade - -The server code is mostly the same as before, with the exception of -extensions. Also, you must pass in the endpoint URL to the server -constructor: - @server = OpenID::Server.new(store, server_url) - -I recommend looking at -examples/rails_openid/app/controllers/server_controller.rb -for an example of the new way of doing extensions. - --- -Dag Arneson, JanRain Inc. -Please direct questions to openid@janrain.com diff --git a/vendor/gems/ruby-openid-2.1.2/admin/runtests.rb b/vendor/gems/ruby-openid-2.1.2/admin/runtests.rb deleted file mode 100644 index 50abe044..00000000 --- a/vendor/gems/ruby-openid-2.1.2/admin/runtests.rb +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/ruby - -require "logger" -require "stringio" -require "pathname" - -require 'test/unit/collector/dir' -require 'test/unit/ui/console/testrunner' - -def main - old_verbose = $VERBOSE - $VERBOSE = true - - tests_dir = Pathname.new(__FILE__).dirname.dirname.join('test') - - # Collect tests from everything named test_*.rb. - c = Test::Unit::Collector::Dir.new - - if c.respond_to?(:base=) - # In order to supress warnings from ruby 1.8.6 about accessing - # undefined member - c.base = tests_dir - suite = c.collect - else - # Because base is not defined in ruby < 1.8.6 - suite = c.collect(tests_dir) - end - - - result = Test::Unit::UI::Console::TestRunner.run(suite) - result.passed? -ensure - $VERBOSE = old_verbose -end - -exit(main) diff --git a/vendor/gems/ruby-openid-2.1.2/examples/README b/vendor/gems/ruby-openid-2.1.2/examples/README deleted file mode 100644 index 71aa30d7..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/README +++ /dev/null @@ -1,32 +0,0 @@ -This directory contains several examples that demonstrate use of the -OpenID library. Make sure you have properly installed the library -before running the examples. These examples are a great place to -start in integrating OpenID into your application. - -==Rails example - -The rails_openid contains a fully functional OpenID server and relying -party, and acts as a starting point for implementing your own -production rails server. You'll need the latest version of Ruby on -Rails installed, and then: - - cd rails_openid - ./script/server - -Open a web browser to http://localhost:3000/ and follow the instructions. - -The relevant code to work from when writing your Rails OpenID Relying -Party is: - rails_openid/app/controllers/consumer_controller.rb -If you are working on an OpenID provider, check out - rails_openid/app/controllers/server_controller.rb - -Since the library and examples are Apache-licensed, don't be shy about -copy-and-paste. - -==Rails ActiveRecord OpenIDStore plugin - -For various reasons you may want or need to deploy your ruby openid -consumer/server using an SQL based store. The active_record_openid_store -is a plugin that makes using an SQL based store simple. Follow the -README inside the plugin's dir for usage. diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/README b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/README deleted file mode 100644 index 11787298..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/README +++ /dev/null @@ -1,58 +0,0 @@ -=Active Record OpenID Store Plugin - -A store is required by an OpenID server and optionally by the consumer -to store associations, nonces, and auth key information across -requests and processes. If rails is distributed across several -machines, they must must all have access to the same OpenID store -data, so the FilesystemStore won't do. - -This directory contains a plugin for connecting your -OpenID enabled rails app to an ActiveRecord based OpenID store. - -==Install - -1) Copy this directory and all it's contents into your -RAILS_ROOT/vendor/plugins directory. You structure should look like -this: - - RAILS_ROOT/vendor/plugins/active_record_openid_store/ - -2) Copy the migration, XXX_add_open_id_store_to_db.rb to your - RAILS_ROOT/db/migrate directory. Rename the XXX portion of the - file to next sequential migration number. - -3) Run the migration: - - rake migrate - -4) Change your app to use the ActiveRecordOpenIDStore: - - store = ActiveRecordOpenIDStore.new - consumer = OpenID::Consumer.new(session, store) - -5) That's it! All your OpenID state will now be stored in the database. - -==Upgrade - -If you are upgrading from the 1.x ActiveRecord store, replace your old -RAILS_ROOT/vendor/plugins/active_record_openid_store/ directory with -the new one and run the migration XXX_upgrade_open_id_store.rb. - -==What about garbage collection? - -You may garbage collect unused nonces and expired associations using -the gc instance method of ActiveRecordOpenIDStore. Hook it up to a -task in your app's Rakefile like so: - - desc 'GC OpenID store' - task :gc_openid_store => :environment do - ActiveRecordOpenIDStore.new.cleanup - end - -Run it by typing: - - rake gc_openid_store - - -==Questions? -Contact Dag Arneson: dag at janrain dot com diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb deleted file mode 100644 index 99625453..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Use this migration to create the tables for the ActiveRecord store -class AddOpenIdStoreToDb < ActiveRecord::Migration - def self.up - create_table "open_id_associations", :force => true do |t| - t.column "server_url", :binary, :null => false - t.column "handle", :string, :null => false - t.column "secret", :binary, :null => false - t.column "issued", :integer, :null => false - t.column "lifetime", :integer, :null => false - t.column "assoc_type", :string, :null => false - end - - create_table "open_id_nonces", :force => true do |t| - t.column :server_url, :string, :null => false - t.column :timestamp, :integer, :null => false - t.column :salt, :string, :null => false - end - end - - def self.down - drop_table "open_id_associations" - drop_table "open_id_nonces" - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb deleted file mode 100644 index 273d285b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Use this migration to upgrade the old 1.1 ActiveRecord store schema -# to the new 2.0 schema. -class UpgradeOpenIdStore < ActiveRecord::Migration - def self.up - drop_table "open_id_settings" - drop_table "open_id_nonces" - create_table "open_id_nonces", :force => true do |t| - t.column :server_url, :string, :null => false - t.column :timestamp, :integer, :null => false - t.column :salt, :string, :null => false - end - end - - def self.down - drop_table "open_id_nonces" - create_table "open_id_nonces", :force => true do |t| - t.column "nonce", :string - t.column "created", :integer - end - - create_table "open_id_settings", :force => true do |t| - t.column "setting", :string - t.column "value", :binary - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/init.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/init.rb deleted file mode 100644 index b625179e..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/init.rb +++ /dev/null @@ -1,8 +0,0 @@ -# might using the ruby-openid gem -begin - require 'rubygems' -rescue LoadError - nil -end -require 'openid' -require 'openid_ar_store' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/association.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/association.rb deleted file mode 100644 index 09eda8b5..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/association.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'openid/association' -require 'time' - -class Association < ActiveRecord::Base - set_table_name 'open_id_associations' - def from_record - OpenID::Association.new(handle, secret, Time.at(issued), lifetime, assoc_type) - end -end - diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/nonce.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/nonce.rb deleted file mode 100644 index fcf51530..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/nonce.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Nonce < ActiveRecord::Base - set_table_name 'open_id_nonces' -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/open_id_setting.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/open_id_setting.rb deleted file mode 100644 index 030e4c25..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/open_id_setting.rb +++ /dev/null @@ -1,4 +0,0 @@ -class OpenIdSetting < ActiveRecord::Base - - validates_uniqueness_of :setting -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/openid_ar_store.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/openid_ar_store.rb deleted file mode 100644 index 276569c5..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/lib/openid_ar_store.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'association' -require 'nonce' -require 'openid/store/interface' - -# not in OpenID module to avoid namespace conflict -class ActiveRecordStore < OpenID::Store::Interface - def store_association(server_url, assoc) - remove_association(server_url, assoc.handle) - Association.create!(:server_url => server_url, - :handle => assoc.handle, - :secret => assoc.secret, - :issued => assoc.issued.to_i, - :lifetime => assoc.lifetime, - :assoc_type => assoc.assoc_type) - end - - def get_association(server_url, handle=nil) - assocs = if handle.blank? - Association.find_all_by_server_url(server_url) - else - Association.find_all_by_server_url_and_handle(server_url, handle) - end - - assocs.reverse.each do |assoc| - a = assoc.from_record - if a.expires_in == 0 - assoc.destroy - else - return a - end - end if assocs.any? - - return nil - end - - def remove_association(server_url, handle) - Association.delete_all(['server_url = ? AND handle = ?', server_url, handle]) > 0 - end - - def use_nonce(server_url, timestamp, salt) - return false if Nonce.find_by_server_url_and_timestamp_and_salt(server_url, timestamp, salt) - return false if (timestamp - Time.now.to_i).abs > OpenID::Nonce.skew - Nonce.create!(:server_url => server_url, :timestamp => timestamp, :salt => salt) - return true - end - - def cleanup_nonces - now = Time.now.to_i - Nonce.delete_all(["timestamp > ? OR timestamp < ?", now + OpenID::Nonce.skew, now - OpenID::Nonce.skew]) - end - - def cleanup_associations - now = Time.now.to_i - Association.delete_all(['issued + lifetime > ?',now]) - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/test/store_test.rb b/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/test/store_test.rb deleted file mode 100644 index 8e1986c6..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/active_record_openid_store/test/store_test.rb +++ /dev/null @@ -1,212 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../lib') -require 'test/unit' -RAILS_ENV = "test" -require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb')) - -module StoreTestCase - @@allowed_handle = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' - @@allowed_nonce = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - - def _gen_nonce - OpenID::CryptUtil.random_string(8, @@allowed_nonce) - end - - def _gen_handle(n) - OpenID::CryptUtil.random_string(n, @@allowed_handle) - end - - def _gen_secret(n, chars=nil) - OpenID::CryptUtil.random_string(n, chars) - end - - def _gen_assoc(issued, lifetime=600) - secret = _gen_secret(20) - handle = _gen_handle(128) - OpenID::Association.new(handle, secret, Time.now + issued, lifetime, - 'HMAC-SHA1') - end - - def _check_retrieve(url, handle=nil, expected=nil) - ret_assoc = @store.get_association(url, handle) - - if expected.nil? - assert_nil(ret_assoc) - else - assert_equal(expected, ret_assoc) - assert_equal(expected.handle, ret_assoc.handle) - assert_equal(expected.secret, ret_assoc.secret) - end - end - - def _check_remove(url, handle, expected) - present = @store.remove_association(url, handle) - assert_equal(expected, present) - end - - def test_store - server_url = "http://www.myopenid.com/openid" - assoc = _gen_assoc(issued=0) - - # Make sure that a missing association returns no result - _check_retrieve(server_url) - - # Check that after storage, getting returns the same result - @store.store_association(server_url, assoc) - _check_retrieve(server_url, nil, assoc) - - # more than once - _check_retrieve(server_url, nil, assoc) - - # Storing more than once has no ill effect - @store.store_association(server_url, assoc) - _check_retrieve(server_url, nil, assoc) - - # Removing an association that does not exist returns not present - _check_remove(server_url, assoc.handle + 'x', false) - - # Removing an association that does not exist returns not present - _check_remove(server_url + 'x', assoc.handle, false) - - # Removing an association that is present returns present - _check_remove(server_url, assoc.handle, true) - - # but not present on subsequent calls - _check_remove(server_url, assoc.handle, false) - - # Put assoc back in the store - @store.store_association(server_url, assoc) - - # More recent and expires after assoc - assoc2 = _gen_assoc(issued=1) - @store.store_association(server_url, assoc2) - - # After storing an association with a different handle, but the - # same server_url, the handle with the later expiration is returned. - _check_retrieve(server_url, nil, assoc2) - - # We can still retrieve the older association - _check_retrieve(server_url, assoc.handle, assoc) - - # Plus we can retrieve the association with the later expiration - # explicitly - _check_retrieve(server_url, assoc2.handle, assoc2) - - # More recent, and expires earlier than assoc2 or assoc. Make sure - # that we're picking the one with the latest issued date and not - # taking into account the expiration. - assoc3 = _gen_assoc(issued=2, lifetime=100) - @store.store_association(server_url, assoc3) - - _check_retrieve(server_url, nil, assoc3) - _check_retrieve(server_url, assoc.handle, assoc) - _check_retrieve(server_url, assoc2.handle, assoc2) - _check_retrieve(server_url, assoc3.handle, assoc3) - - _check_remove(server_url, assoc2.handle, true) - - _check_retrieve(server_url, nil, assoc3) - _check_retrieve(server_url, assoc.handle, assoc) - _check_retrieve(server_url, assoc2.handle, nil) - _check_retrieve(server_url, assoc3.handle, assoc3) - - _check_remove(server_url, assoc2.handle, false) - _check_remove(server_url, assoc3.handle, true) - - _check_retrieve(server_url, nil, assoc) - _check_retrieve(server_url, assoc.handle, assoc) - _check_retrieve(server_url, assoc2.handle, nil) - _check_retrieve(server_url, assoc3.handle, nil) - - _check_remove(server_url, assoc2.handle, false) - _check_remove(server_url, assoc.handle, true) - _check_remove(server_url, assoc3.handle, false) - - _check_retrieve(server_url, nil, nil) - _check_retrieve(server_url, assoc.handle, nil) - _check_retrieve(server_url, assoc2.handle, nil) - _check_retrieve(server_url, assoc3.handle, nil) - - _check_remove(server_url, assoc2.handle, false) - _check_remove(server_url, assoc.handle, false) - _check_remove(server_url, assoc3.handle, false) - - assocValid1 = _gen_assoc(-3600, 7200) - assocValid2 = _gen_assoc(-5) - assocExpired1 = _gen_assoc(-7200, 3600) - assocExpired2 = _gen_assoc(-7200, 3600) - - @store.cleanup_associations - @store.store_association(server_url + '1', assocValid1) - @store.store_association(server_url + '1', assocExpired1) - @store.store_association(server_url + '2', assocExpired2) - @store.store_association(server_url + '3', assocValid2) - - cleaned = @store.cleanup_associations() - assert_equal(2, cleaned, "cleaned up associations") - end - - def _check_use_nonce(nonce, expected, server_url, msg='') - stamp, salt = OpenID::Nonce::split_nonce(nonce) - actual = @store.use_nonce(server_url, stamp, salt) - assert_equal(expected, actual, msg) - end - - def test_nonce - server_url = "http://www.myopenid.com/openid" - [server_url, ''].each{|url| - nonce1 = OpenID::Nonce::mk_nonce - - _check_use_nonce(nonce1, true, url, "#{url}: nonce allowed by default") - _check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed twice") - _check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed third time") - - # old nonces shouldn't pass - old_nonce = OpenID::Nonce::mk_nonce(3600) - _check_use_nonce(old_nonce, false, url, "Old nonce #{old_nonce.inspect} passed") - - } - - now = Time.now.to_i - old_nonce1 = OpenID::Nonce::mk_nonce(now - 20000) - old_nonce2 = OpenID::Nonce::mk_nonce(now - 10000) - recent_nonce = OpenID::Nonce::mk_nonce(now - 600) - - orig_skew = OpenID::Nonce.skew - OpenID::Nonce.skew = 0 - count = @store.cleanup_nonces - OpenID::Nonce.skew = 1000000 - ts, salt = OpenID::Nonce::split_nonce(old_nonce1) - assert(@store.use_nonce(server_url, ts, salt), "oldnonce1") - ts, salt = OpenID::Nonce::split_nonce(old_nonce2) - assert(@store.use_nonce(server_url, ts, salt), "oldnonce2") - ts, salt = OpenID::Nonce::split_nonce(recent_nonce) - assert(@store.use_nonce(server_url, ts, salt), "recent_nonce") - - - OpenID::Nonce.skew = 1000 - cleaned = @store.cleanup_nonces - assert_equal(2, cleaned, "Cleaned #{cleaned} nonces") - - OpenID::Nonce.skew = 100000 - ts, salt = OpenID::Nonce::split_nonce(old_nonce1) - assert(@store.use_nonce(server_url, ts, salt), "oldnonce1 after cleanup") - ts, salt = OpenID::Nonce::split_nonce(old_nonce2) - assert(@store.use_nonce(server_url, ts, salt), "oldnonce2 after cleanup") - ts, salt = OpenID::Nonce::split_nonce(recent_nonce) - assert(!@store.use_nonce(server_url, ts, salt), "recent_nonce after cleanup") - - OpenID::Nonce.skew = orig_skew - - end -end - - -class TestARStore < Test::Unit::TestCase - include StoreTestCase - - def setup - @store = ActiveRecordStore.new - end - -end - diff --git a/vendor/gems/ruby-openid-2.1.2/examples/discover b/vendor/gems/ruby-openid-2.1.2/examples/discover deleted file mode 100644 index ab985a49..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/discover +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env ruby -require "openid/consumer/discovery" -require 'openid/fetchers' - -OpenID::fetcher_use_env_http_proxy - -$names = [[:server_url, "Server URL "], - [:local_id, "Local ID "], - [:canonical_id, "Canonical ID"], - ] - -def show_services(user_input, normalized, services) - puts " Claimed identifier: #{normalized}" - if services.empty? - puts " No OpenID services found" - puts - else - puts " Discovered services:" - n = 0 - services.each do |service| - n += 1 - puts " #{n}." - $names.each do |meth, name| - val = service.send(meth) - if val - printf(" %s: %s\n", name, val) - end - end - puts " Type URIs:" - for type_uri in service.type_uris - puts " * #{type_uri}" - end - puts - end - end -end - -ARGV.each do |openid_identifier| - puts "=" * 50 - puts "Running discovery on #{openid_identifier}" - begin - normalized_identifier, services = OpenID.discover(openid_identifier) - rescue OpenID::DiscoveryFailure => why - puts "Discovery failed: #{why.message}" - puts - else - show_services(openid_identifier, normalized_identifier, services) - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/README b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/README deleted file mode 100644 index cd9d0ffe..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/README +++ /dev/null @@ -1,153 +0,0 @@ -== Welcome to Rails - -Rails is a web-application and persistence framework that includes everything -needed to create database-backed web-applications according to the -Model-View-Control pattern of separation. This pattern splits the view (also -called the presentation) into "dumb" templates that are primarily responsible -for inserting pre-built data in between HTML tags. The model contains the -"smart" domain objects (such as Account, Product, Person, Post) that holds all -the business logic and knows how to persist themselves to a database. The -controller handles the incoming requests (such as Save New Account, Update -Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting started - -1. Run the WEBrick servlet: ruby script/server (run with --help for options) - ...or if you have lighttpd installed: ruby script/lighttpd (it's faster) -2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!" -3. Follow the guidelines on the "Congratulations, you've put Ruby on Rails!" screen - - -== Example for Apache conf - - - ServerName rails - DocumentRoot /path/application/public/ - ErrorLog /path/application/log/server.log - - - Options ExecCGI FollowSymLinks - AllowOverride all - Allow from all - Order allow,deny - - - -NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI -should be on and ".cgi" should respond. All requests from 127.0.0.1 go -through CGI, so no Apache restart is necessary for changes. All other requests -go through FCGI (or mod_ruby), which requires a restart to show changes. - - -== Debugging Rails - -Have "tail -f" commands running on both the server.log, production.log, and -test.log files. Rails will automatically display debugging and runtime -information to these files. Debugging info will also be shown in the browser -on requests from 127.0.0.1. - - -== Breakpoints - -Breakpoint support is available through the script/breakpointer client. This -means that you can break out of execution at any point in the code, investigate -and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find_all - breakpoint "Breaking out from the list" - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the breakpointer window. Here you can do things like: - -Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you press CTRL-D - - -== Console - -You can interact with the domain model by starting the console through script/console. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like console production. - - -== Description of contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblog_controller.rb for - automated URL mapping. All controllers should descend from - ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblog/index.rhtml for the WeblogController#index action. All views use eRuby - syntax. This directory can also be used to keep stylesheets, images, and so on - that can be symlinked to public. - -app/helpers - Holds view helpers that should be named like weblog_helper.rb. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -components - Self-contained mini-applications that can bundle together controllers, models, and views. - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - This directory is in the load path. diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/Rakefile b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/Rakefile deleted file mode 100644 index cffd19f0..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/Rakefile +++ /dev/null @@ -1,10 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. - -require(File.join(File.dirname(__FILE__), 'config', 'boot')) - -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -require 'tasks/rails' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/application.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/application.rb deleted file mode 100644 index 537de40d..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/application.rb +++ /dev/null @@ -1,4 +0,0 @@ -# Filters added to this controller will be run for all controllers in the application. -# Likewise, all the methods added will be available for all controllers. -class ApplicationController < ActionController::Base -end \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/consumer_controller.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/consumer_controller.rb deleted file mode 100644 index 37dd3bbd..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/consumer_controller.rb +++ /dev/null @@ -1,122 +0,0 @@ -require 'pathname' - -require "openid" -require 'openid/extensions/sreg' -require 'openid/extensions/pape' -require 'openid/store/filesystem' - -class ConsumerController < ApplicationController - layout nil - - def index - # render an openid form - end - - def start - begin - identifier = params[:openid_identifier] - if identifier.nil? - flash[:error] = "Enter an OpenID identifier" - redirect_to :action => 'index' - return - end - oidreq = consumer.begin(identifier) - rescue OpenID::OpenIDError => e - flash[:error] = "Discovery failed for #{identifier}: #{e}" - redirect_to :action => 'index' - return - end - if params[:use_sreg] - sregreq = OpenID::SReg::Request.new - # required fields - sregreq.request_fields(['email','nickname'], true) - # optional fields - sregreq.request_fields(['dob', 'fullname'], false) - oidreq.add_extension(sregreq) - oidreq.return_to_args['did_sreg'] = 'y' - end - if params[:use_pape] - papereq = OpenID::PAPE::Request.new - papereq.add_policy_uri(OpenID::PAPE::AUTH_PHISHING_RESISTANT) - papereq.max_auth_age = 2*60*60 - oidreq.add_extension(papereq) - oidreq.return_to_args['did_pape'] = 'y' - end - if params[:force_post] - oidreq.return_to_args['force_post']='x'*2048 - end - return_to = url_for :action => 'complete', :only_path => false - realm = url_for :action => 'index', :only_path => false - - if oidreq.send_redirect?(realm, return_to, params[:immediate]) - redirect_to oidreq.redirect_url(realm, return_to, params[:immediate]) - else - render :text => oidreq.html_markup(realm, return_to, params[:immediate], {'id' => 'openid_form'}) - end - end - - def complete - # FIXME - url_for some action is not necessarily the current URL. - current_url = url_for(:action => 'complete', :only_path => false) - parameters = params.reject{|k,v|request.path_parameters[k]} - oidresp = consumer.complete(parameters, current_url) - case oidresp.status - when OpenID::Consumer::FAILURE - if oidresp.display_identifier - flash[:error] = ("Verification of #{oidresp.display_identifier}"\ - " failed: #{oidresp.message}") - else - flash[:error] = "Verification failed: #{oidresp.message}" - end - when OpenID::Consumer::SUCCESS - flash[:success] = ("Verification of #{oidresp.display_identifier}"\ - " succeeded.") - if params[:did_sreg] - sreg_resp = OpenID::SReg::Response.from_success_response(oidresp) - sreg_message = "Simple Registration data was requested" - if sreg_resp.empty? - sreg_message << ", but none was returned." - else - sreg_message << ". The following data were sent:" - sreg_resp.data.each {|k,v| - sreg_message << "
    #{k}: #{v}" - } - end - flash[:sreg_results] = sreg_message - end - if params[:did_pape] - pape_resp = OpenID::PAPE::Response.from_success_response(oidresp) - pape_message = "A phishing resistant authentication method was requested" - if pape_resp.auth_policies.member? OpenID::PAPE::AUTH_PHISHING_RESISTANT - pape_message << ", and the server reported one." - else - pape_message << ", but the server did not report one." - end - if pape_resp.auth_time - pape_message << "
    Authentication time: #{pape_resp.auth_time} seconds" - end - if pape_resp.nist_auth_level - pape_message << "
    NIST Auth Level: #{pape_resp.nist_auth_level}" - end - flash[:pape_results] = pape_message - end - when OpenID::Consumer::SETUP_NEEDED - flash[:alert] = "Immediate request failed - Setup Needed" - when OpenID::Consumer::CANCEL - flash[:alert] = "OpenID transaction cancelled." - else - end - redirect_to :action => 'index' - end - - private - - def consumer - if @consumer.nil? - dir = Pathname.new(RAILS_ROOT).join('db').join('cstore') - store = OpenID::Store::Filesystem.new(dir) - @consumer = OpenID::Consumer.new(session, store) - end - return @consumer - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/login_controller.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/login_controller.rb deleted file mode 100644 index ff7c257b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/login_controller.rb +++ /dev/null @@ -1,45 +0,0 @@ -# Controller for handling the login, logout process for "users" of our -# little server. Users have no password. This is just an example. - -require 'openid' - -class LoginController < ApplicationController - - layout 'server' - - def base_url - url_for(:controller => 'login', :action => nil, :only_path => false) - end - - def index - response.headers['X-XRDS-Location'] = url_for(:controller => "server", - :action => "idp_xrds", - :only_path => false) - @base_url = base_url - # just show the login page - end - - def submit - user = params[:username] - - # if we get a user, log them in by putting their username in - # the session hash. - unless user.nil? - session[:username] = user unless user.nil? - session[:approvals] = [] - flash[:notice] = "Your OpenID URL is #{base_url}user/#{user}

    Proceed to step 2 below." - else - flash[:error] = "Sorry, couldn't log you in. Try again." - end - - redirect_to :action => 'index' - end - - def logout - # delete the username from the session hash - session[:username] = nil - session[:approvals] = nil - redirect_to :action => 'index' - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/server_controller.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/server_controller.rb deleted file mode 100644 index af0b1a7c..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/controllers/server_controller.rb +++ /dev/null @@ -1,265 +0,0 @@ -require 'pathname' - -# load the openid library, first trying rubygems -#begin -# require "rubygems" -# require_gem "ruby-openid", ">= 1.0" -#rescue LoadError -require "openid" -require "openid/consumer/discovery" -require 'openid/extensions/sreg' -require 'openid/extensions/pape' -require 'openid/store/filesystem' -#end - -class ServerController < ApplicationController - - include ServerHelper - include OpenID::Server - layout nil - - def index - begin - oidreq = server.decode_request(params) - rescue ProtocolError => e - # invalid openid request, so just display a page with an error message - render :text => e.to_s, :status => 500 - return - end - - # no openid.mode was given - unless oidreq - render :text => "This is an OpenID server endpoint." - return - end - - oidresp = nil - - if oidreq.kind_of?(CheckIDRequest) - - identity = oidreq.identity - - if oidreq.id_select - if oidreq.immediate - oidresp = oidreq.answer(false) - elsif session[:username].nil? - # The user hasn't logged in. - show_decision_page(oidreq) - return - else - # Else, set the identity to the one the user is using. - identity = url_for_user - end - end - - if oidresp - nil - elsif self.is_authorized(identity, oidreq.trust_root) - oidresp = oidreq.answer(true, nil, identity) - - # add the sreg response if requested - add_sreg(oidreq, oidresp) - # ditto pape - add_pape(oidreq, oidresp) - - elsif oidreq.immediate - server_url = url_for :action => 'index' - oidresp = oidreq.answer(false, server_url) - - else - show_decision_page(oidreq) - return - end - - else - oidresp = server.handle_request(oidreq) - end - - self.render_response(oidresp) - end - - def show_decision_page(oidreq, message="Do you trust this site with your identity?") - session[:last_oidreq] = oidreq - @oidreq = oidreq - - if message - flash[:notice] = message - end - - render :template => 'server/decide', :layout => 'server' - end - - def user_page - # Yadis content-negotiation: we want to return the xrds if asked for. - accept = request.env['HTTP_ACCEPT'] - - # This is not technically correct, and should eventually be updated - # to do real Accept header parsing and logic. Though I expect it will work - # 99% of the time. - if accept and accept.include?('application/xrds+xml') - user_xrds - return - end - - # content negotiation failed, so just render the user page - xrds_url = url_for(:controller=>'user',:action=>params[:username])+'/xrds' - identity_page = < - - -

    OpenID identity page for #{params[:username]}

    - -EOS - - # Also add the Yadis location header, so that they don't have - # to parse the html unless absolutely necessary. - response.headers['X-XRDS-Location'] = xrds_url - render :text => identity_page - end - - def user_xrds - types = [ - OpenID::OPENID_2_0_TYPE, - OpenID::OPENID_1_0_TYPE, - OpenID::SREG_URI, - ] - - render_xrds(types) - end - - def idp_xrds - types = [ - OpenID::OPENID_IDP_2_0_TYPE, - ] - - render_xrds(types) - end - - def decision - oidreq = session[:last_oidreq] - session[:last_oidreq] = nil - - if params[:yes].nil? - redirect_to oidreq.cancel_url - return - else - id_to_send = params[:id_to_send] - - identity = oidreq.identity - if oidreq.id_select - if id_to_send and id_to_send != "" - session[:username] = id_to_send - session[:approvals] = [] - identity = url_for_user - else - msg = "You must enter a username to in order to send " + - "an identifier to the Relying Party." - show_decision_page(oidreq, msg) - return - end - end - - if session[:approvals] - session[:approvals] << oidreq.trust_root - else - session[:approvals] = [oidreq.trust_root] - end - oidresp = oidreq.answer(true, nil, identity) - add_sreg(oidreq, oidresp) - add_pape(oidreq, oidresp) - return self.render_response(oidresp) - end - end - - protected - - def server - if @server.nil? - server_url = url_for :action => 'index', :only_path => false - dir = Pathname.new(RAILS_ROOT).join('db').join('openid-store') - store = OpenID::Store::Filesystem.new(dir) - @server = Server.new(store, server_url) - end - return @server - end - - def approved(trust_root) - return false if session[:approvals].nil? - return session[:approvals].member?(trust_root) - end - - def is_authorized(identity_url, trust_root) - return (session[:username] and (identity_url == url_for_user) and self.approved(trust_root)) - end - - def render_xrds(types) - type_str = "" - - types.each { |uri| - type_str += "#{uri}\n " - } - - yadis = < - - - - #{type_str} - #{url_for(:controller => 'server', :only_path => false)} - - - -EOS - - response.headers['content-type'] = 'application/xrds+xml' - render :text => yadis - end - - def add_sreg(oidreq, oidresp) - # check for Simple Registration arguments and respond - sregreq = OpenID::SReg::Request.from_openid_request(oidreq) - - return if sregreq.nil? - # In a real application, this data would be user-specific, - # and the user should be asked for permission to release - # it. - sreg_data = { - 'nickname' => session[:username], - 'fullname' => 'Mayor McCheese', - 'email' => 'mayor@example.com' - } - - sregresp = OpenID::SReg::Response.extract_response(sregreq, sreg_data) - oidresp.add_extension(sregresp) - end - - def add_pape(oidreq, oidresp) - papereq = OpenID::PAPE::Request.from_openid_request(oidreq) - return if papereq.nil? - paperesp = OpenID::PAPE::Response.new - paperesp.nist_auth_level = 0 # we don't even do auth at all! - oidresp.add_extension(paperesp) - end - - def render_response(oidresp) - if oidresp.needs_signing - signed_response = server.signatory.sign(oidresp) - end - web_response = server.encode_response(oidresp) - - case web_response.code - when HTTP_OK - render :text => web_response.body, :status => 200 - - when HTTP_REDIRECT - redirect_to web_response.headers['location'] - - else - render :text => web_response.body, :status => 400 - end - end - - -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/application_helper.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/application_helper.rb deleted file mode 100644 index 22a7940e..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/application_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Methods added to this helper will be available to all templates in the application. -module ApplicationHelper -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/login_helper.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/login_helper.rb deleted file mode 100644 index a0418e32..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/login_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module LoginHelper -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/server_helper.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/server_helper.rb deleted file mode 100644 index 409b2104..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/helpers/server_helper.rb +++ /dev/null @@ -1,9 +0,0 @@ - -module ServerHelper - - def url_for_user - url_for :controller => 'user', :action => session[:username] - end - -end - diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/consumer/index.rhtml b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/consumer/index.rhtml deleted file mode 100644 index 0cecbe8e..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/consumer/index.rhtml +++ /dev/null @@ -1,81 +0,0 @@ - - -Rails OpenID Example Relying Party - - - -

    Rails OpenID Example Relying Party

    - <% if flash[:alert] %> -
    - <%= h(flash[:alert]) %> -
    - <% end %> - <% if flash[:error] %> -
    - <%= h(flash[:error]) %> -
    - <% end %> - <% if flash[:success] %> -
    - <%= h(flash[:success]) %> -
    - <% end %> - <% if flash[:sreg_results] %> -
    - <%= flash[:sreg_results] %> -
    - <% end %> - <% if flash[:pape_results] %> -
    - <%= flash[:pape_results] %> -
    - <% end %> -
    -
    '> - Identifier: - -
    -
    -
    -
    - -
    -
    - - diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/layouts/server.rhtml b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/layouts/server.rhtml deleted file mode 100644 index 3dd5d786..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/layouts/server.rhtml +++ /dev/null @@ -1,68 +0,0 @@ - - OpenID Server Example - - - - - - <% if session[:username] %> -
    - Welcome, <%= session[:username] %> | <%= link_to('Log out', :controller => 'login', :action => 'logout') %>
    - <%= @base_url %>user/<%= session[:username] %> -
    - <% end %> - -

    Ruby OpenID Server Example

    - -
    - - <% if flash[:notice] or flash[:error] %> -
    - <%= flash[:error] or flash[:notice] %> -
    - <% end %> - - <%= @content_for_layout %> - - - - diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/login/index.rhtml b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/login/index.rhtml deleted file mode 100644 index 9990a575..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/login/index.rhtml +++ /dev/null @@ -1,56 +0,0 @@ - - -<% if session[:username].nil? %> - -
    -
    -Type a username: - - -
    - -
    - -<% end %> - -

    Welcome to the Ruby OpenID example. This code is a starting point -for developers wishing to implement an OpenID provider or relying -party. We've used the Rails -platform to demonstrate, but the library code is not Rails specific.

    - -

    To use the example provider

    -

    -

      - -
    1. Enter a username in the form above. You will be "Logged In" - to the server, at which point you may authenticate using an OpenID - consumer. Your OpenID URL will be displayed after you log - in.

      The server will automatically create an identity page for - you at <%= @base_url %>user/name

    2. - -
    3. Because WEBrick can only handle one thing at a time, you'll need to - run another instance of the example on another port if you want to use - a relying party to use with this example provider:

      -
      - script/server --port=3001 -
      - -

      (The RP needs to be able to access the provider, so unless you're - running this example on a public IP, you can't use the live example - at openidenabled.com on - your local provider.)

      -
    4. - -
    5. Point your browser to this new instance and follow the directions - below.
    6. - -
    - -

    - -

    To use the example relying party

    - -

    Visit /consumer -and enter your OpenID.

    -

    - diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/server/decide.rhtml b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/server/decide.rhtml deleted file mode 100644 index 5322b48a..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/app/views/server/decide.rhtml +++ /dev/null @@ -1,26 +0,0 @@ -
    - - - - - <% if @oidreq.id_select %> - - - - - - - - <% else %> - - <% end %> -
    Site:<%= @oidreq.trust_root %>
    - You entered the server identifier at the relying party. - You'll need to send an identifier of your choosing. Enter a - username below. -
    Identity to send:
    Identity:<%= @oidreq.identity %>
    - - - - -
    diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/boot.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/boot.rb deleted file mode 100644 index 9fcd50fe..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/boot.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb - -unless defined?(RAILS_ROOT) - root_path = File.join(File.dirname(__FILE__), '..') - unless RUBY_PLATFORM =~ /mswin32/ - require 'pathname' - root_path = Pathname.new(root_path).cleanpath(true).to_s - end - RAILS_ROOT = root_path -end - -if File.directory?("#{RAILS_ROOT}/vendor/rails") - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" -else - require 'rubygems' - require 'initializer' -end - -Rails::Initializer.run(:set_load_path) diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/database.yml b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/database.yml deleted file mode 100644 index 1b2eb82d..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/database.yml +++ /dev/null @@ -1,74 +0,0 @@ -# MySQL (default setup). Versions 4.1 and 5.0 are recommended. -# -# Get the fast C bindings: -# gem install mysql -# (on OS X: gem install mysql -- --include=/usr/local/lib) -# And be sure to use new-style password hashing: -# http://dev.mysql.com/doc/refman/5.0/en/old-client.html -development: - adapter: sqlite3 - database: db/development.sqlite3 - -# Warning: The database defined as 'test' will be erased and -# re-generated from your development database when you run 'rake'. -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: ":memory:" - -production: - adapter: mysql - database: rails_server_production - username: root - password: - socket: /path/to/your/mysql.sock - - -# PostgreSQL versions 7.4 - 8.1 -# -# Get the C bindings: -# gem install postgres -# or use the pure-Ruby bindings on Windows: -# gem install postgres-pr -postgresql_example: - adapter: postgresql - database: rails_server_development - username: rails_server - password: - - # Connect on a TCP socket. Omitted by default since the client uses a - # domain socket that doesn't need configuration. - #host: remote-database - #port: 5432 - - # Schema search path. The server defaults to $user,public - #schema_search_path: myapp,sharedapp,public - - # Character set encoding. The server defaults to sql_ascii. - #encoding: UTF8 - - # Minimum log levels, in increasing order: - # debug5, debug4, debug3, debug2, debug1, - # info, notice, warning, error, log, fatal, or panic - # The server defaults to notice. - #min_messages: warning - - -# SQLite version 2.x -# gem install sqlite-ruby -sqlite_example: - adapter: sqlite - database: db/development.sqlite2 - - -# SQLite version 3.x -# gem install sqlite3-ruby -sqlite3_example: - adapter: sqlite3 - database: db/development.sqlite3 - - -# In-memory SQLite 3 database. Useful for tests. -sqlite3_in_memory_example: - adapter: sqlite3 - database: ":memory:" \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environment.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environment.rb deleted file mode 100644 index 0a78bf83..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environment.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Be sure to restart your web server when you modify this file. - -# Uncomment below to force Rails into production mode when -# you don't control web/app server and can't set it the proper way -# ENV['RAILS_ENV'] ||= 'production' - -# Bootstrap the Rails environment, frameworks, and default configuration -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence those specified here - - # Skip frameworks you're not going to use - # config.frameworks -= [ :action_web_service, :action_mailer ] - - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Force all environments to use the same logger level - # (by default production uses :info, the others :debug) - # config.log_level = :debug - - # Use the database for sessions instead of the file system - # (create the session table with 'rake create_sessions_table') - # config.action_controller.session_store = :active_record_store - - # Enable page/fragment caching by setting a file-based store - # (remember to create the caching directory and make it readable to the application) - # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache" - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector - - # Make Active Record use UTC-base instead of local time - # config.active_record.default_timezone = :utc - - # Use Active Record's schema dumper instead of SQL when creating the test database - # (enables use of different database adapters for development and test environments) - # config.active_record.schema_format = :ruby - - # See Rails::Configuration for more options -end - -# Add new inflection rules using the following format -# (all these examples are active by default): -# Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end - -# Include your application configuration below -ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = '_session_id_2' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/development.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/development.rb deleted file mode 100644 index 04b77920..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/development.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# In the development environment your application's code is reloaded on -# every request. This slows down response time but is perfect for development -# since you don't have to restart the webserver when you make code changes. -config.cache_classes = false - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Enable the breakpoint server that script/breakpointer connects to -config.breakpoint_server = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false - -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/production.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/production.rb deleted file mode 100644 index c9a4396c..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/production.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true - -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new - - -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true - -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" - -# Disable delivery errors if you bad email addresses should just be ignored -# config.action_mailer.raise_delivery_errors = false diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/test.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/test.rb deleted file mode 100644 index 6a4cddbd..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/environments/test.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = true - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false - -# Tell ActionMailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/routes.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/routes.rb deleted file mode 100644 index d5ceed20..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/config/routes.rb +++ /dev/null @@ -1,24 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - # Add your own custom routes here. - # The priority is based upon order of creation: first created -> highest priority. - - # Here's a sample route: - # map.connect 'products/:id', :controller => 'catalog', :action => 'view' - # Keep in mind you can assign values other than :controller and :action - - # You can have the root of your site routed by hooking up '' - # -- just remember to delete public/index.html. - # map.connect '', :controller => "welcome" - - map.connect '', :controller => 'login' - map.connect 'server/xrds', :controller => 'server', :action => 'idp_xrds' - map.connect 'user/:username', :controller => 'server', :action => 'user_page' - map.connect 'user/:username/xrds', :controller => 'server', :action => 'user_xrds' - - # Allow downloading Web Service WSDL as a file with an extension - # instead of a file named 'wsdl' - map.connect ':controller/service.wsdl', :action => 'wsdl' - - # Install the default route as the lowest priority. - map.connect ':controller/:action/:id' -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/doc/README_FOR_APP b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/doc/README_FOR_APP deleted file mode 100644 index ac6c1491..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -Use this README file to introduce your application and point to useful places in the API for learning more. -Run "rake appdoc" to generate API documentation for your models and controllers. \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/404.html b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/404.html deleted file mode 100644 index 0e184561..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/404.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -

    File not found

    -

    Change this error message for pages not found in public/404.html

    - - \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/500.html b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/500.html deleted file mode 100644 index a1001a00..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/500.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -

    Application error (Apache)

    -

    Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html

    - - \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.cgi b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.cgi deleted file mode 100644 index dfe5dc30..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.cgi +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/ruby1.8 - -#!/usr/local/bin/ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.fcgi b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.fcgi deleted file mode 100644 index d02c35b8..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.fcgi +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/ruby1.8 - -#!/usr/local/bin/ruby -# -# You may specify the path to the FastCGI crash log (a log of unhandled -# exceptions which forced the FastCGI instance to exit, great for debugging) -# and the number of requests to process before running garbage collection. -# -# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log -# and the GC period is nil (turned off). A reasonable number of requests -# could range from 10-100 depending on the memory footprint of your app. -# -# Example: -# # Default log path, normal GC behavior. -# RailsFCGIHandler.process! -# -# # Default log path, 50 requests between GC. -# RailsFCGIHandler.process! nil, 50 -# -# # Custom log path, normal GC behavior. -# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' -# -require File.dirname(__FILE__) + "/../config/environment" -require 'fcgi_handler' - -RailsFCGIHandler.process! diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.rb deleted file mode 100644 index dfe5dc30..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/dispatch.rb +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/ruby1.8 - -#!/usr/local/bin/ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/favicon.ico b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/images/openid_login_bg.gif b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/images/openid_login_bg.gif deleted file mode 100644 index cde836c8..00000000 Binary files a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/images/openid_login_bg.gif and /dev/null differ diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/controls.js b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/controls.js deleted file mode 100644 index 9742b691..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/controls.js +++ /dev/null @@ -1,750 +0,0 @@ -// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) -// (c) 2005 Jon Tirsen (http://www.tirsen.com) -// Contributors: -// Richard Livsey -// Rahul Bhargava -// Rob Wills -// -// See scriptaculous.js for full license. - -// Autocompleter.Base handles all the autocompletion functionality -// that's independent of the data source for autocompletion. This -// includes drawing the autocompletion menu, observing keyboard -// and mouse events, and similar. -// -// Specific autocompleters need to provide, at the very least, -// a getUpdatedChoices function that will be invoked every time -// the text inside the monitored textbox changes. This method -// should get the text for which to provide autocompletion by -// invoking this.getToken(), NOT by directly accessing -// this.element.value. This is to allow incremental tokenized -// autocompletion. Specific auto-completion logic (AJAX, etc) -// belongs in getUpdatedChoices. -// -// Tokenized incremental autocompletion is enabled automatically -// when an autocompleter is instantiated with the 'tokens' option -// in the options parameter, e.g.: -// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); -// will incrementally autocomplete with a comma as the token. -// Additionally, ',' in the above example can be replaced with -// a token array, e.g. { tokens: [',', '\n'] } which -// enables autocompletion on multiple tokens. This is most -// useful when one of the tokens is \n (a newline), as it -// allows smart autocompletion after linebreaks. - -var Autocompleter = {} -Autocompleter.Base = function() {}; -Autocompleter.Base.prototype = { - baseInitialize: function(element, update, options) { - this.element = $(element); - this.update = $(update); - this.hasFocus = false; - this.changed = false; - this.active = false; - this.index = 0; - this.entryCount = 0; - - if (this.setOptions) - this.setOptions(options); - else - this.options = options || {}; - - this.options.paramName = this.options.paramName || this.element.name; - this.options.tokens = this.options.tokens || []; - this.options.frequency = this.options.frequency || 0.4; - this.options.minChars = this.options.minChars || 1; - this.options.onShow = this.options.onShow || - function(element, update){ - if(!update.style.position || update.style.position=='absolute') { - update.style.position = 'absolute'; - Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); - } - Effect.Appear(update,{duration:0.15}); - }; - this.options.onHide = this.options.onHide || - function(element, update){ new Effect.Fade(update,{duration:0.15}) }; - - if (typeof(this.options.tokens) == 'string') - this.options.tokens = new Array(this.options.tokens); - - this.observer = null; - - this.element.setAttribute('autocomplete','off'); - - Element.hide(this.update); - - Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); - Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); - }, - - show: function() { - if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); - if(!this.iefix && - (navigator.appVersion.indexOf('MSIE')>0) && - (navigator.userAgent.indexOf('Opera')<0) && - (Element.getStyle(this.update, 'position')=='absolute')) { - new Insertion.After(this.update, - ''); - this.iefix = $(this.update.id+'_iefix'); - } - if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); - }, - - fixIEOverlapping: function() { - Position.clone(this.update, this.iefix); - this.iefix.style.zIndex = 1; - this.update.style.zIndex = 2; - Element.show(this.iefix); - }, - - hide: function() { - this.stopIndicator(); - if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); - if(this.iefix) Element.hide(this.iefix); - }, - - startIndicator: function() { - if(this.options.indicator) Element.show(this.options.indicator); - }, - - stopIndicator: function() { - if(this.options.indicator) Element.hide(this.options.indicator); - }, - - onKeyPress: function(event) { - if(this.active) - switch(event.keyCode) { - case Event.KEY_TAB: - case Event.KEY_RETURN: - this.selectEntry(); - Event.stop(event); - case Event.KEY_ESC: - this.hide(); - this.active = false; - Event.stop(event); - return; - case Event.KEY_LEFT: - case Event.KEY_RIGHT: - return; - case Event.KEY_UP: - this.markPrevious(); - this.render(); - if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); - return; - case Event.KEY_DOWN: - this.markNext(); - this.render(); - if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); - return; - } - else - if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN) - return; - - this.changed = true; - this.hasFocus = true; - - if(this.observer) clearTimeout(this.observer); - this.observer = - setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); - }, - - onHover: function(event) { - var element = Event.findElement(event, 'LI'); - if(this.index != element.autocompleteIndex) - { - this.index = element.autocompleteIndex; - this.render(); - } - Event.stop(event); - }, - - onClick: function(event) { - var element = Event.findElement(event, 'LI'); - this.index = element.autocompleteIndex; - this.selectEntry(); - this.hide(); - }, - - onBlur: function(event) { - // needed to make click events working - setTimeout(this.hide.bind(this), 250); - this.hasFocus = false; - this.active = false; - }, - - render: function() { - if(this.entryCount > 0) { - for (var i = 0; i < this.entryCount; i++) - this.index==i ? - Element.addClassName(this.getEntry(i),"selected") : - Element.removeClassName(this.getEntry(i),"selected"); - - if(this.hasFocus) { - this.show(); - this.active = true; - } - } else { - this.active = false; - this.hide(); - } - }, - - markPrevious: function() { - if(this.index > 0) this.index-- - else this.index = this.entryCount-1; - }, - - markNext: function() { - if(this.index < this.entryCount-1) this.index++ - else this.index = 0; - }, - - getEntry: function(index) { - return this.update.firstChild.childNodes[index]; - }, - - getCurrentEntry: function() { - return this.getEntry(this.index); - }, - - selectEntry: function() { - this.active = false; - this.updateElement(this.getCurrentEntry()); - }, - - updateElement: function(selectedElement) { - if (this.options.updateElement) { - this.options.updateElement(selectedElement); - return; - } - - var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - var lastTokenPos = this.findLastToken(); - if (lastTokenPos != -1) { - var newValue = this.element.value.substr(0, lastTokenPos + 1); - var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); - if (whitespace) - newValue += whitespace[0]; - this.element.value = newValue + value; - } else { - this.element.value = value; - } - this.element.focus(); - - if (this.options.afterUpdateElement) - this.options.afterUpdateElement(this.element, selectedElement); - }, - - updateChoices: function(choices) { - if(!this.changed && this.hasFocus) { - this.update.innerHTML = choices; - Element.cleanWhitespace(this.update); - Element.cleanWhitespace(this.update.firstChild); - - if(this.update.firstChild && this.update.firstChild.childNodes) { - this.entryCount = - this.update.firstChild.childNodes.length; - for (var i = 0; i < this.entryCount; i++) { - var entry = this.getEntry(i); - entry.autocompleteIndex = i; - this.addObservers(entry); - } - } else { - this.entryCount = 0; - } - - this.stopIndicator(); - - this.index = 0; - this.render(); - } - }, - - addObservers: function(element) { - Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); - Event.observe(element, "click", this.onClick.bindAsEventListener(this)); - }, - - onObserverEvent: function() { - this.changed = false; - if(this.getToken().length>=this.options.minChars) { - this.startIndicator(); - this.getUpdatedChoices(); - } else { - this.active = false; - this.hide(); - } - }, - - getToken: function() { - var tokenPos = this.findLastToken(); - if (tokenPos != -1) - var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); - else - var ret = this.element.value; - - return /\n/.test(ret) ? '' : ret; - }, - - findLastToken: function() { - var lastTokenPos = -1; - - for (var i=0; i lastTokenPos) - lastTokenPos = thisTokenPos; - } - return lastTokenPos; - } -} - -Ajax.Autocompleter = Class.create(); -Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { - initialize: function(element, update, url, options) { - this.baseInitialize(element, update, options); - this.options.asynchronous = true; - this.options.onComplete = this.onComplete.bind(this); - this.options.defaultParams = this.options.parameters || null; - this.url = url; - }, - - getUpdatedChoices: function() { - entry = encodeURIComponent(this.options.paramName) + '=' + - encodeURIComponent(this.getToken()); - - this.options.parameters = this.options.callback ? - this.options.callback(this.element, entry) : entry; - - if(this.options.defaultParams) - this.options.parameters += '&' + this.options.defaultParams; - - new Ajax.Request(this.url, this.options); - }, - - onComplete: function(request) { - this.updateChoices(request.responseText); - } - -}); - -// The local array autocompleter. Used when you'd prefer to -// inject an array of autocompletion options into the page, rather -// than sending out Ajax queries, which can be quite slow sometimes. -// -// The constructor takes four parameters. The first two are, as usual, -// the id of the monitored textbox, and id of the autocompletion menu. -// The third is the array you want to autocomplete from, and the fourth -// is the options block. -// -// Extra local autocompletion options: -// - choices - How many autocompletion choices to offer -// -// - partialSearch - If false, the autocompleter will match entered -// text only at the beginning of strings in the -// autocomplete array. Defaults to true, which will -// match text at the beginning of any *word* in the -// strings in the autocomplete array. If you want to -// search anywhere in the string, additionally set -// the option fullSearch to true (default: off). -// -// - fullSsearch - Search anywhere in autocomplete array strings. -// -// - partialChars - How many characters to enter before triggering -// a partial match (unlike minChars, which defines -// how many characters are required to do any match -// at all). Defaults to 2. -// -// - ignoreCase - Whether to ignore case when autocompleting. -// Defaults to true. -// -// It's possible to pass in a custom function as the 'selector' -// option, if you prefer to write your own autocompletion logic. -// In that case, the other options above will not apply unless -// you support them. - -Autocompleter.Local = Class.create(); -Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), { - initialize: function(element, update, array, options) { - this.baseInitialize(element, update, options); - this.options.array = array; - }, - - getUpdatedChoices: function() { - this.updateChoices(this.options.selector(this)); - }, - - setOptions: function(options) { - this.options = Object.extend({ - choices: 10, - partialSearch: true, - partialChars: 2, - ignoreCase: true, - fullSearch: false, - selector: function(instance) { - var ret = []; // Beginning matches - var partial = []; // Inside matches - var entry = instance.getToken(); - var count = 0; - - for (var i = 0; i < instance.options.array.length && - ret.length < instance.options.choices ; i++) { - - var elem = instance.options.array[i]; - var foundPos = instance.options.ignoreCase ? - elem.toLowerCase().indexOf(entry.toLowerCase()) : - elem.indexOf(entry); - - while (foundPos != -1) { - if (foundPos == 0 && elem.length != entry.length) { - ret.push("
  • " + elem.substr(0, entry.length) + "" + - elem.substr(entry.length) + "
  • "); - break; - } else if (entry.length >= instance.options.partialChars && - instance.options.partialSearch && foundPos != -1) { - if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) { - partial.push("
  • " + elem.substr(0, foundPos) + "" + - elem.substr(foundPos, entry.length) + "" + elem.substr( - foundPos + entry.length) + "
  • "); - break; - } - } - - foundPos = instance.options.ignoreCase ? - elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : - elem.indexOf(entry, foundPos + 1); - - } - } - if (partial.length) - ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) - return "
      " + ret.join('') + "
    "; - } - }, options || {}); - } -}); - -// AJAX in-place editor -// -// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor - -// Use this if you notice weird scrolling problems on some browsers, -// the DOM might be a bit confused when this gets called so do this -// waits 1 ms (with setTimeout) until it does the activation -Field.scrollFreeActivate = function(field) { - setTimeout(function() { - Field.activate(field); - }, 1); -} - -Ajax.InPlaceEditor = Class.create(); -Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99"; -Ajax.InPlaceEditor.prototype = { - initialize: function(element, url, options) { - this.url = url; - this.element = $(element); - - this.options = Object.extend({ - okText: "ok", - cancelText: "cancel", - savingText: "Saving...", - clickToEditText: "Click to edit", - okText: "ok", - rows: 1, - onComplete: function(transport, element) { - new Effect.Highlight(element, {startcolor: this.options.highlightcolor}); - }, - onFailure: function(transport) { - alert("Error communicating with the server: " + transport.responseText.stripTags()); - }, - callback: function(form) { - return Form.serialize(form); - }, - handleLineBreaks: true, - loadingText: 'Loading...', - savingClassName: 'inplaceeditor-saving', - loadingClassName: 'inplaceeditor-loading', - formClassName: 'inplaceeditor-form', - highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, - highlightendcolor: "#FFFFFF", - externalControl: null, - ajaxOptions: {} - }, options || {}); - - if(!this.options.formId && this.element.id) { - this.options.formId = this.element.id + "-inplaceeditor"; - if ($(this.options.formId)) { - // there's already a form with that name, don't specify an id - this.options.formId = null; - } - } - - if (this.options.externalControl) { - this.options.externalControl = $(this.options.externalControl); - } - - this.originalBackground = Element.getStyle(this.element, 'background-color'); - if (!this.originalBackground) { - this.originalBackground = "transparent"; - } - - this.element.title = this.options.clickToEditText; - - this.onclickListener = this.enterEditMode.bindAsEventListener(this); - this.mouseoverListener = this.enterHover.bindAsEventListener(this); - this.mouseoutListener = this.leaveHover.bindAsEventListener(this); - Event.observe(this.element, 'click', this.onclickListener); - Event.observe(this.element, 'mouseover', this.mouseoverListener); - Event.observe(this.element, 'mouseout', this.mouseoutListener); - if (this.options.externalControl) { - Event.observe(this.options.externalControl, 'click', this.onclickListener); - Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener); - Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener); - } - }, - enterEditMode: function(evt) { - if (this.saving) return; - if (this.editing) return; - this.editing = true; - this.onEnterEditMode(); - if (this.options.externalControl) { - Element.hide(this.options.externalControl); - } - Element.hide(this.element); - this.createForm(); - this.element.parentNode.insertBefore(this.form, this.element); - Field.scrollFreeActivate(this.editField); - // stop the event to avoid a page refresh in Safari - if (evt) { - Event.stop(evt); - } - return false; - }, - createForm: function() { - this.form = document.createElement("form"); - this.form.id = this.options.formId; - Element.addClassName(this.form, this.options.formClassName) - this.form.onsubmit = this.onSubmit.bind(this); - - this.createEditField(); - - if (this.options.textarea) { - var br = document.createElement("br"); - this.form.appendChild(br); - } - - okButton = document.createElement("input"); - okButton.type = "submit"; - okButton.value = this.options.okText; - this.form.appendChild(okButton); - - cancelLink = document.createElement("a"); - cancelLink.href = "#"; - cancelLink.appendChild(document.createTextNode(this.options.cancelText)); - cancelLink.onclick = this.onclickCancel.bind(this); - this.form.appendChild(cancelLink); - }, - hasHTMLLineBreaks: function(string) { - if (!this.options.handleLineBreaks) return false; - return string.match(/
    /i); - }, - convertHTMLLineBreaks: function(string) { - return string.replace(/
    /gi, "\n").replace(//gi, "\n").replace(/<\/p>/gi, "\n").replace(/

    /gi, ""); - }, - createEditField: function() { - var text; - if(this.options.loadTextURL) { - text = this.options.loadingText; - } else { - text = this.getText(); - } - - if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) { - this.options.textarea = false; - var textField = document.createElement("input"); - textField.type = "text"; - textField.name = "value"; - textField.value = text; - textField.style.backgroundColor = this.options.highlightcolor; - var size = this.options.size || this.options.cols || 0; - if (size != 0) textField.size = size; - this.editField = textField; - } else { - this.options.textarea = true; - var textArea = document.createElement("textarea"); - textArea.name = "value"; - textArea.value = this.convertHTMLLineBreaks(text); - textArea.rows = this.options.rows; - textArea.cols = this.options.cols || 40; - this.editField = textArea; - } - - if(this.options.loadTextURL) { - this.loadExternalText(); - } - this.form.appendChild(this.editField); - }, - getText: function() { - return this.element.innerHTML; - }, - loadExternalText: function() { - Element.addClassName(this.form, this.options.loadingClassName); - this.editField.disabled = true; - new Ajax.Request( - this.options.loadTextURL, - Object.extend({ - asynchronous: true, - onComplete: this.onLoadedExternalText.bind(this) - }, this.options.ajaxOptions) - ); - }, - onLoadedExternalText: function(transport) { - Element.removeClassName(this.form, this.options.loadingClassName); - this.editField.disabled = false; - this.editField.value = transport.responseText.stripTags(); - }, - onclickCancel: function() { - this.onComplete(); - this.leaveEditMode(); - return false; - }, - onFailure: function(transport) { - this.options.onFailure(transport); - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - this.oldInnerHTML = null; - } - return false; - }, - onSubmit: function() { - // onLoading resets these so we need to save them away for the Ajax call - var form = this.form; - var value = this.editField.value; - - // do this first, sometimes the ajax call returns before we get a chance to switch on Saving... - // which means this will actually switch on Saving... *after* we've left edit mode causing Saving... - // to be displayed indefinitely - this.onLoading(); - - new Ajax.Updater( - { - success: this.element, - // don't update on failure (this could be an option) - failure: null - }, - this.url, - Object.extend({ - parameters: this.options.callback(form, value), - onComplete: this.onComplete.bind(this), - onFailure: this.onFailure.bind(this) - }, this.options.ajaxOptions) - ); - // stop the event to avoid a page refresh in Safari - if (arguments.length > 1) { - Event.stop(arguments[0]); - } - return false; - }, - onLoading: function() { - this.saving = true; - this.removeForm(); - this.leaveHover(); - this.showSaving(); - }, - showSaving: function() { - this.oldInnerHTML = this.element.innerHTML; - this.element.innerHTML = this.options.savingText; - Element.addClassName(this.element, this.options.savingClassName); - this.element.style.backgroundColor = this.originalBackground; - Element.show(this.element); - }, - removeForm: function() { - if(this.form) { - if (this.form.parentNode) Element.remove(this.form); - this.form = null; - } - }, - enterHover: function() { - if (this.saving) return; - this.element.style.backgroundColor = this.options.highlightcolor; - if (this.effect) { - this.effect.cancel(); - } - Element.addClassName(this.element, this.options.hoverClassName) - }, - leaveHover: function() { - if (this.options.backgroundColor) { - this.element.style.backgroundColor = this.oldBackground; - } - Element.removeClassName(this.element, this.options.hoverClassName) - if (this.saving) return; - this.effect = new Effect.Highlight(this.element, { - startcolor: this.options.highlightcolor, - endcolor: this.options.highlightendcolor, - restorecolor: this.originalBackground - }); - }, - leaveEditMode: function() { - Element.removeClassName(this.element, this.options.savingClassName); - this.removeForm(); - this.leaveHover(); - this.element.style.backgroundColor = this.originalBackground; - Element.show(this.element); - if (this.options.externalControl) { - Element.show(this.options.externalControl); - } - this.editing = false; - this.saving = false; - this.oldInnerHTML = null; - this.onLeaveEditMode(); - }, - onComplete: function(transport) { - this.leaveEditMode(); - this.options.onComplete.bind(this)(transport, this.element); - }, - onEnterEditMode: function() {}, - onLeaveEditMode: function() {}, - dispose: function() { - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - } - this.leaveEditMode(); - Event.stopObserving(this.element, 'click', this.onclickListener); - Event.stopObserving(this.element, 'mouseover', this.mouseoverListener); - Event.stopObserving(this.element, 'mouseout', this.mouseoutListener); - if (this.options.externalControl) { - Event.stopObserving(this.options.externalControl, 'click', this.onclickListener); - Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener); - Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener); - } - } -}; - -// Delayed observer, like Form.Element.Observer, -// but waits for delay after last key input -// Ideal for live-search fields - -Form.Element.DelayedObserver = Class.create(); -Form.Element.DelayedObserver.prototype = { - initialize: function(element, delay, callback) { - this.delay = delay || 0.5; - this.element = $(element); - this.callback = callback; - this.timer = null; - this.lastValue = $F(this.element); - Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); - }, - delayedListener: function(event) { - if(this.lastValue == $F(this.element)) return; - if(this.timer) clearTimeout(this.timer); - this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); - this.lastValue = $F(this.element); - }, - onTimerEvent: function() { - this.timer = null; - this.callback(this.element, $F(this.element)); - } -}; \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/dragdrop.js b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/dragdrop.js deleted file mode 100644 index 92d1f731..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/dragdrop.js +++ /dev/null @@ -1,584 +0,0 @@ -// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// -// See scriptaculous.js for full license. - -/*--------------------------------------------------------------------------*/ - -var Droppables = { - drops: [], - - remove: function(element) { - this.drops = this.drops.reject(function(d) { return d.element==$(element) }); - }, - - add: function(element) { - element = $(element); - var options = Object.extend({ - greedy: true, - hoverclass: null - }, arguments[1] || {}); - - // cache containers - if(options.containment) { - options._containers = []; - var containment = options.containment; - if((typeof containment == 'object') && - (containment.constructor == Array)) { - containment.each( function(c) { options._containers.push($(c)) }); - } else { - options._containers.push($(containment)); - } - } - - if(options.accept) options.accept = [options.accept].flatten(); - - Element.makePositioned(element); // fix IE - options.element = element; - - this.drops.push(options); - }, - - isContained: function(element, drop) { - var parentNode = element.parentNode; - return drop._containers.detect(function(c) { return parentNode == c }); - }, - - isAffected: function(point, element, drop) { - return ( - (drop.element!=element) && - ((!drop._containers) || - this.isContained(element, drop)) && - ((!drop.accept) || - (Element.classNames(element).detect( - function(v) { return drop.accept.include(v) } ) )) && - Position.within(drop.element, point[0], point[1]) ); - }, - - deactivate: function(drop) { - if(drop.hoverclass) - Element.removeClassName(drop.element, drop.hoverclass); - this.last_active = null; - }, - - activate: function(drop) { - if(drop.hoverclass) - Element.addClassName(drop.element, drop.hoverclass); - this.last_active = drop; - }, - - show: function(point, element) { - if(!this.drops.length) return; - - if(this.last_active) this.deactivate(this.last_active); - this.drops.each( function(drop) { - if(Droppables.isAffected(point, element, drop)) { - if(drop.onHover) - drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); - if(drop.greedy) { - Droppables.activate(drop); - throw $break; - } - } - }); - }, - - fire: function(event, element) { - if(!this.last_active) return; - Position.prepare(); - - if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) - if (this.last_active.onDrop) - this.last_active.onDrop(element, this.last_active.element, event); - }, - - reset: function() { - if(this.last_active) - this.deactivate(this.last_active); - } -} - -var Draggables = { - drags: [], - observers: [], - - register: function(draggable) { - if(this.drags.length == 0) { - this.eventMouseUp = this.endDrag.bindAsEventListener(this); - this.eventMouseMove = this.updateDrag.bindAsEventListener(this); - this.eventKeypress = this.keyPress.bindAsEventListener(this); - - Event.observe(document, "mouseup", this.eventMouseUp); - Event.observe(document, "mousemove", this.eventMouseMove); - Event.observe(document, "keypress", this.eventKeypress); - } - this.drags.push(draggable); - }, - - unregister: function(draggable) { - this.drags = this.drags.reject(function(d) { return d==draggable }); - if(this.drags.length == 0) { - Event.stopObserving(document, "mouseup", this.eventMouseUp); - Event.stopObserving(document, "mousemove", this.eventMouseMove); - Event.stopObserving(document, "keypress", this.eventKeypress); - } - }, - - activate: function(draggable) { - window.focus(); // allows keypress events if window isn't currently focused, fails for Safari - this.activeDraggable = draggable; - }, - - deactivate: function(draggbale) { - this.activeDraggable = null; - }, - - updateDrag: function(event) { - if(!this.activeDraggable) return; - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - // Mozilla-based browsers fire successive mousemove events with - // the same coordinates, prevent needless redrawing (moz bug?) - if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; - this._lastPointer = pointer; - this.activeDraggable.updateDrag(event, pointer); - }, - - endDrag: function(event) { - if(!this.activeDraggable) return; - this._lastPointer = null; - this.activeDraggable.endDrag(event); - }, - - keyPress: function(event) { - if(this.activeDraggable) - this.activeDraggable.keyPress(event); - }, - - addObserver: function(observer) { - this.observers.push(observer); - this._cacheObserverCallbacks(); - }, - - removeObserver: function(element) { // element instead of observer fixes mem leaks - this.observers = this.observers.reject( function(o) { return o.element==element }); - this._cacheObserverCallbacks(); - }, - - notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' - if(this[eventName+'Count'] > 0) - this.observers.each( function(o) { - if(o[eventName]) o[eventName](eventName, draggable, event); - }); - }, - - _cacheObserverCallbacks: function() { - ['onStart','onEnd','onDrag'].each( function(eventName) { - Draggables[eventName+'Count'] = Draggables.observers.select( - function(o) { return o[eventName]; } - ).length; - }); - } -} - -/*--------------------------------------------------------------------------*/ - -var Draggable = Class.create(); -Draggable.prototype = { - initialize: function(element) { - var options = Object.extend({ - handle: false, - starteffect: function(element) { - new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7}); - }, - reverteffect: function(element, top_offset, left_offset) { - var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; - element._revert = new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur}); - }, - endeffect: function(element) { - new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0}); - }, - zindex: 1000, - revert: false, - snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] } - }, arguments[1] || {}); - - this.element = $(element); - - if(options.handle && (typeof options.handle == 'string')) - this.handle = Element.childrenWithClassName(this.element, options.handle)[0]; - if(!this.handle) this.handle = $(options.handle); - if(!this.handle) this.handle = this.element; - - Element.makePositioned(this.element); // fix IE - - this.delta = this.currentDelta(); - this.options = options; - this.dragging = false; - - this.eventMouseDown = this.initDrag.bindAsEventListener(this); - Event.observe(this.handle, "mousedown", this.eventMouseDown); - - Draggables.register(this); - }, - - destroy: function() { - Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); - Draggables.unregister(this); - }, - - currentDelta: function() { - return([ - parseInt(this.element.style.left || '0'), - parseInt(this.element.style.top || '0')]); - }, - - initDrag: function(event) { - if(Event.isLeftClick(event)) { - // abort on form elements, fixes a Firefox issue - var src = Event.element(event); - if(src.tagName && ( - src.tagName=='INPUT' || - src.tagName=='SELECT' || - src.tagName=='BUTTON' || - src.tagName=='TEXTAREA')) return; - - if(this.element._revert) { - this.element._revert.cancel(); - this.element._revert = null; - } - - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var pos = Position.cumulativeOffset(this.element); - this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); - - Draggables.activate(this); - Event.stop(event); - } - }, - - startDrag: function(event) { - this.dragging = true; - - if(this.options.zindex) { - this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); - this.element.style.zIndex = this.options.zindex; - } - - if(this.options.ghosting) { - this._clone = this.element.cloneNode(true); - Position.absolutize(this.element); - this.element.parentNode.insertBefore(this._clone, this.element); - } - - Draggables.notify('onStart', this, event); - if(this.options.starteffect) this.options.starteffect(this.element); - }, - - updateDrag: function(event, pointer) { - if(!this.dragging) this.startDrag(event); - Position.prepare(); - Droppables.show(pointer, this.element); - Draggables.notify('onDrag', this, event); - this.draw(pointer); - if(this.options.change) this.options.change(this); - - // fix AppleWebKit rendering - if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); - Event.stop(event); - }, - - finishDrag: function(event, success) { - this.dragging = false; - - if(this.options.ghosting) { - Position.relativize(this.element); - Element.remove(this._clone); - this._clone = null; - } - - if(success) Droppables.fire(event, this.element); - Draggables.notify('onEnd', this, event); - - var revert = this.options.revert; - if(revert && typeof revert == 'function') revert = revert(this.element); - - var d = this.currentDelta(); - if(revert && this.options.reverteffect) { - this.options.reverteffect(this.element, - d[1]-this.delta[1], d[0]-this.delta[0]); - } else { - this.delta = d; - } - - if(this.options.zindex) - this.element.style.zIndex = this.originalZ; - - if(this.options.endeffect) - this.options.endeffect(this.element); - - Draggables.deactivate(this); - Droppables.reset(); - }, - - keyPress: function(event) { - if(!event.keyCode==Event.KEY_ESC) return; - this.finishDrag(event, false); - Event.stop(event); - }, - - endDrag: function(event) { - if(!this.dragging) return; - this.finishDrag(event, true); - Event.stop(event); - }, - - draw: function(point) { - var pos = Position.cumulativeOffset(this.element); - var d = this.currentDelta(); - pos[0] -= d[0]; pos[1] -= d[1]; - - var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this)); - - if(this.options.snap) { - if(typeof this.options.snap == 'function') { - p = this.options.snap(p[0],p[1]); - } else { - if(this.options.snap instanceof Array) { - p = p.map( function(v, i) { - return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this)) - } else { - p = p.map( function(v) { - return Math.round(v/this.options.snap)*this.options.snap }.bind(this)) - } - }} - - var style = this.element.style; - if((!this.options.constraint) || (this.options.constraint=='horizontal')) - style.left = p[0] + "px"; - if((!this.options.constraint) || (this.options.constraint=='vertical')) - style.top = p[1] + "px"; - if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering - } -} - -/*--------------------------------------------------------------------------*/ - -var SortableObserver = Class.create(); -SortableObserver.prototype = { - initialize: function(element, observer) { - this.element = $(element); - this.observer = observer; - this.lastValue = Sortable.serialize(this.element); - }, - - onStart: function() { - this.lastValue = Sortable.serialize(this.element); - }, - - onEnd: function() { - Sortable.unmark(); - if(this.lastValue != Sortable.serialize(this.element)) - this.observer(this.element) - } -} - -var Sortable = { - sortables: new Array(), - - options: function(element){ - element = $(element); - return this.sortables.detect(function(s) { return s.element == element }); - }, - - destroy: function(element){ - element = $(element); - this.sortables.findAll(function(s) { return s.element == element }).each(function(s){ - Draggables.removeObserver(s.element); - s.droppables.each(function(d){ Droppables.remove(d) }); - s.draggables.invoke('destroy'); - }); - this.sortables = this.sortables.reject(function(s) { return s.element == element }); - }, - - create: function(element) { - element = $(element); - var options = Object.extend({ - element: element, - tag: 'li', // assumes li children, override with tag: 'tagname' - dropOnEmpty: false, - tree: false, // fixme: unimplemented - overlap: 'vertical', // one of 'vertical', 'horizontal' - constraint: 'vertical', // one of 'vertical', 'horizontal', false - containment: element, // also takes array of elements (or id's); or false - handle: false, // or a CSS class - only: false, - hoverclass: null, - ghosting: false, - format: null, - onChange: Prototype.emptyFunction, - onUpdate: Prototype.emptyFunction - }, arguments[1] || {}); - - // clear any old sortable with same element - this.destroy(element); - - // build options for the draggables - var options_for_draggable = { - revert: true, - ghosting: options.ghosting, - constraint: options.constraint, - handle: options.handle }; - - if(options.starteffect) - options_for_draggable.starteffect = options.starteffect; - - if(options.reverteffect) - options_for_draggable.reverteffect = options.reverteffect; - else - if(options.ghosting) options_for_draggable.reverteffect = function(element) { - element.style.top = 0; - element.style.left = 0; - }; - - if(options.endeffect) - options_for_draggable.endeffect = options.endeffect; - - if(options.zindex) - options_for_draggable.zindex = options.zindex; - - // build options for the droppables - var options_for_droppable = { - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass, - onHover: Sortable.onHover, - greedy: !options.dropOnEmpty - } - - // fix for gecko engine - Element.cleanWhitespace(element); - - options.draggables = []; - options.droppables = []; - - // make it so - - // drop on empty handling - if(options.dropOnEmpty) { - Droppables.add(element, - {containment: options.containment, onHover: Sortable.onEmptyHover, greedy: false}); - options.droppables.push(element); - } - - (this.findElements(element, options) || []).each( function(e) { - // handles are per-draggable - var handle = options.handle ? - Element.childrenWithClassName(e, options.handle)[0] : e; - options.draggables.push( - new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); - Droppables.add(e, options_for_droppable); - options.droppables.push(e); - }); - - // keep reference - this.sortables.push(options); - - // for onupdate - Draggables.addObserver(new SortableObserver(element, options.onUpdate)); - - }, - - // return all suitable-for-sortable elements in a guaranteed order - findElements: function(element, options) { - if(!element.hasChildNodes()) return null; - var elements = []; - $A(element.childNodes).each( function(e) { - if(e.tagName && e.tagName.toUpperCase()==options.tag.toUpperCase() && - (!options.only || (Element.hasClassName(e, options.only)))) - elements.push(e); - if(options.tree) { - var grandchildren = this.findElements(e, options); - if(grandchildren) elements.push(grandchildren); - } - }); - - return (elements.length>0 ? elements.flatten() : null); - }, - - onHover: function(element, dropon, overlap) { - if(overlap>0.5) { - Sortable.mark(dropon, 'before'); - if(dropon.previousSibling != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, dropon); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } else { - Sortable.mark(dropon, 'after'); - var nextElement = dropon.nextSibling || null; - if(nextElement != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, nextElement); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } - }, - - onEmptyHover: function(element, dropon) { - if(element.parentNode!=dropon) { - var oldParentNode = element.parentNode; - dropon.appendChild(element); - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon).onChange(element); - } - }, - - unmark: function() { - if(Sortable._marker) Element.hide(Sortable._marker); - }, - - mark: function(dropon, position) { - // mark on ghosting only - var sortable = Sortable.options(dropon.parentNode); - if(sortable && !sortable.ghosting) return; - - if(!Sortable._marker) { - Sortable._marker = $('dropmarker') || document.createElement('DIV'); - Element.hide(Sortable._marker); - Element.addClassName(Sortable._marker, 'dropmarker'); - Sortable._marker.style.position = 'absolute'; - document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); - } - var offsets = Position.cumulativeOffset(dropon); - Sortable._marker.style.left = offsets[0] + 'px'; - Sortable._marker.style.top = offsets[1] + 'px'; - - if(position=='after') - if(sortable.overlap == 'horizontal') - Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px'; - else - Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px'; - - Element.show(Sortable._marker); - }, - - serialize: function(element) { - element = $(element); - var sortableOptions = this.options(element); - var options = Object.extend({ - tag: sortableOptions.tag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format || /^[^_]*_(.*)$/ - }, arguments[1] || {}); - return $(this.findElements(element, options) || []).map( function(item) { - return (encodeURIComponent(options.name) + "[]=" + - encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : '')); - }).join("&"); - } -} \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/effects.js b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/effects.js deleted file mode 100644 index 414398ce..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/effects.js +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// Contributors: -// Justin Palmer (http://encytemedia.com/) -// Mark Pilgrim (http://diveintomark.org/) -// Martin Bialasinki -// -// See scriptaculous.js for full license. - -/* ------------- element ext -------------- */ - -// converts rgb() and #xxx to #xxxxxx format, -// returns self (or first argument) if not convertable -String.prototype.parseColor = function() { - var color = '#'; - if(this.slice(0,4) == 'rgb(') { - var cols = this.slice(4,this.length-1).split(','); - var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); - } else { - if(this.slice(0,1) == '#') { - if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); - if(this.length==7) color = this.toLowerCase(); - } - } - return(color.length==7 ? color : (arguments[0] || this)); -} - -Element.collectTextNodesIgnoreClass = function(element, ignoreclass) { - var children = $(element).childNodes; - var text = ''; - var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i'); - - for (var i = 0; i < children.length; i++) { - if(children[i].nodeType==3) { - text+=children[i].nodeValue; - } else { - if((!children[i].className.match(classtest)) && children[i].hasChildNodes()) - text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass); - } - } - - return text; -} - -Element.setStyle = function(element, style) { - element = $(element); - for(k in style) element.style[k.camelize()] = style[k]; -} - -Element.setContentZoom = function(element, percent) { - Element.setStyle(element, {fontSize: (percent/100) + 'em'}); - if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); -} - -Element.getOpacity = function(element){ - var opacity; - if (opacity = Element.getStyle(element, 'opacity')) - return parseFloat(opacity); - if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) - if(opacity[1]) return parseFloat(opacity[1]) / 100; - return 1.0; -} - -Element.setOpacity = function(element, value){ - element= $(element); - if (value == 1){ - Element.setStyle(element, { opacity: - (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? - 0.999999 : null }); - if(/MSIE/.test(navigator.userAgent)) - Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); - } else { - if(value < 0.00001) value = 0; - Element.setStyle(element, {opacity: value}); - if(/MSIE/.test(navigator.userAgent)) - Element.setStyle(element, - { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + - 'alpha(opacity='+value*100+')' }); - } -} - -Element.getInlineOpacity = function(element){ - return $(element).style.opacity || ''; -} - -Element.childrenWithClassName = function(element, className) { - return $A($(element).getElementsByTagName('*')).select( - function(c) { return Element.hasClassName(c, className) }); -} - -Array.prototype.call = function() { - var args = arguments; - this.each(function(f){ f.apply(this, args) }); -} - -/*--------------------------------------------------------------------------*/ - -var Effect = { - tagifyText: function(element) { - var tagifyStyle = 'position:relative'; - if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; - element = $(element); - $A(element.childNodes).each( function(child) { - if(child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - Builder.node('span',{style: tagifyStyle}, - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if(((typeof element == 'object') || - (typeof element == 'function')) && - (element.length)) - elements = element; - else - elements = $(element).childNodes; - - var options = Object.extend({ - speed: 0.1, - delay: 0.0 - }, arguments[2] || {}); - var masterDelay = options.delay; - - $A(elements).each( function(element, index) { - new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); - }); - } -}; - -var Effect2 = Effect; // deprecated - -/* ------------- transitions ------------- */ - -Effect.Transitions = {} - -Effect.Transitions.linear = function(pos) { - return pos; -} -Effect.Transitions.sinoidal = function(pos) { - return (-Math.cos(pos*Math.PI)/2) + 0.5; -} -Effect.Transitions.reverse = function(pos) { - return 1-pos; -} -Effect.Transitions.flicker = function(pos) { - return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; -} -Effect.Transitions.wobble = function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; -} -Effect.Transitions.pulse = function(pos) { - return (Math.floor(pos*10) % 2 == 0 ? - (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); -} -Effect.Transitions.none = function(pos) { - return 0; -} -Effect.Transitions.full = function(pos) { - return 1; -} - -/* ------------- core effects ------------- */ - -Effect.Queue = { - effects: [], - _each: function(iterator) { - this.effects._each(iterator); - }, - interval: null, - add: function(effect) { - var timestamp = new Date().getTime(); - - switch(effect.options.queue) { - case 'front': - // move unstarted effects after this effect - this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - }); - break; - case 'end': - // start effect after last queued effect has finished - timestamp = this.effects.pluck('finishOn').max() || timestamp; - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - this.effects.push(effect); - if(!this.interval) - this.interval = setInterval(this.loop.bind(this), 40); - }, - remove: function(effect) { - this.effects = this.effects.reject(function(e) { return e==effect }); - if(this.effects.length == 0) { - clearInterval(this.interval); - this.interval = null; - } - }, - loop: function() { - var timePos = new Date().getTime(); - this.effects.invoke('loop', timePos); - } -} -Object.extend(Effect.Queue, Enumerable); - -Effect.Base = function() {}; -Effect.Base.prototype = { - position: null, - setOptions: function(options) { - this.options = Object.extend({ - transition: Effect.Transitions.sinoidal, - duration: 1.0, // seconds - fps: 25.0, // max. 25fps due to Effect.Queue implementation - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' - }, options || {}); - }, - start: function(options) { - this.setOptions(options || {}); - this.currentFrame = 0; - this.state = 'idle'; - this.startOn = this.options.delay*1000; - this.finishOn = this.startOn + (this.options.duration*1000); - this.event('beforeStart'); - if(!this.options.sync) Effect.Queue.add(this); - }, - loop: function(timePos) { - if(timePos >= this.startOn) { - if(timePos >= this.finishOn) { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - if(this.finish) this.finish(); - this.event('afterFinish'); - return; - } - var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); - var frame = Math.round(pos * this.options.fps * this.options.duration); - if(frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - render: function(pos) { - if(this.state == 'idle') { - this.state = 'running'; - this.event('beforeSetup'); - if(this.setup) this.setup(); - this.event('afterSetup'); - } - if(this.state == 'running') { - if(this.options.transition) pos = this.options.transition(pos); - pos *= (this.options.to-this.options.from); - pos += this.options.from; - this.position = pos; - this.event('beforeUpdate'); - if(this.update) this.update(pos); - this.event('afterUpdate'); - } - }, - cancel: function() { - if(!this.options.sync) Effect.Queue.remove(this); - this.state = 'finished'; - }, - event: function(eventName) { - if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); - if(this.options[eventName]) this.options[eventName](this); - }, - inspect: function() { - return '#'; - } -} - -Effect.Parallel = Class.create(); -Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), { - initialize: function(effects) { - this.effects = effects || []; - this.start(arguments[1]); - }, - update: function(position) { - this.effects.invoke('render', position); - }, - finish: function(position) { - this.effects.each( function(effect) { - effect.render(1.0); - effect.cancel(); - effect.event('beforeFinish'); - if(effect.finish) effect.finish(position); - effect.event('afterFinish'); - }); - } -}); - -Effect.Opacity = Class.create(); -Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - // make this work on IE on elements without 'layout' - if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) - Element.setStyle(this.element, {zoom: 1}); - var options = Object.extend({ - from: Element.getOpacity(this.element) || 0.0, - to: 1.0 - }, arguments[1] || {}); - this.start(options); - }, - update: function(position) { - Element.setOpacity(this.element, position); - } -}); - -Effect.MoveBy = Class.create(); -Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), { - initialize: function(element, toTop, toLeft) { - this.element = $(element); - this.toTop = toTop; - this.toLeft = toLeft; - this.start(arguments[3]); - }, - setup: function() { - // Bug in Opera: Opera returns the "real" position of a static element or - // relative element that does not have top/left explicitly set. - // ==> Always set top and left for position relative elements in your stylesheets - // (to 0 if you do not need them) - Element.makePositioned(this.element); - this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0'); - this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0'); - }, - update: function(position) { - Element.setStyle(this.element, { - top: this.toTop * position + this.originalTop + 'px', - left: this.toLeft * position + this.originalLeft + 'px' - }); - } -}); - -Effect.Scale = Class.create(); -Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { - initialize: function(element, percent) { - this.element = $(element) - var options = Object.extend({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or {} with provided values - scaleFrom: 100.0, - scaleTo: percent - }, arguments[2] || {}); - this.start(options); - }, - setup: function() { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = Element.getStyle(this.element,'position'); - - this.originalStyle = {}; - ['top','left','width','height','fontSize'].each( function(k) { - this.originalStyle[k] = this.element.style[k]; - }.bind(this)); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = Element.getStyle(this.element,'font-size') || '100%'; - ['em','px','%'].each( function(fontSizeType) { - if(fontSize.indexOf(fontSizeType)>0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }.bind(this)); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - this.dims = null; - if(this.options.scaleMode=='box') - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - if(/^content/.test(this.options.scaleMode)) - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - if(!this.dims) - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - }, - update: function(position) { - var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); - if(this.options.scaleContent && this.fontSize) - Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType }); - this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); - }, - finish: function(position) { - if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle); - }, - setDimensions: function(height, width) { - var d = {}; - if(this.options.scaleX) d.width = width + 'px'; - if(this.options.scaleY) d.height = height + 'px'; - if(this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if(this.elementPositioning == 'absolute') { - if(this.options.scaleY) d.top = this.originalTop-topd + 'px'; - if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; - } else { - if(this.options.scaleY) d.top = -topd + 'px'; - if(this.options.scaleX) d.left = -leftd + 'px'; - } - } - Element.setStyle(this.element, d); - } -}); - -Effect.Highlight = Class.create(); -Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); - this.start(options); - }, - setup: function() { - // Prevent executing on elements not in the layout flow - if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; } - // Disable background image during the effect - this.oldStyle = { - backgroundImage: Element.getStyle(this.element, 'background-image') }; - Element.setStyle(this.element, {backgroundImage: 'none'}); - if(!this.options.endcolor) - this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff'); - if(!this.options.restorecolor) - this.options.restorecolor = Element.getStyle(this.element, 'background-color'); - // init color calculations - this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); - this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); - }, - update: function(position) { - Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){ - return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) }); - }, - finish: function() { - Element.setStyle(this.element, Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = Class.create(); -Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), { - initialize: function(element) { - this.element = $(element); - this.start(arguments[1] || {}); - }, - setup: function() { - Position.prepare(); - var offsets = Position.cumulativeOffset(this.element); - if(this.options.offset) offsets[1] += this.options.offset; - var max = window.innerHeight ? - window.height - window.innerHeight : - document.body.scrollHeight - - (document.documentElement.clientHeight ? - document.documentElement.clientHeight : document.body.clientHeight); - this.scrollStart = Position.deltaY; - this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart; - }, - update: function(position) { - Position.prepare(); - window.scrollTo(Position.deltaX, - this.scrollStart + (position*this.delta)); - } -}); - -/* ------------- combination effects ------------- */ - -Effect.Fade = function(element) { - var oldOpacity = Element.getInlineOpacity(element); - var options = Object.extend({ - from: Element.getOpacity(element) || 1.0, - to: 0.0, - afterFinishInternal: function(effect) { with(Element) { - if(effect.options.to!=0) return; - hide(effect.element); - setStyle(effect.element, {opacity: oldOpacity}); }} - }, arguments[1] || {}); - return new Effect.Opacity(element,options); -} - -Effect.Appear = function(element) { - var options = Object.extend({ - from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0), - to: 1.0, - beforeSetup: function(effect) { with(Element) { - setOpacity(effect.element, effect.options.from); - show(effect.element); }} - }, arguments[1] || {}); - return new Effect.Opacity(element,options); -} - -Effect.Puff = function(element) { - element = $(element); - var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') }; - return new Effect.Parallel( - [ new Effect.Scale(element, 200, - { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], - Object.extend({ duration: 1.0, - beforeSetupInternal: function(effect) { with(Element) { - setStyle(effect.effects[0].element, {position: 'absolute'}); }}, - afterFinishInternal: function(effect) { with(Element) { - hide(effect.effects[0].element); - setStyle(effect.effects[0].element, oldStyle); }} - }, arguments[1] || {}) - ); -} - -Effect.BlindUp = function(element) { - element = $(element); - Element.makeClipping(element); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function(effect) { with(Element) { - [hide, undoClipping].call(effect.element); }} - }, arguments[1] || {}) - ); -} - -Effect.BlindDown = function(element) { - element = $(element); - var oldHeight = Element.getStyle(element, 'height'); - var elementDimensions = Element.getDimensions(element); - return new Effect.Scale(element, 100, - Object.extend({ scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { with(Element) { - makeClipping(effect.element); - setStyle(effect.element, {height: '0px'}); - show(effect.element); - }}, - afterFinishInternal: function(effect) { with(Element) { - undoClipping(effect.element); - setStyle(effect.element, {height: oldHeight}); - }} - }, arguments[1] || {}) - ); -} - -Effect.SwitchOff = function(element) { - element = $(element); - var oldOpacity = Element.getInlineOpacity(element); - return new Effect.Appear(element, { - duration: 0.4, - from: 0, - transition: Effect.Transitions.flicker, - afterFinishInternal: function(effect) { - new Effect.Scale(effect.element, 1, { - duration: 0.3, scaleFromCenter: true, - scaleX: false, scaleContent: false, restoreAfterFinish: true, - beforeSetup: function(effect) { with(Element) { - [makePositioned,makeClipping].call(effect.element); - }}, - afterFinishInternal: function(effect) { with(Element) { - [hide,undoClipping,undoPositioned].call(effect.element); - setStyle(effect.element, {opacity: oldOpacity}); - }} - }) - } - }); -} - -Effect.DropOut = function(element) { - element = $(element); - var oldStyle = { - top: Element.getStyle(element, 'top'), - left: Element.getStyle(element, 'left'), - opacity: Element.getInlineOpacity(element) }; - return new Effect.Parallel( - [ new Effect.MoveBy(element, 100, 0, { sync: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 }) ], - Object.extend( - { duration: 0.5, - beforeSetup: function(effect) { with(Element) { - makePositioned(effect.effects[0].element); }}, - afterFinishInternal: function(effect) { with(Element) { - [hide, undoPositioned].call(effect.effects[0].element); - setStyle(effect.effects[0].element, oldStyle); }} - }, arguments[1] || {})); -} - -Effect.Shake = function(element) { - element = $(element); - var oldStyle = { - top: Element.getStyle(element, 'top'), - left: Element.getStyle(element, 'left') }; - return new Effect.MoveBy(element, 0, 20, - { duration: 0.05, afterFinishInternal: function(effect) { - new Effect.MoveBy(effect.element, 0, -40, - { duration: 0.1, afterFinishInternal: function(effect) { - new Effect.MoveBy(effect.element, 0, 40, - { duration: 0.1, afterFinishInternal: function(effect) { - new Effect.MoveBy(effect.element, 0, -40, - { duration: 0.1, afterFinishInternal: function(effect) { - new Effect.MoveBy(effect.element, 0, 40, - { duration: 0.1, afterFinishInternal: function(effect) { - new Effect.MoveBy(effect.element, 0, -20, - { duration: 0.05, afterFinishInternal: function(effect) { with(Element) { - undoPositioned(effect.element); - setStyle(effect.element, oldStyle); - }}}) }}) }}) }}) }}) }}); -} - -Effect.SlideDown = function(element) { - element = $(element); - Element.cleanWhitespace(element); - // SlideDown need to have the content of the element wrapped in a container element with fixed height! - var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); - var elementDimensions = Element.getDimensions(element); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { with(Element) { - makePositioned(effect.element); - makePositioned(effect.element.firstChild); - if(window.opera) setStyle(effect.element, {top: ''}); - makeClipping(effect.element); - setStyle(effect.element, {height: '0px'}); - show(element); }}, - afterUpdateInternal: function(effect) { with(Element) { - setStyle(effect.element.firstChild, {bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, - afterFinishInternal: function(effect) { with(Element) { - undoClipping(effect.element); - undoPositioned(effect.element.firstChild); - undoPositioned(effect.element); - setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} - }, arguments[1] || {}) - ); -} - -Effect.SlideUp = function(element) { - element = $(element); - Element.cleanWhitespace(element); - var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - restoreAfterFinish: true, - beforeStartInternal: function(effect) { with(Element) { - makePositioned(effect.element); - makePositioned(effect.element.firstChild); - if(window.opera) setStyle(effect.element, {top: ''}); - makeClipping(effect.element); - show(element); }}, - afterUpdateInternal: function(effect) { with(Element) { - setStyle(effect.element.firstChild, {bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, - afterFinishInternal: function(effect) { with(Element) { - [hide, undoClipping].call(effect.element); - undoPositioned(effect.element.firstChild); - undoPositioned(effect.element); - setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} - }, arguments[1] || {}) - ); -} - -// Bug in opera makes the TD containing this element expand for a instance after finish -Effect.Squish = function(element) { - return new Effect.Scale(element, window.opera ? 1 : 0, - { restoreAfterFinish: true, - beforeSetup: function(effect) { with(Element) { - makeClipping(effect.element); }}, - afterFinishInternal: function(effect) { with(Element) { - hide(effect.element); - undoClipping(effect.element); }} - }); -} - -Effect.Grow = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransistion: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.full - }, arguments[1] || {}); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: Element.getInlineOpacity(element) }; - - var dims = Element.getDimensions(element); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.width; - initialMoveY = moveY = 0; - moveX = -dims.width; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.height; - moveY = -dims.height; - break; - case 'bottom-right': - initialMoveX = dims.width; - initialMoveY = dims.height; - moveX = -dims.width; - moveY = -dims.height; - break; - case 'center': - initialMoveX = dims.width / 2; - initialMoveY = dims.height / 2; - moveX = -dims.width / 2; - moveY = -dims.height / 2; - break; - } - - return new Effect.MoveBy(element, initialMoveY, initialMoveX, { - duration: 0.01, - beforeSetup: function(effect) { with(Element) { - hide(effect.element); - makeClipping(effect.element); - makePositioned(effect.element); - }}, - afterFinishInternal: function(effect) { - new Effect.Parallel( - [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), - new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }), - new Effect.Scale(effect.element, 100, { - scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, - sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) - ], Object.extend({ - beforeSetup: function(effect) { with(Element) { - setStyle(effect.effects[0].element, {height: '0px'}); - show(effect.effects[0].element); }}, - afterFinishInternal: function(effect) { with(Element) { - [undoClipping, undoPositioned].call(effect.effects[0].element); - setStyle(effect.effects[0].element, oldStyle); }} - }, options) - ) - } - }); -} - -Effect.Shrink = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransistion: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.none - }, arguments[1] || {}); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: Element.getInlineOpacity(element) }; - - var dims = Element.getDimensions(element); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.width; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.height; - break; - case 'bottom-right': - moveX = dims.width; - moveY = dims.height; - break; - case 'center': - moveX = dims.width / 2; - moveY = dims.height / 2; - break; - } - - return new Effect.Parallel( - [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), - new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), - new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition }) - ], Object.extend({ - beforeStartInternal: function(effect) { with(Element) { - [makePositioned, makeClipping].call(effect.effects[0].element) }}, - afterFinishInternal: function(effect) { with(Element) { - [hide, undoClipping, undoPositioned].call(effect.effects[0].element); - setStyle(effect.effects[0].element, oldStyle); }} - }, options) - ); -} - -Effect.Pulsate = function(element) { - element = $(element); - var options = arguments[1] || {}; - var oldOpacity = Element.getInlineOpacity(element); - var transition = options.transition || Effect.Transitions.sinoidal; - var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; - reverser.bind(transition); - return new Effect.Opacity(element, - Object.extend(Object.extend({ duration: 3.0, from: 0, - afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); } - }, options), {transition: reverser})); -} - -Effect.Fold = function(element) { - element = $(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height }; - Element.makeClipping(element); - return new Effect.Scale(element, 5, Object.extend({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function(effect) { - new Effect.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function(effect) { with(Element) { - [hide, undoClipping].call(effect.element); - setStyle(effect.element, oldStyle); - }} }); - }}, arguments[1] || {})); -} diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/prototype.js b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/prototype.js deleted file mode 100644 index e9ccd3c8..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/javascripts/prototype.js +++ /dev/null @@ -1,1785 +0,0 @@ -/* Prototype JavaScript framework, version 1.4.0 - * (c) 2005 Sam Stephenson - * - * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff - * against the source tree, available from the Prototype darcs repository. - * - * Prototype is freely distributable under the terms of an MIT-style license. - * - * For details, see the Prototype web site: http://prototype.conio.net/ - * -/*--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.4.0', - ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)', - - emptyFunction: function() {}, - K: function(x) {return x} -} - -var Class = { - create: function() { - return function() { - this.initialize.apply(this, arguments); - } - } -} - -var Abstract = new Object(); - -Object.extend = function(destination, source) { - for (property in source) { - destination[property] = source[property]; - } - return destination; -} - -Object.inspect = function(object) { - try { - if (object == undefined) return 'undefined'; - if (object == null) return 'null'; - return object.inspect ? object.inspect() : object.toString(); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } -} - -Function.prototype.bind = function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } -} - -Function.prototype.bindAsEventListener = function(object) { - var __method = this; - return function(event) { - return __method.call(object, event || window.event); - } -} - -Object.extend(Number.prototype, { - toColorPart: function() { - var digits = this.toString(16); - if (this < 16) return '0' + digits; - return digits; - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator) { - $R(0, this, true).each(iterator); - return this; - } -}); - -var Try = { - these: function() { - var returnValue; - - for (var i = 0; i < arguments.length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) {} - } - - return returnValue; - } -} - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create(); -PeriodicalExecuter.prototype = { - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.callback(); - } finally { - this.currentlyExecuting = false; - } - } - } -} - -/*--------------------------------------------------------------------------*/ - -function $() { - var elements = new Array(); - - for (var i = 0; i < arguments.length; i++) { - var element = arguments[i]; - if (typeof element == 'string') - element = document.getElementById(element); - - if (arguments.length == 1) - return element; - - elements.push(element); - } - - return elements; -} -Object.extend(String.prototype, { - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(eval); - }, - - escapeHTML: function() { - var div = document.createElement('div'); - var text = document.createTextNode(this); - div.appendChild(text); - return div.innerHTML; - }, - - unescapeHTML: function() { - var div = document.createElement('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; - }, - - toQueryParams: function() { - var pairs = this.match(/^\??(.*)$/)[1].split('&'); - return pairs.inject({}, function(params, pairString) { - var pair = pairString.split('='); - params[pair[0]] = pair[1]; - return params; - }); - }, - - toArray: function() { - return this.split(''); - }, - - camelize: function() { - var oStringList = this.split('-'); - if (oStringList.length == 1) return oStringList[0]; - - var camelizedString = this.indexOf('-') == 0 - ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) - : oStringList[0]; - - for (var i = 1, len = oStringList.length; i < len; i++) { - var s = oStringList[i]; - camelizedString += s.charAt(0).toUpperCase() + s.substring(1); - } - - return camelizedString; - }, - - inspect: function() { - return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'"; - } -}); - -String.prototype.parseQuery = String.prototype.toQueryParams; - -var $break = new Object(); -var $continue = new Object(); - -var Enumerable = { - each: function(iterator) { - var index = 0; - try { - this._each(function(value) { - try { - iterator(value, index++); - } catch (e) { - if (e != $continue) throw e; - } - }); - } catch (e) { - if (e != $break) throw e; - } - }, - - all: function(iterator) { - var result = true; - this.each(function(value, index) { - result = result && !!(iterator || Prototype.K)(value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator) { - var result = true; - this.each(function(value, index) { - if (result = !!(iterator || Prototype.K)(value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator) { - var results = []; - this.each(function(value, index) { - results.push(iterator(value, index)); - }); - return results; - }, - - detect: function (iterator) { - var result; - this.each(function(value, index) { - if (iterator(value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator) { - var results = []; - this.each(function(value, index) { - if (iterator(value, index)) - results.push(value); - }); - return results; - }, - - grep: function(pattern, iterator) { - var results = []; - this.each(function(value, index) { - var stringValue = value.toString(); - if (stringValue.match(pattern)) - results.push((iterator || Prototype.K)(value, index)); - }) - return results; - }, - - include: function(object) { - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inject: function(memo, iterator) { - this.each(function(value, index) { - memo = iterator(memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.collect(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator) { - var result; - this.each(function(value, index) { - value = (iterator || Prototype.K)(value, index); - if (value >= (result || value)) - result = value; - }); - return result; - }, - - min: function(iterator) { - var result; - this.each(function(value, index) { - value = (iterator || Prototype.K)(value, index); - if (value <= (result || value)) - result = value; - }); - return result; - }, - - partition: function(iterator) { - var trues = [], falses = []; - this.each(function(value, index) { - ((iterator || Prototype.K)(value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value, index) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator) { - var results = []; - this.each(function(value, index) { - if (!iterator(value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator) { - return this.collect(function(value, index) { - return {value: value, criteria: iterator(value, index)}; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.collect(Prototype.K); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (typeof args.last() == 'function') - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - iterator(value = collections.pluck(index)); - return value; - }); - }, - - inspect: function() { - return '#'; - } -} - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray -}); -var $A = Array.from = function(iterable) { - if (!iterable) return []; - if (iterable.toArray) { - return iterable.toArray(); - } else { - var results = []; - for (var i = 0; i < iterable.length; i++) - results.push(iterable[i]); - return results; - } -} - -Object.extend(Array.prototype, Enumerable); - -Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0; i < this.length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != undefined || value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(value.constructor == Array ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - indexOf: function(object) { - for (var i = 0; i < this.length; i++) - if (this[i] == object) return i; - return -1; - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - shift: function() { - var result = this[0]; - for (var i = 0; i < this.length - 1; i++) - this[i] = this[i + 1]; - this.length--; - return result; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - } -}); -var Hash = { - _each: function(iterator) { - for (key in this) { - var value = this[key]; - if (typeof value == 'function') continue; - - var pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - merge: function(hash) { - return $H(hash).inject($H(this), function(mergedHash, pair) { - mergedHash[pair.key] = pair.value; - return mergedHash; - }); - }, - - toQueryString: function() { - return this.map(function(pair) { - return pair.map(encodeURIComponent).join('='); - }).join('&'); - }, - - inspect: function() { - return '#'; - } -} - -function $H(object) { - var hash = Object.extend({}, object || {}); - Object.extend(hash, Enumerable); - Object.extend(hash, Hash); - return hash; -} -ObjectRange = Class.create(); -Object.extend(ObjectRange.prototype, Enumerable); -Object.extend(ObjectRange.prototype, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - do { - iterator(value); - value = value.succ(); - } while (this.include(value)); - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -} - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')}, - function() {return new XMLHttpRequest()} - ) || false; - }, - - activeRequestCount: 0 -} - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responderToAdd) { - if (!this.include(responderToAdd)) - this.responders.push(responderToAdd); - }, - - unregister: function(responderToRemove) { - this.responders = this.responders.without(responderToRemove); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (responder[callback] && typeof responder[callback] == 'function') { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) {} - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { - Ajax.activeRequestCount++; - }, - - onComplete: function() { - Ajax.activeRequestCount--; - } -}); - -Ajax.Base = function() {}; -Ajax.Base.prototype = { - setOptions: function(options) { - this.options = { - method: 'post', - asynchronous: true, - parameters: '' - } - Object.extend(this.options, options || {}); - }, - - responseIsSuccess: function() { - return this.transport.status == undefined - || this.transport.status == 0 - || (this.transport.status >= 200 && this.transport.status < 300); - }, - - responseIsFailure: function() { - return !this.responseIsSuccess(); - } -} - -Ajax.Request = Class.create(); -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Request.prototype = Object.extend(new Ajax.Base(), { - initialize: function(url, options) { - this.transport = Ajax.getTransport(); - this.setOptions(options); - this.request(url); - }, - - request: function(url) { - var parameters = this.options.parameters || ''; - if (parameters.length > 0) parameters += '&_='; - - try { - this.url = url; - if (this.options.method == 'get' && parameters.length > 0) - this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; - - Ajax.Responders.dispatch('onCreate', this, this.transport); - - this.transport.open(this.options.method, this.url, - this.options.asynchronous); - - if (this.options.asynchronous) { - this.transport.onreadystatechange = this.onStateChange.bind(this); - setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); - } - - this.setRequestHeaders(); - - var body = this.options.postBody ? this.options.postBody : parameters; - this.transport.send(this.options.method == 'post' ? body : null); - - } catch (e) { - this.dispatchException(e); - } - }, - - setRequestHeaders: function() { - var requestHeaders = - ['X-Requested-With', 'XMLHttpRequest', - 'X-Prototype-Version', Prototype.Version]; - - if (this.options.method == 'post') { - requestHeaders.push('Content-type', - 'application/x-www-form-urlencoded'); - - /* Force "Connection: close" for Mozilla browsers to work around - * a bug where XMLHttpReqeuest sends an incorrect Content-length - * header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType) - requestHeaders.push('Connection', 'close'); - } - - if (this.options.requestHeaders) - requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); - - for (var i = 0; i < requestHeaders.length; i += 2) - this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState != 1) - this.respondToReadyState(this.transport.readyState); - }, - - header: function(name) { - try { - return this.transport.getResponseHeader(name); - } catch (e) {} - }, - - evalJSON: function() { - try { - return eval(this.header('X-JSON')); - } catch (e) {} - }, - - evalResponse: function() { - try { - return eval(this.transport.responseText); - } catch (e) { - this.dispatchException(e); - } - }, - - respondToReadyState: function(readyState) { - var event = Ajax.Request.Events[readyState]; - var transport = this.transport, json = this.evalJSON(); - - if (event == 'Complete') { - try { - (this.options['on' + this.transport.status] - || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(transport, json); - } catch (e) { - this.dispatchException(e); - } - - if ((this.header('Content-type') || '').match(/^text\/javascript/i)) - this.evalResponse(); - } - - try { - (this.options['on' + event] || Prototype.emptyFunction)(transport, json); - Ajax.Responders.dispatch('on' + event, this, transport, json); - } catch (e) { - this.dispatchException(e); - } - - /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ - if (event == 'Complete') - this.transport.onreadystatechange = Prototype.emptyFunction; - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Updater = Class.create(); - -Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { - initialize: function(container, url, options) { - this.containers = { - success: container.success ? $(container.success) : $(container), - failure: container.failure ? $(container.failure) : - (container.success ? null : $(container)) - } - - this.transport = Ajax.getTransport(); - this.setOptions(options); - - var onComplete = this.options.onComplete || Prototype.emptyFunction; - this.options.onComplete = (function(transport, object) { - this.updateContent(); - onComplete(transport, object); - }).bind(this); - - this.request(url); - }, - - updateContent: function() { - var receiver = this.responseIsSuccess() ? - this.containers.success : this.containers.failure; - var response = this.transport.responseText; - - if (!this.options.evalScripts) - response = response.stripScripts(); - - if (receiver) { - if (this.options.insertion) { - new this.options.insertion(receiver, response); - } else { - Element.update(receiver, response); - } - } - - if (this.responseIsSuccess()) { - if (this.onComplete) - setTimeout(this.onComplete.bind(this), 10); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(); -Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { - initialize: function(container, url, options) { - this.setOptions(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = {}; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(request) { - if (this.options.decay) { - this.decay = (request.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = request.responseText; - } - this.timer = setTimeout(this.onTimerEvent.bind(this), - this.decay * this.frequency * 1000); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -document.getElementsByClassName = function(className, parentElement) { - var children = ($(parentElement) || document.body).getElementsByTagName('*'); - return $A(children).inject([], function(elements, child) { - if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) - elements.push(child); - return elements; - }); -} - -/*--------------------------------------------------------------------------*/ - -if (!window.Element) { - var Element = new Object(); -} - -Object.extend(Element, { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function() { - for (var i = 0; i < arguments.length; i++) { - var element = $(arguments[i]); - Element[Element.visible(element) ? 'hide' : 'show'](element); - } - }, - - hide: function() { - for (var i = 0; i < arguments.length; i++) { - var element = $(arguments[i]); - element.style.display = 'none'; - } - }, - - show: function() { - for (var i = 0; i < arguments.length; i++) { - var element = $(arguments[i]); - element.style.display = ''; - } - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - }, - - update: function(element, html) { - $(element).innerHTML = html.stripScripts(); - setTimeout(function() {html.evalScripts()}, 10); - }, - - getHeight: function(element) { - element = $(element); - return element.offsetHeight; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - return Element.classNames(element).include(className); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - return Element.classNames(element).add(className); - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - return Element.classNames(element).remove(className); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - for (var i = 0; i < element.childNodes.length; i++) { - var node = element.childNodes[i]; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - Element.remove(node); - } - }, - - empty: function(element) { - return $(element).innerHTML.match(/^\s*$/); - }, - - scrollTo: function(element) { - element = $(element); - var x = element.x ? element.x : element.offsetLeft, - y = element.y ? element.y : element.offsetTop; - window.scrollTo(x, y); - }, - - getStyle: function(element, style) { - element = $(element); - var value = element.style[style.camelize()]; - if (!value) { - if (document.defaultView && document.defaultView.getComputedStyle) { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css.getPropertyValue(style) : null; - } else if (element.currentStyle) { - value = element.currentStyle[style.camelize()]; - } - } - - if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) - if (Element.getStyle(element, 'position') == 'static') value = 'auto'; - - return value == 'auto' ? null : value; - }, - - setStyle: function(element, style) { - element = $(element); - for (name in style) - element.style[name.camelize()] = style[name]; - }, - - getDimensions: function(element) { - element = $(element); - if (Element.getStyle(element, 'display') != 'none') - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = ''; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = 'none'; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (window.opera) { - element.style.top = 0; - element.style.left = 0; - } - } - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return; - element._overflow = element.style.overflow; - if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') - element.style.overflow = 'hidden'; - }, - - undoClipping: function(element) { - element = $(element); - if (element._overflow) return; - element.style.overflow = element._overflow; - element._overflow = undefined; - } -}); - -var Toggle = new Object(); -Toggle.display = Element.toggle; - -/*--------------------------------------------------------------------------*/ - -Abstract.Insertion = function(adjacency) { - this.adjacency = adjacency; -} - -Abstract.Insertion.prototype = { - initialize: function(element, content) { - this.element = $(element); - this.content = content.stripScripts(); - - if (this.adjacency && this.element.insertAdjacentHTML) { - try { - this.element.insertAdjacentHTML(this.adjacency, this.content); - } catch (e) { - if (this.element.tagName.toLowerCase() == 'tbody') { - this.insertContent(this.contentFromAnonymousTable()); - } else { - throw e; - } - } - } else { - this.range = this.element.ownerDocument.createRange(); - if (this.initializeRange) this.initializeRange(); - this.insertContent([this.range.createContextualFragment(this.content)]); - } - - setTimeout(function() {content.evalScripts()}, 10); - }, - - contentFromAnonymousTable: function() { - var div = document.createElement('div'); - div.innerHTML = '' + this.content + '
    '; - return $A(div.childNodes[0].childNodes[0].childNodes); - } -} - -var Insertion = new Object(); - -Insertion.Before = Class.create(); -Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), { - initializeRange: function() { - this.range.setStartBefore(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.parentNode.insertBefore(fragment, this.element); - }).bind(this)); - } -}); - -Insertion.Top = Class.create(); -Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), { - initializeRange: function() { - this.range.selectNodeContents(this.element); - this.range.collapse(true); - }, - - insertContent: function(fragments) { - fragments.reverse(false).each((function(fragment) { - this.element.insertBefore(fragment, this.element.firstChild); - }).bind(this)); - } -}); - -Insertion.Bottom = Class.create(); -Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), { - initializeRange: function() { - this.range.selectNodeContents(this.element); - this.range.collapse(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.appendChild(fragment); - }).bind(this)); - } -}); - -Insertion.After = Class.create(); -Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), { - initializeRange: function() { - this.range.setStartAfter(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.parentNode.insertBefore(fragment, - this.element.nextSibling); - }).bind(this)); - } -}); - -/*--------------------------------------------------------------------------*/ - -Element.ClassNames = Class.create(); -Element.ClassNames.prototype = { - initialize: function(element) { - this.element = $(element); - }, - - _each: function(iterator) { - this.element.className.split(/\s+/).select(function(name) { - return name.length > 0; - })._each(iterator); - }, - - set: function(className) { - this.element.className = className; - }, - - add: function(classNameToAdd) { - if (this.include(classNameToAdd)) return; - this.set(this.toArray().concat(classNameToAdd).join(' ')); - }, - - remove: function(classNameToRemove) { - if (!this.include(classNameToRemove)) return; - this.set(this.select(function(className) { - return className != classNameToRemove; - }).join(' ')); - }, - - toString: function() { - return this.toArray().join(' '); - } -} - -Object.extend(Element.ClassNames.prototype, Enumerable); -var Field = { - clear: function() { - for (var i = 0; i < arguments.length; i++) - $(arguments[i]).value = ''; - }, - - focus: function(element) { - $(element).focus(); - }, - - present: function() { - for (var i = 0; i < arguments.length; i++) - if ($(arguments[i]).value == '') return false; - return true; - }, - - select: function(element) { - $(element).select(); - }, - - activate: function(element) { - element = $(element); - element.focus(); - if (element.select) - element.select(); - } -} - -/*--------------------------------------------------------------------------*/ - -var Form = { - serialize: function(form) { - var elements = Form.getElements($(form)); - var queryComponents = new Array(); - - for (var i = 0; i < elements.length; i++) { - var queryComponent = Form.Element.serialize(elements[i]); - if (queryComponent) - queryComponents.push(queryComponent); - } - - return queryComponents.join('&'); - }, - - getElements: function(form) { - form = $(form); - var elements = new Array(); - - for (tagName in Form.Element.Serializers) { - var tagElements = form.getElementsByTagName(tagName); - for (var j = 0; j < tagElements.length; j++) - elements.push(tagElements[j]); - } - return elements; - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) - return inputs; - - var matchingInputs = new Array(); - for (var i = 0; i < inputs.length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || - (name && input.name != name)) - continue; - matchingInputs.push(input); - } - - return matchingInputs; - }, - - disable: function(form) { - var elements = Form.getElements(form); - for (var i = 0; i < elements.length; i++) { - var element = elements[i]; - element.blur(); - element.disabled = 'true'; - } - }, - - enable: function(form) { - var elements = Form.getElements(form); - for (var i = 0; i < elements.length; i++) { - var element = elements[i]; - element.disabled = ''; - } - }, - - findFirstElement: function(form) { - return Form.getElements(form).find(function(element) { - return element.type != 'hidden' && !element.disabled && - ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - Field.activate(Form.findFirstElement(form)); - }, - - reset: function(form) { - $(form).reset(); - } -} - -Form.Element = { - serialize: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - var parameter = Form.Element.Serializers[method](element); - - if (parameter) { - var key = encodeURIComponent(parameter[0]); - if (key.length == 0) return; - - if (parameter[1].constructor != Array) - parameter[1] = [parameter[1]]; - - return parameter[1].map(function(value) { - return key + '=' + encodeURIComponent(value); - }).join('&'); - } - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - var parameter = Form.Element.Serializers[method](element); - - if (parameter) - return parameter[1]; - } -} - -Form.Element.Serializers = { - input: function(element) { - switch (element.type.toLowerCase()) { - case 'submit': - case 'hidden': - case 'password': - case 'text': - return Form.Element.Serializers.textarea(element); - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element); - } - return false; - }, - - inputSelector: function(element) { - if (element.checked) - return [element.name, element.value]; - }, - - textarea: function(element) { - return [element.name, element.value]; - }, - - select: function(element) { - return Form.Element.Serializers[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - }, - - selectOne: function(element) { - var value = '', opt, index = element.selectedIndex; - if (index >= 0) { - opt = element.options[index]; - value = opt.value; - if (!value && !('value' in opt)) - value = opt.text; - } - return [element.name, value]; - }, - - selectMany: function(element) { - var value = new Array(); - for (var i = 0; i < element.length; i++) { - var opt = element.options[i]; - if (opt.selected) { - var optValue = opt.value; - if (!optValue && !('value' in opt)) - optValue = opt.text; - value.push(optValue); - } - } - return [element.name, value]; - } -} - -/*--------------------------------------------------------------------------*/ - -var $F = Form.Element.getValue; - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = function() {} -Abstract.TimedObserver.prototype = { - initialize: function(element, frequency, callback) { - this.frequency = frequency; - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - this.registerCallback(); - }, - - registerCallback: function() { - setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - onTimerEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - } -} - -Form.Element.Observer = Class.create(); -Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(); -Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = function() {} -Abstract.EventObserver.prototype = { - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - var elements = Form.getElements(this.element); - for (var i = 0; i < elements.length; i++) - this.registerCallback(elements[i]); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - case 'password': - case 'text': - case 'textarea': - case 'select-one': - case 'select-multiple': - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -} - -Form.Element.EventObserver = Class.create(); -Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(); -Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) { - var Event = new Object(); -} - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - - element: function(event) { - return event.target || event.srcElement; - }, - - isLeftClick: function(event) { - return (((event.which) && (event.which == 1)) || - ((event.button) && (event.button == 1))); - }, - - pointerX: function(event) { - return event.pageX || (event.clientX + - (document.documentElement.scrollLeft || document.body.scrollLeft)); - }, - - pointerY: function(event) { - return event.pageY || (event.clientY + - (document.documentElement.scrollTop || document.body.scrollTop)); - }, - - stop: function(event) { - if (event.preventDefault) { - event.preventDefault(); - event.stopPropagation(); - } else { - event.returnValue = false; - event.cancelBubble = true; - } - }, - - // find the first node with the given tagName, starting from the - // node the event was triggered on; traverses the DOM upwards - findElement: function(event, tagName) { - var element = Event.element(event); - while (element.parentNode && (!element.tagName || - (element.tagName.toUpperCase() != tagName.toUpperCase()))) - element = element.parentNode; - return element; - }, - - observers: false, - - _observeAndCache: function(element, name, observer, useCapture) { - if (!this.observers) this.observers = []; - if (element.addEventListener) { - this.observers.push([element, name, observer, useCapture]); - element.addEventListener(name, observer, useCapture); - } else if (element.attachEvent) { - this.observers.push([element, name, observer, useCapture]); - element.attachEvent('on' + name, observer); - } - }, - - unloadCache: function() { - if (!Event.observers) return; - for (var i = 0; i < Event.observers.length; i++) { - Event.stopObserving.apply(this, Event.observers[i]); - Event.observers[i][0] = null; - } - Event.observers = false; - }, - - observe: function(element, name, observer, useCapture) { - var element = $(element); - useCapture = useCapture || false; - - if (name == 'keypress' && - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) - || element.attachEvent)) - name = 'keydown'; - - this._observeAndCache(element, name, observer, useCapture); - }, - - stopObserving: function(element, name, observer, useCapture) { - var element = $(element); - useCapture = useCapture || false; - - if (name == 'keypress' && - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) - || element.detachEvent)) - name = 'keydown'; - - if (element.removeEventListener) { - element.removeEventListener(name, observer, useCapture); - } else if (element.detachEvent) { - element.detachEvent('on' + name, observer); - } - } -}); - -/* prevent memory leaks in IE */ -Event.observe(window, 'unload', Event.unloadCache, false); -var Position = { - // set to true if needed, warning: firefox performance problems - // NOT neeeded for page scrolling, only if draggable contained in - // scrollable elements - includeScrollOffsets: false, - - // must be called before calling withinIncludingScrolloffset, every time the - // page is scrolled - prepare: function() { - this.deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - this.deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - }, - - realOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return [valueL, valueT]; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return [valueL, valueT]; - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - p = Element.getStyle(element, 'position'); - if (p == 'relative' || p == 'absolute') break; - } - } while (element); - return [valueL, valueT]; - }, - - offsetParent: function(element) { - if (element.offsetParent) return element.offsetParent; - if (element == document.body) return element; - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return element; - - return document.body; - }, - - // caches x/y coordinate pair to use with overlap - within: function(element, x, y) { - if (this.includeScrollOffsets) - return this.withinIncludingScrolloffsets(element, x, y); - this.xcomp = x; - this.ycomp = y; - this.offset = this.cumulativeOffset(element); - - return (y >= this.offset[1] && - y < this.offset[1] + element.offsetHeight && - x >= this.offset[0] && - x < this.offset[0] + element.offsetWidth); - }, - - withinIncludingScrolloffsets: function(element, x, y) { - var offsetcache = this.realOffset(element); - - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.offset = this.cumulativeOffset(element); - - return (this.ycomp >= this.offset[1] && - this.ycomp < this.offset[1] + element.offsetHeight && - this.xcomp >= this.offset[0] && - this.xcomp < this.offset[0] + element.offsetWidth); - }, - - // within must be called directly before - overlap: function(mode, element) { - if (!mode) return 0; - if (mode == 'vertical') - return ((this.offset[1] + element.offsetHeight) - this.ycomp) / - element.offsetHeight; - if (mode == 'horizontal') - return ((this.offset[0] + element.offsetWidth) - this.xcomp) / - element.offsetWidth; - }, - - clone: function(source, target) { - source = $(source); - target = $(target); - target.style.position = 'absolute'; - var offsets = this.cumulativeOffset(source); - target.style.top = offsets[1] + 'px'; - target.style.left = offsets[0] + 'px'; - target.style.width = source.offsetWidth + 'px'; - target.style.height = source.offsetHeight + 'px'; - }, - - page: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent==document.body) - if (Element.getStyle(element,'position')=='absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } while (element = element.parentNode); - - return [valueL, valueT]; - }, - - clone: function(source, target) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || {}) - - // find page position of source - source = $(source); - var p = Position.page(source); - - // find coordinate system to use - target = $(target); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(target,'position') == 'absolute') { - parent = Position.offsetParent(target); - delta = Position.page(parent); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if(options.setWidth) target.style.width = source.offsetWidth + 'px'; - if(options.setHeight) target.style.height = source.offsetHeight + 'px'; - }, - - absolutize: function(element) { - element = $(element); - if (element.style.position == 'absolute') return; - Position.prepare(); - - var offsets = Position.positionedOffset(element); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px';; - element.style.left = left + 'px';; - element.style.width = width + 'px';; - element.style.height = height + 'px';; - }, - - relativize: function(element) { - element = $(element); - if (element.style.position == 'relative') return; - Position.prepare(); - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - } -} - -// Safari returns margins on body which is incorrect if the child is absolutely -// positioned. For performance reasons, redefine Position.cumulativeOffset for -// KHTML/WebKit only. -if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { - Position.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return [valueL, valueT]; - } -} \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/robots.txt b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/robots.txt deleted file mode 100644 index 4ab9e89f..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/about b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/about deleted file mode 100644 index 7b07d46a..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/about +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/about' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/breakpointer b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/breakpointer deleted file mode 100644 index 64af76ed..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/breakpointer +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/breakpointer' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/console b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/console deleted file mode 100644 index 42f28f7d..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/console +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/console' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/destroy b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/destroy deleted file mode 100644 index fa0e6fcd..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/destroy +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/destroy' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/generate b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/generate deleted file mode 100644 index ef976e09..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/generate +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/generate' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/performance/benchmarker b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/performance/benchmarker deleted file mode 100644 index c842d35d..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/performance/benchmarker +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/benchmarker' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/performance/profiler b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/performance/profiler deleted file mode 100644 index d855ac8b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/performance/profiler +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/profiler' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/plugin b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/plugin deleted file mode 100644 index 26ca64c0..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/plugin +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/plugin' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/reaper b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/reaper deleted file mode 100644 index c77f0453..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/reaper +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/reaper' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/spawner b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/spawner deleted file mode 100644 index 7118f398..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/spawner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/spawner' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/spinner b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/spinner deleted file mode 100644 index 6816b32e..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/process/spinner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/spinner' diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/runner b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/runner deleted file mode 100644 index ccc30f9d..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/runner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/runner' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/server b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/server deleted file mode 100644 index dfabcb88..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/script/server +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/server' \ No newline at end of file diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/functional/login_controller_test.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/functional/login_controller_test.rb deleted file mode 100644 index a21d4382..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/functional/login_controller_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'login_controller' - -# Re-raise errors caught by the controller. -class LoginController; def rescue_action(e) raise e end; end - -class LoginControllerTest < Test::Unit::TestCase - def setup - @controller = LoginController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/functional/server_controller_test.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/functional/server_controller_test.rb deleted file mode 100644 index 7afd69e6..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/functional/server_controller_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'server_controller' - -# Re-raise errors caught by the controller. -class ServerController; def rescue_action(e) raise e end; end - -class ServerControllerTest < Test::Unit::TestCase - def setup - @controller = ServerController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/test_helper.rb b/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/test_helper.rb deleted file mode 100644 index a299c7f6..00000000 --- a/vendor/gems/ruby-openid-2.1.2/examples/rails_openid/test/test_helper.rb +++ /dev/null @@ -1,28 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") -require 'test_help' - -class Test::Unit::TestCase - # Transactional fixtures accelerate your tests by wrapping each test method - # in a transaction that's rolled back on completion. This ensures that the - # test database remains unchanged so your fixtures don't have to be reloaded - # between every test method. Fewer database queries means faster tests. - # - # Read Mike Clark's excellent walkthrough at - # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting - # - # Every Active Record database supports transactions except MyISAM tables - # in MySQL. Turn off transactional fixtures in this case; however, if you - # don't care one way or the other, switching from MyISAM to InnoDB tables - # is recommended. - self.use_transactional_fixtures = true - - # Instantiated fixtures are slow, but give you @david where otherwise you - # would need people(:david). If you don't want to migrate your existing - # test cases which use the @david style and don't mind the speed hit (each - # instantiated fixtures translates to a database query per test method), - # then set this back to true. - self.use_instantiated_fixtures = false - - # Add more helper methods to be used by all tests here... -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/hmac/hmac.rb b/vendor/gems/ruby-openid-2.1.2/lib/hmac/hmac.rb deleted file mode 100644 index e8bfa42b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/hmac/hmac.rb +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (C) 2001 Daiki Ueno -# This library is distributed under the terms of the Ruby license. - -# This module provides common interface to HMAC engines. -# HMAC standard is documented in RFC 2104: -# -# H. Krawczyk et al., "HMAC: Keyed-Hashing for Message Authentication", -# RFC 2104, February 1997 -# -# These APIs are inspired by JCE 1.2's javax.crypto.Mac interface. -# -# - -module HMAC - class Base - def initialize(algorithm, block_size, output_length, key) - @algorithm = algorithm - @block_size = block_size - @output_length = output_length - @status = STATUS_UNDEFINED - @key_xor_ipad = '' - @key_xor_opad = '' - set_key(key) unless key.nil? - end - - private - def check_status - unless @status == STATUS_INITIALIZED - raise RuntimeError, - "The underlying hash algorithm has not yet been initialized." - end - end - - public - def set_key(key) - # If key is longer than the block size, apply hash function - # to key and use the result as a real key. - key = @algorithm.digest(key) if key.size > @block_size - key_xor_ipad = "\x36" * @block_size - key_xor_opad = "\x5C" * @block_size - for i in 0 .. key.size - 1 - key_xor_ipad[i] ^= key[i] - key_xor_opad[i] ^= key[i] - end - @key_xor_ipad = key_xor_ipad - @key_xor_opad = key_xor_opad - @md = @algorithm.new - @status = STATUS_INITIALIZED - end - - def reset_key - @key_xor_ipad.gsub!(/./, '?') - @key_xor_opad.gsub!(/./, '?') - @key_xor_ipad[0..-1] = '' - @key_xor_opad[0..-1] = '' - @status = STATUS_UNDEFINED - end - - def update(text) - check_status - # perform inner H - md = @algorithm.new - md.update(@key_xor_ipad) - md.update(text) - str = md.digest - # perform outer H - md = @algorithm.new - md.update(@key_xor_opad) - md.update(str) - @md = md - end - alias << update - - def digest - check_status - @md.digest - end - - def hexdigest - check_status - @md.hexdigest - end - alias to_s hexdigest - - # These two class methods below are safer than using above - # instance methods combinatorially because an instance will have - # held a key even if it's no longer in use. - def Base.digest(key, text) - begin - hmac = self.new(key) - hmac.update(text) - hmac.digest - ensure - hmac.reset_key - end - end - - def Base.hexdigest(key, text) - begin - hmac = self.new(key) - hmac.update(text) - hmac.hexdigest - ensure - hmac.reset_key - end - end - - private_class_method :new, :digest, :hexdigest - end - - STATUS_UNDEFINED, STATUS_INITIALIZED = 0, 1 -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/hmac/sha1.rb b/vendor/gems/ruby-openid-2.1.2/lib/hmac/sha1.rb deleted file mode 100644 index d2f0088a..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/hmac/sha1.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'hmac/hmac' -require 'digest/sha1' - -module HMAC - class SHA1 < Base - def initialize(key = nil) - super(Digest::SHA1, 64, 20, key) - end - public_class_method :new, :digest, :hexdigest - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/hmac/sha2.rb b/vendor/gems/ruby-openid-2.1.2/lib/hmac/sha2.rb deleted file mode 100644 index 0412ba40..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/hmac/sha2.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'hmac/hmac' -require 'digest/sha2' - -module HMAC - class SHA256 < Base - def initialize(key = nil) - super(Digest::SHA256, 64, 32, key) - end - public_class_method :new, :digest, :hexdigest - end - - class SHA384 < Base - def initialize(key = nil) - super(Digest::SHA384, 128, 48, key) - end - public_class_method :new, :digest, :hexdigest - end - - class SHA512 < Base - def initialize(key = nil) - super(Digest::SHA512, 128, 64, key) - end - public_class_method :new, :digest, :hexdigest - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid.rb deleted file mode 100644 index de6cc6b4..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2006-2007 JanRain, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you -# may not use this file except in compliance with the License. You may -# obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. - -module OpenID - VERSION = "2.1.2" -end - -require "openid/consumer" -require 'openid/server' diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/association.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/association.rb deleted file mode 100644 index fd2cd599..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/association.rb +++ /dev/null @@ -1,249 +0,0 @@ -require "openid/kvform" -require "openid/util" -require "openid/cryptutil" -require "openid/message" - -module OpenID - - def self.get_secret_size(assoc_type) - if assoc_type == 'HMAC-SHA1' - return 20 - elsif assoc_type == 'HMAC-SHA256' - return 32 - else - raise ArgumentError("Unsupported association type: #{assoc_type}") - end - end - - # An Association holds the shared secret between a relying party and - # an OpenID provider. - class Association - attr_reader :handle, :secret, :issued, :lifetime, :assoc_type - - FIELD_ORDER = - [:version, :handle, :secret, :issued, :lifetime, :assoc_type,] - - # Load a serialized Association - def self.deserialize(serialized) - parsed = Util.kv_to_seq(serialized) - parsed_fields = parsed.map{|k, v| k.to_sym} - if parsed_fields != FIELD_ORDER - raise ProtocolError, 'Unexpected fields in serialized association'\ - " (Expected #{FIELD_ORDER.inspect}, got #{parsed_fields.inspect})" - end - version, handle, secret64, issued_s, lifetime_s, assoc_type = - parsed.map {|field, value| value} - if version != '2' - raise ProtocolError, "Attempted to deserialize unsupported version "\ - "(#{parsed[0][1].inspect})" - end - - self.new(handle, - Util.from_base64(secret64), - Time.at(issued_s.to_i), - lifetime_s.to_i, - assoc_type) - end - - # Create an Association with an issued time of now - def self.from_expires_in(expires_in, handle, secret, assoc_type) - issued = Time.now - self.new(handle, secret, issued, expires_in, assoc_type) - end - - def initialize(handle, secret, issued, lifetime, assoc_type) - @handle = handle - @secret = secret - @issued = issued - @lifetime = lifetime - @assoc_type = assoc_type - end - - # Serialize the association to a form that's consistent across - # JanRain OpenID libraries. - def serialize - data = { - :version => '2', - :handle => handle, - :secret => Util.to_base64(secret), - :issued => issued.to_i.to_s, - :lifetime => lifetime.to_i.to_s, - :assoc_type => assoc_type, - } - - Util.assert(data.length == FIELD_ORDER.length) - - pairs = FIELD_ORDER.map{|field| [field.to_s, data[field]]} - return Util.seq_to_kv(pairs, strict=true) - end - - # The number of seconds until this association expires - def expires_in(now=nil) - if now.nil? - now = Time.now.to_i - else - now = now.to_i - end - time_diff = (issued.to_i + lifetime) - now - if time_diff < 0 - return 0 - else - return time_diff - end - end - - # Generate a signature for a sequence of [key, value] pairs - def sign(pairs) - kv = Util.seq_to_kv(pairs) - case assoc_type - when 'HMAC-SHA1' - CryptUtil.hmac_sha1(@secret, kv) - when 'HMAC-SHA256' - CryptUtil.hmac_sha256(@secret, kv) - else - raise ProtocolError, "Association has unknown type: "\ - "#{assoc_type.inspect}" - end - end - - # Generate the list of pairs that form the signed elements of the - # given message - def make_pairs(message) - signed = message.get_arg(OPENID_NS, 'signed') - if signed.nil? - raise ProtocolError, 'Missing signed list' - end - signed_fields = signed.split(',', -1) - data = message.to_post_args - signed_fields.map {|field| [field, data.fetch('openid.'+field,'')] } - end - - # Return whether the message's signature passes - def check_message_signature(message) - message_sig = message.get_arg(OPENID_NS, 'sig') - if message_sig.nil? - raise ProtocolError, "#{message} has no sig." - end - calculated_sig = get_message_signature(message) - return calculated_sig == message_sig - end - - # Get the signature for this message - def get_message_signature(message) - Util.to_base64(sign(make_pairs(message))) - end - - def ==(other) - (other.class == self.class and - other.handle == self.handle and - other.secret == self.secret and - - # The internals of the time objects seemed to differ - # in an opaque way when serializing/unserializing. - # I don't think this will be a problem. - other.issued.to_i == self.issued.to_i and - - other.lifetime == self.lifetime and - other.assoc_type == self.assoc_type) - end - - # Add a signature (and a signed list) to a message. - def sign_message(message) - if (message.has_key?(OPENID_NS, 'sig') or - message.has_key?(OPENID_NS, 'signed')) - raise ArgumentError, 'Message already has signed list or signature' - end - - extant_handle = message.get_arg(OPENID_NS, 'assoc_handle') - if extant_handle and extant_handle != self.handle - raise ArgumentError, "Message has a different association handle" - end - - signed_message = message.copy() - signed_message.set_arg(OPENID_NS, 'assoc_handle', self.handle) - message_keys = signed_message.to_post_args.keys() - - signed_list = [] - message_keys.each { |k| - if k.starts_with?('openid.') - signed_list << k[7..-1] - end - } - - signed_list << 'signed' - signed_list.sort! - - signed_message.set_arg(OPENID_NS, 'signed', signed_list.join(',')) - sig = get_message_signature(signed_message) - signed_message.set_arg(OPENID_NS, 'sig', sig) - return signed_message - end - end - - class AssociationNegotiator - attr_reader :allowed_types - - def self.get_session_types(assoc_type) - case assoc_type - when 'HMAC-SHA1' - ['DH-SHA1', 'no-encryption'] - when 'HMAC-SHA256' - ['DH-SHA256', 'no-encryption'] - else - raise ProtocolError, "Unknown association type #{assoc_type.inspect}" - end - end - - def self.check_session_type(assoc_type, session_type) - if !get_session_types(assoc_type).include?(session_type) - raise ProtocolError, "Session type #{session_type.inspect} not "\ - "valid for association type #{assoc_type.inspect}" - end - end - - def initialize(allowed_types) - self.allowed_types=(allowed_types) - end - - def copy - Marshal.load(Marshal.dump(self)) - end - - def allowed_types=(allowed_types) - allowed_types.each do |assoc_type, session_type| - self.class.check_session_type(assoc_type, session_type) - end - @allowed_types = allowed_types - end - - def add_allowed_type(assoc_type, session_type=nil) - if session_type.nil? - session_types = self.class.get_session_types(assoc_type) - else - self.class.check_session_type(assoc_type, session_type) - session_types = [session_type] - end - for session_type in session_types do - @allowed_types << [assoc_type, session_type] - end - end - - def allowed?(assoc_type, session_type) - @allowed_types.include?([assoc_type, session_type]) - end - - def get_allowed_type - @allowed_types.empty? ? nil : @allowed_types[0] - end - end - - DefaultNegotiator = - AssociationNegotiator.new([['HMAC-SHA1', 'DH-SHA1'], - ['HMAC-SHA1', 'no-encryption'], - ['HMAC-SHA256', 'DH-SHA256'], - ['HMAC-SHA256', 'no-encryption']]) - - EncryptedNegotiator = - AssociationNegotiator.new([['HMAC-SHA1', 'DH-SHA1'], - ['HMAC-SHA256', 'DH-SHA256']]) -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer.rb deleted file mode 100644 index f7c52377..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer.rb +++ /dev/null @@ -1,394 +0,0 @@ -require "openid/consumer/idres.rb" -require "openid/consumer/checkid_request.rb" -require "openid/consumer/associationmanager.rb" -require "openid/consumer/responses.rb" -require "openid/consumer/discovery_manager" -require "openid/consumer/discovery" -require "openid/message" -require "openid/yadis/discovery" -require "openid/store/nonce" - -module OpenID - # OpenID support for Relying Parties (aka Consumers). - # - # This module documents the main interface with the OpenID consumer - # library. The only part of the library which has to be used and - # isn't documented in full here is the store required to create an - # Consumer instance. - # - # = OVERVIEW - # - # The OpenID identity verification process most commonly uses the - # following steps, as visible to the user of this library: - # - # 1. The user enters their OpenID into a field on the consumer's - # site, and hits a login button. - # - # 2. The consumer site discovers the user's OpenID provider using - # the Yadis protocol. - # - # 3. The consumer site sends the browser a redirect to the OpenID - # provider. This is the authentication request as described in - # the OpenID specification. - # - # 4. The OpenID provider's site sends the browser a redirect back to - # the consumer site. This redirect contains the provider's - # response to the authentication request. - # - # The most important part of the flow to note is the consumer's site - # must handle two separate HTTP requests in order to perform the - # full identity check. - # - # = LIBRARY DESIGN - # - # This consumer library is designed with that flow in mind. The - # goal is to make it as easy as possible to perform the above steps - # securely. - # - # At a high level, there are two important parts in the consumer - # library. The first important part is this module, which contains - # the interface to actually use this library. The second is - # openid/store/interface.rb, which describes the interface to use if - # you need to create a custom method for storing the state this - # library needs to maintain between requests. - # - # In general, the second part is less important for users of the - # library to know about, as several implementations are provided - # which cover a wide variety of situations in which consumers may - # use the library. - # - # The Consumer class has methods corresponding to the actions - # necessary in each of steps 2, 3, and 4 described in the overview. - # Use of this library should be as easy as creating an Consumer - # instance and calling the methods appropriate for the action the - # site wants to take. - # - # This library automatically detects which version of the OpenID - # protocol should be used for a transaction and constructs the - # proper requests and responses. Users of this library do not need - # to worry about supporting multiple protocol versions; the library - # supports them implicitly. Depending on the version of the - # protocol in use, the OpenID transaction may be more secure. See - # the OpenID specifications for more information. - # - # = SESSIONS, STORES, AND STATELESS MODE - # - # The Consumer object keeps track of two types of state: - # - # 1. State of the user's current authentication attempt. Things - # like the identity URL, the list of endpoints discovered for - # that URL, and in case where some endpoints are unreachable, the - # list of endpoints already tried. This state needs to be held - # from Consumer.begin() to Consumer.complete(), but it is only - # applicable to a single session with a single user agent, and at - # the end of the authentication process (i.e. when an OP replies - # with either id_res. or cancel it may be - # discarded. - # - # 2. State of relationships with servers, i.e. shared secrets - # (associations) with servers and nonces seen on signed messages. - # This information should persist from one session to the next - # and should not be bound to a particular user-agent. - # - # These two types of storage are reflected in the first two - # arguments of Consumer's constructor, session and - # store. session is a dict-like object and we - # hope your web framework provides you with one of these bound to - # the user agent. store is an instance of Store. - # - # Since the store does hold secrets shared between your application - # and the OpenID provider, you should be careful about how you use - # it in a shared hosting environment. If the filesystem or database - # permissions of your web host allow strangers to read from them, do - # not store your data there! If you have no safe place to store - # your data, construct your consumer with nil for the store, and it - # will operate only in stateless mode. Stateless mode may be - # slower, put more load on the OpenID provider, and trusts the - # provider to keep you safe from replay attacks. - # - # Several store implementation are provided, and the interface is - # fully documented so that custom stores can be used as well. See - # the documentation for the Consumer class for more information on - # the interface for stores. The implementations that are provided - # allow the consumer site to store the necessary data in several - # different ways, including several SQL databases and normal files - # on disk. - # - # = IMMEDIATE MODE - # - # In the flow described above, the user may need to confirm to the - # OpenID provider that it's ok to disclose his or her identity. The - # provider may draw pages asking for information from the user - # before it redirects the browser back to the consumer's site. This - # is generally transparent to the consumer site, so it is typically - # ignored as an implementation detail. - # - # There can be times, however, where the consumer site wants to get - # a response immediately. When this is the case, the consumer can - # put the library in immediate mode. In immediate mode, there is an - # extra response possible from the server, which is essentially the - # server reporting that it doesn't have enough information to answer - # the question yet. - # - # = USING THIS LIBRARY - # - # Integrating this library into an application is usually a - # relatively straightforward process. The process should basically - # follow this plan: - # - # Add an OpenID login field somewhere on your site. When an OpenID - # is entered in that field and the form is submitted, it should make - # a request to the your site which includes that OpenID URL. - # - # First, the application should instantiate a Consumer with a - # session for per-user state and store for shared state using the - # store of choice. - # - # Next, the application should call the begin method of - # Consumer instance. This method takes the OpenID URL as entered by - # the user. The begin method returns a CheckIDRequest - # object. - # - # Next, the application should call the redirect_url method on the - # CheckIDRequest object. The parameter return_to is the - # URL that the OpenID server will send the user back to after - # attempting to verify his or her identity. The realm - # parameter is the URL (or URL pattern) that identifies your web - # site to the user when he or she is authorizing it. Send a - # redirect to the resulting URL to the user's browser. - # - # That's the first half of the authentication process. The second - # half of the process is done after the user's OpenID Provider sends - # the user's browser a redirect back to your site to complete their - # login. - # - # When that happens, the user will contact your site at the URL - # given as the return_to URL to the redirect_url call made - # above. The request will have several query parameters added to - # the URL by the OpenID provider as the information necessary to - # finish the request. - # - # Get a Consumer instance with the same session and store as before - # and call its complete() method, passing in all the received query - # arguments and URL currently being handled. - # - # There are multiple possible return types possible from that - # method. These indicate the whether or not the login was - # successful, and include any additional information appropriate for - # their type. - class Consumer - attr_accessor :session_key_prefix - - # Initialize a Consumer instance. - # - # You should create a new instance of the Consumer object with - # every HTTP request that handles OpenID transactions. - # - # session: the session object to use to store request information. - # The session should behave like a hash. - # - # store: an object that implements the interface in Store. - def initialize(session, store) - @session = session - @store = store - @session_key_prefix = 'OpenID::Consumer::' - end - - # Start the OpenID authentication process. See steps 1-2 in the - # overview for the Consumer class. - # - # user_url: Identity URL given by the user. This method performs a - # textual transformation of the URL to try and make sure it is - # normalized. For example, a user_url of example.com will be - # normalized to http://example.com/ normalizing and resolving any - # redirects the server might issue. - # - # anonymous: A boolean value. Whether to make an anonymous - # request of the OpenID provider. Such a request does not ask for - # an authorization assertion for an OpenID identifier, but may be - # used with extensions to pass other data. e.g. "I don't care who - # you are, but I'd like to know your time zone." - # - # Returns a CheckIDRequest object containing the discovered - # information, with a method for building a redirect URL to the - # server, as described in step 3 of the overview. This object may - # also be used to add extension arguments to the request, using - # its add_extension_arg method. - # - # Raises DiscoveryFailure when no OpenID server can be found for - # this URL. - def begin(openid_identifier, anonymous=false) - manager = discovery_manager(openid_identifier) - service = manager.get_next_service(&method(:discover)) - - if service.nil? - raise DiscoveryFailure.new("No usable OpenID services were found "\ - "for #{openid_identifier.inspect}", nil) - else - begin_without_discovery(service, anonymous) - end - end - - # Start OpenID verification without doing OpenID server - # discovery. This method is used internally by Consumer.begin() - # after discovery is performed, and exists to provide an interface - # for library users needing to perform their own discovery. - # - # service: an OpenID service endpoint descriptor. This object and - # factories for it are found in the openid/consumer/discovery.rb - # module. - # - # Returns an OpenID authentication request object. - def begin_without_discovery(service, anonymous) - assoc = association_manager(service).get_association - checkid_request = CheckIDRequest.new(assoc, service) - checkid_request.anonymous = anonymous - - if service.compatibility_mode - rt_args = checkid_request.return_to_args - rt_args[Consumer.openid1_return_to_nonce_name] = Nonce.mk_nonce - rt_args[Consumer.openid1_return_to_claimed_id_name] = - service.claimed_id - end - - self.last_requested_endpoint = service - return checkid_request - end - - # Called to interpret the server's response to an OpenID - # request. It is called in step 4 of the flow described in the - # Consumer overview. - # - # query: A hash of the query parameters for this HTTP request. - # Note that in rails, this is not params but - # params.reject{|k,v|request.path_parameters[k]} - # because controller and action and other - # "path parameters" are included in params. - # - # current_url: Extract the URL of the current request from your - # application's web request framework and specify it here to have it - # checked against the openid.return_to value in the response. Do not - # just pass args['openid.return_to'] here; that will defeat the - # purpose of this check. (See OpenID Authentication 2.0 section 11.1.) - # - # If the return_to URL check fails, the status of the completion will be - # FAILURE. - - # - # Returns a subclass of Response. The type of response is - # indicated by the status attribute, which will be one of - # SUCCESS, CANCEL, FAILURE, or SETUP_NEEDED. - def complete(query, current_url) - message = Message.from_post_args(query) - mode = message.get_arg(OPENID_NS, 'mode', 'invalid') - begin - meth = method('complete_' + mode) - rescue NameError - meth = method(:complete_invalid) - end - response = meth.call(message, current_url) - cleanup_last_requested_endpoint - if [SUCCESS, CANCEL].member?(response.status) - cleanup_session - end - return response - end - - protected - - def session_get(name) - @session[session_key(name)] - end - - def session_set(name, val) - @session[session_key(name)] = val - end - - def session_key(suffix) - @session_key_prefix + suffix - end - - def last_requested_endpoint - session_get('last_requested_endpoint') - end - - def last_requested_endpoint=(endpoint) - session_set('last_requested_endpoint', endpoint) - end - - def cleanup_last_requested_endpoint - @session[session_key('last_requested_endpoint')] = nil - end - - def discovery_manager(openid_identifier) - DiscoveryManager.new(@session, openid_identifier, @session_key_prefix) - end - - def cleanup_session - discovery_manager(nil).cleanup(true) - end - - - def discover(identifier) - OpenID.discover(identifier) - end - - def negotiator - DefaultNegotiator - end - - def association_manager(service) - AssociationManager.new(@store, service.server_url, - service.compatibility_mode, negotiator) - end - - def handle_idres(message, current_url) - IdResHandler.new(message, current_url, @store, last_requested_endpoint) - end - - def complete_invalid(message, unused_return_to) - mode = message.get_arg(OPENID_NS, 'mode', '') - return FailureResponse.new(last_requested_endpoint, - "Invalid openid.mode: #{mode}") - end - - def complete_cancel(unused_message, unused_return_to) - return CancelResponse.new(last_requested_endpoint) - end - - def complete_error(message, unused_return_to) - error = message.get_arg(OPENID_NS, 'error') - contact = message.get_arg(OPENID_NS, 'contact') - reference = message.get_arg(OPENID_NS, 'reference') - - return FailureResponse.new(last_requested_endpoint, - error, contact, reference) - end - - def complete_setup_needed(message, unused_return_to) - if message.is_openid1 - return complete_invalid(message, nil) - else - return SetupNeededResponse.new(last_requested_endpoint, nil) - end - end - - def complete_id_res(message, current_url) - if message.is_openid1 - setup_url = message.get_arg(OPENID1_NS, 'user_setup_url') - if !setup_url.nil? - return SetupNeededResponse.new(last_requested_endpoint, setup_url) - end - end - - begin - idres = handle_idres(message, current_url) - rescue OpenIDError => why - return FailureResponse.new(last_requested_endpoint, why.message) - else - return SuccessResponse.new(idres.endpoint, message, - idres.signed_fields) - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/associationmanager.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/associationmanager.rb deleted file mode 100644 index 51c0f3d2..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/associationmanager.rb +++ /dev/null @@ -1,340 +0,0 @@ -require "openid/dh" -require "openid/util" -require "openid/kvpost" -require "openid/cryptutil" -require "openid/protocolerror" -require "openid/association" - -module OpenID - class Consumer - - # A superclass for implementing Diffie-Hellman association sessions. - class DiffieHellmanSession - class << self - attr_reader :session_type, :secret_size, :allowed_assoc_types, - :hashfunc - end - - def initialize(dh=nil) - if dh.nil? - dh = DiffieHellman.from_defaults - end - @dh = dh - end - - # Return the query parameters for requesting an association - # using this Diffie-Hellman association session - def get_request - args = {'dh_consumer_public' => CryptUtil.num_to_base64(@dh.public)} - if (!@dh.using_default_values?) - args['dh_modulus'] = CryptUtil.num_to_base64(@dh.modulus) - args['dh_gen'] = CryptUtil.num_to_base64(@dh.generator) - end - - return args - end - - # Process the response from a successful association request and - # return the shared secret for this association - def extract_secret(response) - dh_server_public64 = response.get_arg(OPENID_NS, 'dh_server_public', - NO_DEFAULT) - enc_mac_key64 = response.get_arg(OPENID_NS, 'enc_mac_key', NO_DEFAULT) - dh_server_public = CryptUtil.base64_to_num(dh_server_public64) - enc_mac_key = Util.from_base64(enc_mac_key64) - return @dh.xor_secret(self.class.hashfunc, - dh_server_public, enc_mac_key) - end - end - - # A Diffie-Hellman association session that uses SHA1 as its hash - # function - class DiffieHellmanSHA1Session < DiffieHellmanSession - @session_type = 'DH-SHA1' - @secret_size = 20 - @allowed_assoc_types = ['HMAC-SHA1'] - @hashfunc = CryptUtil.method(:sha1) - end - - # A Diffie-Hellman association session that uses SHA256 as its hash - # function - class DiffieHellmanSHA256Session < DiffieHellmanSession - @session_type = 'DH-SHA256' - @secret_size = 32 - @allowed_assoc_types = ['HMAC-SHA256'] - @hashfunc = CryptUtil.method(:sha256) - end - - # An association session that does not use encryption - class NoEncryptionSession - class << self - attr_reader :session_type, :allowed_assoc_types - end - @session_type = 'no-encryption' - @allowed_assoc_types = ['HMAC-SHA1', 'HMAC-SHA256'] - - def get_request - return {} - end - - def extract_secret(response) - mac_key64 = response.get_arg(OPENID_NS, 'mac_key', NO_DEFAULT) - return Util.from_base64(mac_key64) - end - end - - # An object that manages creating and storing associations for an - # OpenID provider endpoint - class AssociationManager - def self.create_session(session_type) - case session_type - when 'no-encryption' - NoEncryptionSession.new - when 'DH-SHA1' - DiffieHellmanSHA1Session.new - when 'DH-SHA256' - DiffieHellmanSHA256Session.new - else - raise ArgumentError, "Unknown association session type: "\ - "#{session_type.inspect}" - end - end - - def initialize(store, server_url, compatibility_mode=false, - negotiator=nil) - @store = store - @server_url = server_url - @compatibility_mode = compatibility_mode - @negotiator = negotiator || DefaultNegotiator - end - - def get_association - if @store.nil? - return nil - end - - assoc = @store.get_association(@server_url) - if assoc.nil? || assoc.expires_in <= 0 - assoc = negotiate_association - if !assoc.nil? - @store.store_association(@server_url, assoc) - end - end - - return assoc - end - - def negotiate_association - assoc_type, session_type = @negotiator.get_allowed_type - begin - return request_association(assoc_type, session_type) - rescue ServerError => why - supported_types = extract_supported_association_type(why, assoc_type) - if !supported_types.nil? - # Attempt to create an association from the assoc_type and - # session_type that the server told us it supported. - assoc_type, session_type = supported_types - begin - return request_association(assoc_type, session_type) - rescue ServerError => why - Util.log("Server #{@server_url} refused its suggested " \ - "association type: session_type=#{session_type}, " \ - "assoc_type=#{assoc_type}") - return nil - end - end - end - end - - protected - def extract_supported_association_type(server_error, assoc_type) - # Any error message whose code is not 'unsupported-type' should - # be considered a total failure. - if (server_error.error_code != 'unsupported-type' or - server_error.message.is_openid1) - Util.log("Server error when requesting an association from "\ - "#{@server_url}: #{server_error.error_text}") - return nil - end - - # The server didn't like the association/session type that we - # sent, and it sent us back a message that might tell us how to - # handle it. - Util.log("Unsupported association type #{assoc_type}: "\ - "#{server_error.error_text}") - - # Extract the session_type and assoc_type from the error message - assoc_type = server_error.message.get_arg(OPENID_NS, 'assoc_type') - session_type = server_error.message.get_arg(OPENID_NS, 'session_type') - - if assoc_type.nil? or session_type.nil? - Util.log("Server #{@server_url} responded with unsupported "\ - "association session but did not supply a fallback.") - return nil - elsif !@negotiator.allowed?(assoc_type, session_type) - Util.log("Server sent unsupported session/association type: "\ - "session_type=#{session_type}, assoc_type=#{assoc_type}") - return nil - else - return [assoc_type, session_type] - end - end - - # Make and process one association request to this endpoint's OP - # endpoint URL. Returns an association object or nil if the - # association processing failed. Raises ServerError when the - # remote OpenID server returns an error. - def request_association(assoc_type, session_type) - assoc_session, args = create_associate_request(assoc_type, session_type) - - begin - response = OpenID.make_kv_post(args, @server_url) - return extract_association(response, assoc_session) - rescue HTTPStatusError => why - Util.log("Got HTTP status error when requesting association: #{why}") - return nil - rescue Message::KeyNotFound => why - Util.log("Missing required parameter in response from "\ - "#{@server_url}: #{why}") - return nil - - rescue ProtocolError => why - Util.log("Protocol error processing response from #{@server_url}: "\ - "#{why}") - return nil - end - end - - # Create an association request for the given assoc_type and - # session_type. Returns a pair of the association session object - # and the request message that will be sent to the server. - def create_associate_request(assoc_type, session_type) - assoc_session = self.class.create_session(session_type) - args = { - 'mode' => 'associate', - 'assoc_type' => assoc_type, - } - - if !@compatibility_mode - args['ns'] = OPENID2_NS - end - - # Leave out the session type if we're in compatibility mode - # *and* it's no-encryption. - if !@compatibility_mode || - assoc_session.class.session_type != 'no-encryption' - args['session_type'] = assoc_session.class.session_type - end - - args.merge!(assoc_session.get_request) - message = Message.from_openid_args(args) - return assoc_session, message - end - - # Given an association response message, extract the OpenID 1.X - # session type. Returns the association type for this message - # - # This function mostly takes care of the 'no-encryption' default - # behavior in OpenID 1. - # - # If the association type is plain-text, this function will - # return 'no-encryption' - def get_openid1_session_type(assoc_response) - # If it's an OpenID 1 message, allow session_type to default - # to nil (which signifies "no-encryption") - session_type = assoc_response.get_arg(OPENID1_NS, 'session_type') - - # Handle the differences between no-encryption association - # respones in OpenID 1 and 2: - - # no-encryption is not really a valid session type for - # OpenID 1, but we'll accept it anyway, while issuing a - # warning. - if session_type == 'no-encryption' - Util.log("WARNING: #{@server_url} sent 'no-encryption'"\ - "for OpenID 1.X") - - # Missing or empty session type is the way to flag a - # 'no-encryption' response. Change the session type to - # 'no-encryption' so that it can be handled in the same - # way as OpenID 2 'no-encryption' respones. - elsif session_type == '' || session_type.nil? - session_type = 'no-encryption' - end - - return session_type - end - - def self.extract_expires_in(message) - # expires_in should be a base-10 string. - expires_in_str = message.get_arg(OPENID_NS, 'expires_in', NO_DEFAULT) - if !(/\A\d+\Z/ =~ expires_in_str) - raise ProtocolError, "Invalid expires_in field: #{expires_in_str}" - end - expires_in_str.to_i - end - - # Attempt to extract an association from the response, given the - # association response message and the established association - # session. - def extract_association(assoc_response, assoc_session) - # Extract the common fields from the response, raising an - # exception if they are not found - assoc_type = assoc_response.get_arg(OPENID_NS, 'assoc_type', - NO_DEFAULT) - assoc_handle = assoc_response.get_arg(OPENID_NS, 'assoc_handle', - NO_DEFAULT) - expires_in = self.class.extract_expires_in(assoc_response) - - # OpenID 1 has funny association session behaviour. - if assoc_response.is_openid1 - session_type = get_openid1_session_type(assoc_response) - else - session_type = assoc_response.get_arg(OPENID2_NS, 'session_type', - NO_DEFAULT) - end - - # Session type mismatch - if assoc_session.class.session_type != session_type - if (assoc_response.is_openid1 and session_type == 'no-encryption') - # In OpenID 1, any association request can result in a - # 'no-encryption' association response. Setting - # assoc_session to a new no-encryption session should - # make the rest of this function work properly for - # that case. - assoc_session = NoEncryptionSession.new - else - # Any other mismatch, regardless of protocol version - # results in the failure of the association session - # altogether. - raise ProtocolError, "Session type mismatch. Expected "\ - "#{assoc_session.class.session_type}, got "\ - "#{session_type}" - end - end - - # Make sure assoc_type is valid for session_type - if !assoc_session.class.allowed_assoc_types.member?(assoc_type) - raise ProtocolError, "Unsupported assoc_type for session "\ - "#{assoc_session.class.session_type} "\ - "returned: #{assoc_type}" - end - - # Delegate to the association session to extract the secret - # from the response, however is appropriate for that session - # type. - begin - secret = assoc_session.extract_secret(assoc_response) - rescue Message::KeyNotFound, ArgumentError => why - raise ProtocolError, "Malformed response for "\ - "#{assoc_session.class.session_type} "\ - "session: #{why.message}" - end - - - return Association.from_expires_in(expires_in, assoc_handle, secret, - assoc_type) - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/checkid_request.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/checkid_request.rb deleted file mode 100644 index eb5d3979..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/checkid_request.rb +++ /dev/null @@ -1,186 +0,0 @@ -require "openid/message" -require "openid/util" - -module OpenID - class Consumer - # An object that holds the state necessary for generating an - # OpenID authentication request. This object holds the association - # with the server and the discovered information with which the - # request will be made. - # - # It is separate from the consumer because you may wish to add - # things to the request before sending it on its way to the - # server. It also has serialization options that let you encode - # the authentication request as a URL or as a form POST. - class CheckIDRequest - attr_accessor :return_to_args, :message - attr_reader :endpoint - - # Users of this library should not create instances of this - # class. Instances of this class are created by the library - # when needed. - def initialize(assoc, endpoint) - @assoc = assoc - @endpoint = endpoint - @return_to_args = {} - @message = Message.new(endpoint.preferred_namespace) - @anonymous = false - end - - attr_reader :anonymous - - # Set whether this request should be made anonymously. If a - # request is anonymous, the identifier will not be sent in the - # request. This is only useful if you are making another kind of - # request with an extension in this request. - # - # Anonymous requests are not allowed when the request is made - # with OpenID 1. - def anonymous=(is_anonymous) - if is_anonymous && @message.is_openid1 - raise ArgumentError, ("OpenID1 requests MUST include the "\ - "identifier in the request") - end - @anonymous = is_anonymous - end - - # Add an object that implements the extension interface for - # adding arguments to an OpenID message to this checkid request. - # - # extension_request: an OpenID::Extension object. - def add_extension(extension_request) - extension_request.to_message(@message) - end - - # Add an extension argument to this OpenID authentication - # request. You probably want to use add_extension and the - # OpenID::Extension interface. - # - # Use caution when adding arguments, because they will be - # URL-escaped and appended to the redirect URL, which can easily - # get quite long. - def add_extension_arg(namespace, key, value) - @message.set_arg(namespace, key, value) - end - - # Produce a OpenID::Message representing this request. - # - # Not specifying a return_to URL means that the user will not be - # returned to the site issuing the request upon its completion. - # - # If immediate mode is requested, the OpenID provider is to send - # back a response immediately, useful for behind-the-scenes - # authentication attempts. Otherwise the OpenID provider may - # engage the user before providing a response. This is the - # default case, as the user may need to provide credentials or - # approve the request before a positive response can be sent. - def get_message(realm, return_to=nil, immediate=false) - if !return_to.nil? - return_to = Util.append_args(return_to, @return_to_args) - elsif immediate - raise ArgumentError, ('"return_to" is mandatory when using '\ - '"checkid_immediate"') - elsif @message.is_openid1 - raise ArgumentError, ('"return_to" is mandatory for OpenID 1 '\ - 'requests') - elsif @return_to_args.empty? - raise ArgumentError, ('extra "return_to" arguments were specified, '\ - 'but no return_to was specified') - end - - - message = @message.copy - - mode = immediate ? 'checkid_immediate' : 'checkid_setup' - message.set_arg(OPENID_NS, 'mode', mode) - - realm_key = message.is_openid1 ? 'trust_root' : 'realm' - message.set_arg(OPENID_NS, realm_key, realm) - - if !return_to.nil? - message.set_arg(OPENID_NS, 'return_to', return_to) - end - - if not @anonymous - if @endpoint.is_op_identifier - # This will never happen when we're in OpenID 1 - # compatibility mode, as long as is_op_identifier() - # returns false whenever preferred_namespace returns - # OPENID1_NS. - claimed_id = request_identity = IDENTIFIER_SELECT - else - request_identity = @endpoint.get_local_id - claimed_id = @endpoint.claimed_id - end - - # This is true for both OpenID 1 and 2 - message.set_arg(OPENID_NS, 'identity', request_identity) - - if message.is_openid2 - message.set_arg(OPENID2_NS, 'claimed_id', claimed_id) - end - end - - if @assoc - message.set_arg(OPENID_NS, 'assoc_handle', @assoc.handle) - assoc_log_msg = "with assocication #{@assoc.handle}" - else - assoc_log_msg = 'using stateless mode.' - end - - Util.log("Generated #{mode} request to #{@endpoint.server_url} "\ - "#{assoc_log_msg}") - return message - end - - # Returns a URL with an encoded OpenID request. - # - # The resulting URL is the OpenID provider's endpoint URL with - # parameters appended as query arguments. You should redirect - # the user agent to this URL. - # - # OpenID 2.0 endpoints also accept POST requests, see - # 'send_redirect?' and 'form_markup'. - def redirect_url(realm, return_to=nil, immediate=false) - message = get_message(realm, return_to, immediate) - return message.to_url(@endpoint.server_url) - end - - # Get html for a form to submit this request to the IDP. - # - # form_tag_attrs is a hash of attributes to be added to the form - # tag. 'accept-charset' and 'enctype' have defaults that can be - # overridden. If a value is supplied for 'action' or 'method', - # it will be replaced. - def form_markup(realm, return_to=nil, immediate=false, - form_tag_attrs=nil) - message = get_message(realm, return_to, immediate) - return message.to_form_markup(@endpoint.server_url, form_tag_attrs) - end - - # Get a complete HTML document that autosubmits the request to the IDP - # with javascript. This method wraps form_markup - see that method's - # documentation for help with the parameters. - def html_markup(realm, return_to=nil, immediate=false, - form_tag_attrs=nil) - Util.auto_submit_html(form_markup(realm, - return_to, - immediate, - form_tag_attrs)) - end - - # Should this OpenID authentication request be sent as a HTTP - # redirect or as a POST (form submission)? - # - # This takes the same parameters as redirect_url or form_markup - def send_redirect?(realm, return_to=nil, immediate=false) - if @endpoint.compatibility_mode - return true - else - url = redirect_url(realm, return_to, immediate) - return url.length <= OPENID1_URL_LIMIT - end - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/discovery.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/discovery.rb deleted file mode 100644 index 986b476f..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/discovery.rb +++ /dev/null @@ -1,490 +0,0 @@ -# Functions to discover OpenID endpoints from identifiers. - -require 'uri' -require 'openid/util' -require 'openid/fetchers' -require 'openid/urinorm' -require 'openid/message' -require 'openid/yadis/discovery' -require 'openid/yadis/xrds' -require 'openid/yadis/xri' -require 'openid/yadis/services' -require 'openid/yadis/filters' -require 'openid/consumer/html_parse' -require 'openid/yadis/xrires' - -module OpenID - - OPENID_1_0_NS = 'http://openid.net/xmlns/1.0' - OPENID_IDP_2_0_TYPE = 'http://specs.openid.net/auth/2.0/server' - OPENID_2_0_TYPE = 'http://specs.openid.net/auth/2.0/signon' - OPENID_1_1_TYPE = 'http://openid.net/signon/1.1' - OPENID_1_0_TYPE = 'http://openid.net/signon/1.0' - - OPENID_1_0_MESSAGE_NS = OPENID1_NS - OPENID_2_0_MESSAGE_NS = OPENID2_NS - - # Object representing an OpenID service endpoint. - class OpenIDServiceEndpoint - - # OpenID service type URIs, listed in order of preference. The - # ordering of this list affects yadis and XRI service discovery. - OPENID_TYPE_URIS = [ - OPENID_IDP_2_0_TYPE, - - OPENID_2_0_TYPE, - OPENID_1_1_TYPE, - OPENID_1_0_TYPE, - ] - - # the verified identifier. - attr_accessor :claimed_id - - # For XRI, the persistent identifier. - attr_accessor :canonical_id - - attr_accessor :server_url, :type_uris, :local_id, :used_yadis - - def initialize - @claimed_id = nil - @server_url = nil - @type_uris = [] - @local_id = nil - @canonical_id = nil - @used_yadis = false # whether this came from an XRDS - @display_identifier = nil - end - - def display_identifier - return @display_identifier if @display_identifier - - return @claimed_id if @claimed_id.nil? - - begin - parsed_identifier = URI.parse(@claimed_id) - rescue URI::InvalidURIError - raise ProtocolError, "Claimed identifier #{claimed_id} is not a valid URI" - end - - return @claimed_id if not parsed_identifier.fragment - - disp = parsed_identifier - disp.fragment = nil - - return disp.to_s - end - - def display_identifier=(display_identifier) - @display_identifier = display_identifier - end - - def uses_extension(extension_uri) - return @type_uris.member?(extension_uri) - end - - def preferred_namespace - if (@type_uris.member?(OPENID_IDP_2_0_TYPE) or - @type_uris.member?(OPENID_2_0_TYPE)) - return OPENID_2_0_MESSAGE_NS - else - return OPENID_1_0_MESSAGE_NS - end - end - - def supports_type(type_uri) - # Does this endpoint support this type? - # - # I consider C{/server} endpoints to implicitly support C{/signon}. - ( - @type_uris.member?(type_uri) or - (type_uri == OPENID_2_0_TYPE and is_op_identifier()) - ) - end - - def compatibility_mode - return preferred_namespace() != OPENID_2_0_MESSAGE_NS - end - - def is_op_identifier - return @type_uris.member?(OPENID_IDP_2_0_TYPE) - end - - def parse_service(yadis_url, uri, type_uris, service_element) - # Set the state of this object based on the contents of the - # service element. - @type_uris = type_uris - @server_url = uri - @used_yadis = true - - if !is_op_identifier() - # XXX: This has crappy implications for Service elements that - # contain both 'server' and 'signon' Types. But that's a - # pathological configuration anyway, so I don't think I care. - @local_id = OpenID.find_op_local_identifier(service_element, - @type_uris) - @claimed_id = yadis_url - end - end - - def get_local_id - # Return the identifier that should be sent as the - # openid.identity parameter to the server. - if @local_id.nil? and @canonical_id.nil? - return @claimed_id - else - return (@local_id or @canonical_id) - end - end - - def self.from_basic_service_endpoint(endpoint) - # Create a new instance of this class from the endpoint object - # passed in. - # - # @return: nil or OpenIDServiceEndpoint for this endpoint object""" - - type_uris = endpoint.match_types(OPENID_TYPE_URIS) - - # If any Type URIs match and there is an endpoint URI specified, - # then this is an OpenID endpoint - if (!type_uris.nil? and !type_uris.empty?) and !endpoint.uri.nil? - openid_endpoint = self.new - openid_endpoint.parse_service( - endpoint.yadis_url, - endpoint.uri, - endpoint.type_uris, - endpoint.service_element) - else - openid_endpoint = nil - end - - return openid_endpoint - end - - def self.from_html(uri, html) - # Parse the given document as HTML looking for an OpenID - # - # @rtype: [OpenIDServiceEndpoint] - - discovery_types = [ - [OPENID_2_0_TYPE, 'openid2.provider', 'openid2.local_id'], - [OPENID_1_1_TYPE, 'openid.server', 'openid.delegate'], - ] - - link_attrs = OpenID.parse_link_attrs(html) - services = [] - discovery_types.each { |type_uri, op_endpoint_rel, local_id_rel| - - op_endpoint_url = OpenID.find_first_href(link_attrs, op_endpoint_rel) - - if !op_endpoint_url - next - end - - service = self.new - service.claimed_id = uri - service.local_id = OpenID.find_first_href(link_attrs, local_id_rel) - service.server_url = op_endpoint_url - service.type_uris = [type_uri] - - services << service - } - - return services - end - - def self.from_xrds(uri, xrds) - # Parse the given document as XRDS looking for OpenID services. - # - # @rtype: [OpenIDServiceEndpoint] - # - # @raises L{XRDSError}: When the XRDS does not parse. - return Yadis::apply_filter(uri, xrds, self) - end - - def self.from_discovery_result(discoveryResult) - # Create endpoints from a DiscoveryResult. - # - # @type discoveryResult: L{DiscoveryResult} - # - # @rtype: list of L{OpenIDServiceEndpoint} - # - # @raises L{XRDSError}: When the XRDS does not parse. - if discoveryResult.is_xrds() - meth = self.method('from_xrds') - else - meth = self.method('from_html') - end - - return meth.call(discoveryResult.normalized_uri, - discoveryResult.response_text) - end - - def self.from_op_endpoint_url(op_endpoint_url) - # Construct an OP-Identifier OpenIDServiceEndpoint object for - # a given OP Endpoint URL - # - # @param op_endpoint_url: The URL of the endpoint - # @rtype: OpenIDServiceEndpoint - service = self.new - service.server_url = op_endpoint_url - service.type_uris = [OPENID_IDP_2_0_TYPE] - return service - end - - def to_s - return sprintf("<%s server_url=%s claimed_id=%s " + - "local_id=%s canonical_id=%s used_yadis=%s>", - self.class, @server_url, @claimed_id, - @local_id, @canonical_id, @used_yadis) - end - end - - def self.find_op_local_identifier(service_element, type_uris) - # Find the OP-Local Identifier for this xrd:Service element. - # - # This considers openid:Delegate to be a synonym for xrd:LocalID - # if both OpenID 1.X and OpenID 2.0 types are present. If only - # OpenID 1.X is present, it returns the value of - # openid:Delegate. If only OpenID 2.0 is present, it returns the - # value of xrd:LocalID. If there is more than one LocalID tag and - # the values are different, it raises a DiscoveryFailure. This is - # also triggered when the xrd:LocalID and openid:Delegate tags are - # different. - - # XXX: Test this function on its own! - - # Build the list of tags that could contain the OP-Local - # Identifier - local_id_tags = [] - if type_uris.member?(OPENID_1_1_TYPE) or - type_uris.member?(OPENID_1_0_TYPE) - # local_id_tags << Yadis::nsTag(OPENID_1_0_NS, 'openid', 'Delegate') - service_element.add_namespace('openid', OPENID_1_0_NS) - local_id_tags << "openid:Delegate" - end - - if type_uris.member?(OPENID_2_0_TYPE) - # local_id_tags.append(Yadis::nsTag(XRD_NS_2_0, 'xrd', 'LocalID')) - service_element.add_namespace('xrd', Yadis::XRD_NS_2_0) - local_id_tags << "xrd:LocalID" - end - - # Walk through all the matching tags and make sure that they all - # have the same value - local_id = nil - local_id_tags.each { |local_id_tag| - service_element.each_element(local_id_tag) { |local_id_element| - if local_id.nil? - local_id = local_id_element.text - elsif local_id != local_id_element.text - format = 'More than one %s tag found in one service element' - message = sprintf(format, local_id_tag) - raise DiscoveryFailure.new(message, nil) - end - } - } - - return local_id - end - - def self.normalize_url(url) - # Normalize a URL, converting normalization failures to - # DiscoveryFailure - begin - normalized = URINorm.urinorm(url) - rescue URI::Error => why - raise DiscoveryFailure.new("Error normalizing #{url}: #{why.message}", nil) - else - defragged = URI::parse(normalized) - defragged.fragment = nil - return defragged.normalize.to_s - end - end - - def self.best_matching_service(service, preferred_types) - # Return the index of the first matching type, or something higher - # if no type matches. - # - # This provides an ordering in which service elements that contain - # a type that comes earlier in the preferred types list come - # before service elements that come later. If a service element - # has more than one type, the most preferred one wins. - preferred_types.each_with_index { |value, index| - if service.type_uris.member?(value) - return index - end - } - - return preferred_types.length - end - - def self.arrange_by_type(service_list, preferred_types) - # Rearrange service_list in a new list so services are ordered by - # types listed in preferred_types. Return the new list. - - # Build a list with the service elements in tuples whose - # comparison will prefer the one with the best matching service - prio_services = [] - - service_list.each_with_index { |s, index| - prio_services << [best_matching_service(s, preferred_types), index, s] - } - - prio_services.sort! - - # Now that the services are sorted by priority, remove the sort - # keys from the list. - (0...prio_services.length).each { |i| - prio_services[i] = prio_services[i][2] - } - - return prio_services - end - - def self.get_op_or_user_services(openid_services) - # Extract OP Identifier services. If none found, return the rest, - # sorted with most preferred first according to - # OpenIDServiceEndpoint.openid_type_uris. - # - # openid_services is a list of OpenIDServiceEndpoint objects. - # - # Returns a list of OpenIDServiceEndpoint objects. - - op_services = arrange_by_type(openid_services, [OPENID_IDP_2_0_TYPE]) - - openid_services = arrange_by_type(openid_services, - OpenIDServiceEndpoint::OPENID_TYPE_URIS) - - if !op_services.empty? - return op_services - else - return openid_services - end - end - - def self.discover_yadis(uri) - # Discover OpenID services for a URI. Tries Yadis and falls back - # on old-style discovery if Yadis fails. - # - # @param uri: normalized identity URL - # @type uri: str - # - # @return: (claimed_id, services) - # @rtype: (str, list(OpenIDServiceEndpoint)) - # - # @raises DiscoveryFailure: when discovery fails. - - # Might raise a yadis.discover.DiscoveryFailure if no document - # came back for that URI at all. I don't think falling back to - # OpenID 1.0 discovery on the same URL will help, so don't bother - # to catch it. - response = Yadis.discover(uri) - - yadis_url = response.normalized_uri - body = response.response_text - - begin - openid_services = OpenIDServiceEndpoint.from_xrds(yadis_url, body) - rescue Yadis::XRDSError - # Does not parse as a Yadis XRDS file - openid_services = [] - end - - if openid_services.empty? - # Either not an XRDS or there are no OpenID services. - - if response.is_xrds - # if we got the Yadis content-type or followed the Yadis - # header, re-fetch the document without following the Yadis - # header, with no Accept header. - return self.discover_no_yadis(uri) - end - - # Try to parse the response as HTML. - # - openid_services = OpenIDServiceEndpoint.from_html(yadis_url, body) - end - - return [yadis_url, self.get_op_or_user_services(openid_services)] - end - - def self.discover_xri(iname) - endpoints = [] - - begin - canonical_id, services = Yadis::XRI::ProxyResolver.new().query( - iname, OpenIDServiceEndpoint::OPENID_TYPE_URIS) - - if canonical_id.nil? - raise Yadis::XRDSError.new(sprintf('No CanonicalID found for XRI %s', iname)) - end - - flt = Yadis.make_filter(OpenIDServiceEndpoint) - - services.each { |service_element| - endpoints += flt.get_service_endpoints(iname, service_element) - } - rescue Yadis::XRDSError => why - Util.log('xrds error on ' + iname + ': ' + why.to_s) - end - - endpoints.each { |endpoint| - # Is there a way to pass this through the filter to the endpoint - # constructor instead of tacking it on after? - endpoint.canonical_id = canonical_id - endpoint.claimed_id = canonical_id - endpoint.display_identifier = iname - } - - # FIXME: returned xri should probably be in some normal form - return [iname, self.get_op_or_user_services(endpoints)] - end - - def self.discover_no_yadis(uri) - http_resp = OpenID.fetch(uri) - if http_resp.code != "200" and http_resp.code != "206" - raise DiscoveryFailure.new( - "HTTP Response status from identity URL host is not \"200\". "\ - "Got status #{http_resp.code.inspect}", http_resp) - end - - claimed_id = http_resp.final_url - openid_services = OpenIDServiceEndpoint.from_html( - claimed_id, http_resp.body) - return [claimed_id, openid_services] - end - - def self.discover_uri(uri) - # Hack to work around URI parsing for URls with *no* scheme. - if uri.index("://").nil? - uri = 'http://' + uri - end - - begin - parsed = URI::parse(uri) - rescue URI::InvalidURIError => why - raise DiscoveryFailure.new("URI is not valid: #{why.message}", nil) - end - - if !parsed.scheme.nil? and !parsed.scheme.empty? - if !['http', 'https'].member?(parsed.scheme) - raise DiscoveryFailure.new( - "URI scheme #{parsed.scheme} is not HTTP or HTTPS", nil) - end - end - - uri = self.normalize_url(uri) - claimed_id, openid_services = self.discover_yadis(uri) - claimed_id = self.normalize_url(claimed_id) - return [claimed_id, openid_services] - end - - def self.discover(identifier) - if Yadis::XRI::identifier_scheme(identifier) == :xri - normalized_identifier, services = discover_xri(identifier) - else - return discover_uri(identifier) - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/discovery_manager.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/discovery_manager.rb deleted file mode 100644 index 8f838117..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/discovery_manager.rb +++ /dev/null @@ -1,123 +0,0 @@ -module OpenID - class Consumer - - # A set of discovered services, for tracking which providers have - # been attempted for an OpenID identifier - class DiscoveredServices - attr_reader :current - - def initialize(starting_url, yadis_url, services) - @starting_url = starting_url - @yadis_url = yadis_url - @services = services.dup - @current = nil - end - - def next - @current = @services.shift - end - - def for_url?(url) - [@starting_url, @yadis_url].member?(url) - end - - def started? - !@current.nil? - end - - def empty? - @services.empty? - end - end - - # Manages calling discovery and tracking which endpoints have - # already been attempted. - class DiscoveryManager - def initialize(session, url, session_key_suffix=nil) - @url = url - - @session = session - @session_key_suffix = session_key_suffix || 'auth' - end - - def get_next_service - manager = get_manager - if !manager.nil? && manager.empty? - destroy_manager - manager = nil - end - - if manager.nil? - yadis_url, services = yield @url - manager = create_manager(yadis_url, services) - end - - if !manager.nil? - service = manager.next - store(manager) - else - service = nil - end - - return service - end - - def cleanup(force=false) - manager = get_manager(force) - if !manager.nil? - service = manager.current - destroy_manager(force) - else - service = nil - end - return service - end - - protected - - def get_manager(force=false) - manager = load - if force || manager.nil? || manager.for_url?(@url) - return manager - else - return nil - end - end - - def create_manager(yadis_url, services) - manager = get_manager - if !manager.nil? - raise StandardError, "There is already a manager for #{yadis_url}" - end - if services.empty? - return nil - end - manager = DiscoveredServices.new(@url, yadis_url, services) - store(manager) - return manager - end - - def destroy_manager(force=false) - if !get_manager(force).nil? - destroy! - end - end - - def session_key - 'OpenID::Consumer::DiscoveredServices::' + @session_key_suffix - end - - def store(manager) - @session[session_key] = manager - end - - def load - @session[session_key] - end - - def destroy! - @session[session_key] = nil - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/html_parse.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/html_parse.rb deleted file mode 100644 index 579874ca..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/html_parse.rb +++ /dev/null @@ -1,134 +0,0 @@ -require "openid/yadis/htmltokenizer" - -module OpenID - - # Stuff to remove before we start looking for tags - REMOVED_RE = / - # Comments - - - # CDATA blocks - | - - # script blocks - | ]*>.*?<\/script> - - /mixu - - def OpenID.openid_unescape(s) - s.gsub('&','&').gsub('<','<').gsub('>','>').gsub('"','"') - end - - def OpenID.unescape_hash(h) - newh = {} - h.map{|k,v| - newh[k]=openid_unescape(v) - } - newh - end - - - def OpenID.parse_link_attrs(html) - stripped = html.gsub(REMOVED_RE,'') - parser = HTMLTokenizer.new(stripped) - - links = [] - # to keep track of whether or not we are in the head element - in_head = false - in_html = false - saw_head = false - - begin - while el = parser.getTag('head', '/head', 'link', 'body', '/body', - 'html', '/html') - - # we are leaving head or have reached body, so we bail - return links if ['/head', 'body', '/body', '/html'].member?(el.tag_name) - - # enforce html > head > link - if el.tag_name == 'html' - in_html = true - end - next unless in_html - if el.tag_name == 'head' - if saw_head - return links #only allow one head - end - saw_head = true - unless el.to_s[-2] == 47 # tag ends with a /: a short tag - in_head = true - end - end - next unless in_head - - return links if el.tag_name == 'html' - - if el.tag_name == 'link' - links << unescape_hash(el.attr_hash) - end - - end - rescue Exception # just stop parsing if there's an error - end - return links - end - - def OpenID.rel_matches(rel_attr, target_rel) - # Does this target_rel appear in the rel_str? - # XXX: TESTME - rels = rel_attr.strip().split() - rels.each { |rel| - rel = rel.downcase - if rel == target_rel - return true - end - } - - return false - end - - def OpenID.link_has_rel(link_attrs, target_rel) - # Does this link have target_rel as a relationship? - - # XXX: TESTME - rel_attr = link_attrs['rel'] - return (rel_attr and rel_matches(rel_attr, target_rel)) - end - - def OpenID.find_links_rel(link_attrs_list, target_rel) - # Filter the list of link attributes on whether it has target_rel - # as a relationship. - - # XXX: TESTME - matchesTarget = lambda { |attrs| link_has_rel(attrs, target_rel) } - result = [] - - link_attrs_list.each { |item| - if matchesTarget.call(item) - result << item - end - } - - return result - end - - def OpenID.find_first_href(link_attrs_list, target_rel) - # Return the value of the href attribute for the first link tag in - # the list that has target_rel as a relationship. - - # XXX: TESTME - matches = find_links_rel(link_attrs_list, target_rel) - if !matches or matches.empty? - return nil - end - - first = matches[0] - return first['href'] - end -end - diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/idres.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/idres.rb deleted file mode 100644 index ab924e29..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/idres.rb +++ /dev/null @@ -1,523 +0,0 @@ -require "openid/message" -require "openid/protocolerror" -require "openid/kvpost" -require "openid/consumer/discovery" -require "openid/urinorm" - -module OpenID - class TypeURIMismatch < ProtocolError - attr_reader :type_uri, :endpoint - - def initialize(type_uri, endpoint) - @type_uri = type_uri - @endpoint = endpoint - end - end - - class Consumer - @openid1_return_to_nonce_name = 'rp_nonce' - @openid1_return_to_claimed_id_name = 'openid1_claimed_id' - - # Set the name of the query parameter that this library will use - # to thread a nonce through an OpenID 1 transaction. It will be - # appended to the return_to URL. - def self.openid1_return_to_nonce_name=(query_arg_name) - @openid1_return_to_nonce_name = query_arg_name - end - - # See openid1_return_to_nonce_name= documentation - def self.openid1_return_to_nonce_name - @openid1_return_to_nonce_name - end - - # Set the name of the query parameter that this library will use - # to thread the requested URL through an OpenID 1 transaction (for - # use when verifying discovered information). It will be appended - # to the return_to URL. - def self.openid1_return_to_claimed_id_name=(query_arg_name) - @openid1_return_to_claimed_id_name = query_arg_name - end - - # See openid1_return_to_claimed_id_name= - def self.openid1_return_to_claimed_id_name - @openid1_return_to_claimed_id_name - end - - # Handles an openid.mode=id_res response. This object is - # instantiated and used by the Consumer. - class IdResHandler - attr_reader :endpoint, :message - - def initialize(message, current_url, store=nil, endpoint=nil) - @store = store # Fer the nonce and invalidate_handle - @message = message - @endpoint = endpoint - @current_url = current_url - @signed_list = nil - - # Start the verification process - id_res - end - - def signed_fields - signed_list.map {|x| 'openid.' + x} - end - - protected - - # This method will raise ProtocolError unless the request is a - # valid id_res response. Once it has been verified, the methods - # 'endpoint', 'message', and 'signed_fields' contain the - # verified information. - def id_res - check_for_fields - verify_return_to - verify_discovery_results - check_signature - check_nonce - end - - def server_url - @endpoint.nil? ? nil : @endpoint.server_url - end - - def openid_namespace - @message.get_openid_namespace - end - - def fetch(field, default=NO_DEFAULT) - @message.get_arg(OPENID_NS, field, default) - end - - def signed_list - if @signed_list.nil? - signed_list_str = fetch('signed', nil) - if signed_list_str.nil? - raise ProtocolError, 'Response missing signed list' - end - - @signed_list = signed_list_str.split(',', -1) - end - @signed_list - end - - def check_for_fields - # XXX: if a field is missing, we should not have to explicitly - # check that it's present, just make sure that the fields are - # actually being used by the rest of the code in - # tests. Although, which fields are signed does need to be - # checked somewhere. - basic_fields = ['return_to', 'assoc_handle', 'sig', 'signed'] - basic_sig_fields = ['return_to', 'identity'] - - case openid_namespace - when OPENID2_NS - require_fields = basic_fields + ['op_endpoint'] - require_sigs = basic_sig_fields + - ['response_nonce', 'claimed_id', 'assoc_handle',] - when OPENID1_NS - require_fields = basic_fields + ['identity'] - require_sigs = basic_sig_fields - else - raise RuntimeError, "check_for_fields doesn't know about "\ - "namespace #{openid_namespace.inspect}" - end - - require_fields.each do |field| - if !@message.has_key?(OPENID_NS, field) - raise ProtocolError, "Missing required field #{field}" - end - end - - require_sigs.each do |field| - # Field is present and not in signed list - if @message.has_key?(OPENID_NS, field) && !signed_list.member?(field) - raise ProtocolError, "#{field.inspect} not signed" - end - end - end - - def verify_return_to - begin - msg_return_to = URI.parse(URINorm::urinorm(fetch('return_to'))) - rescue URI::InvalidURIError - raise ProtocolError, ("return_to is not a valid URI") - end - - verify_return_to_args(msg_return_to) - if !@current_url.nil? - verify_return_to_base(msg_return_to) - end - end - - def verify_return_to_args(msg_return_to) - return_to_parsed_query = {} - if !msg_return_to.query.nil? - CGI.parse(msg_return_to.query).each_pair do |k, vs| - return_to_parsed_query[k] = vs[0] - end - end - query = @message.to_post_args - return_to_parsed_query.each_pair do |rt_key, rt_val| - msg_val = query[rt_key] - if msg_val.nil? - raise ProtocolError, "Message missing return_to argument '#{rt_key}'" - elsif msg_val != rt_val - raise ProtocolError, ("Parameter '#{rt_key}' value "\ - "#{msg_val.inspect} does not match "\ - "return_to's value #{rt_val.inspect}") - end - end - @message.get_args(BARE_NS).each_pair do |bare_key, bare_val| - rt_val = return_to_parsed_query[bare_key] - if not return_to_parsed_query.has_key? bare_key - # This may be caused by your web framework throwing extra - # entries in to your parameters hash that were not GET or - # POST parameters. For example, Rails has been known to - # add "controller" and "action" keys; another server adds - # at least a "format" key. - raise ProtocolError, ("Unexpected parameter (not on return_to): "\ - "'#{bare_key}'=#{rt_val.inspect})") - end - if rt_val != bare_val - raise ProtocolError, ("Parameter '#{bare_key}' value "\ - "#{bare_val.inspect} does not match "\ - "return_to's value #{rt_val.inspect}") - end - end - end - - def verify_return_to_base(msg_return_to) - begin - app_parsed = URI.parse(URINorm::urinorm(@current_url)) - rescue URI::InvalidURIError - raise ProtocolError, "current_url is not a valid URI: #{@current_url}" - end - - [:scheme, :host, :port, :path].each do |meth| - if msg_return_to.send(meth) != app_parsed.send(meth) - raise ProtocolError, "return_to #{meth.to_s} does not match" - end - end - end - - # Raises ProtocolError if the signature is bad - def check_signature - if @store.nil? - assoc = nil - else - assoc = @store.get_association(server_url, fetch('assoc_handle')) - end - - if assoc.nil? - check_auth - else - if assoc.expires_in <= 0 - # XXX: It might be a good idea sometimes to re-start the - # authentication with a new association. Doing it - # automatically opens the possibility for - # denial-of-service by a server that just returns expired - # associations (or really short-lived associations) - raise ProtocolError, "Association with #{server_url} expired" - elsif !assoc.check_message_signature(@message) - raise ProtocolError, "Bad signature in response from #{server_url}" - end - end - end - - def check_auth - Util.log("Using 'check_authentication' with #{server_url}") - begin - request = create_check_auth_request - rescue Message::KeyNotFound => why - raise ProtocolError, "Could not generate 'check_authentication' "\ - "request: #{why.message}" - end - - response = OpenID.make_kv_post(request, server_url) - - process_check_auth_response(response) - end - - def create_check_auth_request - signed_list = @message.get_arg(OPENID_NS, 'signed', NO_DEFAULT).split(',') - - # check that we got all the signed arguments - signed_list.each {|k| - @message.get_aliased_arg(k, NO_DEFAULT) - } - - ca_message = @message.copy - ca_message.set_arg(OPENID_NS, 'mode', 'check_authentication') - - return ca_message - end - - # Process the response message from a check_authentication - # request, invalidating associations if requested. - def process_check_auth_response(response) - is_valid = response.get_arg(OPENID_NS, 'is_valid', 'false') - - invalidate_handle = response.get_arg(OPENID_NS, 'invalidate_handle') - if !invalidate_handle.nil? - Util.log("Received 'invalidate_handle' from server #{server_url}") - if @store.nil? - Util.log('Unexpectedly got "invalidate_handle" without a store!') - else - @store.remove_association(server_url, invalidate_handle) - end - end - - if is_valid != 'true' - raise ProtocolError, ("Server #{server_url} responds that the "\ - "'check_authentication' call is not valid") - end - end - - def check_nonce - case openid_namespace - when OPENID1_NS - nonce = - @message.get_arg(BARE_NS, Consumer.openid1_return_to_nonce_name) - - # We generated the nonce, so it uses the empty string as the - # server URL - server_url = '' - when OPENID2_NS - nonce = @message.get_arg(OPENID2_NS, 'response_nonce') - server_url = self.server_url - else - raise StandardError, 'Not reached' - end - - if nonce.nil? - raise ProtocolError, 'Nonce missing from response' - end - - begin - time, extra = Nonce.split_nonce(nonce) - rescue ArgumentError => why - raise ProtocolError, "Malformed nonce: #{nonce.inspect}" - end - - if !@store.nil? && !@store.use_nonce(server_url, time, extra) - raise ProtocolError, ("Nonce already used or out of range: "\ - "#{nonce.inspect}") - end - end - - def verify_discovery_results - begin - case openid_namespace - when OPENID1_NS - verify_discovery_results_openid1 - when OPENID2_NS - verify_discovery_results_openid2 - else - raise StandardError, "Not reached: #{openid_namespace}" - end - rescue Message::KeyNotFound => why - raise ProtocolError, "Missing required field: #{why.message}" - end - end - - def verify_discovery_results_openid2 - to_match = OpenIDServiceEndpoint.new - to_match.type_uris = [OPENID_2_0_TYPE] - to_match.claimed_id = fetch('claimed_id', nil) - to_match.local_id = fetch('identity', nil) - to_match.server_url = fetch('op_endpoint') - - if to_match.claimed_id.nil? && !to_match.local_id.nil? - raise ProtocolError, ('openid.identity is present without '\ - 'openid.claimed_id') - elsif !to_match.claimed_id.nil? && to_match.local_id.nil? - raise ProtocolError, ('openid.claimed_id is present without '\ - 'openid.identity') - - # This is a response without identifiers, so there's really no - # checking that we can do, so return an endpoint that's for - # the specified `openid.op_endpoint' - elsif to_match.claimed_id.nil? - @endpoint = - OpenIDServiceEndpoint.from_op_endpoint_url(to_match.server_url) - return - end - - if @endpoint.nil? - Util.log('No pre-discovered information supplied') - discover_and_verify(to_match.claimed_id, [to_match]) - else - begin - verify_discovery_single(@endpoint, to_match) - rescue ProtocolError => why - Util.log("Error attempting to use stored discovery "\ - "information: #{why.message}") - Util.log("Attempting discovery to verify endpoint") - discover_and_verify(to_match.claimed_id, [to_match]) - end - end - - if @endpoint.claimed_id != to_match.claimed_id - @endpoint = @endpoint.dup - @endpoint.claimed_id = to_match.claimed_id - end - end - - def verify_discovery_results_openid1 - claimed_id = - @message.get_arg(BARE_NS, Consumer.openid1_return_to_claimed_id_name) - - if claimed_id.nil? - if @endpoint.nil? - raise ProtocolError, ("When using OpenID 1, the claimed ID must "\ - "be supplied, either by passing it through "\ - "as a return_to parameter or by using a "\ - "session, and supplied to the IdResHandler "\ - "when it is constructed.") - else - claimed_id = @endpoint.claimed_id - end - end - - to_match = OpenIDServiceEndpoint.new - to_match.type_uris = [OPENID_1_1_TYPE] - to_match.local_id = fetch('identity') - # Restore delegate information from the initiation phase - to_match.claimed_id = claimed_id - - to_match_1_0 = to_match.dup - to_match_1_0.type_uris = [OPENID_1_0_TYPE] - - if !@endpoint.nil? - begin - begin - verify_discovery_single(@endpoint, to_match) - rescue TypeURIMismatch - verify_discovery_single(@endpoint, to_match_1_0) - end - rescue ProtocolError => why - Util.log('Error attempting to use stored discovery information: ' + - why.message) - Util.log('Attempting discovery to verify endpoint') - else - return @endpoint - end - end - - # Either no endpoint was supplied or OpenID 1.x verification - # of the information that's in the message failed on that - # endpoint. - discover_and_verify(to_match.claimed_id, [to_match, to_match_1_0]) - end - - # Given an endpoint object created from the information in an - # OpenID response, perform discovery and verify the discovery - # results, returning the matching endpoint that is the result of - # doing that discovery. - def discover_and_verify(claimed_id, to_match_endpoints) - Util.log("Performing discovery on #{claimed_id}") - _, services = OpenID.discover(claimed_id) - if services.length == 0 - # XXX: this might want to be something other than - # ProtocolError. In Python, it's DiscoveryFailure - raise ProtocolError, ("No OpenID information found at "\ - "#{claimed_id}") - end - verify_discovered_services(claimed_id, services, to_match_endpoints) - end - - - def verify_discovered_services(claimed_id, services, to_match_endpoints) - # Search the services resulting from discovery to find one - # that matches the information from the assertion - failure_messages = [] - for endpoint in services - for to_match_endpoint in to_match_endpoints - begin - verify_discovery_single(endpoint, to_match_endpoint) - rescue ProtocolError => why - failure_messages << why.message - else - # It matches, so discover verification has - # succeeded. Return this endpoint. - @endpoint = endpoint - return - end - end - end - - Util.log("Discovery verification failure for #{claimed_id}") - failure_messages.each do |failure_message| - Util.log(" * Endpoint mismatch: " + failure_message) - end - - # XXX: is DiscoveryFailure in Python OpenID - raise ProtocolError, ("No matching endpoint found after "\ - "discovering #{claimed_id}") - end - - def verify_discovery_single(endpoint, to_match) - # Every type URI that's in the to_match endpoint has to be - # present in the discovered endpoint. - for type_uri in to_match.type_uris - if !endpoint.uses_extension(type_uri) - raise TypeURIMismatch.new(type_uri, endpoint) - end - end - - # Fragments do not influence discovery, so we can't compare a - # claimed identifier with a fragment to discovered information. - defragged_claimed_id = - case Yadis::XRI.identifier_scheme(endpoint.claimed_id) - when :xri - endpoint.claimed_id - when :uri - begin - parsed = URI.parse(endpoint.claimed_id) - rescue URI::InvalidURIError - endpoint.claimed_id - else - parsed.fragment = nil - parsed.to_s - end - else - raise StandardError, 'Not reached' - end - - if defragged_claimed_id != endpoint.claimed_id - raise ProtocolError, ("Claimed ID does not match (different "\ - "subjects!), Expected "\ - "#{defragged_claimed_id}, got "\ - "#{endpoint.claimed_id}") - end - - if to_match.get_local_id != endpoint.get_local_id - raise ProtocolError, ("local_id mismatch. Expected "\ - "#{to_match.get_local_id}, got "\ - "#{endpoint.get_local_id}") - end - - # If the server URL is nil, this must be an OpenID 1 - # response, because op_endpoint is a required parameter in - # OpenID 2. In that case, we don't actually care what the - # discovered server_url is, because signature checking or - # check_auth should take care of that check for us. - if to_match.server_url.nil? - if to_match.preferred_namespace != OPENID1_NS - raise StandardError, - "The code calling this must ensure that OpenID 2 "\ - "responses have a non-none `openid.op_endpoint' and "\ - "that it is set as the `server_url' attribute of the "\ - "`to_match' endpoint." - end - elsif to_match.server_url != endpoint.server_url - raise ProtocolError, ("OP Endpoint mismatch. Expected"\ - "#{to_match.server_url}, got "\ - "#{endpoint.server_url}") - end - end - - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/responses.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/responses.rb deleted file mode 100644 index 91262398..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/consumer/responses.rb +++ /dev/null @@ -1,148 +0,0 @@ -module OpenID - class Consumer - # Code returned when either the of the - # OpenID::OpenIDConsumer.begin_auth or OpenID::OpenIDConsumer.complete_auth - # methods return successfully. - SUCCESS = :success - - # Code OpenID::OpenIDConsumer.complete_auth - # returns when the value it received indicated an invalid login. - FAILURE = :failure - - # Code returned by OpenIDConsumer.complete_auth when the user - # cancels the operation from the server. - CANCEL = :cancel - - # Code returned by OpenID::OpenIDConsumer.complete_auth when the - # OpenIDConsumer instance is in immediate mode and ther server sends back a - # URL for the user to login with. - SETUP_NEEDED = :setup_needed - - - module Response - attr_reader :endpoint - - def status - self.class::STATUS - end - - # The identity URL that has been authenticated; the Claimed Identifier. - # See also display_identifier. - def identity_url - @endpoint ? @endpoint.claimed_id : nil - end - - # The display identifier is related to the Claimed Identifier, but the - # two are not always identical. The display identifier is something the - # user should recognize as what they entered, whereas the response's - # claimed identifier (in the identity_url attribute) may have extra - # information for better persistence. - # - # URLs will be stripped of their fragments for display. XRIs will - # display the human-readable identifier (i-name) instead of the - # persistent identifier (i-number). - # - # Use the display identifier in your user interface. Use identity_url - # for querying your database or authorization server, or other - # identifier equality comparisons. - def display_identifier - @endpoint ? @endpoint.display_identifier : nil - end - end - - # A successful acknowledgement from the OpenID server that the - # supplied URL is, indeed controlled by the requesting agent. - class SuccessResponse - include Response - - STATUS = SUCCESS - - attr_reader :message, :signed_fields - - def initialize(endpoint, message, signed_fields) - # Don't use :endpoint=, because endpoint should never be nil - # for a successfull transaction. - @endpoint = endpoint - @identity_url = endpoint.claimed_id - @message = message - @signed_fields = signed_fields - end - - # Was this authentication response an OpenID 1 authentication - # response? - def is_openid1 - @message.is_openid1 - end - - # Return whether a particular key is signed, regardless of its - # namespace alias - def signed?(ns_uri, ns_key) - @signed_fields.member?(@message.get_key(ns_uri, ns_key)) - end - - # Return the specified signed field if available, otherwise - # return default - def get_signed(ns_uri, ns_key, default=nil) - if singed?(ns_uri, ns_key) - return @message.get_arg(ns_uri, ns_key, default) - else - return default - end - end - - # Get signed arguments from the response message. Return a dict - # of all arguments in the specified namespace. If any of the - # arguments are not signed, return nil. - def get_signed_ns(ns_uri) - msg_args = @message.get_args(ns_uri) - msg_args.each_key do |key| - if !signed?(ns_uri, key) - return nil - end - end - return msg_args - end - - # Return response arguments in the specified namespace. - # If require_signed is true and the arguments are not signed, - # return nil. - def extension_response(namespace_uri, require_signed) - if require_signed - get_signed_ns(namespace_uri) - else - @message.get_args(namespace_uri) - end - end - end - - class FailureResponse - include Response - STATUS = FAILURE - - attr_reader :message, :contact, :reference - def initialize(endpoint, message, contact=nil, reference=nil) - @endpoint = endpoint - @message = message - @contact = contact - @reference = reference - end - end - - class CancelResponse - include Response - STATUS = CANCEL - def initialize(endpoint) - @endpoint = endpoint - end - end - - class SetupNeededResponse - include Response - STATUS = SETUP_NEEDED - def initialize(endpoint, setup_url) - @endpoint = endpoint - @setup_url = setup_url - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/cryptutil.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/cryptutil.rb deleted file mode 100644 index d8ffead9..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/cryptutil.rb +++ /dev/null @@ -1,97 +0,0 @@ -require "openid/util" -require "digest/sha1" -require "digest/sha2" -begin - require "digest/hmac" -rescue LoadError - require "hmac/sha1" - require "hmac/sha2" -end - -module OpenID - # This module contains everything needed to perform low-level - # cryptograph and data manipulation tasks. - module CryptUtil - - # Generate a random number, doing a little extra work to make it - # more likely that it's suitable for cryptography. If your system - # doesn't have /dev/urandom then this number is not - # cryptographically safe. See - # - # for more information. max is the largest possible value of such - # a random number, where the result will be less than max. - def CryptUtil.rand(max) - Kernel.srand() - return Kernel.rand(max) - end - - def CryptUtil.sha1(text) - return Digest::SHA1.digest(text) - end - - def CryptUtil.hmac_sha1(key, text) - if Digest.const_defined? :HMAC - Digest::HMAC.new(key,Digest::SHA1).update(text).digest - else - return HMAC::SHA1.digest(key, text) - end - end - - def CryptUtil.sha256(text) - return Digest::SHA256.digest(text) - end - - def CryptUtil.hmac_sha256(key, text) - if Digest.const_defined? :HMAC - Digest::HMAC.new(key,Digest::SHA256).update(text).digest - else - return HMAC::SHA256.digest(key, text) - end - end - - # Generate a random string of the given length, composed of the - # specified characters. If chars is nil, generate a string - # composed of characters in the range 0..255. - def CryptUtil.random_string(length, chars=nil) - s = "" - - unless chars.nil? - length.times { s << chars[rand(chars.length)] } - else - length.times { s << rand(256).chr } - end - return s - end - - # Convert a number to its binary representation; return a string - # of bytes. - def CryptUtil.num_to_binary(n) - bits = n.to_s(2) - prepend = (8 - bits.length % 8) - bits = ('0' * prepend) + bits - return [bits].pack('B*') - end - - # Convert a string of bytes into a number. - def CryptUtil.binary_to_num(s) - # taken from openid-ruby 0.0.1 - s = "\000" * (4 - (s.length % 4)) + s - num = 0 - s.unpack('N*').each do |x| - num <<= 32 - num |= x - end - return num - end - - # Encode a number as a base64-encoded byte string. - def CryptUtil.num_to_base64(l) - return OpenID::Util.to_base64(num_to_binary(l)) - end - - # Decode a base64 byte string to a number. - def CryptUtil.base64_to_num(s) - return binary_to_num(OpenID::Util.from_base64(s)) - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/dh.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/dh.rb deleted file mode 100644 index cbe53114..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/dh.rb +++ /dev/null @@ -1,89 +0,0 @@ -require "openid/util" -require "openid/cryptutil" - -module OpenID - - # Encapsulates a Diffie-Hellman key exchange. This class is used - # internally by both the consumer and server objects. - # - # Read more about Diffie-Hellman on wikipedia: - # http://en.wikipedia.org/wiki/Diffie-Hellman - - class DiffieHellman - - # From the OpenID specification - @@default_mod = 155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638443 - @@default_gen = 2 - - attr_reader :modulus, :generator, :public - - # A new DiffieHellman object, using the modulus and generator from - # the OpenID specification - def DiffieHellman.from_defaults - DiffieHellman.new(@@default_mod, @@default_gen) - end - - def initialize(modulus=nil, generator=nil, priv=nil) - @modulus = modulus.nil? ? @@default_mod : modulus - @generator = generator.nil? ? @@default_gen : generator - set_private(priv.nil? ? OpenID::CryptUtil.rand(@modulus-2) + 1 : priv) - end - - def get_shared_secret(composite) - DiffieHellman.powermod(composite, @private, @modulus) - end - - def xor_secret(algorithm, composite, secret) - dh_shared = get_shared_secret(composite) - packed_dh_shared = OpenID::CryptUtil.num_to_binary(dh_shared) - hashed_dh_shared = algorithm.call(packed_dh_shared) - return DiffieHellman.strxor(secret, hashed_dh_shared) - end - - def using_default_values? - @generator == @@default_gen && @modulus == @@default_mod - end - - private - def set_private(priv) - @private = priv - @public = DiffieHellman.powermod(@generator, @private, @modulus) - end - - def DiffieHellman.strxor(s, t) - if s.length != t.length - raise ArgumentError, "strxor: lengths don't match. " + - "Inputs were #{s.inspect} and #{t.inspect}" - end - - if String.method_defined? :bytes - s.bytes.zip(t.bytes).map{|sb,tb| sb^tb}.pack('C*') - else - indices = 0...(s.length) - chrs = indices.collect {|i| (s[i]^t[i]).chr} - chrs.join("") - end - end - - # This code is taken from this post: - # - # by Eric Lee Green. - def DiffieHellman.powermod(x, n, q) - counter=0 - n_p=n - y_p=1 - z_p=x - while n_p != 0 - if n_p[0]==1 - y_p=(y_p*z_p) % q - end - n_p = n_p >> 1 - z_p = (z_p * z_p) % q - counter += 1 - end - return y_p - end - - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/extension.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/extension.rb deleted file mode 100644 index f0f02bb5..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/extension.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'openid/message' - -module OpenID - # An interface for OpenID extensions. - class Extension < Object - - def initialize - @ns_uri = nil - @ns_alias = nil - end - - # Get the string arguments that should be added to an OpenID - # message for this extension. - def get_extension_args - raise NotImplementedError - end - - # Add the arguments from this extension to the provided - # message, or create a new message containing only those - # arguments. Returns the message with added extension args. - def to_message(message = nil) - if message.nil? -# warnings.warn('Passing None to Extension.toMessage is deprecated. ' -# 'Creating a message assuming you want OpenID 2.', -# DeprecationWarning, stacklevel=2) - Message.new(OPENID2_NS) - end - message = Message.new if message.nil? - - implicit = message.is_openid1() - - message.namespaces.add_alias(@ns_uri, @ns_alias, implicit) - # XXX python ignores keyerror if m.ns.getAlias(uri) == alias - - message.update_args(@ns_uri, get_extension_args) - return message - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/ax.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/ax.rb deleted file mode 100644 index 55eda8e7..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/ax.rb +++ /dev/null @@ -1,516 +0,0 @@ -# Implements the OpenID attribute exchange specification, version 1.0 - -require 'openid/extension' -require 'openid/trustroot' -require 'openid/message' - -module OpenID - module AX - - UNLIMITED_VALUES = "unlimited" - MINIMUM_SUPPORTED_ALIAS_LENGTH = 32 - - # check alias for invalid characters, raise AXError if found - def self.check_alias(name) - if name.match(/(,|\.)/) - raise Error, ("Alias #{name.inspect} must not contain a "\ - "comma or period.") - end - end - - # Raised when data does not comply with AX 1.0 specification - class Error < ArgumentError - end - - # Abstract class containing common code for attribute exchange messages - class AXMessage < Extension - attr_accessor :ns_alias, :mode, :ns_uri - - NS_URI = 'http://openid.net/srv/ax/1.0' - def initialize - @ns_alias = 'ax' - @ns_uri = NS_URI - @mode = nil - end - - protected - - # Raise an exception if the mode in the attribute exchange - # arguments does not match what is expected for this class. - def check_mode(ax_args) - actual_mode = ax_args['mode'] - if actual_mode != @mode - raise Error, "Expected mode #{mode.inspect}, got #{actual_mode.inspect}" - end - end - - def new_args - {'mode' => @mode} - end - end - - # Represents a single attribute in an attribute exchange - # request. This should be added to an Request object in order to - # request the attribute. - # - # @ivar required: Whether the attribute will be marked as required - # when presented to the subject of the attribute exchange - # request. - # @type required: bool - # - # @ivar count: How many values of this type to request from the - # subject. Defaults to one. - # @type count: int - # - # @ivar type_uri: The identifier that determines what the attribute - # represents and how it is serialized. For example, one type URI - # representing dates could represent a Unix timestamp in base 10 - # and another could represent a human-readable string. - # @type type_uri: str - # - # @ivar ns_alias: The name that should be given to this alias in the - # request. If it is not supplied, a generic name will be - # assigned. For example, if you want to call a Unix timestamp - # value 'tstamp', set its alias to that value. If two attributes - # in the same message request to use the same alias, the request - # will fail to be generated. - # @type alias: str or NoneType - class AttrInfo < Object - attr_reader :type_uri, :count, :ns_alias - attr_accessor :required - def initialize(type_uri, ns_alias=nil, required=false, count=1) - @type_uri = type_uri - @count = count - @required = required - @ns_alias = ns_alias - end - - def wants_unlimited_values? - @count == UNLIMITED_VALUES - end - end - - # Given a namespace mapping and a string containing a - # comma-separated list of namespace aliases, return a list of type - # URIs that correspond to those aliases. - # namespace_map: OpenID::NamespaceMap - def self.to_type_uris(namespace_map, alias_list_s) - return [] if alias_list_s.nil? - alias_list_s.split(',').inject([]) {|uris, name| - type_uri = namespace_map.get_namespace_uri(name) - raise IndexError, "No type defined for attribute name #{name.inspect}" if type_uri.nil? - uris << type_uri - } - end - - - # An attribute exchange 'fetch_request' message. This message is - # sent by a relying party when it wishes to obtain attributes about - # the subject of an OpenID authentication request. - class FetchRequest < AXMessage - attr_reader :requested_attributes - attr_accessor :update_url - - def initialize(update_url = nil) - super() - @mode = 'fetch_request' - @requested_attributes = {} - @update_url = update_url - end - - # Add an attribute to this attribute exchange request. - # attribute: AttrInfo, the attribute being requested - # Raises IndexError if the requested attribute is already present - # in this request. - def add(attribute) - if @requested_attributes[attribute.type_uri] - raise IndexError, "The attribute #{attribute.type_uri} has already been requested" - end - @requested_attributes[attribute.type_uri] = attribute - end - - # Get the serialized form of this attribute fetch request. - # returns a hash of the arguments - def get_extension_args - aliases = NamespaceMap.new - required = [] - if_available = [] - ax_args = new_args - @requested_attributes.each{|type_uri, attribute| - if attribute.ns_alias - name = aliases.add_alias(type_uri, attribute.ns_alias) - else - name = aliases.add(type_uri) - end - if attribute.required - required << name - else - if_available << name - end - if attribute.count != 1 - ax_args["count.#{name}"] = attribute.count.to_s - end - ax_args["type.#{name}"] = type_uri - } - - unless required.empty? - ax_args['required'] = required.join(',') - end - unless if_available.empty? - ax_args['if_available'] = if_available.join(',') - end - return ax_args - end - - # Get the type URIs for all attributes that have been marked - # as required. - def get_required_attrs - @requested_attributes.inject([]) {|required, (type_uri, attribute)| - if attribute.required - required << type_uri - else - required - end - } - end - - # Extract a FetchRequest from an OpenID message - # message: OpenID::Message - # return a FetchRequest or nil if AX arguments are not present - def self.from_openid_request(oidreq) - message = oidreq.message - ax_args = message.get_args(NS_URI) - return nil if ax_args == {} - req = new - req.parse_extension_args(ax_args) - - if req.update_url - realm = message.get_arg(OPENID_NS, 'realm', - message.get_arg(OPENID_NS, 'return_to')) - if realm.nil? or realm.empty? - raise Error, "Cannot validate update_url #{req.update_url.inspect} against absent realm" - end - tr = TrustRoot::TrustRoot.parse(realm) - unless tr.validate_url(req.update_url) - raise Error, "Update URL #{req.update_url.inspect} failed validation against realm #{realm.inspect}" - end - end - - return req - end - - def parse_extension_args(ax_args) - check_mode(ax_args) - - aliases = NamespaceMap.new - - ax_args.each{|k,v| - if k.index('type.') == 0 - name = k[5..-1] - type_uri = v - aliases.add_alias(type_uri, name) - - count_key = 'count.'+name - count_s = ax_args[count_key] - count = 1 - if count_s - if count_s == UNLIMITED_VALUES - count = count_s - else - count = count_s.to_i - if count <= 0 - raise Error, "Invalid value for count #{count_key.inspect}: #{count_s.inspect}" - end - end - end - add(AttrInfo.new(type_uri, name, false, count)) - end - } - - required = AX.to_type_uris(aliases, ax_args['required']) - required.each{|type_uri| - @requested_attributes[type_uri].required = true - } - if_available = AX.to_type_uris(aliases, ax_args['if_available']) - all_type_uris = required + if_available - - aliases.namespace_uris.each{|type_uri| - unless all_type_uris.member? type_uri - raise Error, "Type URI #{type_uri.inspect} was in the request but not present in 'required' or 'if_available'" - end - } - @update_url = ax_args['update_url'] - end - - # return the list of AttrInfo objects contained in the FetchRequest - def attributes - @requested_attributes.values - end - - # return the list of requested attribute type URIs - def requested_types - @requested_attributes.keys - end - - def member?(type_uri) - ! @requested_attributes[type_uri].nil? - end - - end - - # Abstract class that implements a message that has attribute - # keys and values. It contains the common code between - # fetch_response and store_request. - class KeyValueMessage < AXMessage - attr_reader :data - def initialize - super() - @mode = nil - @data = {} - @data.default = [] - end - - # Add a single value for the given attribute type to the - # message. If there are already values specified for this type, - # this value will be sent in addition to the values already - # specified. - def add_value(type_uri, value) - @data[type_uri] = @data[type_uri] << value - end - - # Set the values for the given attribute type. This replaces - # any values that have already been set for this attribute. - def set_values(type_uri, values) - @data[type_uri] = values - end - - # Get the extension arguments for the key/value pairs - # contained in this message. - def _get_extension_kv_args(aliases = nil) - aliases = NamespaceMap.new if aliases.nil? - - ax_args = new_args - - @data.each{|type_uri, values| - name = aliases.add(type_uri) - ax_args['type.'+name] = type_uri - ax_args['count.'+name] = values.size.to_s - - values.each_with_index{|value, i| - key = "value.#{name}.#{i+1}" - ax_args[key] = value - } - } - return ax_args - end - - # Parse attribute exchange key/value arguments into this object. - - def parse_extension_args(ax_args) - check_mode(ax_args) - aliases = NamespaceMap.new - - ax_args.each{|k, v| - if k.index('type.') == 0 - type_uri = v - name = k[5..-1] - - AX.check_alias(name) - aliases.add_alias(type_uri,name) - end - } - - aliases.each{|type_uri, name| - count_s = ax_args['count.'+name] - count = count_s.to_i - if count_s.nil? - value = ax_args['value.'+name] - if value.nil? - raise IndexError, "Missing #{'value.'+name} in FetchResponse" - elsif value.empty? - values = [] - else - values = [value] - end - elsif count_s.to_i == 0 - values = [] - else - values = (1..count).inject([]){|l,i| - key = "value.#{name}.#{i}" - v = ax_args[key] - raise IndexError, "Missing #{key} in FetchResponse" if v.nil? - l << v - } - end - @data[type_uri] = values - } - end - - # Get a single value for an attribute. If no value was sent - # for this attribute, use the supplied default. If there is more - # than one value for this attribute, this method will fail. - def get_single(type_uri, default = nil) - values = @data[type_uri] - return default if values.empty? - if values.size != 1 - raise Error, "More than one value present for #{type_uri.inspect}" - else - return values[0] - end - end - - # retrieve the list of values for this attribute - def get(type_uri) - @data[type_uri] - end - - # retrieve the list of values for this attribute - def [](type_uri) - @data[type_uri] - end - - # get the number of responses for this attribute - def count(type_uri) - @data[type_uri].size - end - - end - - # A fetch_response attribute exchange message - class FetchResponse < KeyValueMessage - attr_reader :update_url - - def initialize(update_url = nil) - super() - @mode = 'fetch_response' - @update_url = update_url - end - - # Serialize this object into arguments in the attribute - # exchange namespace - # Takes an optional FetchRequest. If specified, the response will be - # validated against this request, and empty responses for requested - # fields with no data will be sent. - def get_extension_args(request = nil) - aliases = NamespaceMap.new - zero_value_types = [] - - if request - # Validate the data in the context of the request (the - # same attributes should be present in each, and the - # counts in the response must be no more than the counts - # in the request) - @data.keys.each{|type_uri| - unless request.member? type_uri - raise IndexError, "Response attribute not present in request: #{type_uri.inspect}" - end - } - - request.attributes.each{|attr_info| - # Copy the aliases from the request so that reading - # the response in light of the request is easier - if attr_info.ns_alias.nil? - aliases.add(attr_info.type_uri) - else - aliases.add_alias(attr_info.type_uri, attr_info.ns_alias) - end - values = @data[attr_info.type_uri] - if values.empty? # @data defaults to [] - zero_value_types << attr_info - end - if attr_info.count != UNLIMITED_VALUES and attr_info.count < values.size - raise Error, "More than the number of requested values were specified for #{attr_info.type_uri.inspect}" - end - } - end - - kv_args = _get_extension_kv_args(aliases) - - # Add the KV args into the response with the args that are - # unique to the fetch_response - ax_args = new_args - - zero_value_types.each{|attr_info| - name = aliases.get_alias(attr_info.type_uri) - kv_args['type.' + name] = attr_info.type_uri - kv_args['count.' + name] = '0' - } - update_url = (request and request.update_url or @update_url) - ax_args['update_url'] = update_url unless update_url.nil? - ax_args.update(kv_args) - return ax_args - end - - def parse_extension_args(ax_args) - super - @update_url = ax_args['update_url'] - end - - # Construct a FetchResponse object from an OpenID library - # SuccessResponse object. - def self.from_success_response(success_response, signed=true) - obj = self.new - if signed - ax_args = success_response.get_signed_ns(obj.ns_uri) - else - ax_args = success_response.message.get_args(obj.ns_uri) - end - - begin - obj.parse_extension_args(ax_args) - return obj - rescue Error => e - return nil - end - end - end - - # A store request attribute exchange message representation - class StoreRequest < KeyValueMessage - def initialize - super - @mode = 'store_request' - end - - def get_extension_args(aliases=nil) - ax_args = new_args - kv_args = _get_extension_kv_args(aliases) - ax_args.update(kv_args) - return ax_args - end - end - - # An indication that the store request was processed along with - # this OpenID transaction. - class StoreResponse < AXMessage - SUCCESS_MODE = 'store_response_success' - FAILURE_MODE = 'store_response_failure' - attr_reader :error_message - - def initialize(succeeded = true, error_message = nil) - super() - if succeeded and error_message - raise Error, "Error message included in a success response" - end - if succeeded - @mode = SUCCESS_MODE - else - @mode = FAILURE_MODE - end - @error_message = error_message - end - - def succeeded? - @mode == SUCCESS_MODE - end - - def get_extension_args - ax_args = new_args - if !succeeded? and error_message - ax_args['error'] = @error_message - end - return ax_args - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/pape.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/pape.rb deleted file mode 100644 index 0a7413c1..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/pape.rb +++ /dev/null @@ -1,179 +0,0 @@ -# An implementation of the OpenID Provider Authentication Policy -# Extension 1.0 -# see: http://openid.net/specs/ - -require 'openid/extension' - -module OpenID - - module PAPE - NS_URI = "http://specs.openid.net/extensions/pape/1.0" - AUTH_MULTI_FACTOR_PHYSICAL = - 'http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical' - AUTH_MULTI_FACTOR = - 'http://schemas.openid.net/pape/policies/2007/06/multi-factor' - AUTH_PHISHING_RESISTANT = - 'http://schemas.openid.net/pape/policies/2007/06/phishing-resistant' - TIME_VALIDATOR = /\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/ - # A Provider Authentication Policy request, sent from a relying - # party to a provider - class Request < Extension - attr_accessor :preferred_auth_policies, :max_auth_age, :ns_alias, :ns_uri - def initialize(preferred_auth_policies=[], max_auth_age=nil) - @ns_alias = 'pape' - @ns_uri = NS_URI - @preferred_auth_policies = preferred_auth_policies - @max_auth_age = max_auth_age - end - - # Add an acceptable authentication policy URI to this request - # This method is intended to be used by the relying party to add - # acceptable authentication types to the request. - def add_policy_uri(policy_uri) - unless @preferred_auth_policies.member? policy_uri - @preferred_auth_policies << policy_uri - end - end - - def get_extension_args - ns_args = { - 'preferred_auth_policies' => @preferred_auth_policies.join(' ') - } - ns_args['max_auth_age'] = @max_auth_age.to_s if @max_auth_age - return ns_args - end - - # Instantiate a Request object from the arguments in a - # checkid_* OpenID message - # return nil if the extension was not requested. - def self.from_openid_request(oid_req) - pape_req = new - args = oid_req.message.get_args(NS_URI) - if args == {} - return nil - end - pape_req.parse_extension_args(args) - return pape_req - end - - # Set the state of this request to be that expressed in these - # PAPE arguments - def parse_extension_args(args) - @preferred_auth_policies = [] - policies_str = args['preferred_auth_policies'] - if policies_str - policies_str.split(' ').each{|uri| - add_policy_uri(uri) - } - end - - max_auth_age_str = args['max_auth_age'] - if max_auth_age_str - @max_auth_age = max_auth_age_str.to_i - else - @max_auth_age = nil - end - end - - # Given a list of authentication policy URIs that a provider - # supports, this method returns the subset of those types - # that are preferred by the relying party. - def preferred_types(supported_types) - @preferred_auth_policies.select{|uri| supported_types.member? uri} - end - end - - # A Provider Authentication Policy response, sent from a provider - # to a relying party - class Response < Extension - attr_accessor :ns_alias, :auth_policies, :auth_time, :nist_auth_level - def initialize(auth_policies=[], auth_time=nil, nist_auth_level=nil) - @ns_alias = 'pape' - @ns_uri = NS_URI - @auth_policies = auth_policies - @auth_time = auth_time - @nist_auth_level = nist_auth_level - end - - # Add a policy URI to the response - # see http://openid.net/specs/openid-provider-authentication-policy-extension-1_0-01.html#auth_policies - def add_policy_uri(policy_uri) - @auth_policies << policy_uri unless @auth_policies.member?(policy_uri) - end - - # Create a Response object from an OpenID::Consumer::SuccessResponse - def self.from_success_response(success_response) - args = success_response.get_signed_ns(NS_URI) - return nil if args.nil? - pape_resp = new - pape_resp.parse_extension_args(args) - return pape_resp - end - - # parse the provider authentication policy arguments into the - # internal state of this object - # if strict is specified, raise an exception when bad data is - # encountered - def parse_extension_args(args, strict=false) - policies_str = args['auth_policies'] - if policies_str and policies_str != 'none' - @auth_policies = policies_str.split(' ') - end - - nist_level_str = args['nist_auth_level'] - if nist_level_str - # special handling of zero to handle to_i behavior - if nist_level_str.strip == '0' - nist_level = 0 - else - nist_level = nist_level_str.to_i - # if it's zero here we have a bad value - if nist_level == 0 - nist_level = nil - end - end - if nist_level and nist_level >= 0 and nist_level < 5 - @nist_auth_level = nist_level - elsif strict - raise ArgumentError, "nist_auth_level must be an integer 0 through 4, not #{nist_level_str.inspect}" - end - end - - auth_time_str = args['auth_time'] - if auth_time_str - # validate time string - if auth_time_str =~ TIME_VALIDATOR - @auth_time = auth_time_str - elsif strict - raise ArgumentError, "auth_time must be in RFC3339 format" - end - end - end - - def get_extension_args - ns_args = {} - if @auth_policies.empty? - ns_args['auth_policies'] = 'none' - else - ns_args['auth_policies'] = @auth_policies.join(' ') - end - if @nist_auth_level - unless (0..4).member? @nist_auth_level - raise ArgumentError, "nist_auth_level must be an integer 0 through 4, not #{@nist_auth_level.inspect}" - end - ns_args['nist_auth_level'] = @nist_auth_level.to_s - end - - if @auth_time - unless @auth_time =~ TIME_VALIDATOR - raise ArgumentError, "auth_time must be in RFC3339 format" - end - ns_args['auth_time'] = @auth_time - end - return ns_args - end - - end - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/sreg.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/sreg.rb deleted file mode 100644 index 8dc780eb..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/extensions/sreg.rb +++ /dev/null @@ -1,277 +0,0 @@ -require 'openid/extension' -require 'openid/util' -require 'openid/message' - -module OpenID - module SReg - DATA_FIELDS = { - 'fullname'=>'Full Name', - 'nickname'=>'Nickname', - 'dob'=>'Date of Birth', - 'email'=>'E-mail Address', - 'gender'=>'Gender', - 'postcode'=>'Postal Code', - 'country'=>'Country', - 'language'=>'Language', - 'timezone'=>'Time Zone', - } - - NS_URI_1_0 = 'http://openid.net/sreg/1.0' - NS_URI_1_1 = 'http://openid.net/extensions/sreg/1.1' - NS_URI = NS_URI_1_1 - - begin - Message.register_namespace_alias(NS_URI_1_1, 'sreg') - rescue NamespaceAliasRegistrationError => e - Util.log(e) - end - - # raise ArgumentError if fieldname is not in the defined sreg fields - def OpenID.check_sreg_field_name(fieldname) - unless DATA_FIELDS.member? fieldname - raise ArgumentError, "#{fieldname} is not a defined simple registration field" - end - end - - # Does the given endpoint advertise support for simple registration? - def OpenID.supports_sreg?(endpoint) - endpoint.uses_extension(NS_URI_1_1) || endpoint.uses_extension(NS_URI_1_0) - end - - # Extract the simple registration namespace URI from the given - # OpenID message. Handles OpenID 1 and 2, as well as both sreg - # namespace URIs found in the wild, as well as missing namespace - # definitions (for OpenID 1) - def OpenID.get_sreg_ns(message) - [NS_URI_1_1, NS_URI_1_0].each{|ns| - if message.namespaces.get_alias(ns) - return ns - end - } - # try to add an alias, since we didn't find one - ns = NS_URI_1_1 - begin - message.namespaces.add_alias(ns, 'sreg') - rescue IndexError - raise NamespaceError - end - return ns - end - - # The simple registration namespace was not found and could not - # be created using the expected name (there's another extension - # using the name 'sreg') - # - # This is not illegal, for OpenID 2, although it probably - # indicates a problem, since it's not expected that other extensions - # will re-use the alias that is in use for OpenID 1. - # - # If this is an OpenID 1 request, then there is no recourse. This - # should not happen unless some code has modified the namespaces for - # the message that is being processed. - class NamespaceError < ArgumentError - end - - # An object to hold the state of a simple registration request. - class Request < Extension - attr_reader :optional, :required, :ns_uri - attr_accessor :policy_url - def initialize(required = nil, optional = nil, policy_url = nil, ns_uri = NS_URI) - super() - - @policy_url = policy_url - @ns_uri = ns_uri - @ns_alias = 'sreg' - @required = [] - @optional = [] - - if required - request_fields(required, true, true) - end - if optional - request_fields(optional, false, true) - end - end - - # Create a simple registration request that contains the - # fields that were requested in the OpenID request with the - # given arguments - # Takes an OpenID::CheckIDRequest, returns an OpenID::Sreg::Request - # return nil if the extension was not requested. - def self.from_openid_request(request) - # Since we're going to mess with namespace URI mapping, don't - # mutate the object that was passed in. - message = request.message.copy - ns_uri = OpenID::get_sreg_ns(message) - args = message.get_args(ns_uri) - return nil if args == {} - req = new(nil,nil,nil,ns_uri) - req.parse_extension_args(args) - return req - end - - # Parse the unqualified simple registration request - # parameters and add them to this object. - # - # This method is essentially the inverse of - # getExtensionArgs. This method restores the serialized simple - # registration request fields. - # - # If you are extracting arguments from a standard OpenID - # checkid_* request, you probably want to use fromOpenIDRequest, - # which will extract the sreg namespace and arguments from the - # OpenID request. This method is intended for cases where the - # OpenID server needs more control over how the arguments are - # parsed than that method provides. - def parse_extension_args(args, strict = false) - required_items = args['required'] - unless required_items.nil? or required_items.empty? - required_items.split(',').each{|field_name| - begin - request_field(field_name, true, strict) - rescue ArgumentError - raise if strict - end - } - end - - optional_items = args['optional'] - unless optional_items.nil? or optional_items.empty? - optional_items.split(',').each{|field_name| - begin - request_field(field_name, false, strict) - rescue ArgumentError - raise if strict - end - } - end - @policy_url = args['policy_url'] - end - - # A list of all of the simple registration fields that were - # requested, whether they were required or optional. - def all_requested_fields - @required + @optional - end - - # Have any simple registration fields been requested? - def were_fields_requested? - !all_requested_fields.empty? - end - - # Request the specified field from the OpenID user - # field_name: the unqualified simple registration field name - # required: whether the given field should be presented - # to the user as being a required to successfully complete - # the request - # strict: whether to raise an exception when a field is - # added to a request more than once - # Raises ArgumentError if the field_name is not a simple registration - # field, or if strict is set and a field is added more than once - def request_field(field_name, required=false, strict=false) - OpenID::check_sreg_field_name(field_name) - - if strict - if (@required + @optional).member? field_name - raise ArgumentError, 'That field has already been requested' - end - else - return if @required.member? field_name - if @optional.member? field_name - if required - @optional.delete field_name - else - return - end - end - end - if required - @required << field_name - else - @optional << field_name - end - end - - # Add the given list of fields to the request. - def request_fields(field_names, required = false, strict = false) - raise ArgumentError unless field_names.respond_to?(:each) and - field_names[0].is_a?(String) - field_names.each{|fn|request_field(fn, required, strict)} - end - - # Get a hash of unqualified simple registration arguments - # representing this request. - # This method is essentially the inverse of parse_extension_args. - # This method serializes the simple registration request fields. - def get_extension_args - args = {} - args['required'] = @required.join(',') unless @required.empty? - args['optional'] = @optional.join(',') unless @optional.empty? - args['policy_url'] = @policy_url unless @policy_url.nil? - return args - end - - def member?(field_name) - all_requested_fields.member?(field_name) - end - - end - - # Represents the data returned in a simple registration response - # inside of an OpenID id_res response. This object will be - # created by the OpenID server, added to the id_res response - # object, and then extracted from the id_res message by the Consumer. - class Response < Extension - attr_reader :ns_uri, :data - - def initialize(data = {}, ns_uri=NS_URI) - @ns_alias = 'sreg' - @data = data - @ns_uri = ns_uri - end - - # Take a Request and a hash of simple registration - # values and create a Response object containing that data. - def self.extract_response(request, data) - arf = request.all_requested_fields - resp_data = data.reject{|k,v| !arf.member?(k) || v.nil? } - new(resp_data, request.ns_uri) - end - - # Create an Response object from an - # OpenID::Consumer::SuccessResponse from consumer.complete - # If you set the signed_only parameter to false, unsigned data from - # the id_res message from the server will be processed. - def self.from_success_response(success_response, signed_only = true) - ns_uri = OpenID::get_sreg_ns(success_response.message) - if signed_only - args = success_response.get_signed_ns(ns_uri) - return nil if args.nil? # No signed args, so fail - else - args = success_response.message.get_args(ns_uri) - end - args.reject!{|k,v| !DATA_FIELDS.member?(k) } - new(args, ns_uri) - end - - # Get the fields to put in the simple registration namespace - # when adding them to an id_res message. - def get_extension_args - return @data - end - - # Read-only hashlike interface. - # Raises an exception if the field name is bad - def [](field_name) - OpenID::check_sreg_field_name(field_name) - data[field_name] - end - - def empty? - @data.empty? - end - # XXX is there more to a hashlike interface I should add? - end - end -end - diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/extras.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/extras.rb deleted file mode 100644 index 0d9560ab..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/extras.rb +++ /dev/null @@ -1,11 +0,0 @@ -class String - def starts_with?(other) - head = self[0, other.length] - head == other - end - - def ends_with?(other) - tail = self[-1 * other.length, other.length] - tail == other - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/fetchers.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/fetchers.rb deleted file mode 100644 index b194a66b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/fetchers.rb +++ /dev/null @@ -1,239 +0,0 @@ -require 'net/http' -require 'openid' -require 'openid/util' - -begin - require 'net/https' -rescue LoadError - OpenID::Util.log('WARNING: no SSL support found. Will not be able ' + - 'to fetch HTTPS URLs!') - require 'net/http' -end - -MAX_RESPONSE_KB = 1024 - -module Net - class HTTP - def post_connection_check(hostname) - check_common_name = true - cert = @socket.io.peer_cert - cert.extensions.each { |ext| - next if ext.oid != "subjectAltName" - ext.value.split(/,\s+/).each{ |general_name| - if /\ADNS:(.*)/ =~ general_name - check_common_name = false - reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+") - return true if /\A#{reg}\z/i =~ hostname - elsif /\AIP Address:(.*)/ =~ general_name - check_common_name = false - return true if $1 == hostname - end - } - } - if check_common_name - cert.subject.to_a.each{ |oid, value| - if oid == "CN" - reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+") - return true if /\A#{reg}\z/i =~ hostname - end - } - end - raise OpenSSL::SSL::SSLError, "hostname does not match" - end - end -end - -module OpenID - # Our HTTPResponse class extends Net::HTTPResponse with an additional - # method, final_url. - class HTTPResponse - attr_accessor :final_url - - attr_accessor :_response - - def self._from_net_response(response, final_url, headers=nil) - me = self.new - me._response = response - me.final_url = final_url - return me - end - - def method_missing(method, *args) - @_response.send(method, *args) - end - - def body=(s) - @_response.instance_variable_set('@body', s) - # XXX Hack to work around ruby's HTTP library behavior. @body - # is only returned if it has been read from the response - # object's socket, but since we're not using a socket in this - # case, we need to set the @read flag to true to avoid a bug in - # Net::HTTPResponse.stream_check when @socket is nil. - @_response.instance_variable_set('@read', true) - end - end - - class FetchingError < OpenIDError - end - - class HTTPRedirectLimitReached < FetchingError - end - - class SSLFetchingError < FetchingError - end - - @fetcher = nil - - def self.fetch(url, body=nil, headers=nil, - redirect_limit=StandardFetcher::REDIRECT_LIMIT) - return fetcher.fetch(url, body, headers, redirect_limit) - end - - def self.fetcher - if @fetcher.nil? - @fetcher = StandardFetcher.new - end - - return @fetcher - end - - def self.fetcher=(fetcher) - @fetcher = fetcher - end - - # Set the default fetcher to use the HTTP proxy defined in the environment - # variable 'http_proxy'. - def self.fetcher_use_env_http_proxy - proxy_string = ENV['http_proxy'] - return unless proxy_string - - proxy_uri = URI.parse(proxy_string) - @fetcher = StandardFetcher.new(proxy_uri.host, proxy_uri.port, - proxy_uri.user, proxy_uri.password) - end - - class StandardFetcher - - USER_AGENT = "ruby-openid/#{OpenID::VERSION} (#{RUBY_PLATFORM})" - - REDIRECT_LIMIT = 5 - TIMEOUT = 60 - - attr_accessor :ca_file - attr_accessor :timeout - - # I can fetch through a HTTP proxy; arguments are as for Net::HTTP::Proxy. - def initialize(proxy_addr=nil, proxy_port=nil, - proxy_user=nil, proxy_pass=nil) - @ca_file = nil - @proxy = Net::HTTP::Proxy(proxy_addr, proxy_port, proxy_user, proxy_pass) - @timeout = TIMEOUT - end - - def supports_ssl?(conn) - return conn.respond_to?(:use_ssl=) - end - - def make_http(uri) - http = @proxy.new(uri.host, uri.port) - http.read_timeout = @timeout - http.open_timeout = @timeout - return http - end - - def set_verified(conn, verify) - if verify - conn.verify_mode = OpenSSL::SSL::VERIFY_PEER - else - conn.verify_mode = OpenSSL::SSL::VERIFY_NONE - end - end - - def make_connection(uri) - conn = make_http(uri) - - if !conn.is_a?(Net::HTTP) - raise RuntimeError, sprintf("Expected Net::HTTP object from make_http; got %s", - conn.class) - end - - if uri.scheme == 'https' - if supports_ssl?(conn) - - conn.use_ssl = true - - if @ca_file - set_verified(conn, true) - conn.ca_file = @ca_file - else - Util.log("WARNING: making https request to #{uri} without verifying " + - "server certificate; no CA path was specified.") - set_verified(conn, false) - end - else - raise RuntimeError, "SSL support not found; cannot fetch #{uri}" - end - end - - return conn - end - - def fetch(url, body=nil, headers=nil, redirect_limit=REDIRECT_LIMIT) - unparsed_url = url.dup - url = URI::parse(url) - if url.nil? - raise FetchingError, "Invalid URL: #{unparsed_url}" - end - - headers ||= {} - headers['User-agent'] ||= USER_AGENT - headers['Range'] ||= "0-#{MAX_RESPONSE_KB*1024}" - - begin - conn = make_connection(url) - response = nil - - response = conn.start { - # Check the certificate against the URL's hostname - if supports_ssl?(conn) and conn.use_ssl? - conn.post_connection_check(url.host) - end - - if body.nil? - conn.request_get(url.request_uri, headers) - else - headers["Content-type"] ||= "application/x-www-form-urlencoded" - conn.request_post(url.request_uri, body, headers) - end - } - rescue RuntimeError => why - raise why - rescue OpenSSL::SSL::SSLError => why - raise SSLFetchingError, "Error connecting to SSL URL #{url}: #{why}" - rescue FetchingError => why - raise why - rescue Exception => why - # Things we've caught here include a Timeout::Error, which descends - # from SignalException. - raise FetchingError, "Error fetching #{url}: #{why}" - end - - case response - when Net::HTTPRedirection - if redirect_limit <= 0 - raise HTTPRedirectLimitReached.new( - "Too many redirects, not fetching #{response['location']}") - end - begin - return fetch(response['location'], body, headers, redirect_limit - 1) - rescue HTTPRedirectLimitReached => e - raise e - rescue FetchingError => why - raise FetchingError, "Error encountered in redirect from #{url}: #{why}" - end - else - return HTTPResponse._from_net_response(response, unparsed_url) - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/kvform.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/kvform.rb deleted file mode 100644 index c534d203..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/kvform.rb +++ /dev/null @@ -1,136 +0,0 @@ - -module OpenID - - class KVFormError < Exception - end - - module Util - - def Util.seq_to_kv(seq, strict=false) - # Represent a sequence of pairs of strings as newline-terminated - # key:value pairs. The pairs are generated in the order given. - # - # @param seq: The pairs - # - # returns a string representation of the sequence - err = lambda { |msg| - msg = "seq_to_kv warning: #{msg}: #{seq.inspect}" - if strict - raise KVFormError, msg - else - Util.log(msg) - end - } - - lines = [] - seq.each { |k, v| - if !k.is_a?(String) - err.call("Converting key to string: #{k.inspect}") - k = k.to_s - end - - if !k.index("\n").nil? - raise KVFormError, "Invalid input for seq_to_kv: key contains newline: #{k.inspect}" - end - - if !k.index(":").nil? - raise KVFormError, "Invalid input for seq_to_kv: key contains colon: #{k.inspect}" - end - - if k.strip() != k - err.call("Key has whitespace at beginning or end: #{k.inspect}") - end - - if !v.is_a?(String) - err.call("Converting value to string: #{v.inspect}") - v = v.to_s - end - - if !v.index("\n").nil? - raise KVFormError, "Invalid input for seq_to_kv: value contains newline: #{v.inspect}" - end - - if v.strip() != v - err.call("Value has whitespace at beginning or end: #{v.inspect}") - end - - lines << k + ":" + v + "\n" - } - - return lines.join("") - end - - def Util.kv_to_seq(data, strict=false) - # After one parse, seq_to_kv and kv_to_seq are inverses, with no - # warnings: - # - # seq = kv_to_seq(s) - # seq_to_kv(kv_to_seq(seq)) == seq - err = lambda { |msg| - msg = "kv_to_seq warning: #{msg}: #{data.inspect}" - if strict - raise KVFormError, msg - else - Util.log(msg) - end - } - - lines = data.split("\n") - if data.length == 0 - return [] - end - - if data[-1].chr != "\n" - err.call("Does not end in a newline") - # We don't expect the last element of lines to be an empty - # string because split() doesn't behave that way. - end - - pairs = [] - line_num = 0 - lines.each { |line| - line_num += 1 - - # Ignore blank lines - if line.strip() == "" - next - end - - pair = line.split(':', 2) - if pair.length == 2 - k, v = pair - k_s = k.strip() - if k_s != k - msg = "In line #{line_num}, ignoring leading or trailing whitespace in key #{k.inspect}" - err.call(msg) - end - - if k_s.length == 0 - err.call("In line #{line_num}, got empty key") - end - - v_s = v.strip() - if v_s != v - msg = "In line #{line_num}, ignoring leading or trailing whitespace in value #{v.inspect}" - err.call(msg) - end - - pairs << [k_s, v_s] - else - err.call("Line #{line_num} does not contain a colon") - end - } - - return pairs - end - - def Util.dict_to_kv(d) - return seq_to_kv(d.entries.sort) - end - - def Util.kv_to_dict(s) - seq = kv_to_seq(s) - return Hash[*seq.flatten] - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/kvpost.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/kvpost.rb deleted file mode 100644 index 1495afe7..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/kvpost.rb +++ /dev/null @@ -1,58 +0,0 @@ -require "openid/message" -require "openid/fetchers" - -module OpenID - # Exception that is raised when the server returns a 400 response - # code to a direct request. - class ServerError < OpenIDError - attr_reader :error_text, :error_code, :message - - def initialize(error_text, error_code, message) - super(error_text) - @error_text = error_text - @error_code = error_code - @message = message - end - - def self.from_message(msg) - error_text = msg.get_arg(OPENID_NS, 'error', - '') - error_code = msg.get_arg(OPENID_NS, 'error_code') - return self.new(error_text, error_code, msg) - end - end - - class KVPostNetworkError < OpenIDError - end - class HTTPStatusError < OpenIDError - end - - class Message - def self.from_http_response(response, server_url) - msg = self.from_kvform(response.body) - case response.code.to_i - when 200 - return msg - when 206 - return msg - when 400 - raise ServerError.from_message(msg) - else - error_message = "bad status code from server #{server_url}: "\ - "#{response.code}" - raise HTTPStatusError.new(error_message) - end - end - end - - # Send the message to the server via HTTP POST and receive and parse - # a response in KV Form - def self.make_kv_post(request_message, server_url) - begin - http_response = self.fetch(server_url, request_message.to_url_encoded) - rescue Exception - raise KVPostNetworkError.new("Unable to contact OpenID server: #{$!.to_s}") - end - return Message.from_http_response(http_response, server_url) - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/message.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/message.rb deleted file mode 100644 index 8700378b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/message.rb +++ /dev/null @@ -1,553 +0,0 @@ -require 'openid/util' -require 'openid/kvform' - -module OpenID - - IDENTIFIER_SELECT = 'http://specs.openid.net/auth/2.0/identifier_select' - - # URI for Simple Registration extension, the only commonly deployed - # OpenID 1.x extension, and so a special case. - SREG_URI = 'http://openid.net/sreg/1.0' - - # The OpenID 1.x namespace URIs - OPENID1_NS = 'http://openid.net/signon/1.0' - OPENID11_NS = 'http://openid.net/signon/1.1' - OPENID1_NAMESPACES = [OPENID1_NS, OPENID11_NS] - - # The OpenID 2.0 namespace URI - OPENID2_NS = 'http://specs.openid.net/auth/2.0' - - # The namespace consisting of pairs with keys that are prefixed with - # "openid." but not in another namespace. - NULL_NAMESPACE = :null_namespace - - # The null namespace, when it is an allowed OpenID namespace - OPENID_NS = :openid_namespace - - # The top-level namespace, excluding all pairs with keys that start - # with "openid." - BARE_NS = :bare_namespace - - # Limit, in bytes, of identity provider and return_to URLs, - # including response payload. See OpenID 1.1 specification, - # Appendix D. - OPENID1_URL_LIMIT = 2047 - - # All OpenID protocol fields. Used to check namespace aliases. - OPENID_PROTOCOL_FIELDS = [ - 'ns', 'mode', 'error', 'return_to', - 'contact', 'reference', 'signed', - 'assoc_type', 'session_type', - 'dh_modulus', 'dh_gen', - 'dh_consumer_public', 'claimed_id', - 'identity', 'realm', 'invalidate_handle', - 'op_endpoint', 'response_nonce', 'sig', - 'assoc_handle', 'trust_root', 'openid', - ] - - # Sentinel used for Message implementation to indicate that getArg - # should raise an exception instead of returning a default. - NO_DEFAULT = :no_default - - # Raised if the generic OpenID namespace is accessed when there - # is no OpenID namespace set for this message. - class UndefinedOpenIDNamespace < Exception; end - - # Raised when an alias or namespace URI has already been registered. - class NamespaceAliasRegistrationError < Exception; end - - # Raised if openid.ns is not a recognized value. - # See Message class variable @@allowed_openid_namespaces - class InvalidOpenIDNamespace < Exception; end - - class Message - attr_reader :namespaces - - # Raised when key lookup fails - class KeyNotFound < IndexError ; end - - # Namespace / alias registration map. See - # register_namespace_alias. - @@registered_aliases = {} - - # Registers a (namespace URI, alias) mapping in a global namespace - # alias map. Raises NamespaceAliasRegistrationError if either the - # namespace URI or alias has already been registered with a - # different value. This function is required if you want to use a - # namespace with an OpenID 1 message. - def Message.register_namespace_alias(namespace_uri, alias_) - if @@registered_aliases[alias_] == namespace_uri - return - end - - if @@registered_aliases.values.include?(namespace_uri) - raise NamespaceAliasRegistrationError, - 'Namespace uri #{namespace_uri} already registered' - end - - if @@registered_aliases.member?(alias_) - raise NamespaceAliasRegistrationError, - 'Alias #{alias_} already registered' - end - - @@registered_aliases[alias_] = namespace_uri - end - - @@allowed_openid_namespaces = [OPENID1_NS, OPENID2_NS, OPENID11_NS] - - # Raises InvalidNamespaceError if you try to instantiate a Message - # with a namespace not in the above allowed list - def initialize(openid_namespace=nil) - @args = {} - @namespaces = NamespaceMap.new - if openid_namespace - implicit = OPENID1_NAMESPACES.member? openid_namespace - self.set_openid_namespace(openid_namespace, implicit) - else - @openid_ns_uri = nil - end - end - - # Construct a Message containing a set of POST arguments. - # Raises InvalidNamespaceError if you try to instantiate a Message - # with a namespace not in the above allowed list - def Message.from_post_args(args) - m = Message.new - openid_args = {} - args.each do |key,value| - if value.is_a?(Array) - raise ArgumentError, "Query dict must have one value for each key, " + - "not lists of values. Query is #{args.inspect}" - end - - prefix, rest = key.split('.', 2) - - if prefix != 'openid' or rest.nil? - m.set_arg(BARE_NS, key, value) - else - openid_args[rest] = value - end - end - - m._from_openid_args(openid_args) - return m - end - - # Construct a Message from a parsed KVForm message. - # Raises InvalidNamespaceError if you try to instantiate a Message - # with a namespace not in the above allowed list - def Message.from_openid_args(openid_args) - m = Message.new - m._from_openid_args(openid_args) - return m - end - - # Raises InvalidNamespaceError if you try to instantiate a Message - # with a namespace not in the above allowed list - def _from_openid_args(openid_args) - ns_args = [] - - # resolve namespaces - openid_args.each { |rest, value| - ns_alias, ns_key = rest.split('.', 2) - if ns_key.nil? - ns_alias = NULL_NAMESPACE - ns_key = rest - end - - if ns_alias == 'ns' - @namespaces.add_alias(value, ns_key) - elsif ns_alias == NULL_NAMESPACE and ns_key == 'ns' - set_openid_namespace(value, false) - else - ns_args << [ns_alias, ns_key, value] - end - } - - # implicitly set an OpenID 1 namespace - unless get_openid_namespace - set_openid_namespace(OPENID1_NS, true) - end - - # put the pairs into the appropriate namespaces - ns_args.each { |ns_alias, ns_key, value| - ns_uri = @namespaces.get_namespace_uri(ns_alias) - unless ns_uri - ns_uri = _get_default_namespace(ns_alias) - unless ns_uri - ns_uri = get_openid_namespace - ns_key = "#{ns_alias}.#{ns_key}" - else - @namespaces.add_alias(ns_uri, ns_alias, true) - end - end - self.set_arg(ns_uri, ns_key, value) - } - end - - def _get_default_namespace(mystery_alias) - # only try to map an alias to a default if it's an - # OpenID 1.x namespace - if is_openid1 - @@registered_aliases[mystery_alias] - end - end - - def set_openid_namespace(openid_ns_uri, implicit) - if !@@allowed_openid_namespaces.include?(openid_ns_uri) - raise InvalidOpenIDNamespace, "Invalid null namespace: #{openid_ns_uri}" - end - @namespaces.add_alias(openid_ns_uri, NULL_NAMESPACE, implicit) - @openid_ns_uri = openid_ns_uri - end - - def get_openid_namespace - return @openid_ns_uri - end - - def is_openid1 - return OPENID1_NAMESPACES.member?(@openid_ns_uri) - end - - def is_openid2 - return @openid_ns_uri == OPENID2_NS - end - - # Create a message from a KVForm string - def Message.from_kvform(kvform_string) - return Message.from_openid_args(Util.kv_to_dict(kvform_string)) - end - - def copy - return Marshal.load(Marshal.dump(self)) - end - - # Return all arguments with "openid." in from of namespaced arguments. - def to_post_args - args = {} - - # add namespace defs to the output - @namespaces.each { |ns_uri, ns_alias| - if @namespaces.implicit?(ns_uri) - next - end - if ns_alias == NULL_NAMESPACE - ns_key = 'openid.ns' - else - ns_key = 'openid.ns.' + ns_alias - end - args[ns_key] = ns_uri - } - - @args.each { |k, value| - ns_uri, ns_key = k - key = get_key(ns_uri, ns_key) - args[key] = value - } - - return args - end - - # Return all namespaced arguments, failing if any non-namespaced arguments - # exist. - def to_args - post_args = self.to_post_args - kvargs = {} - post_args.each { |k,v| - if !k.starts_with?('openid.') - raise ArgumentError, "This message can only be encoded as a POST, because it contains arguments that are not prefixed with 'openid.'" - else - kvargs[k[7..-1]] = v - end - } - return kvargs - end - - # Generate HTML form markup that contains the values in this - # message, to be HTTP POSTed as x-www-form-urlencoded UTF-8. - def to_form_markup(action_url, form_tag_attrs=nil, submit_text='Continue') - form_tag_attr_map = {} - - if form_tag_attrs - form_tag_attrs.each { |name, attr| - form_tag_attr_map[name] = attr - } - end - - form_tag_attr_map['action'] = action_url - form_tag_attr_map['method'] = 'post' - form_tag_attr_map['accept-charset'] = 'UTF-8' - form_tag_attr_map['enctype'] = 'application/x-www-form-urlencoded' - - markup = "

    #{key} not in this message" - else - default - end - } - end - - # Get the arguments that are defined for this namespace URI. - def get_args(namespace) - namespace = _fix_ns(namespace) - args = {} - @args.each { |k,v| - pair_ns, ns_key = k - args[ns_key] = v if pair_ns == namespace - } - return args - end - - # Set multiple key/value pairs in one call. - def update_args(namespace, updates) - namespace = _fix_ns(namespace) - updates.each {|k,v| set_arg(namespace, k, v)} - end - - # Set a single argument in this namespace - def set_arg(namespace, key, value) - namespace = _fix_ns(namespace) - @args[[namespace, key].freeze] = value - if namespace != BARE_NS - @namespaces.add(namespace) - end - end - - # Remove a single argument from this namespace. - def del_arg(namespace, key) - namespace = _fix_ns(namespace) - _key = [namespace, key] - @args.delete(_key) - end - - def ==(other) - other.is_a?(self.class) && @args == other.instance_eval { @args } - end - - def get_aliased_arg(aliased_key, default=nil) - if aliased_key == 'ns' - return get_openid_namespace() - end - - ns_alias, key = aliased_key.split('.', 2) - if ns_alias == 'ns' - uri = @namespaces.get_namespace_uri(key) - if uri.nil? and default == NO_DEFAULT - raise KeyNotFound, "Namespace #{key} not defined when looking "\ - "for #{aliased_key}" - else - return (uri.nil? ? default : uri) - end - end - - if key.nil? - key = aliased_key - ns = nil - else - ns = @namespaces.get_namespace_uri(ns_alias) - end - - if ns.nil? - key = aliased_key - ns = get_openid_namespace - end - - return get_arg(ns, key, default) - end - end - - - # Maintains a bidirectional map between namespace URIs and aliases. - class NamespaceMap - - def initialize - @alias_to_namespace = {} - @namespace_to_alias = {} - @implicit_namespaces = [] - end - - def get_alias(namespace_uri) - @namespace_to_alias[namespace_uri] - end - - def get_namespace_uri(namespace_alias) - @alias_to_namespace[namespace_alias] - end - - # Add an alias from this namespace URI to the alias. - def add_alias(namespace_uri, desired_alias, implicit=false) - # Check that desired_alias is not an openid protocol field as - # per the spec. - Util.assert(!OPENID_PROTOCOL_FIELDS.include?(desired_alias), - "#{desired_alias} is not an allowed namespace alias") - - # check that there is not a namespace already defined for the - # desired alias - current_namespace_uri = @alias_to_namespace.fetch(desired_alias, nil) - if current_namespace_uri and current_namespace_uri != namespace_uri - raise IndexError, "Cannot map #{namespace_uri} to alias #{desired_alias}. #{current_namespace_uri} is already mapped to alias #{desired_alias}" - end - - # Check that desired_alias does not contain a period as per the - # spec. - if desired_alias.is_a?(String) - Util.assert(desired_alias.index('.').nil?, - "#{desired_alias} must not contain a dot") - end - - # check that there is not already a (different) alias for this - # namespace URI. - _alias = @namespace_to_alias[namespace_uri] - if _alias and _alias != desired_alias - raise IndexError, "Cannot map #{namespace_uri} to alias #{desired_alias}. It is already mapped to alias #{_alias}" - end - - @alias_to_namespace[desired_alias] = namespace_uri - @namespace_to_alias[namespace_uri] = desired_alias - @implicit_namespaces << namespace_uri if implicit - return desired_alias - end - - # Add this namespace URI to the mapping, without caring what alias - # it ends up with. - def add(namespace_uri) - # see if this namepace is already mapped to an alias - _alias = @namespace_to_alias[namespace_uri] - return _alias if _alias - - # Fall back to generating a numberical alias - i = 0 - while true - _alias = 'ext' + i.to_s - begin - add_alias(namespace_uri, _alias) - rescue IndexError - i += 1 - else - return _alias - end - end - - raise StandardError, 'Unreachable' - end - - def member?(namespace_uri) - @namespace_to_alias.has_key?(namespace_uri) - end - - def each - @namespace_to_alias.each {|k,v| yield k,v} - end - - def namespace_uris - # Return an iterator over the namespace URIs - return @namespace_to_alias.keys() - end - - def implicit?(namespace_uri) - return @implicit_namespaces.member?(namespace_uri) - end - - def aliases - # Return an iterator over the aliases - return @alias_to_namespace.keys() - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/protocolerror.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/protocolerror.rb deleted file mode 100644 index 2aad0e4a..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/protocolerror.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'openid/util' - -module OpenID - - # An error in the OpenID protocol - class ProtocolError < OpenIDError - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/server.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/server.rb deleted file mode 100644 index 53aa68a2..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/server.rb +++ /dev/null @@ -1,1544 +0,0 @@ - -require 'openid/cryptutil' -require 'openid/util' -require 'openid/dh' -require 'openid/store/nonce' -require 'openid/trustroot' -require 'openid/association' -require 'openid/message' - -require 'time' - -module OpenID - - module Server - - HTTP_OK = 200 - HTTP_REDIRECT = 302 - HTTP_ERROR = 400 - - BROWSER_REQUEST_MODES = ['checkid_setup', 'checkid_immediate'] - - ENCODE_KVFORM = ['kvform'].freeze - ENCODE_URL = ['URL/redirect'].freeze - ENCODE_HTML_FORM = ['HTML form'].freeze - - UNUSED = nil - - class OpenIDRequest - attr_accessor :message, :mode - - # I represent an incoming OpenID request. - # - # Attributes: - # mode:: The "openid.mode" of this request - def initialize - @mode = nil - @message = nil - end - - def namespace - if @message.nil? - raise RuntimeError, "Request has no message" - else - return @message.get_openid_namespace - end - end - end - - # A request to verify the validity of a previous response. - # - # See OpenID Specs, Verifying Directly with the OpenID Provider - # - class CheckAuthRequest < OpenIDRequest - - # The association handle the response was signed with. - attr_accessor :assoc_handle - - # The message with the signature which wants checking. - attr_accessor :signed - - # An association handle the client is asking about the validity - # of. May be nil. - attr_accessor :invalidate_handle - - attr_accessor :sig - - # Construct me. - # - # These parameters are assigned directly as class attributes. - # - # Parameters: - # assoc_handle:: the association handle for this request - # signed:: The signed message - # invalidate_handle:: An association handle that the relying - # party is checking to see if it is invalid - def initialize(assoc_handle, signed, invalidate_handle=nil) - super() - - @mode = "check_authentication" - @required_fields = ["identity", "return_to", "response_nonce"].freeze - - @sig = nil - @assoc_handle = assoc_handle - @signed = signed - @invalidate_handle = invalidate_handle - end - - # Construct me from an OpenID::Message. - def self.from_message(message, op_endpoint=UNUSED) - assoc_handle = message.get_arg(OPENID_NS, 'assoc_handle') - invalidate_handle = message.get_arg(OPENID_NS, 'invalidate_handle') - - signed = message.copy() - # openid.mode is currently check_authentication because - # that's the mode of this request. But the signature - # was made on something with a different openid.mode. - # http://article.gmane.org/gmane.comp.web.openid.general/537 - if signed.has_key?(OPENID_NS, "mode") - signed.set_arg(OPENID_NS, "mode", "id_res") - end - - obj = self.new(assoc_handle, signed, invalidate_handle) - obj.message = message - obj.sig = message.get_arg(OPENID_NS, 'sig') - - if !obj.assoc_handle or - !obj.sig - msg = sprintf("%s request missing required parameter from message %s", - obj.mode, message) - raise ProtocolError.new(message, msg) - end - - return obj - end - - # Respond to this request. - # - # Given a Signatory, I can check the validity of the signature - # and the invalidate_handle. I return a response with an - # is_valid (and, if appropriate invalidate_handle) field. - def answer(signatory) - is_valid = signatory.verify(@assoc_handle, @signed) - # Now invalidate that assoc_handle so it this checkAuth - # message cannot be replayed. - signatory.invalidate(@assoc_handle, dumb=true) - response = OpenIDResponse.new(self) - valid_str = is_valid ? "true" : "false" - response.fields.set_arg(OPENID_NS, 'is_valid', valid_str) - - if @invalidate_handle - assoc = signatory.get_association(@invalidate_handle, false) - if !assoc - response.fields.set_arg( - OPENID_NS, 'invalidate_handle', @invalidate_handle) - end - end - - return response - end - - def to_s - ih = nil - - if @invalidate_handle - ih = sprintf(" invalidate? %s", @invalidate_handle) - else - ih = "" - end - - s = sprintf("<%s handle: %s sig: %s: signed: %s%s>", - self.class, @assoc_handle, - @sig, @signed, ih) - return s - end - end - - class BaseServerSession - attr_reader :session_type - - def initialize(session_type, allowed_assoc_types) - @session_type = session_type - @allowed_assoc_types = allowed_assoc_types.dup.freeze - end - - def allowed_assoc_type?(typ) - @allowed_assoc_types.member?(typ) - end - end - - # An object that knows how to handle association requests with - # no session type. - # - # See OpenID Specs, Section 8: Establishing Associations - # - class PlainTextServerSession < BaseServerSession - # The session_type for this association session. There is no - # type defined for plain-text in the OpenID specification, so we - # use 'no-encryption'. - attr_reader :session_type - - def initialize - super('no-encryption', ['HMAC-SHA1', 'HMAC-SHA256']) - end - - def self.from_message(unused_request) - return self.new - end - - def answer(secret) - return {'mac_key' => Util.to_base64(secret)} - end - end - - # An object that knows how to handle association requests with the - # Diffie-Hellman session type. - # - # See OpenID Specs, Section 8: Establishing Associations - # - class DiffieHellmanSHA1ServerSession < BaseServerSession - - # The Diffie-Hellman algorithm values for this request - attr_accessor :dh - - # The public key sent by the consumer in the associate request - attr_accessor :consumer_pubkey - - # The session_type for this association session. - attr_reader :session_type - - def initialize(dh, consumer_pubkey) - super('DH-SHA1', ['HMAC-SHA1']) - - @hash_func = CryptUtil.method('sha1') - @dh = dh - @consumer_pubkey = consumer_pubkey - end - - # Construct me from OpenID Message - # - # Raises ProtocolError when parameters required to establish the - # session are missing. - def self.from_message(message) - dh_modulus = message.get_arg(OPENID_NS, 'dh_modulus') - dh_gen = message.get_arg(OPENID_NS, 'dh_gen') - if ((!dh_modulus and dh_gen) or - (!dh_gen and dh_modulus)) - - if !dh_modulus - missing = 'modulus' - else - missing = 'generator' - end - - raise ProtocolError.new(message, - sprintf('If non-default modulus or generator is ' + - 'supplied, both must be supplied. Missing %s', - missing)) - end - - if dh_modulus or dh_gen - dh_modulus = CryptUtil.base64_to_num(dh_modulus) - dh_gen = CryptUtil.base64_to_num(dh_gen) - dh = DiffieHellman.new(dh_modulus, dh_gen) - else - dh = DiffieHellman.from_defaults() - end - - consumer_pubkey = message.get_arg(OPENID_NS, 'dh_consumer_public') - if !consumer_pubkey - raise ProtocolError.new(message, - sprintf("Public key for DH-SHA1 session " + - "not found in message %s", message)) - end - - consumer_pubkey = CryptUtil.base64_to_num(consumer_pubkey) - - return self.new(dh, consumer_pubkey) - end - - def answer(secret) - mac_key = @dh.xor_secret(@hash_func, - @consumer_pubkey, - secret) - return { - 'dh_server_public' => CryptUtil.num_to_base64(@dh.public), - 'enc_mac_key' => Util.to_base64(mac_key), - } - end - end - - class DiffieHellmanSHA256ServerSession < DiffieHellmanSHA1ServerSession - def initialize(*args) - super(*args) - @session_type = 'DH-SHA256' - @hash_func = CryptUtil.method('sha256') - @allowed_assoc_types = ['HMAC-SHA256'].freeze - end - end - - # A request to establish an association. - # - # See OpenID Specs, Section 8: Establishing Associations - # - class AssociateRequest < OpenIDRequest - # An object that knows how to handle association requests of a - # certain type. - attr_accessor :session - - # The type of association. Supported values include HMAC-SHA256 - # and HMAC-SHA1 - attr_accessor :assoc_type - - @@session_classes = { - 'no-encryption' => PlainTextServerSession, - 'DH-SHA1' => DiffieHellmanSHA1ServerSession, - 'DH-SHA256' => DiffieHellmanSHA256ServerSession, - } - - # Construct me. - # - # The session is assigned directly as a class attribute. See my - # class documentation for its description. - def initialize(session, assoc_type) - super() - @session = session - @assoc_type = assoc_type - - @mode = "associate" - end - - # Construct me from an OpenID Message. - def self.from_message(message, op_endpoint=UNUSED) - if message.is_openid1() - session_type = message.get_arg(OPENID_NS, 'session_type') - if session_type == 'no-encryption' - Util.log('Received OpenID 1 request with a no-encryption ' + - 'association session type. Continuing anyway.') - elsif !session_type - session_type = 'no-encryption' - end - else - session_type = message.get_arg(OPENID2_NS, 'session_type') - if !session_type - raise ProtocolError.new(message, - text="session_type missing from request") - end - end - - session_class = @@session_classes[session_type] - - if !session_class - raise ProtocolError.new(message, - sprintf("Unknown session type %s", session_type)) - end - - begin - session = session_class.from_message(message) - rescue ArgumentError => why - # XXX - raise ProtocolError.new(message, - sprintf('Error parsing %s session: %s', - session_type, why)) - end - - assoc_type = message.get_arg(OPENID_NS, 'assoc_type', 'HMAC-SHA1') - if !session.allowed_assoc_type?(assoc_type) - msg = sprintf('Session type %s does not support association type %s', - session_type, assoc_type) - raise ProtocolError.new(message, msg) - end - - obj = self.new(session, assoc_type) - obj.message = message - return obj - end - - # Respond to this request with an association. - # - # assoc:: The association to send back. - # - # Returns a response with the association information, encrypted - # to the consumer's public key if appropriate. - def answer(assoc) - response = OpenIDResponse.new(self) - response.fields.update_args(OPENID_NS, { - 'expires_in' => sprintf('%d', assoc.expires_in()), - 'assoc_type' => @assoc_type, - 'assoc_handle' => assoc.handle, - }) - response.fields.update_args(OPENID_NS, - @session.answer(assoc.secret)) - unless (@session.session_type == 'no-encryption' and - @message.is_openid1) - response.fields.set_arg( - OPENID_NS, 'session_type', @session.session_type) - end - - return response - end - - # Respond to this request indicating that the association type - # or association session type is not supported. - def answer_unsupported(message, preferred_association_type=nil, - preferred_session_type=nil) - if @message.is_openid1() - raise ProtocolError.new(@message) - end - - response = OpenIDResponse.new(self) - response.fields.set_arg(OPENID_NS, 'error_code', 'unsupported-type') - response.fields.set_arg(OPENID_NS, 'error', message) - - if preferred_association_type - response.fields.set_arg( - OPENID_NS, 'assoc_type', preferred_association_type) - end - - if preferred_session_type - response.fields.set_arg( - OPENID_NS, 'session_type', preferred_session_type) - end - - return response - end - end - - # A request to confirm the identity of a user. - # - # This class handles requests for openid modes - # +checkid_immediate+ and +checkid_setup+ . - class CheckIDRequest < OpenIDRequest - - # Provided in smart mode requests, a handle for a previously - # established association. nil for dumb mode requests. - attr_accessor :assoc_handle - - # Is this an immediate-mode request? - attr_accessor :immediate - - # The URL to send the user agent back to to reply to this - # request. - attr_accessor :return_to - - # The OP-local identifier being checked. - attr_accessor :identity - - # The claimed identifier. Not present in OpenID 1.x - # messages. - attr_accessor :claimed_id - - # This URL identifies the party making the request, and the user - # will use that to make her decision about what answer she - # trusts them to have. Referred to as "realm" in OpenID 2.0. - attr_accessor :trust_root - - # mode:: +checkid_immediate+ or +checkid_setup+ - attr_accessor :mode - - attr_accessor :op_endpoint - - # These parameters are assigned directly as attributes, - # see the #CheckIDRequest class documentation for their - # descriptions. - # - # Raises #MalformedReturnURL when the +return_to+ URL is not - # a URL. - def initialize(identity, return_to, op_endpoint, trust_root=nil, - immediate=false, assoc_handle=nil) - @assoc_handle = assoc_handle - @identity = identity - @claimed_id = identity - @return_to = return_to - @trust_root = trust_root or return_to - @op_endpoint = op_endpoint - @message = nil - - if immediate - @immediate = true - @mode = "checkid_immediate" - else - @immediate = false - @mode = "checkid_setup" - end - - if @return_to and - !TrustRoot::TrustRoot.parse(@return_to) - raise MalformedReturnURL.new(nil, @return_to) - end - - if !trust_root_valid() - raise UntrustedReturnURL.new(nil, @return_to, @trust_root) - end - end - - # Construct me from an OpenID message. - # - # message:: An OpenID checkid_* request Message - # - # op_endpoint:: The endpoint URL of the server that this - # message was sent to. - # - # Raises: - # ProtocolError:: When not all required parameters are present - # in the message. - # - # MalformedReturnURL:: When the +return_to+ URL is not a URL. - # - # UntrustedReturnURL:: When the +return_to+ URL is - # outside the +trust_root+. - def self.from_message(message, op_endpoint) - obj = self.allocate - obj.message = message - obj.op_endpoint = op_endpoint - mode = message.get_arg(OPENID_NS, 'mode') - if mode == "checkid_immediate" - obj.immediate = true - obj.mode = "checkid_immediate" - else - obj.immediate = false - obj.mode = "checkid_setup" - end - - obj.return_to = message.get_arg(OPENID_NS, 'return_to') - if message.is_openid1 and !obj.return_to - msg = sprintf("Missing required field 'return_to' from %s", - message) - raise ProtocolError.new(message, msg) - end - - obj.identity = message.get_arg(OPENID_NS, 'identity') - obj.claimed_id = message.get_arg(OPENID_NS, 'claimed_id') - if message.is_openid1() - if !obj.identity - s = "OpenID 1 message did not contain openid.identity" - raise ProtocolError.new(message, s) - end - else - if obj.identity and not obj.claimed_id - s = ("OpenID 2.0 message contained openid.identity but not " + - "claimed_id") - raise ProtocolError.new(message, s) - elsif obj.claimed_id and not obj.identity - s = ("OpenID 2.0 message contained openid.claimed_id but not " + - "identity") - raise ProtocolError.new(message, s) - end - end - - # There's a case for making self.trust_root be a TrustRoot - # here. But if TrustRoot isn't currently part of the "public" - # API, I'm not sure it's worth doing. - if message.is_openid1 - trust_root_param = 'trust_root' - else - trust_root_param = 'realm' - end - trust_root = message.get_arg(OPENID_NS, trust_root_param) - trust_root = obj.return_to if (trust_root.nil? || trust_root.empty?) - obj.trust_root = trust_root - - if !message.is_openid1 and !obj.return_to and !obj.trust_root - raise ProtocolError.new(message, "openid.realm required when " + - "openid.return_to absent") - end - - obj.assoc_handle = message.get_arg(OPENID_NS, 'assoc_handle') - - # Using TrustRoot.parse here is a bit misleading, as we're not - # parsing return_to as a trust root at all. However, valid - # URLs are valid trust roots, so we can use this to get an - # idea if it is a valid URL. Not all trust roots are valid - # return_to URLs, however (particularly ones with wildcards), - # so this is still a little sketchy. - if obj.return_to and \ - !TrustRoot::TrustRoot.parse(obj.return_to) - raise MalformedReturnURL.new(message, obj.return_to) - end - - # I first thought that checking to see if the return_to is - # within the trust_root is premature here, a - # logic-not-decoding thing. But it was argued that this is - # really part of data validation. A request with an invalid - # trust_root/return_to is broken regardless of application, - # right? - if !obj.trust_root_valid() - raise UntrustedReturnURL.new(message, obj.return_to, obj.trust_root) - end - - return obj - end - - # Is the identifier to be selected by the IDP? - def id_select - # So IDPs don't have to import the constant - return @identity == IDENTIFIER_SELECT - end - - # Is my return_to under my trust_root? - def trust_root_valid - if !@trust_root - return true - end - - tr = TrustRoot::TrustRoot.parse(@trust_root) - if !tr - raise MalformedTrustRoot.new(@message, @trust_root) - end - - if @return_to - return tr.validate_url(@return_to) - else - return true - end - end - - # Does the relying party publish the return_to URL for this - # response under the realm? It is up to the provider to set a - # policy for what kinds of realms should be allowed. This - # return_to URL verification reduces vulnerability to - # data-theft attacks based on open proxies, - # corss-site-scripting, or open redirectors. - # - # This check should only be performed after making sure that - # the return_to URL matches the realm. - # - # Raises DiscoveryFailure if the realm - # URL does not support Yadis discovery (and so does not - # support the verification process). - # - # Returns true if the realm publishes a document with the - # return_to URL listed - def return_to_verified - return TrustRoot.verify_return_to(@trust_root, @return_to) - end - - # Respond to this request. - # - # allow:: Allow this user to claim this identity, and allow the - # consumer to have this information? - # - # server_url:: DEPRECATED. Passing op_endpoint to the - # #Server constructor makes this optional. - # - # When an OpenID 1.x immediate mode request does - # not succeed, it gets back a URL where the request - # may be carried out in a not-so-immediate fashion. - # Pass my URL in here (the fully qualified address - # of this server's endpoint, i.e. - # http://example.com/server), and I will - # use it as a base for the URL for a new request. - # - # Optional for requests where - # #CheckIDRequest.immediate is false or +allow+ is - # true. - # - # identity:: The OP-local identifier to answer with. Only for use - # when the relying party requested identifier selection. - # - # claimed_id:: The claimed identifier to answer with, - # for use with identifier selection in the case where the - # claimed identifier and the OP-local identifier differ, - # i.e. when the claimed_id uses delegation. - # - # If +identity+ is provided but this is not, - # +claimed_id+ will default to the value of +identity+. - # When answering requests that did not ask for identifier - # selection, the response +claimed_id+ will default to - # that of the request. - # - # This parameter is new in OpenID 2.0. - # - # Returns an OpenIDResponse object containing a OpenID id_res message. - # - # Raises NoReturnToError if the return_to is missing. - # - # Version 2.0 deprecates +server_url+ and adds +claimed_id+. - def answer(allow, server_url=nil, identity=nil, claimed_id=nil) - if !@return_to - raise NoReturnToError - end - - if !server_url - if @message.is_openid2 and !@op_endpoint - # In other words, that warning I raised in - # Server.__init__? You should pay attention to it now. - raise RuntimeError, ("#{self} should be constructed with "\ - "op_endpoint to respond to OpenID 2.0 "\ - "messages.") - end - - server_url = @op_endpoint - end - - if allow - mode = 'id_res' - elsif @message.is_openid1 - if @immediate - mode = 'id_res' - else - mode = 'cancel' - end - else - if @immediate - mode = 'setup_needed' - else - mode = 'cancel' - end - end - - response = OpenIDResponse.new(self) - - if claimed_id and @message.is_openid1 - raise VersionError, ("claimed_id is new in OpenID 2.0 and not "\ - "available for #{@message.get_openid_namespace}") - end - - if identity and !claimed_id - claimed_id = identity - end - - if allow - if @identity == IDENTIFIER_SELECT - if !identity - raise ArgumentError, ("This request uses IdP-driven "\ - "identifier selection.You must supply "\ - "an identifier in the response.") - end - - response_identity = identity - response_claimed_id = claimed_id - - elsif @identity - if identity and (@identity != identity) - raise ArgumentError, ("Request was for identity #{@identity}, "\ - "cannot reply with identity #{identity}") - end - - response_identity = @identity - response_claimed_id = @claimed_id - else - if identity - raise ArgumentError, ("This request specified no identity "\ - "and you supplied #{identity}") - end - response_identity = nil - end - - if @message.is_openid1 and !response_identity - raise ArgumentError, ("Request was an OpenID 1 request, so "\ - "response must include an identifier.") - end - - response.fields.update_args(OPENID_NS, { - 'mode' => mode, - 'op_endpoint' => server_url, - 'return_to' => @return_to, - 'response_nonce' => Nonce.mk_nonce(), - }) - - if response_identity - response.fields.set_arg(OPENID_NS, 'identity', response_identity) - if @message.is_openid2 - response.fields.set_arg(OPENID_NS, - 'claimed_id', response_claimed_id) - end - end - else - response.fields.set_arg(OPENID_NS, 'mode', mode) - if @immediate - if @message.is_openid1 and !server_url - raise ArgumentError, ("setup_url is required for allow=false "\ - "in OpenID 1.x immediate mode.") - end - - # Make a new request just like me, but with - # immediate=false. - setup_request = self.class.new(@identity, @return_to, - @op_endpoint, @trust_root, false, - @assoc_handle) - setup_request.message = Message.new(@message.get_openid_namespace) - setup_url = setup_request.encode_to_url(server_url) - response.fields.set_arg(OPENID_NS, 'user_setup_url', setup_url) - end - end - - return response - end - - def encode_to_url(server_url) - # Encode this request as a URL to GET. - # - # server_url:: The URL of the OpenID server to make this - # request of. - if !@return_to - raise NoReturnToError - end - - # Imported from the alternate reality where these classes are - # used in both the client and server code, so Requests are - # Encodable too. That's right, code imported from alternate - # realities all for the love of you, id_res/user_setup_url. - q = {'mode' => @mode, - 'identity' => @identity, - 'claimed_id' => @claimed_id, - 'return_to' => @return_to} - - if @trust_root - if @message.is_openid1 - q['trust_root'] = @trust_root - else - q['realm'] = @trust_root - end - end - - if @assoc_handle - q['assoc_handle'] = @assoc_handle - end - - response = Message.new(@message.get_openid_namespace) - response.update_args(@message.get_openid_namespace, q) - return response.to_url(server_url) - end - - def cancel_url - # Get the URL to cancel this request. - # - # Useful for creating a "Cancel" button on a web form so that - # operation can be carried out directly without another trip - # through the server. - # - # (Except you may want to make another trip through the - # server so that it knows that the user did make a decision.) - # - # Returns a URL as a string. - if !@return_to - raise NoReturnToError - end - - if @immediate - raise ArgumentError.new("Cancel is not an appropriate response to " + - "immediate mode requests.") - end - - response = Message.new(@message.get_openid_namespace) - response.set_arg(OPENID_NS, 'mode', 'cancel') - return response.to_url(@return_to) - end - - def to_s - return sprintf('<%s id:%s im:%s tr:%s ah:%s>', self.class, - @identity, - @immediate, - @trust_root, - @assoc_handle) - end - end - - # I am a response to an OpenID request. - # - # Attributes: - # signed:: A list of the names of the fields which should be signed. - # - # Implementer's note: In a more symmetric client/server - # implementation, there would be more types of #OpenIDResponse - # object and they would have validated attributes according to - # the type of response. But as it is, Response objects in a - # server are basically write-only, their only job is to go out - # over the wire, so this is just a loose wrapper around - # #OpenIDResponse.fields. - class OpenIDResponse - # The #OpenIDRequest I respond to. - attr_accessor :request - - # An #OpenID::Message with the data to be returned. - # Keys are parameter names with no - # leading openid. e.g. identity and mac_key - # never openid.identity. - attr_accessor :fields - - def initialize(request) - # Make a response to an OpenIDRequest. - @request = request - @fields = Message.new(request.namespace) - end - - def to_s - return sprintf("%s for %s: %s", - self.class, - @request.class, - @fields) - end - - # form_tag_attrs is a hash of attributes to be added to the form - # tag. 'accept-charset' and 'enctype' have defaults that can be - # overridden. If a value is supplied for 'action' or 'method', - # it will be replaced. - # Returns the form markup for this response. - def to_form_markup(form_tag_attrs=nil) - return @fields.to_form_markup(@request.return_to, form_tag_attrs) - end - - # Wraps the form tag from to_form_markup in a complete HTML document - # that uses javascript to autosubmit the form. - def to_html(form_tag_attrs=nil) - return Util.auto_submit_html(to_form_markup(form_tag_attrs)) - end - - def render_as_form - # Returns true if this response's encoding is - # ENCODE_HTML_FORM. Convenience method for server authors. - return self.which_encoding == ENCODE_HTML_FORM - end - - def needs_signing - # Does this response require signing? - return @fields.get_arg(OPENID_NS, 'mode') == 'id_res' - end - - # implements IEncodable - - def which_encoding - # How should I be encoded? - # returns one of ENCODE_URL or ENCODE_KVFORM. - if BROWSER_REQUEST_MODES.member?(@request.mode) - if @fields.is_openid2 and - encode_to_url.length > OPENID1_URL_LIMIT - return ENCODE_HTML_FORM - else - return ENCODE_URL - end - else - return ENCODE_KVFORM - end - end - - def encode_to_url - # Encode a response as a URL for the user agent to GET. - # You will generally use this URL with a HTTP redirect. - return @fields.to_url(@request.return_to) - end - - def add_extension(extension_response) - # Add an extension response to this response message. - # - # extension_response:: An object that implements the - # #OpenID::Extension interface for adding arguments to an OpenID - # message. - extension_response.to_message(@fields) - end - - def encode_to_kvform - # Encode a response in key-value colon/newline format. - # - # This is a machine-readable format used to respond to - # messages which came directly from the consumer and not - # through the user agent. - # - # see: OpenID Specs, - # Key-Value Colon/Newline format - return @fields.to_kvform - end - - def copy - return Marshal.load(Marshal.dump(self)) - end - end - - # I am a response to an OpenID request in terms a web server - # understands. - # - # I generally come from an #Encoder, either directly or from - # #Server.encodeResponse. - class WebResponse - - # The HTTP code of this response as an integer. - attr_accessor :code - - # #Hash of headers to include in this response. - attr_accessor :headers - - # The body of this response. - attr_accessor :body - - def initialize(code=HTTP_OK, headers=nil, body="") - # Construct me. - # - # These parameters are assigned directly as class attributes, - # see my class documentation for their - # descriptions. - @code = code - if headers - @headers = headers - else - @headers = {} - end - @body = body - end - end - - # I sign things. - # - # I also check signatures. - # - # All my state is encapsulated in a store, which means I'm not - # generally pickleable but I am easy to reconstruct. - class Signatory - # The number of seconds a secret remains valid. Defaults to 14 days. - attr_accessor :secret_lifetime - - # keys have a bogus server URL in them because the filestore - # really does expect that key to be a URL. This seems a little - # silly for the server store, since I expect there to be only - # one server URL. - @@_normal_key = 'http://localhost/|normal' - @@_dumb_key = 'http://localhost/|dumb' - - def self._normal_key - @@_normal_key - end - - def self._dumb_key - @@_dumb_key - end - - attr_accessor :store - - # Create a new Signatory. store is The back-end where my - # associations are stored. - def initialize(store) - Util.assert(store) - @store = store - @secret_lifetime = 14 * 24 * 60 * 60 - end - - # Verify that the signature for some data is valid. - def verify(assoc_handle, message) - assoc = get_association(assoc_handle, true) - if !assoc - Util.log(sprintf("failed to get assoc with handle %s to verify " + - "message %s", assoc_handle, message)) - return false - end - - begin - valid = assoc.check_message_signature(message) - rescue StandardError => ex - Util.log(sprintf("Error in verifying %s with %s: %s", - message, assoc, ex)) - return false - end - - return valid - end - - # Sign a response. - # - # I take an OpenIDResponse, create a signature for everything in - # its signed list, and return a new copy of the response object - # with that signature included. - def sign(response) - signed_response = response.copy - assoc_handle = response.request.assoc_handle - if assoc_handle - # normal mode disabling expiration check because even if the - # association is expired, we still need to know some - # properties of the association so that we may preserve - # those properties when creating the fallback association. - assoc = get_association(assoc_handle, false, false) - - if !assoc or assoc.expires_in <= 0 - # fall back to dumb mode - signed_response.fields.set_arg( - OPENID_NS, 'invalidate_handle', assoc_handle) - assoc_type = assoc ? assoc.assoc_type : 'HMAC-SHA1' - if assoc and assoc.expires_in <= 0 - # now do the clean-up that the disabled checkExpiration - # code didn't get to do. - invalidate(assoc_handle, false) - end - assoc = create_association(true, assoc_type) - end - else - # dumb mode. - assoc = create_association(true) - end - - begin - signed_response.fields = assoc.sign_message(signed_response.fields) - rescue KVFormError => err - raise EncodingError, err - end - return signed_response - end - - # Make a new association. - def create_association(dumb=true, assoc_type='HMAC-SHA1') - secret = CryptUtil.random_string(OpenID.get_secret_size(assoc_type)) - uniq = Util.to_base64(CryptUtil.random_string(4)) - handle = sprintf('{%s}{%x}{%s}', assoc_type, Time.now.to_i, uniq) - - assoc = Association.from_expires_in( - secret_lifetime, handle, secret, assoc_type) - - if dumb - key = @@_dumb_key - else - key = @@_normal_key - end - - @store.store_association(key, assoc) - return assoc - end - - # Get the association with the specified handle. - def get_association(assoc_handle, dumb, checkExpiration=true) - # Hmm. We've created an interface that deals almost entirely - # with assoc_handles. The only place outside the Signatory - # that uses this (and thus the only place that ever sees - # Association objects) is when creating a response to an - # association request, as it must have the association's - # secret. - - if !assoc_handle - raise ArgumentError.new("assoc_handle must not be None") - end - - if dumb - key = @@_dumb_key - else - key = @@_normal_key - end - - assoc = @store.get_association(key, assoc_handle) - if assoc and assoc.expires_in <= 0 - Util.log(sprintf("requested %sdumb key %s is expired (by %s seconds)", - (!dumb) ? 'not-' : '', - assoc_handle, assoc.expires_in)) - if checkExpiration - @store.remove_association(key, assoc_handle) - assoc = nil - end - end - - return assoc - end - - # Invalidates the association with the given handle. - def invalidate(assoc_handle, dumb) - if dumb - key = @@_dumb_key - else - key = @@_normal_key - end - - @store.remove_association(key, assoc_handle) - end - end - - # I encode responses in to WebResponses. - # - # If you don't like WebResponses, you can do - # your own handling of OpenIDResponses with - # OpenIDResponse.whichEncoding, - # OpenIDResponse.encodeToURL, and - # OpenIDResponse.encodeToKVForm. - class Encoder - @@responseFactory = WebResponse - - # Encode a response to a WebResponse. - # - # Raises EncodingError when I can't figure out how to encode - # this message. - def encode(response) - encode_as = response.which_encoding() - if encode_as == ENCODE_KVFORM - wr = @@responseFactory.new(HTTP_OK, nil, - response.encode_to_kvform()) - if response.is_a?(Exception) - wr.code = HTTP_ERROR - end - elsif encode_as == ENCODE_URL - location = response.encode_to_url() - wr = @@responseFactory.new(HTTP_REDIRECT, - {'location' => location}) - elsif encode_as == ENCODE_HTML_FORM - wr = @@responseFactory.new(HTTP_OK, nil, - response.to_form_markup()) - else - # Can't encode this to a protocol message. You should - # probably render it to HTML and show it to the user. - raise EncodingError.new(response) - end - - return wr - end - end - - # I encode responses in to WebResponses, signing - # them when required. - class SigningEncoder < Encoder - - attr_accessor :signatory - - # Create a SigningEncoder given a Signatory - def initialize(signatory) - @signatory = signatory - end - - # Encode a response to a WebResponse, signing it first if - # appropriate. - # - # Raises EncodingError when I can't figure out how to encode this - # message. - # - # Raises AlreadySigned when this response is already signed. - def encode(response) - # the is_a? is a bit of a kludge... it means there isn't - # really an adapter to make the interfaces quite match. - if !response.is_a?(Exception) and response.needs_signing() - if !@signatory - raise ArgumentError.new( - sprintf("Must have a store to sign this request: %s", - response), response) - end - - if response.fields.has_key?(OPENID_NS, 'sig') - raise AlreadySigned.new(response) - end - - response = @signatory.sign(response) - end - - return super(response) - end - end - - # I decode an incoming web request in to a OpenIDRequest. - class Decoder - - @@handlers = { - 'checkid_setup' => CheckIDRequest.method('from_message'), - 'checkid_immediate' => CheckIDRequest.method('from_message'), - 'check_authentication' => CheckAuthRequest.method('from_message'), - 'associate' => AssociateRequest.method('from_message'), - } - - attr_accessor :server - - # Construct a Decoder. The server is necessary because some - # replies reference their server. - def initialize(server) - @server = server - end - - # I transform query parameters into an OpenIDRequest. - # - # If the query does not seem to be an OpenID request at all, I - # return nil. - # - # Raises ProtocolError when the query does not seem to be a valid - # OpenID request. - def decode(query) - if query.nil? or query.length == 0 - return nil - end - - begin - message = Message.from_post_args(query) - rescue InvalidOpenIDNamespace => e - query = query.dup - query['openid.ns'] = OPENID2_NS - message = Message.from_post_args(query) - raise ProtocolError.new(message, e.to_s) - end - - mode = message.get_arg(OPENID_NS, 'mode') - if !mode - msg = sprintf("No mode value in message %s", message) - raise ProtocolError.new(message, msg) - end - - handler = @@handlers.fetch(mode, self.method('default_decoder')) - return handler.call(message, @server.op_endpoint) - end - - # Called to decode queries when no handler for that mode is - # found. - # - # This implementation always raises ProtocolError. - def default_decoder(message, server) - mode = message.get_arg(OPENID_NS, 'mode') - msg = sprintf("Unrecognized OpenID mode %s", mode) - raise ProtocolError.new(message, msg) - end - end - - # I handle requests for an OpenID server. - # - # Some types of requests (those which are not checkid requests) - # may be handed to my handleRequest method, and I will take care - # of it and return a response. - # - # For your convenience, I also provide an interface to - # Decoder.decode and SigningEncoder.encode through my methods - # decodeRequest and encodeResponse. - # - # All my state is encapsulated in an store, which means I'm not - # generally pickleable but I am easy to reconstruct. - class Server - @@signatoryClass = Signatory - @@encoderClass = SigningEncoder - @@decoderClass = Decoder - - # The back-end where my associations and nonces are stored. - attr_accessor :store - - # I'm using this for associate requests and to sign things. - attr_accessor :signatory - - # I'm using this to encode things. - attr_accessor :encoder - - # I'm using this to decode things. - attr_accessor :decoder - - # I use this instance of OpenID::AssociationNegotiator to - # determine which kinds of associations I can make and how. - attr_accessor :negotiator - - # My URL. - attr_accessor :op_endpoint - - # op_endpoint is new in library version 2.0. - def initialize(store, op_endpoint) - @store = store - @signatory = @@signatoryClass.new(@store) - @encoder = @@encoderClass.new(@signatory) - @decoder = @@decoderClass.new(self) - @negotiator = DefaultNegotiator.copy() - @op_endpoint = op_endpoint - end - - # Handle a request. - # - # Give me a request, I will give you a response. Unless it's a - # type of request I cannot handle myself, in which case I will - # raise RuntimeError. In that case, you can handle it yourself, - # or add a method to me for handling that request type. - def handle_request(request) - begin - handler = self.method('openid_' + request.mode) - rescue NameError - raise RuntimeError.new( - sprintf("%s has no handler for a request of mode %s.", - self, request.mode)) - end - - return handler.call(request) - end - - # Handle and respond to check_authentication requests. - def openid_check_authentication(request) - return request.answer(@signatory) - end - - # Handle and respond to associate requests. - def openid_associate(request) - assoc_type = request.assoc_type - session_type = request.session.session_type - if @negotiator.allowed?(assoc_type, session_type) - assoc = @signatory.create_association(false, - assoc_type) - return request.answer(assoc) - else - message = sprintf('Association type %s is not supported with ' + - 'session type %s', assoc_type, session_type) - preferred_assoc_type, preferred_session_type = @negotiator.get_allowed_type() - return request.answer_unsupported(message, - preferred_assoc_type, - preferred_session_type) - end - end - - # Transform query parameters into an OpenIDRequest. - # query should contain the query parameters as a Hash with - # each key mapping to one value. - # - # If the query does not seem to be an OpenID request at all, I - # return nil. - def decode_request(query) - return @decoder.decode(query) - end - - # Encode a response to a WebResponse, signing it first if - # appropriate. - # - # Raises EncodingError when I can't figure out how to encode this - # message. - # - # Raises AlreadySigned When this response is already signed. - def encode_response(response) - return @encoder.encode(response) - end - end - - # A message did not conform to the OpenID protocol. - class ProtocolError < Exception - # The query that is failing to be a valid OpenID request. - attr_accessor :openid_message - attr_accessor :reference - attr_accessor :contact - - # text:: A message about the encountered error. - def initialize(message, text=nil, reference=nil, contact=nil) - @openid_message = message - @reference = reference - @contact = contact - Util.assert(!message.is_a?(String)) - super(text) - end - - # Get the return_to argument from the request, if any. - def get_return_to - if @openid_message.nil? - return nil - else - return @openid_message.get_arg(OPENID_NS, 'return_to') - end - end - - # Did this request have a return_to parameter? - def has_return_to - return !get_return_to.nil? - end - - # Generate a Message object for sending to the relying party, - # after encoding. - def to_message - namespace = @openid_message.get_openid_namespace() - reply = Message.new(namespace) - reply.set_arg(OPENID_NS, 'mode', 'error') - reply.set_arg(OPENID_NS, 'error', self.to_s) - - if @contact - reply.set_arg(OPENID_NS, 'contact', @contact.to_s) - end - - if @reference - reply.set_arg(OPENID_NS, 'reference', @reference.to_s) - end - - return reply - end - - # implements IEncodable - - def encode_to_url - return to_message().to_url(get_return_to()) - end - - def encode_to_kvform - return to_message().to_kvform() - end - - def to_form_markup - return to_message().to_form_markup(get_return_to()) - end - - def to_html - return Util.auto_submit_html(to_form_markup) - end - - # How should I be encoded? - # - # Returns one of ENCODE_URL, ENCODE_KVFORM, or None. If None, - # I cannot be encoded as a protocol message and should be - # displayed to the user. - def which_encoding - if has_return_to() - if @openid_message.is_openid2 and - encode_to_url().length > OPENID1_URL_LIMIT - return ENCODE_HTML_FORM - else - return ENCODE_URL - end - end - - if @openid_message.nil? - return nil - end - - mode = @openid_message.get_arg(OPENID_NS, 'mode') - if mode - if !BROWSER_REQUEST_MODES.member?(mode) - return ENCODE_KVFORM - end - end - - # If your request was so broken that you didn't manage to - # include an openid.mode, I'm not going to worry too much - # about returning you something you can't parse. - return nil - end - end - - # Raised when an operation was attempted that is not compatible - # with the protocol version being used. - class VersionError < Exception - end - - # Raised when a response to a request cannot be generated - # because the request contains no return_to URL. - class NoReturnToError < Exception - end - - # Could not encode this as a protocol message. - # - # You should probably render it and show it to the user. - class EncodingError < Exception - # The response that failed to encode. - attr_reader :response - - def initialize(response) - super(response) - @response = response - end - end - - # This response is already signed. - class AlreadySigned < EncodingError - end - - # A return_to is outside the trust_root. - class UntrustedReturnURL < ProtocolError - attr_reader :return_to, :trust_root - - def initialize(message, return_to, trust_root) - super(message) - @return_to = return_to - @trust_root = trust_root - end - - def to_s - return sprintf("return_to %s not under trust_root %s", - @return_to, - @trust_root) - end - end - - # The return_to URL doesn't look like a valid URL. - class MalformedReturnURL < ProtocolError - attr_reader :return_to - - def initialize(openid_message, return_to) - @return_to = return_to - super(openid_message) - end - end - - # The trust root is not well-formed. - class MalformedTrustRoot < ProtocolError - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/filesystem.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/store/filesystem.rb deleted file mode 100644 index e2993eea..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/filesystem.rb +++ /dev/null @@ -1,271 +0,0 @@ -require 'fileutils' -require 'pathname' -require 'tempfile' - -require 'openid/util' -require 'openid/store/interface' -require 'openid/association' - -module OpenID - module Store - class Filesystem < Interface - @@FILENAME_ALLOWED = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-".split("") - - # Create a Filesystem store instance, putting all data in +directory+. - def initialize(directory) - p_dir = Pathname.new(directory) - @nonce_dir = p_dir.join('nonces') - @association_dir = p_dir.join('associations') - @temp_dir = p_dir.join('temp') - - self.ensure_dir(@nonce_dir) - self.ensure_dir(@association_dir) - self.ensure_dir(@temp_dir) - end - - # Create a unique filename for a given server url and handle. The - # filename that is returned will contain the domain name from the - # server URL for ease of human inspection of the data dir. - def get_association_filename(server_url, handle) - unless server_url.index('://') - raise ArgumentError, "Bad server URL: #{server_url}" - end - - proto, rest = server_url.split('://', 2) - domain = filename_escape(rest.split('/',2)[0]) - url_hash = safe64(server_url) - if handle - handle_hash = safe64(handle) - else - handle_hash = '' - end - filename = [proto,domain,url_hash,handle_hash].join('-') - @association_dir.join(filename) - end - - # Store an association in the assoc directory - def store_association(server_url, association) - assoc_s = association.serialize - filename = get_association_filename(server_url, association.handle) - f, tmp = mktemp - - begin - begin - f.write(assoc_s) - f.fsync - ensure - f.close - end - - begin - File.rename(tmp, filename) - rescue Errno::EEXIST - - begin - File.unlink(filename) - rescue Errno::ENOENT - # do nothing - end - - File.rename(tmp, filename) - end - - rescue - self.remove_if_present(tmp) - raise - end - end - - # Retrieve an association - def get_association(server_url, handle=nil) - # the filename with empty handle is the prefix for the associations - # for a given server url - filename = get_association_filename(server_url, handle) - if handle - return _get_association(filename) - end - assoc_filenames = Dir.glob(filename.to_s + '*') - - assocs = assoc_filenames.collect do |f| - _get_association(f) - end - - assocs = assocs.find_all { |a| not a.nil? } - assocs = assocs.sort_by { |a| a.issued } - - return nil if assocs.empty? - return assocs[-1] - end - - def _get_association(filename) - begin - assoc_file = File.open(filename, "r") - rescue Errno::ENOENT - return nil - else - begin - assoc_s = assoc_file.read - ensure - assoc_file.close - end - - begin - association = Association.deserialize(assoc_s) - rescue - self.remove_if_present(filename) - return nil - end - - # clean up expired associations - if association.expires_in == 0 - self.remove_if_present(filename) - return nil - else - return association - end - end - end - - # Remove an association if it exists, otherwise do nothing. - def remove_association(server_url, handle) - assoc = get_association(server_url, handle) - - if assoc.nil? - return false - else - filename = get_association_filename(server_url, handle) - return self.remove_if_present(filename) - end - end - - # Return whether the nonce is valid - def use_nonce(server_url, timestamp, salt) - return false if (timestamp - Time.now.to_i).abs > Nonce.skew - - if server_url and !server_url.empty? - proto, rest = server_url.split('://',2) - else - proto, rest = '','' - end - raise "Bad server URL" unless proto && rest - - domain = filename_escape(rest.split('/',2)[0]) - url_hash = safe64(server_url) - salt_hash = safe64(salt) - - nonce_fn = '%08x-%s-%s-%s-%s'%[timestamp, proto, domain, url_hash, salt_hash] - - filename = @nonce_dir.join(nonce_fn) - - begin - fd = File.new(filename, File::CREAT | File::EXCL | File::WRONLY, 0200) - fd.close - return true - rescue Errno::EEXIST - return false - end - end - - # Remove expired entries from the database. This is potentially expensive, - # so only run when it is acceptable to take time. - def cleanup - cleanup_associations - cleanup_nonces - end - - def cleanup_associations - association_filenames = Dir[@association_dir.join("*").to_s] - count = 0 - association_filenames.each do |af| - begin - f = File.open(af, 'r') - rescue Errno::ENOENT - next - else - begin - assoc_s = f.read - ensure - f.close - end - begin - association = OpenID::Association.deserialize(assoc_s) - rescue StandardError - self.remove_if_present(af) - next - else - if association.expires_in == 0 - self.remove_if_present(af) - count += 1 - end - end - end - end - return count - end - - def cleanup_nonces - nonces = Dir[@nonce_dir.join("*").to_s] - now = Time.now.to_i - - count = 0 - nonces.each do |filename| - nonce = filename.split('/')[-1] - timestamp = nonce.split('-', 2)[0].to_i(16) - nonce_age = (timestamp - now).abs - if nonce_age > Nonce.skew - self.remove_if_present(filename) - count += 1 - end - end - return count - end - - protected - - # Create a temporary file and return the File object and filename. - def mktemp - f = Tempfile.new('tmp', @temp_dir) - [f, f.path] - end - - # create a safe filename from a url - def filename_escape(s) - s = '' if s.nil? - filename_chunks = [] - s.split('').each do |c| - if @@FILENAME_ALLOWED.index(c) - filename_chunks << c - else - filename_chunks << sprintf("_%02X", c[0]) - end - end - filename_chunks.join("") - end - - def safe64(s) - s = OpenID::CryptUtil.sha1(s) - s = OpenID::Util.to_base64(s) - s.gsub!('+', '_') - s.gsub!('/', '.') - s.gsub!('=', '') - return s - end - - # remove file if present in filesystem - def remove_if_present(filename) - begin - File.unlink(filename) - rescue Errno::ENOENT - return false - end - return true - end - - # ensure that a path exists - def ensure_dir(dir_name) - FileUtils::mkdir_p(dir_name) - end - end - end -end - diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/interface.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/store/interface.rb deleted file mode 100644 index 50819f6f..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/interface.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'openid/util' - -module OpenID - - # Stores for Associations and nonces. Used by both the Consumer and - # the Server. If you have a database abstraction layer or other - # state storage in your application or framework already, you can - # implement the store interface. - module Store - # Abstract Store - # Changes in 2.0: - # * removed store_nonce, get_auth_key, is_dumb - # * changed use_nonce to support one-way nonces - # * added cleanup_nonces, cleanup_associations, cleanup - class Interface < Object - - # Put a Association object into storage. - # When implementing a store, don't assume that there are any limitations - # on the character set of the server_url. In particular, expect to see - # unescaped non-url-safe characters in the server_url field. - def store_association(server_url, association) - raise NotImplementedError - end - - # Returns a Association object from storage that matches - # the server_url. Returns nil if no such association is found or if - # the one matching association is expired. (Is allowed to GC expired - # associations when found.) - def get_association(server_url, handle=nil) - raise NotImplementedError - end - - # If there is a matching association, remove it from the store and - # return true, otherwise return false. - def remove_association(server_url, handle) - raise NotImplementedError - end - - # Return true if the nonce has not been used before, and store it - # for a while to make sure someone doesn't try to use the same value - # again. Return false if the nonce has already been used or if the - # timestamp is not current. - # You can use OpenID::Store::Nonce::SKEW for your timestamp window. - # server_url: URL of the server from which the nonce originated - # timestamp: time the nonce was created in seconds since unix epoch - # salt: A random string that makes two nonces issued by a server in - # the same second unique - def use_nonce(server_url, timestamp, salt) - raise NotImplementedError - end - - # Remove expired nonces from the store - # Discards any nonce that is old enough that it wouldn't pass use_nonce - # Not called during normal library operation, this method is for store - # admins to keep their storage from filling up with expired data - def cleanup_nonces - raise NotImplementedError - end - - # Remove expired associations from the store - # Not called during normal library operation, this method is for store - # admins to keep their storage from filling up with expired data - def cleanup_associations - raise NotImplementedError - end - - # Remove expired nonces and associations from the store - # Not called during normal library operation, this method is for store - # admins to keep their storage from filling up with expired data - def cleanup - return cleanup_nonces, cleanup_associations - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/memory.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/store/memory.rb deleted file mode 100644 index 58455b95..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/memory.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'openid/store/interface' -module OpenID - module Store - # An in-memory implementation of Store. This class is mainly used - # for testing, though it may be useful for long-running single - # process apps. Note that this store is NOT thread-safe. - # - # You should probably be looking at OpenID::Store::Filesystem - class Memory < Interface - - def initialize - @associations = {} - @associations.default = {} - @nonces = {} - end - - def store_association(server_url, assoc) - assocs = @associations[server_url] - @associations[server_url] = assocs.merge({assoc.handle => deepcopy(assoc)}) - end - - def get_association(server_url, handle=nil) - assocs = @associations[server_url] - assoc = nil - if handle - assoc = assocs[handle] - else - assoc = assocs.values.sort{|a,b| a.issued <=> b.issued}[-1] - end - - return assoc - end - - def remove_association(server_url, handle) - assocs = @associations[server_url] - if assocs.delete(handle) - return true - else - return false - end - end - - def use_nonce(server_url, timestamp, salt) - return false if (timestamp - Time.now.to_i).abs > Nonce.skew - nonce = [server_url, timestamp, salt].join('') - return false if @nonces[nonce] - @nonces[nonce] = timestamp - return true - end - - def cleanup_associations - count = 0 - @associations.each{|server_url, assocs| - assocs.each{|handle, assoc| - if assoc.expires_in == 0 - assocs.delete(handle) - count += 1 - end - } - } - return count - end - - def cleanup_nonces - count = 0 - now = Time.now.to_i - @nonces.each{|nonce, timestamp| - if (timestamp - now).abs > Nonce.skew - @nonces.delete(nonce) - count += 1 - end - } - return count - end - - protected - - def deepcopy(o) - Marshal.load(Marshal.dump(o)) - end - - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/nonce.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/store/nonce.rb deleted file mode 100644 index 08a9e529..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/store/nonce.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'openid/cryptutil' -require 'date' -require 'time' - -module OpenID - module Nonce - DEFAULT_SKEW = 60*60*5 - TIME_FMT = '%Y-%m-%dT%H:%M:%SZ' - TIME_STR_LEN = '0000-00-00T00:00:00Z'.size - @@NONCE_CHRS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - TIME_VALIDATOR = /\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/ - - @skew = DEFAULT_SKEW - - # The allowed nonce time skew in seconds. Defaults to 5 hours. - # Used for checking nonce validity, and by stores' cleanup methods. - def Nonce.skew - @skew - end - - def Nonce.skew=(new_skew) - @skew = new_skew - end - - # Extract timestamp from a nonce string - def Nonce.split_nonce(nonce_str) - timestamp_str = nonce_str[0...TIME_STR_LEN] - raise ArgumentError if timestamp_str.size < TIME_STR_LEN - raise ArgumentError unless timestamp_str.match(TIME_VALIDATOR) - ts = Time.parse(timestamp_str).to_i - raise ArgumentError if ts < 0 - return ts, nonce_str[TIME_STR_LEN..-1] - end - - # Is the timestamp that is part of the specified nonce string - # within the allowed clock-skew of the current time? - def Nonce.check_timestamp(nonce_str, allowed_skew=nil, now=nil) - allowed_skew = skew if allowed_skew.nil? - begin - stamp, foo = split_nonce(nonce_str) - rescue ArgumentError # bad timestamp - return false - end - now = Time.now.to_i unless now - - # times before this are too old - past = now - allowed_skew - - # times newer than this are too far in the future - future = now + allowed_skew - - return (past <= stamp and stamp <= future) - end - - # generate a nonce with the specified timestamp (defaults to now) - def Nonce.mk_nonce(time = nil) - salt = CryptUtil::random_string(6, @@NONCE_CHRS) - if time.nil? - t = Time.now.getutc - else - t = Time.at(time).getutc - end - time_str = t.strftime(TIME_FMT) - return time_str + salt - end - - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/trustroot.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/trustroot.rb deleted file mode 100644 index 16695f05..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/trustroot.rb +++ /dev/null @@ -1,349 +0,0 @@ -require 'uri' -require 'openid/urinorm' - -module OpenID - - class RealmVerificationRedirected < Exception - # Attempting to verify this realm resulted in a redirect. - def initialize(relying_party_url, rp_url_after_redirects) - @relying_party_url = relying_party_url - @rp_url_after_redirects = rp_url_after_redirects - end - - def to_s - return "Attempting to verify #{@relying_party_url} resulted in " + - "redirect to #{@rp_url_after_redirects}" - end - end - - module TrustRoot - TOP_LEVEL_DOMAINS = %w' - ac ad ae aero af ag ai al am an ao aq ar arpa as asia at - au aw ax az ba bb bd be bf bg bh bi biz bj bm bn bo br bs bt - bv bw by bz ca cat cc cd cf cg ch ci ck cl cm cn co com coop - cr cu cv cx cy cz de dj dk dm do dz ec edu ee eg er es et eu - fi fj fk fm fo fr ga gb gd ge gf gg gh gi gl gm gn gov gp gq - gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in info int - io iq ir is it je jm jo jobs jp ke kg kh ki km kn kp kr kw - ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mil - mk ml mm mn mo mobi mp mq mr ms mt mu museum mv mw mx my mz - na name nc ne net nf ng ni nl no np nr nu nz om org pa pe pf - pg ph pk pl pm pn pr pro ps pt pw py qa re ro rs ru rw sa sb - sc sd se sg sh si sj sk sl sm sn so sr st su sv sy sz tc td - tel tf tg th tj tk tl tm tn to tp tr travel tt tv tw tz ua - ug uk us uy uz va vc ve vg vi vn vu wf ws xn--0zwm56d - xn--11b5bs3a9aj6g xn--80akhbyknj4f xn--9t4b11yi5a - xn--deba0ad xn--g6w251d xn--hgbk6aj7f53bba - xn--hlcj6aya9esc7a xn--jxalpdlp xn--kgbechtv xn--zckzah ye - yt yu za zm zw' - - ALLOWED_PROTOCOLS = ['http', 'https'] - - # The URI for relying party discovery, used in realm verification. - # - # XXX: This should probably live somewhere else (like in - # OpenID or OpenID::Yadis somewhere) - RP_RETURN_TO_URL_TYPE = 'http://specs.openid.net/auth/2.0/return_to' - - # If the endpoint is a relying party OpenID return_to endpoint, - # return the endpoint URL. Otherwise, return None. - # - # This function is intended to be used as a filter for the Yadis - # filtering interface. - # - # endpoint: An XRDS BasicServiceEndpoint, as returned by - # performing Yadis dicovery. - # - # returns the endpoint URL or None if the endpoint is not a - # relying party endpoint. - def TrustRoot._extract_return_url(endpoint) - if endpoint.matchTypes([RP_RETURN_TO_URL_TYPE]) - return endpoint.uri - else - return nil - end - end - - # Is the return_to URL under one of the supplied allowed - # return_to URLs? - def TrustRoot.return_to_matches(allowed_return_to_urls, return_to) - allowed_return_to_urls.each { |allowed_return_to| - # A return_to pattern works the same as a realm, except that - # it's not allowed to use a wildcard. We'll model this by - # parsing it as a realm, and not trying to match it if it has - # a wildcard. - - return_realm = TrustRoot.parse(allowed_return_to) - if (# Parses as a trust root - !return_realm.nil? and - - # Does not have a wildcard - !return_realm.wildcard and - - # Matches the return_to that we passed in with it - return_realm.validate_url(return_to) - ) - return true - end - } - - # No URL in the list matched - return false - end - - # Given a relying party discovery URL return a list of return_to - # URLs. - def TrustRoot.get_allowed_return_urls(relying_party_url) - rp_url_after_redirects, return_to_urls = services.get_service_endpoints( - relying_party_url, _extract_return_url) - - if rp_url_after_redirects != relying_party_url - # Verification caused a redirect - raise RealmVerificationRedirected.new( - relying_party_url, rp_url_after_redirects) - end - - return return_to_urls - end - - # Verify that a return_to URL is valid for the given realm. - # - # This function builds a discovery URL, performs Yadis discovery - # on it, makes sure that the URL does not redirect, parses out - # the return_to URLs, and finally checks to see if the current - # return_to URL matches the return_to. - # - # raises DiscoveryFailure when Yadis discovery fails returns - # true if the return_to URL is valid for the realm - def TrustRoot.verify_return_to(realm_str, return_to, _vrfy=nil) - # _vrfy parameter is there to make testing easier - if _vrfy.nil? - _vrfy = self.method('get_allowed_return_urls') - end - - if !(_vrfy.is_a?(Proc) or _vrfy.is_a?(Method)) - raise ArgumentError, "_vrfy must be a Proc or Method" - end - - realm = TrustRoot.parse(realm_str) - if realm.nil? - # The realm does not parse as a URL pattern - return false - end - - begin - allowable_urls = _vrfy.call(realm.build_discovery_url()) - rescue RealmVerificationRedirected => err - Util.log(err.to_s) - return false - end - - if return_to_matches(allowable_urls, return_to) - return true - else - Util.log("Failed to validate return_to #{return_to} for " + - "realm #{realm_str}, was not in #{allowable_urls}") - return false - end - end - - class TrustRoot - - attr_reader :unparsed, :proto, :wildcard, :host, :port, :path - - @@empty_re = Regexp.new('^http[s]*:\/\/\*\/$') - - def TrustRoot._build_path(path, query=nil, frag=nil) - s = path.dup - - frag = nil if frag == '' - query = nil if query == '' - - if query - s << "?" << query - end - - if frag - s << "#" << frag - end - - return s - end - - def TrustRoot._parse_url(url) - begin - url = URINorm.urinorm(url) - rescue URI::InvalidURIError => err - nil - end - - begin - parsed = URI::parse(url) - rescue URI::InvalidURIError - return nil - end - - path = TrustRoot._build_path(parsed.path, - parsed.query, - parsed.fragment) - - return [parsed.scheme || '', parsed.host || '', - parsed.port || '', path || ''] - end - - def TrustRoot.parse(trust_root) - trust_root = trust_root.dup - unparsed = trust_root.dup - - # look for wildcard - wildcard = (not trust_root.index('://*.').nil?) - trust_root.sub!('*.', '') if wildcard - - # handle http://*/ case - if not wildcard and @@empty_re.match(trust_root) - proto = trust_root.split(':')[0] - port = proto == 'http' ? 80 : 443 - return new(unparsed, proto, true, '', port, '/') - end - - parts = TrustRoot._parse_url(trust_root) - return nil if parts.nil? - - proto, host, port, path = parts - - # check for URI fragment - if path and !path.index('#').nil? - return nil - end - - return nil unless ['http', 'https'].member?(proto) - return new(unparsed, proto, wildcard, host, port, path) - end - - def TrustRoot.check_sanity(trust_root_string) - trust_root = TrustRoot.parse(trust_root_string) - if trust_root.nil? - return false - else - return trust_root.sane? - end - end - - # quick func for validating a url against a trust root. See the - # TrustRoot class if you need more control. - def self.check_url(trust_root, url) - tr = self.parse(trust_root) - return (!tr.nil? and tr.validate_url(url)) - end - - # Return a discovery URL for this realm. - # - # This function does not check to make sure that the realm is - # valid. Its behaviour on invalid inputs is undefined. - # - # return_to:: The relying party return URL of the OpenID - # authentication request - # - # Returns the URL upon which relying party discovery should be - # run in order to verify the return_to URL - def build_discovery_url - if self.wildcard - # Use "www." in place of the star - www_domain = 'www.' + @host - port = (!@port.nil? and ![80, 443].member?(@port)) ? (":" + @port.to_s) : '' - return "#{@proto}://#{www_domain}#{port}#{@path}" - else - return @unparsed - end - end - - def initialize(unparsed, proto, wildcard, host, port, path) - @unparsed = unparsed - @proto = proto - @wildcard = wildcard - @host = host - @port = port - @path = path - end - - def sane? - return true if @host == 'localhost' - - host_parts = @host.split('.') - - # a note: ruby string split does not put an empty string at - # the end of the list if the split element is last. for - # example, 'foo.com.'.split('.') => ['foo','com']. Mentioned - # because the python code differs here. - - return false if host_parts.length == 0 - - # no adjacent dots - return false if host_parts.member?('') - - # last part must be a tld - tld = host_parts[-1] - return false unless TOP_LEVEL_DOMAINS.member?(tld) - - return false if host_parts.length == 1 - - if @wildcard - if tld.length == 2 and host_parts[-2].length <= 3 - # It's a 2-letter tld with a short second to last segment - # so there needs to be more than two segments specified - # (e.g. *.co.uk is insane) - return host_parts.length > 2 - end - end - - return true - end - - def validate_url(url) - parts = TrustRoot._parse_url(url) - return false if parts.nil? - - proto, host, port, path = parts - - return false unless proto == @proto - return false unless port == @port - return false unless host.index('*').nil? - - if !@wildcard - if host != @host - return false - end - elsif ((@host != '') and - (!host.ends_with?('.' + @host)) and - (host != @host)) - return false - end - - if path != @path - path_len = @path.length - trust_prefix = @path[0...path_len] - url_prefix = path[0...path_len] - - # must be equal up to the length of the path, at least - if trust_prefix != url_prefix - return false - end - - # These characters must be on the boundary between the end - # of the trust root's path and the start of the URL's path. - if !@path.index('?').nil? - allowed = '&' - else - allowed = '?/' - end - - return (!allowed.index(@path[-1]).nil? or - !allowed.index(path[path_len]).nil?) - end - - return true - end - end - end -end - diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/urinorm.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/urinorm.rb deleted file mode 100644 index f30893ea..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/urinorm.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'uri' - -require "openid/extras" - -module OpenID - - module URINorm - public - def URINorm.urinorm(uri) - uri = URI.parse(uri) - - raise URI::InvalidURIError.new('no scheme') unless uri.scheme - uri.scheme = uri.scheme.downcase - unless ['http','https'].member?(uri.scheme) - raise URI::InvalidURIError.new('Not an HTTP or HTTPS URI') - end - - raise URI::InvalidURIError.new('no host') unless uri.host - uri.host = uri.host.downcase - - uri.path = remove_dot_segments(uri.path) - uri.path = '/' if uri.path.length == 0 - - uri = uri.normalize.to_s - uri = uri.gsub(PERCENT_ESCAPE_RE) { - sub = $&[1..2].to_i(16).chr - reserved(sub) ? $&.upcase : sub - } - - return uri - end - - private - RESERVED_RE = /[A-Za-z0-9._~-]/ - PERCENT_ESCAPE_RE = /%[0-9a-zA-Z]{2}/ - - def URINorm.reserved(chr) - not RESERVED_RE =~ chr - end - - def URINorm.remove_dot_segments(path) - result_segments = [] - - while path.length > 0 - if path.starts_with?('../') - path = path[3..-1] - elsif path.starts_with?('./') - path = path[2..-1] - elsif path.starts_with?('/./') - path = path[2..-1] - elsif path == '/.' - path = '/' - elsif path.starts_with?('/../') - path = path[3..-1] - result_segments.pop if result_segments.length > 0 - elsif path == '/..' - path = '/' - result_segments.pop if result_segments.length > 0 - elsif path == '..' or path == '.' - path = '' - else - i = 0 - i = 1 if path[0].chr == '/' - i = path.index('/', i) - i = path.length if i.nil? - result_segments << path[0...i] - path = path[i..-1] - end - end - - return result_segments.join('') - end - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/util.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/util.rb deleted file mode 100644 index c5a6716b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/util.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "cgi" -require "uri" -require "logger" - -require "openid/extras" - -# See OpenID::Consumer or OpenID::Server modules, as well as the store classes -module OpenID - class AssertionError < Exception - end - - # Exceptions that are raised by the library are subclasses of this - # exception type, so if you want to catch all exceptions raised by - # the library, you can catch OpenIDError - class OpenIDError < StandardError - end - - module Util - - BASE64_CHARS = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' \ - 'abcdefghijklmnopqrstuvwxyz0123456789+/') - BASE64_RE = Regexp.compile(" - \\A - ([#{BASE64_CHARS}]{4})* - ([#{BASE64_CHARS}]{2}==| - [#{BASE64_CHARS}]{3}=)? - \\Z", Regexp::EXTENDED) - - def Util.assert(value, message=nil) - if not value - raise AssertionError, message or value - end - end - - def Util.to_base64(s) - [s].pack('m').gsub("\n", "") - end - - def Util.from_base64(s) - without_newlines = s.gsub(/[\r\n]+/, '') - if !BASE64_RE.match(without_newlines) - raise ArgumentError, "Malformed input: #{s.inspect}" - end - without_newlines.unpack('m').first - end - - def Util.urlencode(args) - a = [] - args.each do |key, val| - val = '' unless val - a << (CGI::escape(key) + "=" + CGI::escape(val)) - end - a.join("&") - end - - def Util.parse_query(qs) - query = {} - CGI::parse(qs).each {|k,v| query[k] = v[0]} - return query - end - - def Util.append_args(url, args) - url = url.dup - return url if args.length == 0 - - if args.respond_to?('each_pair') - args = args.sort - end - - url << (url.include?("?") ? "&" : "?") - url << Util.urlencode(args) - end - - @@logger = Logger.new(STDERR) - @@logger.progname = "OpenID" - - def Util.logger=(logger) - @@logger = logger - end - - def Util.logger - @@logger - end - - # change the message below to do whatever you like for logging - def Util.log(message) - logger.info(message) - end - - def Util.auto_submit_html(form, title='OpenID transaction in progress') - return " - - - #{title} - - -#{form} - - - -" - end - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/accept.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/accept.rb deleted file mode 100644 index a1657482..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/accept.rb +++ /dev/null @@ -1,148 +0,0 @@ -module OpenID - - module Yadis - - # Generate an accept header value - # - # [str or (str, float)] -> str - def self.generate_accept_header(*elements) - parts = [] - elements.each { |element| - if element.is_a?(String) - qs = "1.0" - mtype = element - else - mtype, q = element - q = q.to_f - if q > 1 or q <= 0 - raise ArgumentError.new("Invalid preference factor: #{q}") - end - qs = sprintf("%0.1f", q) - end - - parts << [qs, mtype] - } - - parts.sort! - chunks = [] - parts.each { |q, mtype| - if q == '1.0' - chunks << mtype - else - chunks << sprintf("%s; q=%s", mtype, q) - end - } - - return chunks.join(', ') - end - - def self.parse_accept_header(value) - # Parse an accept header, ignoring any accept-extensions - # - # returns a list of tuples containing main MIME type, MIME - # subtype, and quality markdown. - # - # str -> [(str, str, float)] - chunks = value.split(',', -1).collect { |v| v.strip } - accept = [] - chunks.each { |chunk| - parts = chunk.split(";", -1).collect { |s| s.strip } - - mtype = parts.shift - if mtype.index('/').nil? - # This is not a MIME type, so ignore the bad data - next - end - - main, sub = mtype.split('/', 2) - - q = nil - parts.each { |ext| - if !ext.index('=').nil? - k, v = ext.split('=', 2) - if k == 'q' - q = v.to_f - end - end - } - - q = 1.0 if q.nil? - - accept << [q, main, sub] - } - - accept.sort! - accept.reverse! - - return accept.collect { |q, main, sub| [main, sub, q] } - end - - def self.match_types(accept_types, have_types) - # Given the result of parsing an Accept: header, and the - # available MIME types, return the acceptable types with their - # quality markdowns. - # - # For example: - # - # >>> acceptable = parse_accept_header('text/html, text/plain; q=0.5') - # >>> matchTypes(acceptable, ['text/plain', 'text/html', 'image/jpeg']) - # [('text/html', 1.0), ('text/plain', 0.5)] - # - # Type signature: ([(str, str, float)], [str]) -> [(str, float)] - if accept_types.nil? or accept_types == [] - # Accept all of them - default = 1 - else - default = 0 - end - - match_main = {} - match_sub = {} - accept_types.each { |main, sub, q| - if main == '*' - default = [default, q].max - next - elsif sub == '*' - match_main[main] = [match_main.fetch(main, 0), q].max - else - match_sub[[main, sub]] = [match_sub.fetch([main, sub], 0), q].max - end - } - - accepted_list = [] - order_maintainer = 0 - have_types.each { |mtype| - main, sub = mtype.split('/', 2) - if match_sub.member?([main, sub]) - q = match_sub[[main, sub]] - else - q = match_main.fetch(main, default) - end - - if q != 0 - accepted_list << [1 - q, order_maintainer, q, mtype] - order_maintainer += 1 - end - } - - accepted_list.sort! - return accepted_list.collect { |_, _, q, mtype| [mtype, q] } - end - - def self.get_acceptable(accept_header, have_types) - # Parse the accept header and return a list of available types - # in preferred order. If a type is unacceptable, it will not be - # in the resulting list. - # - # This is a convenience wrapper around matchTypes and - # parse_accept_header - # - # (str, [str]) -> [str] - accepted = self.parse_accept_header(accept_header) - preferred = self.match_types(accepted, have_types) - return preferred.collect { |mtype, _| mtype } - end - - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/constants.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/constants.rb deleted file mode 100644 index 99b58b13..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/constants.rb +++ /dev/null @@ -1,21 +0,0 @@ - -require 'openid/yadis/accept' - -module OpenID - - module Yadis - - YADIS_HEADER_NAME = 'X-XRDS-Location' - YADIS_CONTENT_TYPE = 'application/xrds+xml' - - # A value suitable for using as an accept header when performing - # YADIS discovery, unless the application has special requirements - YADIS_ACCEPT_HEADER = generate_accept_header( - ['text/html', 0.3], - ['application/xhtml+xml', 0.5], - [YADIS_CONTENT_TYPE, 1.0] - ) - - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/discovery.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/discovery.rb deleted file mode 100644 index 55d6f09b..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/discovery.rb +++ /dev/null @@ -1,153 +0,0 @@ - -require 'openid/util' -require 'openid/fetchers' -require 'openid/yadis/constants' -require 'openid/yadis/parsehtml' - -module OpenID - - # Raised when a error occurs in the discovery process - class DiscoveryFailure < OpenIDError - attr_accessor :identity_url, :http_response - - def initialize(message, http_response) - super(message) - @identity_url = nil - @http_response = http_response - end - end - - module Yadis - - # Contains the result of performing Yadis discovery on a URI - class DiscoveryResult - - # The result of following redirects from the request_uri - attr_accessor :normalize_uri - - # The URI from which the response text was returned (set to - # nil if there was no XRDS document found) - attr_accessor :xrds_uri - - # The content-type returned with the response_text - attr_accessor :content_type - - # The document returned from the xrds_uri - attr_accessor :response_text - - attr_accessor :request_uri, :normalized_uri - - def initialize(request_uri) - # Initialize the state of the object - # - # sets all attributes to None except the request_uri - @request_uri = request_uri - @normalized_uri = nil - @xrds_uri = nil - @content_type = nil - @response_text = nil - end - - # Was the Yadis protocol's indirection used? - def used_yadis_location? - return @normalized_uri != @xrds_uri - end - - # Is the response text supposed to be an XRDS document? - def is_xrds - return (used_yadis_location?() or - @content_type == YADIS_CONTENT_TYPE) - end - end - - # Discover services for a given URI. - # - # uri: The identity URI as a well-formed http or https URI. The - # well-formedness and the protocol are not checked, but the - # results of this function are undefined if those properties do - # not hold. - # - # returns a DiscoveryResult object - # - # Raises DiscoveryFailure when the HTTP response does not have - # a 200 code. - def self.discover(uri) - result = DiscoveryResult.new(uri) - begin - resp = OpenID.fetch(uri, nil, {'Accept' => YADIS_ACCEPT_HEADER}) - rescue Exception - raise DiscoveryFailure.new("Failed to fetch identity URL #{uri} : #{$!}", $!) - end - if resp.code != "200" and resp.code != "206" - raise DiscoveryFailure.new( - "HTTP Response status from identity URL host is not \"200\"."\ - "Got status #{resp.code.inspect} for #{resp.final_url}", resp) - end - - # Note the URL after following redirects - result.normalized_uri = resp.final_url - - # Attempt to find out where to go to discover the document or if - # we already have it - result.content_type = resp['content-type'] - - result.xrds_uri = self.where_is_yadis?(resp) - - if result.xrds_uri and result.used_yadis_location? - begin - resp = OpenID.fetch(result.xrds_uri) - rescue - raise DiscoveryFailure.new("Failed to fetch Yadis URL #{result.xrds_uri} : #{$!}", $!) - end - if resp.code != "200" and resp.code != "206" - exc = DiscoveryFailure.new( - "HTTP Response status from Yadis host is not \"200\". " + - "Got status #{resp.code.inspect} for #{resp.final_url}", resp) - exc.identity_url = result.normalized_uri - raise exc - end - - result.content_type = resp['content-type'] - end - - result.response_text = resp.body - return result - end - - # Given a HTTPResponse, return the location of the Yadis - # document. - # - # May be the URL just retrieved, another URL, or None, if I - # can't find any. - # - # [non-blocking] - def self.where_is_yadis?(resp) - # Attempt to find out where to go to discover the document or if - # we already have it - content_type = resp['content-type'] - - # According to the spec, the content-type header must be an - # exact match, or else we have to look for an indirection. - if (!content_type.nil? and !content_type.to_s.empty? and - content_type.split(';', 2)[0].downcase == YADIS_CONTENT_TYPE) - return resp.final_url - else - # Try the header - yadis_loc = resp[YADIS_HEADER_NAME.downcase] - - if yadis_loc.nil? - # Parse as HTML if the header is missing. - # - # XXX: do we want to do something with content-type, like - # have a whitelist or a blacklist (for detecting that it's - # HTML)? - yadis_loc = Yadis.html_yadis_location(resp.body) - end - end - - return yadis_loc - end - - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/filters.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/filters.rb deleted file mode 100644 index 90f350ea..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/filters.rb +++ /dev/null @@ -1,205 +0,0 @@ -# This file contains functions and classes used for extracting -# endpoint information out of a Yadis XRD file using the REXML -# XML parser. - -# -module OpenID - module Yadis - class BasicServiceEndpoint - attr_reader :type_uris, :yadis_url, :uri, :service_element - - # Generic endpoint object that contains parsed service - # information, as well as a reference to the service element - # from which it was generated. If there is more than one - # xrd:Type or xrd:URI in the xrd:Service, this object represents - # just one of those pairs. - # - # This object can be used as a filter, because it implements - # fromBasicServiceEndpoint. - # - # The simplest kind of filter you can write implements - # fromBasicServiceEndpoint, which takes one of these objects. - def initialize(yadis_url, type_uris, uri, service_element) - @type_uris = type_uris - @yadis_url = yadis_url - @uri = uri - @service_element = service_element - end - - # Query this endpoint to see if it has any of the given type - # URIs. This is useful for implementing other endpoint classes - # that e.g. need to check for the presence of multiple - # versions of a single protocol. - def match_types(type_uris) - return @type_uris & type_uris - end - - # Trivial transform from a basic endpoint to itself. This - # method exists to allow BasicServiceEndpoint to be used as a - # filter. - # - # If you are subclassing this object, re-implement this function. - def self.from_basic_service_endpoint(endpoint) - return endpoint - end - - # A hack to make both this class and its instances respond to - # this message since Ruby doesn't support static methods. - def from_basic_service_endpoint(endpoint) - return self.class.from_basic_service_endpoint(endpoint) - end - - end - - # Take a list of basic filters and makes a filter that - # transforms the basic filter into a top-level filter. This is - # mostly useful for the implementation of make_filter, which - # should only be needed for special cases or internal use by - # this library. - # - # This object is useful for creating simple filters for services - # that use one URI and are specified by one Type (we expect most - # Types will fit this paradigm). - # - # Creates a BasicServiceEndpoint object and apply the filter - # functions to it until one of them returns a value. - class TransformFilterMaker - attr_reader :filter_procs - - # Initialize the filter maker's state - # - # filter_functions are the endpoint transformer - # Procs to apply to the basic endpoint. These are called in - # turn until one of them does not return nil, and the result - # of that transformer is returned. - def initialize(filter_procs) - @filter_procs = filter_procs - end - - # Returns an array of endpoint objects produced by the - # filter procs. - def get_service_endpoints(yadis_url, service_element) - endpoints = [] - - # Do an expansion of the service element by xrd:Type and - # xrd:URI - Yadis::expand_service(service_element).each { |type_uris, uri, _| - # Create a basic endpoint object to represent this - # yadis_url, Service, Type, URI combination - endpoint = BasicServiceEndpoint.new( - yadis_url, type_uris, uri, service_element) - - e = apply_filters(endpoint) - if !e.nil? - endpoints << e - end - } - return endpoints - end - - def apply_filters(endpoint) - # Apply filter procs to an endpoint until one of them returns - # non-nil. - @filter_procs.each { |filter_proc| - e = filter_proc.call(endpoint) - if !e.nil? - # Once one of the filters has returned an endpoint, do not - # apply any more. - return e - end - } - - return nil - end - end - - class CompoundFilter - attr_reader :subfilters - - # Create a new filter that applies a set of filters to an - # endpoint and collects their results. - def initialize(subfilters) - @subfilters = subfilters - end - - # Generate all endpoint objects for all of the subfilters of - # this filter and return their concatenation. - def get_service_endpoints(yadis_url, service_element) - endpoints = [] - @subfilters.each { |subfilter| - endpoints += subfilter.get_service_endpoints(yadis_url, service_element) - } - return endpoints - end - end - - # Exception raised when something is not able to be turned into a - # filter - @@filter_type_error = TypeError.new( - 'Expected a filter, an endpoint, a callable or a list of any of these.') - - # Convert a filter-convertable thing into a filter - # - # parts should be a filter, an endpoint, a callable, or a list of - # any of these. - def self.make_filter(parts) - # Convert the parts into a list, and pass to mk_compound_filter - if parts.nil? - parts = [BasicServiceEndpoint] - end - - if parts.is_a?(Array) - return mk_compound_filter(parts) - else - return mk_compound_filter([parts]) - end - end - - # Create a filter out of a list of filter-like things - # - # Used by make_filter - # - # parts should be a list of things that can be passed to make_filter - def self.mk_compound_filter(parts) - - if !parts.respond_to?('each') - raise TypeError, "#{parts.inspect} is not iterable" - end - - # Separate into a list of callables and a list of filter objects - transformers = [] - filters = [] - parts.each { |subfilter| - if !subfilter.is_a?(Array) - # If it's not an iterable - if subfilter.respond_to?('get_service_endpoints') - # It's a full filter - filters << subfilter - elsif subfilter.respond_to?('from_basic_service_endpoint') - # It's an endpoint object, so put its endpoint conversion - # attribute into the list of endpoint transformers - transformers << subfilter.method('from_basic_service_endpoint') - elsif subfilter.respond_to?('call') - # It's a proc, so add it to the list of endpoint - # transformers - transformers << subfilter - else - raise @@filter_type_error - end - else - filters << mk_compound_filter(subfilter) - end - } - - if transformers.length > 0 - filters << TransformFilterMaker.new(transformers) - end - - if filters.length == 1 - return filters[0] - else - return CompoundFilter.new(filters) - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/htmltokenizer.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/htmltokenizer.rb deleted file mode 100644 index b2081097..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/htmltokenizer.rb +++ /dev/null @@ -1,305 +0,0 @@ -# = HTMLTokenizer -# -# Author:: Ben Giddings (mailto:bg-rubyforge@infofiend.com) -# Copyright:: Copyright (c) 2004 Ben Giddings -# License:: Distributes under the same terms as Ruby -# -# -# This is a partial port of the functionality behind Perl's TokeParser -# Provided a page it progressively returns tokens from that page -# -# $Id: htmltokenizer.rb,v 1.7 2005/06/07 21:05:53 merc Exp $ - -# -# A class to tokenize HTML. -# -# Example: -# -# page = " -# -# This is the title -# -# -# -#

    This is the header

    -#

    -# This is the paragraph, it contains -# links, -# images
-#        are
-#        really cool. Ok, here is some more text and -# another link. -#

    -# -# -# " -# toke = HTMLTokenizer.new(page) -# -# assert("

    " == toke.getTag("h1", "h2", "h3").to_s.downcase) -# assert(HTMLTag.new("") == toke.getTag("IMG", "A")) -# assert("links" == toke.getTrimmedText) -# assert(toke.getTag("IMG", "A").attr_hash['optional']) -# assert("_blank" == toke.getTag("IMG", "A").attr_hash['target']) -# -class HTMLTokenizer - @@version = 1.0 - - # Get version of HTMLTokenizer lib - def self.version - @@version - end - - attr_reader :page - - # Create a new tokenizer, based on the content, used as a string. - def initialize(content) - @page = content.to_s - @cur_pos = 0 - end - - # Reset the parser, setting the current position back at the stop - def reset - @cur_pos = 0 - end - - # Look at the next token, but don't actually grab it - def peekNextToken - if @cur_pos == @page.length then return nil end - - if ?< == @page[@cur_pos] - # Next token is a tag of some kind - if '!--' == @page[(@cur_pos + 1), 3] - # Token is a comment - tag_end = @page.index('-->', (@cur_pos + 1)) - if tag_end.nil? - raise HTMLTokenizerError, "No end found to started comment:\n#{@page[@cur_pos,80]}" - end - # p @page[@cur_pos .. (tag_end+2)] - HTMLComment.new(@page[@cur_pos .. (tag_end + 2)]) - else - # Token is a html tag - tag_end = @page.index('>', (@cur_pos + 1)) - if tag_end.nil? - raise HTMLTokenizerError, "No end found to started tag:\n#{@page[@cur_pos,80]}" - end - # p @page[@cur_pos .. tag_end] - HTMLTag.new(@page[@cur_pos .. tag_end]) - end - else - # Next token is text - text_end = @page.index('<', @cur_pos) - text_end = text_end.nil? ? -1 : (text_end - 1) - # p @page[@cur_pos .. text_end] - HTMLText.new(@page[@cur_pos .. text_end]) - end - end - - # Get the next token, returns an instance of - # * HTMLText - # * HTMLToken - # * HTMLTag - def getNextToken - token = peekNextToken - if token - # @page = @page[token.raw.length .. -1] - # @page.slice!(0, token.raw.length) - @cur_pos += token.raw.length - end - #p token - #print token.raw - return token - end - - # Get a tag from the specified set of desired tags. - # For example: - # foo = toke.getTag("h1", "h2", "h3") - # Will return the next header tag encountered. - def getTag(*sought_tags) - sought_tags.collect! {|elm| elm.downcase} - - while (tag = getNextToken) - if tag.kind_of?(HTMLTag) and - (0 == sought_tags.length or sought_tags.include?(tag.tag_name)) - break - end - end - tag - end - - # Get all the text between the current position and the next tag - # (if specified) or a specific later tag - def getText(until_tag = nil) - if until_tag.nil? - if ?< == @page[@cur_pos] - # Next token is a tag, not text - "" - else - # Next token is text - getNextToken.text - end - else - ret_str = "" - - while (tag = peekNextToken) - if tag.kind_of?(HTMLTag) and tag.tag_name == until_tag - break - end - - if ("" != tag.text) - ret_str << (tag.text + " ") - end - getNextToken - end - - ret_str - end - end - - # Like getText, but squeeze all whitespace, getting rid of - # leading and trailing whitespace, and squeezing multiple - # spaces into a single space. - def getTrimmedText(until_tag = nil) - getText(until_tag).strip.gsub(/\s+/m, " ") - end - -end - -class HTMLTokenizerError < Exception -end - -# The parent class for all three types of HTML tokens -class HTMLToken - attr_accessor :raw - - # Initialize the token based on the raw text - def initialize(text) - @raw = text - end - - # By default, return exactly the string used to create the text - def to_s - raw - end - - # By default tokens have no text representation - def text - "" - end - - def trimmed_text - text.strip.gsub(/\s+/m, " ") - end - - # Compare to another based on the raw source - def ==(other) - raw == other.to_s - end -end - -# Class representing text that isn't inside a tag -class HTMLText < HTMLToken - def text - raw - end -end - -# Class representing an HTML comment -class HTMLComment < HTMLToken - attr_accessor :contents - def initialize(text) - super(text) - temp_arr = text.scan(/^$/m) - if temp_arr[0].nil? - raise HTMLTokenizerError, "Text passed to HTMLComment.initialize is not a comment" - end - - @contents = temp_arr[0][0] - end -end - -# Class representing an HTML tag -class HTMLTag < HTMLToken - attr_reader :end_tag, :tag_name - def initialize(text) - super(text) - if ?< != text[0] or ?> != text[-1] - raise HTMLTokenizerError, "Text passed to HTMLComment.initialize is not a comment" - end - - @attr_hash = Hash.new - @raw = text - - tag_name = text.scan(/[\w:-]+/)[0] - if tag_name.nil? - raise HTMLTokenizerError, "Error, tag is nil: #{tag_name}" - end - - if ?/ == text[1] - # It's an end tag - @end_tag = true - @tag_name = '/' + tag_name.downcase - else - @end_tag = false - @tag_name = tag_name.downcase - end - - @hashed = false - end - - # Retrieve a hash of all the tag's attributes. - # Lazily done, so that if you don't look at a tag's attributes - # things go quicker - def attr_hash - # Lazy initialize == don't build the hash until it's needed - if !@hashed - if !@end_tag - # Get the attributes - attr_arr = @raw.scan(/<[\w:-]+\s+(.*?)\/?>/m)[0] - if attr_arr.kind_of?(Array) - # Attributes found, parse them - attrs = attr_arr[0] - attr_arr = attrs.scan(/\s*([\w:-]+)(?:\s*=\s*("[^"]*"|'[^']*'|([^"'>][^\s>]*)))?/m) - # clean up the array by: - # * setting all nil elements to true - # * removing enclosing quotes - attr_arr.each { - |item| - val = if item[1].nil? - item[0] - elsif '"'[0] == item[1][0] or '\''[0] == item[1][0] - item[1][1 .. -2] - else - item[1] - end - @attr_hash[item[0].downcase] = val - } - end - end - @hashed = true - end - - #p self - - @attr_hash - end - - # Get the 'alt' text for a tag, if it exists, or an empty string otherwise - def text - if !end_tag - case tag_name - when 'img' - if !attr_hash['alt'].nil? - return attr_hash['alt'] - end - when 'applet' - if !attr_hash['alt'].nil? - return attr_hash['alt'] - end - end - end - return '' - end -end - diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/parsehtml.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/parsehtml.rb deleted file mode 100644 index 9074ab6c..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/parsehtml.rb +++ /dev/null @@ -1,44 +0,0 @@ -require "openid/yadis/htmltokenizer" -require 'cgi' - -module OpenID - module Yadis - def Yadis.html_yadis_location(html) - parser = HTMLTokenizer.new(html) - - # to keep track of whether or not we are in the head element - in_head = false - - begin - while el = parser.getTag('head', '/head', 'meta', 'body', '/body', - 'html', 'script') - - # we are leaving head or have reached body, so we bail - return nil if ['/head', 'body', '/body'].member?(el.tag_name) - - if el.tag_name == 'head' - unless el.to_s[-2] == ?/ # tag ends with a /: a short tag - in_head = true - end - end - next unless in_head - - if el.tag_name == 'script' - unless el.to_s[-2] == ?/ # tag ends with a /: a short tag - parser.getTag('/script') - end - end - - return nil if el.tag_name == 'html' - - if el.tag_name == 'meta' and (equiv = el.attr_hash['http-equiv']) - if ['x-xrds-location','x-yadis-location'].member?(equiv.downcase) - return CGI::unescapeHTML(el.attr_hash['content']) - end - end - end - rescue HTMLTokenizerError # just stop parsing if there's an error - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/services.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/services.rb deleted file mode 100644 index e3b3e0f6..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/services.rb +++ /dev/null @@ -1,42 +0,0 @@ - -require 'openid/yadis/filters' -require 'openid/yadis/discovery' -require 'openid/yadis/xrds' - -module OpenID - module Yadis - def Yadis.get_service_endpoints(input_url, flt=nil) - # Perform the Yadis protocol on the input URL and return an - # iterable of resulting endpoint objects. - # - # @param flt: A filter object or something that is convertable - # to a filter object (using mkFilter) that will be used to - # generate endpoint objects. This defaults to generating - # BasicEndpoint objects. - result = Yadis.discover(input_url) - begin - endpoints = Yadis.apply_filter(result.normalized_uri, - result.response_text, flt) - rescue XRDSError => err - raise DiscoveryFailure.new(err.to_s, nil) - end - - return [result.normalized_uri, endpoints] - end - - def Yadis.apply_filter(normalized_uri, xrd_data, flt=nil) - # Generate an iterable of endpoint objects given this input data, - # presumably from the result of performing the Yadis protocol. - - flt = Yadis.make_filter(flt) - et = Yadis.parseXRDS(xrd_data) - - endpoints = [] - each_service(et) { |service_element| - endpoints += flt.get_service_endpoints(normalized_uri, service_element) - } - - return endpoints - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xrds.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xrds.rb deleted file mode 100644 index 0ebf34ab..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xrds.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'rexml/document' -require 'rexml/element' -require 'rexml/xpath' - -require 'openid/yadis/xri' - -module OpenID - module Yadis - - XRD_NS_2_0 = 'xri://$xrd*($v*2.0)' - XRDS_NS = 'xri://$xrds' - - XRDS_NAMESPACES = { - 'xrds' => XRDS_NS, - 'xrd' => XRD_NS_2_0, - } - - class XRDSError < StandardError; end - - # Raised when there's an assertion in the XRDS that it does not - # have the authority to make. - class XRDSFraud < XRDSError - end - - def Yadis::get_canonical_id(iname, xrd_tree) - # Return the CanonicalID from this XRDS document. - # - # @param iname: the XRI being resolved. - # @type iname: unicode - # - # @param xrd_tree: The XRDS output from the resolver. - # - # @returns: The XRI CanonicalID or None. - # @returntype: unicode or None - - xrd_list = [] - REXML::XPath::match(xrd_tree.root, '/xrds:XRDS/xrd:XRD', XRDS_NAMESPACES).each { |el| - xrd_list << el - } - - xrd_list.reverse! - - cid_elements = [] - - if !xrd_list.empty? - xrd_list[0].elements.each { |e| - if !e.respond_to?('name') - next - end - if e.name == 'CanonicalID' - cid_elements << e - end - } - end - - cid_element = cid_elements[0] - - if !cid_element - return nil - end - - canonicalID = XRI.make_xri(cid_element.text) - - childID = canonicalID.downcase - - xrd_list[1..-1].each { |xrd| - parent_sought = childID[0...childID.rindex('!')] - - parent = XRI.make_xri(xrd.elements["CanonicalID"].text) - - if parent_sought != parent.downcase - raise XRDSFraud.new(sprintf("%s can not come from %s", parent_sought, - parent)) - end - - childID = parent_sought - } - - root = XRI.root_authority(iname) - if not XRI.provider_is_authoritative(root, childID) - raise XRDSFraud.new(sprintf("%s can not come from root %s", childID, root)) - end - - return canonicalID - end - - class XRDSError < StandardError - end - - def Yadis::parseXRDS(text) - if text.nil? - raise XRDSError.new("Not an XRDS document.") - end - - begin - d = REXML::Document.new(text) - rescue RuntimeError => why - raise XRDSError.new("Not an XRDS document. Failed to parse XML.") - end - - if is_xrds?(d) - return d - else - raise XRDSError.new("Not an XRDS document.") - end - end - - def Yadis::is_xrds?(xrds_tree) - xrds_root = xrds_tree.root - return (!xrds_root.nil? and - xrds_root.name == 'XRDS' and - xrds_root.namespace == XRDS_NS) - end - - def Yadis::get_yadis_xrd(xrds_tree) - REXML::XPath.each(xrds_tree.root, - '/xrds:XRDS/xrd:XRD[last()]', - XRDS_NAMESPACES) { |el| - return el - } - raise XRDSError.new("No XRD element found.") - end - - # aka iterServices in Python - def Yadis::each_service(xrds_tree, &block) - xrd = get_yadis_xrd(xrds_tree) - xrd.each_element('Service', &block) - end - - def Yadis::services(xrds_tree) - s = [] - each_service(xrds_tree) { |service| - s << service - } - return s - end - - def Yadis::expand_service(service_element) - es = service_element.elements - uris = es.each('URI') { |u| } - uris = prio_sort(uris) - types = es.each('Type/text()') - # REXML::Text objects are not strings. - types = types.collect { |t| t.to_s } - uris.collect { |uri| [types, uri.text, service_element] } - end - - # Sort a list of elements that have priority attributes. - def Yadis::prio_sort(elements) - elements.sort { |a,b| - a.attribute('priority').to_s.to_i <=> b.attribute('priority').to_s.to_i - } - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xri.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xri.rb deleted file mode 100644 index 89dd99af..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xri.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'openid/yadis/xrds' -require 'openid/fetchers' - -module OpenID - module Yadis - module XRI - - # The '(' is for cross-reference authorities, and hopefully has a - # matching ')' somewhere. - XRI_AUTHORITIES = ["!", "=", "@", "+", "$", "("] - - def self.identifier_scheme(identifier) - if (!identifier.nil? and - identifier.length > 0 and - (identifier.match('^xri://') or - XRI_AUTHORITIES.member?(identifier[0].chr))) - return :xri - else - return :uri - end - end - - # Transform an XRI reference to an IRI reference. Note this is - # not not idempotent, so do not apply this to an identifier more - # than once. XRI Syntax section 2.3.1 - def self.to_iri_normal(xri) - iri = xri.dup - iri.insert(0, 'xri://') if not iri.match('^xri://') - return escape_for_iri(iri) - end - - # Note this is not not idempotent, so do not apply this more than - # once. XRI Syntax section 2.3.2 - def self.escape_for_iri(xri) - esc = xri.dup - # encode all % - esc.gsub!(/%/, '%25') - esc.gsub!(/\((.*?)\)/) { |xref_match| - xref_match.gsub(/[\/\?\#]/) { |char_match| - CGI::escape(char_match) - } - } - return esc - end - - # Transform an XRI reference to a URI reference. Note this is not - # not idempotent, so do not apply this to an identifier more than - # once. XRI Syntax section 2.3.1 - def self.to_uri_normal(xri) - return iri_to_uri(to_iri_normal(xri)) - end - - # RFC 3987 section 3.1 - def self.iri_to_uri(iri) - uri = iri.dup - # for char in ucschar or iprivate - # convert each char to %HH%HH%HH (as many %HH as octets) - return uri - end - - def self.provider_is_authoritative(provider_id, canonical_id) - lastbang = canonical_id.rindex('!') - return false unless lastbang - parent = canonical_id[0...lastbang] - return parent == provider_id - end - - def self.root_authority(xri) - xri = xri[6..-1] if xri.index('xri://') == 0 - authority = xri.split('/', 2)[0] - if authority[0].chr == '(' - root = authority[0...authority.index(')')+1] - elsif XRI_AUTHORITIES.member?(authority[0].chr) - root = authority[0].chr - else - root = authority.split(/[!*]/)[0] - end - - self.make_xri(root) - end - - def self.make_xri(xri) - if xri.index('xri://') != 0 - xri = 'xri://' + xri - end - return xri - end - end - end -end diff --git a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xrires.rb b/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xrires.rb deleted file mode 100644 index 39439119..00000000 --- a/vendor/gems/ruby-openid-2.1.2/lib/openid/yadis/xrires.rb +++ /dev/null @@ -1,106 +0,0 @@ -require "cgi" -require "openid/yadis/xri" -require "openid/yadis/xrds" -require "openid/fetchers" - -module OpenID - - module Yadis - - module XRI - - class XRIHTTPError < StandardError; end - - class ProxyResolver - - DEFAULT_PROXY = 'http://proxy.xri.net/' - - def initialize(proxy_url=nil) - if proxy_url - @proxy_url = proxy_url - else - @proxy_url = DEFAULT_PROXY - end - - @proxy_url += '/' unless @proxy_url.match('/$') - end - - def query_url(xri, service_type=nil) - # URI normal form has a leading xri://, but we need to strip - # that off again for the QXRI. This is under discussion for - # XRI Resolution WD 11. - qxri = XRI.to_uri_normal(xri)[6..-1] - hxri = @proxy_url + qxri - args = {'_xrd_r' => 'application/xrds+xml'} - if service_type - args['_xrd_t'] = service_type - else - # don't perform service endpoint selection - args['_xrd_r'] += ';sep=false' - end - - return XRI.append_args(hxri, args) - end - - def query(xri, service_types) - # these can be query args or http headers, needn't be both. - # headers = {'Accept' => 'application/xrds+xml;sep=true'} - canonicalID = nil - - services = service_types.collect { |service_type| - url = self.query_url(xri, service_type) - begin - response = OpenID.fetch(url) - rescue - raise XRIHTTPError, ["Could not fetch #{xri}", $!] - end - raise XRIHTTPError, "Could not fetch #{xri}" if response.nil? - - xrds = Yadis::parseXRDS(response.body) - canonicalID = Yadis::get_canonical_id(xri, xrds) - - Yadis::services(xrds) unless xrds.nil? - } - # TODO: - # * If we do get hits for multiple service_types, we're almost - # certainly going to have duplicated service entries and - # broken priority ordering. - services = services.inject([]) { |flatter, some_services| - flatter += some_services unless some_services.nil? - } - - return canonicalID, services - end - end - - def self.urlencode(args) - a = [] - args.each do |key, val| - a << (CGI::escape(key) + "=" + CGI::escape(val)) - end - a.join("&") - end - - def self.append_args(url, args) - return url if args.length == 0 - - # rstrip question marks - rstripped = url.dup - while rstripped[-1].chr == '?' - rstripped = rstripped[0...rstripped.length-1] - end - - if rstripped.index('?') - sep = '&' - else - sep = '?' - end - - return url + sep + XRI.urlencode(args) - end - - end - - end - -end diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/accept.txt b/vendor/gems/ruby-openid-2.1.2/test/data/accept.txt deleted file mode 100644 index 884ff662..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/accept.txt +++ /dev/null @@ -1,124 +0,0 @@ -# Accept: [Accept: header value from RFC2616, -# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html] -# Available: [whitespace-separated content types] -# Expected: [Accept-header like list, containing the available content -# types with their q-values] - -Accept: */* -Available: text/plain -Expected: text/plain; q=1.0 - -Accept: */* -Available: text/plain, text/html -Expected: text/plain; q=1.0, text/html; q=1.0 - -# The order matters -Accept: */* -Available: text/html, text/plain -Expected: text/html; q=1.0, text/plain; q=1.0 - -Accept: text/*, */*; q=0.9 -Available: text/plain, image/jpeg -Expected: text/plain; q=1.0, image/jpeg; q=0.9 - -Accept: text/*, */*; q=0.9 -Available: image/jpeg, text/plain -Expected: text/plain; q=1.0, image/jpeg; q=0.9 - -# wildcard subtypes still reject differing main types -Accept: text/* -Available: image/jpeg, text/plain -Expected: text/plain; q=1.0 - -Accept: text/html -Available: text/html -Expected: text/html; q=1.0 - -Accept: text/html, text/* -Available: text/html -Expected: text/html; q=1.0 - -Accept: text/html, text/* -Available: text/plain, text/html -Expected: text/plain; q=1.0, text/html; q=1.0 - -Accept: text/html, text/*; q=0.9 -Available: text/plain, text/html -Expected: text/html; q=1.0, text/plain; q=0.9 - -# If a more specific type has a higher q-value, then the higher value wins -Accept: text/*; q=0.9, text/html -Available: text/plain, text/html -Expected: text/html; q=1.0, text/plain; q=0.9 - -Accept: */*, text/*; q=0.9, text/html; q=0.1 -Available: text/plain, text/html, image/monkeys -Expected: image/monkeys; q=1.0, text/plain; q=0.9, text/html; q=0.1 - -Accept: text/*, text/html; q=0 -Available: text/html -Expected: - -Accept: text/*, text/html; q=0 -Available: text/html, text/plain -Expected: text/plain; q=1.0 - -Accept: text/html -Available: text/plain -Expected: - -Accept: application/xrds+xml, text/html; q=0.9 -Available: application/xrds+xml, text/html -Expected: application/xrds+xml; q=1.0, text/html; q=0.9 - -Accept: application/xrds+xml, */*; q=0.9 -Available: application/xrds+xml, text/html -Expected: application/xrds+xml; q=1.0, text/html; q=0.9 - -Accept: application/xrds+xml, application/xhtml+xml; q=0.9, text/html; q=0.8, text/xml; q=0.7 -Available: application/xrds+xml, text/html -Expected: application/xrds+xml; q=1.0, text/html; q=0.8 - -# See http://www.rfc-editor.org/rfc/rfc3023.txt, section A.13 -Accept: application/xrds -Available: application/xrds+xml -Expected: - -Accept: application/xrds+xml -Available: application/xrds -Expected: - -Accept: application/xml -Available: application/xrds+xml -Expected: - -Available: application/xrds+xml -Accept: application/xml -Expected: - -Available: -Accept: not_a_content_type -Expected: - -Available: text/html -Accept: not_a_content_type, text/html -Expected: text/html; q=1.0 - -################################################# -# The tests below this line are documentation of how this library -# works. If the implementation changes, it's acceptable to change the -# test to reflect that. These are specified so that we can make sure -# that the current implementation actually works the way that we -# expect it to given these inputs. - -Accept: text/html;level=1 -Available: text/html -Expected: text/html; q=1.0 - -Accept: text/html; level=1, text/html; level=9; q=0.1 -Available: text/html -Expected: text/html; q=1.0 - -Accept: text/html; level=9; q=0.1, text/html; level=1 -Available: text/html -Expected: text/html; q=1.0 diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/dh.txt b/vendor/gems/ruby-openid-2.1.2/test/data/dh.txt deleted file mode 100644 index 0fa52314..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/dh.txt +++ /dev/null @@ -1,29 +0,0 @@ -130706940119084053627151828062879423433929180135817317038378606310097533503449582079984816816837125851552273641820339909167103200910805078308128174143174269944095368580519322913514764528012639683546377014716235962867583443566164615728897857285824741767070432119909660645255499710701356135207437699643611094585 139808169914464096465921128085565621767096724855516655439365028496569658038844954238931647642811548254956660405394116677296461848124300258439895306367561416289126854788101396379292925819850897858045772500578222021901631436550118958972312221974009238050517034542286574826081826542722270952769078386418682059418 -91966407878983240112417790733941098492087186469785726449910011271065622315680646030230288265496017310433513856308693810812043160919214636748486185212617634222158204354206411031403206076739932806412551605172319515223573351072757800448643935018534945933808900467686115619932664888581913179496050117713298715475 88086484332488517006277516020842172054013692832175783214603951240851750819999098631851571207693874357651112736088114133607400684776234181681933311972926752846692615822043533641407510569745606256772455614745111122033229877596984718963046218854103292937700694160593653595134512369959987897086639788909618660591 -94633950701209990078055218830969910271587805983595045023718108184189787131629772007048606080263109446462048743696369276578815611098215686598630889831104860221067872883514840819381234786050098278403321905311637820524177879167250981289318356078312300538871435101338967079907049912435983871847334104247675360099 136836393035803488129856151345450008294260680733328546556640578838845312279198933806383329293483852515700876505956362639881210101974254765087350842271260064592406308509078284840473735904755203614987286456952991025347168970462354352741159076541157478949094536405618626397435745496863324654768971213730622037771 -24685127248019769965088146297942173464487677364928435784091685260262292485380918213538979925891771204729738138857126454465630594391449913947358655368215901119137728648638547728497517587701248406019427282237279437409508871300675355166059811431191200555457304463617727969228965042729205402243355816702436970430 103488011917988946858248200111251786178288940265978921633592888293430082248387786443813155999158786903216094876295371112716734481877806417714913656921169196196571699893360825510307056269738593971532017994987406325068886420548597161498019372380511676314312298122272401348856314619382867707981701472607230523868 -116791045850880292989786005885944774698035781824784400772676299590038746153860847252706167458966356897309533614849402276819438194497464696186624618374179812548893947178936305721131565012344462048549467883494038577857638815386798694225798517783768606048713198211730870155881426709644960689953998714045816205549 25767875422998856261320430397505398614439586659207416236135894343577952114994718158163212134503751463610021489053571733974769536157057815413209619147486931502025658987681202196476489081257777148377685478756033509708349637895740799542063593586769082830323796978935454479273531157121440998804334199442003857410 -75582226959658406842894734694860761896800153014775231713388264961517169436476322183886891849966756849783437334069692683523296295601533803799559985845105706728538458624387103621364117548643541824878550074680443708148686601108223917493525070861593238005735446708555769966855130921562955491250908613793521520082 51100990616369611694975829054222013346248289055987940844427061856603230021472379888102172458517294080775792439385531234808129302064303666640376750139242970123503857186428797403843206765926798353022284672682073397573130625177187185114726049347844460311761033584101482859992951420083621362870301150543916815123 -22852401165908224137274273646590366934616265607879280260563022941455466297431255072303172649495519837876946233272420969249841381161312477263365567831938496555136366981954001163034914812189448922853839616662859772087929140818377228980710884492996109434435597500854043325062122184466315338260530734979159890875 35017410720028595029711778101507729481023945551700945988329114663345341120595162378885287946069695772429641825579528116641336456773227542256911497084242947904528367986325800537695079726856460817606404224094336361853766354225558025931211551975334149258299477750615397616908655079967952372222383056221992235704 -37364490883518159794654045194678325635036705086417851509136183713863262621334636905291385255662750747808690129471989906644041585863034419130023070856805511017402434123099100618568335168939301014148587149578150068910141065808373976114927339040964292334109797421173369274978107389084873550233108940239410902552 40916262212189137562350357241447034318002130016858244002788189310078477605649010031339865625243230798681216437501833540185827501244378529230150467789369234869122179247196276164931090039290879808162629109742198951942358028123056268054775108592325500609335947248599688175189333996086475013450537086042387719925 -42030470670714872936404499074069849778147578537708230270030877866700844337372497704027708080369726758812896818567830863540507961487472657570488625639077418109017434494794778542739932765561706796300920251933107517954265066804108669800167526425723377411855061131982689717887180411017924173629124764378241885274 124652439272864857598747946875599560379786580730218192165733924418687522301721706620565030507816884907589477351553268146177293719586287258662025940181301472851649975563004543250656807255226609296537922304346339513054316391667044301386950180277940536542183725690479451746977789001659540839582630251935163344393 -33176766914206542084736303652243484580303865879984981189372762326078776390896986743451688462101732968104375838228070296418541745483112261133079756514082093269959937647525005374035326747696591842313517634077723301677759648869372517403529488493581781546743147639937580084065663597330159470577639629864369972900 67485835091897238609131069363014775606263390149204621594445803179810038685760826651889895397414961195533694176706808504447269558421955735607423135937153901140512527504198912146656610630396284977496295289999655140295415981288181545277299615922576281262872097567020980675200178329219970170480653040350512964539 -131497983897702298481056962402569646971797912524360547236788650961059980711719600424210346263081838703940277066368168874781981151411096949736205282734026497995296147418292226818536168555712128736975034272678008697869326747592750850184857659420541708058277866000692785617873742438060271311159568468507825422571 5400380840349873337222394910303409203226429752629134721503171858543984393161548520471799318518954232197106728096866840965784563043721652790856860155702760027304915133166173298206604451826182024471262142046935060360564569939062438160049193241369468208458085699995573492688298015026628427440418009025072261296 -83265103005695640943261961853521077357830295830250157593141844209296716788437615940096402365505416686459260302419338241462783388722843946886845478224048360927114533590583464979009731440049610985062455108831881153988321298531365779084012803908832525921630534096740755274371500276660832724874701671184539131864 141285570207910287798371174771658911045525474449663877845558585668334618068814605961306961485855329182957174312715910923324965889174835444049526313968571611940626279733302104955951067959291852710640374412577070764165811275030632465290729619533330733368808295932659463215921521905553936914975786500018720073003 -68435028583616495789148116911096163791710022987677894923742899873596891423986951658100606742052014161171185231735413902875605720814417622409817842932759492013585936536452615480700628719795872201528559780249210820284350401473564919576289210869896327937002173624497942136329576506818749730506884927872345019446 134655528287263100540003157571441260698452262106680191153945271167894435782028803135774578949200580551016388918860856991026082917835209212892423567114480975540305860034439015788120390011692862968771136814777768281366591257663821495720134621172848947971117885754539770645621669309650476331439675400544167728223 -97765390064836080322590528352647421920257073063706996347334558390461274981996865736612531330863478931481491964338380362350271734683183807511097331539820133036984271653285063355715726806139083282458695728902452215405696318402583540317419929113959816258829534543044153959951908676300847164682178008704099351835 92552521881196975294401505656851872247567784546370503402756239533783651371688190302773864319828182042605239246779598629409815474038541272600580320815319709309111399294952620375093803971373108792300726524826209329889463854451846561437729676142864421966497641824498079067929811613947148353921163336822026640804 -145767094672933012300753301037546647564595762930138884463767054235112032706630891961371504668013023047595721138624016493638510710257541241706724342585654715468628355455898091951826598092812212209834746162089753649871544789379424903025374228231365026585872808685759231756517703720396301355299998059523896918448 116669462839999965355861187716880953863237226719689755457884414384663576662696981997535568446560375442532084973721539944428004043491468494548231348032618218312515409944970197902589794303562379864012797605284844016184274353252071642511293089390472576498394410829972525726474727579603392265177009323768966538608 -34172517877854802711907683049441723730724885305592620486269966708379625109832852005775048584124451699198484092407720344962116726808090368739361658889584507734617844212547181476646725256303630128954338675520938806905779837227983648887192531356390902975904503218654196581612781227843742951241442641220856414232 126013077261793777773236390821108423367648447987653714614732477073177878509574051196587476846560696305938891953527959347566502332765820074506907037627115954790645652211088723122982633069089920979477728376746424256704724173255656757918995039125823421607024407307091796807227896314403153380323770001854211384322 -9979624731056222925878866378063961280844793874828281622845276060532093809300121084179730782833657205171434732875093693074415298975346410131191865198158876447591891117577190438695367929923494177555818480377241891190442070100052523008290671797937772993634966511431668500154258765510857129203107386972819651767 76559085024395996164590986654274454741199399364851956129137304209855150918182685643729981600389513229011956888957763987167398150792454613751473654448162776379362213885827651020309844507723069713820393068520302223477225569348080362344052033711960892643036147232270133731530049660264526964146237693063093765111 -18162696663677410793062235946366423954875282212790518677684260521370996677183041664345920941714064628111537529793170736292618705900247450994864220481135611781148410617609559050220262121494712903009168783279356915189941268264177631458029177102542745167475619936272581126346266816618866806564180995726437177435 63244550218824945129624987597134280916829928261688093445040235408899092619821698537312158783367974202557699994650667088974727356690181336666077506063310290098995215324552449858513870629176838494348632073938023916155113126203791709810160925798130199717340478393420816876665127594623142175853115698049952126277 -4817943161362708117912118300716778687157593557807116683477307391846133734701449509121209661982298574607233039490570567781316652698287671086985501523197566560479906850423709894582834963398034434055472063156147829131181965140631257939036683622084290629927807369457311894970308590034407761706800045378158588657 61612160237840981966750225147965256022861527286827877531373888434780789812764688703260066154973576040405676432586962624922734102370509771313805122788566405984830112657060375568510809122230960988304085950306616401218206390412815884549481965750553137717475620505076144744211331973240555181377832337912951699135 -36363324947629373144612372870171042343590861026293829791335153646774927623889458346817049419803031378037141773848560341251355283891019532059644644509836766167835557471311319194033709837770615526356168418160386395260066262292757953919140150454538786106958252854181965875293629955562111756775391296856504912587 86831561031659073326747216166881733513938228972332631084118628692228329095617884068498116676787029033973607066377816508795286358748076949738854520048303930186595481606562375516134920902325649683618195251332651685732712539073110524182134321873838204219194459231650917098791250048469346563303077080880339797744 -26406869969418301728540993821409753036653370247174689204659006239823766914991146853283367848649039747728229875444327879875275718711878211919734397349994000106499628652960403076186651083084423734034070082770589453774926850920776427074440483233447839259180467805375782600203654373428926653730090468535611335253 100139935381469543084506312717977196291289016554846164338908226931204624582010530255955411615528804421371905642197394534614355186795223905217732992497673429554618838376065777445760355552020655667172127543653684405493978325270279321013143828897100500212200358450649158287605846102419527584313353072518101626851 -92613116984760565837109105383781193800503303131143575169488835702472221039082994091847595094556327985517286288659598094631489552181233202387028607421487026032402972597880028640156629614572656967808446397456622178472130864873587747608262139844319805074476178618930354824943672367046477408898479503054125369731 30023391082615178562263328892343821010986429338255434046051061316154579824472412477397496718186615690433045030046315908170615910505869972621853946234911296439134838951047107272129711854649412919542407760508235711897489847951451200722151978578883748353566191421685659370090024401368356823252748749449302536931 -31485815361342085113278193504381994806529237123359718043079410511224607873725611862217941085749929342777366642477711445011074784469367917758629403998067347054115844421430072631339788256386509261291675080191633908849638316409182455648806133048549359800886124554879661473112614246869101243501787363247762961784 114503770698890543429251666713050844656853278831559195214556474458830029271801818536133531843456707474500106283648085144619097572354066554819887152106174400667929098257361286338795493838820850475790977445807435511982704395422526800272723708548541616513134676140304653112325071112865020365664833601046215694089 -76882090884790547431641385530818076533805072109483843307806375918023300052767710853172670987385376253156912268523505310624133905633437815297307463917718596711590885553760690350221265675690787249135345226947453988081566088302642706234126002514517416493192624887800567412565527886687096028028124049522890448168 15056463217273240496622619354104573042767532856243223052125822509781815362480522535564283485059790932505429110157271454207173426525345813426696743168079246510944969446574354255284952839036431873039487144279164893710061580467579842173706653409487110282515691099753380094215805485573768509475850463001549608836 -52345178981230648108672997265819959243255047568833938156267924185186047373470984278294897653277996726416846430969793375429223610099546622112048283560483136389901514170116723365811871938630317974150540909650396429631704968748113009366339718498979597226137532343384889080245796447593572468846438769413505393967 32148494517199936472358017244372701214529606506776255341152991328091526865643069587953759877295255050519124541457805199596762210567333445908166076384465183589342153762720515477404466193879418014196727238972417616122646440870364200208488239778452378059236162633837824948613596114768455832408342040970780086 -41095268619128788015767564971105114602454449306041732792746397800275041704886345704294273937217484580365505320134717320083763349380629342859670693445658118959823430378844830923452105707338162448974869312012791385772125813291388247857971218575518319578818336960572244046567099555399203328678654466958536663208 92166550199033418923713824997841892577149715275633481076285269142670107687867024550593869464613175882141630640739938334001211714884975032600306279287443909448541179109981755796752132502127330056736913454039526413284519137059580845856736918773597087836203497066909257930043736166431682872083389105176299181629 -40049143661018504441607875135884755310012910557581028447435354354754245291878800571089144452035026644953322330676651798951447670184106450649737772686119714700743396359069052813433030118630105307022867200053964644574786137276428546712005171080129190959914708907200288299169344380390093918556722227705114244981 108159089972386282154772900619022507336076619354549601813179459338897131937353741544606392560724999980281424266891537298473163753022749859939445293926707568015958367188089915420630082556748668489756475027008449860889202622698060097015044886961901650857610841562477736791450080980702347705778074391774667412741 -69905259478181995876884927656894491893594530150260951315109404530530357998889589977208787140430938039028941393673520799460431992051993157468616168400324834880926190141581037597526917869362292931957289043707855837933490285814769110495657056206391880865972389421774822461752702336812585852278453803972600333734 71821415380277072313878763768684432371552628204186742842154591000123020597011744840460964835414360968627162765288463383113375595799297552681618876474019263288277398833725479226930770694271622605114061622753165584075733358178384410640349907375170170910499615355511313349300918885560131539570707695789106185664 -26945345439378873515011714350080059082081595419023056538696949766471272811362104837806324694947413603019863785876836706911406330379274553386254346050697348395574746891556054334903838949157798006141473389066020212044825140294048709654273698482867946522782450500680195477050110145664069582549935651920545151500 80313315938584480048642653013876614091607852535582224914294013785054094052454758327935781971746329853786568549510067442145637007308960551652864942042189241081946607011847245280773379099020221884296226818685556430275385068764313042226925852500883894269809033380734632866477789520106865758504064806906234130588 diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/example-xrds.xml b/vendor/gems/ruby-openid-2.1.2/test/data/example-xrds.xml deleted file mode 100644 index 101ba3bd..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/example-xrds.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - http://example.com/ - http://www.openidenabled.com/ - - - - diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/linkparse.txt b/vendor/gems/ruby-openid-2.1.2/test/data/linkparse.txt deleted file mode 100644 index 2fa38cde..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/linkparse.txt +++ /dev/null @@ -1,587 +0,0 @@ -Num Tests: 72 - -OpenID link parsing test cases -Copyright (C) 2005-2008, JanRain, Inc. -See COPYING for license information. - -File format ------------ - -All text before the first triple-newline (this chunk) should be ignored. - -This file may be interpreted as Latin-1 or UTF-8. - -Test cases separated by three line separators (`\n\n\n'). The test -cases consist of a headers section followed by a data block. These are -separated by a double newline. The headers consist of the header name, -followed by a colon, a space, the value, and a newline. There must be -one, and only one, `Name' header for a test case. There may be zero or -more link headers. The `Link' header consists of whitespace-separated -attribute pairs. A link header with an empty string as a value -indicates an empty but present link tag. The attribute pairs are `=' -separated and not quoted. - -Optional Links and attributes have a trailing `*'. A compilant -implementation may produce this as output or may not. A compliant -implementation will not produce any output that is absent from this -file. - - -Name: No link tag at all - - - - - - - -Name: Link element first - - - - -Name: Link inside HTML, not head - - - - - -Name: Link inside head, not html - - - - - -Name: Link inside html, after head - - - - - - - -Name: Link inside html, before head - - - - - - -Name: Link before html and head - - - - - - -Name: Link after html document with head - - - - - - - - -Name: Link inside html inside head, inside another html - - - - - - - -Name: Link inside html inside head - - - - - - -Name: link inside body inside head inside html - - - - - - - -Name: Link inside head inside head inside html - - - - - - - -Name: Link inside script inside head inside html - - - - - - -Name: Link inside comment inside head inside html - - - - - - -Name: Link inside of head after short head - - - - - - - -Name: Plain vanilla -Link: - - - - - - -Name: Ignore tags in the namespace -Link*: - - - - - - - - -Name: Short link tag -Link: - - - - - - -Name: Spaces in the HTML tag -Link: - - - - - - -Name: Spaces in the head tag -Link: - - - - - - -Name: Spaces in the link tag -Link: - - - - - - -Name: No whitespace -Link: - - - - -Name: Closed head tag -Link: - - - - - - - -Name: One good, one bad (after close head) -Link: - - - - - - - - -Name: One good, one bad (after open body) -Link: - - - - - - - - -Name: ill formed (missing close head) -Link: - - - - - - - -Name: Ill formed (no close head, link after ) -Link: - - - - - - - - -Name: Ignore random tags inside of html -Link: - - - - - -<link> - - -Name: case-folding -Link*: - -<HtMl> -<hEaD> -<LiNk> - - -Name: unexpected tags -Link: - -<butternut> -<html> -<summer> -<head> -<turban> -<link> - - -Name: un-closed script tags -Link*: - -<html> -<head> -<script> -<link> - - -Name: un-closed script tags (no whitespace) -Link*: - -<html><head><script><link> - - -Name: un-closed comment -Link*: - -<html> -<head> -<!-- -<link> - - -Name: un-closed CDATA -Link*: - -<html> -<head> -<![CDATA[ -<link> - - -Name: cdata-like -Link*: - -<html> -<head> -<![ACORN[ -<link> -]]> - - -Name: comment close only -Link: - -<html> -<head> -<link> ---> - - -Name: Vanilla, two links -Link: -Link: - -<html> -<head> -<link> -<link> - - -Name: extra tag, two links -Link: -Link: - -<html> -<gold nugget> -<head> -<link> -<link> - - -Name: case-fold, body ends, two links -Link: -Link*: - -<html> -<head> -<link> -<LiNk> -<body> -<link> - - -Name: simple, non-quoted rel -Link: rel=openid.server - -<html><head><link rel=openid.server> - - -Name: short tag has rel -Link: rel=openid.server - -<html><head><link rel=openid.server/> - - -Name: short tag w/space has rel -Link: rel=openid.server - -<html><head><link rel=openid.server /> - - -Name: extra non-attribute, has rel -Link: rel=openid.server hubbard*=hubbard - -<html><head><link hubbard rel=openid.server> - - -Name: non-attr, has rel, short -Link: rel=openid.server hubbard*=hubbard - -<html><head><link hubbard rel=openid.server/> - - -Name: non-attr, has rel, short, space -Link: rel=openid.server hubbard*=hubbard - -<html><head><link hubbard rel=openid.server /> - - -Name: misplaced slash has rel -Link: rel=openid.server - -<html><head><link / rel=openid.server> - - -Name: quoted rel -Link: rel=openid.server - -<html><head><link rel="openid.server"> - - -Name: single-quoted rel -Link: rel=openid.server - -<html><head><link rel='openid.server'> - - -Name: two links w/ rel -Link: x=y -Link: a=b - -<html><head><link x=y><link a=b> - - -Name: non-entity -Link: x=&y - -<html><head><link x=&y> - - -Name: quoted non-entity -Link: x=&y - -<html><head><link x="&y"> - - -Name: quoted entity -Link: x=& - -<html><head><link x="&"> - - -Name: entity not processed -Link: x= - -<html><head><link x=""> - - -Name: < -Link: x=< - -<html><head><link x="<"> - - -Name: > -Link: x=> - -<html><head><link x=">"> - - -Name: " -Link: x=" - -<html><head><link x="""> - - -Name: &" -Link: x=&" - -<html><head><link x="&""> - - -Name: mixed entity and non-entity -Link: x=&"…> - -<html><head><link x="&"…>"> - - -Name: mixed entity and non-entity (w/normal chars) -Link: x=x&"…>x - -<html><head><link x="x&"…>x"> - - -Name: broken tags -Link*: x=y -Link*: x=y< - -<html><head><link x=y<> - - -Name: missing close pointy -Link*: x=y -Link*: x=y<link z=y -Link*: z=y - -<html><head><link x=y<link z=y /> - - -Name: missing attribute value -Link: x=y y*=y -Link: x=y - -<html><head><link x=y y=><link x=y /> - - -Name: Missing close pointy (no following) -Link*: x=y - -<html><head><link x=y - - -Name: Should be quoted -Link*: x=< - -<html><head><link x="<"> - - -Name: Should be quoted (2) -Link*: x=> -Link*: x=x - -<html><head><link x=">"> - - -Name: Repeated attribute -Link: x=y - -<html><head><link x=z x=y> - - -Name: Repeated attribute (2) -Link: x=y - -<html><head><link x=y x=y> - - -Name: Two attributes -Link: x=y y=z - -<html><head><link x=y y=z> - - -Name: Well-formed link rel="openid.server" -Link: rel=openid.server href=http://www.myopenid.com/server - -<html> - <head> - <link rel="openid.server" - href="http://www.myopenid.com/server" /> - </head> -</html> - - -Name: Well-formed link rel="openid.server" and "openid.delegate" -Link: rel=openid.server href=http://www.myopenid.com/server -Link: rel=openid.delegate href=http://example.myopenid.com/ - -<html><head><link rel="openid.server" - href="http://www.myopenid.com/server" /> - <link rel="openid.delegate" href="http://example.myopenid.com/" /> -</head></html> - - -Name: from brian's livejournal page -Link: rel=stylesheet href=http://www.livejournal.com/~serotta/res/319998/stylesheet?1130478711 type=text/css -Link: rel=openid.server href=http://www.livejournal.com/openid/server.bml - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <link rel="stylesheet" - href="http://www.livejournal.com/~serotta/res/319998/stylesheet?1130478711" - type="text/css" /> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta name="foaf:maker" - content="foaf:mbox_sha1sum '12f8abdacb5b1a806711e23249da592c0d316260'" /> - <meta name="robots" content="noindex, nofollow, noarchive" /> - <meta name="googlebot" content="nosnippet" /> - <link rel="openid.server" - href="http://www.livejournal.com/openid/server.bml" /> - <title>Brian - - - -Name: non-ascii (Latin-1 or UTF8) -Link: x=® - - - - diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/n2b64 b/vendor/gems/ruby-openid-2.1.2/test/data/n2b64 deleted file mode 100644 index b12a2460..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/n2b64 +++ /dev/null @@ -1,650 +0,0 @@ -AA== 0 -AQ== 1 -Ag== 2 -Aw== 3 -BA== 4 -BQ== 5 -Bg== 6 -Bw== 7 -CA== 8 -CQ== 9 -Cg== 10 -Cw== 11 -DA== 12 -DQ== 13 -Dg== 14 -Dw== 15 -EA== 16 -EQ== 17 -Eg== 18 -Ew== 19 -FA== 20 -FQ== 21 -Fg== 22 -Fw== 23 -GA== 24 -GQ== 25 -Gg== 26 -Gw== 27 -HA== 28 -HQ== 29 -Hg== 30 -Hw== 31 -IA== 32 -IQ== 33 -Ig== 34 -Iw== 35 -JA== 36 -JQ== 37 -Jg== 38 -Jw== 39 -KA== 40 -KQ== 41 -Kg== 42 -Kw== 43 -LA== 44 -LQ== 45 -Lg== 46 -Lw== 47 -MA== 48 -MQ== 49 -Mg== 50 -Mw== 51 -NA== 52 -NQ== 53 -Ng== 54 -Nw== 55 -OA== 56 -OQ== 57 -Og== 58 -Ow== 59 -PA== 60 -PQ== 61 -Pg== 62 -Pw== 63 -QA== 64 -QQ== 65 -Qg== 66 -Qw== 67 -RA== 68 -RQ== 69 -Rg== 70 -Rw== 71 -SA== 72 -SQ== 73 -Sg== 74 -Sw== 75 -TA== 76 -TQ== 77 -Tg== 78 -Tw== 79 -UA== 80 -UQ== 81 -Ug== 82 -Uw== 83 -VA== 84 -VQ== 85 -Vg== 86 -Vw== 87 -WA== 88 -WQ== 89 -Wg== 90 -Ww== 91 -XA== 92 -XQ== 93 -Xg== 94 -Xw== 95 -YA== 96 -YQ== 97 -Yg== 98 -Yw== 99 -ZA== 100 -ZQ== 101 -Zg== 102 -Zw== 103 -aA== 104 -aQ== 105 -ag== 106 -aw== 107 -bA== 108 -bQ== 109 -bg== 110 -bw== 111 -cA== 112 -cQ== 113 -cg== 114 -cw== 115 -dA== 116 -dQ== 117 -dg== 118 -dw== 119 -eA== 120 -eQ== 121 -eg== 122 -ew== 123 -fA== 124 -fQ== 125 -fg== 126 -fw== 127 -AIA= 128 -AIE= 129 -AII= 130 -AIM= 131 -AIQ= 132 -AIU= 133 -AIY= 134 -AIc= 135 -AIg= 136 -AIk= 137 -AIo= 138 -AIs= 139 -AIw= 140 -AI0= 141 -AI4= 142 -AI8= 143 -AJA= 144 -AJE= 145 -AJI= 146 -AJM= 147 -AJQ= 148 -AJU= 149 -AJY= 150 -AJc= 151 -AJg= 152 -AJk= 153 -AJo= 154 -AJs= 155 -AJw= 156 -AJ0= 157 -AJ4= 158 -AJ8= 159 -AKA= 160 -AKE= 161 -AKI= 162 -AKM= 163 -AKQ= 164 -AKU= 165 -AKY= 166 -AKc= 167 -AKg= 168 -AKk= 169 -AKo= 170 -AKs= 171 -AKw= 172 -AK0= 173 -AK4= 174 -AK8= 175 -ALA= 176 -ALE= 177 -ALI= 178 -ALM= 179 -ALQ= 180 -ALU= 181 -ALY= 182 -ALc= 183 -ALg= 184 -ALk= 185 -ALo= 186 -ALs= 187 -ALw= 188 -AL0= 189 -AL4= 190 -AL8= 191 -AMA= 192 -AME= 193 -AMI= 194 -AMM= 195 -AMQ= 196 -AMU= 197 -AMY= 198 -AMc= 199 -AMg= 200 -AMk= 201 -AMo= 202 -AMs= 203 -AMw= 204 -AM0= 205 -AM4= 206 -AM8= 207 -ANA= 208 -ANE= 209 -ANI= 210 -ANM= 211 -ANQ= 212 -ANU= 213 -ANY= 214 -ANc= 215 -ANg= 216 -ANk= 217 -ANo= 218 -ANs= 219 -ANw= 220 -AN0= 221 -AN4= 222 -AN8= 223 -AOA= 224 -AOE= 225 -AOI= 226 -AOM= 227 -AOQ= 228 -AOU= 229 -AOY= 230 -AOc= 231 -AOg= 232 -AOk= 233 -AOo= 234 -AOs= 235 -AOw= 236 -AO0= 237 -AO4= 238 -AO8= 239 -APA= 240 -APE= 241 -API= 242 -APM= 243 -APQ= 244 -APU= 245 -APY= 246 -APc= 247 -APg= 248 -APk= 249 -APo= 250 -APs= 251 -APw= 252 -AP0= 253 -AP4= 254 -AP8= 255 -AQA= 256 -AQE= 257 -AQI= 258 -AQM= 259 -AQQ= 260 -AQU= 261 -AQY= 262 -AQc= 263 -AQg= 264 -AQk= 265 -AQo= 266 -AQs= 267 -AQw= 268 -AQ0= 269 -AQ4= 270 -AQ8= 271 -ARA= 272 -ARE= 273 -ARI= 274 -ARM= 275 -ARQ= 276 -ARU= 277 -ARY= 278 -ARc= 279 -ARg= 280 -ARk= 281 -ARo= 282 -ARs= 283 -ARw= 284 -AR0= 285 -AR4= 286 -AR8= 287 -ASA= 288 -ASE= 289 -ASI= 290 -ASM= 291 -ASQ= 292 -ASU= 293 -ASY= 294 -ASc= 295 -ASg= 296 -ASk= 297 -ASo= 298 -ASs= 299 -ASw= 300 -AS0= 301 -AS4= 302 -AS8= 303 -ATA= 304 -ATE= 305 -ATI= 306 -ATM= 307 -ATQ= 308 -ATU= 309 -ATY= 310 -ATc= 311 -ATg= 312 -ATk= 313 -ATo= 314 -ATs= 315 -ATw= 316 -AT0= 317 -AT4= 318 -AT8= 319 -AUA= 320 -AUE= 321 -AUI= 322 -AUM= 323 -AUQ= 324 -AUU= 325 -AUY= 326 -AUc= 327 -AUg= 328 -AUk= 329 -AUo= 330 -AUs= 331 -AUw= 332 -AU0= 333 -AU4= 334 -AU8= 335 -AVA= 336 -AVE= 337 -AVI= 338 -AVM= 339 -AVQ= 340 -AVU= 341 -AVY= 342 -AVc= 343 -AVg= 344 -AVk= 345 -AVo= 346 -AVs= 347 -AVw= 348 -AV0= 349 -AV4= 350 -AV8= 351 -AWA= 352 -AWE= 353 -AWI= 354 -AWM= 355 -AWQ= 356 -AWU= 357 -AWY= 358 -AWc= 359 -AWg= 360 -AWk= 361 -AWo= 362 -AWs= 363 -AWw= 364 -AW0= 365 -AW4= 366 -AW8= 367 -AXA= 368 -AXE= 369 -AXI= 370 -AXM= 371 -AXQ= 372 -AXU= 373 -AXY= 374 -AXc= 375 -AXg= 376 -AXk= 377 -AXo= 378 -AXs= 379 -AXw= 380 -AX0= 381 -AX4= 382 -AX8= 383 -AYA= 384 -AYE= 385 -AYI= 386 -AYM= 387 -AYQ= 388 -AYU= 389 -AYY= 390 -AYc= 391 -AYg= 392 -AYk= 393 -AYo= 394 -AYs= 395 -AYw= 396 -AY0= 397 -AY4= 398 -AY8= 399 -AZA= 400 -AZE= 401 -AZI= 402 -AZM= 403 -AZQ= 404 -AZU= 405 -AZY= 406 -AZc= 407 -AZg= 408 -AZk= 409 -AZo= 410 -AZs= 411 -AZw= 412 -AZ0= 413 -AZ4= 414 -AZ8= 415 -AaA= 416 -AaE= 417 -AaI= 418 -AaM= 419 -AaQ= 420 -AaU= 421 -AaY= 422 -Aac= 423 -Aag= 424 -Aak= 425 -Aao= 426 -Aas= 427 -Aaw= 428 -Aa0= 429 -Aa4= 430 -Aa8= 431 -AbA= 432 -AbE= 433 -AbI= 434 -AbM= 435 -AbQ= 436 -AbU= 437 -AbY= 438 -Abc= 439 -Abg= 440 -Abk= 441 -Abo= 442 -Abs= 443 -Abw= 444 -Ab0= 445 -Ab4= 446 -Ab8= 447 -AcA= 448 -AcE= 449 -AcI= 450 -AcM= 451 -AcQ= 452 -AcU= 453 -AcY= 454 -Acc= 455 -Acg= 456 -Ack= 457 -Aco= 458 -Acs= 459 -Acw= 460 -Ac0= 461 -Ac4= 462 -Ac8= 463 -AdA= 464 -AdE= 465 -AdI= 466 -AdM= 467 -AdQ= 468 -AdU= 469 -AdY= 470 -Adc= 471 -Adg= 472 -Adk= 473 -Ado= 474 -Ads= 475 -Adw= 476 -Ad0= 477 -Ad4= 478 -Ad8= 479 -AeA= 480 -AeE= 481 -AeI= 482 -AeM= 483 -AeQ= 484 -AeU= 485 -AeY= 486 -Aec= 487 -Aeg= 488 -Aek= 489 -Aeo= 490 -Aes= 491 -Aew= 492 -Ae0= 493 -Ae4= 494 -Ae8= 495 -AfA= 496 -AfE= 497 -AfI= 498 -AfM= 499 -AfQ= 500 -AfU= 501 -AfY= 502 -Afc= 503 -Afg= 504 -Afk= 505 -Afo= 506 -Afs= 507 -Afw= 508 -Af0= 509 -Af4= 510 -Af8= 511 -AgA= 512 -ALDs7paJl5xPh6ORH61iDA6pONpV0rTjGiTkLEW2JsVsRKaRiS4AGn2PTR1UZXP0vXAmRXwdSegQgWPUp3Hm3RofRcDh1SykZBLif7ulau1hVO+rhwRyKc7F8F+7LcMf/v+s73eOXUDbbI2r52wfr7skZy/IELhsC8EK6HzhACI3 124241322153253947064453752054205174382289463089695815605736438952932114700118408072544073767229325045596832952652232288773280299665950768731398747700657715829631597019676014848183966683866396215048196276450953653433516126074463193382764063985175903718735372053536664711482497859539116009770850968340298474039 -AOzgU1s6Pd2IkrJlvGND8legXTe50nyDCocI5mwT9rW0YsisY5jaaEOcu51BAq9MmXBPeVX0k/jlXwH4Pn3mCpUAU1rEOsTdcmSJp35siKliDdhTZHHdZNMW+igfXGX5OCsA/BaBcGnE6NnrGWXKyTOoVUGQLEkL2T5yhNUaCT83 166340174936369324883416612727439279977041963320514134445183426741643586944819834936989524033374309932122967866930503619179389342537723598234062828695747850043368572301869699886931403612266216965783079972698791813140295203826980649434652168563255385527187360027803388963151668338040517316899628026707657178935 -AO8hrpw+lDiJ13JahLtCb1RenupQcNd0wlTSck9OLL8wB/x6gAoj0PTLV05eZIbz43N3GUSDmmckjlxdHXiBJ9rsoB0P95l1CWIV+4rXblCqxmOdmlm6VZ13bqbI0x7l0cjeMrkmk+yJ067WqUolqQBlUWMTuJVfkxALJYH5xr/C 167923899524385316022824282304301434707626789716026029252173742527362300338760906999615029022863637963070711762128687835779073122264515776657475985362344360699359591353388569856862973447791264902182048648600267737826849280828116753682917256540180401899752566540869918949003470368970029744573140084219550547906 -QxAn7yrdVs5tlHV+Glbqdaj67c6Ni8am3bBLOL8PV5HbdrLf2xIPmNugo6MfUwFSnT+ZPJ51+VTOsItaNwCFju0Eh1cqyP3JWyLRPE7emKuo6xRhf+5ik0pTg77LEF4JXW6ofDqirpR4alFi0G2d9yImQPphsYJwYGF/nNT8u0Q= 47093316905427544098193936500644355852669366083115552072584429220248776817916430034648347490325490701471113667554329499736495877969341478442613611948220957798780043076906836236556612316544460763366275536846463456405604189392790111985912854476264292503164100482712281088955640964034295834935468665872932715332 -AI9PVzrbJUvmCihwSFans1lBKwudGEZpWWu8pkSK2zVgzGhMvUoGgMp6TG2zsUd1tV8zv7KsVD2t6pXmjT1wPUynufq97GVHI06SGpflDTt30WboYRh3DgYxvso1sOjUXpnDezcaqc2Aiz4nV5MSShkBlyBjA8z2worHDE+uXqw0 100635651531872121827765663065728398779771663753008344681972226973080394359405041113312675686974926993279775427390065833081040771269307007695807025882757371805607979134114890454059957194316765342461291139168706134406917264848659448693866813989352429841300235734400772946895458374870482441457514575059390213172 -FiinVicXOqqRLpxcGTorQpSAGeQ/PfDOuzYK9ViFtmPv6D0cYPfhUH4qXEHOejvmX+0b4lfaX8MWPVZxlqpfXiU9BhG76HJxkLF4ysipukeOvhoHzvcxE5bnhSF1i//bOSifATBLBEZInwqSVg5tHHPuuCkwTL91NqhOulp7Lsk= 15560440884463435471963622630292643727112462888414585143143739400703889930416938984547754943252935620248108237258540176511252143752416771350868493435174026287082706690332705481726295797196444796135827460509780634261726494455068460028424141500629527968240913757449787164107068039175831847071025316475940056777 -aYrxyQN/hkBne2ayqo2/iDLF3DZGgk080SOMJfsj9h3Z1OfFZM7TJA+y+/O7niqatosvKrfHrAw+Qs7c6tCZ6NPwYJ4QJLOF9bqH2u2a3fkI954voNUctlUagYUJsZXV8hdhLM6NwUyIZ3ZFkPcpTZp7nKQQ84tr1a8VjDIT5/o= 74114640794666001532816944350975062126079079113921109750255283189037502412929005615388097912507598112836936032143435813588205939470002911374442844578739574773399427907766548612582213272643279263782396527705126350063372192910060171635870872236876399794128383338399728947176692692942605589343038282957050865658 -AMpCUeKUX/vtRslWiUUuXNl1KA9uDAWjMUkTrdsxxRDESI7iZIn3TR9lW+0kV5fzkLF18iYLAwSGBmX1PS/T0UVFmoBPJ9yS7yktNL0lpQ3noyGFn8HHZ6XB3FkH3jegIfGbvwwhnhhFzpHPrXlpO5iU5Y+rexzp2XHWt4yJGuIL 142031143422642739313498629438991149460874309300342349421794421544918823888598660275343727563280565210534243383322796489809683834300630555650331646026843796764549231159336347965502383849513994449309613369541991287590422095953275586374371960367000083487965487661436037637475372929033613295072397262739084075531 -AIMIQVz0JIEKEI+PREu94m3v9XoiU/Q0CpsSuqkwSSje+Wyul5ea9oU5qgtOpdkMUOW91BJo0DW/GMZ8v3C4qyyP29TtjCcAHObJi9hfLSlnTSuzXZnDStooYYKqzfToLToCaAJKCXiXAVW0vWtapLnyqafrf/KgyGZ5u4HfXKY0 92013973253053602863003242446596060337454881568126916916519869242232429836082762281129448384605359749247852792606718908482332975424967542242332487707042773885428473061056052851768940900752317020681189773407893371297668591494665352294885305475871917069040377145530889271334616499701769138948975263435137525300 -ANfP+zPBTR27afneyac1KJhOB5Pq3AXB+SoAXJvQI/GkSoNhw5KdfqoIkLcoJi8wClCm424Gm1AdrdGwDFOM/iKTSPkrvMag93+b2EbQGX66/n2X3YRFNkgq/Gtb+2M8oCcAL054Z/iiMD67aU5RWzjqS64ePHsn01bJ7dqLgpMO 151548639867177154896951257541227014781655576169318283047778755573323724856619156348444192550664853912434681577093459933599575436686424046466113215132845213008587152894642577278656978304699131916299275797578171518984206145555369576872231567191579337901913492071976578289189524123204040497290426960375042970382 -AK0kHtacLGu1NFWMADq2rG8hpzM4UEYyPOL+aMJbnwXcUYptRIxb0YFZg35RN/RiZs4lQsiq+kEJKzMMV71TsJq59vMkIZhZoB3t8g9ZqBZuq0JYcTICDwRpNSttJidVpJ6P9sR3s1xPMYKdlSwt6EEc9htOXfZU+yHKYgn98X60 121583812047864398969816595368193171848971298823388059338224714026742264861090347096116404814514279627148994345584790617974476594451626305761040465570524035369799925437276511604752129817947910677564301623631349399504187314174538914591944778074509068973226322566160587813128746039859381466427380402262866230964 -W3sZlWW1Aev3x/DiH9MzwCAZzBj++x9cknLfGAHwgFqkLH6vimEH/r8hi85hzlCOG5CjwhoZ0D/Hsfr26ZJ3X4chG84byrfDnek1V9mm1++v+clJvlYgcuVgn2Opsba2TILTm1MDB+Ujs9brJ2AAKrE9+ep5nvtQVeG9PUGtdlo= 64240043913835461386212515483198059541440539167395859777194837833769712010594411295323900074066077107346806786205590345517755715510695858065925747020336398305793661773798243627926904542715123849691490667964262778804487343218972081260210371192903128886030021862362141928329650003493687310970684093289133340250 -FTQRk9/BIj21gbLwI22fHJWYj+8Ghdcc613hOtJ+/hQmh73HwTXLpaGK9aCptxVbpjW0r/bxaRjmgxu9u1CCZh5yRd7Z46Wk/LIPXGd3ycQzqRMFB7TISFQGJIcFoxRp3Eb5wa2OyrUg7c/D+kb7oFJq9P7mEwIh8TpLzwmu4SU= 14889529068556301710329043521845510156960298822469914567758538023025100741826628180855835334285179977296740667353391766487166458692144569279381035582718738461626140662441222061900764829681913534146898551570916312642104487829660946024590782808750587095559047648957238487820069966851521487428624726655438348581 -APYXO6uGvs9qWiEAkcWsaCaCrGJJCP2Z1g++XlJ67oZIgEoWITn3T/R2/c4edAfwUUzNHAYZN1h2dSrRoqlrRXrbxFtGOuRCUrXcGLFFcEbTrtm+z5z8xGRfcorx7Cu3FIBPMK5XcGPcbRZdyP1gBkeDMvuBNAo0/To+LP/dhCNM 172810804474418448604443090732221483571611665465870520701624598983692130272337358406272727413570938793741430131635927237320173996217984860203754686741782921346604605228620148450611724714868551781003004492587584071978757421616871762681049508123223983431502852926521520561941051298696758046005573332373854233420 -AIDNxhnDEe1kTJ3XGfTS8zKXeXPRdw5yifm8j8Ibzj/quExy7hFPtKct8hRskPR2qwTlMiW9Ra8Npg2USsqHV0rBoIkX7E3psxq5LBfp/q00l3SEBuLL4K2FGR87bPgU+Duk3RVrNMnColiTcnAR5XkoeWhn/r9MfJMIN9Y0FEh8 90449107125498302548188660544012777357148118984122992664008792590422284061463729084479315745509706793674355738023180454297730948397413371686013210006834869294564190666543874617716180411178090109573192518129248278410216362657350215009192850017507998797754539132540293137589672869131300859207213449571846080636 -AIRWavxYRsGlH0Yr0DudwrpYtbrByf9ZsDawKom7ubiRfepqYzcBlwt4adMMnkYSaXeYtOsD4KBm2ZvLKN3++RkYNmxgkyarORBEg7ERyiThBj7Ksw57pNHCAoHtBEhH7Wp9mHhuZtPvPgCEptmwCu9rYhLt4zZp+Zq8a02dkXvM 92930601962515884925250459851491509622611227724602941760145671636277317511265759558869239180653492283311584982044597979173761619470326096725838197524704577188104121460089235709339932110663536557497112887112782062772810759971739760085128369628777812332518137107605855679096146402427144185104230596200130247628 -AMNJGLcAiJtL5fUfkesWKYJurdYSnvsOZeZcrg7bemkEVjF6S9CcojimUl+ncr/YY5/EXnU0mg84fObtDxWWdJ7z7l0CFcoALTyEatDYKshT0xvdKY3u+LUShxIAyk8EcGnf+KoEaa4Mx3tg2oTBnVegXClOakNTWw8bu2ItagoQ 137134165107366719462230252606689766470445826753581409513106273517221906418464863733870948759313279128624638614534848890858250894834883265387344539280755177217350585564186248554307335197387734431939154077778003706720017441895613190141376534460438929588407764609772857975000507660651583780079804513519571438096 -BmGPZt8XqqI1PuLN4K1/PZMi2rfOYtHEMrcwZdSjKRm5qTkd0Pbb/5zPV07TnM0uLRvIQYTLloEY+GYyn0K5gDTEZpEtQ8ee6Y87zYGDwcf20eqYNxkA7FVV71vqCP/Uw3Oi6B+hMvsWZbvv2vH6MkAeADCrezOtwqVS+irftyc= 4480956865245875120472829476982311611308898564405318773810939350829150182630548948231116574193987272498161864310429976564278532538229396846813874244969927890037756969704618336242255039858182439641759659872128285423988638335967412040624105824571426792562334458751137508116412821914961236269913776304372561703 -APqFgCIYbJWuRyEGuOStPvcprj2PILQ0JpgwQ2jLKn3DvkWSd83qh7PWGKozGavsjh803K+ZzI7P2wP+Nc0r0El3q4nzaHvKaCtVRyMwbXv9wYLFZICeM6J1l9ljUMts4tbDoPzkIy3ScU7pYxarBWqMkcBU8qL6NN1vEdkeu0fW 175922170410080716883576123079908758276229469783745771772401183721225804343343063277676406040455068452258961299511343441961963941297631097736305638850193978800615558067791016294285848963023036905095022181004058235239390870177623185946205281141386416867569004073524130001309977475780893497185890756991672600534 -APA/rCcGeH6A+6ZwaBBDM6mB6tTD8mjkrOWEo/pK3MCZ+rrErMBnFp2S19GhlLOfuY8BHS+D834Fdm8+3wKYkWnXZpGb+e3v8ofOQ34G1HvzULOYtrEiC4ISZRt2SSyz2hU+PBXjVnplsHWTRxZDmBxTJdgli4ItAqxGCxj/aJ9m 168708388929747822981923386197903561880341990893945097067702518857172133291360611402092714329372304718329568897960770488377524912057166920574319430820488930520807742026377043178502591886293565177404635365772829346030773275726024973460121300339258054215286249329967181244588558220467488638468686270735376228198 -AKmwrLP108dCGWOWxE/6woJVLRi/Kra/DvdsPkkrZQmWIlUT7IvwM4gU6bUr4f6wpT08cIQls2cGh7dbSEaO0xLa3mmtKhPiAlzSnz0wuifF3JT9U3uXgUfCZuFtE0z7Oi7WTOrpl3k3GA7JFvXnY0lwblIQALVf6oWyNETnajGl 119160465301384937485959146028591622947513292915838943629387700439301197965652871741710280647524383590817798553034250156068573474278225305190573334054718387045488098320076877626430189054572361967283632592181431701411266656256255758079114072932140551282607247364388070762970060420036793573956057551235306893733 -VTe3rCzAL1Sljo3QAXEkAdBy1ZARHZwtrj6ZNRa5ttqd6/l21g4z3iHCeGo4rnE2F8wYTy+NlugjXw86OS+XojW5y6UzTtx0HX5IJ4POqN64aXWmaklGzroBEYWeuFFKcgQN3NOxkuJoDQ6VElP7Epz69kj5CsKJUwL0SjbNrFY= 59841866347633473702601462509811342285929528424012250265905695635971518533504187799047710303717472950129869674786231155102509311322791323986824635569605105662070745033595366004805920086888891275288347907772640070278731650628917037915863439204501060041944275512863990729926528905725569467329169134226609384534 -AIZt1xGhC/HrvpPASsvVIVdsu//tn0noyJmVYh3FdQ6yIh1uce47iCsrV1yvYqx5ZTbC0vnfnbjFcWqH+HtLX/DelgvhEwzqJ8hwQrfE1ShLG4ZjAVo1Z4GCjrDcEUMlwKcunuSJssuxeQuXwTLS92+q6QeBSS7OmfxPX29CLb4B 94399298271083745508290936113986978382457275531684761701599029877008571741877683365769553170771833981099580359640421358853566501815723434822307977440496208486103754978934472597505865596938563438311337045817621762649604204720249750058676095769230214181772215323235427976398686727606000594646472236822594174465 -NIhTPpWXS82VTA0LTd6TfM+HgLgUcmvnMYtLqPpuqCKZwalAycwl0XFYNyVvaY21J94j92ts/lRYgVtHDhk7/9nLXq5js/lsUnG8rWPHJo11JTxvW+df88aX0pw8u+biOWt87vc1MW1dsMTTsJFJAeBx77qU/Cwto95IVqM7vSE= 36889590210230649939994518345793530042252563793069578097360569338647730438860274349862767107939590441616825589851005429465345268710487649366046960918184701290985280638488938340668212498212581853679035928093386035688597446809895381618260692378376844452061580510108168030682664507293277674052032318576713776417 -KXdi4A2Z7tSiiX9YGtDtxUXIfQvPhcc48rUH+Q2SnXL7fLNmr+F4Rf3RiFBRiHKocPfE94pothop5qQJ5X221/DbEKWK6s+ChfQ636jvRxojoLMab3dPtaAPpDJHrfZMxbT4ZaDJT0tpA2e+zZrzBuDs+UUgCpty9nxtdm1gS7A= 29118662951481660380477444121362422614202367719725087486810943918529894738076273660245405874301505615796632229852040910511025841576465052938308369421493312085081188509808322692130449282585522349552501983296872614029139293444558468751646868108213623606366977549477663987815308260383403466635254115908032940976 -AIOTBZQR2EJJRmoWdRNFLG4fceoS3KnRTHRpPdllhHODqdg+QxTOcOvqIzBqgdD0JgO12SuNAjLQOiz0jhd02qkXw9Y1adGuKvL97ARFtNEuJiNzFAj7KpDLy2zk2rPJp4Lp7cjQs0fe8BQYnTzTsNRGm+4ybln/gse1YWu9w8y5 92394618277596007469808288231093678404089765494062813665106014405059399079199990128824492247005602685377185496959522609467906358619318009231448503013528692450191782140091818984176967246749464502089280153086163239846744554575017530385347720563798041108608545014076448155956762636929707905789978331102411214009 -NzfbJRBF4pqEeborJrjoknJgpfK+DZh2k9cE5dcElMPZ2Zn9im7desWGiBSQnu3KbTO4L/t4+m6nFTNcbIJnqbVSMDHdsfG72rG/t89aOuECQw0HMVVgONNNa6i/mw0jZSWnRLD4fa1YgbUlMd8jeqO9XcBDB4mVtDTxyeGa3vU= 38775530011374537813502898274019389132620116890266344603221997943675706375698597061571989090674289834838060050848545748579361837989319487970580969082824601965845786771062335733318139530316825802589479118956745739691326447349403950997231306042638797277408335778415717988679050762936401945487285814799382535925 -Y4BVPZ6necuLSwaqYEPeZp0lt9tTGFl/WCJJbwg7XpyvuwYKtzagC1NLzY5ymBfwGFw1yRlQuyGsYd9mBfC99DuVCIeh0JNrhJN1bNfoSzy5UO5+dmTr+dm66VGSRS0tFcViDTfCIleTV+zxo/xuZT+Bjxq7kZue8zGkjp42Kmo= 69872189501616471647606976308259279995249122669120675885925763529037695584466011511740991152346215507625265226811128801733353566555339153627478941716586678793853828514394269931890370517258825006937741437480128878717892485074131232336852490940507703859793477547154689914725314529986438108117871674332626168426 -AKCP9Mto4q/a2xNqM4N7PekbKspwt48OGPre+iqVwPrSP/jWKxg3CvvLNZzN5P+/FiUGIklMMFJ8w76OaHIPqKuwckj1gvCLECJEE+UAZWrNKPmpzd/ootN9/kQhNMuloTFCyhXAUUOXJ7Z0WVLb2u6fn4zroszSMBoWQEKC6lcq 112750701794692134675959811050012620191158543234019977304167102486465198271340022889272244811582365901584420008564301920174477182946432553537794834985703732129975734658113610563794129371053853971031300761815004524681756388784922001759202643614966614186697992611399618828963452661554240362943588548146868410154 -APOTAFA2waoAODECaGNgCHa8dNN+cjMnD01M+IeQFytzo9RLMzzzg/gpTUFpyLtFMcfbCkDYQMLXwE4crTimdz5sVvjGQ+5fSFQjoDY6Bw7MO6NAcLzlV/sI/1WyNBKaLQbcl2720n16tdUcdckQNnV+cC2J48CVxYM1c7QQlxA0 171043636512232272455501595416608280460445723238023572475354665686544174728784633443479486247342724860289312593374524429736857970220153680852977711594899595712511352458264354251161579203922747468321999465061463474727943140910084880926005209538535217464825087114791420210981711903880998556269523363208766099508 -AMGpxRlB8WVnsGqyyiy3/mzrPymtJW1o1HcDErK11ZwQV5PwTF3c0THwlnxDmcziLWHSWgPQwfRddVDCXMGW9BffJn+XO6aTcWDPmDAh+1DbWJPE1aqApGbHvQ8HONy90dQMZf1ayuwceWCVTuU1wnHdo9F/sIsRbuu7ic2OJDzY 135994898408425255747055209966103741651849229328236418804928584233229830656742052333413774490626915784901255640138520158698845938184666683995579777154437927013722740366497459963753542029774185193376253885864514386760437194444013834088425088260658670140534670789371556026135595577395047002643901630053097946328 -AJAw4uDYdSYkOrjtwJVWLv3pi1+UxWge4RmkWKqVquTsAVcT2tRZ+MFdHM457Hl7fmFIyxvGZQy4c2v1AbHEfPR8ID2sCRQpdcfrxEUZPMDqxfnHHm0ziny6W4X6ggdBzMp/sBWaVNTBL0e61/pELBGYNRGFMzGws7HQkr/sro1D 101254336834199527040756567675327011562230719161388328289463594628690618298993695452746353237675715087353241661592074446889034411683413957950360025295995263477031608845241728493807755308798509893719674568267846671753070163272328014412744008880395248474446310603301447848026040555910147467745595720879397834051 -AM09TdtXgYL4FI5CGNiVjf0T/AN/pZ5zZsBOi1MAUKMURiXnc1x8VKYTqM9Xb86mqNBBqphynIQG6/3e/YbGJgHlsSdrmKbo+P9daMr02I/7Z76/7Osa8+7Ky6lhVCbU3F0tBH4WvopkCQmuJ267afgvDD5kB+9uNr28deMH00cY 144124056591600568767398029380314564902309327093641173350205276895603332085753288682409279238417493662029954512382520307259348748813767324609446500382301421328754981718014234615523158887865271179104711373675849713359713282937065993613915015084108700238420759344034475478243507306107546245540340758766909867800 -AKDhK+/BKGXbrbBh2vM61OP8LN81YwlJKe68KNwUu4tjXlQg7i49Jis7QKPI/YFPUpSNTu5N2iCgeMnCX4+r3NAfivOao9lw4N3nc9bi839SIWdlokhwBHBYmCIgjehUeBAdkU4jKqlE06pIrpRmSvBtn7O4aWTbT+C++ViYAcGF 112973480670453665543892521898882856059335781900313607790238402438320486344365203510769919022496690291280873287383392088872774202832124927485754495093552572232234532821756395965072330282810574669371524103814871172318519695921477775100282448247625395376072233777533359104085023946019406729587713120941266551173 -ALxDiSxHjfxvP8ETvpE+SyDPTS7q3o3zCK519WTepygC58KSRfvDnIVIyV3toQKzgqD50kF1Ni5D/wuaSs62y3zg3kELX1g+WuBCc8+x50+kDtbHXa1Me3et/OqVS/QeppkcjK1UZMU29fXze6P/w6aQfvKQkE7koeQtZBKkYc0p 132203344567902304830160099595561253300484092355345272411265169562971473393256361094745618829297250316196312398486598077249124198329075791740755862221465178128527292695331061023291345396067863215552021206609309872689233899464919108147533679134727064586730810633196817136739658243232643507412032417747255282985 -VF0YUTvy8Mfi5o6X06DEvLm87r72mAtTdyyLNr0/GXlk0Xj3L2Oi2bVUMtcXQNRXg/mkdGP88pgdaP/eMzqkUU++vJ7t3UgOC1i3SHegpiBhhZh+aZHH/wjFV8Mz2XZB5z8MpMgN+QwALK1TT2Pyt/feQTsOy0imVanB5+OvCeQ= 59242171319056188000481457618922567543461456096441095927600135114274111606802456239311634638536207588762066940095527920532936960549439269891703098017342732142860571277442598349453761561189719823290643146391349978698217357430495238876700400634593256155537598291759795109752990651995982467695091946768443574756 -ezpwBt0N6QhTusiPcKrBvSB6yuk/KShTLUFQHdf5J1u1fgDYrp+aOWuXOFVfOd0bweiG4UxBQNXB2IDFWfYON0fBoaDqNk/41YyqXBSkKbiNWLi1y3zPmwTAiwK0PzYp2EPfk/t/j0HsDbvebu0ygcxb2tPqj4EQ1TXEdD007kU= 86533835313999945727720083706940213467453975054116752898416709637030456504024135513972566184073843025739226187558143854850980654667596935003124034699919861200483994576288766702308068265526535622439762454501169018136389983894783905946543636163866717367545972667876983557989192393479830223914708619684891389509 -U8BT26zT46tTZnkmTNxGUAlXbJhk5cNi4AMSd8fSvZHm55siMFGJ8Jl7mtdzEFR1UFAyEztf2fUhxdtMLe8ei/OJgM0j7myQ9STucEwnsShT7QS/DjBmfvcC42sl1CRpXkb0ZLrEJCPf+crtLKGrG7ExS1oawIAgALBiMQIL6mE= 58812148564290791415180898639607206220554150794356494356250223429674091688305329629529905854147200457536549527135776329004085047145097927266797668252160196098870200925284256433894773392353678965699083286106628662506590268955650280670838340651598082083455821825076016227525614626726458235627297885815646710369 -HfYii3U1SIkBZl09RHaGGA7H3np+qxyNeeCNY07PDl8LwZAaaYk/bHPeBVboan0I2X4o78zCD/gFXFBJ4rxwwUsVjHEioyO2JcpV2/oDOelJBD//78WzBMMSWt7ZKbJV9uYr9ZUM0BUD3fsk1esFCEdnDJdr86U0UMmiig2R+ME= 21039655953870571289679214995029926285040274249531458675115179004718812090027267801012507748013357317597416722235988917212676802092082137617336199787762782958420742299451435320649616271885264333948336627286638368859041172783505464468640994920853000441536629081040963398001710173320125308624362209157720438977 -AICOlee3daFyqTrTdtWjVb5M2rclh9BpIo1CRvKo2bF7NYcjrU0/VvbOnTVXDwdeGMLupbi76f0BrfDxYtkzMXvIZlgoTit4g5ennnklDHFBC5cogaGlri8U28w4/h5oMunZ1O4ezdpRgVJe9nTP/sSEMYiNS5IA7Zshdvm/XccF 90275777798511290102824338787811725003177532250296755103300529948194832904403489332420505850668003332750291879153080212231952155092379375422537931240723308384652734942204313672973885652497290433943089371705605128843469306776615573873479312715317072986990219294942040272550822460408702072075001377245051602693 -L0QUSVIjxvE201b1ztRZyOOxy8vkUz6626TH4tbLwXjjc+AhmrvplaVlavnOgHqve+/L18XNuAYP4BqdxIcWTx+yxBKm4ZS92dRJdcAtccvZpEJtYjdJvI6qbL5Ph6HluaVZwp4dyFyXuZOJGTfYdTb7PUWM0jNT/xsqyjxSQ2U= 33191267986826803728285073844005357792766429917696698533494382218509532051029343127452480789088572904364699220151221680328978554239767633887572649589456766209242252549993823283929686430100804479376247660556781589549613316880150951333982646510273364068770923588389668733632648346075516618646974067295703417701 -APlD9ECKJuACUmQUsbd2GTOpb2PgQVT08C/5hyNEVdA5bWoICX7epmoCKCybdolk+cfEBP6fSz33j+Vn8MbeiHBLdmF6ETbmcyOjldJ902MDvU8dqAa8IgEZN5Uh5x/xzN+3dqk9o0ji7yi291u90rpfIh85PPpDat2B4l5zs9i5 175040148659257809883308984693597046378367187659749953472629929701758633206586720399909808941145946314755491399962797299295431089674294356220216615950668954164397362123668926410543898553191541662075745481299747832013627018846822876386760538344447600390187421938699064459451308870669878673306013635576901916857 -KB7N0tE+A5vFhyrd/m6Qe1wTihkjqmBn+rinfmMAzRlvtxIBSyDLzQsOQs7L4oTG64ABU+YwcWVijvoeZNamaxGl4hatAH1pRqmC/r8FMvC4vqiFTbFHzQhkjM7uoHD1aKnxyBVgjMj0E0KZjrRxydZjIR2p13FXjLP3UQSFtII= 28173452509830313810392326357601136401754938805266458365469366750775669869895498658593356375710132149836430968810246171974040975430205200958564616924399794768861923079158311829444850822144940112488994119845741191519421434257276977333662656888696213514226866147767570046232093727585815615828360199830275208322 -bxFgV7eXwnbQScl4VzS3RTdcMW+NY6pcGkT1UsqHIeDVyBb8DnH/2/Z+DX3zniR1iW6FPdvhJJeQyPIax1ohILa11R27C1TLxGvTrRBGUycxjEcBIxamHveBsXbECWusYLEakeSDg9x4BTWMz1rTQajkorBoeEjYuW+xBxQtXME= 77994515143740690952370766995249847650881300682406161400195705464876513409097078624084133111941171517535435606295232558665316819077765607639545069239931096306624817379462598756505457054433358548941076472902905065316335603665413114267741896000877284610377452471067725794013283338924419969559537339967562669249 -AOH6E2eBzD76QdTJ6QbR/7OeF7AagUif9pEYx7fMqrIsXCJKKpLV/RHIItCDYP2WO4URCaVueoAJe3M/Shj4o6efvH9pf5Q8MLM0rn5MTHWhThivqYQDwjCp1ZsPgq1VFS+gcnmwgHhj2W7XzJxiNPeRXlxI2vL+XTT/wPBYhqEP 158686346608862569574095184731081143351413141116869402750758091813874232272198082464382169470744476593016502816563462778075467588097653320101723165887488327616477297401486647183409348122990505635004320879840358339260797834264972100385692477324858942142372580281421734058008608134075577990829273447077276721423 -ANDDgNXOB/rXwmS4KEjiHj7RCDocVrMv5SU0aw6AJzNTBfseFngqidXx2AJKOEeG7RDDN2gzn4K4qJktF0AIPG2JbELlLUu0MFlpOLxamp586qyp67Cl9OuPq3UZTyQhIsSIE3VQkvxuQkGsaV1owDV3BKIWQbQEqMQI3yT4ELHm 146598844784260148346676185962272439320781765598895126402049215152385925250917998794921584290777625240122575975327405909800121511343265147922400813488099624745229653124857224399973509428158163452130086943873214460600035260925149630502192183407327427517292065083168010281295559088633086659209316582810260124134 -Vprr6oBnWuxIzyTZjuxlKSdZhBc0upeNBHVIlXpQEnN1Q+XURKzp4/6Vg/koITftr3SMSgGpE7LkrERMGFgYaqM5XZ1RXYFKT9dRJnz9VRDITVZtdkDrU04bqo2Ur+jvZhvg/oHBDTgQ4nPLJfHO3+GEmUtck+g/wOVozMMgufY= 60816213163057201559480662231646403262735082707152897397414589876256824040344252799972529759737904461369360580708093117244392116003622336721789703580184437841209963565058475060017600871779929808204093448248984201640754565635410002090180110910120481044515630478472999135146756643143415057403006410330361346550 -do4LGsm0afQLHl9alWF2RVyEKPxLIErsf4pTPgScRE7ZiTSVErbCDeyzd/KHzhBLQs/DhHHcw+OXj541cIRm6jaLVKiT8EwLW/dVG0AkVli83sFh2f56Kk+bCGSKvfGEQcGLY2k7nQ06zoMlYR/xbZCka6Q6kSq4YBDQgigQ1lU= 83252051731120517035090523892596419800592471447735288551342681962005778435125655090199060145942826521644585427683714084736143440310518046334877897672493531918539106001203807757254797471481884534543367685912500572052457610702790097953420236852480969038388056545966568595395722585797418296411673622376893961813 -OL2Qoj4xkqRrQmuuLwrABG3BMMBNGjfBtVBNTdBf7g027Ghkk/z3aK3jKT1EPpdiOdn8zXYBSO1mTRGyK3n7Jo8ICOcnlBOF6cZtDsb9bvSVE26MOD2wzl6irU7vzS+s3vGBkN3AazrxPD4czk3xezA9y13DJVnNzgAgIQHEols= 39844525812817530522650122383059885756573694015271773938493414420875846359054562126060762455794481186614035892021706051863945033061233991184379580556219478200155757966121832613842937722944431875100059046588723473670448006803481527981834627086055642349130254917244469014754132003347635357123155857820000494171 -Ljgn+3Hcg5DOf6usRumk7P+ZrdTBRmo968HdZU1mS7LwLW3Hii2KNkwMV7J77zA0P1pnvhMSEEeh1RbCUjLtSIbt3RIcOEoc+aO0eINF8r99l83xF57CBI3MDA3AAbtaYATy/NUXSC2h4W5kdsQuR88139MFi5y8E5njqxHu3UI= 32456338403763561215581247445990611953939298888251578685087656354454727113846722731945605696397627662593375001096230320486703167389461057538581895745078593206660798580358701927596287363374862536765135996838944212622199018632046955402325290145163082309469649329852148345837780541107029165352782710901375425858 -AMt5/u+ZUNm+Xsucr4RQPUu6ExAOq/Jbcjm/Kb2YIAaEQ1czIL82wsu6YmpHcfMaxLjY+EnaaF+eCWQPeGd1av919+QFbQPeh5DT7ZT9klK7BFyVsN0nEDJQ3AMMJqq6lm4sUeVxDVTmMypYnkzRl7jqzyCRY1MHA+o2LyMECdOg 142886089970163885609957244378225169093559131065687633458877059657380607541767850701139140472705242750285722732461954100519608059127637509286558848391554697942686619832870045594188204522385787253648018847569919409782188708374165437385572046835539379151066214153911415525465041951116179326632238059135825466272 -AMvXeHCaa+zk5VdB27KoS8XpjSUngaw7Gwlq6e2RrkEOxBhU2rGWGJ3fhq1HBNRxDf0quqfYTMd1speisaEr3cIyx9BhYwB6A+Nex/Sf9DSixezhcgEz6c5CfwUYP0QTTOiZDqzz+GcjKikjN7DKJTO0WSXMRG8qX8FBbH0rlc9l 143142496664357119491819741364830737485524654099662921673419335301323845847085335210884201567922636945282124120681371777665458057821603161276185071778040317947168899788341482064834489328957963447735297898161379277478278414388733161844053774747425459239004132791029364174047523473372650441001639174571312926565 -AMxoMXHfE2i4khsAkv/lPtLQhbWUjP3kxYmlJkpacpicBB6z/TmG5zjmTC/sqzBvBn3J4UvMzKYFyk9/l7Wnuc480500a3S4HRVtMtirPueV8v/SPktL67eN2zoj1VZA/Rex0aRGjW2CzEKGwEn3G2bZSgdT8hKv7AypF69ppjz6 143539479941314279463880342636704987025205547180882175105616955926182352311179043850344463145750154442573797875223178075233807385237935671604701513551125937539235111702655902037518920150424691586943553275517626347557879039695678271564616114192941679606063184290901862703975921261779714258077775731727612132602 -ODvOKg7l9RCn5CePG1FfMitkR5l9+7JK67eU+WeA5p1YXCcKS8GbYAKCtXPD2QfxmQcrNYfAc6Yb/kksaq29oW7MzZuTDzK0HXY5xBc/fJzEuvU51gaI0PR3cuU1qRlLqwmIlyt16gto+2E64BgPgIKJcAjx+TfH/EqNeJ77/W4= 39488587053253042573878502921384752550143716864908041972426777545317969264945056510991363961916339225192727727267483337259701961148978214005913510275048195308792987888118270387288989623193626554910652030960235845935461155296845475356011099372367616732243132816329531758943935324760665826550992788664237161838 -AKkznyQtB+PGvbVroM5nUIzhJUjiNj7q4fC9sSFbmDgvehnwPElVlie6PimH2FKonGV4GSaxZ+osil+9omfkb4rO3pq8fy5KcFSw/gs09X/U2eEEcUt/4oSbjs2NaMIxQftM2CauULiwfkWdkMFTBkHnh7Bbyocc8dtmrBDdoI8a 118817437232756222334188081193205110010964766506378146125932730686679941224328135190204402802650523704343176483564284220367074983943319572348376466341132480772885833789613392397284313483009178508647973749522358005819092779831781339778163122774381387989185969990310049504391258988402795259963134610905036263194 -AJfwWA7XnYbTjlJt+9hO/Q/OubHkUkyMYrN6Jd0cN5MG9Rg8W3i8U6oJxT18p4XozkiOgPlF1lE7hIAW9KRKJKGTue+iw0okLq5UNMu2Ha6l5/wzKi0QzRVTBnQm2zjPlQpgUorBBty5mcbt/B/Y3vOE4I3iVXklVtjQ7zIBHaNK 106695084438708194568048926154027115609888551145480521213711726807296356271397749432698558860759334362315257102647885062353922543502466463770991058956633500180245599467233361812610650830611712448187310827443315947425061886163301613989593906515923245020641415290300558869209909418659128196109640872398602216266 -aCXItk5XhuNrbrqJr1Qm04U4y4AzSKDMms11PgVcdf5fCGdizibh6/oZqx5OitM26nRz2vob8F+ZIP0CIyIJU0T1M50dVTbbpwuVNdv/XI6gHekQt0d2g34x1TQJIcsT1VWwGWTPNMtht1hezBAYxwv105AGKnqdLiz04YAdEk0= 73134927546833985031652237686088635686032103401394612286045377544136784429757461671691980910279873140130943470029643791712859175007885735170485461366406852784845528918253441791024065848540598601036357817496637108534035807393364939272891745520961269029038360205258229770737579266643408540634722493263322616397 -APNeoaWlyNa554OtHP8F7GAY5V9F7LMoF2ssg5wBmsgGFktrRH1C4FdyD0COrzIb0Vcko1/HiTnA9JXlfGKc3gTHEnO0gxBSDjK41L+EIgUfR0EhAD9iftTaCoBM7qZN3R1MYrSz3sevQZNMFOOnRrzwWEXnJaPKAZXvsqPzOIF9 170899982929163229592439208307232242235219591108657660041403142612622997092685093132858257827585941687488772925553142105567685213341947938835403410054637382864108739466539574004149772568683507025358331323655651148107044968424043673850583150424463706583215452211942132017052425497789362680979074312857823248765 -ALhwBfBYpOk1pfJcNut0C2fEAd4hhYU03/ZQBqVe/7MgpEDjro7oMvSdba5kjH/VBssmZVqpvuZ5lG+vI9lXLukhwRKJg7m67HG8lZXvjDmjU/PCjxBPNt5r8/DziETYmMa+fhaMTw4hedZcwDe37t1VPIflvM94sBKu6be9yJAn 129516480651398210587505113546142851617282590236388547627336279692965778911450075230961856270046942312918567973875005814982283590898552829322178788678196583244198944578081007477482775130405341039067711963061287597331433268366003672643052056973656674139309732186091974604170508497340243515339072325943686631463 -c9vpoiZvtnj71b8XguD67WayOF57QgOX4V4L++nG2u/RY9VT2+0tJ/C4NIawVa7ScQZAPVLuhV4J50HJX7FZgtY5n+lwMzNo0av7i0IqTS+1BBO8eNJy2wkCbWWBxNybuNnF6OK7eXdPb2Mmwm2OmhN2/j7HAr0cD7rK/Hnif7I= 81358980280155473712258342299472964374474635149963153129588784719499494479288254287754874893180126149146558961101860327826747785201363745989346818037655063262173536227595206355647880155693272153902647256175878517626925488264893732295267833614283963802283320574654949992393798458265266551024756663538388467634 -APArEXNLzDydcHrieLDReJryWxFzcsN1dxjpJIVGeJp6itsJOrUtnmXVnETtaZhWsmN3/Zh0R7TgJ253f7PZ/Z2xCEdqF0hs2MmnERSywdWZQ0a0McbDUUaDjBNYFht1wvS6djbI1b8RfayrnEZ0miYdzrrP1ntU+5cM1QBAvj6T 168651870043094856205824264282870999215855903395882323164614939540734011037112413507417141209480771157672307388419164831992909066097194364645695794831939514470650008210390333649278806163193463937050083854756730458780288720541495880958909249273048328511615821480782977316719631334570687241232556472064072892051 -RhGyx6xibf0OvY1XjnmX5na3G7emG8PWbvEa1kIjR6pK6K1MrMZnxFefXpHWInFS7ADESNI9LHjZB8VW5QrjRVPMksgdEAlkhY7MyQxaclUlShFl2AfKYBfIIro+vg7mUMzMctD+07BLk+jejRHtPVIxHmNnZrZYds80ve5z3Xw= 49204219353786910100605282012781696579642953908541693903348594981245301165936599174304121350092894937817100350990938057159324959104937469442065996667276651025661016077514839755853073999975805394464570132481314896694678249282338429544941873047382467276103868995474424700207571657816852575364781281563515280764 -AKbFfU3GL6NILVyONPVD/X0tffk5HS//7FBp7n6JKMXu3VXvWnfTl32R0WyVHk2yP0iIyi6SUusSicOH9ncO8KJHmaoMGN9Fn+Zq94FTFqZne5NxHmCtwRAbFNDVGg4FeemGXEe1S5Kk1VcvWqnp+QgY0uwa7RtT8C7/T+1pZlwq 117110890075563714812929271250884717870581483065920538069845585667296154465072587148155060755111295509684258790280104272121160614620669593483929827848744548171793187278583947500205314283462739235860439216105116687015890394925743036369717346234391524403038196640934551590543386844279091801685432977718405127210 -AJ0xZ9dfRc6P4W31bMHBymgOq+38ETEIMvMtr+wB5WTcsquZY1IUB4IVkrHaOo3W2SIr479IfJOOQhmvyRS4iB05yDI88Z/fJfXarkH53gDivECuo+5+JmV7e0S6gCvOuVamwoQjlK3G32bCV2946ry4EyIsVZ6Alk9xk7X5HfGU 110384671994603894282707302829898242894456931176497230904862171369974466400767175784681299142670706023468915238955836087425993929524341269289746060546848852729416925808186253355106621584826213979718185296723694190658548757311188764342751280681935289121682174507629679900374674992438818324999211250580434317716 -fjzmb1D+YBU5Wn1GlwhxjiJS07k+fXxjeNRbOv5SjktzxOXmautO8xZ5ACOlYrTt5G2gzW2PU6sYNfByQ0xoUSyutOuQlD2r+8MnDrxCo6RxT3P0dUSX7q0IVj+oLK4GPbscnKLfe6KqUcYLMgKnDYnc+ztFD+csL6BQnM9WMLk= 88647261832601702291191332432291274285041869480562430895152086741320122435409959711452438332192792226899741738806447713240934608106883094466050154088410020909933636902495700779087737304255058561688767369900548260278700135161077055869478387490726087630962098228537973426295306997128615315548440548541717688505 -YDg99aHkQSh9RjytWknbXzcgLD8MrWUEHF46yQLHYANKXaQYyf3yGM9TYPCDUqWbOapqQe+XfOCoACLyRg7vVDsnOPRDI9ZFUgCQBNG06ZOxzktEhnNJoRC99da8jyodFqqk2f9UD1lVa8tsQdatjUDocwgJaDAOpYEyGnUlbXo= 67567767932654827067250684965667741848878457020992905661955722020937161710030993261011062929936964216357930453809610708591260182295097124272956485574313839759737390934220465669626974544253750900911093325004172643146669082793591441922014060981070503803266774197958528843445580649512373693546027107823355522426 -ANdsfO+cNtWsbT/QJHGkYAL2WCHWVPrX6oEz78pO8lUwiigVEow5roLI5Tm7GP7XffjF95z5WDxzpoam+Bfp4za75D6ZEHQmuFnpWQAmNLUHdKUE6UcsWN1rbV1uY+x+Nr5Vni/M7PfQi1yRTTJTYav40tFPb9rY48FsUotivoxd 151275723772668372472508916060743043308364940375633847663054782759325087560768667906829087958412643723335046123025802453213225972572697773468957759328009026531148112732519692142632237595562259864125679649273054426879080697360204352423668940795473103047320116317252295126635024518179060076282921965794883439709 -D2Z8YA0G/vzEVVQ6itLPUC92r9n9FKRpf6lDPWIgpZOOfIkukPp7zzTlo9Ej5IsBrZBbtGz/eYmlHeZ8Y9pQj8HFW24HeKYqjmR0ujbNxI0QgoE+VUwPVg0HhoQsOGmq47zpXpkDwpOAZbMh/t1Bafq6r2zM0qmiwOacJ8KFUas= 10814483230552506566705634583020057064935800294861277580077052473134972003523900930560478187758928889017740705417070994563709463926267126567504805864719383185267204810142444719634360655595490833208838383875687102074846353850310954150927702228780599083427768247170427544730791038729428517279760042619935478187 -XoZpSMHqlOyPYJS7dWSRNDJHCkjbo6+DECzu0FpB9O8bftcxan/06Twbo5d1lEqPlLx3w0XeWtrmCSCaeVcXVtlY3QuPjdKPv8LBnnhslPOVcbGyflaTPXU+ITWE6rwnIF+yWQl3NIwCV4EBtCT+3U//Dt/Ebif9gzfKpKltD6U= 66377743237695515693282032069691369056215169443985727092982918806809030742478033317158686828712146024066618073633406428345129492010236994055590530566431286733776441810601990431112187030942086686719669823512292071202675269428014136307286941704297995292544712278047959299939833088742083527714893795660235870117 -QUbbkyJQ0Nru9c/nPbphM6VxHp5DWlai6407KIDbTGvUReVYI7de1gO/BFphL9GA7gDareYoMuej3/SVp8lEujXywtXzjiI+j2TzR3YYiMBAMhsJO1wU9pxy69Cj5xeFFlrOycjE9sPS9nrqnEEEFNPiK/GDDTHj0KuNbWSCLrI= 45838919357034925862751142472777409057791233610959872523563363744902783251621354580995921495295078179996083468819097423327554678806691589090814275138081407920379810144694354354954459732280968086760894209634364189264517251735804373673532012530665557440070501687207620525228416650281363557992436992284712644274 -F+uI7ARCeAlnPLO1YR7RJj8LyhtE/EJMcY45lsNMff0YeENe8KOITZVxNA55FcxDYpg9sKi1UV3/ASqkqpH8MOxWpBdT2UwSX3oBkp6ETfJKqiag0C4MS8cQVsfcKF39BJ6KUE7X6KUEj11j2YIIRREmLPyZ0LatG7dN7Rmv2iI= 16797235966984072293396362937533957334369977688369659112225970370748312376722010874726300554329794854683394163379447263409228872034356195791733533528404245739693397078461712458035888813157166614479153484688995068722288153129390850561042173295997770817893349738328312152341860704179681230323810266038959856162 -ALkEoXznA7BJlBIfA3Avl9kygQcxexEMApwduVRiXeYG0uEXMQU4rgMJBlPqs+ly8LTIcLFaLnJAG2KFQn2GXz2TNa7w4xkegkrslIJEtBWX/lc7VzRtcLbhaXEs0Ci1ValnW9Up7dYOj3Qw9eNo/9M9b1fD9TI+0QXFtp1ge728 129924120553920201168632484268654219915712271781591182777925696006023100660478316445751842982460082888615429513674356810187315558964251402722465707617058251479494744427428152566665405423424700027316505872162698141109433045594670140335040479559124757490095995568556894332243767736124299898808796118800328801724 -Ki3FNTEE870E9GaNtbT418CLSmf++s6Di3hzAy8NgiDOFo+uuicJa54V3JNRxOBc99sl/chfZuaBQt14BFOQ0i+9rm2KD82okNABd+SNfXOb0Ow2taZX8CpkVJYDyphFPyHbPIKmzwMShNx9X2z9w4++tJgzBzGcFTPv1nhAlxc= 29618953883711174042338818332957726953262658484143534778541769862244883781157097499904047532839425875312731531093860721544220959674634750905085721866390609141599426547378130082409488797303960018348798930232014390380383063108812922828160584483043190739354817699497573863286563890071313017508437166939160221463 -AJq8tcSnAq6M32ViO4hVGiHY7Tb08cLVyxpl/v0Y5adYblvjrbsFcCmsNDi5PnBOBl5awR7KZdQ1xgq6jIs+SQbccEMvJvGUZW5MgcHrXBj9XVd+8oB0z0eahqXpgYBqLDeHLU6238xR3dJYFf+Xrcrzjg8swx66OmQKkAQVJtdq 108660120968150664552423780971948386965268856900017812123107864829782135741514930439461240950044759098603910762272795612101834680870627850178371693837566833495418727543557712057554231215186486008080050486837716071537742708913279026303380104388546316647349432118287628353129105425052237438199445863950767806314 -AI3mfrgcRwtE3mA12gSoQV1xyIGy/YA4pCCvja4mTjvzQOAfiZL0efadxZH5awohCC1SpZDCFsE9yYp4LugHKu/A8zMcp4k5ena8sTPDkSod1yucjybgmVJ5h17Pru28AzHQ/YUmCnojQv55aV2+AUhxzIfojY+NT2PKRqr+vuf+ 99645829268436288676280252226747461064597487404802430565833102291706103139410465131373666856042539909746769688396958963177805479987372681967013633920910376342526433530508868114301205524789149997372160919406352823342811006288909548557622230243808373083272214426118230701324879006645047374853535922112549545982 -TmXQ+D8XFKSclXwnTIH8d+sb1IV0gfm7GagJahaFL6A9rvYaZ0NTizkG5DQ0RmXyo0wPmLork/296whsdNdUxVAwnGFlWWvMV0ftR1fOvN9KoT0WtVZ4Rmu6Fuc7q1PskAZzIp7MkOAxILO4iX5dNuVC+GLZYIbpTel3Ga8fXuU= 55052751096768041533898435453266875315629605001878362193939750978427494147944918632414581744895066623527980497732722163665712245580312596487741856071020477624754815927936394948233480228964159047139170955663289543349257377302556035170334384320502468579367401821986660515827461352578142560630318492817238744805 -EF6KIBWQiQoHOnBdJs1p+WIcAv9ILt0cnQVo+o/2niOtI0C+eFBSiNgeddhotkQFgHvGUjq8BPYgtLC8A5IFKGzXu4SYj5ziagka0hqfhVs9zVHKNx2NUoMhPDG5R7+giwEGGPOayGHVNbsBf1FBYG91+mwy8hnNbhcHSnvLGk4= 11494909948912248031301686864833544028186348338729984264372557659364976118965740281229664413031002362633393381744365783802034700038490736736266032000546393704814403638058993380993275865674190555703046732456017652317200288968188655019374159412919163798248766655991273308390043613040731449231289437754791500366 -AL7wCh8tkFe07qChFAzRkrnNehvda/Teroj65X1Bmcr14+/zeJlZDObYRYBOm8YYSYNgJekcL3o9lLFE34sCMbSJgm4dGwpEVexiLVi+zc8ndnqBDSAnRqtC+3jbInm/v8l6cUvuzrUNtzXIQ/H4FrmPMiVy0EMerkMtkfw5GBsd 134080980697158076909534078193319899756347955848461100874771253577754225619652121295523443912922220564492468474647193062555347746840044705102003079330399499915801536721237211615317000955332058281901995149084303143543150689010335818219129745452688372571010816270728441637278434982752674030696337642893239393053 -APunLhlblRi3bbRBwSV8dsw8h5SvT8ncAmXPnca+e1dLzrQZzL7P2OhFope0mW1MCDl2kJPiGTdK3SiYJVsAFeR3r/0z96g3oq+8uS66T6VaJym0QToMsqQF4/fUMaTo9HsukyPyOgjVIU+6TiFd3SxQKIu1/GpQWVQIP2pkHFKM 176716779397275986910036615967409090183531310366246043951791503601618945774743601662530806467045971394247287367421508126613573039423674729894091424105133906122821596079925540513892022311039293333114333317886304014722168786051080135090242879622144693440448171583324154550086458411590240882982297314605229953676 -MM6B5AgdJKe5OLlPzcXwi9WhqQjx5KsnBYxxa3kWdGNTdk/IN6TVd4Ptn8lWkLm78mw3DXP4Ol1sQbIfkHRoKFUN6TaWg5aDCJBDXyHSTZI2FDc1di0Te1SwziYn0sIOe+R+rfuLuHlcT1xaZBgL6+dDLAZaZza36UEjn5i/pTs= 34273208848307582992498656582721015257885595139328466874135636009184357438445251703533153492315835793684794951576799764181908090765379592683793969576893243386892292517067596035059342970830813419330530731370385186653239446376170533147020072285887964430731437765184844167400169982662183791828762458682426369339 -AJK1dx77ZA4F0sYCgRL1LKSTvjGTKBHd4QBeVnE6FKJxIow82puqtsVZ7TBxbECex+LkLQPrEbuQaVr3giUDjg0aJCE0D9ZVXCUS06qulqcCCdWgGFHXDOQzTWDn6TlJCGxtTEMbMxSlUq1q0iKZ19kwMHiT3GydBn8/G7tIYd23 103022457217861194294329435482792508957642944252832971366936865663608381648431732294396977429863681671686490913575377744795372643599438468695483808375208871881849232129651519218503507811863794426234594709451104684234156597418383183271923307418704786548452806494411689822939919114966188329657999811363991575991 -fPZNsqUYBbVGA2FAiglnByxGJOZkVSpj8Y4QNW5wq6o/1e/PRwp0TLYJXIoCJRs82pAj0QDpQbHl5lCZmNxEIQP8o8xI//HCPxPIdgBJmSfm3VGetrOpqEGU0KJJqK4IsjoVpAfPFMUMOpGNz9CSvCHGk1AKrtYvrTJEKmETuig= 87751387019308584846595931543798879607048239290774788042055795835726250309378365187899578817976976035304304847968410200168743967600896348021636654074952051821111673620467434295067182213181329543946368332581250062140819766061014427755090798550122401239987766844126425179573454145697756278292448630509686471208 -EmT6DUd0bxcdprYhAnycQaxm89kltJOlIOGFFRmEK90H3RhzBGr5PRVTJVqemFVpVliO1gy1nPHgqDGVNIE1GXhrhyFJU6m+HJeNcduippRe38xPCiuraRkXao79X7WAiVYUq6RIH+UIRnfTvHBgzTwjrOvKJ5853hYmGaanjh0= 12917015385266582065020051081997430892582163827812227349569911846746592973268746845211126663077128575098045461893559476227689488349263954564361736197688317585888118974603264677576027836032271531903881104937422976121352854003385726888601980526287956222142458858211589791399646989299770657341412683499692330525 -APtOYyWzdY1A/YU0SGrtjPdMZA5E50Y3hJVXppwuuSk04TjXzcbu2Sqp7sMnKYbToRW4nB5p2UnaLPhTRy0yszOd1auLngW+0ttCybD6nTcVoP65gYOwXGfSEQysqKLb1OfV8kYq5Ba92Efn+CcWWWuS0wEr97W5M/Hccx9bGu0r 176473215292413922394356058789571494026727424839036665031567966488209592078148711908841964690807374236235612412767651029865069639786447019874344449598703213025389428836803984245755885691094364960118900160737925054803955567361126391353868279642836569627177281508980029006921064654964339077608785831304875404587 -Vs6bjpYfFA1R/QTeCfhMuZLZ+Zxo6wxq1jFZpi5SBR1LaUwAtOAj38OJC8L7zmxSOj/RGEmJHkulI3E1MH7P7xlWbY468/azfot5fX9BgHrtptV6Q0dkBUg7H91+tcxdbm4/V0HGQGa2rZp+XK1rO+U/d0ki6iNbsCsCR+OeyvI= 60957991334776853645581868230398759578123373154273044785333939425321390401088800849629483265841435899835570419798325123273632247193463641611211088549152950252041797959644227170492417662363676228611376046334386877555777556575818860902071813120592757466883038430756577949025778080997296219236534786815367760626 -GiauT9A+wmwJsFbS2OPIM6ultIbU+kT2NgACn1jFAy+vNBahdfHMCH0jJdCs5TbmKTCeiEf3ITc5TV1OSvIejJ0GRkTf80nY47TAhiP1aehZvMAv59NQHHTDUE1U4TPVYKIyFpm1V1A+JBHKJzuGrB4lvqB2ed7k4m/ZD5lFLMM= 18363925023885496669420377869542744504974590667921570026763131637088916425434675950812384919000566852243714758512996458727914094904422651029609645299422563453163291342992902510788457007623888307499601267675322986672697397389663297565071582648674012080122614260400848960757021864980761735684874056409664531651 -AL/9KOZLtZu4+ZQYQsmOgbST8F4RV4N/Z+l8qsbCFlHdXHqTTkcN0chsccE/3KkVTZsAnAyJqogbAvB/RZqttaK5a8iKlOEoerUS92FVQw/42WhsVaFggR9cHVuvCD6QqclZjSBQKQzUMy0YWPWlycAZDIv96tooA+V+Fk0jbcFs 134819194171226950171930028888667967094069342154233489571728632904658607624703819928943642011918061760802468868660586005724399808048609316802502143143910585363214684061242274402109137825176291816945489430125510625857564490981683683589784133305376252294774711594646923226452625156299996630452243345104727556460 -AK5x2N/4+PKlsW/fNrw76CnE+nS76Rd7Ugo3IKhMTB/IuCc5xG4MQHo5MlWE0oVkZ+Gs4CxUpvD/WCCjHHFlSxKG4mC6ehz3NVLglBt+f1RWfPkF28JPd0UaIOG3um8kG4J3JDN48PXOPP86A0H8ZYbE5+ImmXsGAcwvScUQRInU 122499245103202714319465533564374494931278163571999934877854825659720649344163774228004853964635693562785966889622928722984134944784141208867445419597834322541679973956606275877526560988151196822256754309120410807075405427166696093800381410682490767468563176131997424692783482903880902119461752084196789357012 -ALZ12i0hqFhwRAikcoahYzH/BUolhgZ9Jz6adLvvTO4wk6LLOpNC/zCz+LjM7HazZomT1SqeYJ2X+WeGFLADHuWo+Gp/I3S0UEneYHKJxoU7OoOtE0mB0BCncLckHao/LmbpnQpS+Lx5bRsr0yE6oWNea6gbyRm/R0to74MI3/KK 128128022342420083856194424802390993133863171077961467523372211039771843125192435716337829530528063182315478279257832480290950255315151577221042903861075751839976362752440630888566422581799720709574650482021111126414843635330535518992034746102956214991673417580508389225948159518319625680855827280146399752842 -APXxvLifWgehdwdTRAJP5KrchRzgbUsyMWKcPGm2ZkwGDJjoTl2LIOOGVFiL4CyPBxahkEHf0nMxBN5oNGX/Y4W4PuOAC8gMgHzdLkPWkpnTcyoe5DD+fQsqNuKVw9nvyB15fx8k0d6b056nfFjnnRqgybby7MSllAWSKRYRdxVm 172707950911363219032118650562553641123743396229371815589867086054370029540557395298194067635069298952836929253340374819975848769009260895874615676938511747311585257140973518651959463416682165208985512233703837931718385346209362040743041262031997793519095342415901373534535662377972036003546589624834285049190 -O+9ohtZ9SzGLJoZM8IRQAjhc/GPt2X5G+M22ZidYjx9WgOTrZDXorSyxLuHxay6djsJSgjxYMj8MuanYSn/DzPWBB1Gn4cDmIsfeYuzO+vUJ4l6d0nIvBg9Iqs61/PGFd46YxhnDiVQ9HEznyTjzESnNqc0+/OkQVJcwNHAcZBg= 42087920806448980363073662127262313840530298932643042322138035915324224188032438119079107631420338701086802583985117830416851550991102672642532160807467909040086448764318690465254898516502941122327185894900817634110254371864896139724173087625913998657136384357741816102965779105122269429701537815263708996632 -VJOZmvqrqsIUTQSSJpZPhbQIYN2tsfBhAciWnfAYpwjK9/ts7OP4Qgdp6T/V2EsSRPnfZ0VKdLg1CnEWDhfcODo+/BZcUrJ0AviFAEtdeUhoMSWXtjel9Ln2guHY4s33z2cN70+e8gfjes65lCzrxUIXEF4nKxzKBnScoooQP5k= 59391682001673484862915842850714742391303140646889359425353339320546979084250010101273851580028171449840778038774656177449549941659895629203970455580974953864068394275066532699748911169800076515776388213090834432354601344176559839798153004796057709798368011673585434643656820656931921831615507416411999846297 -FRyJCOgPziO6RDHX1JgYGZRcSAuoQFIZM4niD/B0twK3l+TRpmVigKZAJnZZFtmX+0JQkDwQn3lcBGQIL6mgy+j0hD58U2/Wd6xebuHSzf4OHVGo1cYoqZLplszA+hVCoDVTHi2YAZ+GtfQEggumcNVxqfEZd6D9Nu//hm0t21M= 14824975573460749317081504809641216868382341402512168178334301409725840669112911061147252565570697788806398498723577368905065980113760265945344671897779830912242224090954834750057278285419880820811348943398148063418809729356397202526234113316098584002071850758705282845646489058224513019380757604894853946195 -dUk5LyS7mduFJlvh5o8R73kJIeeTh0Zli/y3XjtIXfCaNRf+wDlD/pX91JEwsQ5Mvj8yq/Uq13QyWhoNwsPpXVcJtJ+02wtIn5darsBDfzcD/LbWhl7zTRUeMjZ72gAWi1djx94SWjrZJS2oWZU92Og1yOyKRG+ua0AhHfYYh6g= 82361050315899968537319599868832189063658136463903643442673674137187842597528653416212822014359684261704550279153006971937114135373937934986951573613797195556144113400128502946618028800530164890707031379614952207482505803377774320259789692177752930767589642007257364960987343146063216186985472686575891023784 -AI6rejwEznR35rIPuIz0CP2aWyhRUR3unJ90YfxyuVYxrqOJQGSDTSf6SGDDw5MqpZXa9pWuwpyrb6smOq4ZtC3Er7lipJfXDjhy+0k1qcfMjmqbATUscwXGpgW+MO71cttccEz6vhbjndi8gvG5M/vfL2l1jA8nXuBd4e254dbz 100186164434910864539376019601151338080943067893748898987236087770762310617199833479771711726248130012472861788210345311298499515751355424063761182369333224929721733015910055321263016834247318907562652286587380604998130368845939290804442878127169587599285040969551065995197981341260363722618429042861484922611 -AJ5vLZX0fSs8dUSBqd5hki48T9cYuR0atxR+qv7cRu9nD1vP8uNVR8dLitg3XH0RARt3ZmOgi/AuggZt6tTxuIBg+9JhBY9WW+BLL5CnYWHC3AKMi7MQBWciLtmBpyF152bDaEcV1PXxtml2KxX0Ba0C+hGVDmJSdi8Kjd4AkfU6 111256341508463539324514225759801553679558662737345522765042612717818066374840372549356543720386819501973783940451033901079765311790026584654529398345993992144903839534037331533660672892487693477412528974248713261092693018326068480417183236210881306241164169849090833681510163753605662526243408192127670285626 -ZhXtSzn1GiFfHHnSKUYZiTcEWqlI8owyCKFjCQ+VEvkdk50m8uN7RCQ6ZhI545tN7Uy0WdLstJhgJETBYLHHIoWsJn07mgPxuyO0XsqNroICMQEOO/YWQFk1c0VqZifcohQAwJj7fONzM7hTcA22/7gVigJ3iLq178jZOJsEPQs= 71686982768953132894579286530164112027530221141251507987469672039995314435159469907420372652392376452531392493658576814100773556880394271726970628960571077839124343525055625420896355363707908511865700866168843075071778015504724409171911254647909938237551680861008772396291072284353858575645679153885560978699 -Vc8Cw5m5yI+bJ5sUJYm/F2wyZ5x3D4ydyL0uU/3eVF2ZJu55OOlC9pUyyv7WGExClHvWpR9mhMnsqCLyseLfM2Q/YXJ7cjGPKp2xd+fvwHa4hRi1FdOxs96rJnb+HUt9hTwQByXgzpnUfs7AqrqaNf4WSlBNMu0IOOqDdB4iVHU= 60256873326783629723455608618518793848697944184579877638436234491615392142659293975260290798403892159720925893207048153291000664050780029732557737984085196691225472664027706406879051455184548871511448456651238810812870905640934953489289909009741493031472382758586341375517766302753448531830002512912250459253 -QmeUn6cbpE8YrDfMETz/+KVFaK+d4NHHzcdj/MnjcmqQSLpP/XwCW/aeudlN3SfKd6rNo1XZefunZO/ek+PHEIy899WzjiJaajhf2X05fl9WuPEaMES3Yrr+ClogFNQ+9jL8+7L+J8lDuqQzvchT0U0RPay5HSNZw+ZouVCiQ18= 46630904037845609335515965570673490721137364238213103678233212262384415738654627185220187275286458759154841820256007930773120637898228224906635911124921895934056288121005350040349882413280772888907627838315559544636626856478316691755270725623680935763476199888127096014398699432042227882284223578563208692575 -ALUBYIShA4w5kRUa6iNF8S33DqaprdOWjVBnO+j9CCGtUh+NNwfpKR8AKf536MtuFFtwaQvRIlkLpaTYXuRxzyU/YG2+UfRQF3pEmXQhcMxJqFzqZ5nWCIWlJ/KtYS4lcC/B7hD2UGAktnIdjVUTSxX60VzA+zxeunV2iBZXQlEs 127106299687401374061881872616647348819431126560557369258073443762502337592227172639640997680536372567116568811258505773087926491911004324918919511363985868314578663758269650473780772688462266790559846182685481907703974916356209771821075179827563487466641669110315430790405454641953880582274165368514679034156 -ANyAdMnVCVjmUZGiVdyvGE5mUQpKoJOJINqMAfzVUGvvxXFmGdoAx+xsDRNAP4KoijpXk6E3yPBPBZEWyhiHnyjEkktK/gX6gnb745afS0QIlsjhKCk/W/BHXkzC862Llnc1ZGAIsERnGceEoZHdICfDUh/7nMFp5WuSMzPB7nEO 154841617115465511611746667401422322067517612306328612547616471923266281876818466022676728696273611923942543658633762267658490816264271663863494188027433799849037906883352478212451733963905925106470599843045599411842850386623187980045961158399934160107237440980574028985561404965317132715808604373199725949198 -AJ4nfhDe+HojR2YrprDHW9FVUxsZvoIekwlNL2iKFRFcTB9IcEdh6QnGcaRinev7yEYUsL6saSxUj39uWlqo8udJFdszuuQUmnloIi34L5uj0m1OpLy2dawpFQr8pqyA7go4ugMMj6XCtiVnISUcK8wjHgY3Jed/EKK8k5ce0Jxt 111059703393618496515021583605572584329116596402705082562306930876194742195701060137568030171429700588269665205795898835699633817098262654446852249498668467827435829513531633390969638488553144849154126899372953755511962841193763362947708260103832329116485114451074371844037650417731807385491783373627950406765 -AL+heSTflb2MkRYFTKghfzqlVQ1oE5vcx0eCIsy9NJ2NGFXCRRvoGDVoB8UEsUWIRnaA+MIpwDKGpbOS8kRQrvBvPe/xM/t3jrGkaS6pN064+bCBx8Y/Jq31ZXNG8oUol+y1Eo6fkUKNl4EOetmZWK8VmhVwol5YngDffj4Q8ned 134567692290185631768518572983694048149859804864902017394351513816079806629664302312927579302025923096596995134868068794900003728293470554490807959649153000914807604036531509869958441069678002226922395630284261949256022972967357884468325217602330254290548618134453007903724438628204981673400911693835033278365 -AI272d2sbYIi637kHZC+6lievgcDvT5VKaCnus3fHwm2vfao7oYu31P4st9DlqPWJ635X6QtLkU5HgvVSy66MDj2fcOfwVL09ffkZYnoGNdhMADVgOq62Ro5cCpOdw8Ko0cCyVpVIaSysPuqY7kiClf9GTdyZz/uYHDgwWeNrc4R 99528854246023003959943182132914587584844397870416002887630245681136432049666385367430032197518895755482367603560037194955739661569172773017279832774100155646116233705958563163070414171045438199561777058338188494271322834524386565519620661180246416329082614115142485663975718653564590519408413408765689056785 -AN9S8vPzo4SkyKsk07nfyD0um1riJzRqqWF9KCL+kWMHajurgPACikYzu61tL7l1mNEaIU16Ndz541o+y76DgsTLYszu4KXUOEt1Gu3eHy05Fq18zCDlNesSVjkZjPmuJr2ku+p0cP0TLLMn7/KuVOm4GlEVc6OvBNZuEzRriSYZ 156823459768092337875922818543729136404805918580285507923139232733465414368775678369646914249412830351437211620056021568154043505276475345347569200977945836210758870414054407438380975491139001471954448623922841964684437333066353208837709613982022690623722155151315252634380695513434502419141555410441456920089 -AMc5H8kywLgiT4zz5xgoI90jejsHorbqUGtBeX9wke7zyvEKyWxRKScZwzRbinjDZzN48eg/30qTZOV2Rw97JFg+EA63iZ0vqfF8jErIt3hODniKX8zayCuNmiSb5kiZL0UDU1SNh8ER4m6o5vshBKkmqs0PeozfCGQtR3bZXlx4 139899247405256530335276706333424670310599977544642091674186635734421385499036688803073040921114325725234673132788498809189814711681909865484671959982394306416477300458309408833281654917008031099378445580498219376391819745965887864647387211647794422908411100892195529730435423964537342228510107659017578765432 -AKv+3H/TruTX3wdMWnLzD05em8u/QMl6lCHT4VkK+uZwBXoLeji54Tcs/hZIhj0Bdj0URrRt+7JdGSTy4Sr986AtVFxBJZA3lT+JT4JSrq3oY1Tv+tX/yg8ZodQmbpQyyfaFg3BgeHNmsUoCrdqhj4IwBqEXoOBRIXnzaTuqqSEw 120779384043726135670909127168686589868907326577918074234323699599475436892003731971700278391108690400460261929381703781833059801757700386671579819341589048987186473249926590758009001670959004477454905417357202448886738669226760846888369186457452643053236389556969071303251275912453385963613554945645058007344 -ANXIB+HxOyJd3YYsscMpqZpi/eYjZi5q6A0MohU4BiWEJK/E4uIObLJDH5yd4ng+hn7UMhc+R/AxG88hIdOc5NyG/QyFs95ZLUC26F9rkRifu2CBkgqR5EQi2cgwC8jGxQOkC62YND6cAn/ILsKTYaH0iavtO9Tz04vQp9Ypc82H 150122383481070201614242107655752525590609186454390549085509458064289390813495886095936526832230958746095739308601699615024239939948911472291507190108935262129646691795733786714291498653838550751365834947465294261687773081563139416397262227609481906371677917295227469553787085145970923979142676551778927103367 -ZQLFoW+dJ7vrHdMlcLRGKY6T6PZKnE2L3NjXymS/55my2CDBLdDf3oXwLlRjVt9KnEiXyQzLhyY2PrFA4k3N/3P5lVDLHero5c36TMshbHgbIKRGN2CGWPEFeQ4j040IwVbQCPJeuF3jL5ikCxWZFXfeEnTL6TqumLfD9yLQfKA= 70932215714423143395949105745758445705072524008235214324766464113352968998429901322485575506330607802260244612268338586532462314021433435523464635419846126736185176246740838082062856583684393425704173881940108783636582561707441482446854068022535943408999200681879161519209676205165680598258447492092651404448 -LzzvPw0FdtM2G/RRiqoajJiIH+Lw3jpL4H+08yOpp1bNITR2Aq0beu2nP0H4o2Z1/FNr2hzuGakkAhVbmmRXc8keoOkeaAQAP/8OYxHpjrqou3WPWaKx+vUCTSqVYYf8gnVKpAAC2cD+3lW+/ZJ538o+c0ovbUKNu1u1j1OBtA0= 33171669664542509840621265032202455391098253465550501094201777336478104142847268103467889435377685359857979277521589539506627375165485879405453566052091202280471235979376217319335800766353336252760793484157724210008639813552207624049019149744883918494762511376489708611103181576211531366514802868659603747853 -APrGj1lIIlxA57DNh+bTEAFbJK2Y2P3MxLShb4fPx2aY6j88k3umoe07ISQLf9PzNPeml4/0I3w0KNd2x4s9KHbj7NsIT64lhO6eQSEteqZXZGXUYUyNzhrTbAjt+Q9LVKItQhsTkTW2HTQ5RQZfGrkL118b/I18J4P+T8CGZdDz 176100632478477421621142147788721746818712752858710594712903769452749028606541677227413333567013253138397373757811889654342173021761934591400685421771460440213093509170325205622261487145789848227404883040799927313402244625239515162996390018403365063394514244196976794479529075569412676472840544017222373593331 -Fvcl/LemWk29I5LCjU1QedTjGlkvFF/kZXNkRJv+vNZ7qgq6pX8WB9yVkk6AoclDYAhCRfKTKuEpR23iafVuHpprPfNXcqBH8n01kq3U27xqIy2hS+D6BRBK67PQaekq31EB0aOcEb/DuNaXakS9+mtTMx6BKt+WoEY+NkzHK6c= 16126868736093163702771491576570380743773057522016869811780571865928979861357811080042796140032050364543242385458140594532945509386155523162799601656485075247603490060565663264947465987286983338572455184901756399862440455644131755848583379822279676555143231305246033911608913609591095831135803702269767527335 -AKW8tvaB8YZ7J5W2lmquBniJzUhRfqFdPZPqvBoMzR4cRh1CMNdSFsYsnsaF3KolNzogdsxFpHAaEMG6zSvpNJAoi4nixCqb5SETXrSLASXvNjI9MvCoE2JCRq7kMbjPL7cem+mBPWZITGUI6KVlJPLxQngHYSFxukqlx7jznwJH 116384596458828069344020651216200368975621068920641012055593076864629080375946542748377736186556382088448816531408136815533164209947323588157210859294774679831647934533061547276394884474877353537242203645373945111105805934070657589374883764420038511061919092743520704686962593876316976299391579463759429567047 -D5N2P4FrqDf7/2Z2BJsqah4SjUtolic/yNqdNzvNEogDKZKAJyGq4zhnHvkYXkEm2ueU/FDPJRqisszG0oULdU6c7p8acirEwsGLVh4RamnFRgmQSK1vbiYB3bR+P+iFX/bZ+TWjN2Y3YMa5UB//I6Zb5kEIjmTpjY2LEPI1e6s= 10937855369372570149476727082965401421189236366492771695094788039313362971972373068736123833330006002198346944149230147444718818161877123407713821100752433128205189334393732633989950841577315682292180735057952587083688644195300641998709155269462601925653013312848413290208844194513502358901613104779186502571 -V/A1ktS0xrcwlI8xrYqvlLCFYrdVp8tEzZaZ9iNNpPH/pzVsA0WbnnUeHbdilkje+4OdoX9C4U2xaOuWOfvqLR0c7GeCkSffCqyf4ZsBmjy/BQL6rCpxMF0gIHXO5O8aJ1h17hy9LTuNzWm4zVh4pNFuHC9L6nAcf92udMiIQzk= 61752386563628388546439207444896778638632243226541303179646524864765343154194512297447627825411023405896612559648434895675553567405277169056807223959390559391191382555701580549902639604424290133917402316755076644943742815711432111554988540913643347167948778404861099845961151998728662878854088239266688156473 -APoPgEKA0/r1FYmt/Iso6ChYK6dDU62Y+vH5h/LVE00biBYG1f7aL3GdllUTN+XQSHpqlDw8CD+9xojwZIMfgpgjOwLbbe7Aso460zLrg3R8aHBpbVt8iZUgjACwPYr5UyKbFzIAWaXcnYYQ+tCO9aDIuOz+/7eIF62C81zXFJVZ 175598490446477604563905754135475294999639698464908622773037381109011373179895295130424828038708319325919451724985361900259676699137657615076219968061941008972496322083528922054390781811699677037439989404270415929836486610353098273115864435328533577114470407444852521009919911888840405368858409835197558461785 -cL54ymLJhRx3U20Y9aUTIsXy9Ags+XHy4qk3F7uJyO46eiXSL7VrrR9vTQXAbETbu1YiVWfslsPht810eUDUVaVir6yLnXkywn46Ci42FEvVoTEFjO22uYcCh8nqB8H589w/+lVSlNrcILugwfdfCvK1iZzVimOO6l3qzfXToOU= 79171550718114578361958369278761819285111811576818442980166457146638966315793211967882077899426611721874954146020093740153495693185472340728106727284441726113022873005252623222594060645383105757498856463065370975867121188445567981809371870213273555432308279508351518168027875538720367440153667708369625129189 -QdQN4qW2QZq8/fmSaqlRiPSoDbhmF0oYjaY29HcKYGHdlOH0AMJb+RUIq1aszvVtjh7AYay2TNhaZMWQ6Qi3c42SNk3A1MVknT6zqiRCGjNFfxf/matbRLbTFQF832MAId708vrFLF/o2HpekMkc5hcHB6bkUUhEI1NLcMXwGck= 46226230186280253581676626651942823886592433541360244612432763620730826574920825070086312767146345247802570752482654580909236388357139147786783758670999083804670979821212991224400629053427330483809790366665043598754931511997925850227997764381723288657884346974360232490075739442406431704368767588177525348809 -cxHvCK/dyVDvaqCCQyLeaiBGA36mV5el+1lc2eUTkHGUzX5gU0QQCEp+iSXNJhIOON8VFpKOFsziuV0Z+3cegWRw/VnxnjXcBh6IDKdupzOPB+Yl8MA1ti/GrQjLC6ikcNYNjQT0ZThL7KTqEvvZJH68WYmD0IuK26swjNGIGaI= 80804939616399473443737611589382762718815989847332356984276911837267997590368701684135326680567847542004499684038240485603420973682522792156533112356849436451918522884749244246467852622918805139990256619014116276456718693703261686778030658826952213058982142604346352178078750879100976710761147710018148637090 -AIQ3OIZevkYoRGBmsFaXJobSfLeInuKKReVYNjP5VEPoMq0mXTltY6l09/rQ3d1JjsMD1PfA7emhxex+H9t3leBIfCi6Ux34GQEjXWpQc4awuiy9tbR077HaJyecvb8Qy1FTnOHoH5C043QJzrKYT/sFXjgB60piI8Y0R/hwxO4r 92845026347218330987427785323244729176754623818531419911990153715676845614711324345879159989637824921793015074978358052562420379797956750450245721653716740651389924718711940869162230097839047895842495414221110468446944827052871968998907462191349838598297775847512250220907563815783358238473966349820476321323 -LoG6ib5lUh57rdmSkZSWzBoudytFohS4uoU/uly6OaQDOi34GeNVxu/yr6RszJyL9JWkGNgFaBIv/HirH5zA9VQAL/6kpL93a0/GQ/nuHkHy3GWZPF/2+yJ0PfazQ40fWhHZfRxBngWslbguFPjj1XaJ37YzpQAYb/+QcUai9ic= 32658152290878644668906121702816147999633088014476055330179597550087921141413344679134407016170035735846077181424615228657687216737432274043674411132745299610950657139041836412322040866250189120286839287690983293111362228893996267791120043532014262644480689231457941173330523718758287779526551822788227954215 -AKu2jgOQCCfYZ3CLkXEH44aO4TtwMPeK/eq4FtNj9HZ9FxT0LLNJh0ZXPOaPJjgznvIw5C7/hNm7rUs1JeV8I8dj3nbS3EVERQz1gc/ckYB3H1bViWREOD5+TScDusi86YO/z4ar3dauKkg5kT1kKDuU/OP5kNMWvtJjHc4Vd3L3 120581042599355202025471829872601846477331097842315143148145881424071317426176264583672725691485724160094190478865850305422057632110749683552966861219554215519032344086824849470294473808177223497912069335635933312949412445851201918768630656712413082629164792850095444166888072453190903931430551124946191872759 -ANLs7OsR7oBM5jSjVADrk+Mx9d0TeieTIkxwWiJ5STKNQmW2EzPOjgbfcLhbYEhzzDFJveXO2dzz6/c8V5oW2yqg7VMx88DzEbpQnQpk/rOQRw9jbI4fxXNJHkNZCeysEVvFfLJb4ecsGA0xJ3Aylny/jP10ahPv2z5K99edGZSU 148116916208650944522110872759145096907599612943009577897396622287067669897712748449324334650112672914917664881091633448764667172850435775162090891556266912697811031318228334453406561952979778127173704706529448647577013482442758465809198730066784986763500579667100246958959793527011919373534159474250508506260 -AL+Er3n1qj+SBsZVtOMJYg4m0CN+DE6gRnC1F7nPvd2XnBe+QE0+LKfcpUDHVNxoydW4BDzNVwnUNbyjXZ+iuddPtO9hchVEI36UiuL0ydeldFpOZ9mtHJaAF6abd0MlHw4vXRf8CbOvXb5N4s76ggijlZBjRtU563sSmBcyq6Zt 134488725667189507159811764480908602790838430340670328479145818969651133017546803581865897303917708192047926432630297993507146075655594931523561067937580218599890162311074002344315818494246433967228889645359283635389151927472221799543158424012020308449895562192866672439712148770104592027035768027605661099629 -AK/04XOBSjjPpuFXTDF82RNWnKqZz9mJQbS2B5bn0ehFnBa6j+B+MazX+AxXTL/d5+hPLT1uexcnSMl3DcGGwKipOXg7Dtuj3pfJXHTrCqXAUYrIXI+8vKVQO55yQPGfzIg9SVgetwW1sDk+a28ZhJ5a9OddqNoi5C+dLce7ZtNb 123560902006294001923570614486104726169564351074482936927091682096999779538353161007361361829586988452098646362280351148131540524964916445100589671458589346440250329883789099771417949746709217272531950438336245613419967556433467843237384555807236658182067742367748737224684334525934210197178231424396818830171 -PzOEGHlihiveoWFAALY+LOfkRJfm0NUF/uR6cSU/tbpGAq4onNpr+iZIzEP5o3JBLOtDC595/NBPI0fzaXl0vQvgJs6KG8iKANjsLKQjIpZBkoKhdbG9MzTVQuAeuDW0w3sn2iMZ/v2dgAzRwfqmQYXJr3I2BbcwWraIJuZXw5A= 44381416070253681813077725822442106641846565789204187691647505370231831464947935035197059366680327425453811558282831465960889061956588244308214943856009686127871667376028831540813257349779756631357122923723235595360268572998278795110672666089470210929411514949652537714634611421849780859192966935514197771152 -APnuduN01GS9dO2m2uCLs400AR2lX7elOnIPC5U6e17qbukxWYzNhilZlM4kdGXAIeYpzFdSIW/gxRMZe6TXq9krFWRaaPyT2QwRfGHYnazS9F1QNYmW1zXdt+qVp0JGxmh5PyDstbP8Z3x50/E8Mb0gLLPhNAvzY2Jnr9A8Q1Hy 175507868985304663005133968393406051624825489142498103948374797086106732382869120248515993626061853699363294022457032257026588816021007648668265488426495800459085474654859258116280251546902009156490112550154951965894022789029787886785376415437170872937201839249103828294508088966180386198213606090453461193202 -QHEhL4iVzNdUsfG0izTEepwTOvxka8t/9MwuF1Ey6kxsI+ry4g4sJPgR2xMnbtOmvQn2NitAkfvA8JPCiL7a8+gmf+DVRDjKDfpfrtgAVmo+3rH+uJYTrKhAp8R7ggU2xIrvbIrgeUj7ieThPI3Rtap+IdkPCL853JC/+oKtytM= 45252649968839515171157821292772647085425694172492111870169593872127007254353374581972876464918186509502070064028725519394859148593053614163356612260257013360168930649423732336969778875205250872728821432415158634190866775855521719727700464116412886964736859295086745723651735554245035077902615220578218265299 -APeaekK4mVhEShCfM0mkRebcg1Iq5CgrFIEGOoh1nHzgebr5A9Wrhm9yD1Vd3e+fFD9urDRB4y5MHPJHX1U2NFToC+H8nQkFXL8bfd/9Wl2c7y8m0Mxwi53pLIdzETLbbfeOOtJvuSYYT3n8+/PeMnJ46UD8OfqtnFuS0/bVpFLS 173873040145444066957050580959132871919216036714423404143335635770937773583761934638398867981658394368476005882852706046614562314432695052874974848076542261910660410561876043187368112065303981001507235893831108658530338308496461162623683138693880482650786841100027392293758260448606244283355655751440485602002 -FqC/wgZDPTUoObPFSH5w4QR79zj/O+ZiHGTEnsBMwNZD3Gl/ClRDIsFMDDupNLgwgXsqCQbpwSOHOtAvUuAFwRpzt5B7lwIgtP5ism/AZRno5p+9WVSmUAM3glHsNtvYydz2MkXtnXzSMIR1ZVoLrdwMnckE4pbMzggqz+JZqxw= 15889870005716350976759704672045310928616256175405784574141006779373730686049218680335525720670897894546334915362899913262232170795516176419192840427996647372619000239408311568577050460995518058850793096827271653902583271225799114408537346367483775593212272587811309978019791973449354003275559762102731778844 -AJXNbv2AMWadF5h99ZAUy5gLnVK/hMaakFo0ZedtPNRJobxPmwj+h52G+Czd0U48G0V0wpdeUJC9v/4BhjzhCvNhNsdAT1+vQXDuteYQ1aspsEKLQ6b+NknO88QSbRJw53+KeOY2xe7PKOa4V89XnFFBF7wljRnIYrM8vvcqVQDk 105194875227030598769888785590198577650278341586165110611689226597424766274486797264032300493674927704016605741286512271390703088626381669060095573361828932336327125438452066548897528158329044309005232090053420259033538936293519762277428283316506398965916381374819450858053512398634116052299066189424983605476 -AIDRnUpBHepjBqYAlU4MG/8JxzX1mPxVNHpWvnEVgvqTQx/bisFPpXrYs3jAKIR/lzevYwhH0K/8Vvw4NK9iTMFqgSnU44AZztKsoxUXsEsl1UU56UscY5C7ciKU6vjjWI7nm/uHNOXdE82TQXkk2WX8ferNqZU5DaLFCb+zxb7w 90459642084794142567976043425270153270545560059973413835786695756473295513758287577749768786155290305189883600338986370836806413936196854410098516254596146039255388020628703824195128439558127783534033672712705194483515442668075394018677699876614329419492391568463215822656901183478205197671375262145069825776 -AIdvVNzJqWPgAShvi3GhbhMQft+SLigKGrhoqas2Saz/bA9u9Td6fAxa2LjrAqshW6cnm2aalc3Yv6RW/Y8vg7Ho31NSaRjT4zMUenykcC0/Y88UNxREi85wdnHwGytms6Lq49H8/7EFGJIyL1PLRWPmZn6XFkegscI/HUq/hiKm 95105613103051650721863964216778532448106311156426028879315612217763044797186635476805213120469258258125661666950525364331551671653846368977016286153840829836509696804585927581668281228810410814602664419962214359687545209312836366693384158782798559255789953908588601637765910472073600954502095647132310971046 -DdchOPjXrI6lpV84IdKCisPmdqZan8AARXRLADEhixsfXCYuO+WhNatI/fM1vgv+/TxwwIQjIfG1vOZcB36JUfjHYdItYQ70vUXaVFdpqvoBGyfOTU50Ds/11iGPCF8mWiQwR30/XAXytqDZtaVJVWsgHD3RigBSnSHhnvZAWYg= 9719024770319024562623340689338530708271347986326272393419504304391837979619189392867902307307106771234732135400958362219711925045600118964223238147375808749507928768896918369395426933218443166133187066167663170936604731896932630589251946733237697936733924510107175304126061649311812536190882160340308613512 -I+Z6rdTOt26/v3dtUP1plITb15fjb6aMDvqFS3AD1+nxBqnnk7ISGE9j6dv762EIWQpMzcCG5NCCq35KOHEwRXP28zup6olOMt3CBFgYVcBE2pWOpGiO19G/iFweYZXZPY5HgIkex7HBbb7l6HhomPc2sLL/IRhh2oogyHx2JMM= 25210054612455888156900839678249806510561198051210010474517915819801056434402727631042894881559517808906460418029149538469607239850657781476308872923928122553395468026744382526167194202058040459679991391557937527079948356545086684521068912222036707113005006607012596093923970784177288565193670152033981048003 -ALbBoyelCs4UkfnPjMT3S67ujhBHBEE0uxLx6kSGZq2IOMU/QdWYPFElRgYC/y++334FSEycjS6NAJJo2ITpZCO5AjNJ93J3WYgbDLiwu1VzKHX6ItfFNEk45km+QTi07+pDKcKNd1k0mxqpLd/PuZd5hRpPDDoKBb6i+mrCb2yF 128335905497646745013379107761994003743181143126608677203818152878840562628631384684712779135591095534911406031545494164782375276574093777950840330452805743803067864740000758175436633463846967335728314347497013853264454015790847388463800323796888198433722196292529074568758149650782323407298620158495364705413 -ANwlxEkeqmqYTxw1ZwMi1v2wo4ntPaEYZYoTLTJQfa+kuIksnHW9va243HAiOixd+rviVdm1dEwzESBbX0wiJNtRBpP+bnRxy4xOBjNoOB0c/tfka5JVwu5eeskyHx4V3inLviUaj86Yck42n5NaJFMfBvhzVftZ/YF9WBITI8g6 154592850289860621115358362871905683265658659789986179554827712019629689749439795961607030363152337159590319622241556795951071651584979664762468782303706550885785493534656062553770262954861884613383561063525714923031691298088562054236178003658891902606245782350998076658704876516153027797371814038658244397114 diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/test1-discover.txt b/vendor/gems/ruby-openid-2.1.2/test/data/test1-discover.txt deleted file mode 100644 index 7ec9b878..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/test1-discover.txt +++ /dev/null @@ -1,137 +0,0 @@ -equiv -Status: 200 OK -Content-Type: text/html - - - - -Joe Schmoe's Homepage - - -

    Joe Schmoe's Homepage

    -

    Blah blah blah blah blah blah blah

    - - - -header -Status: 200 OK -Content-Type: text/html -YADIS_HEADER: URL_BASE/xrds - - - -Joe Schmoe's Homepage - - -

    Joe Schmoe's Homepage

    -

    Blah blah blah blah blah blah blah

    - - -xrds -Status: 200 OK -Content-Type: application/xrds+xml - - - -xrds_ctparam -Status: 200 OK -Content-Type: application/xrds+xml; charset=UTF8 - - - -xrds_ctcase -Status: 200 OK -Content-Type: appliCATION/XRDS+xml - - - -xrds_html -Status: 200 OK -Content-Type: text/html - - - -redir_equiv -Status: 302 Found -Content-Type: text/plain -Location: URL_BASE/equiv - -You are presently being redirected. - -redir_header -Status: 302 Found -Content-Type: text/plain -Location: URL_BASE/header - -You are presently being redirected. - -redir_xrds -Status: 302 Found -Content-Type: application/xrds+xml -Location: URL_BASE/xrds - - - -redir_xrds_html -Status: 302 Found -Content-Type: text/plain -Location: URL_BASE/xrds_html - -You are presently being redirected. - -redir_redir_equiv -Status: 302 Found -Content-Type: text/plain -Location: URL_BASE/redir_equiv - -You are presently being redirected. - -lowercase_header -Status: 200 OK -Content-Type: text/html -x-xrds-location: URL_BASE/xrds - - - -Joe Schmoe's Homepage - - -

    Joe Schmoe's Homepage

    -

    Blah blah blah blah blah blah blah

    - - -404_server_response -Status: 404 Not Found - -EEk! - -500_server_response -Status: 500 Server error - -EEk! - -201_server_response -Status: 201 Created - -EEk! - -404_with_header -Status: 404 Not Found -YADIS_HEADER: URL_BASE/xrds - -EEk! - -404_with_meta -Status: 404 Not Found -Content-Type: text/html - - - - -Joe Schmoe's Homepage - - -

    Joe Schmoe's Homepage

    -

    Blah blah blah blah blah blah blah

    - - diff --git a/vendor/gems/ruby-openid-2.1.2/test/data/test1-parsehtml.txt b/vendor/gems/ruby-openid-2.1.2/test/data/test1-parsehtml.txt deleted file mode 100644 index 8ed59d33..00000000 --- a/vendor/gems/ruby-openid-2.1.2/test/data/test1-parsehtml.txt +++ /dev/null @@ -1,152 +0,0 @@ -found - - - -found - - - -found - - - -found - - - -found - - - -found - - - -found - - - -found - - - -None - - - - Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. - -* Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [Mike Naberezny] - -* Fixed escaping of backslashes in JavaScriptHelper#escape_javascript #6302 [sven@c3d2.de] - -* Fixed that some 500 rescues would cause 500's themselves because the response had not yet been generated #6329 [cmselmer] - -* respond_to :html doesn't assume .rhtml. #6281 [Hampton Catlin] - -* Fixed some deprecation warnings in ActionPack [Rick Olson] - -* assert_select_rjs decodes escaped unicode chars since the Javascript generators encode them. #6240 [japgolly] - -* Deprecation: @cookies, @headers, @request, @response will be removed after 1.2. Use the corresponding method instead. [Jeremy Kemper] - -* Make the :status parameter expand to the default message for that status code if it is an integer. Also support symbol statuses. [Jamis Buck]. Examples: - - head :status => 404 # expands to "404 Not Found" - head :status => :not_found # expands to "404 Not Found" - head :status => :created # expands to "201 Created" - -* Add head(options = {}) for responses that have no body. [Jamis Buck]. Examples: - - head :status => 404 # return an empty response with a 404 status - head :location => person_path(@person), :status => 201 - -* Fix bug that kept any before_filter except the first one from being able to halt the before_filter chain. [Rick Olson] - -* strip_links is case-insensitive. #6285 [tagoh, Bob Silva] - -* Clear the cache of possible controllers whenever Routes are reloaded. [Nicholas Seckar] - -* Filters overhaul including meantime filter support using around filters + blocks. #5949 [Martin Emde, Roman Le Negrate, Stefan Kaes, Jeremy Kemper] - -* Update RJS render tests. [sam] - -* Update CGI process to allow sessions to contain namespaced models. Closes #4638. [dfelstead@site5.com] - -* Fix routing to respect user provided requirements and defaults when assigning default routing options (such as :action => 'index'). Closes #5950. [Nicholas Seckar] - -* Rescue Errno::ECONNRESET to handle an unexpectedly closed socket connection. Improves SCGI reliability. #3368, #6226 [sdsykes, fhanshaw@vesaria.com] - -* Added that respond_to blocks will automatically set the content type to be the same as is requested [David Heinemeier Hansson]. Examples: - - respond_to do |format| - format.html { render :text => "I'm being sent as text/html" } - format.rss { render :text => "I'm being sent as application/rss+xml" } - format.atom { render :text => "I'm being sent as application/xml", :content_type => Mime::XML } - end - -* Added utf-8 as the default charset for all renders. You can change this default using ActionController::Base.default_charset=(encoding) [David Heinemeier Hansson] - -* Added proper getters and setters for content type and charset [David Heinemeier Hansson]. Example of what we used to do: - - response.headers["Content-Type"] = "application/atom+xml; charset=utf-8" - - ...now: - - response.content_type = Mime::ATOM - response.charset = "utf-8" - -* Updated prototype.js to 1.5.0_rc1 with latest fixes. [Rick Olson] - - - XPATH support - - Make Form.getElements() return elements in the correct order - - fix broken Form.serialize return - -* Declare file extensions exempt from layouts. #6219 [brandon] - Example: ActionController::Base.exempt_from_layout 'rpdf' - -* Add chained replace/update support for assert_select_rjs [Rick Olson] - - Given RJS like... - - page['test1'].replace "
    foo
    " - page['test2'].replace_html "
    foo
    " - - Test it with... - - assert_select_rjs :chained_replace - assert_select_rjs :chained_replace, "test1" - - assert_select_rjs :chained_replace_html - assert_select_rjs :chained_replace_html, "test2" - -* Load helpers in alphabetical order for consistency. Resolve cyclic javascript_helper dependency. #6132, #6178 [choonkeat@gmail.com] - -* Skip params with empty names, such as the &=Save query string from . #2569 [Manfred Stienstra, raphinou@yahoo.com] - -* Fix assert_tag so that :content => "foo" does not match substrings, but only exact strings. Use :content => /foo/ to match substrings. #2799 [Eric Hodel] - -* Add descriptive messages to the exceptions thrown by cgi_methods. #6091, #6103 [Nicholas Seckar, Bob Silva] - -* Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, #6068 [petermichaux@gmail.com] - -* Update UrlWriter to support :only_path. [Nicholas Seckar, Dave Thomas] - -* Fixed JavaScriptHelper#link_to_function and JavaScriptHelper#button_to_function to have the script argument be optional [David Heinemeier Hansson]. So what used to require a nil, like this: - - link_to("Hider", nil, :class => "hider_link") { |p| p[:something].hide } - - ...can be written like this: - - link_to("Hider", :class => "hider_link") { |p| p[:something].hide } - -* Update to script.aculo.us 1.6.3 [Thomas Fuchs] - -* Update to Prototype 1.5.0_rc1 [sam] - -* Added access to nested attributes in RJS #4548 [richcollins@gmail.com]. Examples: - - page['foo']['style'] # => $('foo').style; - page['foo']['style']['color'] # => $('blank_slate').style.color; - page['foo']['style']['color'] = 'red' # => $('blank_slate').style.color = 'red'; - page['foo']['style'].color = 'red' # => $('blank_slate').style.color = 'red'; - -* Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] - -* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] - -* Fixed FormOptionsHelper#select to respect :selected value #5813 - -* Fixed TextHelper#simple_format to deal with multiple single returns within a single paragraph #5835 [moriq@moriq.com] - -* Fixed TextHelper#pluralize to handle 1 as a string #5909 [rails@bencurtis.com] - -* Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva] - -* Changed that uncaught exceptions raised any where in the application will cause RAILS_ROOT/public/500.html to be read and shown instead of just the static "Application error (Rails)" [David Heinemeier Hansson] - -* Integration tests: thoroughly test ActionController::Integration::Session. #6022 [Kevin Clark] - (tests skipped unless you `gem install mocha`) - -* Added deprecation language for pagination which will become a plugin by Rails 2.0 [David Heinemeier Hansson] - -* Added deprecation language for in_place_editor and auto_complete_field that both pieces will become plugins by Rails 2.0 [David Heinemeier Hansson] - -* Deprecated all of ActionController::Dependencies. All dependency loading is now handled from Active Support [David Heinemeier Hansson] - -* Added assert_select* for CSS selector-based testing (deprecates assert_tag) #5936 [assaf.arkin@gmail.com] - -* radio_button_tag generates unique id attributes. #3353 [Bob Silva, somekool@gmail.com] - -* strip_tags passes through blank args such as nil or "". #2229, #6702 [duncan@whomwah.com, dharana] - -* Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com] - -* button_to accepts :method so you can PUT and DELETE with it. #6005 [Dan Webb] - -* Update sanitize text helper to strip plaintext tags, and . [Rick Olson] - -* Update routing documentation. Closes #6017 [Nathan Witmer] - -* Add routing tests to assert that RoutingError is raised when conditions aren't met. Closes #6016 [Nathan Witmer] - -* Deprecation: update docs. #5998 [Jakob Skjerning, Kevin Clark] - -* Make auto_link parse a greater subset of valid url formats. [Jamis Buck] - -* Integration tests: headers beginning with X aren't excluded from the HTTP_ prefix, so X-Requested-With becomes HTTP_X_REQUESTED_WITH as expected. [Mike Clark] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Fix send_data documentation typo. #5982 [brad@madriska.com] - -* Switch to using FormEncodedPairParser for parsing request parameters. [Nicholas Seckar, David Heinemeier Hansson] - -* respond_to .html now always renders #{action_name}.rhtml so that registered custom template handlers do not override it in priority. Custom mime types require a block and throw proper error now. [Tobias Lütke] - -* Deprecation: test deprecated instance vars in partials. [Jeremy Kemper] - -* Add UrlWriter to allow writing urls from Mailers and scripts. [Nicholas Seckar] - -* Clean up and run the Active Record integration tests by default. #5854 [Kevin Clark, Jeremy Kemper] - -* Correct example in cookies docs. #5832 [jessemerriman@warpmail.net] - -* Updated to script.aculo.us 1.6.2 [Thomas Fuchs] - -* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar] - -* Add controller_paths variable to Routing. [Nicholas Seckar] - -* Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson] - -* Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson] - -* Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar] - -* Require Tempfile explicitly for TestUploadedFile due to changes in class auto loading. [Rick Olson] - -* Add RoutingError exception when RouteSet fails to generate a path from a Named Route. [Rick Olson] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so. [Jeremy Kemper] - -* Add support for the param_name parameter to the auto_complete_field helper. #5026 [david.a.williams@gmail.com] - -* Deprecation! @params, @session, @flash will be removed after 1.2. Use the corresponding instance methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper] - -* Make Routing noisy when an anchor regexp is assigned to a segment. #5674 [François Beausoleil] - -* Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" #5611 [pjhyett@gmail.com] - -* Short documentation to mention use of Mime::Type.register. #5710 [choonkeat@gmail.com] - -* Make controller_path available as an instance method. #5724 [jmckible@gmail.com] - -* Update query parser to support adjacent hashes. [Nicholas Seckar] - -* Make action caching aware of different formats for the same action so that, e.g. foo.xml is cached separately from foo.html. Implicitly set content type when reading in cached content with mime revealing extensions so the entire onous isn't on the webserver. [Marcel Molina Jr.] - -* Restrict Request Method hacking with ?_method to POST requests. [Rick Olson] - -* Fix bug when passing multiple options to SimplyRestful, like :new => { :preview => :get, :draft => :get }. [Rick Olson, Josh Susser, Lars Pind] - -* Dup the options passed to map.resources so that multiple resources get the same options. [Rick Olson] - -* Fixed the new_#{resource}_url route and added named route tests for Simply Restful. [Rick Olson] - -* Added map.resources from the Simply Restful plugin [David Heinemeier Hansson]. Examples (the API has changed to use plurals!): - - map.resources :messages - map.resources :messages, :comments - map.resources :messages, :new => { :preview => :post } - -* Fixed that integration simulation of XHRs should set Accept header as well [Edward Frederick] - -* TestRequest#reset_session should restore a TestSession, not a hash [Michael Koziarski] - -* Don't search a load-path of '.' for controller files [Jamis Buck] - -* Update integration.rb to require test_process explicitly instead of via Dependencies. [Nicholas Seckar] - -* Fixed that you can still access the flash after the flash has been reset in reset_session. Closes #5584 [lmarlow] - -* Allow form_for and fields_for to work with indexed form inputs. [Jeremy Kemper, Matt Lyon] - - <% form_for 'post[]', @post do |f| -%> - <% end -%> - -* Remove leak in development mode by replacing define_method with module_eval. [Nicholas Seckar] - -* Provide support for decimal columns to form helpers. Closes #5672. [Dave Thomas] - -* Update documentation for erb trim syntax. #5651 [matt@mattmargolis.net] - -* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com] - -* Reset @html_document between requests so assert_tag works. #4810 [Jarkko Laine, easleydp@gmail.com] - -* Update render :partial documentation. #5646 [matt@mattmargolis.net] - -* Integration tests behave well with render_component. #4632 [edward.frederick@revolution.com, dev.rubyonrails@maxdunn.com] - -* Added exception handling of missing layouts #5373 [chris@ozmm.org] - -* Fixed that real files and symlinks should be treated the same when compiling templates #5438 [zachary@panandscan.com] - -* Fixed that the flash should be reset when reset_session is called #5584 [Shugo Maeda] - -* Added special case for "1 Byte" in NumberHelper#number_to_human_size #5593 [murpyh@rubychan.de] - -* Fixed proper form-encoded parameter parsing for requests with "Content-Type: application/x-www-form-urlencoded; charset=utf-8" (note the presence of a charset directive) [David Heinemeier Hansson] - -* Add route_name_path method to generate only the path for a named routes. For example, map.person will add person_path. [Nicholas Seckar] - -* Avoid naming collision among compiled view methods. [Jeremy Kemper] - -* Fix CGI extensions when they expect string but get nil in Windows. Closes #5276 [Mislav Marohnić] - -* Determine the correct template_root for deeply nested components. #2841 [s.brink@web.de] - -* Fix that routes with *path segments in the recall can generate URLs. [Rick Olson] - -* Fix strip_links so that it doesn't hang on multiline tags [Jamis Buck] - -* Remove problematic control chars in rescue template. #5316 [Stefan Kaes] - -* Make sure passed routing options are not mutated by routing code. #5314 [Blair Zajac] - -* Make sure changing the controller from foo/bar to bing/bang does not change relative to foo. [Jamis Buck] - -* Escape the path before routing recognition. #3671 - -* Make sure :id and friends are unescaped properly. #5275 [me@julik.nl] - -* Fix documentation for with_routing to reflect new reality. #5281 [rramdas@gmail.com] - -* Rewind readable CGI params so others may reread them (such as CGI::Session when passing the session id in a multipart form). #210 [mklame@atxeu.com, matthew@walker.wattle.id.au] - -* Added Mime::TEXT (text/plain) and Mime::ICS (text/calendar) as new default types [David Heinemeier Hansson] - -* Added Mime::Type.register(string, symbol, synonyms = []) for adding new custom mime types [David Heinemeier Hansson]. Example: Mime::Type.register("image/gif", :gif) - -* Added support for Mime objects in render :content_type option [David Heinemeier Hansson]. Example: render :text => some_atom, :content_type => Mime::ATOM - -* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra ] - -* Routing rewrite. Simpler, faster, easier to understand. The published API for config/routes.rb is unchanged, but nearly everything else is different, so expect breakage in plugins and libs that try to fiddle with routes. [Nicholas Seckar, Jamis Buck] - - map.connect '/foo/:id', :controller => '...', :action => '...' - map.connect '/foo/:id.:format', :controller => '...', :action => '...' - map.connect '/foo/:id', ..., :conditions => { :method => :get } - -* Cope with missing content type and length headers. Parse parameters from multipart and urlencoded request bodies only. [Jeremy Kemper] - -* Accept multipart PUT parameters. #5235 [guy.naor@famundo.com] - -* Added interrogation of params[:format] to determine Accept type. If :format is specified and matches a declared extension, like "rss" or "xml", that mime type will be put in front of the accept handler. This means you can link to the same action from different extensions and use that fact to determine output [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find :all - - respond_to do |format| - format.html - format.xml { render :xml => @posts.to_xml } - format.rss { render :action => "feed.rxml" } - end - end - end - - # returns HTML when requested by a browser, since the browser - # has the HTML mimetype at the top of its priority list - Accept: text/html - GET /weblog - - # returns the XML - Accept: application/xml - GET /weblog - - # returns the HTML - Accept: application/xml - GET /weblog.html - - # returns the XML - Accept: text/html - GET /weblog.xml - - All this relies on the fact that you have a route that includes .:format. - -* Expanded :method option in FormTagHelper#form_tag, FormHelper#form_for, PrototypeHelper#remote_form_for, PrototypeHelper#remote_form_tag, and PrototypeHelper#link_to_remote to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [David Heinemeier Hansson] - -* Added :method option to UrlHelper#link_to, which allows for using other verbs than GET for the link. This replaces the :post option, which is now deprecated. Example: link_to "Destroy", person_url(:id => person), :method => :delete [David Heinemeier Hansson] - -* follow_redirect doesn't complain about being redirected to the same controller. #5153 [dymo@mk.ukrtelecom.ua] - -* Add layout attribute to response object with the name of the layout that was rendered, or nil if none rendered. [Kevin Clark] - -* Fix NoMethodError when parsing params like &&. [Adam Greenfield] - -* Fix flip flopped logic in docs for url_for's :only_path option. Closes #4998. [esad@esse.at] - -* form.text_area handles the :size option just like the original text_area (:size => '60x10' becomes cols="60" rows="10"). [Jeremy Kemper] - -* Excise ingrown code from FormOptionsHelper#options_for_select. #5008 [anonymous] - -* Small fix in routing to allow dynamic routes (broken after [4242]) [Rick Olson] - - map.connect '*path', :controller => 'files', :action => 'show' - -* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Use #flush between switching from #write to #syswrite. Closes #4907. [Blair Zajac ] - -* Documentation fix: integration test scripts don't require integration_test. Closes #4914. [Frederick Ros ] - -* ActionController::Base Summary documentation rewrite. Closes #4900. [Kevin Clark] - -* Fix text_helper.rb documentation rendering. Closes #4725. [Frederick Ros] - -* Fixes bad rendering of JavaScriptMacrosHelper rdoc (closes #4910) [Frederick Ros] - -* Allow error_messages_for to report errors for multiple objects, as well as support for customizing the name of the object in the error summary header. Closes #4186. [andrew@redlinesoftware.com, Marcel Molina Jr.] - - error_messages_for :account, :user, :subscription, :object_name => :account - -* Enhance documentation for setting headers in integration tests. Skip auto HTTP prepending when its already there. Closes #4079. [Rick Olson] - -* Documentation for AbstractRequest. Closes #4895. [Kevin Clark] - -* Refactor various InstanceTag instance method to class methods. Closes #4800. [Stefan Kaes] - -* Remove all remaining references to @params in the documentation. [Marcel Molina Jr.] - -* Add documentation for redirect_to :back's RedirectBackError exception. [Marcel Molina Jr.] - -* Update layout and content_for documentation to use yield rather than magic @content_for instance variables. [Marcel Molina Jr.] - -* Fix assert_redirected_to tests according to real-world usage. Also, don't fail if you add an extra :controller option: [Rick Olson] - - redirect_to :action => 'new' - assert_redirected_to :controller => 'monkeys', :action => 'new' - -* Cache CgiRequest#request_parameters so that multiple calls don't re-parse multipart data. [Rick Olson] - -* Diff compared routing options. Allow #assert_recognizes to take a second arg as a hash to specify optional request method [Rick Olson] - - assert_recognizes({:controller => 'users', :action => 'index'}, 'users') - assert_recognizes({:controller => 'users', :action => 'create'}, {:path => 'users', :method => :post}) - -* Diff compared options with #assert_redirected_to [Rick Olson] - -* Add support in routes for semicolon delimited "subpaths", like /books/:id;:action [Jamis Buck] - -* Change link_to_function and button_to_function to (optionally) take an update_page block instead of a JavaScript string. Closes #4804. [zraii@comcast.net, Sam Stephenson] - -* Fixed that remote_form_for can leave out the object parameter and default to the instance variable of the object_name, just like form_for [David Heinemeier Hansson] - -* Modify routing so that you can say :require => { :method => :post } for a route, and the route will never be selected unless the request method is POST. Only works for route recognition, not for route generation. [Jamis Buck] - -* Added :add_headers option to verify which merges a hash of name/value pairs into the response's headers hash if the prerequisites cannot be satisfied. [Sam Stephenson] - ex. verify :only => :speak, :method => :post, - :render => { :status => 405, :text => "Must be post" }, - :add_headers => { "Allow" => "POST" } - -* Added ActionController.filter_parameter_logging that makes it easy to remove passwords, credit card numbers, and other sensitive information from being logged when a request is handled #1897 [jeremye@bsa.ca.gov] - - -*1.13.3* (March 12th, 2007) - -* Apply [5709] to stable. - -* session_enabled? works with session :off. #6680 [Jonathan del Strother] - -* Performance: patch cgi/session to require digest/md5 once rather than per #create_new_id. [Stefan Kaes] - - -*1.13.2* (February 5th, 2007) - -* Add much-needed html-scanner tests. Fixed CDATA parsing bug. [Rick Olson] - -* improve error message for Routing for named routes. [Rob Sanheim] - -* Added enhanced docs to routing assertions. [Rob Sanheim] - -* fix form_for example in ActionController::Resources documentation. [gnarg] - -* Add singleton resources from trunk [Rick Olson] - -* select :multiple => true suffixes the attribute name with [] unless already suffixed. #6977 [nik.kakelin, ben, julik] - -* Improve routes documentation. #7095 [zackchandler] - -* Resource member routes require :id, eliminating the ambiguous overlap with collection routes. #7229 [dkubb] - -* Fixed NumberHelper#number_with_delimiter to use "." always for splitting the original number, not the delimiter parameter #7389 [ceefour] - -* Autolinking recognizes trailing and embedded . , : ; #7354 [Jarkko Laine] - -* Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268. [imajes] - -* Improved auto_link to match more valid urls correctly [Tobias Lütke] - - -*1.13.1* (January 18th, 2007) - -* Fixed content-type bug in Prototype [sam] - - -*1.13.0* (January 16th, 2007) - -* Modernize cookie testing code, and increase coverage (Heckle++) #7101 [Kevin Clark] - -* Heckling ActionController::Resources::Resource revealed that set_prefixes didn't break when :name_prefix was munged. #7081 [Kevin Clark] - -* Update to Prototype 1.5.0. [Sam Stephenson] - -* Allow exempt_from_layout :rhtml. #6742, #7026 [Dan Manges, Squeegy] - -* Fix parsing of array[] CGI parameters so extra empty values aren't included. #6252 [Nicholas Seckar, aiwilliams, brentrowland] - -* link_to_unless_current works with full URLs as well as paths. #6891 [Jarkko Laine, Manfred Stienstra, idrifter] - -* Fix HTML::Node to output double quotes instead of single quotes. Closes #6845 [mitreandy] - -* Fix no method error with error_messages_on. Closes #6935 [nik.wakelin Koz] - -* Slight doc tweak to the ActionView::Helpers::PrototypeHelper#replace docs. Closes #6922 [Steven Bristol] - -* Slight doc tweak to #prepend_filter. Closes #6493 [Jeremy Voorhis] - -* Add more extensive documentation to the AssetTagHelper. Closes #6452 [Bob Silva] - -* Clean up multiple calls to #stringify_keys in TagHelper, add better documentation and testing for TagHelper. Closes #6394 [Bob Silva] - -* [DOCS] fix reference to ActionController::Macros::AutoComplete for #text_field_with_auto_complete. Closes #2578 [Jan Prill] - -* Make sure html_document is reset between integration test requests. [ctm] - -* Set session to an empty hash if :new_session => false and no session cookie or param is present. CGI::Session was raising an unrescued ArgumentError. [Josh Susser] - -* Fix assert_redirected_to bug where redirecting from a nested to to a top-level controller incorrectly added the current controller's nesting. Closes #6128. [Rick Olson] - -* Ensure render :json => ... skips the layout. #6808 [Josh Peek] - -* Silence log_error deprecation warnings from inspecting deprecated instance variables. [Nate Wiger] - -* Only cache GET requests with a 200 OK response. #6514, #6743 [RSL, anamba] - -* Correctly report which filter halted the chain. #6699 [Martin Emde] - -* respond_to recognizes JSON. render :json => @person.to_json automatically sets the content type and takes a :callback option to specify a client-side function to call using the rendered JSON as an argument. #4185 [Scott Raymond, eventualbuddha] - # application/json response with body 'Element.show({:name: "David"})' - respond_to do |format| - format.json { render :json => { :name => "David" }.to_json, :callback => 'Element.show' } - end - -* Makes :discard_year work without breaking multi-attribute parsing in AR. #1260, #3800 [sean@ardismg.com, jmartin@desertflood.com, stephen@touset.org, Bob Silva] - -* Adds html id attribute to date helper elements. #1050, #1382 [mortonda@dgrmm.net, David North, Bob Silva] - -* Add :index and @auto_index capability to model driven date/time selects. #847, #2655 [moriq, Doug Fales, Bob Silva] - -* Add :order to datetime_select, select_datetime, and select_date. #1427 [Timothee Peignier, Patrick Lenz, Bob Silva] - -* Added time_select to work with time values in models. Update scaffolding. #2489, #2833 [Justin Palmer, Andre Caum, Bob Silva] - -* Added :include_seconds to select_datetime, datetime_select and time_select. #2998 [csn, Bob Silva] - -* All date/datetime selects can now accept an array of month names with :use_month_names. Allows for localization. #363 [tomasj, Bob Silva] - -* Adds :time_separator to select_time and :date_separator to select_datetime. Preserves BC. #3811 [Bob Silva] - -* @response.redirect_url works with 201 Created responses: just return headers['Location'] rather than checking the response status. [Jeremy Kemper] - -* Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [David Heinemeier Hansson] - -* Added GET-masquarading for HEAD, so request.method will return :get even for HEADs. This will help anyone relying on case request.method to automatically work with HEAD and map.resources will also allow HEADs to all GET actions. Rails automatically throws away the response content in a reply to HEAD, so you don't even need to worry about that. If you, for whatever reason, still need to distinguish between GET and HEAD in some edge case, you can use Request#head? and even Request.headers["REQUEST_METHOD"] for get the "real" answer. Closes #6694 [David Heinemeier Hansson] - - -*1.13.0 RC1* (r5619, November 22nd, 2006) - -* Update Routing to complain when :controller is not specified by a route. Closes #6669. [Nicholas Seckar] - -* Ensure render_to_string cleans up after itself when an exception is raised. #6658 [rsanheim] - -* Update to Prototype and script.aculo.us [5579]. [Sam Stephenson, Thomas Fuchs] - -* simple_format helper doesn't choke on nil. #6644 [jerry426] - -* Reuse named route helper module between Routing reloads. Use remove_method to delete named route methods after each load. Since the module is never collected, this fixes a significant memory leak. [Nicholas Seckar] - -* Deprecate standalone components. [Jeremy Kemper] - -* Always clear model associations from session. #4795 [sd@notso.net, andylien@gmail.com] - -* Remove JavaScriptLiteral in favor of ActiveSupport::JSON::Variable. [Sam Stephenson] - -* Sync ActionController::StatusCodes::STATUS_CODES with http://www.iana.org/assignments/http-status-codes. #6586 [dkubb] - -* Multipart form values may have a content type without being treated as uploaded files if they do not provide a filename. #6401 [Andreas Schwarz, Jeremy Kemper] - -* assert_response supports symbolic status codes. #6569 [Kevin Clark] - assert_response :ok - assert_response :not_found - assert_response :forbidden - -* Cache parsed query parameters. #6559 [Stefan Kaes] - -* Deprecate JavaScriptHelper#update_element_function, which is superseeded by RJS [Thomas Fuchs] - -* Fix invalid test fixture exposed by stricter Ruby 1.8.5 multipart parsing. #6524 [Bob Silva] - -* Set ActionView::Base.default_form_builder once rather than passing the :builder option to every form or overriding the form helper methods. [Jeremy Kemper] - -* Deprecate expire_matched_fragments. Use expire_fragment instead. #6535 [Bob Silva] - -* Deprecate start_form_tag and end_form_tag. Use form_tag / '' from now on. [Rick Olson] - -* Added block-usage to PrototypeHelper#form_remote_tag, document block-usage of FormTagHelper#form_tag [Rick Olson] - -* Add a 0 margin/padding div around the hidden _method input tag that form_tag outputs. [Rick Olson] - -* Added block-usage to TagHelper#content_tag [David Heinemeier Hansson]. Example: - - <% content_tag :div, :class => "strong" %> - Hello world! - <% end %> - - Will output: -
    Hello world!
    - -* Deprecated UrlHelper#link_to_image and UrlHelper#link_to :post => true #6409 [Bob Silva] - -* Upgraded NumberHelper with number_to_phone support international formats to comply with ITU E.123 by supporting area codes with less than 3 digits, added precision argument to number_to_human_size (defaults to 1) #6421 [Bob Silva] - -* Fixed that setting RAILS_ASSET_ID to "" should not add a trailing slash after assets #6454 [Bob Silva/chrismear] - -* Force *_url named routes to show the host in ActionView [Rick Olson] - - <%= url_for ... %> # no host - <%= foo_path %> # no host - <%= foo_url %> # host! - -* Add support for converting blocks into function arguments to JavaScriptGenerator#call and JavaScriptProxy#call. [Sam Stephenson] - -* Add JavaScriptGenerator#literal for wrapping a string in an object whose #to_json is the string itself. [Sam Stephenson] - -* Add <%= escape_once html %> to escape html while leaving any currently escaped entities alone. Fix button_to double-escaping issue. [Rick Olson] - -* Fix double-escaped entities, such as &amp;, &#123;, etc. [Rick Olson] - -* Fix routing to correctly determine when generation fails. Closes #6300. [psross]. - -* Fix broken assert_generates when extra keys are being checked. [Jamis Buck] - -* Replace KCODE checks with String#chars for truncate. Closes #6385 [Manfred Stienstra] - -* Make page caching respect the format of the resource that is being requested even if the current route is the default route so that, e.g. posts.rss is not transformed by url_for to '/' and subsequently cached as '/index.html' when it should be cached as '/posts.rss'. [Marcel Molina Jr.] - -* Use String#chars in TextHelper::excerpt. Closes #6386 [Manfred Stienstra] - -* Fix relative URL root matching problems. [Mark Imbriaco] - -* Fix filter skipping in controller subclasses. #5949, #6297, #6299 [Martin Emde] - -* render_text may optionally append to the response body. render_javascript appends by default. This allows you to chain multiple render :update calls by setting @performed_render = false between them (awaiting a better public API). [Jeremy Kemper] - -* Rename test assertion to prevent shadowing. Closes #6306. [psross] - -* Fixed that NumberHelper#number_to_delimiter should respect precision of higher than two digits #6231 [Philip Hallstrom] - -* Fixed that FormHelper#radio_button didn't respect an :id being passed in #6266 [evansj] - -* Added an html_options hash parameter to javascript_tag() and update_page_tag() helpers #6311 [tzaharia]. Example: - - update_page_tag :defer => 'true' { |page| ... } - - Gives: - - - - Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. - -* Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [Mike Naberezny] - -* Fixed escaping of backslashes in JavaScriptHelper#escape_javascript #6302 [sven@c3d2.de] - -* Fixed that some 500 rescues would cause 500's themselves because the response had not yet been generated #6329 [cmselmer] - -* respond_to :html doesn't assume .rhtml. #6281 [Hampton Catlin] - -* Fixed some deprecation warnings in ActionPack [Rick Olson] - -* assert_select_rjs decodes escaped unicode chars since the Javascript generators encode them. #6240 [japgolly] - -* Deprecation: @cookies, @headers, @request, @response will be removed after 1.2. Use the corresponding method instead. [Jeremy Kemper] - -* Make the :status parameter expand to the default message for that status code if it is an integer. Also support symbol statuses. [Jamis Buck]. Examples: - - head :status => 404 # expands to "404 Not Found" - head :status => :not_found # expands to "404 Not Found" - head :status => :created # expands to "201 Created" - -* Add head(options = {}) for responses that have no body. [Jamis Buck]. Examples: - - head :status => 404 # return an empty response with a 404 status - head :location => person_path(@person), :status => 201 - -* Fix bug that kept any before_filter except the first one from being able to halt the before_filter chain. [Rick Olson] - -* strip_links is case-insensitive. #6285 [tagoh, Bob Silva] - -* Clear the cache of possible controllers whenever Routes are reloaded. [Nicholas Seckar] - -* Filters overhaul including meantime filter support using around filters + blocks. #5949 [Martin Emde, Roman Le Negrate, Stefan Kaes, Jeremy Kemper] - -* Update CGI process to allow sessions to contain namespaced models. Closes #4638. [dfelstead@site5.com] - -* Fix routing to respect user provided requirements and defaults when assigning default routing options (such as :action => 'index'). Closes #5950. [Nicholas Seckar] - -* Rescue Errno::ECONNRESET to handle an unexpectedly closed socket connection. Improves SCGI reliability. #3368, #6226 [sdsykes, fhanshaw@vesaria.com] - -* Added that respond_to blocks will automatically set the content type to be the same as is requested [David Heinemeier Hansson]. Examples: - - respond_to do |format| - format.html { render :text => "I'm being sent as text/html" } - format.rss { render :text => "I'm being sent as application/rss+xml" } - format.atom { render :text => "I'm being sent as application/xml", :content_type => Mime::XML } - end - -* Added utf-8 as the default charset for all renders. You can change this default using ActionController::Base.default_charset=(encoding) [David Heinemeier Hansson] - -* Added proper getters and setters for content type and charset [David Heinemeier Hansson]. Example of what we used to do: - - response.headers["Content-Type"] = "application/atom+xml; charset=utf-8" - - ...now: - - response.content_type = Mime::ATOM - response.charset = "utf-8" - -* Declare file extensions exempt from layouts. #6219 [brandon] - Example: ActionController::Base.exempt_from_layout 'rpdf' - -* Add chained replace/update support for assert_select_rjs [Rick Olson] - - Given RJS like... - - page['test1'].replace "
    foo
    " - page['test2'].replace_html "
    foo
    " - - Test it with... - - assert_select_rjs :chained_replace - assert_select_rjs :chained_replace, "test1" - - assert_select_rjs :chained_replace_html - assert_select_rjs :chained_replace_html, "test2" - -* Load helpers in alphabetical order for consistency. Resolve cyclic javascript_helper dependency. #6132, #6178 [choonkeat@gmail.com] - -* Skip params with empty names, such as the &=Save query string from . #2569 [Manfred Stienstra, raphinou@yahoo.com] - -* Fix assert_tag so that :content => "foo" does not match substrings, but only exact strings. Use :content => /foo/ to match substrings. #2799 [Eric Hodel] - -* Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, #6068 [petermichaux@gmail.com] - -* Update UrlWriter to support :only_path. [Nicholas Seckar, Dave Thomas] - -* Fixed JavaScriptHelper#link_to_function and JavaScriptHelper#button_to_function to have the script argument be optional [David Heinemeier Hansson]. So what used to require a nil, like this: - - link_to("Hider", nil, :class => "hider_link") { |p| p[:something].hide } - - ...can be written like this: - - link_to("Hider", :class => "hider_link") { |p| p[:something].hide } - -* Added access to nested attributes in RJS #4548 [richcollins@gmail.com]. Examples: - - page['foo']['style'] # => $('foo').style; - page['foo']['style']['color'] # => $('blank_slate').style.color; - page['foo']['style']['color'] = 'red' # => $('blank_slate').style.color = 'red'; - page['foo']['style'].color = 'red' # => $('blank_slate').style.color = 'red'; - -* Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] - -* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] - -* Fixed FormOptionsHelper#select to respect :selected value #5813 - -* Fixed TextHelper#simple_format to deal with multiple single returns within a single paragraph #5835 [moriq@moriq.com] - -* Fixed TextHelper#pluralize to handle 1 as a string #5909 [rails@bencurtis.com] - -* Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva] - -* Changed that uncaught exceptions raised any where in the application will cause RAILS_ROOT/public/500.html to be read and shown instead of just the static "Application error (Rails)" [David Heinemeier Hansson] - -* Added deprecation language for pagination which will become a plugin by Rails 2.0 [David Heinemeier Hansson] - -* Added deprecation language for in_place_editor and auto_complete_field that both pieces will become plugins by Rails 2.0 [David Heinemeier Hansson] - -* Deprecated all of ActionController::Dependencies. All dependency loading is now handled from Active Support [David Heinemeier Hansson] - -* Added assert_select* for CSS selector-based testing (deprecates assert_tag) #5936 [assaf.arkin@gmail.com] - -* radio_button_tag generates unique id attributes. #3353 [Bob Silva, somekool@gmail.com] - -* strip_tags passes through blank args such as nil or "". #2229, #6702 [duncan@whomwah.com, dharana] - -* Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com] - -* button_to accepts :method so you can PUT and DELETE with it. #6005 [Dan Webb] - -* Update sanitize text helper to strip plaintext tags, and . [Rick Olson] - -* Add routing tests to assert that RoutingError is raised when conditions aren't met. Closes #6016 [Nathan Witmer] - -* Make auto_link parse a greater subset of valid url formats. [Jamis Buck] - -* Integration tests: headers beginning with X aren't excluded from the HTTP_ prefix, so X-Requested-With becomes HTTP_X_REQUESTED_WITH as expected. [Mike Clark] - -* Switch to using FormEncodedPairParser for parsing request parameters. [Nicholas Seckar, David Heinemeier Hansson] - -* respond_to .html now always renders #{action_name}.rhtml so that registered custom template handlers do not override it in priority. Custom mime types require a block and throw proper error now. [Tobias Lütke] - -* Deprecation: test deprecated instance vars in partials. [Jeremy Kemper] - -* Add UrlWriter to allow writing urls from Mailers and scripts. [Nicholas Seckar] - -* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar] - -* Add controller_paths variable to Routing. [Nicholas Seckar] - -* Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson] - -* Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson] - -* Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar] - -* Add RoutingError exception when RouteSet fails to generate a path from a Named Route. [Rick Olson] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so. [Jeremy Kemper] - -* Add support for the param_name parameter to the auto_complete_field helper. #5026 [david.a.williams@gmail.com] - -* Deprecation! @params, @session, @flash will be removed after 1.2. Use the corresponding instance methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper] - -* Make Routing noisy when an anchor regexp is assigned to a segment. #5674 [François Beausoleil] - -* Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" #5611 [pjhyett@gmail.com] - -* Make controller_path available as an instance method. #5724 [jmckible@gmail.com] - -* Update query parser to support adjacent hashes. [Nicholas Seckar] - -* Make action caching aware of different formats for the same action so that, e.g. foo.xml is cached separately from foo.html. Implicitly set content type when reading in cached content with mime revealing extensions so the entire onous isn't on the webserver. [Marcel Molina Jr.] - -* Restrict Request Method hacking with ?_method to POST requests. [Rick Olson] - -* Fixed the new_#{resource}_url route and added named route tests for Simply Restful. [Rick Olson] - -* Added map.resources from the Simply Restful plugin [David Heinemeier Hansson]. Examples (the API has changed to use plurals!): - - map.resources :messages - map.resources :messages, :comments - map.resources :messages, :new => { :preview => :post } - -* Fixed that integration simulation of XHRs should set Accept header as well [Edward Frederick] - -* TestRequest#reset_session should restore a TestSession, not a hash [Michael Koziarski] - -* Don't search a load-path of '.' for controller files [Jamis Buck] - -* Update integration.rb to require test_process explicitly instead of via Dependencies. [Nicholas Seckar] - -* Fixed that you can still access the flash after the flash has been reset in reset_session. Closes #5584 [lmarlow] - -* Allow form_for and fields_for to work with indexed form inputs. [Jeremy Kemper, Matt Lyon] - - <% form_for 'post[]', @post do |f| -%> - <% end -%> - -* Remove leak in development mode by replacing define_method with module_eval. [Nicholas Seckar] - -* Provide support for decimal columns to form helpers. Closes #5672. [Dave Thomas] - -* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com] - -* Reset @html_document between requests so assert_tag works. #4810 [Jarkko Laine, easleydp@gmail.com] - -* Integration tests behave well with render_component. #4632 [edward.frederick@revolution.com, dev.rubyonrails@maxdunn.com] - -* Added exception handling of missing layouts #5373 [chris@ozmm.org] - -* Fixed that real files and symlinks should be treated the same when compiling templates #5438 [zachary@panandscan.com] - -* Fixed that the flash should be reset when reset_session is called #5584 [Shugo Maeda] - -* Added special case for "1 Byte" in NumberHelper#number_to_human_size #5593 [murpyh@rubychan.de] - -* Fixed proper form-encoded parameter parsing for requests with "Content-Type: application/x-www-form-urlencoded; charset=utf-8" (note the presence of a charset directive) [David Heinemeier Hansson] - -* Add route_name_path method to generate only the path for a named routes. For example, map.person will add person_path. [Nicholas Seckar] - -* Avoid naming collision among compiled view methods. [Jeremy Kemper] - -* Fix CGI extensions when they expect string but get nil in Windows. Closes #5276 [Mislav Marohnić] - -* Determine the correct template_root for deeply nested components. #2841 [s.brink@web.de] - -* Fix that routes with *path segments in the recall can generate URLs. [Rick Olson] - -* Fix strip_links so that it doesn't hang on multiline tags [Jamis Buck] - -* Remove problematic control chars in rescue template. #5316 [Stefan Kaes] - -* Make sure passed routing options are not mutated by routing code. #5314 [Blair Zajac] - -* Make sure changing the controller from foo/bar to bing/bang does not change relative to foo. [Jamis Buck] - -* Escape the path before routing recognition. #3671 - -* Make sure :id and friends are unescaped properly. #5275 [me@julik.nl] - -* Rewind readable CGI params so others may reread them (such as CGI::Session when passing the session id in a multipart form). #210 [mklame@atxeu.com, matthew@walker.wattle.id.au] - -* Added Mime::TEXT (text/plain) and Mime::ICS (text/calendar) as new default types [David Heinemeier Hansson] - -* Added Mime::Type.register(string, symbol, synonyms = []) for adding new custom mime types [David Heinemeier Hansson]. Example: Mime::Type.register("image/gif", :gif) - -* Added support for Mime objects in render :content_type option [David Heinemeier Hansson]. Example: render :text => some_atom, :content_type => Mime::ATOM - -* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra ] - -* Routing rewrite. Simpler, faster, easier to understand. The published API for config/routes.rb is unchanged, but nearly everything else is different, so expect breakage in plugins and libs that try to fiddle with routes. [Nicholas Seckar, Jamis Buck] - - map.connect '/foo/:id', :controller => '...', :action => '...' - map.connect '/foo/:id.:format', :controller => '...', :action => '...' - map.connect '/foo/:id', ..., :conditions => { :method => :get } - -* Cope with missing content type and length headers. Parse parameters from multipart and urlencoded request bodies only. [Jeremy Kemper] - -* Accept multipart PUT parameters. #5235 [guy.naor@famundo.com] - -* Added interrogation of params[:format] to determine Accept type. If :format is specified and matches a declared extension, like "rss" or "xml", that mime type will be put in front of the accept handler. This means you can link to the same action from different extensions and use that fact to determine output [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find :all - - respond_to do |format| - format.html - format.xml { render :xml => @posts.to_xml } - format.rss { render :action => "feed.rxml" } - end - end - end - - # returns HTML when requested by a browser, since the browser - # has the HTML mimetype at the top of its priority list - Accept: text/html - GET /weblog - - # returns the XML - Accept: application/xml - GET /weblog - - # returns the HTML - Accept: application/xml - GET /weblog.html - - # returns the XML - Accept: text/html - GET /weblog.xml - - All this relies on the fact that you have a route that includes .:format. - -* Expanded :method option in FormTagHelper#form_tag, FormHelper#form_for, PrototypeHelper#remote_form_for, PrototypeHelper#remote_form_tag, and PrototypeHelper#link_to_remote to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [David Heinemeier Hansson] - -* Added :method option to UrlHelper#link_to, which allows for using other verbs than GET for the link. This replaces the :post option, which is now deprecated. Example: link_to "Destroy", person_url(:id => person), :method => :delete [David Heinemeier Hansson] - -* follow_redirect doesn't complain about being redirected to the same controller. #5153 [dymo@mk.ukrtelecom.ua] - -* Add layout attribute to response object with the name of the layout that was rendered, or nil if none rendered. [Kevin Clark] - -* Fix NoMethodError when parsing params like &&. [Adam Greenfield] - -* form.text_area handles the :size option just like the original text_area (:size => '60x10' becomes cols="60" rows="10"). [Jeremy Kemper] - -* Excise ingrown code from FormOptionsHelper#options_for_select. #5008 [anonymous] - -* Small fix in routing to allow dynamic routes (broken after [4242]) [Rick Olson] - - map.connect '*path', :controller => 'files', :action => 'show' - -* Use #flush between switching from #write to #syswrite. Closes #4907. [Blair Zajac ] - -* Allow error_messages_for to report errors for multiple objects, as well as support for customizing the name of the object in the error summary header. Closes #4186. [andrew@redlinesoftware.com, Marcel Molina Jr.] - - error_messages_for :account, :user, :subscription, :object_name => :account - -* Fix assert_redirected_to tests according to real-world usage. Also, don't fail if you add an extra :controller option: [Rick Olson] - - redirect_to :action => 'new' - assert_redirected_to :controller => 'monkeys', :action => 'new' - -* Diff compared routing options. Allow #assert_recognizes to take a second arg as a hash to specify optional request method [Rick Olson] - - assert_recognizes({:controller => 'users', :action => 'index'}, 'users') - assert_recognizes({:controller => 'users', :action => 'create'}, {:path => 'users', :method => :post}) - -* Diff compared options with #assert_redirected_to [Rick Olson] - -* Add support in routes for semicolon delimited "subpaths", like /books/:id;:action [Jamis Buck] - -* Change link_to_function and button_to_function to (optionally) take an update_page block instead of a JavaScript string. Closes #4804. [zraii@comcast.net, Sam Stephenson] - -* Modify routing so that you can say :require => { :method => :post } for a route, and the route will never be selected unless the request method is POST. Only works for route recognition, not for route generation. [Jamis Buck] - -* Added :add_headers option to verify which merges a hash of name/value pairs into the response's headers hash if the prerequisites cannot be satisfied. [Sam Stephenson] - ex. verify :only => :speak, :method => :post, - :render => { :status => 405, :text => "Must be post" }, - :add_headers => { "Allow" => "POST" } - - -*1.12.5* (August 10th, 2006) - -* Updated security fix - - -*1.12.4* (August 8th, 2006) - -* Cache CgiRequest#request_parameters so that multiple calls don't re-parse multipart data. [Rick Olson] - -* Fixed that remote_form_for can leave out the object parameter and default to the instance variable of the object_name, just like form_for [David Heinemeier Hansson] - -* Added ActionController.filter_parameter_logging that makes it easy to remove passwords, credit card numbers, and other sensitive information from being logged when a request is handled. #1897 [jeremye@bsa.ca.gov] - -* Fixed that real files and symlinks should be treated the same when compiling templates. #5438 [zachary@panandscan.com] - -* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra ] - -* Update documentation for erb trim syntax. #5651 [matt@mattmargolis.net] - -* Short documentation to mention use of Mime::Type.register. #5710 [choonkeat@gmail.com] - - -*1.12.3* (June 28th, 2006) - -* Fix broken traverse_to_controller. We now: - Look for a _controller.rb file under RAILS_ROOT to load. - If we find it, we require_dependency it and return the controller it defined. (If none was defined we stop looking.) - If we don't find it, we look for a .rb file under RAILS_ROOT to load. If we find it, and it loads a constant we keep looking. - Otherwise we check to see if a directory of the same name exists, and if it does we create a module for it. - - -*1.12.2* (June 27th, 2006) - -* Refinement to avoid exceptions in traverse_to_controller. - -* (Hackish) Fix loading of arbitrary files in Ruby's load path by traverse_to_controller. [Nicholas Seckar] - - -*1.12.1* (April 6th, 2006) - -* Fixed that template extensions would be cached development mode #4624 [Stefan Kaes] - -* Update to Prototype 1.5.0_rc0 [Sam Stephenson] - -* Honor skipping filters conditionally for only certain actions even when the parent class sets that filter to conditionally be executed only for the same actions. #4522 [Marcel Molina Jr.] - -* Delegate xml_http_request in integration tests to the session instance. [Jamis Buck] - -* Update the diagnostics template skip the useless '' text. [Nicholas Seckar] - -* CHANGED DEFAULT: Don't parse YAML input by default, but keep it available as an easy option [David Heinemeier Hansson] - -* Add additional autocompleter options [aballai, Thomas Fuchs] - -* Fixed fragment caching of binary data on Windows #4493 [bellis@deepthought.org] - -* Applied Prototype $() performance patches (#4465, #4477) and updated script.aculo.us [Sam Stephenson, Thomas Fuchs] - -* Added automated timestamping to AssetTagHelper methods for stylesheets, javascripts, and images when Action Controller is run under Rails [David Heinemeier Hansson]. Example: - - image_tag("rails.png") # => 'Rails' - - ...to avoid frequent stats (not a problem for most people), you can set RAILS_ASSET_ID in the ENV to avoid stats: - - ENV["RAILS_ASSET_ID"] = "2345" - image_tag("rails.png") # => 'Rails' - - This can be used by deployment managers to set the asset id by application revision - - -*1.12.0* (March 27th, 2006) - -* Add documentation for respond_to. [Jamis Buck] - -* Fixed require of bluecloth and redcloth when gems haven't been loaded #4446 [murphy@cYcnus.de] - -* Update to Prototype 1.5.0_pre1 [Sam Stephenson] - -* Change #form_for and #fields_for so that the second argument is not required [Dave Thomas] - - <% form_for :post, @post, :url => { :action => 'create' } do |f| -%> - - becomes... - - <% form_for :post, :url => { :action => 'create' } do |f| -%> - -* Update to script.aculo.us 1.6 [Thomas Fuchs] - -* Enable application/x-yaml processing by default [Jamis Buck] - -* Fix double url escaping of remote_function. Add :escape => false option to ActionView's url_for. [Nicholas Seckar] - -* Add :script option to in_place_editor to support evalScripts (closes #4194) [Cody Fauser] - -* Fix mixed case enumerable methods in the JavaScript Collection Proxy (closes #4314) [Cody Fauser] - -* Undo accidental escaping for mail_to; add regression test. [Nicholas Seckar] - -* Added nicer message for assert_redirected_to (closes #4294) [court3nay] - - assert_redirected_to :action => 'other_host', :only_path => false - - when it was expecting... - - redirected_to :action => 'other_host', :only_path => true, :host => 'other.test.host' - - gives the error message... - - response is not a redirection to all of the options supplied (redirection is <{:only_path=>false, :host=>"other.test.host", :action=>"other_host"}>), difference: <{:only_path=>"true", :host=>"other.test.host"}> - -* Change url_for to escape the resulting URLs when called from a view. [Nicholas Seckar, coffee2code] - -* Added easy support for testing file uploads with fixture_file_upload #4105 [turnip@turnipspatch.com]. Example: - - # Looks in Test::Unit::TestCase.fixture_path + '/files/spongebob.png' - post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png') - -* Fixed UrlHelper#current_page? to behave even when url-escaped entities are present #3929 [jeremy@planetargon.com] - -* Add ability for relative_url_root to be specified via an environment variable RAILS_RELATIVE_URL_ROOT. [isaac@reuben.com, Nicholas Seckar] - -* Fixed link_to "somewhere", :post => true to produce valid XHTML by using the parentnode instead of document.body for the instant form #3007 [Bob Silva] - -* Added :function option to PrototypeHelper#observe_field/observe_form that allows you to call a function instead of submitting an ajax call as the trigger #4268 [jonathan@daikini.com] - -* Make Mime::Type.parse consider q values (if any) [Jamis Buck] - -* XML-formatted requests are typecast according to "type" attributes for :xml_simple [Jamis Buck] - -* Added protection against proxy setups treating requests as local even when they're not #3898 [Steve Purcell] - -* Added TestRequest#raw_post that simulate raw_post from CgiRequest #3042 [François Beausoleil] - -* Underscore dasherized keys in formatted requests [Jamis Buck] - -* Add MimeResponds::Responder#any for managing multiple types with identical responses [Jamis Buck] - -* Make the xml_http_request testing method set the HTTP_ACCEPT header [Jamis Buck] - -* Add Verification to scaffolds. Prevent destructive actions using GET [Michael Koziarski] - -* Avoid hitting the filesystem when using layouts by using a File.directory? cache. [Stefan Kaes, Nicholas Seckar] - -* Simplify ActionController::Base#controller_path [Nicholas Seckar] - -* Added simple alert() notifications for RJS exceptions when config.action_view.debug_rjs = true. [Sam Stephenson] - -* Added :content_type option to render, so you can change the content type on the fly [David Heinemeier Hansson]. Example: render :action => "atom.rxml", :content_type => "application/atom+xml" - -* CHANGED DEFAULT: The default content type for .rxml is now application/xml instead of type/xml, see http://www.xml.com/pub/a/2004/07/21/dive.html for reason [David Heinemeier Hansson] - -* Added option to render action/template/file of a specific extension (and here by template type). This means you can have multiple templates with the same name but a different extension [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find :all - - respond_to do |type| - type.html # using defaults, which will render weblog/index.rhtml - type.xml { render :action => "index.rxml" } - type.js { render :action => "index.rjs" } - end - end - end - -* Added better support for using the same actions to output for different sources depending on the Accept header [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def create - @post = Post.create(params[:post]) - - respond_to do |type| - type.js { render } # renders create.rjs - type.html { redirect_to :action => "index" } - type.xml do - headers["Location"] = url_for(:action => "show", :id => @post) - render(:nothing, :status => "201 Created") - end - end - end - end - -* Added Base#render(:xml => xml) that works just like Base#render(:text => text), but sets the content-type to text/xml and the charset to UTF-8 [David Heinemeier Hansson] - -* Integration test's url_for now runs in the context of the last request (if any) so after post /products/show/1 url_for :action => 'new' will yield /product/new [Tobias Lütke] - -* Re-added mixed-in helper methods for the JavascriptGenerator. Moved JavascriptGenerators methods to a module that is mixed in after the helpers are added. Also fixed that variables set in the enumeration methods like #collect are set correctly. Documentation added for the enumeration methods [Rick Olson]. Examples: - - page.select('#items li').collect('items') do |element| - element.hide - end - # => var items = $$('#items li').collect(function(value, index) { return value.hide(); }); - -* Added plugin support for parameter parsers, which allows for better support for REST web services. By default, posts submitted with the application/xml content type is handled by creating a XmlSimple hash with the same name as the root element of the submitted xml. More handlers can easily be registered like this: - - # Assign a new param parser to a new content type - ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| - node = REXML::Document.new(post) - { node.root.name => node.root } - end - - # Assign the default XmlSimple to a new content type - ActionController::Base.param_parsers['application/backpack+xml'] = :xml_simple - -Default YAML web services were retired, ActionController::Base.param_parsers carries an example which shows how to get this functionality back. As part of this new plugin support, request.[formatted_post?, xml_post?, yaml_post? and post_format] were all deprecated in favor of request.content_type [Tobias Lütke] - -* Fixed Effect.Appear in effects.js to work with floats in Safari #3524, #3813, #3044 [Thomas Fuchs] - -* Fixed that default image extension was not appended when using a full URL with AssetTagHelper#image_tag #4032, #3728 [rubyonrails@beautifulpixel.com] - -* Added that page caching will only happen if the response code is less than 400 #4033 [g.bucher@teti.ch] - -* Add ActionController::IntegrationTest to allow high-level testing of the way the controllers and routes all work together [Jamis Buck] - -* Added support to AssetTagHelper#javascript_include_tag for having :defaults appear anywhere in the list, so you can now make one call ala javascript_include_tag(:defaults, "my_scripts") or javascript_include_tag("my_scripts", :defaults) depending on how you want the load order #3506 [Bob Silva] - -* Added support for visual effects scoped queues to the visual_effect helper #3530 [Abdur-Rahman Advany] - -* Added .rxml (and any non-rhtml template, really) supportfor CaptureHelper#content_for and CaptureHelper#capture #3287 [Brian Takita] - -* Added script.aculo.us drag and drop helpers to RJS [Thomas Fuchs]. Examples: - - page.draggable 'product-1' - page.drop_receiving 'wastebasket', :url => { :action => 'delete' } - page.sortable 'todolist', :url => { action => 'change_order' } - -* Fixed that form elements would strip the trailing [] from the first parameter #3545 [ruby@bobsilva.com] - -* During controller resolution, update the NameError suppression to check for the expected constant. [Nicholas Seckar] - -* Update script.aculo.us to V1.5.3 [Thomas Fuchs] - -* Added various InPlaceEditor options, #3746, #3891, #3896, #3906 [Bill Burcham, ruairi, sl33p3r] - -* Added :count option to pagination that'll make it possible for the ActiveRecord::Base.count call to using something else than * for the count. Especially important for count queries using DISTINCT #3839 [Stefan Kaes] - -* Update script.aculo.us to V1.5.2 [Thomas Fuchs] - -* Added element and collection proxies to RJS [David Heinemeier Hansson]. Examples: - - page['blank_slate'] # => $('blank_slate'); - page['blank_slate'].show # => $('blank_slate').show(); - page['blank_slate'].show('first').up # => $('blank_slate').show('first').up(); - - page.select('p') # => $$('p'); - page.select('p.welcome b').first # => $$('p.welcome b').first(); - page.select('p.welcome b').first.hide # => $$('p.welcome b').first().hide(); - -* Add JavaScriptGenerator#replace for replacing an element's "outer HTML". #3246 [tom@craz8.com, Sam Stephenson] - -* Remove over-engineered form_for code for a leaner implementation. [Nicholas Seckar] - -* Document form_for's :html option. [Nicholas Seckar] - -* Major components cleanup and speedup. #3527 [Stefan Kaes] - -* Fix problems with pagination and :include. [Kevin Clark] - -* Add ActiveRecordTestCase for testing AR integration. [Kevin Clark] - -* Add Unit Tests for pagination [Kevin Clark] - -* Add :html option for specifying form tag options in form_for. [Sam Stephenson] - -* Replace dubious controller parent class in filter docs. #3655, #3722 [info@rhalff.com, eigentone@gmail.com] - -* Don't interpret the :value option on text_area as an html attribute. Set the text_area's value. #3752 [gabriel@gironda.org] - -* Fix remote_form_for creates a non-ajax form. [Rick Olson] - -* Don't let arbitrary classes match as controllers -- a potentially dangerous bug. [Nicholas Seckar] - -* Fix Routing tests. Fix routing where failing to match a controller would prevent the rest of routes from being attempted. [Nicholas Seckar] - -* Add :builder => option to form_for and friends. [Nicholas Seckar, Rick Olson] - -* Fix controller resolution to avoid accidentally inheriting a controller from a parent module. [Nicholas Seckar] - -* Set sweeper's @controller to nil after a request so that the controller may be collected between requests. [Nicholas Seckar] - -* Subclasses of ActionController::Caching::Sweeper should be Reloadable. [Rick Olson] - -* Document the :xhr option for verifications. #3666 [leeo] - -* Added :only and :except controls to skip_before/after_filter just like for when you add filters [David Heinemeier Hansson] - -* Ensure that the instance variables are copied to the template when performing render :update. [Nicholas Seckar] - -* Add the ability to call JavaScriptGenerator methods from helpers called in update blocks. [Sam Stephenson] Example: - module ApplicationHelper - def update_time - page.replace_html 'time', Time.now.to_s(:db) - page.visual_effect :highlight, 'time' - end - end - - class UserController < ApplicationController - def poll - render :update { |page| page.update_time } - end - end - -* Add render(:update) to ActionView::Base. [Sam Stephenson] - -* Fix render(:update) to not render layouts. [Sam Stephenson] - -* Fixed that SSL would not correctly be detected when running lighttpd/fcgi behind lighttpd w/mod_proxy #3548 [Steve Purcell] - -* Added the possibility to specify atomatic expiration for the memcachd session container #3571 [Stefan Kaes] - -* Change layout discovery to take into account the change in semantics with File.join and nil arguments. [Marcel Molina Jr.] - -* Raise a RedirectBackError if redirect_to :back is called when there's no HTTP_REFERER defined #3049 [Kevin Clark] - -* Treat timestamps like datetimes for scaffolding purposes #3388 [Maik Schmidt] - -* Fix IE bug with link_to "something", :post => true #3443 [Justin Palmer] - -* Extract Test::Unit::TestCase test process behavior into an ActionController::TestProcess module. [Sam Stephenson] - -* Pass along blocks from render_to_string to render. [Sam Stephenson] - -* Add render :update for inline RJS. [Sam Stephenson] Example: - class UserController < ApplicationController - def refresh - render :update do |page| - page.replace_html 'user_list', :partial => 'user', :collection => @users - page.visual_effect :highlight, 'user_list' - end - end - end - -* allow nil objects for error_messages_for [Michael Koziarski] - -* Refactor human_size to exclude decimal place if it is zero. [Marcel Molina Jr.] - -* Update to Prototype 1.5.0_pre0 [Sam Stephenson] - -* Automatically discover layouts when a controller is namespaced. #2199, #3424 [me@jonnii.com rails@jeffcole.net Marcel Molina Jr.] - -* Add support for multiple proxy servers to CgiRequest#host [gaetanot@comcast.net] - -* Documentation typo fix. #2367 [Blair Zajac] - -* Remove Upload Progress. #2871 [Sean Treadway] - -* Fix typo in function name mapping in auto_complete_field. #2929 #3446 [doppler@gmail.com phil.ross@gmail.com] - -* Allow auto-discovery of third party template library layouts. [Marcel Molina Jr.] - -* Have the form builder output radio button, not check box, when calling the radio button helper. #3331 [LouisStAmour@gmail.com] - -* Added assignment of the Autocompleter object created by JavaScriptMacroHelper#auto_complete_field to a local javascript variables [David Heinemeier Hansson] - -* Added :on option for PrototypeHelper#observe_field that allows you to specify a different callback hook to have the observer trigger on [David Heinemeier Hansson] - -* Added JavaScriptHelper#button_to_function that works just like JavaScriptHelper#link_to_function but uses a button instead of a href [David Heinemeier Hansson] - -* Added that JavaScriptHelper#link_to_function will honor existing :onclick definitions when adding the function call [David Heinemeier Hansson] - -* Added :disable_with option to FormTagHelper#submit_tag to allow for easily disabled submit buttons with different text [David Heinemeier Hansson] - -* Make auto_link handle nil by returning quickly if blank? [Scott Barron] - -* Make auto_link match urls with a port number specified. [Marcel Molina Jr.] - -* Added support for toggling visual effects to ScriptaculousHelper::visual_effect, #3323. [Thomas Fuchs] - -* Update to script.aculo.us to 1.5.0 rev. 3343 [Thomas Fuchs] - -* Added :select option for JavaScriptMacroHelper#auto_complete_field that makes it easier to only use part of the auto-complete suggestion as the value for insertion [Thomas Fuchs] - -* Added delayed execution of Javascript from within RJS #3264 [devslashnull@gmail.com]. Example: - - page.delay(20) do - page.visual_effect :fade, 'notice' - end - -* Add session ID to default logging, but remove the verbose description of every step [David Heinemeier Hansson] - -* Add the following RJS methods: [Sam Stephenson] - - * alert - Displays an alert() dialog - * redirect_to - Changes window.location.href to simulate a browser redirect - * call - Calls a JavaScript function - * assign - Assigns to a JavaScript variable - * << - Inserts an arbitrary JavaScript string - -* Fix incorrect documentation for form_for [Nicholas Seckar] - -* Don't include a layout when rendering an rjs template using render's :template option. [Marcel Molina Jr.] - -*1.1.2* (December 13th, 2005) - -* Become part of Rails 1.0 - -* Update to script.aculo.us 1.5.0 final (equals 1.5.0_rc6) [Thomas Fuchs] - -* Update to Prototype 1.4.0 final [Sam Stephenson] - -* Added form_remote_for (form_for meets form_remote_tag) [David Heinemeier Hansson] - -* Update to script.aculo.us 1.5.0_rc6 - -* More robust relative url root discovery for SCGI compatibility. This solves the 'SCGI routes problem' -- you no longer need to prefix all your routes with the name of the SCGI mountpoint. #3070 [Dave Ringoen] - -* Fix docs for text_area_tag. #3083. [Christopher Cotton] - -* Change form_for and fields_for method signatures to take object name and object as separate arguments rather than as a Hash. [David Heinemeier Hansson] - -* Introduce :selected option to the select helper. Allows you to specify a selection other than the current value of object.method. Specify :selected => nil to leave all options unselected. #2991 [Jonathan Viney ] - -* Initialize @optional in routing code to avoid warnings about uninitialized access to an instance variable. [Nicholas Seckar] - -* Make ActionController's render honor the :locals option when rendering a :file. #1665. [Emanuel Borsboom, Marcel Molina Jr.] - -* Allow assert_tag(:conditions) to match the empty string when a tag has no children. Closes #2959. [Jamis Buck] - -* Update html-scanner to handle CDATA sections better. Closes #2970. [Jamis Buck] - -* Don't put flash in session if sessions are disabled. [Jeremy Kemper] - -* Strip out trailing &_= for raw post bodies. Closes #2868. [Sam Stephenson] - -* Pass multiple arguments to Element.show and Element.hide in JavaScriptGenerator instead of using iterators. [Sam Stephenson] - -* Improve expire_fragment documentation. #2966 [court3nay] - -* Correct docs for automatic layout assignment. #2610. [Charles M. Gerungan] - -* Always create new AR sessions rather than trying too hard to avoid database traffic. #2731 [Jeremy Kemper] - -* Update to Prototype 1.4.0_rc4. Closes #2943 (old Array.prototype.reverse behavior can be obtained by passing false as an argument). [Sam Stephenson] - -* Use Element.update('id', 'html') instead of $('id').innerHTML = 'html' in JavaScriptGenerator#replace_html so that script tags are evaluated. [Sam Stephenson] - -* Make rjs templates always implicitly skip out on layouts. [Marcel Molina Jr.] - -* Correct length for the truncate text helper. #2913 [Stefan Kaes] - -* Update to Prototype 1.4.0_rc3. Closes #1893, #2505, #2550, #2748, #2783. [Sam Stephenson] - -* Add support for new rjs templates which wrap an update_page block. [Marcel Molina Jr.] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Correct time_zone_options_for_select docs. #2892 [pudeyo@rpi.com] - -* Remove the unused, slow response_dump and session_dump variables from error pages. #1222 [lmarlow] - -* Performance tweaks: use Set instead of Array to speed up prototype helper include? calls. Avoid logging code if logger is nil. Inline commonly-called template presence checks. #2880, #2881, #2882, #2883 [Stefan Kaes] - -* MemCache store may be given multiple addresses. #2869 [Ryan Carver ] - -* Handle cookie parsing irregularity for certain Nokia phones. #2530 [zaitzow@gmail.com] - -* Added PrototypeHelper::JavaScriptGenerator and PrototypeHelper#update_page for easily modifying multiple elements in an Ajax response. [Sam Stephenson] Example: - - update_page do |page| - page.insert_html :bottom, 'list', '
  • Last item
  • ' - page.visual_effect :highlight, 'list' - page.hide 'status-indicator', 'cancel-link' - end - - generates the following JavaScript: - - new Insertion.Bottom("list", "
  • Last item
  • "); - new Effect.Highlight("list"); - ["status-indicator", "cancel-link"].each(Element.hide); - -* Refactored JavaScriptHelper into PrototypeHelper and ScriptaculousHelper [Sam Stephenson] - -* Update to latest script.aculo.us version (as of [3031]) - -* Updated docs for in_place_editor, fixes a couple bugs and offers extended support for external controls [Justin Palmer] - -* Update documentation for render :file. #2858 [Tom Werner] - -* Only include builtin filters whose filenames match /^[a-z][a-z_]*_helper.rb$/ to avoid including operating system metadata such as ._foo_helper.rb. #2855 [court3nay] - -* Added FormHelper#form_for and FormHelper#fields_for that makes it easier to work with forms for single objects also if they don't reside in instance variables [David Heinemeier Hansson]. Examples: - - <% form_for :person, @person, :url => { :action => "update" } do |f| %> - First name: <%= f.text_field :first_name %> - Last name : <%= f.text_field :last_name %> - Biography : <%= f.text_area :biography %> - Admin? : <%= f.check_box :admin %> - <% end %> - - <% form_for :person, person, :url => { :action => "update" } do |person_form| %> - First name: <%= person_form.text_field :first_name %> - Last name : <%= person_form.text_field :last_name %> - - <% fields_for :permission => person.permission do |permission_fields| %> - Admin? : <%= permission_fields.check_box :admin %> - <% end %> - <% end %> - -* options_for_select allows any objects which respond_to? :first and :last rather than restricting to Array and Range. #2824 [Jacob Robbins , Jeremy Kemper] - -* The auto_link text helper accepts an optional block to format the link text for each url and email address. Example: auto_link(post.body) { |text| truncate(text, 10) } [Jeremy Kemper] - -* assert_tag uses exact matches for string conditions, instead of partial matches. Use regex to do partial matches. #2799 [Jamis Buck] - -* CGI::Session::ActiveRecordStore.data_column_name = 'foobar' to use a different session data column than the 'data' default. [nbpwie102@sneakemail.com] - -* Do not raise an exception when default helper is missing; log a debug message instead. It's nice to delete empty helpers. [Jeremy Kemper] - -* Controllers with acronyms in their names (e.g. PDFController) require the correct default helper (PDFHelper in file pdf_helper.rb). #2262 [jeff@opendbms.com] - - -*1.11.0* (November 7th, 2005) - -* Added request as instance method to views, so you can do <%= request.env["HTTP_REFERER"] %>, just like you can already access response, session, and the likes [David Heinemeier Hansson] - -* Fix conflict with assert_tag and Glue gem #2255 [david.felstead@gmail.com] - -* Add documentation to assert_tag indicating that it only works with well-formed XHTML #1937, #2570 [Jamis Buck] - -* Added action_pack.rb stub so that ActionPack::Version loads properly [Sam Stephenson] - -* Added short-hand to assert_tag so assert_tag :tag => "span" can be written as assert_tag "span" [David Heinemeier Hansson] - -* Added skip_before_filter/skip_after_filter for easier control of the filter chain in inheritance hierachies [David Heinemeier Hansson]. Example: - - class ApplicationController < ActionController::Base - before_filter :authenticate - end - - class WeblogController < ApplicationController - # will run the :authenticate filter - end - - class SignupController < ActionController::Base - # will not run the :authenticate filter - skip_before_filter :authenticate - end - -* Added redirect_to :back as a short-hand for redirect_to(request.env["HTTP_REFERER"]) [David Heinemeier Hansson] - -* Change javascript_include_tag :defaults to not use script.aculo.us loader, which facilitates the use of plugins for future script.aculo.us and third party javascript extensions, and provide register_javascript_include_default for plugins to specify additional JavaScript files to load. Removed slider.js and builder.js from actionpack. [Thomas Fuchs] - -* Fix problem where redirecting components can cause an infinite loop [Rick Olson] - -* Added support for the queue option on visual_effect [Thomas Fuchs] - -* Update script.aculo.us to V1.5_rc4 [Thomas Fuchs] - -* Fix that render :text didn't interpolate instance variables #2629, #2626 [Stefan Kaes] - -* Fix line number detection and escape RAILS_ROOT in backtrace Regexp [Nicholas Seckar] - -* Fixed document.getElementsByClassName from Prototype to be speedy again [Sam Stephenson] - -* Recognize ./#{RAILS_ROOT} as RAILS_ROOT in error traces [Nicholas Seckar] - -* Remove ARStore session fingerprinting [Nicholas Seckar] - -* Fix obscure bug in ARStore [Nicholas Seckar] - -* Added TextHelper#strip_tags for removing HTML tags from a string (using HTMLTokenizer) #2229 [marcin@junkheap.net] - -* Added a reader for flash.now, so it's possible to do stuff like flash.now[:alert] ||= 'New if not set' #2422 [Caio Chassot] - - -*1.10.2* (October 26th, 2005) - -* Reset template variables after using render_to_string [Stefan Kaes] - -* Expose the session model backing CGI::Session - -* Abbreviate RAILS_ROOT in traces - - -*1.10.1* (October 19th, 2005) - -* Update error trace templates [Nicholas Seckar] - -* Stop showing generated routing code in application traces [Nicholas Seckar] - - -*1.10.0* (October 16th, 2005) - -* Make string-keys locals assigns optional. Add documentation describing depreciated state [Stefan Kaes] - -* Improve line number detection for template errors [Nicholas Seckar] - -* Update/clean up documentation (rdoc) - -* Upgrade to Prototype 1.4.0_rc0 [Sam Stephenson] - -* Added assert_vaild. Reports the proper AR error messages as fail message when the passed record is invalid [Tobias Lütke] - -* Add temporary support for passing locals to render using string keys [Nicholas Seckar] - -* Clean up error pages by providing better backtraces [Nicholas Seckar] - -* Raise an exception if an attempt is made to insert more session data into the ActiveRecordStore data column than the column can hold. #2234. [justin@textdrive.com] - -* Removed references to assertions.rb from actionpack assert's backtraces. Makes error reports in functional unit tests much less noisy. [Tobias Lütke] - -* Updated and clarified documentation for JavaScriptHelper to be more concise about the various options for including the JavaScript libs. [Thomas Fuchs] - -* Hide "Retry with Breakpoint" button on error pages until feature is functional. [David Heinemeier Hansson] - -* Fix Request#host_with_port to use the standard port when Rails is behind a proxy. [Nicholas Seckar] - -* Escape query strings in the href attribute of URLs created by url_helper. #2333 [Michael Schuerig ] - -* Improved line number reporting for template errors [Nicholas Seckar] - -* Added :locals support for render :inline #2463 [mdabney@cavoksolutions.com] - -* Unset the X-Requested-With header when using the xhr wrapper in functional tests so that future requests aren't accidentally xhr'ed #2352 [me@julik.nl, Sam Stephenson] - -* Unescape paths before writing cache to file system. #1877. [Damien Pollet] - -* Wrap javascript_tag contents in a CDATA section and add a cdata_section method to TagHelper #1691 [Michael Schuerig, Sam Stephenson] - -* Misc doc fixes (typos/grammar/etc). #2445. [coffee2code] - -* Speed improvement for session_options. #2287. [Stefan Kaes] - -* Make cacheing binary files friendly with Windows. #1975. [Rich Olson] - -* Convert boolean form options form the tag_helper. #809. [Michael Schuerig ] - -* Fixed that an instance variable with the same name as a partial should be implicitly passed as the partial :object #2269 [court3nay] - -* Update Prototype to V1.4.0_pre11, script.aculo.us to [2502] [Thomas Fuchs] - -* Make assert_tag :children count appropriately. Closes #2181. [jamie@bravenet.com] - -* Forced newer versions of RedCloth to use hard breaks [David Heinemeier Hansson] - -* Added new scriptaculous options for auto_complete_field #2343 [Manfred Stienstra] - -* Don't prepend the asset host if the string is already a fully-qualified URL - -* Updated to script.aculo.us V1.5.0_rc2 and Prototype to V1.4.0_pre7 [Thomas Fuchs] - -* Undo condition change made in [2345] to prevent normal parameters arriving as StringIO. - -* Tolerate consecutive delimiters in query parameters. #2295 [darashi@gmail.com] - -* Streamline render process, code cleaning. Closes #2294. [skae] - -* Keep flash after components are rendered. #2291 [Rick Olson, Scott] - -* Shorten IE file upload path to filename only to match other browsers. #1507 [court3nay] - -* Fix open/save dialog in IE not opening files send with send_file/send_data, #2279 [Thomas Fuchs] - -* Fixed that auto_discovery_link_tag couldn't take a string as the URL [David Heinemeier Hansson] - -* Fixed problem with send_file and WEBrick using stdout #1812 [David Heinemeier Hansson] - -* Optimized tag_options to not sort keys, which is no longer necessary when assert_dom_equal and friend is available #1995 [skae] - -* Added assert_dom_equal and assert_dom_not_equal to compare tags generated by the helpers in an order-indifferent manner #1995 [skae] - -* Fixed that Request#domain caused an exception if the domain header wasn't set in the original http request #1795 [Michael Koziarski] - -* Make the truncate() helper multi-byte safe (assuming $KCODE has been set to something other than "NONE") #2103 - -* Add routing tests from #1945 [ben@groovie.org] - -* Add a routing test case covering #2101 [Nicholas Seckar] - -* Cache relative_url_root for all webservers, not just Apache #2193 [skae] - -* Speed up cookie use by decreasing string copying #2194 [skae] - -* Fixed access to "Host" header with requests made by crappy old HTTP/1.0 clients #2124 [Marcel Molina Jr.] - -* Added easy assignment of fragment cache store through use of symbols for included stores (old way still works too) - - Before: - ActionController::Base.fragment_cache_store = - ActionController::Base::Caching::Fragments::FileStore.new("/path/to/cache/directory") - - After: - ActionController::Base.fragment_cache_store = :file_store, "/path/to/cache/directory" - -* Added ActionController::Base.session_store=, session_store, and session_options to make it easier to tweak the session options (instead of going straight to ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS) - -* Added TextHelper#cycle to cycle over an array of values on each hit (useful for alternating row colors etc) #2154 [dave-ml@dribin.org] - -* Ensure that request.path never returns nil. Closes #1675 [Nicholas Seckar] - -* Add ability to specify Route Regexps for controllers. Closes #1917. [Sebastian Kanthak] - -* Provide Named Route's hash methods as helper methods. Closes #1744. [Nicholas Seckar, Steve Purcell] - -* Added :multipart option to ActiveRecordHelper#form to make it possible to add file input fields #2034 [jstirk@oobleyboo.com] - -* Moved auto-completion and in-place editing into the Macros module and their helper counterparts into JavaScriptMacrosHelper - -* Added in-place editing support in the spirit of auto complete with ActionController::Base.in_place_edit_for, JavascriptHelper#in_place_editor_field, and Javascript support from script.aculo.us #2038 [Jon Tirsen] - -* Added :disabled option to all data selects that'll make the elements inaccessible for change #2167, #253 [eigentone] - -* Fixed that TextHelper#auto_link_urls would include punctuation in the links #2166, #1671 [eigentone] - -* Fixed that number_to_currency(1000, {:precision => 0})) should return "$1,000", instead of "$1,000." #2122 [sd@notso.net] - -* Allow link_to_remote to use any DOM-element as the parent of the form elements to be submitted #2137 [erik@ruby-lang.nl]. Example: - - - - - <%= link_to_remote 'Save', :update => "row023", - :submit => "row023", :url => {:action => 'save_row'} %> - - -* Fixed that render :partial would fail when :object was a Hash (due to backwards compatibility issues) #2148 [Sam Stephenson] - -* Fixed JavascriptHelper#auto_complete_for to only include unique items #2153 [Thomas Fuchs] - -* Fixed all AssetHelper methods to work with relative paths, such that javascript_include_tag('stdlib/standard') will look in /javascripts/stdlib/standard instead of '/stdlib/standard/' #1963 - -* Avoid extending view instance with helper modules each request. Closes #1979 - -* Performance improvements to CGI methods. Closes #1980 [Stefan Kaes] - -* Added :post option to UrlHelper#link_to that makes it possible to do POST requests through normal ahref links using Javascript - -* Fixed overwrite_params - -* Added ActionController::Base.benchmark and ActionController::Base.silence to allow for easy benchmarking and turning off the log - -* Updated vendor copy of html-scanner to support better xml parsing - -* Added :popup option to UrlHelper#link_to #1996 [gabriel.gironda@gmail.com]. Examples: - - link_to "Help", { :action => "help" }, :popup => true - link_to "Busy loop", { :action => "busy" }, :popup => ['new_window', 'height=300,width=600'] - -* Drop trailing \000 if present on RAW_POST_DATA (works around bug in Safari Ajax implementation) #918 - -* Fix observe_field to fall back to event-based observation if frequency <= 0 #1916 [Michael Schubert] - -* Allow use of the :with option for submit_to_remote #1936 [jon@instance-design.co.uk] - -* AbstractRequest#domain returns nil when host is an ip address #2012 [Kevin Clark] - -* ActionController documentation update #2051 [François Beausoleil] - -* Yield @content_for_ variables to templates #2058 [Sam Stephenson] - -* Make rendering an empty partial collection behave like :nothing => true #2080 [Sam Stephenson] - -* Add option to specify the singular name used by pagination. - -* Use string key to obtain action value. Allows indifferent hashes to be disabled. - -* Added ActionView::Base.cache_template_loading back. - -* Rewrote compiled templates to decrease code complexity. Removed template load caching in favour of compiled caching. Fixed template error messages. [Nicholas Seckar] - -* Fix Routing to handle :some_param => nil better. [Nicholas Seckar, Luminas] - -* Add support for :include with pagination (subject to existing constraints for :include with :limit and :offset) #1478 [Michael Schubert] - -* Prevent the benchmark module from blowing up if a non-HTTP/1.1 request is processed - -* Added :use_short_month option to select_month helper to show month names as abbreviations - -* Make link_to escape the javascript in the confirm option #1964 [nicolas.pouillard@gmail.com] - -* Make assert_redirected_to properly check URL's passed as strings #1910 [Scott Barron] - -* Make sure :layout => false is always used when rendering inside a layout - -* Use raise instead of assert_not_nil in Test::Unit::TestCase#process to ensure that the test variables (controller, request, response) have been set - -* Make sure assigns are built for every request when testing #1866 - -* Allow remote_addr to be queried on TestRequest #1668 - -* Fixed bug when a partial render was passing a local with the same name as the partial - -* Improved performance of test app req/sec with ~10% refactoring the render method #1823 [Stefan Kaes] - -* Improved performance of test app req/sec with 5-30% through a series of Action Pack optimizations #1811 [Stefan Kaes] - -* Changed caching/expiration/hit to report using the DEBUG log level and errors to use the ERROR log level instead of both using INFO - -* Added support for per-action session management #1763 - -* Improved rendering speed on complicated templates by up to 100% (the more complex the templates, the higher the speedup) #1234 [Stefan Kaes]. This did necessasitate a change to the internals of ActionView#render_template that now has four parameters. Developers of custom view handlers (like Amrita) need to update for that. - -* Added options hash as third argument to FormHelper#input, so you can do input('person', 'zip', :size=>10) #1719 [jeremye@bsa.ca.gov] - -* Added Base#expires_in(seconds)/Base#expires_now to control HTTP content cache headers #1755 [Thomas Fuchs] - -* Fixed line number reporting for Builder template errors #1753 [piotr] - -* Fixed assert_routing so that testing controllers in modules works as expected [Nicholas Seckar, Rick Olson] - -* Fixed bug with :success/:failure callbacks for the JavaScriptHelper methods #1730 [court3nay/Thomas Fuchs] - -* Added named_route method to RouteSet instances so that RouteSet instance methods do not prevent certain names from being used. [Nicholas Seckar] - -* Fixed routes so that routes which do not specify :action in the path or in the requirements have a default of :action => 'index', In addition, fixed url generation so that :action => 'index' does not need to be provided for such urls. [Nicholas Seckar, Markjuh] - -* Worked around a Safari bug where it wouldn't pass headers through if the response was zero length by having render :nothing return ' ' instead of '' - -* Fixed Request#subdomains to handle "foo.foo.com" correctly - - -*1.9.1* (11 July, 2005) - -* Fixed that auto_complete_for didn't force the input string to lower case even as the db comparison was - -* Fixed that Action View should always use the included Builder, never attempt to require the gem, to ensure compatibility - -* Added that nil options are not included in tags, so tag("p", :ignore => nil) now returns

    not

    but that tag("p", :ignore => "") still includes it #1465 [Michael Schuerig] - -* Fixed that UrlHelper#link_to_unless/link_to_if used html_escape on the name if no link was to be applied. This is unnecessary and breaks its use with images #1649 [joergd@pobox.com] - -* Improved error message for DoubleRenderError - -* Fixed routing to allow for testing of *path components #1650 [Nicholas Seckar] - -* Added :handle as an option to sortable_element to restrict the drag handle to a given class #1642 [thejohnny] - -* Added a bunch of script.aculo.us features #1644, #1677, #1695 [Thomas Fuchs] - * Effect.ScrollTo, to smoothly scroll the page to an element - * Better Firefox flickering handling on SlideUp/SlideDown - * Removed a possible memory leak in IE with draggables - * Added support for cancelling dragging my hitting ESC - * Added capability to remove draggables/droppables and redeclare sortables in dragdrop.js (this makes it possible to call sortable_element on the same element more than once, e.g. in AJAX returns that modify the sortable element. all current sortable 'stuff' on the element will be discarded and the sortable will be rebuilt) - * Always reset background color on Effect.Highlight; this make change backwards-compatibility, to be sure include style="background-color:(target-color)" on your elements or else elements will fall back to their CSS rules (which is a good thing in most circumstances) - * Removed circular references from element to prevent memory leaks (still not completely gone in IE) - * Changes to class extension in effects.js - * Make Effect.Highlight restore any previously set background color when finishing (makes effect work with CSS classes that set a background color) - * Fixed myriads of memory leaks in IE and Gecko-based browsers [David Zülke] - * Added incremental and local autocompleting and loads of documentation to controls.js [Ivan Krstic] - * Extended the auto_complete_field helper to accept tokens option - * Changed object extension mechanism to favor Object.extend to make script.aculo.us easily adaptable to support 3rd party libs like IE7.js [David Zülke] - -* Fixed that named routes didn't use the default values for action and possible other parameters #1534 [Nicholas Seckar] - -* Fixed JavascriptHelper#visual_effect to use camelize such that :blind_up will work #1639 [pelletierm@eastmedia.net] - -* Fixed that a SessionRestoreError was thrown if a model object was placed in the session that wasn't available to all controllers. This means that it's no longer necessary to use the 'model :post' work-around in ApplicationController to have a Post model in your session. - - -*1.9.0* (6 July, 2005) - -* Added logging of the request URI in the benchmark statement (makes it easy to grep for slow actions) - -* Added javascript_include_tag :defaults shortcut that'll include all the default javascripts included with Action Pack (prototype, effects, controls, dragdrop) - -* Cache several controller variables that are expensive to calculate #1229 [Stefan Kaes] - -* The session class backing CGI::Session::ActiveRecordStore may be replaced with any class that duck-types with a subset of Active Record. See docs for details #1238 [Stefan Kaes] - -* Fixed that hashes was not working properly when passed by GET to lighttpd #849 [Nicholas Seckar] - -* Fixed assert_template nil will be true when no template was rendered #1565 [maceywj@telus.net] - -* Added :prompt option to FormOptions#select (and the users of it, like FormOptions#select_country etc) to create "Please select" style descriptors #1181 [Michael Schuerig] - -* Added JavascriptHelper#update_element_function, which returns a Javascript function (or expression) that'll update a DOM element according to the options passed #933 [mortonda@dgrmm.net]. Examples: - - <%= update_element_function("products", :action => :insert, :position => :bottom, :content => "

    New product!

    ") %> - - <% update_element_function("products", :action => :replace, :binding => binding) do %> -

    Product 1

    -

    Product 2

    - <% end %> - -* Added :field_name option to DateHelper#select_(year|month|day) to deviate from the year/month/day defaults #1266 [Marcel Molina Jr.] - -* Added JavascriptHelper#draggable_element and JavascriptHelper#drop_receiving_element to facilitate easy dragging and dropping through the script.aculo.us libraries #1578 [Thomas Fuchs] - -* Added that UrlHelper#mail_to will now also encode the default link title #749 [f.svehla@gmail.com] - -* Removed the default option of wrap=virtual on FormHelper#text_area to ensure XHTML compatibility #1300 [thomas@columbus.rr.com] - -* Adds the ability to include XML CDATA tags using Builder #1563 [Josh Knowles]. Example: - - xml.cdata! "some text" # => - -* Added evaluation of - # - # javascript_include_tag "xmlhr.js" # => - # - # - # javascript_include_tag "common.javascript", "/elsewhere/cools" # => - # - # - # - # javascript_include_tag "http://www.railsapplication.com/xmlhr" # => - # - # - # javascript_include_tag "http://www.railsapplication.com/xmlhr.js" # => - # - # - # javascript_include_tag :defaults # => - # - # - # ... - # - # - # * = The application.js file is only referenced if it exists - # - # Though it's not really recommended practice, if you need to extend the default JavaScript set for any reason - # (e.g., you're going to be using a certain .js file in every action), then take a look at the register_javascript_include_default method. - # - # You can also include all javascripts in the javascripts directory using :all as the source: - # - # javascript_include_tag :all # => - # - # - # ... - # - # - # - # - # Note that the default javascript files will be included first. So Prototype and Scriptaculous are available to - # all subsequently included files. - # - # If you want Rails to search in all the subdirectories under javascripts, you should explicitly set :recursive: - # - # javascript_include_tag :all, :recursive => true - # - # == Caching multiple javascripts into one - # - # You can also cache multiple javascripts into one file, which requires less HTTP connections to download and can better be - # compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching - # is set to true (which is the case by default for the Rails production environment, but not for the development - # environment). - # - # ==== Examples - # javascript_include_tag :all, :cache => true # when ActionController::Base.perform_caching is false => - # - # - # ... - # - # - # - # - # javascript_include_tag :all, :cache => true # when ActionController::Base.perform_caching is true => - # - # - # javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is false => - # - # - # - # - # javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is true => - # - # - # The :recursive option is also available for caching: - # - # javascript_include_tag :all, :cache => true, :recursive => true - def javascript_include_tag(*sources) - options = sources.extract_options!.stringify_keys - concat = options.delete("concat") - cache = concat || options.delete("cache") - recursive = options.delete("recursive") - - if concat || (ActionController::Base.perform_caching && cache) - joined_javascript_name = (cache == true ? "all" : cache) + ".js" - joined_javascript_path = File.join(joined_javascript_name[/^#{File::SEPARATOR}/] ? ASSETS_DIR : JAVASCRIPTS_DIR, joined_javascript_name) - - unless ActionController::Base.perform_caching && File.exists?(joined_javascript_path) - write_asset_file_contents(joined_javascript_path, compute_javascript_paths(sources, recursive)) - end - javascript_src_tag(joined_javascript_name, options) - else - expand_javascript_sources(sources, recursive).collect { |source| javascript_src_tag(source, options) }.join("\n").html_safe - end - end - - @@javascript_expansions = { :defaults => JAVASCRIPT_DEFAULT_SOURCES.dup } - - # Register one or more javascript files to be included when symbol - # is passed to javascript_include_tag. This method is typically intended - # to be called from plugin initialization to register javascript files - # that the plugin installed in public/javascripts. - # - # ActionView::Helpers::AssetTagHelper.register_javascript_expansion :monkey => ["head", "body", "tail"] - # - # javascript_include_tag :monkey # => - # - # - # - def self.register_javascript_expansion(expansions) - @@javascript_expansions.merge!(expansions) - end - - @@stylesheet_expansions = {} - - # Register one or more stylesheet files to be included when symbol - # is passed to stylesheet_link_tag. This method is typically intended - # to be called from plugin initialization to register stylesheet files - # that the plugin installed in public/stylesheets. - # - # ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :monkey => ["head", "body", "tail"] - # - # stylesheet_link_tag :monkey # => - # - # - # - def self.register_stylesheet_expansion(expansions) - @@stylesheet_expansions.merge!(expansions) - end - - # Register one or more additional JavaScript files to be included when - # javascript_include_tag :defaults is called. This method is - # typically intended to be called from plugin initialization to register additional - # .js files that the plugin installed in public/javascripts. - def self.register_javascript_include_default(*sources) - @@javascript_expansions[:defaults].concat(sources) - end - - def self.reset_javascript_include_default #:nodoc: - @@javascript_expansions[:defaults] = JAVASCRIPT_DEFAULT_SOURCES.dup - end - - # Computes the path to a stylesheet asset in the public stylesheets directory. - # If the +source+ filename has no extension, .css will be appended. - # Full paths from the document root will be passed through. - # Used internally by +stylesheet_link_tag+ to build the stylesheet path. - # - # ==== Examples - # stylesheet_path "style" # => /stylesheets/style.css - # stylesheet_path "dir/style.css" # => /stylesheets/dir/style.css - # stylesheet_path "/dir/style.css" # => /dir/style.css - # stylesheet_path "http://www.railsapplication.com/css/style" # => http://www.railsapplication.com/css/style.css - # stylesheet_path "http://www.railsapplication.com/css/style.js" # => http://www.railsapplication.com/css/style.css - def stylesheet_path(source) - compute_public_path(source, 'stylesheets', 'css') - end - alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route - - # Returns a stylesheet link tag for the sources specified as arguments. If - # you don't specify an extension, .css will be appended automatically. - # You can modify the link attributes by passing a hash as the last argument. - # - # ==== Examples - # stylesheet_link_tag "style" # => - # - # - # stylesheet_link_tag "style.css" # => - # - # - # stylesheet_link_tag "http://www.railsapplication.com/style.css" # => - # - # - # stylesheet_link_tag "style", :media => "all" # => - # - # - # stylesheet_link_tag "style", :media => "print" # => - # - # - # stylesheet_link_tag "random.styles", "/css/stylish" # => - # - # - # - # You can also include all styles in the stylesheets directory using :all as the source: - # - # stylesheet_link_tag :all # => - # - # - # - # - # If you want Rails to search in all the subdirectories under stylesheets, you should explicitly set :recursive: - # - # stylesheet_link_tag :all, :recursive => true - # - # == Caching multiple stylesheets into one - # - # You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be - # compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching - # is set to true (which is the case by default for the Rails production environment, but not for the development - # environment). Examples: - # - # ==== Examples - # stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is false => - # - # - # - # - # stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is true => - # - # - # stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is false => - # - # - # - # - # stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is true => - # - # - # The :recursive option is also available for caching: - # - # stylesheet_link_tag :all, :cache => true, :recursive => true - # - # To force concatenation (even in development mode) set :concat to true. This is useful if - # you have too many stylesheets for IE to load. - # - # stylesheet_link_tag :all, :concat => true - # - def stylesheet_link_tag(*sources) - options = sources.extract_options!.stringify_keys - concat = options.delete("concat") - cache = concat || options.delete("cache") - recursive = options.delete("recursive") - - if concat || (ActionController::Base.perform_caching && cache) - joined_stylesheet_name = (cache == true ? "all" : cache) + ".css" - joined_stylesheet_path = File.join(joined_stylesheet_name[/^#{File::SEPARATOR}/] ? ASSETS_DIR : STYLESHEETS_DIR, joined_stylesheet_name) - - unless ActionController::Base.perform_caching && File.exists?(joined_stylesheet_path) - write_asset_file_contents(joined_stylesheet_path, compute_stylesheet_paths(sources, recursive)) - end - stylesheet_tag(joined_stylesheet_name, options) - else - expand_stylesheet_sources(sources, recursive).collect { |source| stylesheet_tag(source, options) }.join("\n").html_safe - end - end - - # Computes the path to an image asset in the public images directory. - # Full paths from the document root will be passed through. - # Used internally by +image_tag+ to build the image path. - # - # ==== Examples - # image_path("edit") # => /images/edit - # image_path("edit.png") # => /images/edit.png - # image_path("icons/edit.png") # => /images/icons/edit.png - # image_path("/icons/edit.png") # => /icons/edit.png - # image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png - def image_path(source) - compute_public_path(source, 'images') - end - alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route - - # Returns an html image tag for the +source+. The +source+ can be a full - # path or a file that exists in your public images directory. - # - # ==== Options - # You can add HTML attributes using the +options+. The +options+ supports - # three additional keys for convenience and conformance: - # - # * :alt - If no alt text is given, the file name part of the - # +source+ is used (capitalized and without the extension) - # * :size - Supplied as "{Width}x{Height}", so "30x45" becomes - # width="30" and height="45". :size will be ignored if the - # value is not in the correct format. - # * :mouseover - Set an alternate image to be used when the onmouseover - # event is fired, and sets the original image to be replaced onmouseout. - # This can be used to implement an easy image toggle that fires on onmouseover. - # - # ==== Examples - # image_tag("icon") # => - # Icon - # image_tag("icon.png") # => - # Icon - # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # => - # Edit Entry - # image_tag("/icons/icon.gif", :size => "16x16") # => - # Icon - # image_tag("/icons/icon.gif", :height => '32', :width => '32') # => - # Icon - # image_tag("/icons/icon.gif", :class => "menu_icon") # => - # Icon - # image_tag("mouse.png", :mouseover => "/images/mouse_over.png") # => - # Mouse - # image_tag("mouse.png", :mouseover => image_path("mouse_over.png")) # => - # Mouse - def image_tag(source, options = {}) - options.symbolize_keys! - - options[:src] = path_to_image(source) - options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize - - if size = options.delete(:size) - options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$} - end - - if mouseover = options.delete(:mouseover) - options[:onmouseover] = "this.src='#{image_path(mouseover)}'" - options[:onmouseout] = "this.src='#{image_path(options[:src])}'" - end - - tag("img", options) - end - - def self.cache_asset_timestamps - @@cache_asset_timestamps - end - - # You can enable or disable the asset tag timestamps cache. - # With the cache enabled, the asset tag helper methods will make fewer - # expense file system calls. However this prevents you from modifying - # any asset files while the server is running. - # - # ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false - def self.cache_asset_timestamps=(value) - @@cache_asset_timestamps = value - end - - @@cache_asset_timestamps = true - - private - # Add the the extension +ext+ if not present. Return full URLs otherwise untouched. - # Prefix with /dir/ if lacking a leading +/+. Account for relative URL - # roots. Rewrite the asset path for cache-busting asset ids. Include - # asset host, if configured, with the correct request protocol. - def compute_public_path(source, dir, ext = nil, include_host = true) - has_request = @controller.respond_to?(:request) - - source_ext = File.extname(source)[1..-1] - if ext && (source_ext.blank? || (ext != source_ext && File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}")))) - source += ".#{ext}" - end - - unless source =~ %r{^[-a-z]+://} - source = "/#{dir}/#{source}" unless source[0] == ?/ - - source = rewrite_asset_path(source) - - if has_request && include_host - unless source =~ %r{^#{ActionController::Base.relative_url_root}/} - source = "#{ActionController::Base.relative_url_root}#{source}" - end - end - end - - if include_host && source !~ %r{^[-a-z]+://} - host = compute_asset_host(source) - - if has_request && !host.blank? && host !~ %r{^[-a-z]+://} - host = "#{@controller.request.protocol}#{host}" - end - - "#{host}#{source}" - else - source - end - end - - # Pick an asset host for this source. Returns +nil+ if no host is set, - # the host if no wildcard is set, the host interpolated with the - # numbers 0-3 if it contains %d (the number is the source hash mod 4), - # or the value returned from invoking the proc if it's a proc or the value from - # invoking call if it's an object responding to call. - def compute_asset_host(source) - if host = ActionController::Base.asset_host - if host.is_a?(Proc) || host.respond_to?(:call) - case host.is_a?(Proc) ? host.arity : host.method(:call).arity - when 2 - request = @controller.respond_to?(:request) && @controller.request - host.call(source, request) - else - host.call(source) - end - else - (host =~ /%d/) ? host % (source.hash % 4) : host - end - end - end - - @@asset_timestamps_cache = {} - @@asset_timestamps_cache_guard = Mutex.new - - # Use the RAILS_ASSET_ID environment variable or the source's - # modification time as its cache-busting asset id. - def rails_asset_id(source) - if asset_id = ENV["RAILS_ASSET_ID"] - asset_id - else - if @@cache_asset_timestamps && (asset_id = @@asset_timestamps_cache[source]) - asset_id - else - path = File.join(ASSETS_DIR, source) - asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : '' - - if @@cache_asset_timestamps - @@asset_timestamps_cache_guard.synchronize do - @@asset_timestamps_cache[source] = asset_id - end - end - - asset_id - end - end - end - - # Break out the asset path rewrite in case plugins wish to put the asset id - # someplace other than the query string. - def rewrite_asset_path(source) - asset_id = rails_asset_id(source) - if asset_id.blank? - source - else - source + "?#{asset_id}" - end - end - - def javascript_src_tag(source, options) - content_tag("script", "", { "type" => Mime::JS, "src" => path_to_javascript(source) }.merge(options)) - end - - def stylesheet_tag(source, options) - tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => html_escape(path_to_stylesheet(source)) }.merge(options), false, false) - end - - def compute_javascript_paths(*args) - expand_javascript_sources(*args).collect { |source| compute_public_path(source, 'javascripts', 'js', false) } - end - - def compute_stylesheet_paths(*args) - expand_stylesheet_sources(*args).collect { |source| compute_public_path(source, 'stylesheets', 'css', false) } - end - - def expand_javascript_sources(sources, recursive = false) - if sources.include?(:all) - all_javascript_files = collect_asset_files(JAVASCRIPTS_DIR, ('**' if recursive), '*.js') - ((determine_source(:defaults, @@javascript_expansions).dup & all_javascript_files) + all_javascript_files).uniq - else - expanded_sources = sources.collect do |source| - determine_source(source, @@javascript_expansions) - end.flatten - expanded_sources << "application" if sources.include?(:defaults) && File.exist?(File.join(JAVASCRIPTS_DIR, "application.js")) - expanded_sources - end - end - - def expand_stylesheet_sources(sources, recursive) - if sources.first == :all - collect_asset_files(STYLESHEETS_DIR, ('**' if recursive), '*.css') - else - sources.collect do |source| - determine_source(source, @@stylesheet_expansions) - end.flatten - end - end - - def determine_source(source, collection) - case source - when Symbol - collection[source] || raise(ArgumentError, "No expansion found for #{source.inspect}") - else - source - end - end - - def join_asset_file_contents(paths) - paths.collect { |path| File.read(asset_file_path(path)) }.join("\n\n") - end - - def write_asset_file_contents(joined_asset_path, asset_paths) - FileUtils.mkdir_p(File.dirname(joined_asset_path)) - File.open(joined_asset_path, "w+") { |cache| cache.write(join_asset_file_contents(asset_paths)) } - - # Set mtime to the latest of the combined files to allow for - # consistent ETag without a shared filesystem. - mt = asset_paths.map { |p| File.mtime(asset_file_path(p)) }.max - File.utime(mt, mt, joined_asset_path) - end - - def asset_file_path(path) - File.join(ASSETS_DIR, path.split('?').first) - end - - def collect_asset_files(*path) - dir = path.first - - Dir[File.join(*path.compact)].collect do |file| - file[-(file.size - dir.size - 1)..-1].sub(/\.\w+$/, '') - end.sort - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb deleted file mode 100644 index 9951e11a..00000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +++ /dev/null @@ -1,198 +0,0 @@ -require 'set' - -# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other -# template languages). -module ActionView - module Helpers #:nodoc: - module AtomFeedHelper - # Full usage example: - # - # config/routes.rb: - # ActionController::Routing::Routes.draw do |map| - # map.resources :posts - # map.root :controller => "posts" - # end - # - # app/controllers/posts_controller.rb: - # class PostsController < ApplicationController::Base - # # GET /posts.html - # # GET /posts.atom - # def index - # @posts = Post.find(:all) - # - # respond_to do |format| - # format.html - # format.atom - # end - # end - # end - # - # app/views/posts/index.atom.builder: - # atom_feed do |feed| - # feed.title("My great blog!") - # feed.updated(@posts.first.created_at) - # - # for post in @posts - # feed.entry(post) do |entry| - # entry.title(post.title) - # entry.content(post.body, :type => 'html') - # - # entry.author do |author| - # author.name("DHH") - # end - # end - # end - # end - # - # The options for atom_feed are: - # - # * :language: Defaults to "en-US". - # * :root_url: The HTML alternative that this feed is doubling for. Defaults to / on the current host. - # * :url: The URL for this feed. Defaults to the current URL. - # * :id: The id for this feed. Defaults to "tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}" - # * :schema_date: The date at which the tag scheme for the feed was first used. A good default is the year you - # created the feed. See http://feedvalidator.org/docs/error/InvalidTAG.html for more information. If not specified, - # 2005 is used (as an "I don't care" value). - # * :instruct: Hash of XML processing instructions in the form {target => {attribute => value, }} or {target => [{attribute => value, }, ]} - # - # Other namespaces can be added to the root element: - # - # app/views/posts/index.atom.builder: - # atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', - # 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| - # feed.title("My great blog!") - # feed.updated((@posts.first.created_at)) - # feed.tag!(openSearch:totalResults, 10) - # - # for post in @posts - # feed.entry(post) do |entry| - # entry.title(post.title) - # entry.content(post.body, :type => 'html') - # entry.tag!('app:edited', Time.now) - # - # entry.author do |author| - # author.name("DHH") - # end - # end - # end - # end - # - # The Atom spec defines five elements (content rights title subtitle - # summary) which may directly contain xhtml content if :type => 'xhtml' - # is specified as an attribute. If so, this helper will take care of - # the enclosing div and xhtml namespace declaration. Example usage: - # - # entry.summary :type => 'xhtml' do |xhtml| - # xhtml.p pluralize(order.line_items.count, "line item") - # xhtml.p "Shipped to #{order.address}" - # xhtml.p "Paid by #{order.pay_type}" - # end - # - # - # atom_feed yields an AtomFeedBuilder instance. Nested elements yield - # an AtomBuilder instance. - def atom_feed(options = {}, &block) - if options[:schema_date] - options[:schema_date] = options[:schema_date].strftime("%Y-%m-%d") if options[:schema_date].respond_to?(:strftime) - else - options[:schema_date] = "2005" # The Atom spec copyright date - end - - xml = options.delete(:xml) || eval("xml", block.binding) - xml.instruct! - if options[:instruct] - options[:instruct].each do |target,attrs| - if attrs.respond_to?(:keys) - xml.instruct!(target, attrs) - elsif attrs.respond_to?(:each) - attrs.each { |attr_group| xml.instruct!(target, attr_group) } - end - end - end - - feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom'} - feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)} - - xml.feed(feed_opts) do - xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}") - xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:root_url] || (request.protocol + request.host_with_port)) - xml.link(:rel => 'self', :type => 'application/atom+xml', :href => options[:url] || request.url) - - yield AtomFeedBuilder.new(xml, self, options) - end - end - - class AtomBuilder - XHTML_TAG_NAMES = %w(content rights title subtitle summary).to_set - - def initialize(xml) - @xml = xml - end - - private - # Delegate to xml builder, first wrapping the element in a xhtml - # namespaced div element if the method and arguments indicate - # that an xhtml_block? is desired. - def method_missing(method, *arguments, &block) - if xhtml_block?(method, arguments) - @xml.__send__(method, *arguments) do - @xml.div(:xmlns => 'http://www.w3.org/1999/xhtml') do |xhtml| - block.call(xhtml) - end - end - else - @xml.__send__(method, *arguments, &block) - end - end - - # True if the method name matches one of the five elements defined - # in the Atom spec as potentially containing XHTML content and - # if :type => 'xhtml' is, in fact, specified. - def xhtml_block?(method, arguments) - if XHTML_TAG_NAMES.include?(method.to_s) - last = arguments.last - last.is_a?(Hash) && last[:type].to_s == 'xhtml' - end - end - end - - class AtomFeedBuilder < AtomBuilder - def initialize(xml, view, feed_options = {}) - @xml, @view, @feed_options = xml, view, feed_options - end - - # Accepts a Date or Time object and inserts it in the proper format. If nil is passed, current time in UTC is used. - def updated(date_or_time = nil) - @xml.updated((date_or_time || Time.now.utc).xmlschema) - end - - # Creates an entry tag for a specific record and prefills the id using class and id. - # - # Options: - # - # * :published: Time first published. Defaults to the created_at attribute on the record if one such exists. - # * :updated: Time of update. Defaults to the updated_at attribute on the record if one such exists. - # * :url: The URL for this entry. Defaults to the polymorphic_url for the record. - # * :id: The ID for this entry. Defaults to "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}" - def entry(record, options = {}) - @xml.entry do - @xml.id(options[:id] || "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}") - - if options[:published] || (record.respond_to?(:created_at) && record.created_at) - @xml.published((options[:published] || record.created_at).xmlschema) - end - - if options[:updated] || (record.respond_to?(:updated_at) && record.updated_at) - @xml.updated((options[:updated] || record.updated_at).xmlschema) - end - - @xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record)) - - yield AtomBuilder.new(@xml) - end - end - end - - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb deleted file mode 100644 index 61c2cecb..00000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'benchmark' - -module ActionView - module Helpers - # This helper offers a method to measure the execution time of a block - # in a template. - module BenchmarkHelper - # Allows you to measure the execution time of a block - # in a template and records the result to the log. Wrap this block around - # expensive operations or possible bottlenecks to get a time reading - # for the operation. For example, let's say you thought your file - # processing method was taking too long; you could wrap it in a benchmark block. - # - # <% benchmark "Process data files" do %> - # <%= expensive_files_operation %> - # <% end %> - # - # That would add something like "Process data files (345.2ms)" to the log, - # which you can then use to compare timings when optimizing your code. - # - # You may give an optional logger level as the :level option. - # (:debug, :info, :warn, :error); the default value is :info. - # - # <% benchmark "Low-level files", :level => :debug do %> - # <%= lowlevel_files_operation %> - # <% end %> - # - # Finally, you can pass true as the third argument to silence all log activity - # inside the block. This is great for boiling down a noisy block to just a single statement: - # - # <% benchmark "Process data files", :level => :info, :silence => true do %> - # <%= expensive_and_chatty_files_operation %> - # <% end %> - def benchmark(message = "Benchmarking", options = {}) - if controller.logger - if options.is_a?(Symbol) - ActiveSupport::Deprecation.warn("use benchmark('#{message}', :level => :#{options}) instead", caller) - options = { :level => options, :silence => false } - else - options.assert_valid_keys(:level, :silence) - options[:level] ||= :info - end - - result = nil - ms = Benchmark.ms { result = options[:silence] ? controller.logger.silence { yield } : yield } - controller.logger.send(options[:level], '%s (%.1fms)' % [ message, ms ]) - result - else - yield - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb deleted file mode 100644 index 64d1ad27..00000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb +++ /dev/null @@ -1,39 +0,0 @@ -module ActionView - module Helpers - # This helper to exposes a method for caching of view fragments. - # See ActionController::Caching::Fragments for usage instructions. - module CacheHelper - # A method for caching fragments of a view rather than an entire - # action or page. This technique is useful caching pieces like - # menus, lists of news topics, static HTML fragments, and so on. - # This method takes a block that contains the content you wish - # to cache. See ActionController::Caching::Fragments for more - # information. - # - # ==== Examples - # If you wanted to cache a navigation menu, you could do the - # following. - # - # <% cache do %> - # <%= render :partial => "menu" %> - # <% end %> - # - # You can also cache static content... - # - # <% cache do %> - #

    Hello users! Welcome to our website!

    - # <% end %> - # - # ...and static content mixed with RHTML content. - # - # <% cache do %> - # Topics: - # <%= render :partial => "topics", :collection => @topic_list %> - # Topics listed alphabetically - # <% end %> - def cache(name = {}, options = nil, &block) - @controller.fragment_for(output_buffer, name, options, &block) - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb deleted file mode 100644 index bf265905..00000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb +++ /dev/null @@ -1,136 +0,0 @@ -module ActionView - module Helpers - # CaptureHelper exposes methods to let you extract generated markup which - # can be used in other parts of a template or layout file. - # It provides a method to capture blocks into variables through capture and - # a way to capture a block of markup for use in a layout through content_for. - module CaptureHelper - # The capture method allows you to extract part of a template into a - # variable. You can then use this variable anywhere in your templates or layout. - # - # ==== Examples - # The capture method can be used in ERb templates... - # - # <% @greeting = capture do %> - # Welcome to my shiny new web page! The date and time is - # <%= Time.now %> - # <% end %> - # - # ...and Builder (RXML) templates. - # - # @timestamp = capture do - # "The current timestamp is #{Time.now}." - # end - # - # You can then use that variable anywhere else. For example: - # - # - # <%= @greeting %> - # - # <%= @greeting %> - # - # - def capture(*args, &block) - # Return captured buffer in erb. - if block_called_from_erb?(block) - with_output_buffer { block.call(*args) } - else - # Return block result otherwise, but protect buffer also. - with_output_buffer { return block.call(*args) } - end - end - - # Calling content_for stores a block of markup in an identifier for later use. - # You can make subsequent calls to the stored content in other templates or the layout - # by passing the identifier as an argument to yield. - # - # ==== Examples - # - # <% content_for :not_authorized do %> - # alert('You are not authorized to do that!') - # <% end %> - # - # You can then use yield :not_authorized anywhere in your templates. - # - # <%= yield :not_authorized if current_user.nil? %> - # - # You can also use this syntax alongside an existing call to yield in a layout. For example: - # - # <%# This is the layout %> - # - # - # My Website - # <%= yield :script %> - # - # - # <%= yield %> - # - # - # - # And now, we'll create a view that has a content_for call that - # creates the script identifier. - # - # <%# This is our view %> - # Please login! - # - # <% content_for :script do %> - # - # <% end %> - # - # Then, in another view, you could to do something like this: - # - # <%= link_to_remote 'Logout', :action => 'logout' %> - # - # <% content_for :script do %> - # <%= javascript_include_tag :defaults %> - # <% end %> - # - # That will place - # - # +html_options+ may be a hash of attributes for the - # - # Instead of passing the content as an argument, you can also use a block - # in which case, you pass your +html_options+ as the first parameter. - # <% javascript_tag :defer => 'defer' do -%> - # alert('All is good') - # <% end -%> - def javascript_tag(content_or_options_with_block = nil, html_options = {}, &block) - content = - if block_given? - html_options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) - capture(&block) - else - content_or_options_with_block - end - - tag = content_tag(:script, javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) - - if block_called_from_erb?(block) - concat(tag) - else - tag - end - end - - def javascript_cdata_section(content) #:nodoc: - "\n//#{cdata_section("\n#{content}\n//")}\n".html_safe - end - - protected - def options_for_javascript(options) - if options.empty? - '{}' - else - "{#{options.keys.map { |k| "#{k}:#{options[k]}" }.sort.join(', ')}}" - end - end - - def array_or_string_for_javascript(option) - if option.kind_of?(Array) - "['#{option.join('\',\'')}']" - elsif !option.nil? - "'#{option}'" - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb deleted file mode 100644 index 4c0f5776..00000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +++ /dev/null @@ -1,308 +0,0 @@ -module ActionView - module Helpers #:nodoc: - # Provides methods for converting numbers into formatted strings. - # Methods are provided for phone numbers, currency, percentage, - # precision, positional notation, and file size. - module NumberHelper - # Formats a +number+ into a US phone number (e.g., (555) 123-9876). You can customize the format - # in the +options+ hash. - # - # ==== Options - # * :area_code - Adds parentheses around the area code. - # * :delimiter - Specifies the delimiter to use (defaults to "-"). - # * :extension - Specifies an extension to add to the end of the - # generated number. - # * :country_code - Sets the country code for the phone number. - # - # ==== Examples - # number_to_phone(5551234) # => 555-1234 - # number_to_phone(1235551234) # => 123-555-1234 - # number_to_phone(1235551234, :area_code => true) # => (123) 555-1234 - # number_to_phone(1235551234, :delimiter => " ") # => 123 555 1234 - # number_to_phone(1235551234, :area_code => true, :extension => 555) # => (123) 555-1234 x 555 - # number_to_phone(1235551234, :country_code => 1) # => +1-123-555-1234 - # - # number_to_phone(1235551234, :country_code => 1, :extension => 1343, :delimiter => ".") - # => +1.123.555.1234 x 1343 - def number_to_phone(number, options = {}) - number = number.to_s.strip unless number.nil? - options = options.symbolize_keys - area_code = options[:area_code] || nil - delimiter = options[:delimiter] || "-" - extension = options[:extension].to_s.strip || nil - country_code = options[:country_code] || nil - - begin - str = "" - str << "+#{country_code}#{delimiter}" unless country_code.blank? - str << if area_code - number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4}$)/,"(\\1) \\2#{delimiter}\\3") - else - number.gsub!(/([0-9]{0,3})([0-9]{3})([0-9]{4})$/,"\\1#{delimiter}\\2#{delimiter}\\3") - number.starts_with?('-') ? number.slice!(1..-1) : number - end - str << " x #{extension}" unless extension.blank? - str - rescue - number - end - end - - # Formats a +number+ into a currency string (e.g., $13.65). You can customize the format - # in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 2). - # * :unit - Sets the denomination of the currency (defaults to "$"). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ","). - # * :format - Sets the format of the output string (defaults to "%u%n"). The field types are: - # - # %u The currency unit - # %n The number - # - # ==== Examples - # number_to_currency(1234567890.50) # => $1,234,567,890.50 - # number_to_currency(1234567890.506) # => $1,234,567,890.51 - # number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506 - # - # number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "") - # # => £1234567890,50 - # number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u") - # # => 1234567890,50 £ - def number_to_currency(number, options = {}) - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - currency = I18n.translate(:'number.currency.format', :locale => options[:locale], :raise => true) rescue {} - defaults = defaults.merge(currency) - - precision = options[:precision] || defaults[:precision] - unit = options[:unit] || defaults[:unit] - separator = options[:separator] || defaults[:separator] - delimiter = options[:delimiter] || defaults[:delimiter] - format = options[:format] || defaults[:format] - separator = '' if precision == 0 - - begin - format.gsub(/%n/, number_with_precision(number, - :precision => precision, - :delimiter => delimiter, - :separator => separator) - ).gsub(/%u/, unit).html_safe - rescue - number - end - end - - # Formats a +number+ as a percentage string (e.g., 65%). You can customize the - # format in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 3). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ""). - # - # ==== Examples - # number_to_percentage(100) # => 100.000% - # number_to_percentage(100, :precision => 0) # => 100% - # number_to_percentage(1000, :delimiter => '.', :separator => ',') # => 1.000,000% - # number_to_percentage(302.24398923423, :precision => 5) # => 302.24399% - def number_to_percentage(number, options = {}) - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - percentage = I18n.translate(:'number.percentage.format', :locale => options[:locale], :raise => true) rescue {} - defaults = defaults.merge(percentage) - - precision = options[:precision] || defaults[:precision] - separator = options[:separator] || defaults[:separator] - delimiter = options[:delimiter] || defaults[:delimiter] - - begin - number_with_precision(number, - :precision => precision, - :separator => separator, - :delimiter => delimiter) + "%" - rescue - number - end - end - - # Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324). You can - # customize the format in the +options+ hash. - # - # ==== Options - # * :delimiter - Sets the thousands delimiter (defaults to ","). - # * :separator - Sets the separator between the units (defaults to "."). - # - # ==== Examples - # number_with_delimiter(12345678) # => 12,345,678 - # number_with_delimiter(12345678.05) # => 12,345,678.05 - # number_with_delimiter(12345678, :delimiter => ".") # => 12.345.678 - # number_with_delimiter(12345678, :separator => ",") # => 12,345,678 - # number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",") - # # => 98 765 432,98 - # - # You can still use number_with_delimiter with the old API that accepts the - # +delimiter+ as its optional second and the +separator+ as its - # optional third parameter: - # number_with_delimiter(12345678, " ") # => 12 345.678 - # number_with_delimiter(12345678.05, ".", ",") # => 12.345.678,05 - def number_with_delimiter(number, *args) - options = args.extract_options! - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - - unless args.empty? - ActiveSupport::Deprecation.warn('number_with_delimiter takes an option hash ' + - 'instead of separate delimiter and precision arguments.', caller) - delimiter = args[0] || defaults[:delimiter] - separator = args[1] || defaults[:separator] - end - - delimiter ||= (options[:delimiter] || defaults[:delimiter]) - separator ||= (options[:separator] || defaults[:separator]) - - begin - parts = number.to_s.split('.') - parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}") - parts.join(separator) - rescue - number - end - end - - # Formats a +number+ with the specified level of :precision (e.g., 112.32 has a precision of 2). - # You can customize the format in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 3). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ""). - # - # ==== Examples - # number_with_precision(111.2345) # => 111.235 - # number_with_precision(111.2345, :precision => 2) # => 111.23 - # number_with_precision(13, :precision => 5) # => 13.00000 - # number_with_precision(389.32314, :precision => 0) # => 389 - # number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.') - # # => 1.111,23 - # - # You can still use number_with_precision with the old API that accepts the - # +precision+ as its optional second parameter: - # number_with_precision(number_with_precision(111.2345, 2) # => 111.23 - def number_with_precision(number, *args) - options = args.extract_options! - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale], - :raise => true) rescue {} - defaults = defaults.merge(precision_defaults) - - unless args.empty? - ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' + - 'instead of a separate precision argument.', caller) - precision = args[0] || defaults[:precision] - end - - precision ||= (options[:precision] || defaults[:precision]) - separator ||= (options[:separator] || defaults[:separator]) - delimiter ||= (options[:delimiter] || defaults[:delimiter]) - - begin - rounded_number = (Float(number) * (10 ** precision)).round.to_f / 10 ** precision - number_with_delimiter("%01.#{precision}f" % rounded_number, - :separator => separator, - :delimiter => delimiter) - rescue - number - end - end - - STORAGE_UNITS = [:byte, :kb, :mb, :gb, :tb].freeze - - # Formats the bytes in +size+ into a more understandable representation - # (e.g., giving it 1500 yields 1.5 KB). This method is useful for - # reporting file sizes to users. This method returns nil if - # +size+ cannot be converted into a number. You can customize the - # format in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 1). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ""). - # - # ==== Examples - # number_to_human_size(123) # => 123 Bytes - # number_to_human_size(1234) # => 1.2 KB - # number_to_human_size(12345) # => 12.1 KB - # number_to_human_size(1234567) # => 1.2 MB - # number_to_human_size(1234567890) # => 1.1 GB - # number_to_human_size(1234567890123) # => 1.1 TB - # number_to_human_size(1234567, :precision => 2) # => 1.18 MB - # number_to_human_size(483989, :precision => 0) # => 473 KB - # number_to_human_size(1234567, :precision => 2, :separator => ',') # => 1,18 MB - # - # Zeros after the decimal point are always stripped out, regardless of the - # specified precision: - # helper.number_to_human_size(1234567890123, :precision => 5) # => "1.12283 TB" - # helper.number_to_human_size(524288000, :precision=>5) # => "500 MB" - # - # You can still use number_to_human_size with the old API that accepts the - # +precision+ as its optional second parameter: - # number_to_human_size(1234567, 2) # => 1.18 MB - # number_to_human_size(483989, 0) # => 473 KB - def number_to_human_size(number, *args) - return nil if number.nil? - - options = args.extract_options! - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - human = I18n.translate(:'number.human.format', :locale => options[:locale], :raise => true) rescue {} - defaults = defaults.merge(human) - - unless args.empty? - ActiveSupport::Deprecation.warn('number_to_human_size takes an option hash ' + - 'instead of a separate precision argument.', caller) - precision = args[0] || defaults[:precision] - end - - precision ||= (options[:precision] || defaults[:precision]) - separator ||= (options[:separator] || defaults[:separator]) - delimiter ||= (options[:delimiter] || defaults[:delimiter]) - - storage_units_format = I18n.translate(:'number.human.storage_units.format', :locale => options[:locale], :raise => true) - - if number.to_i < 1024 - unit = I18n.translate(:'number.human.storage_units.units.byte', :locale => options[:locale], :count => number.to_i, :raise => true) - storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, unit) - else - max_exp = STORAGE_UNITS.size - 1 - number = Float(number) - exponent = (Math.log(number) / Math.log(1024)).to_i # Convert to base 1024 - exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit - number /= 1024 ** exponent - - unit_key = STORAGE_UNITS[exponent] - unit = I18n.translate(:"number.human.storage_units.units.#{unit_key}", :locale => options[:locale], :count => number, :raise => true) - - begin - escaped_separator = Regexp.escape(separator) - formatted_number = number_with_precision(number, - :precision => precision, - :separator => separator, - :delimiter => delimiter - ).sub(/(#{escaped_separator})(\d*[1-9])?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '') - storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit) - rescue - number - end - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb deleted file mode 100644 index 3b3278fb..00000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +++ /dev/null @@ -1,1305 +0,0 @@ -require 'set' -require 'active_support/json' - -module ActionView - module Helpers - # Prototype[http://www.prototypejs.org/] is a JavaScript library that provides - # DOM[http://en.wikipedia.org/wiki/Document_Object_Model] manipulation, - # Ajax[http://www.adaptivepath.com/publications/essays/archives/000385.php] - # functionality, and more traditional object-oriented facilities for JavaScript. - # This module provides a set of helpers to make it more convenient to call - # functions from Prototype using Rails, including functionality to call remote - # Rails methods (that is, making a background request to a Rails action) using Ajax. - # This means that you can call actions in your controllers without - # reloading the page, but still update certain parts of it using - # injections into the DOM. A common use case is having a form that adds - # a new element to a list without reloading the page or updating a shopping - # cart total when a new item is added. - # - # == Usage - # To be able to use these helpers, you must first include the Prototype - # JavaScript framework in your pages. - # - # javascript_include_tag 'prototype' - # - # (See the documentation for - # ActionView::Helpers::JavaScriptHelper for more information on including - # this and other JavaScript files in your Rails templates.) - # - # Now you're ready to call a remote action either through a link... - # - # link_to_remote "Add to cart", - # :url => { :action => "add", :id => product.id }, - # :update => { :success => "cart", :failure => "error" } - # - # ...through a form... - # - # <% form_remote_tag :url => '/shipping' do -%> - #
    <%= submit_tag 'Recalculate Shipping' %>
    - # <% end -%> - # - # ...periodically... - # - # periodically_call_remote(:url => 'update', :frequency => '5', :update => 'ticker') - # - # ...or through an observer (i.e., a form or field that is observed and calls a remote - # action when changed). - # - # <%= observe_field(:searchbox, - # :url => { :action => :live_search }), - # :frequency => 0.5, - # :update => :hits, - # :with => 'query' - # %> - # - # As you can see, there are numerous ways to use Prototype's Ajax functions (and actually more than - # are listed here); check out the documentation for each method to find out more about its usage and options. - # - # === Common Options - # See link_to_remote for documentation of options common to all Ajax - # helpers; any of the options specified by link_to_remote can be used - # by the other helpers. - # - # == Designing your Rails actions for Ajax - # When building your action handlers (that is, the Rails actions that receive your background requests), it's - # important to remember a few things. First, whatever your action would normally return to the browser, it will - # return to the Ajax call. As such, you typically don't want to render with a layout. This call will cause - # the layout to be transmitted back to your page, and, if you have a full HTML/CSS, will likely mess a lot of things up. - # You can turn the layout off on particular actions by doing the following: - # - # class SiteController < ActionController::Base - # layout "standard", :except => [:ajax_method, :more_ajax, :another_ajax] - # end - # - # Optionally, you could do this in the method you wish to lack a layout: - # - # render :layout => false - # - # You can tell the type of request from within your action using the request.xhr? (XmlHttpRequest, the - # method that Ajax uses to make background requests) method. - # def name - # # Is this an XmlHttpRequest request? - # if (request.xhr?) - # render :text => @name.to_s - # else - # # No? Then render an action. - # render :action => 'view_attribute', :attr => @name - # end - # end - # - # The else clause can be left off and the current action will render with full layout and template. An extension - # to this solution was posted to Ryan Heneise's blog at ArtOfMission["http://www.artofmission.com/"]. - # - # layout proc{ |c| c.request.xhr? ? false : "application" } - # - # Dropping this in your ApplicationController turns the layout off for every request that is an "xhr" request. - # - # If you are just returning a little data or don't want to build a template for your output, you may opt to simply - # render text output, like this: - # - # render :text => 'Return this from my method!' - # - # Since whatever the method returns is injected into the DOM, this will simply inject some text (or HTML, if you - # tell it to). This is usually how small updates, such updating a cart total or a file count, are handled. - # - # == Updating multiple elements - # See JavaScriptGenerator for information on updating multiple elements - # on the page in an Ajax response. - module PrototypeHelper - unless const_defined? :CALLBACKS - CALLBACKS = Set.new([ :create, :uninitialized, :loading, :loaded, - :interactive, :complete, :failure, :success ] + - (100..599).to_a) - AJAX_OPTIONS = Set.new([ :before, :after, :condition, :url, - :asynchronous, :method, :insertion, :position, - :form, :with, :update, :script, :type ]).merge(CALLBACKS) - end - - # Returns a link to a remote action defined by options[:url] - # (using the url_for format) that's called in the background using - # XMLHttpRequest. The result of that request can then be inserted into a - # DOM object whose id can be specified with options[:update]. - # Usually, the result would be a partial prepared by the controller with - # render :partial. - # - # Examples: - # # Generates:
    Delete this post - # link_to_remote "Delete this post", :update => "posts", - # :url => { :action => "destroy", :id => post.id } - # - # # Generates: Refresh - # link_to_remote(image_tag("refresh"), :update => "emails", - # :url => { :action => "list_emails" }) - # - # You can override the generated HTML options by specifying a hash in - # options[:html]. - # - # link_to_remote "Delete this post", :update => "posts", - # :url => post_url(@post), :method => :delete, - # :html => { :class => "destructive" } - # - # You can also specify a hash for options[:update] to allow for - # easy redirection of output to an other DOM element if a server-side - # error occurs: - # - # Example: - # # Generates: Delete this post - # link_to_remote "Delete this post", - # :url => { :action => "destroy", :id => post.id }, - # :update => { :success => "posts", :failure => "error" } - # - # Optionally, you can use the options[:position] parameter to - # influence how the target DOM element is updated. It must be one of - # :before, :top, :bottom, or :after. - # - # The method used is by default POST. You can also specify GET or you - # can simulate PUT or DELETE over POST. All specified with options[:method] - # - # Example: - # # Generates: Destroy - # link_to_remote "Destroy", :url => person_url(:id => person), :method => :delete - # - # By default, these remote requests are processed asynchronous during - # which various JavaScript callbacks can be triggered (for progress - # indicators and the likes). All callbacks get access to the - # request object, which holds the underlying XMLHttpRequest. - # - # To access the server response, use request.responseText, to - # find out the HTTP status, use request.status. - # - # Example: - # # Generates: hello - # word = 'hello' - # link_to_remote word, - # :url => { :action => "undo", :n => word_counter }, - # :complete => "undoRequestCompleted(request)" - # - # The callbacks that may be specified are (in order): - # - # :loading:: Called when the remote document is being - # loaded with data by the browser. - # :loaded:: Called when the browser has finished loading - # the remote document. - # :interactive:: Called when the user can interact with the - # remote document, even though it has not - # finished loading. - # :success:: Called when the XMLHttpRequest is completed, - # and the HTTP status code is in the 2XX range. - # :failure:: Called when the XMLHttpRequest is completed, - # and the HTTP status code is not in the 2XX - # range. - # :complete:: Called when the XMLHttpRequest is complete - # (fires after success/failure if they are - # present). - # - # You can further refine :success and :failure by - # adding additional callbacks for specific status codes. - # - # Example: - # # Generates: hello - # link_to_remote word, - # :url => { :action => "action" }, - # 404 => "alert('Not found...? Wrong URL...?')", - # :failure => "alert('HTTP Error ' + request.status + '!')" - # - # A status code callback overrides the success/failure handlers if - # present. - # - # If you for some reason or another need synchronous processing (that'll - # block the browser while the request is happening), you can specify - # options[:type] = :synchronous. - # - # You can customize further browser side call logic by passing in - # JavaScript code snippets via some optional parameters. In their order - # of use these are: - # - # :confirm:: Adds confirmation dialog. - # :condition:: Perform remote request conditionally - # by this expression. Use this to - # describe browser-side conditions when - # request should not be initiated. - # :before:: Called before request is initiated. - # :after:: Called immediately after request was - # initiated and before :loading. - # :submit:: Specifies the DOM element ID that's used - # as the parent of the form elements. By - # default this is the current form, but - # it could just as well be the ID of a - # table row or any other DOM element. - # :with:: A JavaScript expression specifying - # the parameters for the XMLHttpRequest. - # Any expressions should return a valid - # URL query string. - # - # Example: - # - # :with => "'name=' + $('name').value" - # - # You can generate a link that uses AJAX in the general case, while - # degrading gracefully to plain link behavior in the absence of - # JavaScript by setting html_options[:href] to an alternate URL. - # Note the extra curly braces around the options hash separate - # it as the second parameter from html_options, the third. - # - # Example: - # link_to_remote "Delete this post", - # { :update => "posts", :url => { :action => "destroy", :id => post.id } }, - # :href => url_for(:action => "destroy", :id => post.id) - def link_to_remote(name, options = {}, html_options = nil) - link_to_function(name, remote_function(options), html_options || options.delete(:html)) - end - - # Creates a button with an onclick event which calls a remote action - # via XMLHttpRequest - # The options for specifying the target with :url - # and defining callbacks is the same as link_to_remote. - def button_to_remote(name, options = {}, html_options = {}) - button_to_function(name, remote_function(options), html_options) - end - - # Periodically calls the specified url (options[:url]) every - # options[:frequency] seconds (default is 10). Usually used to - # update a specified div (options[:update]) with the results - # of the remote call. The options for specifying the target with :url - # and defining callbacks is the same as link_to_remote. - # Examples: - # # Call get_averages and put its results in 'avg' every 10 seconds - # # Generates: - # # new PeriodicalExecuter(function() {new Ajax.Updater('avg', '/grades/get_averages', - # # {asynchronous:true, evalScripts:true})}, 10) - # periodically_call_remote(:url => { :action => 'get_averages' }, :update => 'avg') - # - # # Call invoice every 10 seconds with the id of the customer - # # If it succeeds, update the invoice DIV; if it fails, update the error DIV - # # Generates: - # # new PeriodicalExecuter(function() {new Ajax.Updater({success:'invoice',failure:'error'}, - # # '/testing/invoice/16', {asynchronous:true, evalScripts:true})}, 10) - # periodically_call_remote(:url => { :action => 'invoice', :id => customer.id }, - # :update => { :success => "invoice", :failure => "error" } - # - # # Call update every 20 seconds and update the new_block DIV - # # Generates: - # # new PeriodicalExecuter(function() {new Ajax.Updater('news_block', 'update', {asynchronous:true, evalScripts:true})}, 20) - # periodically_call_remote(:url => 'update', :frequency => '20', :update => 'news_block') - # - def periodically_call_remote(options = {}) - frequency = options[:frequency] || 10 # every ten seconds by default - code = "new PeriodicalExecuter(function() {#{remote_function(options)}}, #{frequency})" - javascript_tag(code) - end - - # Returns a form tag that will submit using XMLHttpRequest in the - # background instead of the regular reloading POST arrangement. Even - # though it's using JavaScript to serialize the form elements, the form - # submission will work just like a regular submission as viewed by the - # receiving side (all elements available in params). The options for - # specifying the target with :url and defining callbacks is the same as - # +link_to_remote+. - # - # A "fall-through" target for browsers that doesn't do JavaScript can be - # specified with the :action/:method options on :html. - # - # Example: - # # Generates: - # #
    - # form_remote_tag :html => { :action => - # url_for(:controller => "some", :action => "place") } - # - # The Hash passed to the :html key is equivalent to the options (2nd) - # argument in the FormTagHelper.form_tag method. - # - # By default the fall-through action is the same as the one specified in - # the :url (and the default method is :post). - # - # form_remote_tag also takes a block, like form_tag: - # # Generates: - # #
    - # #
    - # <% form_remote_tag :url => '/posts' do -%> - #
    <%= submit_tag 'Save' %>
    - # <% end -%> - def form_remote_tag(options = {}, &block) - options[:form] = true - - options[:html] ||= {} - options[:html][:onsubmit] = - (options[:html][:onsubmit] ? options[:html][:onsubmit] + "; " : "") + - "#{remote_function(options)}; return false;" - - form_tag(options[:html].delete(:action) || url_for(options[:url]), options[:html], &block) - end - - # Creates a form that will submit using XMLHttpRequest in the background - # instead of the regular reloading POST arrangement and a scope around a - # specific resource that is used as a base for questioning about - # values for the fields. - # - # === Resource - # - # Example: - # <% remote_form_for(@post) do |f| %> - # ... - # <% end %> - # - # This will expand to be the same as: - # - # <% remote_form_for :post, @post, :url => post_path(@post), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %> - # ... - # <% end %> - # - # === Nested Resource - # - # Example: - # <% remote_form_for([@post, @comment]) do |f| %> - # ... - # <% end %> - # - # This will expand to be the same as: - # - # <% remote_form_for :comment, @comment, :url => post_comment_path(@post, @comment), :html => { :method => :put, :class => "edit_comment", :id => "edit_comment_45" } do |f| %> - # ... - # <% end %> - # - # If you don't need to attach a form to a resource, then check out form_remote_tag. - # - # See FormHelper#form_for for additional semantics. - def remote_form_for(record_or_name_or_array, *args, &proc) - options = args.extract_options! - - case record_or_name_or_array - when String, Symbol - object_name = record_or_name_or_array - when Array - object = record_or_name_or_array.last - object_name = ActionController::RecordIdentifier.singular_class_name(object) - apply_form_for_options!(record_or_name_or_array, options) - args.unshift object - else - object = record_or_name_or_array - object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name_or_array) - apply_form_for_options!(object, options) - args.unshift object - end - - concat(form_remote_tag(options)) - fields_for(object_name, *(args << options), &proc) - concat(''.html_safe) - end - alias_method :form_remote_for, :remote_form_for - - # Returns a button input tag with the element name of +name+ and a value (i.e., display text) of +value+ - # that will submit form using XMLHttpRequest in the background instead of a regular POST request that - # reloads the page. - # - # # Create a button that submits to the create action - # # - # # Generates: - # <%= submit_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %> - # - # # Submit to the remote action update and update the DIV succeed or fail based - # # on the success or failure of the request - # # - # # Generates: - # <%= submit_to_remote 'update_btn', 'Update', :url => { :action => 'update' }, - # :update => { :success => "succeed", :failure => "fail" } - # - # options argument is the same as in form_remote_tag. - def submit_to_remote(name, value, options = {}) - options[:with] ||= 'Form.serialize(this.form)' - - html_options = options.delete(:html) || {} - html_options[:name] = name - - button_to_remote(value, options, html_options) - end - - # Returns 'eval(request.responseText)' which is the JavaScript function - # that +form_remote_tag+ can call in :complete to evaluate a multiple - # update return document using +update_element_function+ calls. - def evaluate_remote_response - "eval(request.responseText)" - end - - # Returns the JavaScript needed for a remote function. - # Takes the same arguments as link_to_remote. - # - # Example: - # # Generates: { :action => :update_options }) %>"> - # - # - # - def remote_function(options) - javascript_options = options_for_ajax(options) - - update = '' - if options[:update] && options[:update].is_a?(Hash) - update = [] - update << "success:'#{options[:update][:success]}'" if options[:update][:success] - update << "failure:'#{options[:update][:failure]}'" if options[:update][:failure] - update = '{' + update.join(',') + '}' - elsif options[:update] - update << "'#{options[:update]}'" - end - - function = update.empty? ? - "new Ajax.Request(" : - "new Ajax.Updater(#{update}, " - - url_options = options[:url] - url_options = url_options.merge(:escape => false) if url_options.is_a?(Hash) - function << "'#{escape_javascript(url_for(url_options))}'" - function << ", #{javascript_options})" - - function = "#{options[:before]}; #{function}" if options[:before] - function = "#{function}; #{options[:after]}" if options[:after] - function = "if (#{options[:condition]}) { #{function}; }" if options[:condition] - function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if options[:confirm] - - return function - end - - # Observes the field with the DOM ID specified by +field_id+ and calls a - # callback when its contents have changed. The default callback is an - # Ajax call. By default the value of the observed field is sent as a - # parameter with the Ajax call. - # - # Example: - # # Generates: new Form.Element.Observer('suggest', 0.25, function(element, value) {new Ajax.Updater('suggest', - # # '/testing/find_suggestion', {asynchronous:true, evalScripts:true, parameters:'q=' + value})}) - # <%= observe_field :suggest, :url => { :action => :find_suggestion }, - # :frequency => 0.25, - # :update => :suggest, - # :with => 'q' - # %> - # - # Required +options+ are either of: - # :url:: +url_for+-style options for the action to call - # when the field has changed. - # :function:: Instead of making a remote call to a URL, you - # can specify javascript code to be called instead. - # Note that the value of this option is used as the - # *body* of the javascript function, a function definition - # with parameters named element and value will be generated for you - # for example: - # observe_field("glass", :frequency => 1, :function => "alert('Element changed')") - # will generate: - # new Form.Element.Observer('glass', 1, function(element, value) {alert('Element changed')}) - # The element parameter is the DOM element being observed, and the value is its value at the - # time the observer is triggered. - # - # Additional options are: - # :frequency:: The frequency (in seconds) at which changes to - # this field will be detected. Not setting this - # option at all or to a value equal to or less than - # zero will use event based observation instead of - # time based observation. - # :update:: Specifies the DOM ID of the element whose - # innerHTML should be updated with the - # XMLHttpRequest response text. - # :with:: A JavaScript expression specifying the parameters - # for the XMLHttpRequest. The default is to send the - # key and value of the observed field. Any custom - # expressions should return a valid URL query string. - # The value of the field is stored in the JavaScript - # variable +value+. - # - # Examples - # - # :with => "'my_custom_key=' + value" - # :with => "'person[name]=' + prompt('New name')" - # :with => "Form.Element.serialize('other-field')" - # - # Finally - # :with => 'name' - # is shorthand for - # :with => "'name=' + value" - # This essentially just changes the key of the parameter. - # - # Additionally, you may specify any of the options documented in the - # Common options section at the top of this document. - # - # Example: - # - # # Sends params: {:title => 'Title of the book'} when the book_title input - # # field is changed. - # observe_field 'book_title', - # :url => 'http://example.com/books/edit/1', - # :with => 'title' - # - # - def observe_field(field_id, options = {}) - if options[:frequency] && options[:frequency] > 0 - build_observer('Form.Element.Observer', field_id, options) - else - build_observer('Form.Element.EventObserver', field_id, options) - end - end - - # Observes the form with the DOM ID specified by +form_id+ and calls a - # callback when its contents have changed. The default callback is an - # Ajax call. By default all fields of the observed field are sent as - # parameters with the Ajax call. - # - # The +options+ for +observe_form+ are the same as the options for - # +observe_field+. The JavaScript variable +value+ available to the - # :with option is set to the serialized form by default. - def observe_form(form_id, options = {}) - if options[:frequency] - build_observer('Form.Observer', form_id, options) - else - build_observer('Form.EventObserver', form_id, options) - end - end - - # All the methods were moved to GeneratorMethods so that - # #include_helpers_from_context has nothing to overwrite. - class JavaScriptGenerator #:nodoc: - def initialize(context, &block) #:nodoc: - @context, @lines = context, [] - include_helpers_from_context - @context.with_output_buffer(@lines) do - @context.instance_exec(self, &block) - end - end - - private - def include_helpers_from_context - extend @context.helpers if @context.respond_to?(:helpers) - extend GeneratorMethods - end - - # JavaScriptGenerator generates blocks of JavaScript code that allow you - # to change the content and presentation of multiple DOM elements. Use - # this in your Ajax response bodies, either in a - # - # mail_to "me@domain.com", "My email", :encode => "hex" - # # => My email - # - # mail_to "me@domain.com", nil, :replace_at => "_at_", :replace_dot => "_dot_", :class => "email" - # # => - # - # mail_to "me@domain.com", "My email", :cc => "ccaddress@domain.com", - # :subject => "This is an example email" - # # => My email - def mail_to(email_address, name = nil, html_options = {}) - html_options = html_options.stringify_keys - encode = html_options.delete("encode").to_s - cc, bcc, subject, body = html_options.delete("cc"), html_options.delete("bcc"), html_options.delete("subject"), html_options.delete("body") - - string = '' - extras = '' - extras << "cc=#{CGI.escape(cc).gsub("+", "%20")}&" unless cc.nil? - extras << "bcc=#{CGI.escape(bcc).gsub("+", "%20")}&" unless bcc.nil? - extras << "body=#{CGI.escape(body).gsub("+", "%20")}&" unless body.nil? - extras << "subject=#{CGI.escape(subject).gsub("+", "%20")}&" unless subject.nil? - extras = "?" << extras.gsub!(/&?$/,"") unless extras.empty? - - email_address_obfuscated = html_escape(email_address) - email_address_obfuscated.gsub!(/@/, html_options.delete("replace_at")) if html_options.has_key?("replace_at") - email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot") - - if encode == "javascript" - html = content_tag("a", name || email_address_obfuscated.html_safe, html_options.merge({ "href" => "mailto:"+html_escape(email_address)+extras })) - "document.write('#{escape_javascript(html)}');".each_byte do |c| - string << sprintf("%%%x", c) - end - "" - elsif encode == "hex" - email_address_encoded = '' - email_address_obfuscated.each_byte do |c| - email_address_encoded << sprintf("&#%d;", c) - end - - protocol = 'mailto:' - protocol.each_byte { |c| string << sprintf("&#%d;", c) } - - email_address.each_byte do |c| - char = c.chr - string << (char =~ /\w/ ? sprintf("%%%x", c) : char) - end - content_tag "a", name || email_address_encoded.html_safe, html_options.merge({ "href" => "#{string}#{extras}" }) - else - content_tag "a", name || email_address_obfuscated.html_safe, html_options.merge({ "href" => "mailto:#{email_address}#{extras}" }) - end - end - - # True if the current request URI was generated by the given +options+. - # - # ==== Examples - # Let's say we're in the /shop/checkout?order=desc action. - # - # current_page?(:action => 'process') - # # => false - # - # current_page?(:controller => 'shop', :action => 'checkout') - # # => true - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'asc') - # # => false - # - # current_page?(:action => 'checkout') - # # => true - # - # current_page?(:controller => 'library', :action => 'checkout') - # # => false - # - # Let's say we're in the /shop/checkout?order=desc&page=1 action. - # - # current_page?(:action => 'process') - # # => false - # - # current_page?(:controller => 'shop', :action => 'checkout') - # # => true - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'desc', :page=>'1') - # # => true - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'desc', :page=>'2') - # # => false - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'desc') - # # => false - # - # current_page?(:action => 'checkout') - # # => true - # - # current_page?(:controller => 'library', :action => 'checkout') - # # => false - def current_page?(options) - url_string = CGI.unescapeHTML(url_for(options)) - request = @controller.request - # We ignore any extra parameters in the request_uri if the - # submitted url doesn't have any either. This lets the function - # work with things like ?order=asc - if url_string.index("?") - request_uri = request.request_uri - else - request_uri = request.request_uri.split('?').first - end - if url_string =~ /^\w+:\/\// - url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" - else - url_string == request_uri - end - end - - private - def convert_options_to_javascript!(html_options, url = '') - confirm, popup = html_options.delete("confirm"), html_options.delete("popup") - - method, href = html_options.delete("method"), html_options['href'] - - html_options["onclick"] = case - when popup && method - raise ActionView::ActionViewError, "You can't use :popup and :method in the same link" - when confirm && popup - "if (#{confirm_javascript_function(confirm)}) { #{popup_javascript_function(popup)} };return false;" - when confirm && method - "if (#{confirm_javascript_function(confirm)}) { #{method_javascript_function(method, url, href)} };return false;" - when confirm - "return #{confirm_javascript_function(confirm)};" - when method - "#{method_javascript_function(method, url, href)}return false;" - when popup - "#{popup_javascript_function(popup)}return false;" - else - html_options["onclick"] - end - end - - def confirm_javascript_function(confirm) - "confirm('#{escape_javascript(confirm)}')" - end - - def popup_javascript_function(popup) - popup.is_a?(Array) ? "window.open(this.href,'#{popup.first}','#{popup.last}');" : "window.open(this.href);" - end - - def method_javascript_function(method, url = '', href = nil) - action = (href && url.size > 0) ? "'#{url}'" : 'this.href' - submit_function = - "var f = document.createElement('form'); f.style.display = 'none'; " + - "this.parentNode.appendChild(f); f.method = 'POST'; f.action = #{action};" - - unless method == :post - submit_function << "var m = document.createElement('input'); m.setAttribute('type', 'hidden'); " - submit_function << "m.setAttribute('name', '_method'); m.setAttribute('value', '#{method}'); f.appendChild(m);" - end - - if protect_against_forgery? - submit_function << "var s = document.createElement('input'); s.setAttribute('type', 'hidden'); " - submit_function << "s.setAttribute('name', '#{request_forgery_protection_token}'); s.setAttribute('value', '#{escape_javascript form_authenticity_token}'); f.appendChild(s);" - end - submit_function << "f.submit();" - end - - # Processes the _html_options_ hash, converting the boolean - # attributes from true/false form into the form required by - # HTML/XHTML. (An attribute is considered to be boolean if - # its name is listed in the given _bool_attrs_ array.) - # - # More specifically, for each boolean attribute in _html_options_ - # given as: - # - # "attr" => bool_value - # - # if the associated _bool_value_ evaluates to true, it is - # replaced with the attribute's name; otherwise the attribute is - # removed from the _html_options_ hash. (See the XHTML 1.0 spec, - # section 4.5 "Attribute Minimization" for more: - # http://www.w3.org/TR/xhtml1/#h-4.5) - # - # Returns the updated _html_options_ hash, which is also modified - # in place. - # - # Example: - # - # convert_boolean_attributes!( html_options, - # %w( checked disabled readonly ) ) - def convert_boolean_attributes!(html_options, bool_attrs) - bool_attrs.each { |x| html_options[x] = x if html_options.delete(x) } - html_options - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/inline_template.rb b/vendor/rails/actionpack/lib/action_view/inline_template.rb deleted file mode 100644 index 54efa543..00000000 --- a/vendor/rails/actionpack/lib/action_view/inline_template.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActionView #:nodoc: - class InlineTemplate #:nodoc: - include Renderable - - attr_reader :source, :extension, :method_segment - - def initialize(source, type = nil) - @source = source - @extension = type - @method_segment = "inline_#{@source.hash.abs}" - end - - private - # Always recompile inline templates - def recompile? - true - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/locale/en.yml b/vendor/rails/actionpack/lib/action_view/locale/en.yml deleted file mode 100644 index b56869ed..00000000 --- a/vendor/rails/actionpack/lib/action_view/locale/en.yml +++ /dev/null @@ -1,117 +0,0 @@ -"en": - number: - # Used in number_with_delimiter() - # These are also the defaults for 'currency', 'percentage', 'precision', and 'human' - format: - # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5) - separator: "." - # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three) - delimiter: "," - # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00) - precision: 3 - - # Used in number_to_currency() - currency: - format: - # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00) - format: "%u%n" - unit: "$" - # These three are to override number.format and are optional - separator: "." - delimiter: "," - precision: 2 - - # Used in number_to_percentage() - percentage: - format: - # These three are to override number.format and are optional - # separator: - delimiter: "" - # precision: - - # Used in number_to_precision() - precision: - format: - # These three are to override number.format and are optional - # separator: - delimiter: "" - # precision: - - # Used in number_to_human_size() - human: - format: - # These three are to override number.format and are optional - # separator: - delimiter: "" - precision: 1 - storage_units: - # Storage units output formatting. - # %u is the storage unit, %n is the number (default: 2 MB) - format: "%n %u" - units: - byte: - one: "Byte" - other: "Bytes" - kb: "KB" - mb: "MB" - gb: "GB" - tb: "TB" - - # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words() - datetime: - distance_in_words: - half_a_minute: "half a minute" - less_than_x_seconds: - one: "less than 1 second" - other: "less than %{count} seconds" - x_seconds: - one: "1 second" - other: "%{count} seconds" - less_than_x_minutes: - one: "less than a minute" - other: "less than %{count} minutes" - x_minutes: - one: "1 minute" - other: "%{count} minutes" - about_x_hours: - one: "about 1 hour" - other: "about %{count} hours" - x_days: - one: "1 day" - other: "%{count} days" - about_x_months: - one: "about 1 month" - other: "about %{count} months" - x_months: - one: "1 month" - other: "%{count} months" - about_x_years: - one: "about 1 year" - other: "about %{count} years" - over_x_years: - one: "over 1 year" - other: "over %{count} years" - almost_x_years: - one: "almost 1 year" - other: "almost %{count} years" - prompts: - year: "Year" - month: "Month" - day: "Day" - hour: "Hour" - minute: "Minute" - second: "Seconds" - - activerecord: - errors: - template: - header: - one: "1 error prohibited this %{model} from being saved" - other: "%{count} errors prohibited this %{model} from being saved" - # The variable :count is also available - body: "There were problems with the following fields:" - - support: - select: - # default value for :prompt => true in FormOptionsHelper - prompt: "Please select" diff --git a/vendor/rails/actionpack/lib/action_view/partials.rb b/vendor/rails/actionpack/lib/action_view/partials.rb deleted file mode 100644 index 3aeebc67..00000000 --- a/vendor/rails/actionpack/lib/action_view/partials.rb +++ /dev/null @@ -1,241 +0,0 @@ -module ActionView - # There's also a convenience method for rendering sub templates within the current controller that depends on a - # single object (we call this kind of sub templates for partials). It relies on the fact that partials should - # follow the naming convention of being prefixed with an underscore -- as to separate them from regular - # templates that could be rendered on their own. - # - # In a template for Advertiser#account: - # - # <%= render :partial => "account" %> - # - # This would render "advertiser/_account.erb" and pass the instance variable @account in as a local variable - # +account+ to the template for display. - # - # In another template for Advertiser#buy, we could have: - # - # <%= render :partial => "account", :locals => { :account => @buyer } %> - # - # <% for ad in @advertisements %> - # <%= render :partial => "ad", :locals => { :ad => ad } %> - # <% end %> - # - # This would first render "advertiser/_account.erb" with @buyer passed in as the local variable +account+, then - # render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. - # - # == Rendering a collection of partials - # - # The example of partial use describes a familiar pattern where a template needs to iterate over an array and - # render a sub template for each of the elements. This pattern has been implemented as a single method that - # accepts an array and renders a partial by the same name as the elements contained within. So the three-lined - # example in "Using partials" can be rewritten with a single line: - # - # <%= render :partial => "ad", :collection => @advertisements %> - # - # This will render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. An - # iteration counter will automatically be made available to the template with a name of the form - # +partial_name_counter+. In the case of the example above, the template would be fed +ad_counter+. - # - # NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also - # just keep domain objects, like Active Records, in there. - # - # == Rendering shared partials - # - # Two controllers can share a set of partials and render them like this: - # - # <%= render :partial => "advertisement/ad", :locals => { :ad => @advertisement } %> - # - # This will render the partial "advertisement/_ad.erb" regardless of which controller this is being called from. - # - # == Rendering objects with the RecordIdentifier - # - # Instead of explicitly naming the location of a partial, you can also let the RecordIdentifier do the work if - # you're following its conventions for RecordIdentifier#partial_path. Examples: - # - # # @account is an Account instance, so it uses the RecordIdentifier to replace - # # <%= render :partial => "accounts/account", :locals => { :account => @buyer } %> - # <%= render :partial => @account %> - # - # # @posts is an array of Post instances, so it uses the RecordIdentifier to replace - # # <%= render :partial => "posts/post", :collection => @posts %> - # <%= render :partial => @posts %> - # - # == Rendering the default case - # - # If you're not going to be using any of the options like collections or layouts, you can also use the short-hand - # defaults of render to render partials. Examples: - # - # # Instead of <%= render :partial => "account" %> - # <%= render "account" %> - # - # # Instead of <%= render :partial => "account", :locals => { :account => @buyer } %> - # <%= render "account", :account => @buyer %> - # - # # @account is an Account instance, so it uses the RecordIdentifier to replace - # # <%= render :partial => "accounts/account", :locals => { :account => @account } %> - # <%= render(@account) %> - # - # # @posts is an array of Post instances, so it uses the RecordIdentifier to replace - # # <%= render :partial => "posts/post", :collection => @posts %> - # <%= render(@posts) %> - # - # == Rendering partials with layouts - # - # Partials can have their own layouts applied to them. These layouts are different than the ones that are - # specified globally for the entire action, but they work in a similar fashion. Imagine a list with two types - # of users: - # - # <%# app/views/users/index.html.erb &> - # Here's the administrator: - # <%= render :partial => "user", :layout => "administrator", :locals => { :user => administrator } %> - # - # Here's the editor: - # <%= render :partial => "user", :layout => "editor", :locals => { :user => editor } %> - # - # <%# app/views/users/_user.html.erb &> - # Name: <%= user.name %> - # - # <%# app/views/users/_administrator.html.erb &> - #
    - # Budget: $<%= user.budget %> - # <%= yield %> - #
    - # - # <%# app/views/users/_editor.html.erb &> - #
    - # Deadline: <%= user.deadline %> - # <%= yield %> - #
    - # - # ...this will return: - # - # Here's the administrator: - #
    - # Budget: $<%= user.budget %> - # Name: <%= user.name %> - #
    - # - # Here's the editor: - #
    - # Deadline: <%= user.deadline %> - # Name: <%= user.name %> - #
    - # - # You can also apply a layout to a block within any template: - # - # <%# app/views/users/_chief.html.erb &> - # <% render(:layout => "administrator", :locals => { :user => chief }) do %> - # Title: <%= chief.title %> - # <% end %> - # - # ...this will return: - # - #
    - # Budget: $<%= user.budget %> - # Title: <%= chief.name %> - #
    - # - # As you can see, the :locals hash is shared between both the partial and its layout. - # - # If you pass arguments to "yield" then this will be passed to the block. One way to use this is to pass - # an array to layout and treat it as an enumerable. - # - # <%# app/views/users/_user.html.erb &> - #
    - # Budget: $<%= user.budget %> - # <%= yield user %> - #
    - # - # <%# app/views/users/index.html.erb &> - # <% render :layout => @users do |user| %> - # Title: <%= user.title %> - # <% end %> - # - # This will render the layout for each user and yield to the block, passing the user, each time. - # - # You can also yield multiple times in one layout and use block arguments to differentiate the sections. - # - # <%# app/views/users/_user.html.erb &> - #
    - # <%= yield user, :header %> - # Budget: $<%= user.budget %> - # <%= yield user, :footer %> - #
    - # - # <%# app/views/users/index.html.erb &> - # <% render :layout => @users do |user, section| %> - # <%- case section when :header -%> - # Title: <%= user.title %> - # <%- when :footer -%> - # Deadline: <%= user.deadline %> - # <%- end -%> - # <% end %> - module Partials - extend ActiveSupport::Memoizable - - private - def render_partial(options = {}) #:nodoc: - local_assigns = options[:locals] || {} - - case partial_path = options[:partial] - when String, Symbol, NilClass - if options.has_key?(:collection) - render_partial_collection(options) - else - _pick_partial_template(partial_path).render_partial(self, options[:object], local_assigns) - end - when ActionView::Helpers::FormBuilder - builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '') - local_assigns.merge!(builder_partial_path.to_sym => partial_path) - render_partial(:partial => builder_partial_path, :object => options[:object], :locals => local_assigns) - else - if Array === partial_path || - (defined?(ActiveRecord) && - (ActiveRecord::Associations::AssociationCollection === partial_path || - ActiveRecord::NamedScope::Scope === partial_path)) - render_partial_collection(options.except(:partial).merge(:collection => partial_path)) - else - object = partial_path - render_partial( - :partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path), - :object => object, - :locals => local_assigns - ) - end - end - end - - def render_partial_collection(options = {}) #:nodoc: - return nil if options[:collection].blank? - - partial = options[:partial] - spacer = options[:spacer_template] ? render(:partial => options[:spacer_template]) : '' - local_assigns = options[:locals] ? options[:locals].clone : {} - as = options[:as] - - index = 0 - options[:collection].map do |object| - _partial_path ||= partial || - ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path) - template = _pick_partial_template(_partial_path) - local_assigns[template.counter_name] = index - local_assigns["#{as.to_s}_counter".to_sym] = local_assigns[template.counter_name] if as - result = template.render_partial(self, object, local_assigns.dup, as) - index += 1 - result - end.join(spacer).html_safe - end - - def _pick_partial_template(partial_path) #:nodoc: - if partial_path.include?('/') - path = File.join(File.dirname(partial_path), "_#{File.basename(partial_path)}") - elsif controller - path = "#{controller.class.controller_path}/_#{partial_path}" - else - path = "_#{partial_path}" - end - - self.view_paths.find_template(path, self.template_format) - end - memoize :_pick_partial_template - end -end diff --git a/vendor/rails/actionpack/lib/action_view/paths.rb b/vendor/rails/actionpack/lib/action_view/paths.rb deleted file mode 100644 index 9c1a2bdb..00000000 --- a/vendor/rails/actionpack/lib/action_view/paths.rb +++ /dev/null @@ -1,77 +0,0 @@ -module ActionView #:nodoc: - class PathSet < Array #:nodoc: - def self.type_cast(obj) - if obj.is_a?(String) - if Base.cache_template_loading? - Template::EagerPath.new(obj.to_s) - else - ReloadableTemplate::ReloadablePath.new(obj.to_s) - end - else - obj - end - end - - def initialize(*args) - super(*args).map! { |obj| self.class.type_cast(obj) } - end - - def <<(obj) - super(self.class.type_cast(obj)) - end - - def concat(array) - super(array.map! { |obj| self.class.type_cast(obj) }) - end - - def insert(index, obj) - super(index, self.class.type_cast(obj)) - end - - def push(*objs) - super(*objs.map { |obj| self.class.type_cast(obj) }) - end - - def unshift(*objs) - super(*objs.map { |obj| self.class.type_cast(obj) }) - end - - def load! - each(&:load!) - end - - def find_template(original_template_path, format = nil, html_fallback = true) - return original_template_path if original_template_path.respond_to?(:render) - template_path = original_template_path.sub(/^\//, '') - - each do |load_path| - if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"]) - return template - # Try the default locale version if the current locale doesn't have one - # (i.e. you haven't translated this view to German yet, but you have the English version on hand) - elsif format && (template = load_path["#{template_path}.#{I18n.default_locale}.#{format}"]) - return template - elsif format && (template = load_path["#{template_path}.#{format}"]) - return template - elsif template = load_path["#{template_path}.#{I18n.locale}"] - return template - elsif template = load_path["#{template_path}.#{I18n.default_locale}"] - return template - elsif template = load_path[template_path] - return template - # Try to find html version if the format is javascript - elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.locale}.html"] - return template - elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.default_locale}.html"] - return template - elsif format == :js && html_fallback && template = load_path["#{template_path}.html"] - return template - end - end - - return Template.new(original_template_path) if File.file?(original_template_path) - - raise MissingTemplate.new(self, original_template_path, format) - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/reloadable_template.rb b/vendor/rails/actionpack/lib/action_view/reloadable_template.rb deleted file mode 100644 index 5ef833d7..00000000 --- a/vendor/rails/actionpack/lib/action_view/reloadable_template.rb +++ /dev/null @@ -1,117 +0,0 @@ -module ActionView #:nodoc: - class ReloadableTemplate < Template - - class TemplateDeleted < ActionView::ActionViewError - end - - class ReloadablePath < Template::Path - - def initialize(path) - super - @paths = {} - new_request! - end - - def new_request! - @disk_cache = {} - end - alias_method :load!, :new_request! - - def [](path) - if found_template = @paths[path] - begin - found_template.reset_cache_if_stale! - rescue TemplateDeleted - unregister_template(found_template) - self[path] - end - else - load_all_templates_from_dir(templates_dir_from_path(path)) - # don't ever hand out a template without running a stale check - (new_template = @paths[path]) && new_template.reset_cache_if_stale! - end - end - - private - def register_template_from_file(template_full_file_path) - if !@paths[relative_path = relative_path_for_template_file(template_full_file_path)] && File.file?(template_full_file_path) - register_template(ReloadableTemplate.new(relative_path, self)) - end - end - - def register_template(template) - template.accessible_paths.each do |path| - @paths[path] = template - end - end - - # remove (probably deleted) template from cache - def unregister_template(template) - template.accessible_paths.each do |template_path| - @paths.delete(template_path) if @paths[template_path] == template - end - # fill in any newly created gaps - @paths.values.uniq.each do |template| - template.accessible_paths.each {|path| @paths[path] ||= template} - end - end - - # load all templates from the directory of the requested template - def load_all_templates_from_dir(dir) - # hit disk only once per template-dir/request - @disk_cache[dir] ||= template_files_from_dir(dir).each {|template_file| register_template_from_file(template_file)} - end - - def templates_dir_from_path(path) - dirname = File.dirname(path) - File.join(@path, dirname == '.' ? '' : dirname) - end - - # get all the template filenames from the dir - def template_files_from_dir(dir) - Dir.glob(File.join(dir, '*')) - end - end - - module Unfreezable - def freeze; self; end - end - - def initialize(*args) - super - - # we don't ever want to get frozen - extend Unfreezable - end - - def mtime - File.mtime(filename) - end - - attr_accessor :previously_last_modified - - def stale? - previously_last_modified.nil? || previously_last_modified < mtime - rescue Errno::ENOENT => e - undef_my_compiled_methods! - raise TemplateDeleted - end - - def reset_cache_if_stale! - if stale? - flush_cache 'source', 'compiled_source' - undef_my_compiled_methods! - @previously_last_modified = mtime - end - self - end - - # remove any compiled methods that look like they might belong to me - def undef_my_compiled_methods! - ActionView::Base::CompiledTemplates.public_instance_methods.grep(/#{Regexp.escape(method_name_without_locals)}(?:_locals_)?/).each do |m| - ActionView::Base::CompiledTemplates.send(:remove_method, m) - end - end - - end -end diff --git a/vendor/rails/actionpack/lib/action_view/renderable.rb b/vendor/rails/actionpack/lib/action_view/renderable.rb deleted file mode 100644 index a7f87ee0..00000000 --- a/vendor/rails/actionpack/lib/action_view/renderable.rb +++ /dev/null @@ -1,109 +0,0 @@ -# encoding: utf-8 - -module ActionView - # NOTE: The template that this mixin is being included into is frozen - # so you cannot set or modify any instance variables - module Renderable #:nodoc: - extend ActiveSupport::Memoizable - - def filename - 'compiled-template' - end - - def handler - Template.handler_class_for_extension(extension) - end - memoize :handler - - def compiled_source - handler.call(self) - end - - def method_name_without_locals - ['_run', extension, method_segment].compact.join('_') - end - memoize :method_name_without_locals - - def render(view, local_assigns = {}) - compile(local_assigns) - - view.with_template self do - view.send(:_evaluate_assigns_and_ivars) - view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type) - - view.send(method_name(local_assigns), local_assigns) do |*names| - ivar = :@_proc_for_layout - if !view.instance_variable_defined?(:"@content_for_#{names.first}") && view.instance_variable_defined?(ivar) && (proc = view.instance_variable_get(ivar)) - view.capture(*names, &proc) - elsif view.instance_variable_defined?(ivar = :"@content_for_#{names.first || :layout}") - view.instance_variable_get(ivar) - end - end - end - end - - def method_name(local_assigns) - if local_assigns && local_assigns.any? - method_name = method_name_without_locals.dup - method_name << "_locals_#{local_assigns.keys.map { |k| k.to_s }.sort.join('_')}" - else - method_name = method_name_without_locals - end - method_name.to_sym - end - - private - # Compile and evaluate the template's code (if necessary) - def compile(local_assigns) - render_symbol = method_name(local_assigns) - - if !Base::CompiledTemplates.method_defined?(render_symbol) || recompile? - compile!(render_symbol, local_assigns) - end - end - - def compile!(render_symbol, local_assigns) - locals_code = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join - - code = compiled_source - if code.sub!(/\A(#.*coding.*)\n/, '') - encoding_comment = $1 - elsif defined?(Encoding) && Encoding.respond_to?(:default_external) - encoding_comment = "#coding:#{Encoding.default_external}" - end - - source = <<-end_src - def #{render_symbol}(local_assigns) - old_output_buffer = output_buffer;#{locals_code};#{code} - ensure - self.output_buffer = old_output_buffer - end - end_src - - if encoding_comment - source = "#{encoding_comment}\n#{source}" - line = -1 - else - line = 0 - end - - begin - ActionView::Base::CompiledTemplates.module_eval(source, filename, line) - rescue Errno::ENOENT => e - raise e # Missing template file, re-raise for Base to rescue - rescue Exception => e # errors from template code - if logger = defined?(ActionController) && Base.logger - logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}" - logger.debug "Function body: #{source}" - logger.debug "Backtrace: #{e.backtrace.join("\n")}" - end - - raise ActionView::TemplateError.new(self, {}, e) - end - end - - def recompile? - false - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/renderable_partial.rb b/vendor/rails/actionpack/lib/action_view/renderable_partial.rb deleted file mode 100644 index fb446145..00000000 --- a/vendor/rails/actionpack/lib/action_view/renderable_partial.rb +++ /dev/null @@ -1,53 +0,0 @@ -module ActionView - # NOTE: The template that this mixin is being included into is frozen - # so you cannot set or modify any instance variables - module RenderablePartial #:nodoc: - extend ActiveSupport::Memoizable - - def variable_name - name.sub(/\A_/, '').to_sym - end - memoize :variable_name - - def counter_name - "#{variable_name}_counter".to_sym - end - memoize :counter_name - - def render(view, local_assigns = {}) - if defined? ActionController - ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do - super - end - else - super - end - end - - def render_partial(view, object = nil, local_assigns = {}, as = nil) - object ||= local_assigns[:object] || local_assigns[variable_name] - - if object.nil? && !local_assigns_key?(local_assigns) && view.respond_to?(:controller) - ivar = :"@#{variable_name}" - object = - if view.controller.instance_variable_defined?(ivar) - ActiveSupport::Deprecation::DeprecatedObjectProxy.new( - view.controller.instance_variable_get(ivar), - "#{ivar} will no longer be implicitly assigned to #{variable_name}") - end - end - - # Ensure correct object is reassigned to other accessors - local_assigns[:object] = local_assigns[variable_name] = object - local_assigns[as] = object if as - - render_template(view, local_assigns) - end - - private - - def local_assigns_key?(local_assigns) - local_assigns.key?(:object) || local_assigns.key?(variable_name) - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template.rb b/vendor/rails/actionpack/lib/action_view/template.rb deleted file mode 100644 index 5a84fa3e..00000000 --- a/vendor/rails/actionpack/lib/action_view/template.rb +++ /dev/null @@ -1,252 +0,0 @@ -module ActionView #:nodoc: - class Template - class Path - attr_reader :path, :paths - delegate :hash, :inspect, :to => :path - - def initialize(path) - raise ArgumentError, "path already is a Path class" if path.is_a?(Path) - @path = (path.ends_with?(File::SEPARATOR) ? path.to(-2) : path).freeze - end - - def to_s - if defined?(RAILS_ROOT) - path.to_s.sub(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '') - else - path.to_s - end - end - - def to_str - path.to_str - end - - def ==(path) - to_str == path.to_str - end - - def eql?(path) - to_str == path.to_str - end - - # Returns a ActionView::Template object for the given path string. The - # input path should be relative to the view path directory, - # +hello/index.html.erb+. This method also has a special exception to - # match partial file names without a handler extension. So - # +hello/index.html+ will match the first template it finds with a - # known template extension, +hello/index.html.erb+. Template extensions - # should not be confused with format extensions +html+, +js+, +xml+, - # etc. A format must be supplied to match a formated file. +hello/index+ - # will never match +hello/index.html.erb+. - def [](path) - end - - def load! - end - - def self.new_and_loaded(path) - new(path).tap do |_path| - _path.load! - end - end - - private - def relative_path_for_template_file(full_file_path) - full_file_path.split("#{@path}/").last - end - end - - class EagerPath < Path - def initialize(path) - super - @loaded = false - end - - def load! - return if @loaded - - @paths = {} - templates_in_path do |template| - template.load! - template.accessible_paths.each do |path| - @paths[path] = template - end - end - @paths.freeze - @loaded = true - end - - def [](path) - load! unless @loaded - @paths[path] - end - - private - def templates_in_path - (Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file| - yield create_template(file) unless File.directory?(file) - end - end - - def create_template(file) - Template.new(relative_path_for_template_file(file), self) - end - end - - extend TemplateHandlers - extend ActiveSupport::Memoizable - include Renderable - - # Templates that are exempt from layouts - @@exempt_from_layout = Set.new([/\.rjs$/]) - - # Don't render layouts for templates with the given extensions. - def self.exempt_from_layout(*extensions) - regexps = extensions.collect do |extension| - extension.is_a?(Regexp) ? extension : /\.#{Regexp.escape(extension.to_s)}$/ - end - @@exempt_from_layout.merge(regexps) - end - - attr_accessor :template_path, :load_path, :base_path - attr_accessor :locale, :name, :format, :extension - attr_writer :filename - delegate :to_s, :to => :path - - def initialize(template_path, load_path = nil) - @template_path, @load_path = template_path.dup, load_path - @base_path, @name, @locale, @format, @extension = split(template_path) - @base_path.to_s.gsub!(/\/$/, '') # Push to split method - - # Extend with partial super powers - extend RenderablePartial if @name =~ /^_/ - end - - def accessible_paths - paths = [] - - if valid_extension?(extension) - paths << path - paths << path_without_extension - if multipart? - formats = format.split(".") - paths << "#{path_without_format_and_extension}.#{formats.first}" - paths << "#{path_without_format_and_extension}.#{formats.second}" - end - else - # template without explicit template handler should only be reachable through its exact path - paths << template_path - end - - paths - end - - def format_and_extension - (extensions = [format, extension].compact.join(".")).blank? ? nil : extensions - end - memoize :format_and_extension - - def multipart? - format && format.include?('.') - end - - def content_type - format.gsub('.', '/') - end - - def mime_type - Mime::Type.lookup_by_extension(format) if format && defined?(::Mime) - end - memoize :mime_type - - def path - [base_path, [name, locale, format, extension].compact.join('.')].compact.join('/') - end - memoize :path - - def path_without_extension - [base_path, [name, locale, format].compact.join('.')].compact.join('/') - end - memoize :path_without_extension - - def path_without_format_and_extension - [base_path, [name, locale].compact.join('.')].compact.join('/') - end - memoize :path_without_format_and_extension - - def relative_path - path = File.expand_path(filename) - path.sub!(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '') if defined?(RAILS_ROOT) - path - end - memoize :relative_path - - def exempt_from_layout? - @@exempt_from_layout.any? { |exempted| path =~ exempted } - end - - def filename - # no load_path means this is an "absolute pathed" template - load_path ? File.join(load_path, template_path) : template_path - end - memoize :filename - - def source - File.read(filename) - end - memoize :source - - def method_segment - relative_path.to_s.gsub(/([^a-zA-Z0-9_])/) { $1.ord } - end - memoize :method_segment - - def render_template(view, local_assigns = {}) - render(view, local_assigns) - rescue Exception => e - raise e unless filename - if TemplateError === e - e.sub_template_of(self) - raise e - else - raise TemplateError.new(self, view.assigns, e) - end - end - - def load! - freeze - end - - private - def valid_extension?(extension) - !Template.registered_template_handler(extension).nil? - end - - def valid_locale?(locale) - locale && I18n.available_locales.include?(locale.to_sym) - end - - # Returns file split into an array - # [base_path, name, locale, format, extension] - def split(file) - if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/) - [m[1], m[2], *parse_extensions(m[3])] - end - end - - # returns parsed extensions as an array - # [locale, format, extension] - def parse_extensions(extensions) - exts = extensions.split(".") - - if extension = valid_extension?(exts.last) && exts.pop || nil - locale = valid_locale?(exts.first) && exts.shift || nil - format = exts.join('.') if exts.any? # join('.') is needed for multipart templates - else # no extension, just format - format = exts.last - end - - [locale, format, extension] - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_error.rb b/vendor/rails/actionpack/lib/action_view/template_error.rb deleted file mode 100644 index 37cb1c7c..00000000 --- a/vendor/rails/actionpack/lib/action_view/template_error.rb +++ /dev/null @@ -1,99 +0,0 @@ -module ActionView - # The TemplateError exception is raised when the compilation of the template fails. This exception then gathers a - # bunch of intimate details and uses it to report a very precise exception message. - class TemplateError < ActionViewError #:nodoc: - SOURCE_CODE_RADIUS = 3 - - attr_reader :original_exception - - def initialize(template, assigns, original_exception) - @template, @assigns, @original_exception = template, assigns.dup, original_exception - @backtrace = compute_backtrace - end - - def file_name - @template.relative_path - end - - def message - ActiveSupport::Deprecation.silence { original_exception.message } - end - - def clean_backtrace - if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) - Rails.backtrace_cleaner.clean(original_exception.backtrace) - else - original_exception.backtrace - end - end - - def sub_template_message - if @sub_templates - "Trace of template inclusion: " + - @sub_templates.collect { |template| template.relative_path }.join(", ") - else - "" - end - end - - def source_extract(indentation = 0) - return unless num = line_number - num = num.to_i - - source_code = @template.source.split("\n") - - start_on_line = [ num - SOURCE_CODE_RADIUS - 1, 0 ].max - end_on_line = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min - - indent = ' ' * indentation - line_counter = start_on_line - return unless source_code = source_code[start_on_line..end_on_line] - - source_code.sum do |line| - line_counter += 1 - "#{indent}#{line_counter}: #{line}\n" - end - end - - def sub_template_of(template_path) - @sub_templates ||= [] - @sub_templates << template_path - end - - def line_number - @line_number ||= - if file_name - regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/ - - $1 if message =~ regexp or clean_backtrace.find { |line| line =~ regexp } - end - end - - def to_s - "\n#{self.class} (#{message}) #{source_location}:\n" + - "#{source_extract}\n #{clean_backtrace.join("\n ")}\n\n" - end - - # don't do anything nontrivial here. Any raised exception from here becomes fatal - # (and can't be rescued). - def backtrace - @backtrace - end - - private - def compute_backtrace - [ - "#{source_location.capitalize}\n\n#{source_extract(4)}\n " + - clean_backtrace.join("\n ") - ] - end - - def source_location - if line_number - "on line ##{line_number} of " - else - 'in ' - end + file_name - end - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/lib/action_view/template_handler.rb b/vendor/rails/actionpack/lib/action_view/template_handler.rb deleted file mode 100644 index 672da0ed..00000000 --- a/vendor/rails/actionpack/lib/action_view/template_handler.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Legacy TemplateHandler stub -module ActionView - module TemplateHandlers #:nodoc: - module Compilable - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - def call(template) - new.compile(template) - end - end - - def compile(template) - raise "Need to implement #{self.class.name}#compile(template)" - end - end - end - - class TemplateHandler - def self.call(template) - "#{name}.new(self).render(template, local_assigns)" - end - - def initialize(view = nil) - @view = view - end - - def render(template, local_assigns) - raise "Need to implement #{self.class.name}#render(template, local_assigns)" - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers.rb b/vendor/rails/actionpack/lib/action_view/template_handlers.rb deleted file mode 100644 index 205f8628..00000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers.rb +++ /dev/null @@ -1,48 +0,0 @@ -module ActionView #:nodoc: - module TemplateHandlers #:nodoc: - autoload :ERB, 'action_view/template_handlers/erb' - autoload :RJS, 'action_view/template_handlers/rjs' - autoload :Builder, 'action_view/template_handlers/builder' - - def self.extended(base) - base.register_default_template_handler :erb, TemplateHandlers::ERB - base.register_template_handler :rjs, TemplateHandlers::RJS - base.register_template_handler :builder, TemplateHandlers::Builder - - # TODO: Depreciate old template extensions - base.register_template_handler :rhtml, TemplateHandlers::ERB - base.register_template_handler :rxml, TemplateHandlers::Builder - end - - @@template_handlers = {} - @@default_template_handlers = nil - - # Register a class that knows how to handle template files with the given - # extension. This can be used to implement new template types. - # The constructor for the class must take the ActiveView::Base instance - # as a parameter, and the class must implement a +render+ method that - # takes the contents of the template to render as well as the Hash of - # local assigns available to the template. The +render+ method ought to - # return the rendered template as a string. - def register_template_handler(extension, klass) - @@template_handlers[extension.to_sym] = klass - end - - def template_handler_extensions - @@template_handlers.keys.map(&:to_s).sort - end - - def registered_template_handler(extension) - extension && @@template_handlers[extension.to_sym] - end - - def register_default_template_handler(extension, klass) - register_template_handler(extension, klass) - @@default_template_handlers = klass - end - - def handler_class_for_extension(extension) - registered_template_handler(extension) || @@default_template_handlers - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb deleted file mode 100644 index 788dc933..00000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'builder' - -module ActionView - module TemplateHandlers - class Builder < TemplateHandler - include Compilable - - def compile(template) - "_set_controller_content_type(Mime::XML);" + - "xml = ::Builder::XmlMarkup.new(:indent => 2);" + - "self.output_buffer = xml.target!;" + - template.source + - ";xml.target!;" - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb deleted file mode 100644 index b53a652f..00000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb +++ /dev/null @@ -1,25 +0,0 @@ -module ActionView - module TemplateHandlers - class ERB < TemplateHandler - include Compilable - - ## - # :singleton-method: - # Specify trim mode for the ERB compiler. Defaults to '-'. - # See ERb documentation for suitable values. - cattr_accessor :erb_trim_mode - self.erb_trim_mode = '-' - - def compile(template) - magic = $1 if template.source =~ /\A(<%#.*coding[:=]\s*(\S+)\s*-?%>)/ - erb = "#{magic}<% __in_erb_template=true %>#{template.source}" - - if erb.respond_to?(:force_encoding) - erb.force_encoding(template.source.encoding) - end - - ::ERB.new(erb, nil, erb_trim_mode, '@output_buffer').src - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb deleted file mode 100644 index 41a1fddb..00000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActionView - module TemplateHandlers - class RJS < TemplateHandler - include Compilable - - def compile(template) - "@template_format = :html;" + - "controller.response.content_type ||= Mime::JS;" + - "update_page do |page|;#{template.source}\nend" - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/test_case.rb b/vendor/rails/actionpack/lib/action_view/test_case.rb deleted file mode 100644 index 049314c4..00000000 --- a/vendor/rails/actionpack/lib/action_view/test_case.rb +++ /dev/null @@ -1,162 +0,0 @@ -require 'active_support/test_case' - -module ActionView - class Base - alias_method :initialize_without_template_tracking, :initialize - def initialize(*args) - @_rendered = { :template => nil, :partials => Hash.new(0) } - initialize_without_template_tracking(*args) - end - end - - module Renderable - alias_method :render_without_template_tracking, :render - def render(view, local_assigns = {}) - if respond_to?(:path) && !is_a?(InlineTemplate) - rendered = view.instance_variable_get(:@_rendered) - rendered[:partials][self] += 1 if is_a?(RenderablePartial) - rendered[:template] ||= self - end - render_without_template_tracking(view, local_assigns) - end - end - - class TestCase < ActiveSupport::TestCase - class TestController < ActionController::Base - attr_accessor :request, :response, :params - - def self.controller_path - '' - end - - def initialize - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @params = {} - send(:initialize_current_url) - end - end - - include ActionController::TestCase::Assertions - include ActionController::TestProcess - - include ActionController::PolymorphicRoutes - include ActionController::RecordIdentifier - - include ActionView::Helpers - include ActionController::Helpers - - class_inheritable_accessor :helper_class - attr_accessor :controller, :output_buffer, :rendered - - setup :setup_with_controller - def setup_with_controller - @controller = TestController.new - @output_buffer = '' - @rendered = '' - - self.class.send(:include_helper_modules!) - make_test_case_available_to_view! - end - - def render(options = {}, local_assigns = {}, &block) - @rendered << output = _view.render(options, local_assigns, &block) - output - end - - def protect_against_forgery? - false - end - - class << self - def tests(helper_class) - self.helper_class = helper_class - end - - def helper_class - if current_helper_class = read_inheritable_attribute(:helper_class) - current_helper_class - else - self.helper_class = determine_default_helper_class(name) - end - end - - def determine_default_helper_class(name) - name.sub(/Test$/, '').constantize - rescue NameError - nil - end - - def helper_method(*methods) - # Almost a duplicate from ActionController::Helpers - methods.flatten.each do |method| - master_helper_module.module_eval <<-end_eval - def #{method}(*args, &block) # def current_user(*args, &block) - _test_case.send(%(#{method}), *args, &block) # test_case.send(%(current_user), *args, &block) - end # end - end_eval - end - end - - private - def include_helper_modules! - helper(helper_class) if helper_class - include master_helper_module - end - end - - private - def make_test_case_available_to_view! - test_case_instance = self - master_helper_module.module_eval do - define_method(:_test_case) { test_case_instance } - private :_test_case - end - end - - def _view - view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller) - view.helpers.include master_helper_module - view.output_buffer = self.output_buffer - view - end - - # Support the selector assertions - # - # Need to experiment if this priority is the best one: rendered => output_buffer - def response_from_page_or_rjs - HTML::Document.new(rendered.blank? ? output_buffer : rendered).root - end - - EXCLUDE_IVARS = %w{ - @output_buffer - @fixture_cache - @method_name - @_result - @loaded_fixtures - @test_passed - @view - } - - def _instance_variables - instance_variables - EXCLUDE_IVARS - end - - def _assigns - _instance_variables.inject({}) do |hash, var| - name = var[1..-1].to_sym - hash[name] = instance_variable_get(var) - hash - end - end - - def method_missing(selector, *args) - if ActionController::Routing::Routes.named_routes.helpers.include?(selector) - @controller.__send__(selector, *args) - else - super - end - end - end -end diff --git a/vendor/rails/actionpack/lib/actionpack.rb b/vendor/rails/actionpack/lib/actionpack.rb deleted file mode 100644 index 41681db7..00000000 --- a/vendor/rails/actionpack/lib/actionpack.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'action_pack' -ActiveSupport::Deprecation.warn 'require "actionpack" is deprecated and will be removed in Rails 3. Use require "action_pack" instead.' diff --git a/vendor/rails/actionpack/test/abstract_unit.rb b/vendor/rails/actionpack/test/abstract_unit.rb deleted file mode 100644 index 0dce5500..00000000 --- a/vendor/rails/actionpack/test/abstract_unit.rb +++ /dev/null @@ -1,78 +0,0 @@ -$:.unshift File.expand_path('../../lib', __FILE__) -$:.unshift File.expand_path('../../../activesupport/lib', __FILE__) -$:.unshift File.expand_path('../fixtures/helpers', __FILE__) -$:.unshift File.expand_path('../fixtures/alternate_helpers', __FILE__) - -require 'rubygems' -require 'yaml' -require 'stringio' -require 'test/unit' - -gem 'mocha', '>= 0.9.7' -require 'mocha' - -begin - require 'ruby-debug' - Debugger.settings[:autoeval] = true - Debugger.start -rescue LoadError - # Debugging disabled. `gem install ruby-debug` to enable. -end - -require 'action_controller' -require 'action_controller/cgi_ext' -require 'action_controller/test_process' -require 'action_view/test_case' - -# Show backtraces for deprecated behavior for quicker cleanup. -ActiveSupport::Deprecation.debug = true - -ActionController::Base.logger = nil -ActionController::Routing::Routes.reload rescue nil - -ActionController::Base.session_store = nil - -# Register languages for testing -I18n.backend.store_translations 'da', "da" => {} -I18n.backend.store_translations 'pt-BR', "pt-BR" => {} -ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort - -FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') -ActionView::Base.cache_template_loading = true -ActionController::Base.view_paths = FIXTURE_LOAD_PATH -CACHED_VIEW_PATHS = ActionView::Base.cache_template_loading? ? - ActionController::Base.view_paths : - ActionController::Base.view_paths.map {|path| ActionView::Template::EagerPath.new(path.to_s)} - -class DummyMutex - def lock - @locked = true - end - - def unlock - @locked = false - end - - def locked? - @locked - end -end - -class ActionController::IntegrationTest < ActiveSupport::TestCase - def with_autoload_path(path) - path = File.join(File.dirname(__FILE__), "fixtures", path) - if ActiveSupport::Dependencies.autoload_paths.include?(path) - yield - else - begin - ActiveSupport::Dependencies.autoload_paths << path - yield - ensure - ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path} - ActiveSupport::Dependencies.clear - end - end - end -end - -ActionController::Reloader.default_lock = DummyMutex.new diff --git a/vendor/rails/actionpack/test/active_record_unit.rb b/vendor/rails/actionpack/test/active_record_unit.rb deleted file mode 100644 index 5c0cb062..00000000 --- a/vendor/rails/actionpack/test/active_record_unit.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'abstract_unit' - -# Define the essentials -class ActiveRecordTestConnector - cattr_accessor :able_to_connect - cattr_accessor :connected - - # Set our defaults - self.connected = false - self.able_to_connect = true -end - -# Try to grab AR -if defined?(ActiveRecord) && defined?(Fixtures) - $stderr.puts 'Active Record is already loaded, running tests' -else - $stderr.print 'Attempting to load Active Record... ' - begin - PATH_TO_AR = File.expand_path('../../../activerecord/lib', __FILE__) - raise LoadError, "#{PATH_TO_AR} doesn't exist" unless File.directory?(PATH_TO_AR) - $LOAD_PATH.unshift PATH_TO_AR - require 'active_record' - require 'active_record/fixtures' - $stderr.puts 'success' - rescue LoadError => e - $stderr.print "failed. Skipping Active Record assertion tests: #{e}" - ActiveRecordTestConnector.able_to_connect = false - end -end -$stderr.flush - - -# Define the rest of the connector -class ActiveRecordTestConnector - class << self - def setup - unless self.connected || !self.able_to_connect - setup_connection - load_schema - require_fixture_models - self.connected = true - end - rescue Exception => e # errors from ActiveRecord setup - $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}" - #$stderr.puts " #{e.backtrace.join("\n ")}\n" - self.able_to_connect = false - end - - private - def setup_connection - if Object.const_defined?(:ActiveRecord) - defaults = { :database => ':memory:' } - begin - adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' - options = defaults.merge :adapter => adapter, :timeout => 500 - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } - ActiveRecord::Base.connection - rescue Exception # errors from establishing a connection - $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' - options = defaults.merge :adapter => 'sqlite' - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } - ActiveRecord::Base.connection - end - - Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE) - else - raise "Can't setup connection since ActiveRecord isn't loaded." - end - end - - # Load actionpack sqlite tables - def load_schema - File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql| - ActiveRecord::Base.connection.execute(sql) unless sql.blank? - end - end - - def require_fixture_models - Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f} - end - end -end - -class ActiveRecordTestCase < ActionController::TestCase - include ActiveRecord::TestFixtures - - # Set our fixture path - if ActiveRecordTestConnector.able_to_connect - self.fixture_path = [FIXTURE_LOAD_PATH] - self.use_transactional_fixtures = false - end - - def self.fixtures(*args) - super if ActiveRecordTestConnector.connected - end - - def run(*args) - super if ActiveRecordTestConnector.connected - end -end - -ActiveRecordTestConnector.setup diff --git a/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb b/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb deleted file mode 100644 index 6f2fe327..00000000 --- a/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +++ /dev/null @@ -1,221 +0,0 @@ -require 'active_record_unit' - -class ActiveRecordStoreTest < ActionController::IntegrationTest - DispatcherApp = ActionController::Dispatcher.new - SessionApp = ActiveRecord::SessionStore.new(DispatcherApp, - :key => '_session_id') - SessionAppWithFixation = ActiveRecord::SessionStore.new(DispatcherApp, - :key => '_session_id', :cookie_only => false) - - class TestController < ActionController::Base - def no_session_access - head :ok - end - - def set_session_value - session[:foo] = params[:foo] || "bar" - head :ok - end - - def get_session_value - render :text => "foo: #{session[:foo].inspect}" - end - - def get_session_id - render :text => "#{request.session_options[:id]}" - end - - def call_reset_session - session[:foo] - reset_session - session[:foo] = "baz" - head :ok - end - - def rescue_action(e) raise end - end - - def setup - ActiveRecord::SessionStore.session_class.create_table! - @integration_session = open_session(SessionApp) - end - - def teardown - ActiveRecord::SessionStore.session_class.drop_table! - end - - %w{ session sql_bypass }.each do |class_name| - define_method("test_setting_and_getting_session_value_with_#{class_name}_store") do - with_store class_name do - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - - get '/set_session_value', :foo => "baz" - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "baz"', response.body - end - end - end - end - - def test_getting_nil_session_value - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "baz"', response.body - - get '/get_session_id' - assert_response :success - assert_not_equal session_id, response.body - end - end - - def test_getting_session_id - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/get_session_id' - assert_response :success - assert_equal session_id, response.body - end - end - - def test_getting_session_value - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal nil, headers['Set-Cookie'], "should not resend the cookie again if session_id cookie is already exists" - session_id = cookies["_session_id"] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - - cookies["_session_id"] = session_id # replace our new session_id with our old, pre-reset session_id - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body, "data for this session should have been obliterated from the database" - end - end - - def test_getting_from_nonexistent_session - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - assert_nil cookies['_session_id'], "should only create session on write, not read" - end - end - - def test_prevents_session_fixation - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - session_id = cookies['_session_id'] - assert session_id - - reset! - - get '/set_session_value', :_session_id => session_id, :foo => "baz" - assert_response :success - assert_equal nil, cookies['_session_id'] - - get '/get_session_value', :_session_id => session_id - assert_response :success - assert_equal 'foo: nil', response.body - assert_equal nil, cookies['_session_id'] - end - end - - def test_allows_session_fixation - @integration_session = open_session(SessionAppWithFixation) - - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - session_id = cookies['_session_id'] - assert session_id - - reset! - @integration_session = open_session(SessionAppWithFixation) - - get '/set_session_value', :_session_id => session_id, :foo => "baz" - assert_response :success - assert_equal session_id, cookies['_session_id'] - - get '/get_session_value', :_session_id => session_id - assert_response :success - assert_equal 'foo: "baz"', response.body - assert_equal session_id, cookies['_session_id'] - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "active_record_store_test/test" do |c| - c.connect "/:action" - end - end - yield - end - end - - def with_store(class_name) - begin - session_class = ActiveRecord::SessionStore.session_class - ActiveRecord::SessionStore.session_class = "ActiveRecord::SessionStore::#{class_name.camelize}".constantize - yield - rescue - ActiveRecord::SessionStore.session_class = session_class - raise - end - end - -end diff --git a/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb deleted file mode 100644 index 0a596c7a..00000000 --- a/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb +++ /dev/null @@ -1,188 +0,0 @@ -require 'active_record_unit' - -class RenderPartialWithRecordIdentificationController < ActionController::Base - def render_with_has_many_and_belongs_to_association - @developer = Developer.find(1) - render :partial => @developer.projects - end - - def render_with_has_many_association - @topic = Topic.find(1) - render :partial => @topic.replies - end - - def render_with_named_scope - render :partial => Reply.base - end - - def render_with_has_many_through_association - @developer = Developer.find(:first) - render :partial => @developer.topics - end - - def render_with_has_one_association - @company = Company.find(1) - render :partial => @company.mascot - end - - def render_with_belongs_to_association - @reply = Reply.find(1) - render :partial => @reply.topic - end - - def render_with_record - @developer = Developer.find(:first) - render :partial => @developer - end - - def render_with_record_collection - @developers = Developer.find(:all) - render :partial => @developers - end - - def render_with_record_collection_and_spacer_template - @developer = Developer.find(1) - render :partial => @developer.projects, :spacer_template => 'test/partial_only' - end -end - -class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase - tests RenderPartialWithRecordIdentificationController - fixtures :developers, :projects, :developers_projects, :topics, :replies, :companies, :mascots - - def test_rendering_partial_with_has_many_and_belongs_to_association - get :render_with_has_many_and_belongs_to_association - assert_template 'projects/_project' - assert_equal assigns(:developer).projects.map(&:name).join, @response.body - end - - def test_rendering_partial_with_has_many_association - get :render_with_has_many_association - assert_template 'replies/_reply' - assert_equal 'Birdman is better!', @response.body - end - - def test_rendering_partial_with_named_scope - get :render_with_named_scope - assert_template 'replies/_reply' - assert_equal 'Birdman is better!Nuh uh!', @response.body - end - - def test_render_with_record - get :render_with_record - assert_template 'developers/_developer' - assert_equal 'David', @response.body - end - - def test_render_with_record_collection - get :render_with_record_collection - assert_template 'developers/_developer' - assert_equal 'DavidJamisfixture_3fixture_4fixture_5fixture_6fixture_7fixture_8fixture_9fixture_10Jamis', @response.body - end - - def test_render_with_record_collection_and_spacer_template - get :render_with_record_collection_and_spacer_template - assert_equal assigns(:developer).projects.map(&:name).join('only partial'), @response.body - end - - def test_rendering_partial_with_has_one_association - mascot = Company.find(1).mascot - get :render_with_has_one_association - assert_template 'mascots/_mascot' - assert_equal mascot.name, @response.body - end -end - -class RenderPartialWithRecordIdentificationController < ActionController::Base - def render_with_has_many_and_belongs_to_association - @developer = Developer.find(1) - render :partial => @developer.projects - end - - def render_with_has_many_association - @topic = Topic.find(1) - render :partial => @topic.replies - end - - def render_with_has_many_through_association - @developer = Developer.find(:first) - render :partial => @developer.topics - end - - def render_with_belongs_to_association - @reply = Reply.find(1) - render :partial => @reply.topic - end - - def render_with_record - @developer = Developer.find(:first) - render :partial => @developer - end - - def render_with_record_collection - @developers = Developer.find(:all) - render :partial => @developers - end -end - -class Game < Struct.new(:name, :id) - def to_param - id.to_s - end -end - -module Fun - class NestedController < ActionController::Base - def render_with_record_in_nested_controller - render :partial => Game.new("Pong") - end - - def render_with_record_collection_in_nested_controller - render :partial => [ Game.new("Pong"), Game.new("Tank") ] - end - end - - module Serious - class NestedDeeperController < ActionController::Base - def render_with_record_in_deeper_nested_controller - render :partial => Game.new("Chess") - end - - def render_with_record_collection_in_deeper_nested_controller - render :partial => [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ] - end - end - end -end - -class RenderPartialWithRecordIdentificationAndNestedControllersTest < ActiveRecordTestCase - tests Fun::NestedController - - def test_render_with_record_in_nested_controller - get :render_with_record_in_nested_controller - assert_template 'fun/games/_game' - assert_equal 'Pong', @response.body - end - - def test_render_with_record_collection_in_nested_controller - get :render_with_record_collection_in_nested_controller - assert_template 'fun/games/_game' - assert_equal 'PongTank', @response.body - end -end - -class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < ActiveRecordTestCase - tests Fun::Serious::NestedDeeperController - - def test_render_with_record_in_deeper_nested_controller - get :render_with_record_in_deeper_nested_controller - assert_template 'fun/serious/games/_game' - assert_equal 'Chess', @response.body - end - - def test_render_with_record_collection_in_deeper_nested_controller - get :render_with_record_collection_in_deeper_nested_controller - assert_template 'fun/serious/games/_game' - assert_equal 'ChessSudokuSolitaire', @response.body - end -end diff --git a/vendor/rails/actionpack/test/adv_attr_test.rb b/vendor/rails/actionpack/test/adv_attr_test.rb deleted file mode 100644 index fdda4ad9..00000000 --- a/vendor/rails/actionpack/test/adv_attr_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' -require 'action_mailer/adv_attr_accessor' - -class AdvAttrTest < Test::Unit::TestCase - class Person - include ActionMailer::AdvAttrAccessor - adv_attr_accessor :name - end - - def test_adv_attr - bob = Person.new - assert_nil bob.name - bob.name 'Bob' - assert_equal 'Bob', bob.name - - assert_raise(ArgumentError) {bob.name 'x', 'y'} - end - - -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb b/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb deleted file mode 100644 index ec7e2164..00000000 --- a/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +++ /dev/null @@ -1,545 +0,0 @@ -require 'abstract_unit' - -# a controller class to facilitate the tests -class ActionPackAssertionsController < ActionController::Base - - # this does absolutely nothing - def nothing() head :ok end - - # a standard template - def hello_world() render :template => "test/hello_world"; end - - # a standard template - def hello_xml_world() render :template => "test/hello_xml_world"; end - - # a standard partial - def partial() render :partial => 'test/partial'; end - - # a redirect to an internal location - def redirect_internal() redirect_to "/nothing"; end - - def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params => { "panda" => "fun" }; end - - def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end - - def redirect_to_controller_with_symbol() redirect_to :controller => :elsewhere, :action => :flash_me; end - - def redirect_to_path() redirect_to '/some/path' end - - def redirect_to_named_route() redirect_to route_one_url end - - # a redirect to an external location - def redirect_external() redirect_to "http://www.rubyonrails.org"; end - - # a 404 - def response404() head '404 AWOL' end - - # a 500 - def response500() head '500 Sorry' end - - # a fictional 599 - def response599() head '599 Whoah!' end - - # putting stuff in the flash - def flash_me - flash['hello'] = 'my name is inigo montoya...' - render :text => "Inconceivable!" - end - - # we have a flash, but nothing is in it - def flash_me_naked - flash.clear - render :text => "wow!" - end - - # assign some template instance variables - def assign_this - @howdy = "ho" - render :inline => "Mr. Henke" - end - - def render_based_on_parameters - render :text => "Mr. #{params[:name]}" - end - - def render_url - render :text => "
    #{url_for(:action => 'flash_me', :only_path => true)}
    " - end - - def render_text_with_custom_content_type - render :text => "Hello!", :content_type => Mime::RSS - end - - # puts something in the session - def session_stuffing - session['xmas'] = 'turkey' - render :text => "ho ho ho" - end - - # raises exception on get requests - def raise_on_get - raise "get" if request.get? - render :text => "request method: #{request.env['REQUEST_METHOD']}" - end - - # raises exception on post requests - def raise_on_post - raise "post" if request.post? - render :text => "request method: #{request.env['REQUEST_METHOD']}" - end - - def get_valid_record - @record = Class.new do - def valid? - true - end - - def errors - Class.new do - def full_messages; []; end - end.new - end - - end.new - - render :nothing => true - end - - - def get_invalid_record - @record = Class.new do - - def valid? - false - end - - def errors - Class.new do - def full_messages; ['...stuff...']; end - end.new - end - end.new - - render :nothing => true - end - - # 911 - def rescue_action(e) raise; end -end - -# Used to test that assert_response includes the exception message -# in the failure message when an action raises and assert_response -# is expecting something other than an error. -class AssertResponseWithUnexpectedErrorController < ActionController::Base - def index - raise 'FAIL' - end - - def show - render :text => "Boom", :status => 500 - end -end - -class UserController < ActionController::Base -end - -module Admin - class InnerModuleController < ActionController::Base - def index - render :nothing => true - end - - def redirect_to_index - redirect_to admin_inner_module_path - end - - def redirect_to_absolute_controller - redirect_to :controller => '/content' - end - - def redirect_to_fellow_controller - redirect_to :controller => 'user' - end - - def redirect_to_top_level_named_route - redirect_to top_level_url(:id => "foo") - end - end -end - -# a test case to exercise the new capabilities TestRequest & TestResponse -class ActionPackAssertionsControllerTest < ActionController::TestCase - # let's get this party started - def setup - ActionController::Routing::Routes.reload - ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user)) - end - - def teardown - ActionController::Routing::Routes.reload - end - - # -- assertion-based testing ------------------------------------------------ - - def test_assert_tag_and_url_for - get :render_url - assert_tag :content => "/action_pack_assertions/flash_me" - end - - # test the get method, make sure the request really was a get - def test_get - assert_raise(RuntimeError) { get :raise_on_get } - get :raise_on_post - assert_equal @response.body, 'request method: GET' - end - - # test the get method, make sure the request really was a get - def test_post - assert_raise(RuntimeError) { post :raise_on_post } - post :raise_on_get - assert_equal @response.body, 'request method: POST' - end - -# the following test fails because the request_method is now cached on the request instance -# test the get/post switch within one test action -# def test_get_post_switch -# post :raise_on_get -# assert_equal @response.body, 'request method: POST' -# get :raise_on_post -# assert_equal @response.body, 'request method: GET' -# post :raise_on_get -# assert_equal @response.body, 'request method: POST' -# get :raise_on_post -# assert_equal @response.body, 'request method: GET' -# end - - # test the redirection to a named route - def test_assert_redirect_to_named_route - with_routing do |set| - set.draw do |map| - map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing' - map.connect ':controller/:action/:id' - end - set.install_helpers - - process :redirect_to_named_route - assert_redirected_to 'http://test.host/route_one' - assert_redirected_to route_one_url - end - end - - def test_assert_redirect_to_named_route_failure - with_routing do |set| - set.draw do |map| - map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'one' - map.route_two 'route_two', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two' - map.connect ':controller/:action/:id' - end - process :redirect_to_named_route - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to 'http://test.host/route_two' - end - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two' - end - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to route_two_url - end - end - end - - def test_assert_redirect_to_nested_named_route - with_routing do |set| - set.draw do |map| - map.admin_inner_module 'admin/inner_module', :controller => 'admin/inner_module', :action => 'index' - map.connect ':controller/:action/:id' - end - @controller = Admin::InnerModuleController.new - process :redirect_to_index - # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> - assert_redirected_to admin_inner_module_path - end - end - - def test_assert_redirected_to_top_level_named_route_from_nested_controller - with_routing do |set| - set.draw do |map| - map.top_level '/action_pack_assertions/:id', :controller => 'action_pack_assertions', :action => 'index' - map.connect ':controller/:action/:id' - end - @controller = Admin::InnerModuleController.new - process :redirect_to_top_level_named_route - # assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return - assert_redirected_to "/action_pack_assertions/foo" - end - end - - def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces - with_routing do |set| - set.draw do |map| - # this controller exists in the admin namespace as well which is the only difference from previous test - map.top_level '/user/:id', :controller => 'user', :action => 'index' - map.connect ':controller/:action/:id' - end - @controller = Admin::InnerModuleController.new - process :redirect_to_top_level_named_route - # assert_redirected_to top_level_url('foo') would pass because of exact match early return - assert_redirected_to top_level_path('foo') - end - end - - # -- standard request/response object testing -------------------------------- - - # make sure that the template objects exist - def test_template_objects_alive - process :assign_this - assert !@response.has_template_object?('hi') - assert @response.has_template_object?('howdy') - end - - # make sure we don't have template objects when we shouldn't - def test_template_object_missing - process :nothing - assert_nil @response.template_objects['howdy'] - end - - # check the empty flashing - def test_flash_me_naked - process :flash_me_naked - assert !@response.has_flash? - assert !@response.has_flash_with_contents? - end - - # check if we have flash objects - def test_flash_haves - process :flash_me - assert @response.has_flash? - assert @response.has_flash_with_contents? - assert @response.has_flash_object?('hello') - end - - # ensure we don't have flash objects - def test_flash_have_nots - process :nothing - assert !@response.has_flash? - assert !@response.has_flash_with_contents? - assert_nil @response.flash['hello'] - end - - # check if we were rendered by a file-based template? - def test_rendered_action - process :nothing - assert_nil @response.rendered[:template] - - process :hello_world - assert @response.rendered[:template] - assert 'hello_world', @response.rendered[:template].to_s - end - - def test_assert_template_with_partial - get :partial - assert_template :partial => '_partial' - end - - def test_assert_template_with_nil - get :nothing - assert_template nil - end - - def test_assert_template_with_string - get :hello_world - assert_template 'hello_world' - end - - def test_assert_template_with_symbol - get :hello_world - assert_template :hello_world - end - - def test_assert_template_with_bad_argument - assert_raise(ArgumentError) { assert_template 1 } - end - - # check the redirection location - def test_redirection_location - process :redirect_internal - assert_equal 'http://test.host/nothing', @response.redirect_url - - process :redirect_external - assert_equal 'http://www.rubyonrails.org', @response.redirect_url - end - - def test_no_redirect_url - process :nothing - assert_nil @response.redirect_url - end - - - # check server errors - def test_server_error_response_code - process :response500 - assert @response.server_error? - - process :response599 - assert @response.server_error? - - process :response404 - assert !@response.server_error? - end - - # check a 404 response code - def test_missing_response_code - process :response404 - assert @response.missing? - end - - # check client errors - def test_client_error_response_code - process :response404 - assert @response.client_error? - end - - # check to see if our redirection matches a pattern - def test_redirect_url_match - process :redirect_external - assert @response.redirect? - assert @response.redirect_url_match?("rubyonrails") - assert @response.redirect_url_match?(/rubyonrails/) - assert !@response.redirect_url_match?("phpoffrails") - assert !@response.redirect_url_match?(/perloffrails/) - end - - # check for a redirection - def test_redirection - process :redirect_internal - assert @response.redirect? - - process :redirect_external - assert @response.redirect? - - process :nothing - assert !@response.redirect? - end - - # check a successful response code - def test_successful_response_code - process :nothing - assert @response.success? - end - - # a basic check to make sure we have a TestResponse object - def test_has_response - process :nothing - assert_kind_of ActionController::TestResponse, @response - end - - def test_render_based_on_parameters - process :render_based_on_parameters, "name" => "David" - assert_equal "Mr. David", @response.body - end - - - def test_assert_redirection_fails_with_incorrect_controller - process :redirect_to_controller - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to :controller => "action_pack_assertions", :action => "flash_me" - end - end - - def test_assert_redirection_with_extra_controller_option - get :redirect_to_action - assert_redirected_to :controller => 'action_pack_assertions', :action => "flash_me", :id => 1, :params => { :panda => 'fun' } - end - - def test_redirected_to_url_leading_slash - process :redirect_to_path - assert_redirected_to '/some/path' - end - - def test_redirected_to_url_no_leadling_slash - process :redirect_to_path - assert_deprecated /leading/ do - assert_redirected_to 'some/path' - end - end - - def test_redirected_to_url_full_url - process :redirect_to_path - assert_redirected_to 'http://test.host/some/path' - end - - def test_assert_redirection_with_symbol - process :redirect_to_controller_with_symbol - assert_nothing_raised { - assert_redirected_to :controller => "elsewhere", :action => "flash_me" - } - process :redirect_to_controller_with_symbol - assert_nothing_raised { - assert_redirected_to :controller => :elsewhere, :action => :flash_me - } - end - - def test_redirected_to_with_nested_controller - @controller = Admin::InnerModuleController.new - get :redirect_to_absolute_controller - assert_redirected_to :controller => '/content' - - get :redirect_to_fellow_controller - assert_redirected_to :controller => 'admin/user' - end - - def test_assert_valid - get :get_valid_record - assert_deprecated { assert_valid assigns('record') } - end - - def test_assert_valid_failing - get :get_invalid_record - - begin - assert_deprecated { assert_valid assigns('record') } - assert false - rescue ActiveSupport::TestCase::Assertion => e - end - end - - def test_assert_response_uses_exception_message - @controller = AssertResponseWithUnexpectedErrorController.new - get :index - assert_response :success - flunk 'Expected non-success response' - rescue ActiveSupport::TestCase::Assertion => e - assert e.message.include?('FAIL') - end - - def test_assert_response_failure_response_with_no_exception - @controller = AssertResponseWithUnexpectedErrorController.new - get :show - assert_response :success - flunk 'Expected non-success response' - rescue ActiveSupport::TestCase::Assertion - # success - rescue - flunk "assert_response failed to handle failure response with missing, but optional, exception." - end -end - -class ActionPackHeaderTest < ActionController::TestCase - tests ActionPackAssertionsController - - def test_rendering_xml_sets_content_type - process :hello_xml_world - assert_equal('application/xml; charset=utf-8', @response.headers['Content-Type']) - end - - def test_rendering_xml_respects_content_type - @response.headers['type'] = 'application/pdf' - process :hello_xml_world - assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type']) - end - - def test_render_text_with_custom_content_type - get :render_text_with_custom_content_type - assert_equal 'application/rss+xml; charset=utf-8', @response.headers['Content-Type'] - end -end diff --git a/vendor/rails/actionpack/test/controller/addresses_render_test.rb b/vendor/rails/actionpack/test/controller/addresses_render_test.rb deleted file mode 100644 index 556b0593..00000000 --- a/vendor/rails/actionpack/test/controller/addresses_render_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'abstract_unit' - -class Address - def Address.count(conditions = nil, join = nil) - nil - end - - def Address.find_all(arg1, arg2, arg3, arg4) - [] - end - - def self.find(*args) - [] - end -end - -class AddressesTestController < ActionController::Base - def self.controller_name; "addresses"; end - def self.controller_path; "addresses"; end -end - -class AddressesTest < ActionController::TestCase - tests AddressesTestController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request.host = "www.nextangle.com" - end - - def test_list - get :list - assert_equal "We only need to get this far!", @response.body.chomp - end -end diff --git a/vendor/rails/actionpack/test/controller/assert_select_test.rb b/vendor/rails/actionpack/test/controller/assert_select_test.rb deleted file mode 100644 index 58fcaa95..00000000 --- a/vendor/rails/actionpack/test/controller/assert_select_test.rb +++ /dev/null @@ -1,735 +0,0 @@ -# encoding: us-ascii -#-- -# Copyright (c) 2006 Assaf Arkin (http://labnotes.org) -# Under MIT and/or CC By license. -#++ - -require 'abstract_unit' -require 'controller/fake_controllers' - - -unless defined?(ActionMailer) - begin - $:.unshift("#{File.dirname(__FILE__)}/../../../actionmailer/lib") - require 'action_mailer' - rescue LoadError => e - raise unless e.message =~ /action_mailer/ - require 'rubygems' - gem 'actionmailer' - end -end - -ActionMailer::Base.template_root = FIXTURE_LOAD_PATH - -class AssertSelectTest < ActionController::TestCase - Assertion = ActiveSupport::TestCase::Assertion - - class AssertSelectMailer < ActionMailer::Base - def test(html) - recipients "test " - from "test@test.host" - subject "Test e-mail" - part :content_type=>"text/html", :body=>html - end - end - - class AssertSelectController < ActionController::Base - def response_with=(content) - @content = content - end - - def response_with(&block) - @update = block - end - - def html() - render :text=>@content, :layout=>false, :content_type=>Mime::HTML - @content = nil - end - - def rjs() - render :update do |page| - @update.call page - end - @update = nil - end - - def xml() - render :text=>@content, :layout=>false, :content_type=>Mime::XML - @content = nil - end - - def rescue_action(e) - raise e - end - end - - tests AssertSelectController - - def setup - ActionMailer::Base.delivery_method = :test - ActionMailer::Base.perform_deliveries = true - ActionMailer::Base.deliveries = [] - end - - def teardown - ActionMailer::Base.deliveries.clear - end - - def assert_failure(message, &block) - e = assert_raise(Assertion, &block) - assert_match(message, e.message) if Regexp === message - assert_equal(message, e.message) if String === message - end - - # - # Test assert select. - # - - def test_assert_select - render_html %Q{
    } - assert_select "div", 2 - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) { assert_select "div", 3 } - assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" } - end - - def test_equality_true_false - render_html %Q{
    } - assert_nothing_raised { assert_select "div" } - assert_raise(Assertion) { assert_select "p" } - assert_nothing_raised { assert_select "div", true } - assert_raise(Assertion) { assert_select "p", true } - assert_raise(Assertion) { assert_select "div", false } - assert_nothing_raised { assert_select "p", false } - end - - def test_equality_string_and_regexp - render_html %Q{
    foo
    foo
    } - assert_nothing_raised { assert_select "div", "foo" } - assert_raise(Assertion) { assert_select "div", "bar" } - assert_nothing_raised { assert_select "div", :text=>"foo" } - assert_raise(Assertion) { assert_select "div", :text=>"bar" } - assert_nothing_raised { assert_select "div", /(foo|bar)/ } - assert_raise(Assertion) { assert_select "div", /foobar/ } - assert_nothing_raised { assert_select "div", :text=>/(foo|bar)/ } - assert_raise(Assertion) { assert_select "div", :text=>/foobar/ } - assert_raise(Assertion) { assert_select "p", :text=>/foobar/ } - end - - def test_equality_of_html - render_html %Q{

    \n"This is not a big problem," he said.\n

    } - text = "\"This is not a big problem,\" he said." - html = "\"This is not a big problem,\" he said." - assert_nothing_raised { assert_select "p", text } - assert_raise(Assertion) { assert_select "p", html } - assert_nothing_raised { assert_select "p", :html=>html } - assert_raise(Assertion) { assert_select "p", :html=>text } - # No stripping for pre. - render_html %Q{
    \n"This is not a big problem," he said.\n
    } - text = "\n\"This is not a big problem,\" he said.\n" - html = "\n\"This is not a big problem,\" he said.\n" - assert_nothing_raised { assert_select "pre", text } - assert_raise(Assertion) { assert_select "pre", html } - assert_nothing_raised { assert_select "pre", :html=>html } - assert_raise(Assertion) { assert_select "pre", :html=>text } - end - - def test_counts - render_html %Q{
    foo
    foo
    } - assert_nothing_raised { assert_select "div", 2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do - assert_select "div", 3 - end - assert_nothing_raised { assert_select "div", 1..2 } - assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do - assert_select "div", 3..4 - end - assert_nothing_raised { assert_select "div", :count=>2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do - assert_select "div", :count=>3 - end - assert_nothing_raised { assert_select "div", :minimum=>1 } - assert_nothing_raised { assert_select "div", :minimum=>2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do - assert_select "div", :minimum=>3 - end - assert_nothing_raised { assert_select "div", :maximum=>2 } - assert_nothing_raised { assert_select "div", :maximum=>3 } - assert_failure(/Expected at most 1 element matching \"div\", found 2/) do - assert_select "div", :maximum=>1 - end - assert_nothing_raised { assert_select "div", :minimum=>1, :maximum=>2 } - assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do - assert_select "div", :minimum=>3, :maximum=>4 - end - end - - def test_substitution_values - render_html %Q{
    foo
    foo
    } - assert_select "div#?", /\d+/ do |elements| - assert_equal 2, elements.size - end - assert_select "div" do - assert_select "div#?", /\d+/ do |elements| - assert_equal 2, elements.size - assert_select "#1" - assert_select "#2" - end - end - end - - def test_nested_assert_select - render_html %Q{
    foo
    foo
    } - assert_select "div" do |elements| - assert_equal 2, elements.size - assert_select elements[0], "#1" - assert_select elements[1], "#2" - end - assert_select "div" do - assert_select "div" do |elements| - assert_equal 2, elements.size - # Testing in a group is one thing - assert_select "#1,#2" - # Testing individually is another. - assert_select "#1" - assert_select "#2" - assert_select "#3", false - end - end - - assert_failure(/Expected at least 1 element matching \"#4\", found 0\./) do - assert_select "div" do - assert_select "#4" - end - end - end - - def test_assert_select_text_match - render_html %Q{
    foo
    bar
    } - assert_select "div" do - assert_nothing_raised { assert_select "div", "foo" } - assert_nothing_raised { assert_select "div", "bar" } - assert_nothing_raised { assert_select "div", /\w*/ } - assert_nothing_raised { assert_select "div", :text => /\w*/, :count=>2 } - assert_raise(Assertion) { assert_select "div", :text=>"foo", :count=>2 } - assert_nothing_raised { assert_select "div", :html=>"bar" } - assert_nothing_raised { assert_select "div", :html=>"bar" } - assert_nothing_raised { assert_select "div", :html=>/\w*/ } - assert_nothing_raised { assert_select "div", :html=>/\w*/, :count=>2 } - assert_raise(Assertion) { assert_select "div", :html=>"foo", :count=>2 } - end - end - - # With single result. - def test_assert_select_from_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
    foo
    \n
    foo
    " - end - assert_select "div" do |elements| - assert elements.size == 2 - assert_select "#1" - assert_select "#2" - end - assert_select "div#?", /\d+/ do |elements| - assert_select "#1" - assert_select "#2" - end - end - - # With multiple results. - def test_assert_select_from_rjs_with_multiple_results - render_rjs do |page| - page.replace_html "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - end - assert_select "div" do |elements| - assert elements.size == 2 - assert_select "#1" - assert_select "#2" - end - end - - def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments - render_rjs do |page| - page.insert_html :top, "test1", "
    foo
    " - page.insert_html :bottom, "test2", "
    foo
    " - end - assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"} - end - - def test_elect_with_xml_namespace_attributes - render_html %Q{} - assert_nothing_raised { assert_select "link[xlink:href=http://nowhere.com]" } - end - - # - # Test css_select. - # - - def test_css_select - render_html %Q{
    } - assert_equal 2, css_select("div").size - assert_equal 0, css_select("p").size - end - - def test_nested_css_select - render_html %Q{
    foo
    foo
    } - assert_select "div#?", /\d+/ do |elements| - assert_equal 1, css_select(elements[0], "div").size - assert_equal 1, css_select(elements[1], "div").size - end - assert_select "div" do - assert_equal 2, css_select("div").size - css_select("div").each do |element| - # Testing as a group is one thing - assert !css_select("#1,#2").empty? - # Testing individually is another - assert !css_select("#1").empty? - assert !css_select("#2").empty? - end - end - end - - # With one result. - def test_css_select_from_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
    foo
    \n
    foo
    " - end - assert_equal 2, css_select("div").size - assert_equal 1, css_select("#1").size - assert_equal 1, css_select("#2").size - end - - # With multiple results. - def test_css_select_from_rjs_with_multiple_results - render_rjs do |page| - page.replace_html "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - end - - assert_equal 2, css_select("div").size - assert_equal 1, css_select("#1").size - assert_equal 1, css_select("#2").size - end - - # - # Test assert_select_rjs. - # - - # Test that we can pick up all statements in the result. - def test_assert_select_rjs_picks_up_all_statements - render_rjs do |page| - page.replace "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - - found = false - assert_select_rjs do - assert_select "#1" - assert_select "#2" - assert_select "#3" - found = true - end - assert found - end - - # Test that we fail if there is nothing to pick. - def test_assert_select_rjs_fails_if_nothing_to_pick - render_rjs { } - assert_raise(Assertion) { assert_select_rjs } - end - - def test_assert_select_rjs_with_unicode - # Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly. - render_rjs do |page| - page.replace "test", "
    \343\203\201\343\202\261\343\203\203\343\203\210
    " - end - assert_select_rjs do - str = "#1" - assert_select str, :text => "\343\203\201\343\202\261\343\203\203\343\203\210" - assert_select str, "\343\203\201\343\202\261\343\203\203\343\203\210" - if str.respond_to?(:force_encoding) - str.force_encoding(Encoding::UTF_8) - assert_select str, /\343\203\201..\343\203\210/u - assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u } - else - assert_select str, Regexp.new("\343\203\201..\343\203\210",0,'U') - assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210",0,'U') } - end - end - end - - def test_assert_select_rjs_with_id - # Test that we can pick up all statements in the result. - render_rjs do |page| - page.replace "test1", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - assert_select_rjs "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs "test3" do - assert_select "div", 1 - assert_select "#3" - end - assert_raise(Assertion) { assert_select_rjs "test4" } - end - - def test_assert_select_rjs_for_replace - render_rjs do |page| - page.replace "test1", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - # Replace. - assert_select_rjs :replace do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :replace, "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_raise(Assertion) { assert_select_rjs :replace, "test2" } - # Replace HTML. - assert_select_rjs :replace_html do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :replace_html, "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" } - end - - def test_assert_select_rjs_for_chained_replace - render_rjs do |page| - page['test1'].replace "
    foo
    " - page['test2'].replace_html "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - # Replace. - assert_select_rjs :chained_replace do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :chained_replace, "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" } - # Replace HTML. - assert_select_rjs :chained_replace_html do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :chained_replace_html, "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" } - end - - # Simple remove - def test_assert_select_rjs_for_remove - render_rjs do |page| - page.remove "test1" - end - - assert_select_rjs :remove, "test1" - end - - def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.remove "test_with_typo" - end - - assert_select_rjs :remove, "test1" - - rescue Assertion - assert_equal "No RJS statement that removes 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_remove_ignores_block - render_rjs do |page| - page.remove "test1" - end - - assert_nothing_raised do - assert_select_rjs :remove, "test1" do - assert_select "p" - end - end - end - - # Simple show - def test_assert_select_rjs_for_show - render_rjs do |page| - page.show "test1" - end - - assert_select_rjs :show, "test1" - end - - def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.show "test_with_typo" - end - - assert_select_rjs :show, "test1" - - rescue Assertion - assert_equal "No RJS statement that shows 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_show_ignores_block - render_rjs do |page| - page.show "test1" - end - - assert_nothing_raised do - assert_select_rjs :show, "test1" do - assert_select "p" - end - end - end - - # Simple hide - def test_assert_select_rjs_for_hide - render_rjs do |page| - page.hide "test1" - end - - assert_select_rjs :hide, "test1" - end - - def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.hide "test_with_typo" - end - - assert_select_rjs :hide, "test1" - - rescue Assertion - assert_equal "No RJS statement that hides 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_hide_ignores_block - render_rjs do |page| - page.hide "test1" - end - - assert_nothing_raised do - assert_select_rjs :hide, "test1" do - assert_select "p" - end - end - end - - # Simple toggle - def test_assert_select_rjs_for_toggle - render_rjs do |page| - page.toggle "test1" - end - - assert_select_rjs :toggle, "test1" - end - - def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.toggle "test_with_typo" - end - - assert_select_rjs :toggle, "test1" - - rescue Assertion - assert_equal "No RJS statement that toggles 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_toggle_ignores_block - render_rjs do |page| - page.toggle "test1" - end - - assert_nothing_raised do - assert_select_rjs :toggle, "test1" do - assert_select "p" - end - end - end - - # Non-positioned insert. - def test_assert_select_rjs_for_nonpositioned_insert - render_rjs do |page| - page.replace "test1", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - assert_select_rjs :insert_html do - assert_select "div", 1 - assert_select "#3" - end - assert_select_rjs :insert_html, "test3" do - assert_select "div", 1 - assert_select "#3" - end - assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" } - end - - # Positioned insert. - def test_assert_select_rjs_for_positioned_insert - render_rjs do |page| - page.insert_html :top, "test1", "
    foo
    " - page.insert_html :bottom, "test2", "
    foo
    " - page.insert_html :before, "test3", "
    foo
    " - page.insert_html :after, "test4", "
    foo
    " - end - assert_select_rjs :insert, :top do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :insert, :bottom do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :insert, :before do - assert_select "div", 1 - assert_select "#3" - end - assert_select_rjs :insert, :after do - assert_select "div", 1 - assert_select "#4" - end - assert_select_rjs :insert_html do - assert_select "div", 4 - end - end - - def test_assert_select_rjs_raise_errors - assert_raise(ArgumentError) { assert_select_rjs(:destroy) } - assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) } - end - - # Simple selection from a single result. - def test_nested_assert_select_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
    foo
    \n
    foo
    " - end - - assert_select_rjs "test" do |elements| - assert_equal 2, elements.size - assert_select "#1" - assert_select "#2" - end - end - - # Deal with two results. - def test_nested_assert_select_rjs_with_two_results - render_rjs do |page| - page.replace_html "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - end - - assert_select_rjs "test" do |elements| - assert_equal 1, elements.size - assert_select "#1" - end - - assert_select_rjs "test2" do |elements| - assert_equal 1, elements.size - assert_select "#2" - end - end - - def test_feed_item_encoded - render_xml <<-EOF - - - - - Test 1

    - ]]> -
    -
    - - - Test 2

    - ]]> -
    -
    -
    -
    -EOF - assert_select "channel item description" do - # Test element regardless of wrapper. - assert_select_encoded do - assert_select "p", :count=>2, :text=>/Test/ - end - # Test through encoded wrapper. - assert_select_encoded do - assert_select "encoded p", :count=>2, :text=>/Test/ - end - # Use :root instead (recommended) - assert_select_encoded do - assert_select ":root p", :count=>2, :text=>/Test/ - end - # Test individually. - assert_select "description" do |elements| - assert_select_encoded elements[0] do - assert_select "p", "Test 1" - end - assert_select_encoded elements[1] do - assert_select "p", "Test 2" - end - end - end - - # Test that we only un-encode element itself. - assert_select "channel item" do - assert_select_encoded do - assert_select "p", 0 - end - end - end - - # - # Test assert_select_email - # - - def test_assert_select_email - assert_raise(Assertion) { assert_select_email {} } - AssertSelectMailer.deliver_test "

    foo

    bar

    " - assert_select_email do - assert_select "div:root" do - assert_select "p:first-child", "foo" - assert_select "p:last-child", "bar" - end - end - end - - protected - def render_html(html) - @controller.response_with = html - get :html - end - - def render_rjs(&block) - @controller.response_with &block - get :rjs - end - - def render_xml(xml) - @controller.response_with = xml - get :xml - end -end diff --git a/vendor/rails/actionpack/test/controller/base_test.rb b/vendor/rails/actionpack/test/controller/base_test.rb deleted file mode 100644 index 9523189f..00000000 --- a/vendor/rails/actionpack/test/controller/base_test.rb +++ /dev/null @@ -1,217 +0,0 @@ -require 'abstract_unit' -require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late - -# Provide some controller to run the tests on. -module Submodule - class ContainedEmptyController < ActionController::Base - end - class ContainedNonEmptyController < ActionController::Base - def public_action - render :nothing => true - end - - hide_action :hidden_action - def hidden_action - raise "Noooo!" - end - - def another_hidden_action - end - hide_action :another_hidden_action - end - class SubclassedController < ContainedNonEmptyController - hide_action :public_action # Hiding it here should not affect the superclass. - end -end -class EmptyController < ActionController::Base -end -class NonEmptyController < ActionController::Base - def public_action - end - - hide_action :hidden_action - def hidden_action - end -end - -class MethodMissingController < ActionController::Base - - hide_action :shouldnt_be_called - def shouldnt_be_called - raise "NO WAY!" - end - -protected - - def method_missing(selector) - render :text => selector.to_s - end - -end - -class DefaultUrlOptionsController < ActionController::Base - def default_url_options_action - end - - def default_url_options(options = nil) - { :host => 'www.override.com', :action => 'new', :bacon => 'chunky' } - end -end - -class ControllerClassTests < Test::Unit::TestCase - def test_controller_path - assert_equal 'empty', EmptyController.controller_path - assert_equal EmptyController.controller_path, EmptyController.new.controller_path - assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path - assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path - end - def test_controller_name - assert_equal 'empty', EmptyController.controller_name - assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name - end -end - -class ControllerInstanceTests < Test::Unit::TestCase - def setup - @empty = EmptyController.new - @contained = Submodule::ContainedEmptyController.new - @empty_controllers = [@empty, @contained, Submodule::SubclassedController.new] - - @non_empty_controllers = [NonEmptyController.new, - Submodule::ContainedNonEmptyController.new] - end - - def test_action_methods - @empty_controllers.each do |c| - hide_mocha_methods_from_controller(c) - assert_equal Set.new, c.__send__(:action_methods), "#{c.controller_path} should be empty!" - end - @non_empty_controllers.each do |c| - hide_mocha_methods_from_controller(c) - assert_equal Set.new(%w(public_action)), c.__send__(:action_methods), "#{c.controller_path} should not be empty!" - end - end - - protected - # Mocha adds some public instance methods to Object that would be - # considered actions, so explicitly hide_action them. - def hide_mocha_methods_from_controller(controller) - mocha_methods = [ - :expects, :mocha, :mocha_inspect, :reset_mocha, :stubba_object, - :stubba_method, :stubs, :verify, :__metaclass__, :__is_a__, :to_matcher, - ] - controller.class.__send__(:hide_action, *mocha_methods) - end -end - - -class PerformActionTest < ActionController::TestCase - class MockLogger - attr_reader :logged - - def initialize - @logged = [] - end - - def method_missing(method, *args) - @logged << args.first - end - end - - def use_controller(controller_class) - @controller = controller_class.new - - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @request.host = "www.nextangle.com" - - rescue_action_in_public! - end - - def test_get_on_priv_should_show_selector - use_controller MethodMissingController - get :shouldnt_be_called - assert_response :success - assert_equal 'shouldnt_be_called', @response.body - end - - def test_method_missing_is_not_an_action_name - use_controller MethodMissingController - assert ! @controller.__send__(:action_methods).include?('method_missing') - - get :method_missing - assert_response :success - assert_equal 'method_missing', @response.body - end - - def test_get_on_hidden_should_fail - use_controller NonEmptyController - get :hidden_action - assert_response 404 - - get :another_hidden_action - assert_response 404 - end - - def test_namespaced_action_should_log_module_name - use_controller Submodule::ContainedNonEmptyController - @controller.logger = MockLogger.new - get :public_action - assert_match /Processing\sSubmodule::ContainedNonEmptyController#public_action/, @controller.logger.logged[1] - end -end - -class DefaultUrlOptionsTest < ActionController::TestCase - tests DefaultUrlOptionsController - - def setup - @request.host = 'www.example.com' - rescue_action_in_public! - end - - def test_default_url_options_are_used_if_set - ActionController::Routing::Routes.draw do |map| - map.default_url_options 'default_url_options', :controller => 'default_url_options' - map.connect ':controller/:action/:id' - end - - get :default_url_options_action # Make a dummy request so that the controller is initialized properly. - - assert_equal 'http://www.override.com/default_url_options/new?bacon=chunky', @controller.url_for(:controller => 'default_url_options') - assert_equal 'http://www.override.com/default_url_options?bacon=chunky', @controller.send(:default_url_options_url) - ensure - ActionController::Routing::Routes.load! - end -end - -class EmptyUrlOptionsTest < ActionController::TestCase - tests NonEmptyController - - def setup - @request.host = 'www.example.com' - rescue_action_in_public! - end - - def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set - get :public_action - assert_equal "http://www.example.com/non_empty/public_action", @controller.url_for - end -end - -class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase - def test_named_routes_still_work - ActionController::Routing::Routes.draw do |map| - map.resources :things - end - EmptyController.send :include, ActionController::UrlWriter - - assert_equal '/things', EmptyController.new.send(:things_path) - ensure - ActionController::Routing::Routes.load! - end -end diff --git a/vendor/rails/actionpack/test/controller/benchmark_test.rb b/vendor/rails/actionpack/test/controller/benchmark_test.rb deleted file mode 100644 index f9100a23..00000000 --- a/vendor/rails/actionpack/test/controller/benchmark_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'abstract_unit' - -# Provide some static controllers. -class BenchmarkedController < ActionController::Base - def public_action - render :nothing => true - end - - def rescue_action(e) - raise e - end -end - -class BenchmarkTest < ActionController::TestCase - tests BenchmarkedController - - class MockLogger - def method_missing(*args) - end - end - - def setup - # benchmark doesn't do anything unless a logger is set - @controller.logger = MockLogger.new - @request.host = "test.actioncontroller.i" - end - - def test_with_http_1_0_request - @request.host = nil - assert_nothing_raised { get :public_action } - end -end diff --git a/vendor/rails/actionpack/test/controller/caching_test.rb b/vendor/rails/actionpack/test/controller/caching_test.rb deleted file mode 100644 index d67e31f7..00000000 --- a/vendor/rails/actionpack/test/controller/caching_test.rb +++ /dev/null @@ -1,743 +0,0 @@ -require 'fileutils' -require 'abstract_unit' -require 'active_record_unit' - -CACHE_DIR = 'test_cache' -# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed -FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR) -ActionController::Base.page_cache_directory = FILE_STORE_PATH -ActionController::Base.cache_store = :file_store, FILE_STORE_PATH - -# Force sweeper classes to load -ActionController::Caching::Sweeper -ActionController::Caching::Sweeping - -class PageCachingTestController < ActionController::Base - caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? } - caches_page :found, :not_found - - def ok - head :ok - end - - def no_content - head :no_content - end - - def found - redirect_to :action => 'ok' - end - - def not_found - head :not_found - end - - def custom_path - render :text => "Super soaker" - cache_page("Super soaker", "/index.html") - end - - def expire_custom_path - expire_page("/index.html") - head :ok - end - - def trailing_slash - render :text => "Sneak attack" - end -end - -class PageCachingTest < ActionController::TestCase - def setup - ActionController::Base.perform_caching = true - - ActionController::Routing::Routes.draw do |map| - map.main '', :controller => 'posts', :format => nil - map.formatted_posts 'posts.:format', :controller => 'posts' - map.resources :posts - map.connect ':controller/:action/:id' - end - - @request = ActionController::TestRequest.new - @request.host = 'hostname.com' - - @response = ActionController::TestResponse.new - @controller = PageCachingTestController.new - - @params = {:controller => 'posts', :action => 'index', :only_path => true, :skip_relative_url_root => true} - @rewriter = ActionController::UrlRewriter.new(@request, @params) - - FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) - FileUtils.mkdir_p(FILE_STORE_PATH) - end - - def teardown - FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) - ActionController::Routing::Routes.clear! - ActionController::Base.perform_caching = false - end - - def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route - @params[:format] = 'rss' - assert_equal '/posts.rss', @rewriter.rewrite(@params) - @params[:format] = nil - assert_equal '/', @rewriter.rewrite(@params) - end - - def test_should_cache_get_with_ok_status - get :ok - assert_response :ok - assert_page_cached :ok, "get with ok status should have been cached" - end - - def test_should_cache_with_custom_path - get :custom_path - assert File.exist?("#{FILE_STORE_PATH}/index.html") - end - - def test_should_expire_cache_with_custom_path - get :custom_path - assert File.exist?("#{FILE_STORE_PATH}/index.html") - - get :expire_custom_path - assert !File.exist?("#{FILE_STORE_PATH}/index.html") - end - - def test_should_cache_without_trailing_slash_on_url - @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash' - assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html") - end - - def test_should_cache_with_trailing_slash_on_url - @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash/' - assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html") - end - - def test_should_cache_ok_at_custom_path - @request.stubs(:path).returns("/index.html") - get :ok - assert_response :ok - assert File.exist?("#{FILE_STORE_PATH}/index.html") - end - - [:ok, :no_content, :found, :not_found].each do |status| - [:get, :post, :put, :delete].each do |method| - unless method == :get and status == :ok - define_method "test_shouldnt_cache_#{method}_with_#{status}_status" do - send(method, status) - assert_response status - assert_page_not_cached status, "#{method} with #{status} status shouldn't have been cached" - end - end - end - end - - def test_page_caching_conditional_options - get :ok, :format=>'json' - assert_page_not_cached :ok - end - - private - def assert_page_cached(action, message = "#{action} should have been cached") - assert page_cached?(action), message - end - - def assert_page_not_cached(action, message = "#{action} shouldn't have been cached") - assert !page_cached?(action), message - end - - def page_cached?(action) - File.exist? "#{FILE_STORE_PATH}/page_caching_test/#{action}.html" - end -end - -class ActionCachingTestController < ActionController::Base - caches_action :index, :redirected, :forbidden, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour - caches_action :show, :cache_path => 'http://test.host/custom/show' - caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } - caches_action :with_layout - caches_action :layout_false, :layout => false - caches_action :record_not_found, :four_oh_four, :simple_runtime_error - - layout 'talk_from_action.erb' - - def index - @cache_this = MockTime.now.to_f.to_s - render :text => @cache_this - end - - def redirected - redirect_to :action => 'index' - end - - def forbidden - render :text => "Forbidden" - response.status = "403 Forbidden" - end - - def with_layout - @cache_this = MockTime.now.to_f.to_s - render :text => @cache_this, :layout => true - end - - def record_not_found - raise ActiveRecord::RecordNotFound, "oops!" - end - - def four_oh_four - render :text => "404'd!", :status => 404 - end - - def simple_runtime_error - raise "oops!" - end - - alias_method :show, :index - alias_method :edit, :index - alias_method :destroy, :index - alias_method :layout_false, :with_layout - - def expire - expire_action :controller => 'action_caching_test', :action => 'index' - render :nothing => true - end - - def expire_xml - expire_action :controller => 'action_caching_test', :action => 'index', :format => 'xml' - render :nothing => true - end -end - -class MockTime < Time - # Let Time spicy to assure that Time.now != Time.now - def to_f - super+rand - end -end - -class ActionCachingMockController - attr_accessor :mock_url_for - attr_accessor :mock_path - - def initialize - yield self if block_given? - end - - def url_for(*args) - @mock_url_for - end - - def request - mocked_path = @mock_path - Object.new.instance_eval(<<-EVAL) - def path; '#{@mock_path}' end - def format; 'all' end - def cache_format; nil end - self - EVAL - end -end - -class ActionCacheTest < ActionController::TestCase - def setup - reset! - FileUtils.mkdir_p(FILE_STORE_PATH) - @path_class = ActionController::Caching::Actions::ActionCachePath - @mock_controller = ActionCachingMockController.new - end - - def teardown - FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) - end - - def test_simple_action_cache - get :index - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test') - reset! - - get :index - assert_equal cached_time, @response.body - end - - def test_simple_action_not_cached - get :destroy - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert !fragment_exist?('hostname.com/action_caching_test/destroy') - reset! - - get :destroy - assert_not_equal cached_time, @response.body - end - - def test_action_cache_with_layout - get :with_layout - cached_time = content_to_cache - assert_not_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test/with_layout') - reset! - - get :with_layout - assert_not_equal cached_time, @response.body - - assert_equal @response.body, read_fragment('hostname.com/action_caching_test/with_layout') - end - - def test_action_cache_with_layout_and_layout_cache_false - get :layout_false - cached_time = content_to_cache - assert_not_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test/layout_false') - reset! - - get :layout_false - assert_not_equal cached_time, @response.body - - assert_equal cached_time, read_fragment('hostname.com/action_caching_test/layout_false') - end - - def test_action_cache_conditional_options - old_use_accept_header = ActionController::Base.use_accept_header - ActionController::Base.use_accept_header = true - @request.env['HTTP_ACCEPT'] = 'application/json' - get :index - assert !fragment_exist?('hostname.com/action_caching_test') - ActionController::Base.use_accept_header = old_use_accept_header - end - - def test_action_cache_with_store_options - MockTime.expects(:now).returns(12345).once - @controller.expects(:read_fragment).with('hostname.com/action_caching_test', :expires_in => 1.hour).once - @controller.expects(:write_fragment).with('hostname.com/action_caching_test', '12345.0', :expires_in => 1.hour).once - get :index - end - - def test_action_cache_with_custom_cache_path - get :show - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert fragment_exist?('test.host/custom/show') - reset! - - get :show - assert_equal cached_time, @response.body - end - - def test_action_cache_with_custom_cache_path_in_block - get :edit - assert fragment_exist?('test.host/edit') - reset! - - get :edit, :id => 1 - assert fragment_exist?('test.host/1;edit') - end - - def test_cache_expiration - get :index - cached_time = content_to_cache - reset! - - get :index - assert_equal cached_time, @response.body - reset! - - get :expire - reset! - - get :index - new_cached_time = content_to_cache - assert_not_equal cached_time, @response.body - reset! - - get :index - assert_response :success - assert_equal new_cached_time, @response.body - end - - def test_cache_expiration_isnt_affected_by_request_format - get :index - cached_time = content_to_cache - reset! - - @request.set_REQUEST_URI "/action_caching_test/expire.xml" - get :expire, :format => :xml - reset! - - get :index - new_cached_time = content_to_cache - assert_not_equal cached_time, @response.body - end - - def test_cache_is_scoped_by_subdomain - @request.host = 'jamis.hostname.com' - get :index - jamis_cache = content_to_cache - - reset! - - @request.host = 'david.hostname.com' - get :index - david_cache = content_to_cache - assert_not_equal jamis_cache, @response.body - - reset! - - @request.host = 'jamis.hostname.com' - get :index - assert_equal jamis_cache, @response.body - - reset! - - @request.host = 'david.hostname.com' - get :index - assert_equal david_cache, @response.body - end - - def test_redirect_is_not_cached - get :redirected - assert_response :redirect - reset! - - get :redirected - assert_response :redirect - end - - def test_forbidden_is_not_cached - get :forbidden - assert_response :forbidden - reset! - - get :forbidden - assert_response :forbidden - end - - def test_xml_version_of_resource_is_treated_as_different_cache - with_routing do |set| - set.draw do |map| - map.connect ':controller/:action.:format' - map.connect ':controller/:action' - end - - get :index, :format => 'xml' - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test/index.xml') - reset! - - get :index, :format => 'xml' - assert_equal cached_time, @response.body - assert_equal 'application/xml', @response.content_type - reset! - - get :expire_xml - reset! - - get :index, :format => 'xml' - assert_not_equal cached_time, @response.body - end - end - - def test_correct_content_type_is_returned_for_cache_hit - # run it twice to cache it the first time - get :index, :id => 'content-type.xml' - get :index, :id => 'content-type.xml' - assert_equal 'application/xml', @response.content_type - end - - def test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key - # run it twice to cache it the first time - get :show, :format => 'xml' - get :show, :format => 'xml' - assert_equal 'application/xml', @response.content_type - end - - def test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key_from_proc - # run it twice to cache it the first time - get :edit, :id => 1, :format => 'xml' - get :edit, :id => 1, :format => 'xml' - assert_equal 'application/xml', @response.content_type - end - - def test_empty_path_is_normalized - @mock_controller.mock_url_for = 'http://example.org/' - @mock_controller.mock_path = '/' - - assert_equal 'example.org/index', @path_class.path_for(@mock_controller, {}) - end - - def test_file_extensions - get :index, :id => 'kitten.jpg' - get :index, :id => 'kitten.jpg' - - assert_response :success - end - - def test_record_not_found_returns_404_for_multiple_requests - get :record_not_found - assert_response 404 - get :record_not_found - assert_response 404 - end - - def test_four_oh_four_returns_404_for_multiple_requests - get :four_oh_four - assert_response 404 - get :four_oh_four - assert_response 404 - end - - def test_simple_runtime_error_returns_500_for_multiple_requests - get :simple_runtime_error - assert_response 500 - get :simple_runtime_error - assert_response 500 - end - - private - def content_to_cache - assigns(:cache_this) - end - - def reset! - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = ActionCachingTestController.new - @request.host = 'hostname.com' - end - - def fragment_exist?(path) - @controller.fragment_exist?(path) - end - - def read_fragment(path) - @controller.read_fragment(path) - end -end - -class FragmentCachingTestController < ActionController::Base - def some_action; end; -end - -class FragmentCachingTest < ActionController::TestCase - def setup - ActionController::Base.perform_caching = true - @store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.cache_store = @store - @controller = FragmentCachingTestController.new - @params = {:controller => 'posts', :action => 'index'} - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller.params = @params - @controller.request = @request - @controller.response = @response - @controller.send(:initialize_current_url) - @controller.send(:initialize_template_class, @response) - @controller.send(:assign_shortcuts, @request, @response) - end - - def test_fragment_cache_key - assert_equal 'views/what a key', @controller.fragment_cache_key('what a key') - assert_equal "views/test.host/fragment_caching_test/some_action", - @controller.fragment_cache_key(:controller => 'fragment_caching_test',:action => 'some_action') - end - - def test_read_fragment_with_caching_enabled - @store.write('views/name', 'value') - assert_equal 'value', @controller.read_fragment('name') - end - - def test_read_fragment_with_caching_disabled - ActionController::Base.perform_caching = false - @store.write('views/name', 'value') - assert_nil @controller.read_fragment('name') - end - - def test_fragment_exist_with_caching_enabled - @store.write('views/name', 'value') - assert @controller.fragment_exist?('name') - assert !@controller.fragment_exist?('other_name') - end - - def test_fragment_exist_with_caching_disabled - ActionController::Base.perform_caching = false - @store.write('views/name', 'value') - assert !@controller.fragment_exist?('name') - assert !@controller.fragment_exist?('other_name') - end - - def test_write_fragment_with_caching_enabled - assert_nil @store.read('views/name') - assert_equal 'value', @controller.write_fragment('name', 'value') - assert_equal 'value', @store.read('views/name') - end - - def test_write_fragment_with_caching_disabled - assert_nil @store.read('views/name') - ActionController::Base.perform_caching = false - assert_equal 'value', @controller.write_fragment('name', 'value') - assert_nil @store.read('views/name') - end - - def test_expire_fragment_with_simple_key - @store.write('views/name', 'value') - @controller.expire_fragment 'name' - assert_nil @store.read('views/name') - end - - def test_expire_fragment_with_regexp - @store.write('views/name', 'value') - @store.write('views/another_name', 'another_value') - @store.write('views/primalgrasp', 'will not expire ;-)') - - @controller.expire_fragment /name/ - - assert_nil @store.read('views/name') - assert_nil @store.read('views/another_name') - assert_equal 'will not expire ;-)', @store.read('views/primalgrasp') - end - - def test_fragment_for_with_disabled_caching - ActionController::Base.perform_caching = false - - @store.write('views/expensive', 'fragment content') - fragment_computed = false - - buffer = 'generated till now -> '.html_safe - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } - - assert fragment_computed - assert_equal 'generated till now -> ', buffer - end - - def test_fragment_for - @store.write('views/expensive', 'fragment content') - fragment_computed = false - - buffer = 'generated till now -> '.html_safe - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } - - assert !fragment_computed - assert_equal 'generated till now -> fragment content', buffer - end - - def test_html_safety - assert_nil @store.read('views/name') - content = 'value'.html_safe - assert_equal content, @controller.write_fragment('name', content) - - cached = @store.read('views/name') - assert_equal content, cached - assert_equal String, cached.class - - html_safe = @controller.read_fragment('name') - assert_equal content, html_safe - assert html_safe.html_safe? - end -end - -class FunctionalCachingController < ActionController::Base - def fragment_cached - end - - def html_fragment_cached_with_partial - respond_to do |format| - format.html - end - end - - def js_fragment_cached_with_partial - respond_to do |format| - format.js - end - end - - def formatted_fragment_cached - respond_to do |format| - format.html - format.xml - format.js - end - end - - def rescue_action(e) - raise e - end -end - -class FunctionalFragmentCachingTest < ActionController::TestCase - def setup - ActionController::Base.perform_caching = true - @store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.cache_store = @store - @controller = FunctionalCachingController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_fragment_caching - get :fragment_cached - assert_response :success - expected_body = <<-CACHED -Hello -This bit's fragment cached -CACHED - assert_equal expected_body, @response.body - - assert_equal "This bit's fragment cached", @store.read('views/test.host/functional_caching/fragment_cached') - end - - def test_fragment_caching_in_partials - get :html_fragment_cached_with_partial - assert_response :success - assert_match /Fragment caching in a partial/, @response.body - assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial') - end - - def test_render_inline_before_fragment_caching - get :inline_fragment_cached - assert_response :success - assert_match /Some inline content/, @response.body - assert_match /Some cached content/, @response.body - assert_match "Some cached content", @store.read('views/test.host/functional_caching/inline_fragment_cached') - end - - def test_fragment_caching_in_rjs_partials - xhr :get, :js_fragment_cached_with_partial - assert_response :success - assert_match /Fragment caching in a partial/, @response.body - assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial') - end - - def test_html_formatted_fragment_caching - get :formatted_fragment_cached, :format => "html" - assert_response :success - expected_body = "\n

    ERB

    \n" - - assert_equal expected_body, @response.body - - assert_equal "

    ERB

    ", @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end - - def test_xml_formatted_fragment_caching - get :formatted_fragment_cached, :format => "xml" - assert_response :success - expected_body = "\n

    Builder

    \n\n" - - assert_equal expected_body, @response.body - - assert_equal "

    Builder

    \n", @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end - - def test_js_formatted_fragment_caching - get :formatted_fragment_cached, :format => "js" - assert_response :success - expected_body = %(title = "Hey";\n$("element_1").visualEffect("highlight");\n) + - %($("element_2").visualEffect("highlight");\nfooter = "Bye";) - assert_equal expected_body, @response.body - - assert_equal ['$("element_1").visualEffect("highlight");', '$("element_2").visualEffect("highlight");'], - @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end -end diff --git a/vendor/rails/actionpack/test/controller/capture_test.rb b/vendor/rails/actionpack/test/controller/capture_test.rb deleted file mode 100644 index 56e37018..00000000 --- a/vendor/rails/actionpack/test/controller/capture_test.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'abstract_unit' - -class CaptureController < ActionController::Base - def self.controller_name; "test"; end - def self.controller_path; "test"; end - - def content_for - render :layout => "talk_from_action" - end - - def content_for_with_parameter - render :layout => "talk_from_action" - end - - def content_for_concatenated - render :layout => "talk_from_action" - end - - def non_erb_block_content_for - render :layout => "talk_from_action" - end - - def rescue_action(e) raise end -end - -class CaptureTest < ActionController::TestCase - tests CaptureController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request.host = "www.nextangle.com" - end - - def test_simple_capture - get :capturing - assert_equal "

    Dreamy days

    ", @response.body.strip - end - - def test_content_for - get :content_for - assert_equal expected_content_for_output, @response.body - end - - def test_should_concatentate_content_for - get :content_for_concatenated - assert_equal expected_content_for_output, @response.body - end - - def test_should_set_content_for_with_parameter - get :content_for_with_parameter - assert_equal expected_content_for_output, @response.body - end - - def test_non_erb_block_content_for - get :non_erb_block_content_for - assert_equal expected_content_for_output, @response.body - end - - private - def expected_content_for_output - "Putting stuff in the title!\n\nGreat stuff!" - end -end diff --git a/vendor/rails/actionpack/test/controller/content_type_test.rb b/vendor/rails/actionpack/test/controller/content_type_test.rb deleted file mode 100644 index 852fbfaa..00000000 --- a/vendor/rails/actionpack/test/controller/content_type_test.rb +++ /dev/null @@ -1,178 +0,0 @@ -require 'abstract_unit' - -class ContentTypeController < ActionController::Base - def render_content_type_from_body - response.content_type = Mime::RSS - render :text => "hello world!" - end - - def render_defaults - render :text => "hello world!" - end - - def render_content_type_from_render - render :text => "hello world!", :content_type => Mime::RSS - end - - def render_charset_from_body - response.charset = "utf-16" - render :text => "hello world!" - end - - def render_nil_charset_from_body - response.charset = nil - render :text => "hello world!" - end - - def render_default_for_rhtml - end - - def render_default_for_rxml - end - - def render_default_for_rjs - end - - def render_change_for_rxml - response.content_type = Mime::HTML - render :action => "render_default_for_rxml" - end - - def render_default_content_types_for_respond_to - respond_to do |format| - format.html { render :text => "hello world!" } - format.xml { render :action => "render_default_content_types_for_respond_to.rhtml" } - format.js { render :text => "hello world!" } - format.rss { render :text => "hello world!", :content_type => Mime::XML } - end - end - - def render_content_type_from_user_input - response.content_type= params[:hello] - render :text=>"hello" - end - - def rescue_action(e) raise end -end - -class ContentTypeTest < ActionController::TestCase - tests ContentTypeController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - end - - def test_render_defaults - get :render_defaults - assert_equal "utf-8", @response.charset - assert_equal Mime::HTML, @response.content_type - end - - def test_render_changed_charset_default - ContentTypeController.default_charset = "utf-16" - get :render_defaults - assert_equal "utf-16", @response.charset - assert_equal Mime::HTML, @response.content_type - ContentTypeController.default_charset = "utf-8" - end - - def test_content_type_from_body - get :render_content_type_from_body - assert_equal "application/rss+xml", @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_content_type_from_render - get :render_content_type_from_render - assert_equal "application/rss+xml", @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_charset_from_body - get :render_charset_from_body - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-16", @response.charset - end - - def test_nil_charset_from_body - get :render_nil_charset_from_body - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-8", @response.charset, @response.headers.inspect - end - - def test_nil_default_for_rhtml - ContentTypeController.default_charset = nil - get :render_default_for_rhtml - assert_equal Mime::HTML, @response.content_type - assert_nil @response.charset, @response.headers.inspect - ensure - ContentTypeController.default_charset = "utf-8" - end - - def test_default_for_rhtml - get :render_default_for_rhtml - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_default_for_rxml - get :render_default_for_rxml - assert_equal Mime::XML, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_default_for_rjs - xhr :post, :render_default_for_rjs - assert_equal Mime::JS, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_change_for_rxml - get :render_change_for_rxml - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_user_supplied_value - get :render_content_type_from_user_input, :hello=>"hello/world\r\nAttack: true" - assert_equal "hello/world%0D%0AAttack: true", @response.content_type - end -end - -class AcceptBasedContentTypeTest < ActionController::TestCase - - tests ContentTypeController - - def setup - ActionController::Base.use_accept_header = true - end - - def teardown - ActionController::Base.use_accept_header = false - end - - - def test_render_default_content_types_for_respond_to - @request.accept = Mime::HTML.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::HTML, @response.content_type - - @request.accept = Mime::JS.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::JS, @response.content_type - end - - def test_render_default_content_types_for_respond_to_with_template - @request.accept = Mime::XML.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::XML, @response.content_type - end - - def test_render_default_content_types_for_respond_to_with_overwrite - @request.accept = Mime::RSS.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::XML, @response.content_type - end -end diff --git a/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb b/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb b/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb b/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/actionpack/test/controller/cookie_test.rb b/vendor/rails/actionpack/test/controller/cookie_test.rb deleted file mode 100644 index f517fdfe..00000000 --- a/vendor/rails/actionpack/test/controller/cookie_test.rb +++ /dev/null @@ -1,208 +0,0 @@ -require 'abstract_unit' - -class CookieTest < ActionController::TestCase - class TestController < ActionController::Base - self.cookie_verifier_secret = "thisISverySECRET123" - - def authenticate - cookies["user_name"] = "david" - end - - def set_with_with_escapable_characters - cookies["that & guy"] = "foo & bar => baz" - end - - def authenticate_for_fourteen_days - cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } - end - - def authenticate_for_fourteen_days_with_symbols - cookies[:user_name] = { :value => "david", :expires => Time.utc(2005, 10, 10,5) } - end - - def set_multiple_cookies - cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } - cookies["login"] = "XJ-122" - end - - def access_frozen_cookies - cookies["will"] = "work" - end - - def logout - cookies.delete("user_name") - end - - def delete_cookie_with_path - cookies.delete("user_name", :path => '/beaten') - render :text => "hello world" - end - - def authenticate_with_http_only - cookies["user_name"] = { :value => "david", :httponly => true } - end - - def authenticate_with_secure - cookies["user_name"] = { :value => "david", :secure => true } - end - - def set_permanent_cookie - cookies.permanent[:user_name] = "Jamie" - end - - def set_signed_cookie - cookies.signed[:user_id] = 45 - end - - def set_permanent_signed_cookie - cookies.permanent.signed[:remember_me] = 100 - end - - def rescue_action(e) - raise unless ActionView::MissingTemplate # No templates here, and we don't care about the output - end - end - - tests TestController - - def setup - @request.host = "www.nextangle.com" - end - - def test_setting_cookie - get :authenticate - assert_equal ["user_name=david; path=/"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_with_escapable_characters - get :set_with_with_escapable_characters - assert_equal ["that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/"], @response.headers["Set-Cookie"] - assert_equal({"that & guy" => "foo & bar => baz"}, @response.cookies) - end - - def test_setting_cookie_for_fourteen_days - get :authenticate_for_fourteen_days - assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_for_fourteen_days_with_symbols - get :authenticate_for_fourteen_days_with_symbols - assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_with_http_only - get :authenticate_with_http_only - assert_equal ["user_name=david; path=/; HttpOnly"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_with_secure - @request.env["HTTPS"] = "on" - get :authenticate_with_secure - assert_equal ["user_name=david; path=/; secure"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_with_secure_in_development - with_environment(:development) do - get :authenticate_with_secure - assert_equal ["user_name=david; path=/; secure"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - end - - def test_not_setting_cookie_with_secure - get :authenticate_with_secure - assert_not_equal ["user_name=david; path=/; secure"], @response.headers["Set-Cookie"] - assert_not_equal({"user_name" => "david"}, @response.cookies) - end - - def test_multiple_cookies - get :set_multiple_cookies - assert_equal 2, @response.cookies.size - assert_equal "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT", @response.headers["Set-Cookie"][0] - assert_equal "login=XJ-122; path=/", @response.headers["Set-Cookie"][1] - assert_equal({"login" => "XJ-122", "user_name" => "david"}, @response.cookies) - end - - def test_setting_test_cookie - assert_nothing_raised { get :access_frozen_cookies } - end - - def test_expiring_cookie - get :logout - assert_equal ["user_name=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => nil}, @response.cookies) - end - - def test_cookiejar_accessor - @request.cookies["user_name"] = "david" - @controller.request = @request - jar = ActionController::CookieJar.new(@controller) - assert_equal "david", jar["user_name"] - assert_equal nil, jar["something_else"] - end - - def test_cookiejar_accessor_with_array_value - @request.cookies["pages"] = %w{1 2 3} - @controller.request = @request - jar = ActionController::CookieJar.new(@controller) - assert_equal %w{1 2 3}, jar["pages"] - end - - def test_cookiejar_delete_removes_item_and_returns_its_value - @request.cookies["user_name"] = "david" - @controller.response = @response - jar = ActionController::CookieJar.new(@controller) - assert_equal "david", jar.delete("user_name") - end - - def test_delete_cookie_with_path - get :delete_cookie_with_path - assert_equal ["user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"] - end - - def test_cookies_persist_throughout_request - get :authenticate - cookies = @controller.send(:cookies) - assert_equal 'david', cookies['user_name'] - end - - def test_permanent_cookie - get :set_permanent_cookie - assert_match /Jamie/, @response.headers["Set-Cookie"].first - assert_match %r(#{20.years.from_now.year}), @response.headers["Set-Cookie"].first - end - - def test_signed_cookie - get :set_signed_cookie - assert_equal 45, @controller.send(:cookies).signed[:user_id] - end - - def test_accessing_nonexistant_signed_cookie_should_not_raise_an_invalid_signature - get :set_signed_cookie - assert_nil @controller.send(:cookies).signed[:non_existant_attribute] - end - - def test_permanent_signed_cookie - get :set_permanent_signed_cookie - assert_match %r(#{20.years.from_now.year}), @response.headers["Set-Cookie"].first - assert_equal 100, @controller.send(:cookies).signed[:remember_me] - end - - private - def with_environment(enviroment) - old_rails = Object.const_get(:Rails) rescue nil - mod = Object.const_set(:Rails, Module.new) - (class << mod; self; end).instance_eval do - define_method(:env) { @_env ||= ActiveSupport::StringInquirer.new(enviroment.to_s) } - end - yield - ensure - Object.module_eval { remove_const(:Rails) } if defined?(Rails) - Object.const_set(:Rails, old_rails) if old_rails - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb b/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb deleted file mode 100644 index dd69a630..00000000 --- a/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'abstract_unit' - -class DeprecatedBaseMethodsTest < ActionController::TestCase - class Target < ActionController::Base - def home_url(greeting) - "http://example.com/#{greeting}" - end - - def raises_name_error - this_method_doesnt_exist - end - - def rescue_action(e) raise e end - end - - tests Target - - def test_log_error_silences_deprecation_warnings - get :raises_name_error - rescue => e - assert_not_deprecated { @controller.send :log_error, e } - end - - if defined? Test::Unit::Error - def test_assertion_failed_error_silences_deprecation_warnings - get :raises_name_error - rescue => e - error = Test::Unit::Error.new('testing ur doodz', e) - assert_not_deprecated { error.message } - end - end -end diff --git a/vendor/rails/actionpack/test/controller/dispatcher_test.rb b/vendor/rails/actionpack/test/controller/dispatcher_test.rb deleted file mode 100644 index 61e70070..00000000 --- a/vendor/rails/actionpack/test/controller/dispatcher_test.rb +++ /dev/null @@ -1,144 +0,0 @@ -require 'abstract_unit' - -class DispatcherTest < Test::Unit::TestCase - Dispatcher = ActionController::Dispatcher - Reloader = ActionController::Reloader - - def setup - ENV['REQUEST_METHOD'] = 'GET' - reset_dispatcher - Dispatcher.stubs(:require_dependency) - end - - def teardown - ENV.delete 'REQUEST_METHOD' - reset_dispatcher - end - - def test_clears_dependencies_after_dispatch_if_in_loading_mode - ActiveSupport::Dependencies.expects(:clear).once - # Close the response so dependencies kicks in - dispatch(false).last.close - end - - def test_reloads_routes_before_dispatch_if_in_loading_mode - ActionController::Routing::Routes.expects(:reload).once - dispatch(false) - end - - def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode - ActionController::Routing::Routes.expects(:reload).never - ActiveSupport::Dependencies.expects(:clear).never - - dispatch - end - - def test_builds_middleware_stack_only_during_initialization_if_not_in_loading_mode - dispatcher = create_dispatcher - assert_not_nil dispatcher.instance_variable_get(:"@app") - dispatcher.instance_variable_set(:"@app", lambda { |env| }) - dispatcher.expects(:build_middleware_stack).never - dispatcher.call(nil) - dispatcher.call(nil) - end - - def test_rebuilds_middleware_stack_on_every_request_if_in_loading_mode - dispatcher = create_dispatcher(false) - dispatcher.instance_variable_set(:"@app", lambda { |env| }) - dispatcher.expects(:build_middleware_stack).twice - dispatcher.call(nil) - Reloader.default_lock.unlock - dispatcher.call(nil) - end - - def test_doesnt_wrap_call_in_reloader_if_not_in_loading_mode - Reloader.expects(:run).never - dispatch - end - - def test_wraps_call_in_reloader_if_in_loading_mode - Reloader.expects(:run).once - dispatch(false) - end - - # Stub out dispatch error logger - class << Dispatcher - def log_failsafe_exception(status, exception); end - end - - def test_failsafe_response - Dispatcher.any_instance.expects(:dispatch).raises('b00m') - ActionController::Failsafe.any_instance.expects(:log_failsafe_exception) - - response = nil - assert_nothing_raised do - response = dispatch - end - assert_equal 3, response.size - assert_equal 500, response[0] - assert_equal({"Content-Type" => "text/html"}, response[1]) - assert_match /500 Internal Server Error/, response[2].join - end - - def test_prepare_callbacks - a = b = c = nil - Dispatcher.to_prepare { |*args| a = b = c = 1 } - Dispatcher.to_prepare { |*args| b = c = 2 } - Dispatcher.to_prepare { |*args| c = 3 } - - # Ensure to_prepare callbacks are not run when defined - assert_nil a || b || c - - # Run callbacks - Dispatcher.run_prepare_callbacks - - assert_equal 1, a - assert_equal 2, b - assert_equal 3, c - - # Make sure they are only run once - a = b = c = nil - dispatch - assert_nil a || b || c - end - - def test_to_prepare_with_identifier_replaces - a = b = nil - Dispatcher.to_prepare(:unique_id) { |*args| a = b = 1 } - Dispatcher.to_prepare(:unique_id) { |*args| a = 2 } - - Dispatcher.run_prepare_callbacks - assert_equal 2, a - assert_equal nil, b - end - - private - def dispatch(cache_classes = true) - ActionController::Routing::RouteSet.any_instance.stubs(:call).returns([200, {}, 'response']) - Dispatcher.define_dispatcher_callbacks(cache_classes) - Dispatcher.new.call({'rack.input' => StringIO.new('')}) - end - - def create_dispatcher(cache_classes = true) - Dispatcher.define_dispatcher_callbacks(cache_classes) - Dispatcher.new - end - - def reset_dispatcher - Dispatcher.middleware = ActionController::MiddlewareStack.new do |middleware| - middlewares = File.expand_path(File.join(File.dirname(__FILE__), "../../lib/action_controller/middlewares.rb")) - middleware.instance_eval(File.read(middlewares)) - end - - # Clear callbacks as they are redefined by Dispatcher#define_dispatcher_callbacks - Dispatcher.instance_variable_set("@prepare_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - Dispatcher.instance_variable_set("@before_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - Dispatcher.instance_variable_set("@after_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - - Dispatcher.define_dispatcher_callbacks(true) - end - - def assert_subclasses(howmany, klass, message = klass.subclasses.inspect) - assert_equal howmany, klass.subclasses.size, message - end -end diff --git a/vendor/rails/actionpack/test/controller/dom_assertions_test.rb b/vendor/rails/actionpack/test/controller/dom_assertions_test.rb deleted file mode 100644 index deddc442..00000000 --- a/vendor/rails/actionpack/test/controller/dom_assertions_test.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'abstract_unit' - -class DomAssertionsTest < ActionView::TestCase - def setup - super - @html_only = '
    • foo
    • bar
    ' - @html_with_meaningless_whitespace = %{ -
      -
    • \tfoo
    • -
    • - bar -
    • -
    - } - @more_html_with_meaningless_whitespace = %{
      - -
    • foo
    • - -
    • bar
    } - end - - test "assert_dom_equal strips meaningless whitespace from expected string" do - assert_dom_equal @html_with_meaningless_whitespace, @html_only - end - - test "assert_dom_equal strips meaningless whitespace from actual string" do - assert_dom_equal @html_only, @html_with_meaningless_whitespace - end - - test "assert_dom_equal strips meaningless whitespace from both expected and actual strings" do - assert_dom_equal @more_html_with_meaningless_whitespace, @html_with_meaningless_whitespace - end - - test "assert_dom_not_equal strips meaningless whitespace from expected string" do - assert_assertion_fails { assert_dom_not_equal @html_with_meaningless_whitespace, @html_only } - end - - test "assert_dom_not_equal strips meaningless whitespace from actual string" do - assert_assertion_fails { assert_dom_not_equal @html_only, @html_with_meaningless_whitespace } - end - - test "assert_dom_not_equal strips meaningless whitespace from both expected and actual strings" do - assert_assertion_fails do - assert_dom_not_equal @more_html_with_meaningless_whitespace, @html_with_meaningless_whitespace - end - end - - private - - def assert_assertion_fails - assert_raise(ActiveSupport::TestCase::Assertion) { yield } - end -end diff --git a/vendor/rails/actionpack/test/controller/failsafe_test.rb b/vendor/rails/actionpack/test/controller/failsafe_test.rb deleted file mode 100644 index 9008f645..00000000 --- a/vendor/rails/actionpack/test/controller/failsafe_test.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'abstract_unit' -require 'stringio' -require 'logger' - -class FailsafeTest < ActionController::TestCase - FIXTURE_PUBLIC = "#{File.dirname(__FILE__)}/../fixtures/failsafe".freeze - - def setup - @old_error_file_path = ActionController::Failsafe.error_file_path - ActionController::Failsafe.error_file_path = FIXTURE_PUBLIC - @app = mock - @log_io = StringIO.new - @logger = Logger.new(@log_io) - @failsafe = ActionController::Failsafe.new(@app) - @failsafe.stubs(:failsafe_logger).returns(@logger) - end - - def teardown - ActionController::Failsafe.error_file_path = @old_error_file_path - end - - def app_will_raise_error! - @app.expects(:call).then.raises(RuntimeError.new("Printer on fire")) - end - - def test_calls_app_and_returns_its_return_value - @app.expects(:call).returns([200, { "Content-Type" => "text/html" }, "ok"]) - assert_equal [200, { "Content-Type" => "text/html" }, "ok"], @failsafe.call({}) - end - - def test_writes_to_log_file_on_exception - app_will_raise_error! - @failsafe.call({}) - assert_match /Printer on fire/, @log_io.string # Logs exception message. - assert_match /failsafe_test\.rb/, @log_io.string # Logs backtrace. - end - - def test_returns_500_internal_server_error_on_exception - app_will_raise_error! - response = @failsafe.call({}) - assert_equal 3, response.size # It is a valid Rack response. - assert_equal 500, response[0] # Status is 500. - end - - def test_renders_error_page_file_with_erb - app_will_raise_error! - response = @failsafe.call({}) - assert_equal 500, response[0] - assert_equal "hello my world", response[2].join - end - - def test_returns_a_default_message_if_erb_rendering_failed - app_will_raise_error! - @failsafe.expects(:render_template).raises(RuntimeError.new("Harddisk is crashing")) - response = @failsafe.call({}) - assert_equal 500, response[0] - assert_match /500 Internal Server Error/, response[2].join - assert_match %r(please read this web application's log file), response[2].join - end -end diff --git a/vendor/rails/actionpack/test/controller/fake_controllers.rb b/vendor/rails/actionpack/test/controller/fake_controllers.rb deleted file mode 100644 index 75c114c1..00000000 --- a/vendor/rails/actionpack/test/controller/fake_controllers.rb +++ /dev/null @@ -1,33 +0,0 @@ -class << Object; alias_method :const_available?, :const_defined?; end - -class ContentController < Class.new(ActionController::Base) -end -class NotAController -end -module Admin - class << self; alias_method :const_available?, :const_defined?; end - class UserController < Class.new(ActionController::Base); end - class NewsFeedController < Class.new(ActionController::Base); end -end - -# For speed test -class SpeedController < ActionController::Base; end -class SearchController < SpeedController; end -class VideosController < SpeedController; end -class VideoFileController < SpeedController; end -class VideoSharesController < SpeedController; end -class VideoAbusesController < SpeedController; end -class VideoUploadsController < SpeedController; end -class VideoVisitsController < SpeedController; end -class UsersController < SpeedController; end -class SettingsController < SpeedController; end -class ChannelsController < SpeedController; end -class ChannelVideosController < SpeedController; end -class SessionsController < SpeedController; end -class LostPasswordsController < SpeedController; end -class PagesController < SpeedController; end - -ActionController::Routing::Routes.draw do |map| - map.route_one 'route_one', :controller => 'elsewhere', :action => 'flash_me' - map.connect ':controller/:action/:id' -end diff --git a/vendor/rails/actionpack/test/controller/fake_models.rb b/vendor/rails/actionpack/test/controller/fake_models.rb deleted file mode 100644 index 0b30c79b..00000000 --- a/vendor/rails/actionpack/test/controller/fake_models.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Customer < Struct.new(:name, :id) - def to_param - id.to_s - end -end - -class BadCustomer < Customer -end - -class GoodCustomer < Customer -end - -module Quiz - class Question < Struct.new(:name, :id) - def to_param - id.to_s - end - end -end diff --git a/vendor/rails/actionpack/test/controller/filter_params_test.rb b/vendor/rails/actionpack/test/controller/filter_params_test.rb deleted file mode 100644 index 670edc15..00000000 --- a/vendor/rails/actionpack/test/controller/filter_params_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'abstract_unit' - -class FilterParamController < ActionController::Base -end - -class FilterParamTest < Test::Unit::TestCase - def setup - @controller = FilterParamController.new - end - - def test_filter_parameters - assert FilterParamController.respond_to?(:filter_parameter_logging) - assert !@controller.respond_to?(:filter_parameters) - - FilterParamController.filter_parameter_logging - assert @controller.respond_to?(:filter_parameters) - - test_hashes = [[{},{},[]], - [{'foo'=>nil},{'foo'=>nil},[]], - [{'foo'=>'bar'},{'foo'=>'bar'},[]], - [{'foo'=>1},{'foo'=>1},[]], - [{'foo'=>'bar'},{'foo'=>'bar'},%w'food'], - [{'foo'=>'bar'},{'foo'=>'[FILTERED]'},%w'foo'], - [{'foo'=>'bar', 'bar'=>'foo'},{'foo'=>'[FILTERED]', 'bar'=>'foo'},%w'foo baz'], - [{'foo'=>'bar', 'baz'=>'foo'},{'foo'=>'[FILTERED]', 'baz'=>'[FILTERED]'},%w'foo baz'], - [{'bar'=>{'foo'=>'bar','bar'=>'foo'}},{'bar'=>{'foo'=>'[FILTERED]','bar'=>'foo'}},%w'fo'], - [{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana'], - [{'baz'=>[{'foo'=>'baz'}]}, {'baz'=>[{'foo'=>'[FILTERED]'}]}, %w(foo)], - [{'baz'=>[{'foo'=>'baz'}, 1, 2, 3]}, {'baz'=>[{'foo'=>'[FILTERED]'}, 1, 2, 3]}, %w(foo)]] - - test_hashes.each do |before_filter, after_filter, filter_words| - FilterParamController.filter_parameter_logging(*filter_words) - assert_equal after_filter, @controller.__send__(:filter_parameters, before_filter) - - filter_words.push('blah') - FilterParamController.filter_parameter_logging(*filter_words) do |key, value| - value.reverse! if key =~ /bargain/ - end - - before_filter['barg'] = {'bargain'=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}} - after_filter['barg'] = {'bargain'=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}} - - assert_equal after_filter, @controller.__send__(:filter_parameters, before_filter) - end - end - - def test_filter_parameters_is_protected - FilterParamController.filter_parameter_logging(:foo) - assert !FilterParamController.action_methods.include?('filter_parameters') - assert_raise(NoMethodError) { @controller.filter_parameters([{'password' => '[FILTERED]'}]) } - end -end diff --git a/vendor/rails/actionpack/test/controller/filters_test.rb b/vendor/rails/actionpack/test/controller/filters_test.rb deleted file mode 100644 index e83fde23..00000000 --- a/vendor/rails/actionpack/test/controller/filters_test.rb +++ /dev/null @@ -1,885 +0,0 @@ -require 'abstract_unit' - -# FIXME: crashes Ruby 1.9 -class FilterTest < Test::Unit::TestCase - class TestController < ActionController::Base - before_filter :ensure_login - after_filter :clean_up - - def show - render :inline => "ran action" - end - - private - def ensure_login - @ran_filter ||= [] - @ran_filter << "ensure_login" - end - - def clean_up - @ran_after_filter ||= [] - @ran_after_filter << "clean_up" - end - end - - class ChangingTheRequirementsController < TestController - before_filter :ensure_login, :except => [:go_wild] - - def go_wild - render :text => "gobble" - end - end - - class TestMultipleFiltersController < ActionController::Base - before_filter :try_1 - before_filter :try_2 - before_filter :try_3 - - (1..3).each do |i| - define_method "fail_#{i}" do - render :text => i.to_s - end - end - - protected - (1..3).each do |i| - define_method "try_#{i}" do - instance_variable_set :@try, i - if action_name == "fail_#{i}" - head(404) - end - end - end - end - - class RenderingController < ActionController::Base - before_filter :render_something_else - - def show - @ran_action = true - render :inline => "ran action" - end - - private - def render_something_else - render :inline => "something else" - end - end - - class ConditionalFilterController < ActionController::Base - def show - render :inline => "ran action" - end - - def another_action - render :inline => "ran action" - end - - def show_without_filter - render :inline => "ran action without filter" - end - - private - def ensure_login - @ran_filter ||= [] - @ran_filter << "ensure_login" - end - - def clean_up_tmp - @ran_filter ||= [] - @ran_filter << "clean_up_tmp" - end - - def rescue_action(e) raise(e) end - end - - class ConditionalCollectionFilterController < ConditionalFilterController - before_filter :ensure_login, :except => [ :show_without_filter, :another_action ] - end - - class OnlyConditionSymController < ConditionalFilterController - before_filter :ensure_login, :only => :show - end - - class ExceptConditionSymController < ConditionalFilterController - before_filter :ensure_login, :except => :show_without_filter - end - - class BeforeAndAfterConditionController < ConditionalFilterController - before_filter :ensure_login, :only => :show - after_filter :clean_up_tmp, :only => :show - end - - class OnlyConditionProcController < ConditionalFilterController - before_filter(:only => :show) {|c| c.instance_variable_set(:"@ran_proc_filter", true) } - end - - class ExceptConditionProcController < ConditionalFilterController - before_filter(:except => :show_without_filter) {|c| c.instance_variable_set(:"@ran_proc_filter", true) } - end - - class ConditionalClassFilter - def self.filter(controller) controller.instance_variable_set(:"@ran_class_filter", true) end - end - - class OnlyConditionClassController < ConditionalFilterController - before_filter ConditionalClassFilter, :only => :show - end - - class ExceptConditionClassController < ConditionalFilterController - before_filter ConditionalClassFilter, :except => :show_without_filter - end - - class AnomolousYetValidConditionController < ConditionalFilterController - before_filter(ConditionalClassFilter, :ensure_login, Proc.new {|c| c.instance_variable_set(:"@ran_proc_filter1", true)}, :except => :show_without_filter) { |c| c.instance_variable_set(:"@ran_proc_filter2", true)} - end - - class ConditionalOptionsFilter < ConditionalFilterController - before_filter :ensure_login, :if => Proc.new { |c| true } - before_filter :clean_up_tmp, :if => Proc.new { |c| false } - end - - class EmptyFilterChainController < TestController - self.filter_chain.clear - def show - @action_executed = true - render :text => "yawp!" - end - end - - class PrependingController < TestController - prepend_before_filter :wonderful_life - # skip_before_filter :fire_flash - - private - def wonderful_life - @ran_filter ||= [] - @ran_filter << "wonderful_life" - end - end - - class SkippingAndLimitedController < TestController - skip_before_filter :ensure_login - before_filter :ensure_login, :only => :index - - def index - render :text => 'ok' - end - - def public - end - end - - class SkippingAndReorderingController < TestController - skip_before_filter :ensure_login - before_filter :find_record - before_filter :ensure_login - - private - def find_record - @ran_filter ||= [] - @ran_filter << "find_record" - end - end - - class ConditionalSkippingController < TestController - skip_before_filter :ensure_login, :only => [ :login ] - skip_after_filter :clean_up, :only => [ :login ] - - before_filter :find_user, :only => [ :change_password ] - - def login - render :inline => "ran action" - end - - def change_password - render :inline => "ran action" - end - - protected - def find_user - @ran_filter ||= [] - @ran_filter << "find_user" - end - end - - class ConditionalParentOfConditionalSkippingController < ConditionalFilterController - before_filter :conditional_in_parent, :only => [:show, :another_action] - after_filter :conditional_in_parent, :only => [:show, :another_action] - - private - - def conditional_in_parent - @ran_filter ||= [] - @ran_filter << 'conditional_in_parent' - end - end - - class ChildOfConditionalParentController < ConditionalParentOfConditionalSkippingController - skip_before_filter :conditional_in_parent, :only => :another_action - skip_after_filter :conditional_in_parent, :only => :another_action - end - - class AnotherChildOfConditionalParentController < ConditionalParentOfConditionalSkippingController - skip_before_filter :conditional_in_parent, :only => :show - end - - class ProcController < PrependingController - before_filter(proc { |c| c.instance_variable_set(:"@ran_proc_filter", true) }) - end - - class ImplicitProcController < PrependingController - before_filter { |c| c.instance_variable_set(:"@ran_proc_filter", true) } - end - - class AuditFilter - def self.filter(controller) - controller.instance_variable_set(:"@was_audited", true) - end - end - - class AroundFilter - def before(controller) - @execution_log = "before" - controller.class.execution_log << " before aroundfilter " if controller.respond_to? :execution_log - controller.instance_variable_set(:"@before_ran", true) - end - - def after(controller) - controller.instance_variable_set(:"@execution_log", @execution_log + " and after") - controller.instance_variable_set(:"@after_ran", true) - controller.class.execution_log << " after aroundfilter " if controller.respond_to? :execution_log - end - end - - class AppendedAroundFilter - def before(controller) - controller.class.execution_log << " before appended aroundfilter " - end - - def after(controller) - controller.class.execution_log << " after appended aroundfilter " - end - end - - class AuditController < ActionController::Base - before_filter(AuditFilter) - - def show - render :text => "hello" - end - end - - class AroundFilterController < PrependingController - around_filter AroundFilter.new - end - - class BeforeAfterClassFilterController < PrependingController - begin - filter = AroundFilter.new - before_filter filter - after_filter filter - end - end - - class MixedFilterController < PrependingController - cattr_accessor :execution_log - - def initialize - @@execution_log = "" - end - - before_filter { |c| c.class.execution_log << " before procfilter " } - prepend_around_filter AroundFilter.new - - after_filter { |c| c.class.execution_log << " after procfilter " } - append_around_filter AppendedAroundFilter.new - end - - class MixedSpecializationController < ActionController::Base - class OutOfOrder < StandardError; end - - before_filter :first - before_filter :second, :only => :foo - - def foo - render :text => 'foo' - end - - def bar - render :text => 'bar' - end - - protected - def first - @first = true - end - - def second - raise OutOfOrder unless @first - end - end - - class DynamicDispatchController < ActionController::Base - before_filter :choose - - %w(foo bar baz).each do |action| - define_method(action) { render :text => action } - end - - private - def choose - self.action_name = params[:choose] - end - end - - class PrependingBeforeAndAfterController < ActionController::Base - prepend_before_filter :before_all - prepend_after_filter :after_all - before_filter :between_before_all_and_after_all - - def before_all - @ran_filter ||= [] - @ran_filter << 'before_all' - end - - def after_all - @ran_filter ||= [] - @ran_filter << 'after_all' - end - - def between_before_all_and_after_all - @ran_filter ||= [] - @ran_filter << 'between_before_all_and_after_all' - end - def show - render :text => 'hello' - end - end - - class ErrorToRescue < Exception; end - - class RescuingAroundFilterWithBlock - def filter(controller) - begin - yield - rescue ErrorToRescue => ex - controller.__send__ :render, :text => "I rescued this: #{ex.inspect}" - end - end - end - - class RescuedController < ActionController::Base - around_filter RescuingAroundFilterWithBlock.new - - def show - raise ErrorToRescue.new("Something made the bad noise.") - end - - private - def rescue_action(exception) - raise exception - end - end - - class NonYieldingAroundFilterController < ActionController::Base - - before_filter :filter_one - around_filter :non_yielding_filter - before_filter :filter_two - after_filter :filter_three - - def index - render :inline => "index" - end - - #make sure the controller complains - def rescue_action(e); raise e; end - - private - - def filter_one - @filters ||= [] - @filters << "filter_one" - end - - def filter_two - @filters << "filter_two" - end - - def non_yielding_filter - @filters << "zomg it didn't yield" - @filter_return_value - end - - def filter_three - @filters << "filter_three" - end - - end - - def test_non_yielding_around_filters_not_returning_false_do_not_raise - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", true - assert_nothing_raised do - test_process(controller, "index") - end - end - - def test_non_yielding_around_filters_returning_false_do_not_raise - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", false - assert_nothing_raised do - test_process(controller, "index") - end - end - - def test_after_filters_are_not_run_if_around_filter_returns_false - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", false - test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] - end - - def test_after_filters_are_not_run_if_around_filter_does_not_yield - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", true - test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] - end - - def test_empty_filter_chain - assert_equal 0, EmptyFilterChainController.filter_chain.size - assert test_process(EmptyFilterChainController).template.assigns['action_executed'] - end - - def test_added_filter_to_inheritance_graph - assert_equal [ :ensure_login ], TestController.before_filters - end - - def test_base_class_in_isolation - assert_equal [ ], ActionController::Base.before_filters - end - - def test_prepending_filter - assert_equal [ :wonderful_life, :ensure_login ], PrependingController.before_filters - end - - def test_running_filters - assert_equal %w( wonderful_life ensure_login ), test_process(PrependingController).template.assigns["ran_filter"] - end - - def test_running_filters_with_proc - assert test_process(ProcController).template.assigns["ran_proc_filter"] - end - - def test_running_filters_with_implicit_proc - assert test_process(ImplicitProcController).template.assigns["ran_proc_filter"] - end - - def test_running_filters_with_class - assert test_process(AuditController).template.assigns["was_audited"] - end - - def test_running_anomolous_yet_valid_condition_filters - response = test_process(AnomolousYetValidConditionController) - assert_equal %w( ensure_login ), response.template.assigns["ran_filter"] - assert response.template.assigns["ran_class_filter"] - assert response.template.assigns["ran_proc_filter1"] - assert response.template.assigns["ran_proc_filter2"] - - response = test_process(AnomolousYetValidConditionController, "show_without_filter") - assert_equal nil, response.template.assigns["ran_filter"] - assert !response.template.assigns["ran_class_filter"] - assert !response.template.assigns["ran_proc_filter1"] - assert !response.template.assigns["ran_proc_filter2"] - end - - def test_running_conditional_options - response = test_process(ConditionalOptionsFilter) - assert_equal %w( ensure_login ), response.template.assigns["ran_filter"] - end - - def test_running_collection_condition_filters - assert_equal %w( ensure_login ), test_process(ConditionalCollectionFilterController).template.assigns["ran_filter"] - assert_equal nil, test_process(ConditionalCollectionFilterController, "show_without_filter").template.assigns["ran_filter"] - assert_equal nil, test_process(ConditionalCollectionFilterController, "another_action").template.assigns["ran_filter"] - end - - def test_running_only_condition_filters - assert_equal %w( ensure_login ), test_process(OnlyConditionSymController).template.assigns["ran_filter"] - assert_equal nil, test_process(OnlyConditionSymController, "show_without_filter").template.assigns["ran_filter"] - - assert test_process(OnlyConditionProcController).template.assigns["ran_proc_filter"] - assert !test_process(OnlyConditionProcController, "show_without_filter").template.assigns["ran_proc_filter"] - - assert test_process(OnlyConditionClassController).template.assigns["ran_class_filter"] - assert !test_process(OnlyConditionClassController, "show_without_filter").template.assigns["ran_class_filter"] - end - - def test_running_except_condition_filters - assert_equal %w( ensure_login ), test_process(ExceptConditionSymController).template.assigns["ran_filter"] - assert_equal nil, test_process(ExceptConditionSymController, "show_without_filter").template.assigns["ran_filter"] - - assert test_process(ExceptConditionProcController).template.assigns["ran_proc_filter"] - assert !test_process(ExceptConditionProcController, "show_without_filter").template.assigns["ran_proc_filter"] - - assert test_process(ExceptConditionClassController).template.assigns["ran_class_filter"] - assert !test_process(ExceptConditionClassController, "show_without_filter").template.assigns["ran_class_filter"] - end - - def test_running_before_and_after_condition_filters - assert_equal %w( ensure_login clean_up_tmp), test_process(BeforeAndAfterConditionController).template.assigns["ran_filter"] - assert_equal nil, test_process(BeforeAndAfterConditionController, "show_without_filter").template.assigns["ran_filter"] - end - - def test_around_filter - controller = test_process(AroundFilterController) - assert controller.template.assigns["before_ran"] - assert controller.template.assigns["after_ran"] - end - - def test_before_after_class_filter - controller = test_process(BeforeAfterClassFilterController) - assert controller.template.assigns["before_ran"] - assert controller.template.assigns["after_ran"] - end - - def test_having_properties_in_around_filter - controller = test_process(AroundFilterController) - assert_equal "before and after", controller.template.assigns["execution_log"] - end - - def test_prepending_and_appending_around_filter - controller = test_process(MixedFilterController) - assert_equal " before aroundfilter before procfilter before appended aroundfilter " + - " after appended aroundfilter after aroundfilter after procfilter ", - MixedFilterController.execution_log - end - - def test_rendering_breaks_filtering_chain - response = test_process(RenderingController) - assert_equal "something else", response.body - assert !response.template.assigns["ran_action"] - end - - def test_filters_with_mixed_specialization_run_in_order - assert_nothing_raised do - response = test_process(MixedSpecializationController, 'bar') - assert_equal 'bar', response.body - end - - assert_nothing_raised do - response = test_process(MixedSpecializationController, 'foo') - assert_equal 'foo', response.body - end - end - - def test_dynamic_dispatch - %w(foo bar baz).each do |action| - request = ActionController::TestRequest.new - request.query_parameters[:choose] = action - response = DynamicDispatchController.process(request, ActionController::TestResponse.new) - assert_equal action, response.body - end - end - - def test_running_prepended_before_and_after_filter - assert_equal 3, PrependingBeforeAndAfterController.filter_chain.length - response = test_process(PrependingBeforeAndAfterController) - assert_equal %w( before_all between_before_all_and_after_all after_all ), response.template.assigns["ran_filter"] - end - - def test_skipping_and_limiting_controller - assert_equal %w( ensure_login ), test_process(SkippingAndLimitedController, "index").template.assigns["ran_filter"] - assert_nil test_process(SkippingAndLimitedController, "public").template.assigns["ran_filter"] - end - - def test_skipping_and_reordering_controller - assert_equal %w( find_record ensure_login ), test_process(SkippingAndReorderingController, "index").template.assigns["ran_filter"] - end - - def test_conditional_skipping_of_filters - assert_nil test_process(ConditionalSkippingController, "login").template.assigns["ran_filter"] - assert_equal %w( ensure_login find_user ), test_process(ConditionalSkippingController, "change_password").template.assigns["ran_filter"] - - assert_nil test_process(ConditionalSkippingController, "login").template.controller.instance_variable_get("@ran_after_filter") - assert_equal %w( clean_up ), test_process(ConditionalSkippingController, "change_password").template.controller.instance_variable_get("@ran_after_filter") - end - - def test_conditional_skipping_of_filters_when_parent_filter_is_also_conditional - assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'] - assert_nil test_process(ChildOfConditionalParentController, 'another_action').template.assigns['ran_filter'] - end - - def test_condition_skipping_of_filters_when_siblings_also_have_conditions - assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'], "1" - assert_equal nil, test_process(AnotherChildOfConditionalParentController).template.assigns['ran_filter'] - assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'] - end - - def test_changing_the_requirements - assert_equal nil, test_process(ChangingTheRequirementsController, "go_wild").template.assigns['ran_filter'] - end - - def test_a_rescuing_around_filter - response = nil - assert_nothing_raised do - response = test_process(RescuedController) - end - - assert response.success? - assert_equal("I rescued this: #", response.body) - end - - private - def test_process(controller, action = "show") - ActionController::Base.class_eval { include ActionController::ProcessWithTest } unless ActionController::Base < ActionController::ProcessWithTest - request = ActionController::TestRequest.new - request.action = action - controller = controller.new if controller.is_a?(Class) - controller.process_with_test(request, ActionController::TestResponse.new) - end -end - - - -class PostsController < ActionController::Base - def rescue_action(e); raise e; end - - module AroundExceptions - class Error < StandardError ; end - class Before < Error ; end - class After < Error ; end - end - include AroundExceptions - - class DefaultFilter - include AroundExceptions - end - - module_eval %w(raises_before raises_after raises_both no_raise no_filter).map { |action| "def #{action}; default_action end" }.join("\n") - - private - def default_action - render :inline => "#{action_name} called" - end -end - -class ControllerWithSymbolAsFilter < PostsController - around_filter :raise_before, :only => :raises_before - around_filter :raise_after, :only => :raises_after - around_filter :without_exception, :only => :no_raise - - private - def raise_before - raise Before - yield - end - - def raise_after - yield - raise After - end - - def without_exception - # Do stuff... - 1 + 1 - - yield - - # Do stuff... - 1 + 1 - end -end - -class ControllerWithFilterClass < PostsController - class YieldingFilter < DefaultFilter - def self.filter(controller) - yield - raise After - end - end - - around_filter YieldingFilter, :only => :raises_after -end - -class ControllerWithFilterInstance < PostsController - class YieldingFilter < DefaultFilter - def filter(controller) - yield - raise After - end - end - - around_filter YieldingFilter.new, :only => :raises_after -end - -class ControllerWithFilterMethod < PostsController - class YieldingFilter < DefaultFilter - def filter(controller) - yield - raise After - end - end - - around_filter YieldingFilter.new.method(:filter), :only => :raises_after -end - -class ControllerWithProcFilter < PostsController - around_filter(:only => :no_raise) do |c,b| - c.instance_variable_set(:"@before", true) - b.call - c.instance_variable_set(:"@after", true) - end -end - -class ControllerWithNestedFilters < ControllerWithSymbolAsFilter - around_filter :raise_before, :raise_after, :without_exception, :only => :raises_both -end - -class ControllerWithAllTypesOfFilters < PostsController - before_filter :before - around_filter :around - after_filter :after - around_filter :around_again - - private - def before - @ran_filter ||= [] - @ran_filter << 'before' - end - - def around - @ran_filter << 'around (before yield)' - yield - @ran_filter << 'around (after yield)' - end - - def after - @ran_filter << 'after' - end - - def around_again - @ran_filter << 'around_again (before yield)' - yield - @ran_filter << 'around_again (after yield)' - end -end - -class ControllerWithTwoLessFilters < ControllerWithAllTypesOfFilters - skip_filter :around_again - skip_filter :after -end - -class YieldingAroundFiltersTest < Test::Unit::TestCase - include PostsController::AroundExceptions - - def test_filters_registering - assert_equal 1, ControllerWithFilterMethod.filter_chain.size - assert_equal 1, ControllerWithFilterClass.filter_chain.size - assert_equal 1, ControllerWithFilterInstance.filter_chain.size - assert_equal 3, ControllerWithSymbolAsFilter.filter_chain.size - assert_equal 6, ControllerWithNestedFilters.filter_chain.size - assert_equal 4, ControllerWithAllTypesOfFilters.filter_chain.size - end - - def test_base - controller = PostsController - assert_nothing_raised { test_process(controller,'no_raise') } - assert_nothing_raised { test_process(controller,'raises_before') } - assert_nothing_raised { test_process(controller,'raises_after') } - assert_nothing_raised { test_process(controller,'no_filter') } - end - - def test_with_symbol - controller = ControllerWithSymbolAsFilter - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(Before) { test_process(controller,'raises_before') } - assert_raise(After) { test_process(controller,'raises_after') } - assert_nothing_raised { test_process(controller,'no_raise') } - end - - def test_with_class - controller = ControllerWithFilterClass - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(After) { test_process(controller,'raises_after') } - end - - def test_with_instance - controller = ControllerWithFilterInstance - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(After) { test_process(controller,'raises_after') } - end - - def test_with_method - controller = ControllerWithFilterMethod - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(After) { test_process(controller,'raises_after') } - end - - def test_with_proc - controller = test_process(ControllerWithProcFilter,'no_raise') - assert controller.template.assigns['before'] - assert controller.template.assigns['after'] - end - - def test_nested_filters - controller = ControllerWithNestedFilters - assert_nothing_raised do - begin - test_process(controller,'raises_both') - rescue Before, After - end - end - assert_raise Before do - begin - test_process(controller,'raises_both') - rescue After - end - end - end - - def test_filter_order_with_all_filter_types - controller = test_process(ControllerWithAllTypesOfFilters,'no_raise') - assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) around (after yield) after',controller.template.assigns['ran_filter'].join(' ') - end - - def test_filter_order_with_skip_filter_method - controller = test_process(ControllerWithTwoLessFilters,'no_raise') - assert_equal 'before around (before yield) around (after yield)',controller.template.assigns['ran_filter'].join(' ') - end - - def test_first_filter_in_multiple_before_filter_chain_halts - controller = ::FilterTest::TestMultipleFiltersController.new - response = test_process(controller, 'fail_1') - assert_equal ' ', response.body - assert_equal 1, controller.instance_variable_get(:@try) - assert controller.instance_variable_get(:@before_filter_chain_aborted) - end - - def test_second_filter_in_multiple_before_filter_chain_halts - controller = ::FilterTest::TestMultipleFiltersController.new - response = test_process(controller, 'fail_2') - assert_equal ' ', response.body - assert_equal 2, controller.instance_variable_get(:@try) - assert controller.instance_variable_get(:@before_filter_chain_aborted) - end - - def test_last_filter_in_multiple_before_filter_chain_halts - controller = ::FilterTest::TestMultipleFiltersController.new - response = test_process(controller, 'fail_3') - assert_equal ' ', response.body - assert_equal 3, controller.instance_variable_get(:@try) - assert controller.instance_variable_get(:@before_filter_chain_aborted) - end - - protected - def test_process(controller, action = "show") - ActionController::Base.class_eval { include ActionController::ProcessWithTest } unless ActionController::Base < ActionController::ProcessWithTest - request = ActionController::TestRequest.new - request.action = action - controller = controller.new if controller.is_a?(Class) - controller.process_with_test(request, ActionController::TestResponse.new) - end -end diff --git a/vendor/rails/actionpack/test/controller/flash_test.rb b/vendor/rails/actionpack/test/controller/flash_test.rb deleted file mode 100644 index daca8806..00000000 --- a/vendor/rails/actionpack/test/controller/flash_test.rb +++ /dev/null @@ -1,174 +0,0 @@ -require 'abstract_unit' - -class FlashTest < ActionController::TestCase - class TestController < ActionController::Base - def set_flash - flash["that"] = "hello" - render :inline => "hello" - end - - def set_flash_now - flash.now["that"] = "hello" - flash.now["foo"] ||= "bar" - flash.now["foo"] ||= "err" - @flashy = flash.now["that"] - @flash_copy = {}.update flash - render :inline => "hello" - end - - def attempt_to_use_flash_now - @flash_copy = {}.update flash - @flashy = flash["that"] - render :inline => "hello" - end - - def use_flash - @flash_copy = {}.update flash - @flashy = flash["that"] - render :inline => "hello" - end - - def use_flash_and_keep_it - @flash_copy = {}.update flash - @flashy = flash["that"] - flash.keep - render :inline => "hello" - end - - def use_flash_and_update_it - flash.update("this" => "hello again") - @flash_copy = {}.update flash - render :inline => "hello" - end - - def use_flash_after_reset_session - flash["that"] = "hello" - @flashy_that = flash["that"] - reset_session - @flashy_that_reset = flash["that"] - flash["this"] = "good-bye" - @flashy_this = flash["this"] - render :inline => "hello" - end - - def rescue_action(e) - raise unless ActionView::MissingTemplate === e - end - - # methods for test_sweep_after_halted_filter_chain - before_filter :halt_and_redir, :only => "filter_halting_action" - - def std_action - @flash_copy = {}.update(flash) - end - - def filter_halting_action - @flash_copy = {}.update(flash) - end - - def halt_and_redir - flash["foo"] = "bar" - redirect_to :action => "std_action" - @flash_copy = {}.update(flash) - end - - def redirect_with_alert - redirect_to '/nowhere', :alert => "Beware the nowheres!" - end - - def redirect_with_notice - redirect_to '/somewhere', :notice => "Good luck in the somewheres!" - end - - def redirect_with_other_flashes - redirect_to '/wonderland', :flash => { :joyride => "Horses!" } - end - end - - tests TestController - - def test_flash - get :set_flash - - get :use_flash - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "hello", @response.template.assigns["flashy"] - - get :use_flash - assert_nil @response.template.assigns["flash_copy"]["that"], "On second flash" - end - - def test_keep_flash - get :set_flash - - get :use_flash_and_keep_it - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "hello", @response.template.assigns["flashy"] - - get :use_flash - assert_equal "hello", @response.template.assigns["flash_copy"]["that"], "On second flash" - - get :use_flash - assert_nil @response.template.assigns["flash_copy"]["that"], "On third flash" - end - - def test_flash_now - get :set_flash_now - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "bar" , @response.template.assigns["flash_copy"]["foo"] - assert_equal "hello", @response.template.assigns["flashy"] - - get :attempt_to_use_flash_now - assert_nil @response.template.assigns["flash_copy"]["that"] - assert_nil @response.template.assigns["flash_copy"]["foo"] - assert_nil @response.template.assigns["flashy"] - end - - def test_update_flash - get :set_flash - get :use_flash_and_update_it - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "hello again", @response.template.assigns["flash_copy"]["this"] - get :use_flash - assert_nil @response.template.assigns["flash_copy"]["that"], "On second flash" - assert_equal "hello again", @response.template.assigns["flash_copy"]["this"], "On second flash" - end - - def test_flash_after_reset_session - get :use_flash_after_reset_session - assert_equal "hello", @response.template.assigns["flashy_that"] - assert_equal "good-bye", @response.template.assigns["flashy_this"] - assert_nil @response.template.assigns["flashy_that_reset"] - end - - def test_sweep_after_halted_filter_chain - get :std_action - assert_nil @response.template.assigns["flash_copy"]["foo"] - get :filter_halting_action - assert_equal "bar", @response.template.assigns["flash_copy"]["foo"] - get :std_action # follow redirection - assert_equal "bar", @response.template.assigns["flash_copy"]["foo"] - get :std_action - assert_nil @response.template.assigns["flash_copy"]["foo"] - end - - def test_does_not_set_the_session_if_the_flash_is_empty - get :std_action - assert_nil session["flash"] - end - - def test_redirect_to_with_alert - get :redirect_with_alert - assert_equal "Beware the nowheres!", @controller.send(:flash)[:alert] - end - - def test_redirect_to_with_notice - get :redirect_with_notice - assert_equal "Good luck in the somewheres!", @controller.send(:flash)[:notice] - end - - def test_redirect_to_with_other_flashes - get :redirect_with_other_flashes - assert_equal "Horses!", @controller.send(:flash)[:joyride] - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/header_test.rb b/vendor/rails/actionpack/test/controller/header_test.rb deleted file mode 100644 index 33c14a18..00000000 --- a/vendor/rails/actionpack/test/controller/header_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'abstract_unit' - -class HeaderTest < Test::Unit::TestCase - def setup - @headers = ActionController::Http::Headers.new("HTTP_CONTENT_TYPE"=>"text/plain") - end - - def test_content_type_works - assert_equal "text/plain", @headers["Content-Type"] - assert_equal "text/plain", @headers["content-type"] - assert_equal "text/plain", @headers["CONTENT_TYPE"] - assert_equal "text/plain", @headers["HTTP_CONTENT_TYPE"] - end -end diff --git a/vendor/rails/actionpack/test/controller/helper_test.rb b/vendor/rails/actionpack/test/controller/helper_test.rb deleted file mode 100644 index 49145864..00000000 --- a/vendor/rails/actionpack/test/controller/helper_test.rb +++ /dev/null @@ -1,224 +0,0 @@ -require 'abstract_unit' - -ActionController::Base.helpers_dir = File.dirname(__FILE__) + '/../fixtures/helpers' - -class TestController < ActionController::Base - attr_accessor :delegate_attr - def delegate_method() end - def rescue_action(e) raise end -end - -module Fun - class GamesController < ActionController::Base - def render_hello_world - render :inline => "hello: <%= stratego %>" - end - - def rescue_action(e) raise end - end - - class PdfController < ActionController::Base - def test - render :inline => "test: <%= foobar %>" - end - - def rescue_action(e) raise end - end -end - -class ApplicationController < ActionController::Base - helper :all -end - -module LocalAbcHelper - def a() end - def b() end - def c() end -end - -class HelperTest < Test::Unit::TestCase - def setup - # Increment symbol counter. - @symbol = (@@counter ||= 'A0').succ!.dup - - # Generate new controller class. - controller_class_name = "Helper#{@symbol}Controller" - eval("class #{controller_class_name} < TestController; end") - @controller_class = self.class.const_get(controller_class_name) - - # Set default test helper. - self.test_helper = LocalAbcHelper - end - - def test_deprecated_helper - assert_equal expected_helper_methods, missing_methods - assert_nothing_raised { @controller_class.helper TestHelper } - assert_equal [], missing_methods - end - - def test_declare_helper - require 'abc_helper' - self.test_helper = AbcHelper - assert_equal expected_helper_methods, missing_methods - assert_nothing_raised { @controller_class.helper :abc } - assert_equal [], missing_methods - end - - def test_declare_missing_helper - assert_equal expected_helper_methods, missing_methods - assert_raise(MissingSourceFile) { @controller_class.helper :missing } - end - - def test_declare_missing_file_from_helper - require 'broken_helper' - rescue LoadError => e - assert_nil(/\bbroken_helper\b/.match(e.to_s)[1]) - end - - def test_helper_block - assert_nothing_raised { - @controller_class.helper { def block_helper_method; end } - } - assert master_helper_methods.include?('block_helper_method') - end - - def test_helper_block_include - assert_equal expected_helper_methods, missing_methods - assert_nothing_raised { - @controller_class.helper { include HelperTest::TestHelper } - } - assert_equal [], missing_methods - end - - def test_helper_method - assert_nothing_raised { @controller_class.helper_method :delegate_method } - assert master_helper_methods.include?('delegate_method') - end - - def test_helper_attr - assert_nothing_raised { @controller_class.helper_attr :delegate_attr } - assert master_helper_methods.include?('delegate_attr') - assert master_helper_methods.include?('delegate_attr=') - end - - def test_helper_for_nested_controller - request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - request.action = 'render_hello_world' - - assert_equal 'hello: Iz guuut!', Fun::GamesController.process(request, response).body - end - - def test_helper_for_acronym_controller - request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - request.action = 'test' - - assert_equal 'test: baz', Fun::PdfController.process(request, response).body - end - - def test_all_helpers - methods = ApplicationController.master_helper_module.instance_methods.map(&:to_s) - - # abc_helper.rb - assert methods.include?('bare_a') - - # fun/games_helper.rb - assert methods.include?('stratego') - - # fun/pdf_helper.rb - assert methods.include?('foobar') - end - - def test_all_helpers_with_alternate_helper_dir - @controller_class.helpers_dir = File.dirname(__FILE__) + '/../fixtures/alternate_helpers' - - # Reload helpers - @controller_class.master_helper_module = Module.new - @controller_class.helper :all - - # helpers/abc_helper.rb should not be included - assert !master_helper_methods.include?('bare_a') - - # alternate_helpers/foo_helper.rb - assert master_helper_methods.include?('baz') - end - - def test_helper_proxy - methods = ApplicationController.helpers.methods.map(&:to_s) - - # ActionView - assert methods.include?('pluralize') - - # abc_helper.rb - assert methods.include?('bare_a') - - # fun/games_helper.rb - assert methods.include?('stratego') - - # fun/pdf_helper.rb - assert methods.include?('foobar') - end - - private - def expected_helper_methods - TestHelper.instance_methods.map(&:to_s) - end - - def master_helper_methods - @controller_class.master_helper_module.instance_methods.map(&:to_s) - end - - def missing_methods - expected_helper_methods - master_helper_methods - end - - def test_helper=(helper_module) - silence_warnings { self.class.const_set('TestHelper', helper_module) } - end -end - - -class IsolatedHelpersTest < Test::Unit::TestCase - class A < ActionController::Base - def index - render :inline => '<%= shout %>' - end - - def rescue_action(e) raise end - end - - class B < A - helper { def shout; 'B' end } - - def index - render :inline => '<%= shout %>' - end - end - - class C < A - helper { def shout; 'C' end } - - def index - render :inline => '<%= shout %>' - end - end - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @request.action = 'index' - end - - def test_helper_in_a - assert_raise(NameError) { A.process(@request, @response) } - end - - def test_helper_in_b - assert_equal 'B', B.process(@request, @response).body - end - - def test_helper_in_c - assert_equal 'C', C.process(@request, @response).body - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/cdata_node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/cdata_node_test.rb deleted file mode 100644 index 1822cc56..00000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/cdata_node_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'abstract_unit' - -class CDATANodeTest < Test::Unit::TestCase - def setup - @node = HTML::CDATA.new(nil, 0, 0, "

    howdy

    ") - end - - def test_to_s - assert_equal "howdy

    ]]>", @node.to_s - end - - def test_content - assert_equal "

    howdy

    ", @node.content - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb deleted file mode 100644 index c68f04fa..00000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb +++ /dev/null @@ -1,148 +0,0 @@ -require 'abstract_unit' - -class DocumentTest < Test::Unit::TestCase - def test_handle_doctype - doc = nil - assert_nothing_raised do - doc = HTML::Document.new <<-HTML.strip - - - - HTML - end - assert_equal 3, doc.root.children.length - assert_equal %{}, doc.root.children[0].content - assert_match %r{\s+}m, doc.root.children[1].content - assert_equal "html", doc.root.children[2].name - end - - def test_find_img - doc = HTML::Document.new <<-HTML.strip - - -

    - - - HTML - assert doc.find(:tag=>"img", :attributes=>{"src"=>"hello.gif"}) - end - - def test_find_all - doc = HTML::Document.new <<-HTML.strip - - -

    -
    -

    something

    -

    here is more

    -
    - - - HTML - all = doc.find_all :attributes => { :class => "test" } - assert_equal 3, all.length - assert_equal [ "p", "p", "em" ], all.map { |n| n.name } - end - - def test_find_with_text - doc = HTML::Document.new <<-HTML.strip - - -

    Some text

    - - - HTML - assert doc.find(:content => "Some text") - assert doc.find(:tag => "p", :child => { :content => "Some text" }) - assert doc.find(:tag => "p", :child => "Some text") - assert doc.find(:tag => "p", :content => "Some text") - end - - def test_parse_xml - assert_nothing_raised { HTML::Document.new("", true, true) } - assert_nothing_raised { HTML::Document.new("something", true, true) } - end - - def test_parse_document - doc = HTML::Document.new(<<-HTML) -
    -

    blah

    - -
    -
    - HTML - assert_not_nil doc.find(:tag => "div", :children => { :count => 1, :only => { :tag => "table" } }) - end - - def test_tag_nesting_nothing_to_s - doc = HTML::Document.new("") - assert_equal "", doc.root.to_s - end - - def test_tag_nesting_space_to_s - doc = HTML::Document.new(" ") - assert_equal " ", doc.root.to_s - end - - def test_tag_nesting_text_to_s - doc = HTML::Document.new("text") - assert_equal "text", doc.root.to_s - end - - def test_tag_nesting_tag_to_s - doc = HTML::Document.new("") - assert_equal "", doc.root.to_s - end - - def test_parse_cdata - doc = HTML::Document.new(<<-HTML) - - - - <![CDATA[<br>]]> - - -

    this document has <br> for a title

    - - -HTML - - assert_nil doc.find(:tag => "title", :descendant => { :tag => "br" }) - assert doc.find(:tag => "title", :child => "
    ") - end - - def test_find_empty_tag - doc = HTML::Document.new("
    ") - assert_nil doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /./) - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /\A\Z/) - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /^$/) - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => "") - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => nil) - end - - def test_parse_invalid_document - assert_nothing_raised do - doc = HTML::Document.new(" - - - - -
    About Us
    - ") - end - end - - def test_invalid_document_raises_exception_when_strict - assert_raise RuntimeError do - doc = HTML::Document.new(" - - - - -
    About Us
    - ", true) - end - end - -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb deleted file mode 100644 index b0df3687..00000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'abstract_unit' - -class NodeTest < Test::Unit::TestCase - - class MockNode - def initialize(matched, value) - @matched = matched - @value = value - end - - def find(conditions) - @matched && self - end - - def to_s - @value.to_s - end - end - - def setup - @node = HTML::Node.new("parent") - @node.children.concat [MockNode.new(false,1), MockNode.new(true,"two"), MockNode.new(false,:three)] - end - - def test_match - assert !@node.match("foo") - end - - def test_tag - assert !@node.tag? - end - - def test_to_s - assert_equal "1twothree", @node.to_s - end - - def test_find - assert_equal "two", @node.find('blah').to_s - end - - def test_parse_strict - s = "" - assert_raise(RuntimeError) { HTML::Node.parse(nil,0,0,s) } - end - - def test_parse_relaxed - s = "" - node = nil - assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) } - assert node.attributes.has_key?("foo") - assert !node.attributes.has_key?("bar") - end - - def test_to_s_with_boolean_attrs - s = "" - node = HTML::Node.parse(nil,0,0,s) - assert node.attributes.has_key?("foo") - assert node.attributes.has_key?("bar") - assert "", node.to_s - end - - def test_parse_with_unclosed_tag - s = "contents', node.content - end - - def test_parse_strict_with_unterminated_cdata_section - s = " hi' - - assert_equal ' hi', sanitizer.sanitize(string) - end - - def test_strip_tags - sanitizer = HTML::FullSanitizer.new - assert_equal("<<")) - assert_equal("Dont touch me", sanitizer.sanitize("Dont touch me")) - assert_equal("This is a test.", sanitizer.sanitize("

    This is a test.

    ")) - assert_equal("Weirdos", sanitizer.sanitize("Wei<a onclick='alert(document.cookie);'/>rdos")) - assert_equal("This is a test.", sanitizer.sanitize("This is a test.")) - assert_equal( - %{This is a test.\n\n\nIt no longer contains any HTML.\n}, sanitizer.sanitize( - %{This is <b>a <a href="" target="_blank">test</a></b>.\n\n\n\n

    It no longer contains any HTML.

    \n})) - assert_equal "This has a here.", sanitizer.sanitize("This has a here.") - assert_equal "This has a here.", sanitizer.sanitize("This has a ]]> here.") - assert_equal "This has an unclosed ", sanitizer.sanitize("This has an unclosed ]] here...") - assert_equal "non printable char is a tag", sanitizer.sanitize("<\x07a href='/hello'>non printable char is a tag") - [nil, '', ' '].each { |blank| assert_equal blank, sanitizer.sanitize(blank) } - end - - def test_strip_links - sanitizer = HTML::LinkSanitizer.new - assert_equal "Dont touch me", sanitizer.sanitize("Dont touch me") - assert_equal "on my mind\nall day long", sanitizer.sanitize("on my mind\nall day long") - assert_equal "0wn3d", sanitizer.sanitize("0wn3d") - assert_equal "Magic", sanitizer.sanitize("Magic") - assert_equal "FrrFox", sanitizer.sanitize("FrrFox") - assert_equal "My mind\nall day long", sanitizer.sanitize("My mind\nall day long") - assert_equal "all day long", sanitizer.sanitize("<a href='hello'>all day long</a>") - - assert_equal "", '' - end - - def test_sanitize_plaintext - raw = "<span>foo</span></plaintext>" - assert_sanitized raw, "<span>foo</span>" - end - - def test_sanitize_script - assert_sanitized "a b c<script language=\"Javascript\">blah blah blah</script>d e f", "a b cd e f" - end - - # fucked - def test_sanitize_js_handlers - raw = %{onthis="do that" <a href="#" onclick="hello" name="foo" onbogus="remove me">hello</a>} - assert_sanitized raw, %{onthis="do that" <a name="foo" href="#">hello</a>} - end - - def test_sanitize_javascript_href - raw = %{href="javascript:bang" <a href="javascript:bang" name="hello">foo</a>, <span href="javascript:bang">bar</span>} - assert_sanitized raw, %{href="javascript:bang" <a name="hello">foo</a>, <span>bar</span>} - end - - def test_sanitize_image_src - raw = %{src="javascript:bang" <img src="javascript:bang" width="5">foo</img>, <span src="javascript:bang">bar</span>} - assert_sanitized raw, %{src="javascript:bang" <img width="5">foo</img>, <span>bar</span>} - end - - HTML::WhiteListSanitizer.allowed_tags.each do |tag_name| - define_method "test_should_allow_#{tag_name}_tag" do - assert_sanitized "start <#{tag_name} title=\"1\" onclick=\"foo\">foo <bad>bar</bad> baz</#{tag_name}> end", %(start <#{tag_name} title="1">foo bar baz</#{tag_name}> end) - end - end - - def test_should_allow_anchors - assert_sanitized %(<a href="foo" onclick="bar"><script>baz</script></a>), %(<a href="foo"></a>) - end - - # RFC 3986, sec 4.2 - def test_allow_colons_in_path_component - assert_sanitized("<a href=\"./this:that\">foo</a>") - end - - %w(src width height alt).each do |img_attr| - define_method "test_should_allow_image_#{img_attr}_attribute" do - assert_sanitized %(<img #{img_attr}="foo" onclick="bar" />), %(<img #{img_attr}="foo" />) - end - end - - def test_should_handle_non_html - assert_sanitized 'abc' - end - - def test_should_handle_blank_text - assert_sanitized nil - assert_sanitized '' - end - - def test_should_allow_custom_tags - text = "<u>foo</u>" - sanitizer = HTML::WhiteListSanitizer.new - assert_equal(text, sanitizer.sanitize(text, :tags => %w(u))) - end - - def test_should_allow_only_custom_tags - text = "<u>foo</u> with <i>bar</i>" - sanitizer = HTML::WhiteListSanitizer.new - assert_equal("<u>foo</u> with bar", sanitizer.sanitize(text, :tags => %w(u))) - end - - def test_should_allow_custom_tags_with_attributes - text = %(<blockquote cite="http://example.com/">foo</blockquote>) - sanitizer = HTML::WhiteListSanitizer.new - assert_equal(text, sanitizer.sanitize(text)) - end - - def test_should_allow_custom_tags_with_custom_attributes - text = %(<blockquote foo="bar">Lorem ipsum</blockquote>) - sanitizer = HTML::WhiteListSanitizer.new - assert_equal(text, sanitizer.sanitize(text, :attributes => ['foo'])) - end - - [%w(img src), %w(a href)].each do |(tag, attr)| - define_method "test_should_strip_#{attr}_attribute_in_#{tag}_with_bad_protocols" do - assert_sanitized %(<#{tag} #{attr}="javascript:bang" title="1">boo</#{tag}>), %(<#{tag} title="1">boo</#{tag}>) - end - end - - def test_should_flag_bad_protocols - sanitizer = HTML::WhiteListSanitizer.new - %w(about chrome data disk hcp help javascript livescript lynxcgi lynxexec ms-help ms-its mhtml mocha opera res resource shell vbscript view-source vnd.ms.radio wysiwyg).each do |proto| - assert sanitizer.send(:contains_bad_protocols?, 'src', "#{proto}://bad") - end - end - - def test_should_accept_good_protocols - sanitizer = HTML::WhiteListSanitizer.new - HTML::WhiteListSanitizer.allowed_protocols.each do |proto| - assert !sanitizer.send(:contains_bad_protocols?, 'src', "#{proto}://good") - end - end - - def test_should_reject_hex_codes_in_protocol - assert_sanitized %(<a href="&#37;6A&#37;61&#37;76&#37;61&#37;73&#37;63&#37;72&#37;69&#37;70&#37;74&#37;3A&#37;61&#37;6C&#37;65&#37;72&#37;74&#37;28&#37;22&#37;58&#37;53&#37;53&#37;22&#37;29">1</a>), "<a>1</a>" - assert @sanitizer.send(:contains_bad_protocols?, 'src', "%6A%61%76%61%73%63%72%69%70%74%3A%61%6C%65%72%74%28%22%58%53%53%22%29") - end - - def test_should_block_script_tag - assert_sanitized %(<SCRIPT\nSRC=http://ha.ckers.org/xss.js></SCRIPT>), "" - end - - [%(<IMG SRC="javascript:alert('XSS');">), - %(<IMG SRC=javascript:alert('XSS')>), - %(<IMG SRC=JaVaScRiPt:alert('XSS')>), - %(<IMG """><SCRIPT>alert("XSS")</SCRIPT>">), - %(<IMG SRC=javascript:alert(&quot;XSS&quot;)>), - %(<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>), - %(<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>), - %(<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>), - %(<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>), - %(<IMG SRC="jav\tascript:alert('XSS');">), - %(<IMG SRC="jav&#x09;ascript:alert('XSS');">), - %(<IMG SRC="jav&#x0A;ascript:alert('XSS');">), - %(<IMG SRC="jav&#x0D;ascript:alert('XSS');">), - %(<IMG SRC=" &#14; javascript:alert('XSS');">), - %(<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>)].each_with_index do |img_hack, i| - define_method "test_should_not_fall_for_xss_image_hack_#{i+1}" do - assert_sanitized img_hack, "<img>" - end - end - - def test_should_sanitize_tag_broken_up_by_null - assert_sanitized %(<SCR\0IPT>alert(\"XSS\")</SCR\0IPT>), "alert(\"XSS\")" - end - - def test_should_sanitize_invalid_script_tag - assert_sanitized %(<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>), "" - end - - def test_should_sanitize_script_tag_with_multiple_open_brackets - assert_sanitized %(<<SCRIPT>alert("XSS");//<</SCRIPT>), "&lt;" - assert_sanitized %(<iframe src=http://ha.ckers.org/scriptlet.html\n<a), %(&lt;a) - end - - def test_should_sanitize_unclosed_script - assert_sanitized %(<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>), "<b>" - end - - def test_should_sanitize_half_open_scripts - assert_sanitized %(<IMG SRC="javascript:alert('XSS')"), "<img>" - end - - def test_should_not_fall_for_ridiculous_hack - img_hack = %(<IMG\nSRC\n=\n"\nj\na\nv\na\ns\nc\nr\ni\np\nt\n:\na\nl\ne\nr\nt\n(\n'\nX\nS\nS\n'\n)\n"\n>) - assert_sanitized img_hack, "<img>" - end - - # fucked - def test_should_sanitize_attributes - assert_sanitized %(<SPAN title="'><script>alert()</script>">blah</SPAN>), %(<span title="'&gt;&lt;script&gt;alert()&lt;/script&gt;">blah</span>) - end - - def test_should_sanitize_illegal_style_properties - raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;) - expected = %(display: block; width: 100%; height: 100%; background-color: black; background-image: ; background-x: center; background-y: center;) - assert_equal expected, sanitize_css(raw) - end - - def test_should_sanitize_with_trailing_space - raw = "display:block; " - expected = "display: block;" - assert_equal expected, sanitize_css(raw) - end - - def test_should_sanitize_xul_style_attributes - raw = %(-moz-binding:url('http://ha.ckers.org/xssmoz.xml#xss')) - assert_equal '', sanitize_css(raw) - end - - def test_should_sanitize_invalid_tag_names - assert_sanitized(%(a b c<script/XSS src="http://ha.ckers.org/xss.js"></script>d e f), "a b cd e f") - end - - def test_should_sanitize_non_alpha_and_non_digit_characters_in_tags - assert_sanitized('<a onclick!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>foo</a>', "<a>foo</a>") - end - - def test_should_sanitize_invalid_tag_names_in_single_tags - assert_sanitized('<img/src="http://ha.ckers.org/xss.js"/>', "<img />") - end - - def test_should_sanitize_img_dynsrc_lowsrc - assert_sanitized(%(<img lowsrc="javascript:alert('XSS')" />), "<img />") - end - - def test_should_sanitize_div_background_image_unicode_encoded - raw = %(background-image:\0075\0072\006C\0028'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029'\0029) - assert_equal '', sanitize_css(raw) - end - - def test_should_sanitize_div_style_expression - raw = %(width: expression(alert('XSS'));) - assert_equal '', sanitize_css(raw) - end - - def test_should_sanitize_img_vbscript - assert_sanitized %(<img src='vbscript:msgbox("XSS")' />), '<img />' - end - - def test_should_sanitize_cdata_section - assert_sanitized "<![CDATA[<span>section</span>]]>", "&lt;![CDATA[&lt;span>section&lt;/span>]]>" - end - - def test_should_sanitize_unterminated_cdata_section - assert_sanitized "<![CDATA[<span>neverending...", "&lt;![CDATA[&lt;span>neverending...]]>" - end - - def test_should_not_mangle_urls_with_ampersand - assert_sanitized %{<a href=\"http://www.domain.com?var1=1&amp;var2=2\">my link</a>} - end - -protected - def assert_sanitized(input, expected = nil) - @sanitizer ||= HTML::WhiteListSanitizer.new - if input - assert_dom_equal expected || input, @sanitizer.sanitize(input) - else - assert_nil @sanitizer.sanitize(input) - end - end - - def sanitize_css(input) - (@sanitizer ||= HTML::WhiteListSanitizer.new).sanitize_css(input) - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb deleted file mode 100644 index d1d46673..00000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb +++ /dev/null @@ -1,238 +0,0 @@ -require 'abstract_unit' - -class TagNodeTest < Test::Unit::TestCase - def test_open_without_attributes - node = tag("<tag>") - assert_equal "tag", node.name - assert_equal Hash.new, node.attributes - assert_nil node.closing - end - - def test_open_with_attributes - node = tag("<TAG1 foo=hey_ho x:bar=\"blah blah\" BAZ='blah blah blah' >") - assert_equal "tag1", node.name - assert_equal "hey_ho", node["foo"] - assert_equal "blah blah", node["x:bar"] - assert_equal "blah blah blah", node["baz"] - end - - def test_self_closing_without_attributes - node = tag("<tag/>") - assert_equal "tag", node.name - assert_equal Hash.new, node.attributes - assert_equal :self, node.closing - end - - def test_self_closing_with_attributes - node = tag("<tag a=b/>") - assert_equal "tag", node.name - assert_equal( { "a" => "b" }, node.attributes ) - assert_equal :self, node.closing - end - - def test_closing_without_attributes - node = tag("</tag>") - assert_equal "tag", node.name - assert_nil node.attributes - assert_equal :close, node.closing - end - - def test_bracket_op_when_no_attributes - node = tag("</tag>") - assert_nil node["foo"] - end - - def test_bracket_op_when_attributes - node = tag("<tag a=b/>") - assert_equal "b", node["a"] - end - - def test_attributes_with_escaped_quotes - node = tag("<tag a='b\\'c' b=\"bob \\\"float\\\"\">") - assert_equal "b\\'c", node["a"] - assert_equal "bob \\\"float\\\"", node["b"] - end - - def test_to_s - node = tag("<a b=c d='f' g=\"h 'i'\" />") - assert_equal %(<a b='c' d='f' g='h \\'i\\'' />), node.to_s - end - - def test_tag - assert tag("<tag>").tag? - end - - def test_match_tag_as_string - assert tag("<tag>").match(:tag => "tag") - assert !tag("<tag>").match(:tag => "b") - end - - def test_match_tag_as_regexp - assert tag("<tag>").match(:tag => /t.g/) - assert !tag("<tag>").match(:tag => /t[bqs]g/) - end - - def test_match_attributes_as_string - t = tag("<tag a=something b=else />") - assert t.match(:attributes => {"a" => "something"}) - assert t.match(:attributes => {"b" => "else"}) - end - - def test_match_attributes_as_regexp - t = tag("<tag a=something b=else />") - assert t.match(:attributes => {"a" => /^something$/}) - assert t.match(:attributes => {"b" => /e.*e/}) - assert t.match(:attributes => {"a" => /me..i/, "b" => /.ls.$/}) - end - - def test_match_attributes_as_number - t = tag("<tag a=15 b=3.1415 />") - assert t.match(:attributes => {"a" => 15}) - assert t.match(:attributes => {"b" => 3.1415}) - assert t.match(:attributes => {"a" => 15, "b" => 3.1415}) - end - - def test_match_attributes_exist - t = tag("<tag a=15 b=3.1415 />") - assert t.match(:attributes => {"a" => true}) - assert t.match(:attributes => {"b" => true}) - assert t.match(:attributes => {"a" => true, "b" => true}) - end - - def test_match_attributes_not_exist - t = tag("<tag a=15 b=3.1415 />") - assert t.match(:attributes => {"c" => false}) - assert t.match(:attributes => {"c" => nil}) - assert t.match(:attributes => {"a" => true, "c" => false}) - end - - def test_match_parent_success - t = tag("<tag a=15 b='hello'>", tag("<foo k='value'>")) - assert t.match(:parent => {:tag => "foo", :attributes => {"k" => /v.l/, "j" => false}}) - end - - def test_match_parent_fail - t = tag("<tag a=15 b='hello'>", tag("<foo k='value'>")) - assert !t.match(:parent => {:tag => /kafka/}) - end - - def test_match_child_success - t = tag("<tag x:k='something'>") - tag("<child v=john a=kelly>", t) - tag("<sib m=vaughn v=james>", t) - assert t.match(:child => { :tag => "sib", :attributes => {"v" => /j/}}) - assert t.match(:child => { :attributes => {"a" => "kelly"}}) - end - - def test_match_child_fail - t = tag("<tag x:k='something'>") - tag("<child v=john a=kelly>", t) - tag("<sib m=vaughn v=james>", t) - assert !t.match(:child => { :tag => "sib", :attributes => {"v" => /r/}}) - assert !t.match(:child => { :attributes => {"v" => false}}) - end - - def test_match_ancestor_success - t = tag("<tag x:k='something'>", tag("<parent v=john a=kelly>", tag("<grandparent m=vaughn v=james>"))) - assert t.match(:ancestor => {:tag => "parent", :attributes => {"a" => /ll/}}) - assert t.match(:ancestor => {:attributes => {"m" => "vaughn"}}) - end - - def test_match_ancestor_fail - t = tag("<tag x:k='something'>", tag("<parent v=john a=kelly>", tag("<grandparent m=vaughn v=james>"))) - assert !t.match(:ancestor => {:tag => /^parent/, :attributes => {"v" => /m/}}) - assert !t.match(:ancestor => {:attributes => {"v" => false}}) - end - - def test_match_descendant_success - tag("<grandchild m=vaughn v=james>", tag("<child v=john a=kelly>", t = tag("<tag x:k='something'>"))) - assert t.match(:descendant => {:tag => "child", :attributes => {"a" => /ll/}}) - assert t.match(:descendant => {:attributes => {"m" => "vaughn"}}) - end - - def test_match_descendant_fail - tag("<grandchild m=vaughn v=james>", tag("<child v=john a=kelly>", t = tag("<tag x:k='something'>"))) - assert !t.match(:descendant => {:tag => /^child/, :attributes => {"v" => /m/}}) - assert !t.match(:descendant => {:attributes => {"v" => false}}) - end - - def test_match_child_count - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<child v=john a=kelly>", t) - tag("<sib m=vaughn v=james>", t) - assert t.match(:children => { :count => 2 }) - assert t.match(:children => { :count => 2..4 }) - assert t.match(:children => { :less_than => 4 }) - assert t.match(:children => { :greater_than => 1 }) - assert !t.match(:children => { :count => 3 }) - end - - def test_conditions_as_strings - t = tag("<tag x:k='something'>") - assert t.match("tag" => "tag") - assert t.match("attributes" => { "x:k" => "something" }) - assert !t.match("tag" => "gat") - assert !t.match("attributes" => { "x:j" => "something" }) - end - - def test_attributes_as_symbols - t = tag("<child v=john a=kelly>") - assert t.match(:attributes => { :v => /oh/ }) - assert t.match(:attributes => { :a => /ll/ }) - end - - def test_match_sibling - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<span a=b>", t) - tag("world", t) - m = tag("<span k=r>", t) - tag("<span m=l>", t) - - assert m.match(:sibling => {:tag => "span", :attributes => {:a => true}}) - assert m.match(:sibling => {:tag => "span", :attributes => {:m => true}}) - assert !m.match(:sibling => {:tag => "span", :attributes => {:k => true}}) - end - - def test_match_sibling_before - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<span a=b>", t) - tag("world", t) - m = tag("<span k=r>", t) - tag("<span m=l>", t) - - assert m.match(:before => {:tag => "span", :attributes => {:m => true}}) - assert !m.match(:before => {:tag => "span", :attributes => {:a => true}}) - assert !m.match(:before => {:tag => "span", :attributes => {:k => true}}) - end - - def test_match_sibling_after - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<span a=b>", t) - tag("world", t) - m = tag("<span k=r>", t) - tag("<span m=l>", t) - - assert m.match(:after => {:tag => "span", :attributes => {:a => true}}) - assert !m.match(:after => {:tag => "span", :attributes => {:m => true}}) - assert !m.match(:after => {:tag => "span", :attributes => {:k => true}}) - end - - def test_to_s - t = tag("<b x='foo'>") - tag("hello", t) - tag("<hr />", t) - assert_equal %(<b x="foo">hello<hr /></b>), t.to_s - end - - private - - def tag(content, parent=nil) - node = HTML::Node.parse(parent,0,0,content) - parent.children << node if parent - node - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb deleted file mode 100644 index 1ab3f445..00000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'abstract_unit' - -class TextNodeTest < Test::Unit::TestCase - def setup - @node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong") - end - - def test_to_s - assert_equal "hello, howdy, aloha, annyeong", @node.to_s - end - - def test_find_string - assert_equal @node, @node.find("hello, howdy, aloha, annyeong") - assert_equal false, @node.find("bogus") - end - - def test_find_regexp - assert_equal @node, @node.find(/an+y/) - assert_nil @node.find(/b/) - end - - def test_find_hash - assert_equal @node, @node.find(:content => /howdy/) - assert_nil @node.find(:content => /^howdy$/) - assert_equal false, @node.find(:content => "howdy") - end - - def test_find_other - assert_nil @node.find(:hello) - end - - def test_match_string - assert @node.match("hello, howdy, aloha, annyeong") - assert_equal false, @node.match("bogus") - end - - def test_match_regexp - assert_not_nil @node, @node.match(/an+y/) - assert_nil @node.match(/b/) - end - - def test_match_hash - assert_not_nil @node, @node.match(:content => "howdy") - assert_nil @node.match(:content => /^howdy$/) - end - - def test_match_other - assert_nil @node.match(:hello) - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb deleted file mode 100644 index a001bcbb..00000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'abstract_unit' - -class TokenizerTest < Test::Unit::TestCase - - def test_blank - tokenize "" - assert_end - end - - def test_space - tokenize " " - assert_next " " - assert_end - end - - def test_tag_simple_open - tokenize "<tag>" - assert_next "<tag>" - assert_end - end - - def test_tag_simple_self_closing - tokenize "<tag />" - assert_next "<tag />" - assert_end - end - - def test_tag_simple_closing - tokenize "</tag>" - assert_next "</tag>" - end - - def test_tag_with_single_quoted_attribute - tokenize %{<tag a='hello'>x} - assert_next %{<tag a='hello'>} - end - - def test_tag_with_single_quoted_attribute_with_escape - tokenize %{<tag a='hello\\''>x} - assert_next %{<tag a='hello\\''>} - end - - def test_tag_with_double_quoted_attribute - tokenize %{<tag a="hello">x} - assert_next %{<tag a="hello">} - end - - def test_tag_with_double_quoted_attribute_with_escape - tokenize %{<tag a="hello\\"">x} - assert_next %{<tag a="hello\\"">} - end - - def test_tag_with_unquoted_attribute - tokenize %{<tag a=hello>x} - assert_next %{<tag a=hello>} - end - - def test_tag_with_lt_char_in_attribute - tokenize %{<tag a="x < y">x} - assert_next %{<tag a="x < y">} - end - - def test_tag_with_gt_char_in_attribute - tokenize %{<tag a="x > y">x} - assert_next %{<tag a="x > y">} - end - - def test_doctype_tag - tokenize %{<!DOCTYPE "blah" "blah" "blah">\n <html>} - assert_next %{<!DOCTYPE "blah" "blah" "blah">} - assert_next %{\n } - assert_next %{<html>} - end - - def test_cdata_tag - tokenize %{<![CDATA[<br>]]>} - assert_next %{<![CDATA[<br>]]>} - assert_end - end - - def test_unterminated_cdata_tag - tokenize %{<content:encoded><![CDATA[ neverending...} - assert_next %{<content:encoded>} - assert_next %{<![CDATA[ neverending...} - assert_end - end - - def test_less_than_with_space - tokenize %{original < hello > world} - assert_next %{original } - assert_next %{< hello > world} - end - - def test_less_than_without_matching_greater_than - tokenize %{hello <span onmouseover="gotcha"\n<b>foo</b>\nbar</span>} - assert_next %{hello } - assert_next %{<span onmouseover="gotcha"\n} - assert_next %{<b>} - assert_next %{foo} - assert_next %{</b>} - assert_next %{\nbar} - assert_next %{</span>} - assert_end - end - - def test_unterminated_comment - tokenize %{hello <!-- neverending...} - assert_next %{hello } - assert_next %{<!-- neverending...} - assert_end - end - - private - - def tokenize(text) - @tokenizer = HTML::Tokenizer.new(text) - end - - def assert_next(expected, message=nil) - token = @tokenizer.next - assert_equal expected, token, message - end - - def assert_sequence(*expected) - assert_next expected.shift until expected.empty? - end - - def assert_end(message=nil) - assert_nil @tokenizer.next, message - end -end diff --git a/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb b/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb deleted file mode 100644 index 23688ca5..00000000 --- a/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +++ /dev/null @@ -1,113 +0,0 @@ -require 'abstract_unit' - -class HttpBasicAuthenticationTest < ActionController::TestCase - class DummyController < ActionController::Base - before_filter :authenticate, :only => :index - before_filter :authenticate_with_request, :only => :display - before_filter :authenticate_long_credentials, :only => :show - - def index - render :text => "Hello Secret" - end - - def display - render :text => 'Definitely Maybe' - end - - def show - render :text => 'Only for loooooong credentials' - end - - private - - def authenticate - authenticate_or_request_with_http_basic do |username, password| - username == 'lifo' && password == 'world' - end - end - - def authenticate_with_request - if authenticate_with_http_basic { |username, password| username == 'pretty' && password == 'please' } - @logged_in = true - else - request_http_basic_authentication("SuperSecret") - end - end - - def authenticate_long_credentials - authenticate_or_request_with_http_basic do |username, password| - username == '1234567890123456789012345678901234567890' && password == '1234567890123456789012345678901234567890' - end - end - end - - AUTH_HEADERS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION', 'REDIRECT_X_HTTP_AUTHORIZATION'] - - tests DummyController - - AUTH_HEADERS.each do |header| - test "successful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials('lifo', 'world') - get :index - - assert_response :success - assert_equal 'Hello Secret', @response.body, "Authentication failed for request header #{header}" - end - test "successful authentication with #{header.downcase} and long credentials" do - @request.env[header] = encode_credentials('1234567890123456789012345678901234567890', '1234567890123456789012345678901234567890') - get :show - - assert_response :success - assert_equal 'Only for loooooong credentials', @response.body, "Authentication failed for request header #{header} and long credentials" - end - end - - AUTH_HEADERS.each do |header| - test "unsuccessful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials('h4x0r', 'world') - get :index - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body, "Authentication didn't fail for request header #{header}" - end - test "unsuccessful authentication with #{header.downcase} and long credentials" do - @request.env[header] = encode_credentials('h4x0rh4x0rh4x0rh4x0rh4x0rh4x0rh4x0rh4x0r', 'worldworldworldworldworldworldworldworld') - get :show - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body, "Authentication didn't fail for request header #{header} and long credentials" - end - end - - test "authentication request without credential" do - get :display - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body - assert_equal 'Basic realm="SuperSecret"', @response.headers['WWW-Authenticate'] - end - - test "authentication request with invalid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials('pretty', 'foo') - get :display - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body - assert_equal 'Basic realm="SuperSecret"', @response.headers['WWW-Authenticate'] - end - - test "authentication request with valid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials('pretty', 'please') - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - private - - def encode_credentials(username, password) - "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}" - end -end diff --git a/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb b/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb deleted file mode 100644 index 9f2750fd..00000000 --- a/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +++ /dev/null @@ -1,254 +0,0 @@ -require 'abstract_unit' - -class HttpDigestAuthenticationTest < ActionController::TestCase - class DummyDigestController < ActionController::Base - before_filter :authenticate, :only => :index - before_filter :authenticate_with_request, :only => :display - - USERS = { 'lifo' => 'world', 'pretty' => 'please', - 'dhh' => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":"))} - - def index - render :text => "Hello Secret" - end - - def display - render :text => 'Definitely Maybe' - end - - private - - def authenticate - authenticate_or_request_with_http_digest("SuperSecret") do |username| - # Return the password - USERS[username] - end - end - - def authenticate_with_request - if authenticate_with_http_digest("SuperSecret") { |username| USERS[username] } - @logged_in = true - else - request_http_digest_authentication("SuperSecret", "Authentication Failed") - end - end - end - - AUTH_HEADERS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION', 'REDIRECT_X_HTTP_AUTHORIZATION'] - - tests DummyDigestController - - AUTH_HEADERS.each do |header| - test "successful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials(:username => 'lifo', :password => 'world') - get :index - - assert_response :success - assert_equal 'Hello Secret', @response.body, "Authentication failed for request header #{header}" - end - end - - AUTH_HEADERS.each do |header| - test "unsuccessful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials(:username => 'h4x0r', :password => 'world') - get :index - - assert_response :unauthorized - assert_equal "HTTP Digest: Access denied.\n", @response.body, "Authentication didn't fail for request header #{header}" - end - end - - test "authentication request without credential" do - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - credentials = decode_credentials(@response.headers['WWW-Authenticate']) - assert_equal 'SuperSecret', credentials[:realm] - end - - test "authentication request with nil credentials" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => nil, :password => nil) - get :index - - assert_response :unauthorized - assert_equal "HTTP Digest: Access denied.\n", @response.body, "Authentication didn't fail for request" - assert_not_equal 'Hello Secret', @response.body, "Authentication didn't fail for request" - end - - test "authentication request with invalid password" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'foo') - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with invalid nonce" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please', :nonce => "xxyyzz") - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with missing nonce should return 401" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please', :remove_nonce => true) - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with Basic auth credentials should return 401" do - ActionController::Base.session_options[:secret] = "session_options_secret" - @request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('pretty', 'please') - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with invalid opaque" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'foo', :opaque => "xxyyzz") - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with invalid realm" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'foo', :realm => "NotSecret") - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with valid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with valid credential and nil session" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - - # session_id = "" in functional test, but is +nil+ in real life - @request.session.session_id = nil - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with request-uri that doesn't match credentials digest-uri" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "/http_digest_authentication_test/dummy_digest/altered/uri" - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with absolute request uri (as in webrick)" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest" - - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with absolute uri in credentials (as in IE)" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:url => "http://test.host/http_digest_authentication_test/dummy_digest", - :username => 'pretty', :password => 'please') - - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with absolute uri in both request and credentials (as in Webrick with IE)" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:url => "http://test.host/http_digest_authentication_test/dummy_digest", - :username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest" - - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with password stored as ha1 digest hash" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'dhh', - :password => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":")), - :password_is_ha1 => true) - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with _method" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please', :method => :post) - @request.env['rack.methodoverride.original_method'] = 'POST' - put :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "validate_digest_response should fail with nil returning password_procedure" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => nil, :password => nil) - assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret"){nil} - end - - private - - def encode_credentials(options) - options.reverse_merge!(:nc => "00000001", :cnonce => "0a4f113b", :password_is_ha1 => false) - password = options.delete(:password) - - # Set in /initializers/session_store.rb. Used as secret in generating nonce - # to prevent tampering of timestamp - ActionController::Base.session_options[:secret] = "session_options_secret" - - # Perform unauthenticated request to retrieve digest parameters to use on subsequent request - method = options.delete(:method) || 'GET' - - case method.to_s.upcase - when 'GET' - get :index - when 'POST' - post :index - end - - assert_response :unauthorized - - remove_nonce = options.delete(:remove_nonce) - - credentials = decode_credentials(@response.headers['WWW-Authenticate']) - credentials.merge!(options) - credentials.merge!(:uri => @request.env['REQUEST_URI'].to_s) - - credentials.delete(:nonce) if remove_nonce - - ActionController::HttpAuthentication::Digest.encode_credentials(method, credentials, password, options[:password_is_ha1]) - end - - def decode_credentials(header) - ActionController::HttpAuthentication::Digest.decode_credentials(@response.headers['WWW-Authenticate']) - end -end diff --git a/vendor/rails/actionpack/test/controller/integration_test.rb b/vendor/rails/actionpack/test/controller/integration_test.rb deleted file mode 100644 index d1bb19c3..00000000 --- a/vendor/rails/actionpack/test/controller/integration_test.rb +++ /dev/null @@ -1,526 +0,0 @@ -require 'abstract_unit' - -class SessionTest < Test::Unit::TestCase - StubApp = lambda { |env| - [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, ["Hello, World!"]] - } - - def setup - @session = ActionController::Integration::Session.new(StubApp) - end - - def test_https_bang_works_and_sets_truth_by_default - assert !@session.https? - @session.https! - assert @session.https? - @session.https! false - assert !@session.https? - end - - def test_host! - assert_not_equal "glu.ttono.us", @session.host - @session.host! "rubyonrails.com" - assert_equal "rubyonrails.com", @session.host - end - - def test_follow_redirect_raises_when_no_redirect - @session.stubs(:redirect?).returns(false) - assert_raise(RuntimeError) { @session.follow_redirect! } - end - - def test_request_via_redirect_uses_given_method - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} - @session.expects(:put).with(path, args, headers) - @session.stubs(:redirect?).returns(false) - @session.request_via_redirect(:put, path, args, headers) - end - - def test_request_via_redirect_follows_redirects - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} - @session.stubs(:redirect?).returns(true, true, false) - @session.expects(:follow_redirect!).times(2) - @session.request_via_redirect(:get, path, args, headers) - end - - def test_request_via_redirect_returns_status - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} - @session.stubs(:redirect?).returns(false) - @session.stubs(:status).returns(200) - assert_equal 200, @session.request_via_redirect(:get, path, args, headers) - end - - def test_get_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:get, path, args, headers) - @session.get_via_redirect(path, args, headers) - end - - def test_post_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:post, path, args, headers) - @session.post_via_redirect(path, args, headers) - end - - def test_put_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:put, path, args, headers) - @session.put_via_redirect(path, args, headers) - end - - def test_delete_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:delete, path, args, headers) - @session.delete_via_redirect(path, args, headers) - end - - def test_url_for_with_controller - options = {:action => 'show'} - mock_controller = mock() - mock_controller.expects(:url_for).with(options).returns('/show') - @session.stubs(:controller).returns(mock_controller) - assert_equal '/show', @session.url_for(options) - end - - def test_url_for_without_controller - options = {:action => 'show'} - mock_rewriter = mock() - mock_rewriter.expects(:rewrite).with(options).returns('/show') - @session.stubs(:generic_url_rewriter).returns(mock_rewriter) - @session.stubs(:controller).returns(nil) - assert_equal '/show', @session.url_for(options) - end - - def test_redirect_bool_with_status_in_300s - @session.stubs(:status).returns 301 - assert @session.redirect? - end - - def test_redirect_bool_with_status_in_200s - @session.stubs(:status).returns 200 - assert !@session.redirect? - end - - def test_get - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:get,path,params,headers) - @session.get(path,params,headers) - end - - def test_post - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:post,path,params,headers) - @session.post(path,params,headers) - end - - def test_put - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:put,path,params,headers) - @session.put(path,params,headers) - end - - def test_delete - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:delete,path,params,headers) - @session.delete(path,params,headers) - end - - def test_head - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:head,path,params,headers) - @session.head(path,params,headers) - end - - def test_xml_http_request_get - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:get,path,params,headers_after_xhr) - @session.xml_http_request(:get,path,params,headers) - end - - def test_xml_http_request_post - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:post,path,params,headers_after_xhr) - @session.xml_http_request(:post,path,params,headers) - end - - def test_xml_http_request_put - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:put,path,params,headers_after_xhr) - @session.xml_http_request(:put,path,params,headers) - end - - def test_xml_http_request_delete - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:delete,path,params,headers_after_xhr) - @session.xml_http_request(:delete,path,params,headers) - end - - def test_xml_http_request_head - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:head,path,params,headers_after_xhr) - @session.xml_http_request(:head,path,params,headers) - end - - def test_xml_http_request_override_accept - path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest" - ) - @session.expects(:process).with(:post,path,params,headers_after_xhr) - @session.xml_http_request(:post,path,params,headers) - end -end - -class IntegrationTestTest < Test::Unit::TestCase - def setup - @test = ::ActionController::IntegrationTest.new(:default_test) - @test.class.stubs(:fixture_table_names).returns([]) - @session = @test.open_session - end - - def test_opens_new_session - @test.class.expects(:fixture_table_names).times(2).returns(['foo']) - - session1 = @test.open_session { |sess| } - session2 = @test.open_session # implicit session - - assert_equal ::ActionController::Integration::Session, session1.class - assert_equal ::ActionController::Integration::Session, session2.class - assert_not_equal session1, session2 - end - - # RSpec mixes Matchers (which has a #method_missing) into - # IntegrationTest's superclass. Make sure IntegrationTest does not - # try to delegate these methods to the session object. - def test_does_not_prevent_method_missing_passing_up_to_ancestors - mixin = Module.new do - def method_missing(name, *args) - name.to_s == 'foo' ? 'pass' : super - end - end - @test.class.superclass.__send__(:include, mixin) - begin - assert_equal 'pass', @test.foo - ensure - # leave other tests as unaffected as possible - mixin.__send__(:remove_method, :method_missing) - end - end -end - -require 'active_record_unit' -# Tests that fixtures are accessible in the integration test sessions -class IntegrationTestWithFixtures < ActiveRecordTestCase - include ActionController::Integration::Runner - - fixtures :companies - - def test_fixtures_in_new_session - sym = :thirty_seven_signals - # fixtures are accessible in main session - assert_not_nil companies(sym) - - # create a new session and the fixtures should be accessible in it as well - session1 = open_session { |sess| } - assert_not_nil session1.companies(sym) - end -end - -# Tests that integration tests don't call Controller test methods for processing. -# Integration tests have their own setup and teardown. -class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest - def self.fixture_table_names - [] - end - - def test_integration_methods_called - reset! - @integration_session.stubs(:generic_url_rewriter) - @integration_session.stubs(:process) - - %w( get post head put delete ).each do |verb| - assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') } - end - end -end - -class IntegrationProcessTest < ActionController::IntegrationTest - class IntegrationController < ActionController::Base - def get - respond_to do |format| - format.html { render :text => "OK", :status => 200 } - format.js { render :text => "JS OK", :status => 200 } - end - end - - def get_with_params - render :text => "foo: #{params[:foo]}", :status => 200 - end - - def post_with_multiparameter_params - render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}", :status => 200 - end - - def multipart_post_with_multiparameter_params - render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}, filesize: #{params[:file].size}", :status => 200 - end - - def multipart_post_with_nested_params - render :text => "foo: #{params[:foo][0]}, #{params[:foo][1]}; [filesize: #{params[:file_list][0][:content].size}, filesize: #{params[:file_list][1][:content].size}]", :status => 200 - end - - def multipart_post_with_multiparameter_complex_params - render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}, [filesize: #{params[:file_list][0][:content].size}, filesize: #{params[:file_list][1][:content].size}]", :status => 200 - end - - def post - render :text => "Created", :status => 201 - end - - def cookie_monster - cookies["cookie_1"] = nil - cookies["cookie_3"] = "chocolate" - render :text => "Gone", :status => 410 - end - - def redirect - redirect_to :action => "get" - end - end - - FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart' - - def test_get - with_test_route_set do - get '/get' - assert_equal 200, status - assert_equal "OK", status_message - assert_response 200 - assert_response :success - assert_response :ok - assert_equal({}, cookies) - assert_equal "OK", body - assert_equal "OK", response.body - assert_kind_of HTML::Document, html_document - assert_equal 1, request_count - end - end - - def test_post - with_test_route_set do - post '/post' - assert_equal 201, status - assert_equal "Created", status_message - assert_response 201 - assert_response :success - assert_response :created - assert_equal({}, cookies) - assert_equal "Created", body - assert_equal "Created", response.body - assert_kind_of HTML::Document, html_document - assert_equal 1, request_count - end - end - - def test_cookie_monster - with_test_route_set do - self.cookies['cookie_1'] = "sugar" - self.cookies['cookie_2'] = "oatmeal" - get '/cookie_monster' - assert_equal 410, status - assert_equal "Gone", status_message - assert_response 410 - assert_response :gone - assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies) - assert_equal "Gone", response.body - end - end - - def test_redirect - with_test_route_set do - get '/redirect' - assert_equal 302, status - assert_equal "Found", status_message - assert_response 302 - assert_response :redirect - assert_response :found - assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body - assert_kind_of HTML::Document, html_document - assert_equal 1, request_count - - follow_redirect! - assert_response :success - assert_equal "/get", path - end - end - - def test_xml_http_request_get - with_test_route_set do - xhr :get, '/get' - assert_equal 200, status - assert_equal "OK", status_message - assert_response 200 - assert_response :success - assert_response :ok - assert_equal "JS OK", response.body - end - end - - def test_get_with_query_string - with_test_route_set do - get '/get_with_params?foo=bar' - assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"] - assert_equal '/get_with_params?foo=bar', request.request_uri - assert_equal "", request.env["QUERY_STRING"] - assert_equal 'foo=bar', request.query_string - assert_equal 'bar', request.parameters['foo'] - - assert_equal 200, status - assert_equal "foo: bar", response.body - end - end - - def test_get_with_parameters - with_test_route_set do - get '/get_with_params', :foo => "bar" - assert_equal '/get_with_params', request.env["REQUEST_URI"] - assert_equal '/get_with_params', request.request_uri - assert_equal 'foo=bar', request.env["QUERY_STRING"] - assert_equal 'foo=bar', request.query_string - assert_equal 'bar', request.parameters['foo'] - - assert_equal 200, status - assert_equal "foo: bar", response.body - end - end - - def test_post_with_multiparameter_attribute_parameters - with_test_route_set do - post '/post_with_multiparameter_params', :"foo(1i)" => "bar", :"foo(2i)" => "baz" - - assert_equal 200, status - assert_equal "foo(1i): bar, foo(2i): baz", response.body - end - end - - def test_multipart_post_with_multiparameter_attribute_parameters - with_test_route_set do - post '/multipart_post_with_multiparameter_params', :"foo(1i)" => "bar", :"foo(2i)" => "baz", :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") - - assert_equal 200, status - assert_equal "foo(1i): bar, foo(2i): baz, filesize: 159528", response.body - end - end - - def test_multipart_post_with_nested_params - with_test_route_set do - post '/multipart_post_with_nested_params', :"foo" => ['a', 'b'], :file_list => [{:content => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")}, {:content => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")}] - - assert_equal 200, status - assert_equal "foo: a, b; [filesize: 159528, filesize: 159528]", response.body - end - end - - def test_multipart_post_with_multiparameter_complex_attribute_parameters - with_test_route_set do - post '/multipart_post_with_multiparameter_complex_params', :"foo(1i)" => "bar", :"foo(2i)" => "baz", :file_list => [{:content => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")}, {:content => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")}] - - assert_equal 200, status - assert_equal "foo(1i): bar, foo(2i): baz, [filesize: 159528, filesize: 159528]", response.body - end - end - - def test_head - with_test_route_set do - head '/get' - assert_equal 200, status - assert_equal "", body - - head '/post' - assert_equal 201, status - assert_equal "", body - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "IntegrationProcessTest::Integration" do |c| - c.connect "/:action" - end - end - yield - end - end -end - -class MetalTest < ActionController::IntegrationTest - class Poller - def self.call(env) - if env["PATH_INFO"] =~ /^\/success/ - [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, ["Hello World!"]] - else - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] - end - end - end - - def setup - @integration_session = ActionController::Integration::Session.new(Poller) - end - - def test_successful_get - get "/success" - assert_response 200 - assert_response :success - assert_response :ok - assert_equal "Hello World!", response.body - end - - def test_failed_get - get "/failure" - assert_response 404 - assert_response :not_found - assert_equal '', response.body - end -end - -class StringSubclassBodyTest < ActionController::IntegrationTest - class SafeString < String - end - - class SafeStringMiddleware - def self.call(env) - [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, [SafeString.new("Hello World!")]] - end - end - - def setup - @integration_session = ActionController::Integration::Session.new(SafeStringMiddleware) - end - - def test_string_subclass_body - get '/' - assert_equal 'Hello World!', response.body - end -end diff --git a/vendor/rails/actionpack/test/controller/layout_test.rb b/vendor/rails/actionpack/test/controller/layout_test.rb deleted file mode 100644 index 7bed9637..00000000 --- a/vendor/rails/actionpack/test/controller/layout_test.rb +++ /dev/null @@ -1,215 +0,0 @@ -require 'abstract_unit' - -# The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited -# method has access to the view_paths array when looking for a layout to automatically assign. -old_load_paths = ActionController::Base.view_paths - -ActionView::Template::register_template_handler :mab, - lambda { |template| template.source.inspect } - -ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ] - -class LayoutTest < ActionController::Base - def self.controller_path; 'views' end - self.view_paths = ActionController::Base.view_paths.dup -end - -# Restore view_paths to previous value -ActionController::Base.view_paths = old_load_paths - -class ProductController < LayoutTest -end - -class ItemController < LayoutTest -end - -class ThirdPartyTemplateLibraryController < LayoutTest -end - -module ControllerNameSpace -end - -class ControllerNameSpace::NestedController < LayoutTest -end - -class MultipleExtensions < LayoutTest -end - -class LayoutAutoDiscoveryTest < ActionController::TestCase - def setup - @request.host = "www.nextangle.com" - end - - def test_application_layout_is_default_when_no_controller_match - @controller = ProductController.new - get :hello - assert_equal 'layout_test.rhtml hello.rhtml', @response.body - end - - def test_controller_name_layout_name_match - @controller = ItemController.new - get :hello - assert_equal 'item.rhtml hello.rhtml', @response.body - end - - def test_third_party_template_library_auto_discovers_layout - @controller = ThirdPartyTemplateLibraryController.new - get :hello - assert_equal 'layouts/third_party_template_library.mab', @controller.active_layout.to_s - assert_equal 'layouts/third_party_template_library', @response.layout - assert_response :success - assert_equal 'Mab', @response.body - end - - def test_namespaced_controllers_auto_detect_layouts - @controller = ControllerNameSpace::NestedController.new - get :hello - assert_equal 'layouts/controller_name_space/nested', @controller.active_layout.to_s - assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body - end - - def test_namespaced_controllers_auto_detect_layouts - @controller = MultipleExtensions.new - get :hello - assert_equal 'layouts/multiple_extensions.html.erb', @controller.active_layout.to_s - assert_equal 'multiple_extensions.html.erb hello.rhtml', @response.body.strip - end -end - -class DefaultLayoutController < LayoutTest -end - -class AbsolutePathLayoutController < LayoutTest - layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/layouts/layout_test.rhtml') -end - -class AbsolutePathWithoutLayoutsController < LayoutTest - # Absolute layout path without 'layouts' in it. - layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/abs_path_layout.rhtml') -end - -class HasOwnLayoutController < LayoutTest - layout 'item' -end - -class PrependsViewPathController < LayoutTest - def hello - prepend_view_path File.dirname(__FILE__) + '/../fixtures/layout_tests/alt/' - render :layout => 'alt' - end -end - -class SetsLayoutInRenderController < LayoutTest - def hello - render :layout => 'third_party_template_library' - end -end - -class RendersNoLayoutController < LayoutTest - def hello - render :layout => false - end -end - -class LayoutSetInResponseTest < ActionController::TestCase - def test_layout_set_when_using_default_layout - @controller = DefaultLayoutController.new - get :hello - assert_equal 'layouts/layout_test', @response.layout - end - - def test_layout_set_when_set_in_controller - @controller = HasOwnLayoutController.new - get :hello - assert_equal 'layouts/item', @response.layout - end - - def test_layout_set_when_using_render - @controller = SetsLayoutInRenderController.new - get :hello - assert_equal 'layouts/third_party_template_library', @response.layout - end - - def test_layout_is_not_set_when_none_rendered - @controller = RendersNoLayoutController.new - get :hello - assert_nil @response.layout - end - - def test_exempt_from_layout_honored_by_render_template - ActionController::Base.exempt_from_layout :rhtml - @controller = RenderWithTemplateOptionController.new - - get :hello - assert_equal "alt/hello.rhtml", @response.body.strip - - ensure - ActionController::Base.exempt_from_layout.delete(/\.rhtml$/) - end - - def test_layout_is_picked_from_the_controller_instances_view_path - @controller = PrependsViewPathController.new - get :hello - assert_equal 'layouts/alt', @response.layout - end - - def test_absolute_pathed_layout - @controller = AbsolutePathLayoutController.new - get :hello - assert_equal "layout_test.rhtml hello.rhtml", @response.body.strip - end - - def test_absolute_pathed_layout_without_layouts_in_path - @controller = AbsolutePathWithoutLayoutsController.new - get :hello - assert_equal "abs_path_layout.rhtml hello.rhtml", @response.body.strip - end -end - -class RenderWithTemplateOptionController < LayoutTest - def hello - render :template => 'alt/hello' - end -end - -class SetsNonExistentLayoutFile < LayoutTest - layout "nofile.rhtml" -end - -class LayoutExceptionRaised < ActionController::TestCase - def test_exception_raised_when_layout_file_not_found - @controller = SetsNonExistentLayoutFile.new - get :hello - assert_kind_of ActionView::MissingTemplate, @response.template.instance_eval { @exception } - end -end - -class LayoutStatusIsRendered < LayoutTest - def hello - render :status => 401 - end -end - -class LayoutStatusIsRenderedTest < ActionController::TestCase - def test_layout_status_is_rendered - @controller = LayoutStatusIsRendered.new - get :hello - assert_response 401 - end -end - -unless RUBY_PLATFORM =~ /(:?mswin|mingw|bccwin)/ - class LayoutSymlinkedTest < LayoutTest - layout "symlinked/symlinked_layout" - end - - class LayoutSymlinkedIsRenderedTest < ActionController::TestCase - def test_symlinked_layout_is_rendered - @controller = LayoutSymlinkedTest.new - get :hello - assert_response 200 - assert_equal "layouts/symlinked/symlinked_layout", @response.layout - end - end -end - diff --git a/vendor/rails/actionpack/test/controller/localized_templates_test.rb b/vendor/rails/actionpack/test/controller/localized_templates_test.rb deleted file mode 100644 index e89e5a81..00000000 --- a/vendor/rails/actionpack/test/controller/localized_templates_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'abstract_unit' - -class LocalizedController < ActionController::Base - def hello_world - end -end - -class LocalizedTemplatesTest < ActionController::TestCase - tests LocalizedController - - teardown { I18n.locale = :en } - - def test_localized_template_is_used - I18n.locale = :de - get :hello_world - assert_equal "Gutten Tag", @response.body - end - - def test_default_locale_template_is_used_when_locale_is_missing - I18n.locale = :dk - get :hello_world - assert_equal "Hello World", @response.body - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/logging_test.rb b/vendor/rails/actionpack/test/controller/logging_test.rb deleted file mode 100644 index 3c936854..00000000 --- a/vendor/rails/actionpack/test/controller/logging_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'abstract_unit' - -class LoggingController < ActionController::Base - def show - render :nothing => true - end -end - -class LoggingTest < ActionController::TestCase - tests LoggingController - - class MockLogger - attr_reader :logged - - def method_missing(method, *args) - @logged ||= [] - @logged << args.first - end - end - - setup :set_logger - - def test_logging_without_parameters - get :show - assert_equal 2, logs.size - assert_nil logs.detect {|l| l =~ /Parameters/ } - end - - def test_logging_with_parameters - get :show, :id => 10 - assert_equal 3, logs.size - - params = logs.detect {|l| l =~ /Parameters/ } - assert_equal 'Parameters: {"id"=>"10"}', params - end - - private - - def set_logger - @controller.logger = MockLogger.new - end - - def logs - @logs ||= @controller.logger.logged.compact.map {|l| l.strip} - end -end diff --git a/vendor/rails/actionpack/test/controller/middleware_stack_test.rb b/vendor/rails/actionpack/test/controller/middleware_stack_test.rb deleted file mode 100644 index 91823101..00000000 --- a/vendor/rails/actionpack/test/controller/middleware_stack_test.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'abstract_unit' - -class MiddlewareStackTest < ActiveSupport::TestCase - class FooMiddleware; end - class BarMiddleware; end - class BazMiddleware; end - - def setup - @stack = ActionController::MiddlewareStack.new - @stack.use FooMiddleware - @stack.use BarMiddleware - end - - test "use should push middleware as class onto the stack" do - assert_difference "@stack.size" do - @stack.use BazMiddleware - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "use should push middleware as a string onto the stack" do - assert_difference "@stack.size" do - @stack.use "MiddlewareStackTest::BazMiddleware" - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "use should push middleware as a symbol onto the stack" do - assert_difference "@stack.size" do - @stack.use :"MiddlewareStackTest::BazMiddleware" - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "use should push middleware class with arguments onto the stack" do - assert_difference "@stack.size" do - @stack.use BazMiddleware, true, :foo => "bar" - end - assert_equal BazMiddleware, @stack.last.klass - assert_equal([true, {:foo => "bar"}], @stack.last.args) - end - - test "insert inserts middleware at the integer index" do - @stack.insert(1, BazMiddleware) - assert_equal BazMiddleware, @stack[1].klass - end - - test "insert_after inserts middleware after the integer index" do - @stack.insert_after(1, BazMiddleware) - assert_equal BazMiddleware, @stack[2].klass - end - - test "insert_before inserts middleware before another middleware class" do - @stack.insert_before(BarMiddleware, BazMiddleware) - assert_equal BazMiddleware, @stack[1].klass - end - - test "insert_after inserts middleware after another middleware class" do - @stack.insert_after(BarMiddleware, BazMiddleware) - assert_equal BazMiddleware, @stack[2].klass - end - - test "swaps one middleware out for another" do - assert_equal FooMiddleware, @stack[0].klass - @stack.swap(FooMiddleware, BazMiddleware) - assert_equal BazMiddleware, @stack[0].klass - end - - test "active returns all only enabled middleware" do - assert_no_difference "@stack.active.size" do - assert_difference "@stack.size" do - @stack.use BazMiddleware, :if => lambda { false } - end - end - end - - test "lazy evaluates middleware class" do - assert_difference "@stack.size" do - @stack.use lambda { BazMiddleware } - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "lazy evaluates middleware arguments" do - assert_difference "@stack.size" do - @stack.use BazMiddleware, lambda { :foo } - end - assert_equal [:foo], @stack.last.send(:build_args) - end -end diff --git a/vendor/rails/actionpack/test/controller/mime_responds_test.rb b/vendor/rails/actionpack/test/controller/mime_responds_test.rb deleted file mode 100644 index edd71623..00000000 --- a/vendor/rails/actionpack/test/controller/mime_responds_test.rb +++ /dev/null @@ -1,536 +0,0 @@ -require 'abstract_unit' - -class RespondToController < ActionController::Base - layout :set_layout - - def html_xml_or_rss - respond_to do |type| - type.html { render :text => "HTML" } - type.xml { render :text => "XML" } - type.rss { render :text => "RSS" } - type.all { render :text => "Nothing" } - end - end - - def js_or_html - respond_to do |type| - type.html { render :text => "HTML" } - type.js { render :text => "JS" } - type.all { render :text => "Nothing" } - end - end - - def json_or_yaml - respond_to do |type| - type.json { render :text => "JSON" } - type.yaml { render :text => "YAML" } - end - end - - def html_or_xml - respond_to do |type| - type.html { render :text => "HTML" } - type.xml { render :text => "XML" } - type.all { render :text => "Nothing" } - end - end - - def forced_xml - request.format = :xml - - respond_to do |type| - type.html { render :text => "HTML" } - type.xml { render :text => "XML" } - end - end - - def just_xml - respond_to do |type| - type.xml { render :text => "XML" } - end - end - - def using_defaults - respond_to do |type| - type.html - type.js - type.xml - end - end - - def using_defaults_with_type_list - respond_to(:html, :js, :xml) - end - - def made_for_content_type - respond_to do |type| - type.rss { render :text => "RSS" } - type.atom { render :text => "ATOM" } - type.all { render :text => "Nothing" } - end - end - - def custom_type_handling - respond_to do |type| - type.html { render :text => "HTML" } - type.custom("application/crazy-xml") { render :text => "Crazy XML" } - type.all { render :text => "Nothing" } - end - end - - def custom_constant_handling - Mime::Type.register("text/x-mobile", :mobile) - - respond_to do |type| - type.html { render :text => "HTML" } - type.mobile { render :text => "Mobile" } - end - ensure - Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) } - end - - def custom_constant_handling_without_block - Mime::Type.register("text/x-mobile", :mobile) - - respond_to do |type| - type.html { render :text => "HTML" } - type.mobile - end - - ensure - Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) } - end - - def handle_any - respond_to do |type| - type.html { render :text => "HTML" } - type.any(:js, :xml) { render :text => "Either JS or XML" } - end - end - - def handle_any_any - respond_to do |type| - type.html { render :text => 'HTML' } - type.any { render :text => 'Whatever you ask for, I got it' } - end - end - - def all_types_with_layout - respond_to do |type| - type.html - type.js - end - end - - def iphone_with_html_response_type - Mime::Type.register_alias("text/html", :iphone) - request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone" - - respond_to do |type| - type.html { @type = "Firefox" } - type.iphone { @type = "iPhone" } - end - - ensure - Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) } - end - - def iphone_with_html_response_type_without_layout - Mime::Type.register_alias("text/html", :iphone) - request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" - - respond_to do |type| - type.html { @type = "Firefox"; render :action => "iphone_with_html_response_type" } - type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" } - end - - ensure - Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) } - end - - def rescue_action(e) - raise - end - - protected - def set_layout - if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name) - "respond_to/layouts/standard" - elsif action_name == "iphone_with_html_response_type_without_layout" - "respond_to/layouts/missing" - end - end -end - -class MimeControllerTest < ActionController::TestCase - tests RespondToController - - def setup - ActionController::Base.use_accept_header = true - @request.host = "www.example.com" - end - - def teardown - ActionController::Base.use_accept_header = false - end - - def test_html - @request.accept = "text/html" - get :js_or_html - assert_equal 'HTML', @response.body - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_response 406 - end - - def test_all - @request.accept = "*/*" - get :js_or_html - assert_equal 'HTML', @response.body # js is not part of all - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_equal 'XML', @response.body - end - - def test_xml - @request.accept = "application/xml" - get :html_xml_or_rss - assert_equal 'XML', @response.body - end - - def test_js_or_html - @request.accept = "text/javascript, text/html" - get :js_or_html - assert_equal 'JS', @response.body - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_response 406 - end - - def test_json_or_yaml - get :json_or_yaml - assert_equal 'JSON', @response.body - - get :json_or_yaml, :format => 'json' - assert_equal 'JSON', @response.body - - get :json_or_yaml, :format => 'yaml' - assert_equal 'YAML', @response.body - - { 'YAML' => %w(text/yaml), - 'JSON' => %w(application/json text/x-json) - }.each do |body, content_types| - content_types.each do |content_type| - @request.accept = content_type - get :json_or_yaml - assert_equal body, @response.body - end - end - end - - def test_js_or_anything - @request.accept = "text/javascript, */*" - get :js_or_html - assert_equal 'JS', @response.body - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_equal 'XML', @response.body - end - - def test_using_defaults - @request.accept = "*/*" - get :using_defaults - assert_equal "text/html", @response.content_type - assert_equal 'Hello world!', @response.body - - @request.accept = "text/javascript" - get :using_defaults - assert_equal "text/javascript", @response.content_type - assert_equal '$("body").visualEffect("highlight");', @response.body - - @request.accept = "application/xml" - get :using_defaults - assert_equal "application/xml", @response.content_type - assert_equal "<p>Hello world!</p>\n", @response.body - end - - def test_using_defaults_with_type_list - @request.accept = "*/*" - get :using_defaults_with_type_list - assert_equal "text/html", @response.content_type - assert_equal 'Hello world!', @response.body - - @request.accept = "text/javascript" - get :using_defaults_with_type_list - assert_equal "text/javascript", @response.content_type - assert_equal '$("body").visualEffect("highlight");', @response.body - - @request.accept = "application/xml" - get :using_defaults_with_type_list - assert_equal "application/xml", @response.content_type - assert_equal "<p>Hello world!</p>\n", @response.body - end - - def test_with_atom_content_type - @request.env["CONTENT_TYPE"] = "application/atom+xml" - get :made_for_content_type - assert_equal "ATOM", @response.body - end - - def test_with_rss_content_type - @request.env["CONTENT_TYPE"] = "application/rss+xml" - get :made_for_content_type - assert_equal "RSS", @response.body - end - - def test_synonyms - @request.accept = "application/javascript" - get :js_or_html - assert_equal 'JS', @response.body - - @request.accept = "application/x-xml" - get :html_xml_or_rss - assert_equal "XML", @response.body - end - - def test_custom_types - @request.accept = "application/crazy-xml" - get :custom_type_handling - assert_equal "application/crazy-xml", @response.content_type - assert_equal 'Crazy XML', @response.body - - @request.accept = "text/html" - get :custom_type_handling - assert_equal "text/html", @response.content_type - assert_equal 'HTML', @response.body - end - - def test_xhtml_alias - @request.accept = "application/xhtml+xml,application/xml" - get :html_or_xml - assert_equal 'HTML', @response.body - end - - def test_firefox_simulation - @request.accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" - get :html_or_xml - assert_equal 'HTML', @response.body - end - - def test_handle_any - @request.accept = "*/*" - get :handle_any - assert_equal 'HTML', @response.body - - @request.accept = "text/javascript" - get :handle_any - assert_equal 'Either JS or XML', @response.body - - @request.accept = "text/xml" - get :handle_any - assert_equal 'Either JS or XML', @response.body - end - - def test_handle_any_any - @request.accept = "*/*" - get :handle_any_any - assert_equal 'HTML', @response.body - end - - def test_handle_any_any_parameter_format - get :handle_any_any, {:format=>'html'} - assert_equal 'HTML', @response.body - end - - def test_handle_any_any_explicit_html - @request.accept = "text/html" - get :handle_any_any - assert_equal 'HTML', @response.body - end - - def test_handle_any_any_javascript - @request.accept = "text/javascript" - get :handle_any_any - assert_equal 'Whatever you ask for, I got it', @response.body - end - - def test_handle_any_any_xml - @request.accept = "text/xml" - get :handle_any_any - assert_equal 'Whatever you ask for, I got it', @response.body - end - - def test_rjs_type_skips_layout - @request.accept = "text/javascript" - get :all_types_with_layout - assert_equal 'RJS for all_types_with_layout', @response.body - end - - def test_html_type_with_layout - @request.accept = "text/html" - get :all_types_with_layout - assert_equal '<html><div id="html">HTML for all_types_with_layout</div></html>', @response.body - end - - def test_xhr - xhr :get, :js_or_html - assert_equal 'JS', @response.body - - xhr :get, :using_defaults - assert_equal '$("body").visualEffect("highlight");', @response.body - end - - def test_custom_constant - get :custom_constant_handling, :format => "mobile" - assert_equal "text/x-mobile", @response.content_type - assert_equal "Mobile", @response.body - end - - def test_custom_constant_handling_without_block - get :custom_constant_handling_without_block, :format => "mobile" - assert_equal "text/x-mobile", @response.content_type - assert_equal "Mobile", @response.body - end - - def test_forced_format - get :html_xml_or_rss - assert_equal "HTML", @response.body - - get :html_xml_or_rss, :format => "html" - assert_equal "HTML", @response.body - - get :html_xml_or_rss, :format => "xml" - assert_equal "XML", @response.body - - get :html_xml_or_rss, :format => "rss" - assert_equal "RSS", @response.body - end - - def test_internally_forced_format - get :forced_xml - assert_equal "XML", @response.body - - get :forced_xml, :format => "html" - assert_equal "XML", @response.body - end - - def test_extension_synonyms - get :html_xml_or_rss, :format => "xhtml" - assert_equal "HTML", @response.body - end - - def test_render_action_for_html - @controller.instance_eval do - def render(*args) - unless args.empty? - @action = args.first[:action] - end - response.body = "#{@action} - #{@template.template_format}" - end - end - - get :using_defaults - assert_equal "using_defaults - html", @response.body - - get :using_defaults, :format => "xml" - assert_equal "using_defaults - xml", @response.body - end - - def test_format_with_custom_response_type - get :iphone_with_html_response_type - assert_equal '<html><div id="html">Hello future from Firefox!</div></html>', @response.body - - get :iphone_with_html_response_type, :format => "iphone" - assert_equal "text/html", @response.content_type - assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body - end - - def test_format_with_custom_response_type_and_request_headers - @request.accept = "text/iphone" - get :iphone_with_html_response_type - assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body - assert_equal "text/html", @response.content_type - end - - def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present - get :iphone_with_html_response_type_without_layout - assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body - - @request.accept = "text/iphone" - assert_raise(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout } - end -end - -class AbstractPostController < ActionController::Base - self.view_paths = File.dirname(__FILE__) + "/../fixtures/post_test/" -end - -# For testing layouts which are set automatically -class PostController < AbstractPostController - around_filter :with_iphone - - def index - respond_to do |type| - type.html - type.iphone - end - end - - protected - def with_iphone - Mime::Type.register_alias("text/html", :iphone) - request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" - yield - ensure - Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) } - end -end - -class SuperPostController < PostController - def index - respond_to do |type| - type.html - type.iphone - end - end -end - -class MimeControllerLayoutsTest < ActionController::TestCase - tests PostController - - def setup - @request.host = "www.example.com" - end - - def test_missing_layout_renders_properly - get :index - assert_equal '<html><div id="html">Hello Firefox</div></html>', @response.body - - @request.accept = "text/iphone" - get :index - assert_equal 'Hello iPhone', @response.body - end - - def test_format_with_inherited_layouts - @controller = SuperPostController.new - - get :index - assert_equal 'Super Firefox', @response.body - - @request.accept = "text/iphone" - get :index - assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body - end -end diff --git a/vendor/rails/actionpack/test/controller/mime_type_test.rb b/vendor/rails/actionpack/test/controller/mime_type_test.rb deleted file mode 100644 index c7faa621..00000000 --- a/vendor/rails/actionpack/test/controller/mime_type_test.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'abstract_unit' - -class MimeTypeTest < Test::Unit::TestCase - Mime::Type.register "image/png", :png - Mime::Type.register "application/pdf", :pdf - - def test_parse_single - Mime::LOOKUP.keys.each do |mime_type| - assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type) - end - end - - def test_parse_without_q - accept = "text/xml,application/xhtml+xml,text/yaml,application/xml,text/html,image/png,text/plain,application/pdf,*/*" - expect = [Mime::HTML, Mime::XML, Mime::YAML, Mime::PNG, Mime::TEXT, Mime::PDF, Mime::ALL] - assert_equal expect, Mime::Type.parse(accept) - end - - def test_parse_with_q - accept = "text/xml,application/xhtml+xml,text/yaml; q=0.3,application/xml,text/html; q=0.8,image/png,text/plain; q=0.5,application/pdf,*/*; q=0.2" - expect = [Mime::HTML, Mime::XML, Mime::PNG, Mime::PDF, Mime::TEXT, Mime::YAML, Mime::ALL] - assert_equal expect, Mime::Type.parse(accept) - end - - # Accept header send with user HTTP_USER_AGENT: Sunrise/0.42j (Windows XP) - def test_parse_crappy_broken_acceptlines - accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/*,,*/*;q=0.5" - expect = [Mime::HTML, Mime::XML, "image/*", Mime::TEXT, Mime::ALL] - assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s } - end - - # Accept header send with user HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1) - def test_parse_crappy_broken_acceptlines2 - accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*" - expect = ['image/gif', 'image/x-xbitmap', 'image/jpeg','image/pjpeg', 'application/x-shockwave-flash', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/msword', 'pronto/1.00.00', 'sslvpn/1.00.00.00', Mime::ALL ] - assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s } - end - - def test_custom_type - Mime::Type.register("image/gif", :gif) - assert_nothing_raised do - Mime::GIF - assert_equal Mime::GIF, Mime::SET.last - end - ensure - Mime.module_eval { remove_const :GIF if const_defined?(:GIF) } - end - - def test_type_should_be_equal_to_symbol - assert_equal Mime::HTML, 'application/xhtml+xml' - assert_equal Mime::HTML, :html - end - - def test_type_convenience_methods - # Don't test Mime::ALL, since it Mime::ALL#html? == true - types = Mime::SET.to_a.map(&:to_sym).uniq - [:all] - - # Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE - types.delete_if { |type| !Mime.const_defined?(type.to_s.upcase) } - - types.each do |type| - mime = Mime.const_get(type.to_s.upcase) - assert mime.send("#{type}?"), "#{mime.inspect} is not #{type}?" - invalid_types = types - [type] - invalid_types.delete(:html) if Mime::Type.html_types.include?(type) - invalid_types.each { |other_type| assert !mime.send("#{other_type}?"), "#{mime.inspect} is #{other_type}?" } - end - end - - def test_mime_all_is_html - assert Mime::ALL.all?, "Mime::ALL is not all?" - assert Mime::ALL.html?, "Mime::ALL is not html?" - end - - def test_verifiable_mime_types - all_types = Mime::SET.to_a.map(&:to_sym) - all_types.uniq! - # Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE - all_types.delete_if { |type| !Mime.const_defined?(type.to_s.upcase) } - verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type } - assert verified.each { |type| assert Mime.const_get(type.to_s.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" } - assert unverified.each { |type| assert !Mime.const_get(type.to_s.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" } - end - - def test_regexp_matcher - assert Mime::JS =~ "text/javascript" - assert Mime::JS =~ "application/javascript" - assert Mime::JS !~ "text/html" - assert !(Mime::JS !~ "text/javascript") - assert !(Mime::JS !~ "application/javascript") - assert Mime::HTML =~ 'application/xhtml+xml' - end -end diff --git a/vendor/rails/actionpack/test/controller/output_escaping_test.rb b/vendor/rails/actionpack/test/controller/output_escaping_test.rb deleted file mode 100644 index 43a8c05c..00000000 --- a/vendor/rails/actionpack/test/controller/output_escaping_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'abstract_unit' - -class OutputEscapingTest < ActiveSupport::TestCase - - test "escape_html shouldn't die when passed nil" do - assert ERB::Util.h(nil).blank? - end - - test "escapeHTML should escape strings" do - assert_equal "&lt;&gt;&quot;", ERB::Util.h("<>\"") - end - - test "escapeHTML shouldn't touch explicitly safe strings" do - # TODO this seems easier to compose and reason about, but - # this should be verified - assert_equal "<", ERB::Util.h("<".html_safe) - end - -end diff --git a/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb b/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb deleted file mode 100644 index a075fc4a..00000000 --- a/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb +++ /dev/null @@ -1,297 +0,0 @@ -require 'abstract_unit' - -class Article - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - model = self.class.name.downcase - @id.nil? ? "new #{model}" : "#{model} ##{@id}" - end -end - -class Response < Article - def post_id; 1 end -end - -class Tag < Article - def response_id; 1 end -end - -class Tax - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - model = self.class.name.downcase - @id.nil? ? "new #{model}" : "#{model} ##{@id}" - end -end - -class Fax < Tax - def store_id; 1 end -end - -# TODO: test nested models -class Response::Nested < Response; end - -class PolymorphicRoutesTest < ActiveSupport::TestCase - include ActionController::PolymorphicRoutes - - def setup - @article = Article.new - @response = Response.new - @tax = Tax.new - @fax = Fax.new - end - - def test_with_record - @article.save - expects(:article_url).with(@article) - polymorphic_url(@article) - end - - def test_with_new_record - expects(:articles_url).with() - @article.expects(:new_record?).returns(true) - polymorphic_url(@article) - end - - def test_with_record_and_action - expects(:new_article_url).with() - @article.expects(:new_record?).never - polymorphic_url(@article, :action => 'new') - end - - def test_url_helper_prefixed_with_new - expects(:new_article_url).with() - new_polymorphic_url(@article) - end - - def test_url_helper_prefixed_with_edit - @article.save - expects(:edit_article_url).with(@article) - edit_polymorphic_url(@article) - end - - def test_url_helper_prefixed_with_edit_with_url_options - @article.save - expects(:edit_article_url).with(@article, :param1 => '10') - edit_polymorphic_url(@article, :param1 => '10') - end - - def test_url_helper_with_url_options - @article.save - expects(:article_url).with(@article, :param1 => '10') - polymorphic_url(@article, :param1 => '10') - end - - def test_formatted_url_helper_is_deprecated - expects(:articles_url).with(:format => :pdf) - assert_deprecated do - formatted_polymorphic_url([@article, :pdf]) - end - end - - def test_format_option - @article.save - expects(:article_url).with(@article, :format => :pdf) - polymorphic_url(@article, :format => :pdf) - end - - def test_format_option_with_url_options - @article.save - expects(:article_url).with(@article, :format => :pdf, :param1 => '10') - polymorphic_url(@article, :format => :pdf, :param1 => '10') - end - - def test_id_and_format_option - @article.save - expects(:article_url).with(:id => @article, :format => :pdf) - polymorphic_url(:id => @article, :format => :pdf) - end - - def test_with_nested - @response.save - expects(:article_response_url).with(@article, @response) - polymorphic_url([@article, @response]) - end - - def test_with_nested_unsaved - expects(:article_responses_url).with(@article) - polymorphic_url([@article, @response]) - end - - def test_new_with_array_and_namespace - expects(:new_admin_article_url).with() - polymorphic_url([:admin, @article], :action => 'new') - end - - def test_unsaved_with_array_and_namespace - expects(:admin_articles_url).with() - polymorphic_url([:admin, @article]) - end - - def test_nested_unsaved_with_array_and_namespace - @article.save - expects(:admin_article_url).with(@article) - polymorphic_url([:admin, @article]) - expects(:admin_article_responses_url).with(@article) - polymorphic_url([:admin, @article, @response]) - end - - def test_nested_with_array_and_namespace - @response.save - expects(:admin_article_response_url).with(@article, @response) - polymorphic_url([:admin, @article, @response]) - - # a ridiculously long named route tests correct ordering of namespaces and nesting: - @tag = Tag.new - @tag.save - expects(:site_admin_article_response_tag_url).with(@article, @response, @tag) - polymorphic_url([:site, :admin, @article, @response, @tag]) - end - - def test_nesting_with_array_ending_in_singleton_resource - expects(:article_response_url).with(@article) - polymorphic_url([@article, :response]) - end - - def test_nesting_with_array_containing_singleton_resource - @tag = Tag.new - @tag.save - expects(:article_response_tag_url).with(@article, @tag) - polymorphic_url([@article, :response, @tag]) - end - - def test_nesting_with_array_containing_namespace_and_singleton_resource - @tag = Tag.new - @tag.save - expects(:admin_article_response_tag_url).with(@article, @tag) - polymorphic_url([:admin, @article, :response, @tag]) - end - - def test_nesting_with_array_containing_singleton_resource_and_format - @tag = Tag.new - @tag.save - expects(:article_response_tag_url).with(@article, @tag, :format => :pdf) - polymorphic_url([@article, :response, @tag], :format => :pdf) - end - - def test_nesting_with_array_containing_singleton_resource_and_format_option - @tag = Tag.new - @tag.save - expects(:article_response_tag_url).with(@article, @tag, :format => :pdf) - polymorphic_url([@article, :response, @tag], :format => :pdf) - end - - def test_nesting_with_array_containing_nil - expects(:article_response_url).with(@article) - polymorphic_url([@article, nil, :response]) - end - - def test_with_array_containing_single_object - @article.save - expects(:article_url).with(@article) - polymorphic_url([nil, @article]) - end - - def test_with_array_containing_single_name - @article.save - expects(:articles_url) - polymorphic_url([:articles]) - end - - # TODO: Needs to be updated to correctly know about whether the object is in a hash or not - def xtest_with_hash - expects(:article_url).with(@article) - @article.save - polymorphic_url(:id => @article) - end - - def test_polymorphic_path_accepts_options - expects(:new_article_path).with() - polymorphic_path(@article, :action => :new) - end - - def test_polymorphic_path_does_not_modify_arguments - expects(:admin_article_responses_url).with(@article) - path = [:admin, @article, @response] - assert_no_difference 'path.size' do - polymorphic_url(path) - end - end - - # Tests for names where .plural.singular doesn't round-trip - def test_with_irregular_plural_record - @tax.save - expects(:taxis_url).with(@tax) - polymorphic_url(@tax) - end - - def test_with_irregular_plural_new_record - expects(:taxes_url).with() - @tax.expects(:new_record?).returns(true) - polymorphic_url(@tax) - end - - def test_with_irregular_plural_record_and_action - expects(:new_taxis_url).with() - @tax.expects(:new_record?).never - polymorphic_url(@tax, :action => 'new') - end - - def test_irregular_plural_url_helper_prefixed_with_new - expects(:new_taxis_url).with() - new_polymorphic_url(@tax) - end - - def test_irregular_plural_url_helper_prefixed_with_edit - @tax.save - expects(:edit_taxis_url).with(@tax) - edit_polymorphic_url(@tax) - end - - def test_with_nested_irregular_plurals - @fax.save - expects(:taxis_faxis_url).with(@tax, @fax) - polymorphic_url([@tax, @fax]) - end - - def test_with_nested_unsaved_irregular_plurals - expects(:taxis_faxes_url).with(@tax) - polymorphic_url([@tax, @fax]) - end - - def test_new_with_irregular_plural_array_and_namespace - expects(:new_admin_taxis_url).with() - polymorphic_url([:admin, @tax], :action => 'new') - end - - def test_unsaved_with_irregular_plural_array_and_namespace - expects(:admin_taxes_url).with() - polymorphic_url([:admin, @tax]) - end - - def test_nesting_with_irregular_plurals_and_array_ending_in_singleton_resource - expects(:taxis_faxis_url).with(@tax) - polymorphic_url([@tax, :faxis]) - end - - def test_with_array_containing_single_irregular_plural_object - @tax.save - expects(:taxis_url).with(@tax) - polymorphic_url([nil, @tax]) - end - - def test_with_array_containing_single_name_irregular_plural - @tax.save - expects(:taxes_url) - polymorphic_url([:taxes]) - end - - def test_with_array_containing_symbols - expects(:new_article_url).with() - polymorphic_url([:new, :article]) - end -end diff --git a/vendor/rails/actionpack/test/controller/rack_test.rb b/vendor/rails/actionpack/test/controller/rack_test.rb deleted file mode 100644 index 3d0643cf..00000000 --- a/vendor/rails/actionpack/test/controller/rack_test.rb +++ /dev/null @@ -1,308 +0,0 @@ -require 'abstract_unit' - -class BaseRackTest < ActiveSupport::TestCase - def setup - @env = { - "HTTP_MAX_FORWARDS" => "10", - "SERVER_NAME" => "glu.ttono.us", - "FCGI_ROLE" => "RESPONDER", - "AUTH_TYPE" => "Basic", - "HTTP_X_FORWARDED_HOST" => "glu.ttono.us", - "HTTP_ACCEPT_CHARSET" => "UTF-8", - "HTTP_ACCEPT_ENCODING" => "gzip, deflate", - "HTTP_CACHE_CONTROL" => "no-cache, max-age=0", - "HTTP_PRAGMA" => "no-cache", - "HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)", - "PATH_INFO" => "/homepage/", - "HTTP_ACCEPT_LANGUAGE" => "en", - "HTTP_NEGOTIATE" => "trans", - "HTTP_HOST" => "glu.ttono.us:8007", - "HTTP_REFERER" => "http://www.google.com/search?q=glu.ttono.us", - "HTTP_FROM" => "googlebot", - "SERVER_PROTOCOL" => "HTTP/1.1", - "REDIRECT_URI" => "/dispatch.fcgi", - "SCRIPT_NAME" => "/dispatch.fcgi", - "SERVER_ADDR" => "207.7.108.53", - "REMOTE_ADDR" => "207.7.108.53", - "REMOTE_HOST" => "google.com", - "REMOTE_IDENT" => "kevin", - "REMOTE_USER" => "kevin", - "SERVER_SOFTWARE" => "lighttpd/1.4.5", - "HTTP_COOKIE" => "_session_id=c84ace84796670c052c6ceb2451fb0f2; is_admin=yes", - "HTTP_X_FORWARDED_SERVER" => "glu.ttono.us", - "REQUEST_URI" => "/admin", - "DOCUMENT_ROOT" => "/home/kevinc/sites/typo/public", - "PATH_TRANSLATED" => "/home/kevinc/sites/typo/public/homepage/", - "SERVER_PORT" => "8007", - "QUERY_STRING" => "", - "REMOTE_PORT" => "63137", - "GATEWAY_INTERFACE" => "CGI/1.1", - "HTTP_X_FORWARDED_FOR" => "65.88.180.234", - "HTTP_ACCEPT" => "*/*", - "SCRIPT_FILENAME" => "/home/kevinc/sites/typo/public/dispatch.fcgi", - "REDIRECT_STATUS" => "200", - "REQUEST_METHOD" => "GET" - } - @request = ActionController::Request.new(@env) - # some Nokia phone browsers omit the space after the semicolon separator. - # some developers have grown accustomed to using comma in cookie values. - @alt_cookie_fmt_request = ActionController::Request.new(@env.merge({"HTTP_COOKIE"=>"_session_id=c84ace847,96670c052c6ceb2451fb0f2;is_admin=yes"})) - end - - def default_test; end - - private - - def set_content_data(data) - @request.env['REQUEST_METHOD'] = 'POST' - @request.env['CONTENT_LENGTH'] = data.length - @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' - @request.env['rack.input'] = StringIO.new(data) - end -end - -class RackRequestTest < BaseRackTest - def test_proxy_request - assert_equal 'glu.ttono.us', @request.host_with_port - end - - def test_http_host - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "rubyonrails.org:8080" - assert_equal "rubyonrails.org", @request.host - assert_equal "rubyonrails.org:8080", @request.host_with_port - - @env['HTTP_X_FORWARDED_HOST'] = "www.firsthost.org, www.secondhost.org" - assert_equal "www.secondhost.org", @request.host - end - - def test_http_host_with_default_port_overrides_server_port - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "rubyonrails.org" - assert_equal "rubyonrails.org", @request.host_with_port - end - - def test_host_with_port_defaults_to_server_name_if_no_host_headers - @env.delete "HTTP_X_FORWARDED_HOST" - @env.delete "HTTP_HOST" - assert_equal "glu.ttono.us:8007", @request.host_with_port - end - - def test_host_with_port_falls_back_to_server_addr_if_necessary - @env.delete "HTTP_X_FORWARDED_HOST" - @env.delete "HTTP_HOST" - @env.delete "SERVER_NAME" - assert_equal "207.7.108.53", @request.host - assert_equal 8007, @request.port - assert_equal "207.7.108.53:8007", @request.host_with_port - end - - def test_host_with_port_if_http_standard_port_is_specified - @env['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:80" - assert_equal "glu.ttono.us", @request.host_with_port - end - - def test_host_with_port_if_https_standard_port_is_specified - @env['HTTP_X_FORWARDED_PROTO'] = "https" - @env['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:443" - assert_equal "glu.ttono.us", @request.host_with_port - end - - def test_host_if_ipv6_reference - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]" - assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host - end - - def test_host_if_ipv6_reference_with_port - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]:8008" - assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host - end - - def test_cgi_environment_variables - assert_equal "Basic", @request.auth_type - assert_equal 0, @request.content_length - assert_equal nil, @request.content_type - assert_equal "CGI/1.1", @request.gateway_interface - assert_equal "*/*", @request.accept - assert_equal "UTF-8", @request.accept_charset - assert_equal "gzip, deflate", @request.accept_encoding - assert_equal "en", @request.accept_language - assert_equal "no-cache, max-age=0", @request.cache_control - assert_equal "googlebot", @request.from - assert_equal "glu.ttono.us", @request.host - assert_equal "trans", @request.negotiate - assert_equal "no-cache", @request.pragma - assert_equal "http://www.google.com/search?q=glu.ttono.us", @request.referer - assert_equal "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)", @request.user_agent - assert_equal "/homepage/", @request.path_info - assert_equal "/home/kevinc/sites/typo/public/homepage/", @request.path_translated - assert_equal "", @request.query_string - assert_equal "207.7.108.53", @request.remote_addr - assert_equal "google.com", @request.remote_host - assert_equal "kevin", @request.remote_ident - assert_equal "kevin", @request.remote_user - assert_equal :get, @request.request_method - assert_equal "/dispatch.fcgi", @request.script_name - assert_equal "glu.ttono.us", @request.server_name - assert_equal 8007, @request.server_port - assert_equal "HTTP/1.1", @request.server_protocol - assert_equal "lighttpd", @request.server_software - end - - def test_cookie_syntax_resilience - cookies = @request.cookies - assert_equal "c84ace84796670c052c6ceb2451fb0f2", cookies["_session_id"], cookies.inspect - assert_equal "yes", cookies["is_admin"], cookies.inspect - - alt_cookies = @alt_cookie_fmt_request.cookies - #assert_equal "c84ace847,96670c052c6ceb2451fb0f2", alt_cookies["_session_id"], alt_cookies.inspect - assert_equal "yes", alt_cookies["is_admin"], alt_cookies.inspect - end -end - -class RackRequestParamsParsingTest < BaseRackTest - def test_doesnt_break_when_content_type_has_charset - set_content_data 'flamenco=love' - - assert_equal({"flamenco"=> "love"}, @request.request_parameters) - end - - def test_doesnt_interpret_request_uri_as_query_string_when_missing - @request.env['REQUEST_URI'] = 'foo' - assert_equal({}, @request.query_parameters) - end -end - -class RackRequestContentTypeTest < BaseRackTest - def test_html_content_type_verification - @request.env['CONTENT_TYPE'] = Mime::HTML.to_s - assert @request.content_type.verify_request? - end - - def test_xml_content_type_verification - @request.env['CONTENT_TYPE'] = Mime::XML.to_s - assert !@request.content_type.verify_request? - end -end - -class RackRequestNeedsRewoundTest < BaseRackTest - def test_body_should_be_rewound - data = 'foo' - @env['rack.input'] = StringIO.new(data) - @env['CONTENT_LENGTH'] = data.length - @env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' - - # Read the request body by parsing params. - request = ActionController::Request.new(@env) - request.request_parameters - - # Should have rewound the body. - assert_equal 0, request.body.pos - end -end - -class RackResponseTest < BaseRackTest - def setup - super - @response = ActionController::Response.new - end - - def test_simple_output - @response.body = "Hello, World!" - @response.prepare! - - status, headers, body = @response.to_a - assert_equal 200, status - assert_equal({ - "Content-Type" => "text/html; charset=utf-8", - "Cache-Control" => "private, max-age=0, must-revalidate", - "ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"', - "Content-Length" => "13" - }, headers) - - parts = [] - body.each { |part| parts << part } - assert_equal ["Hello, World!"], parts - end - - def test_utf8_output - @response.body = [1090, 1077, 1089, 1090].pack("U*") - @response.prepare! - - status, headers, body = @response.to_a - assert_equal 200, status - assert_equal({ - "Content-Type" => "text/html; charset=utf-8", - "Cache-Control" => "private, max-age=0, must-revalidate", - "ETag" => '"ebb5e89e8a94e9dd22abf5d915d112b2"', - "Content-Length" => "8" - }, headers) - end - - def test_streaming_block - @response.body = Proc.new do |response, output| - 5.times { |n| output.write(n) } - end - @response.prepare! - - status, headers, body = @response.to_a - assert_equal 200, status - assert_equal({ - "Content-Type" => "text/html; charset=utf-8", - "Cache-Control" => "no-cache" - }, headers) - - parts = [] - body.each { |part| parts << part } - assert_equal ["0", "1", "2", "3", "4"], parts - end - - def test_streaming_block_with_flush_is_deprecated - @response.body = Proc.new do |response, output| - 5.times do |n| - output.write(n) - output.flush - end - end - - assert_deprecated(/output.flush is no longer needed/) do - @response.prepare! - status, headers, body = @response.to_a - - parts = [] - body.each { |part| parts << part } - end - end -end - -class RackResponseHeadersTest < BaseRackTest - def setup - super - @response = ActionController::Response.new - @response.status = "200 OK" - end - - def test_content_type - [204, 304].each do |c| - @response.status = c.to_s - assert !response_headers.has_key?("Content-Type"), "#{c} should not have Content-Type header" - end - - [200, 302, 404, 500].each do |c| - @response.status = c.to_s - assert response_headers.has_key?("Content-Type"), "#{c} did not have Content-Type header" - end - end - - def test_status - assert !response_headers.has_key?('Status') - end - - private - def response_headers - @response.prepare! - @response.to_a[1] - end -end diff --git a/vendor/rails/actionpack/test/controller/record_identifier_test.rb b/vendor/rails/actionpack/test/controller/record_identifier_test.rb deleted file mode 100644 index 12c1eaea..00000000 --- a/vendor/rails/actionpack/test/controller/record_identifier_test.rb +++ /dev/null @@ -1,139 +0,0 @@ -require 'abstract_unit' - -class Comment - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new comment' : "comment ##{@id}" - end -end - -class Comment::Nested < Comment; end - -class Test::Unit::TestCase - protected - def comments_url - 'http://www.example.com/comments' - end - - def comment_url(comment) - "http://www.example.com/comments/#{comment.id}" - end -end - - -class RecordIdentifierTest < Test::Unit::TestCase - include ActionController::RecordIdentifier - - def setup - @klass = Comment - @record = @klass.new - @singular = 'comment' - @plural = 'comments' - end - - def test_dom_id_with_new_record - assert_equal "new_#{@singular}", dom_id(@record) - end - - def test_dom_id_with_new_record_and_prefix - assert_equal "custom_prefix_#{@singular}", dom_id(@record, :custom_prefix) - end - - def test_dom_id_with_saved_record - @record.save - assert_equal "#{@singular}_1", dom_id(@record) - end - - def test_dom_id_with_prefix - @record.save - assert_equal "edit_#{@singular}_1", dom_id(@record, :edit) - end - - def test_partial_path - expected = "#{@plural}/#{@singular}" - assert_equal expected, partial_path(@record) - assert_equal expected, partial_path(Comment) - end - - def test_partial_path_with_namespaced_controller_path - expected = "admin/#{@plural}/#{@singular}" - assert_equal expected, partial_path(@record, "admin/posts") - assert_equal expected, partial_path(@klass, "admin/posts") - end - - def test_partial_path_with_not_namespaced_controller_path - expected = "#{@plural}/#{@singular}" - assert_equal expected, partial_path(@record, "posts") - assert_equal expected, partial_path(@klass, "posts") - end - - def test_dom_class - assert_equal @singular, dom_class(@record) - end - - def test_dom_class_with_prefix - assert_equal "custom_prefix_#{@singular}", dom_class(@record, :custom_prefix) - end - - def test_singular_class_name - assert_equal @singular, singular_class_name(@record) - end - - def test_singular_class_name_for_class - assert_equal @singular, singular_class_name(@klass) - end - - def test_plural_class_name - assert_equal @plural, plural_class_name(@record) - end - - def test_plural_class_name_for_class - assert_equal @plural, plural_class_name(@klass) - end - - private - def method_missing(method, *args) - RecordIdentifier.send(method, *args) - end -end - -class NestedRecordIdentifierTest < RecordIdentifierTest - def setup - @klass = Comment::Nested - @record = @klass.new - @singular = 'comment_nested' - @plural = 'comment_nesteds' - end - - def test_partial_path - expected = "comment/nesteds/nested" - assert_equal expected, partial_path(@record) - assert_equal expected, partial_path(Comment::Nested) - end - - def test_partial_path_with_namespaced_controller_path - expected = "admin/comment/nesteds/nested" - assert_equal expected, partial_path(@record, "admin/posts") - assert_equal expected, partial_path(@klass, "admin/posts") - end - - def test_partial_path_with_deeper_namespaced_controller_path - expected = "deeper/admin/comment/nesteds/nested" - assert_equal expected, partial_path(@record, "deeper/admin/posts") - assert_equal expected, partial_path(@klass, "deeper/admin/posts") - end - - def test_partial_path_with_even_deeper_namespaced_controller_path - expected = "even/more/deeper/admin/comment/nesteds/nested" - assert_equal expected, partial_path(@record, "even/more/deeper/admin/posts") - assert_equal expected, partial_path(@klass, "even/more/deeper/admin/posts") - end - - def test_partial_path_with_not_namespaced_controller_path - expected = "comment/nesteds/nested" - assert_equal expected, partial_path(@record, "posts") - assert_equal expected, partial_path(@klass, "posts") - end -end diff --git a/vendor/rails/actionpack/test/controller/redirect_test.rb b/vendor/rails/actionpack/test/controller/redirect_test.rb deleted file mode 100644 index e80502b6..00000000 --- a/vendor/rails/actionpack/test/controller/redirect_test.rb +++ /dev/null @@ -1,285 +0,0 @@ -require 'abstract_unit' - -class WorkshopsController < ActionController::Base -end - -class Workshop - attr_accessor :id, :new_record - - def initialize(id, new_record) - @id, @new_record = id, new_record - end - - def new_record? - @new_record - end - - def to_s - id.to_s - end -end - -class RedirectController < ActionController::Base - def simple_redirect - redirect_to :action => "hello_world" - end - - def redirect_with_status - redirect_to({:action => "hello_world", :status => 301}) - end - - def redirect_with_status_hash - redirect_to({:action => "hello_world"}, {:status => 301}) - end - - def url_redirect_with_status - redirect_to("http://www.example.com", :status => :moved_permanently) - end - - def url_redirect_with_status_hash - redirect_to("http://www.example.com", {:status => 301}) - end - - def relative_url_redirect_with_status - redirect_to("/things/stuff", :status => :found) - end - - def relative_url_redirect_with_status_hash - redirect_to("/things/stuff", {:status => 301}) - end - - def redirect_to_back_with_status - redirect_to :back, :status => 307 - end - - def host_redirect - redirect_to :action => "other_host", :only_path => false, :host => 'other.test.host' - end - - def module_redirect - redirect_to :controller => 'module_test/module_redirect', :action => "hello_world" - end - - def redirect_with_assigns - @hello = "world" - redirect_to :action => "hello_world" - end - - def redirect_to_url - redirect_to "http://www.rubyonrails.org/" - end - - def redirect_to_url_with_unescaped_query_string - redirect_to "http://dev.rubyonrails.org/query?status=new" - end - - def redirect_to_url_with_complex_scheme - redirect_to "x-test+scheme.complex:redirect" - end - - def redirect_to_back - redirect_to :back - end - - def redirect_to_existing_record - redirect_to Workshop.new(5, false) - end - - def redirect_to_new_record - redirect_to Workshop.new(5, true) - end - - def redirect_to_nil - redirect_to nil - end - - def rescue_errors(e) raise e end - - def rescue_action(e) raise end - - protected - def dashbord_url(id, message) - url_for :action => "dashboard", :params => { "id" => id, "message" => message } - end -end - -class RedirectTest < ActionController::TestCase - tests RedirectController - - def test_simple_redirect - get :simple_redirect - assert_response :redirect - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_redirect_with_no_status - get :simple_redirect - assert_response 302 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_redirect_with_status - get :redirect_with_status - assert_response 301 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_redirect_with_status_hash - get :redirect_with_status_hash - assert_response 301 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_url_redirect_with_status - get :url_redirect_with_status - assert_response 301 - assert_equal "http://www.example.com", redirect_to_url - end - - def test_url_redirect_with_status_hash - get :url_redirect_with_status_hash - assert_response 301 - assert_equal "http://www.example.com", redirect_to_url - end - - - def test_relative_url_redirect_with_status - get :relative_url_redirect_with_status - assert_response 302 - assert_equal "http://test.host/things/stuff", redirect_to_url - end - - def test_relative_url_redirect_with_status_hash - get :relative_url_redirect_with_status_hash - assert_response 301 - assert_equal "http://test.host/things/stuff", redirect_to_url - end - - def test_redirect_to_back_with_status - @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" - get :redirect_to_back_with_status - assert_response 307 - assert_equal "http://www.example.com/coming/from", redirect_to_url - end - - def test_simple_redirect_using_options - get :host_redirect - assert_response :redirect - assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host' - end - - def test_module_redirect - get :module_redirect - assert_response :redirect - assert_redirected_to "http://test.host/module_test/module_redirect/hello_world" - end - - def test_module_redirect_using_options - get :module_redirect - assert_response :redirect - assert_redirected_to :controller => 'module_test/module_redirect', :action => 'hello_world' - end - - def test_redirect_with_assigns - get :redirect_with_assigns - assert_response :redirect - assert_equal "world", assigns["hello"] - end - - def test_redirect_to_url - get :redirect_to_url - assert_response :redirect - assert_redirected_to "http://www.rubyonrails.org/" - end - - def test_redirect_to_url_with_unescaped_query_string - get :redirect_to_url_with_unescaped_query_string - assert_response :redirect - assert_redirected_to "http://dev.rubyonrails.org/query?status=new" - end - - def test_redirect_to_url_with_complex_scheme - get :redirect_to_url_with_complex_scheme - assert_response :redirect - assert_equal "x-test+scheme.complex:redirect", redirect_to_url - end - - def test_redirect_to_back - @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" - get :redirect_to_back - assert_response :redirect - assert_equal "http://www.example.com/coming/from", redirect_to_url - end - - def test_redirect_to_back_with_no_referer - assert_raise(ActionController::RedirectBackError) { - @request.env["HTTP_REFERER"] = nil - get :redirect_to_back - } - end - - def test_redirect_to_record - ActionController::Routing::Routes.draw do |map| - map.resources :workshops - map.connect ':controller/:action/:id' - end - - get :redirect_to_existing_record - assert_equal "http://test.host/workshops/5", redirect_to_url - assert_redirected_to Workshop.new(5, false) - - get :redirect_to_new_record - assert_equal "http://test.host/workshops", redirect_to_url - assert_redirected_to Workshop.new(5, true) - end - - def test_redirect_with_partial_params - get :module_redirect - - assert_deprecated(/test_redirect_with_partial_params/) do - assert_redirected_to :action => 'hello_world' - end - end - - def test_redirect_to_nil - assert_raise(ActionController::ActionControllerError) do - get :redirect_to_nil - end - end -end - -module ModuleTest - class ModuleRedirectController < ::RedirectController - def module_redirect - redirect_to :controller => '/redirect', :action => "hello_world" - end - end - - class ModuleRedirectTest < ActionController::TestCase - tests ModuleRedirectController - - def test_simple_redirect - get :simple_redirect - assert_response :redirect - assert_equal "http://test.host/module_test/module_redirect/hello_world", redirect_to_url - end - - def test_simple_redirect_using_options - get :host_redirect - assert_response :redirect - assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host' - end - - def test_module_redirect - get :module_redirect - assert_response :redirect - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_module_redirect_using_options - get :module_redirect - assert_response :redirect - assert_redirected_to :controller => '/redirect', :action => "hello_world" - end - end -end diff --git a/vendor/rails/actionpack/test/controller/reloader_test.rb b/vendor/rails/actionpack/test/controller/reloader_test.rb deleted file mode 100644 index d78f8111..00000000 --- a/vendor/rails/actionpack/test/controller/reloader_test.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'abstract_unit' -require 'thread' - -class ReloaderTests < ActiveSupport::TestCase - Reloader = ActionController::Reloader - Dispatcher = ActionController::Dispatcher - - class MyBody < Array - def initialize(&block) - @on_close = block - end - - def foo - "foo" - end - - def bar - "bar" - end - - def close - @on_close.call if @on_close - end - end - - def setup - @lock = Mutex.new - end - - def test_it_reloads_the_application_before_yielding - Dispatcher.expects(:reload_application) - Reloader.run(@lock) do - [200, { "Content-Type" => "text/html" }, [""]] - end - end - - def test_it_locks_before_yielding - lock = DummyMutex.new - Dispatcher.expects(:reload_application) - Reloader.run(lock) do - assert lock.locked? - [200, { "Content-Type" => "text/html" }, [""]] - end - assert lock.locked? - end - - def test_it_unlocks_upon_calling_close_on_body - lock = DummyMutex.new - Dispatcher.expects(:reload_application) - headers, status, body = Reloader.run(lock) do - [200, { "Content-Type" => "text/html" }, [""]] - end - body.close - assert !lock.locked? - end - - def test_it_unlocks_if_app_object_raises_exception - lock = DummyMutex.new - Dispatcher.expects(:reload_application) - assert_raise(RuntimeError) do - Reloader.run(lock) do - raise "oh no!" - end - end - assert !lock.locked? - end - - def test_returned_body_object_always_responds_to_close - status, headers, body = Reloader.run(@lock) do - [200, { "Content-Type" => "text/html" }, [""]] - end - assert body.respond_to?(:close) - end - - def test_returned_body_object_behaves_like_underlying_object - status, headers, body = Reloader.run(@lock) do - b = MyBody.new - b << "hello" - b << "world" - [200, { "Content-Type" => "text/html" }, b] - end - assert_equal 2, body.size - assert_equal "hello", body[0] - assert_equal "world", body[1] - assert_equal "foo", body.foo - assert_equal "bar", body.bar - end - - def test_it_calls_close_on_underlying_object_when_close_is_called_on_body - close_called = false - status, headers, body = Reloader.run(@lock) do - b = MyBody.new do - close_called = true - end - [200, { "Content-Type" => "text/html" }, b] - end - body.close - assert close_called - end - - def test_returned_body_object_responds_to_all_methods_supported_by_underlying_object - status, headers, body = Reloader.run(@lock) do - [200, { "Content-Type" => "text/html" }, MyBody.new] - end - assert body.respond_to?(:size) - assert body.respond_to?(:each) - assert body.respond_to?(:foo) - assert body.respond_to?(:bar) - end - - def test_it_doesnt_clean_up_the_application_after_call - Dispatcher.expects(:cleanup_application).never - status, headers, body = Reloader.run(@lock) do - [200, { "Content-Type" => "text/html" }, MyBody.new] - end - end - - def test_it_cleans_up_the_application_when_close_is_called_on_body - Dispatcher.expects(:cleanup_application) - status, headers, body = Reloader.run(@lock) do - [200, { "Content-Type" => "text/html" }, MyBody.new] - end - body.close - end -end diff --git a/vendor/rails/actionpack/test/controller/render_test.rb b/vendor/rails/actionpack/test/controller/render_test.rb deleted file mode 100644 index 288260a2..00000000 --- a/vendor/rails/actionpack/test/controller/render_test.rb +++ /dev/null @@ -1,1783 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_models' - -module Fun - class GamesController < ActionController::Base - def hello_world - end - end -end - -class MockLogger - attr_reader :logged - - def initialize - @logged = [] - end - - def method_missing(method, *args) - @logged << args.first - end -end - -class TestController < ActionController::Base - protect_from_forgery - - class LabellingFormBuilder < ActionView::Helpers::FormBuilder - end - - layout :determine_layout - - def hello_world - end - - def conditional_hello - if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123]) - render :action => 'hello_world' - end - end - - def conditional_hello_with_public_header - if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123], :public => true) - render :action => 'hello_world' - end - end - - def conditional_hello_with_public_header_and_expires_at - expires_in 1.minute - if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123], :public => true) - render :action => 'hello_world' - end - end - - def conditional_hello_with_expires_in - expires_in 1.minute - render :action => 'hello_world' - end - - def conditional_hello_with_expires_in_with_public - expires_in 1.minute, :public => true - render :action => 'hello_world' - end - - def conditional_hello_with_expires_in_with_public_with_more_keys - expires_in 1.minute, :public => true, 'max-stale' => 5.hours - render :action => 'hello_world' - end - - def conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax - expires_in 1.minute, :public => true, :private => nil, 'max-stale' => 5.hours - render :action => 'hello_world' - end - - def conditional_hello_with_bangs - render :action => 'hello_world' - end - before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs - - def handle_last_modified_and_etags - fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ]) - end - - def render_hello_world - render :template => "test/hello_world" - end - - def render_hello_world_with_last_modified_set - response.last_modified = Date.new(2008, 10, 10).to_time - render :template => "test/hello_world" - end - - def render_hello_world_with_etag_set - response.etag = "hello_world" - render :template => "test/hello_world" - end - - def render_hello_world_with_forward_slash - render :template => "/test/hello_world" - end - - def render_template_in_top_directory - render :template => 'shared' - end - - def render_template_in_top_directory_with_slash - render :template => '/shared' - end - - def render_hello_world_from_variable - @person = "david" - render :text => "hello #{@person}" - end - - def render_action_hello_world - render :action => "hello_world" - end - - def render_action_hello_world_as_string - render "hello_world" - end - - def render_action_hello_world_with_symbol - render :action => :hello_world - end - - def render_text_hello_world - render :text => "hello world" - end - - def render_text_hello_world_with_layout - @variable_for_layout = ", I'm here!" - render :text => "hello world", :layout => true - end - - def hello_world_with_layout_false - render :layout => false - end - - def render_file_with_instance_variables - @secret = 'in the sauce' - path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb') - render :file => path - end - - def render_file_as_string_with_instance_variables - @secret = 'in the sauce' - path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')) - render path - end - - def render_file_not_using_full_path - @secret = 'in the sauce' - render :file => 'test/render_file_with_ivar' - end - - def render_file_not_using_full_path_with_dot_in_path - @secret = 'in the sauce' - render :file => 'test/dot.directory/render_file_with_ivar' - end - - def render_file_using_pathname - @secret = 'in the sauce' - render :file => Pathname.new(File.dirname(__FILE__)).join('..', 'fixtures', 'test', 'dot.directory', 'render_file_with_ivar.erb') - end - - def render_file_from_template - @secret = 'in the sauce' - @path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')) - end - - def render_file_with_locals - path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb') - render :file => path, :locals => {:secret => 'in the sauce'} - end - - def render_file_as_string_with_locals - path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb')) - render path, :locals => {:secret => 'in the sauce'} - end - - def accessing_request_in_template - render :inline => "Hello: <%= request.host %>" - end - - def accessing_logger_in_template - render :inline => "<%= logger.class %>" - end - - def accessing_action_name_in_template - render :inline => "<%= action_name %>" - end - - def accessing_controller_name_in_template - render :inline => "<%= controller_name %>" - end - - def render_json_nil - render :json => nil - end - - def render_json_hello_world - render :json => ActiveSupport::JSON.encode(:hello => 'world') - end - - def render_json_hello_world_with_callback - render :json => ActiveSupport::JSON.encode(:hello => 'world'), :callback => 'alert' - end - - def render_json_with_custom_content_type - render :json => ActiveSupport::JSON.encode(:hello => 'world'), :content_type => 'text/javascript' - end - - def render_symbol_json - render :json => ActiveSupport::JSON.encode(:hello => 'world') - end - - def render_json_with_render_to_string - render :json => {:hello => render_to_string(:partial => 'partial')} - end - - def render_custom_code - render :text => "hello world", :status => 404 - end - - def render_custom_code_rjs - render :update, :status => 404 do |page| - page.replace :foo, :partial => 'partial' - end - end - - def render_text_with_nil - render :text => nil - end - - def render_text_with_false - render :text => false - end - - def render_nothing_with_appendix - render :text => "appended" - end - - def render_vanilla_js_hello - render :js => "alert('hello')" - end - - def render_xml_hello - @name = "David" - render :template => "test/hello" - end - - def render_xml_hello_as_string_template - @name = "David" - render "test/hello" - end - - def render_xml_with_custom_content_type - render :xml => "<blah/>", :content_type => "application/atomsvc+xml" - end - - def render_line_offset - render :inline => '<% raise %>', :locals => {:foo => 'bar'} - end - - def heading - head :ok - end - - def greeting - # let's just rely on the template - end - - def blank_response - render :text => ' ' - end - - def layout_test - render :action => "hello_world" - end - - def builder_layout_test - render :action => "hello", :layout => "layouts/builder" - end - - def builder_partial_test - render :action => "hello_world_container" - end - - def partials_list - @test_unchanged = 'hello' - @customers = [ Customer.new("david"), Customer.new("mary") ] - render :action => "list" - end - - def partial_only - render :partial => true - end - - def hello_in_a_string - @customers = [ Customer.new("david"), Customer.new("mary") ] - render :text => "How's there? " + render_to_string(:template => "test/list") - end - - def accessing_params_in_template - render :inline => "Hello: <%= params[:name] %>" - end - - def accessing_local_assigns_in_inline_template - name = params[:local_name] - render :inline => "<%= 'Goodbye, ' + local_name %>", - :locals => { :local_name => name } - end - - def render_implicit_html_template - end - - def render_explicit_html_template - end - - def render_implicit_html_template_from_xhr_request - end - - def render_implicit_js_template_without_layout - end - - def render_html_explicit_template_and_layout - render :template => 'test/render_implicit_html_template_from_xhr_request', :layout => 'layouts/default_html' - end - - def formatted_html_erb - end - - def formatted_xml_erb - end - - def render_to_string_test - @foo = render_to_string :inline => "this is a test" - end - - def default_render - if @alternate_default_render - @alternate_default_render.call - else - super - end - end - - def render_action_hello_world_as_symbol - render :action => :hello_world - end - - def layout_test_with_different_layout - render :action => "hello_world", :layout => "standard" - end - - def layout_test_with_different_layout_and_string_action - render "hello_world", :layout => "standard" - end - - def layout_test_with_different_layout_and_symbol_action - render :hello_world, :layout => "standard" - end - - def rendering_without_layout - render :action => "hello_world", :layout => false - end - - def layout_overriding_layout - render :action => "hello_world", :layout => "standard" - end - - def rendering_nothing_on_layout - render :nothing => true - end - - def render_to_string_with_assigns - @before = "i'm before the render" - render_to_string :text => "foo" - @after = "i'm after the render" - render :action => "test/hello_world" - end - - def render_to_string_with_exception - render_to_string :file => "exception that will not be caught - this will certainly not work" - end - - def render_to_string_with_caught_exception - @before = "i'm before the render" - begin - render_to_string :file => "exception that will be caught- hope my future instance vars still work!" - rescue - end - @after = "i'm after the render" - render :action => "test/hello_world" - end - - def accessing_params_in_template_with_layout - render :layout => nil, :inline => "Hello: <%= params[:name] %>" - end - - def render_with_explicit_template - render :template => "test/hello_world" - end - - def render_with_explicit_string_template - render "test/hello_world" - end - - def render_with_explicit_template_with_locals - render :template => "test/render_file_with_locals", :locals => { :secret => 'area51' } - end - - def double_render - render :text => "hello" - render :text => "world" - end - - def double_redirect - redirect_to :action => "double_render" - redirect_to :action => "double_render" - end - - def render_and_redirect - render :text => "hello" - redirect_to :action => "double_render" - end - - def render_to_string_and_render - @stuff = render_to_string :text => "here is some cached stuff" - render :text => "Hi web users! #{@stuff}" - end - - def render_to_string_with_inline_and_render - render_to_string :inline => "<%= 'dlrow olleh'.reverse %>" - render :template => "test/hello_world" - end - - def rendering_with_conflicting_local_vars - @name = "David" - def @template.name() nil end - render :action => "potential_conflicts" - end - - def hello_world_from_rxml_using_action - render :action => "hello_world_from_rxml.builder" - end - - def hello_world_from_rxml_using_template - render :template => "test/hello_world_from_rxml.builder" - end - - module RenderTestHelper - def rjs_helper_method_from_module - page.visual_effect :highlight - end - end - - helper RenderTestHelper - helper do - def rjs_helper_method(value) - page.visual_effect :highlight, value - end - end - - def enum_rjs_test - render :update do |page| - page.select('.product').each do |value| - page.rjs_helper_method_from_module - page.rjs_helper_method(value) - page.sortable(value, :url => { :action => "order" }) - page.draggable(value) - end - end - end - - def delete_with_js - @project_id = 4 - end - - def render_js_with_explicit_template - @project_id = 4 - render :template => 'test/delete_with_js' - end - - def render_js_with_explicit_action_template - @project_id = 4 - render :action => 'delete_with_js' - end - - def update_page - render :update do |page| - page.replace_html 'balance', '$37,000,000.00' - page.visual_effect :highlight, 'balance' - end - end - - def update_page_with_instance_variables - @money = '$37,000,000.00' - @div_id = 'balance' - render :update do |page| - page.replace_html @div_id, @money - page.visual_effect :highlight, @div_id - end - end - - def update_page_with_view_method - render :update do |page| - page.replace_html 'person', pluralize(2, 'person') - end - end - - def action_talk_to_layout - # Action template sets variable that's picked up by layout - end - - def render_text_with_assigns - @hello = "world" - render :text => "foo" - end - - def yield_content_for - render :action => "content_for", :layout => "yield" - end - - def render_content_type_from_body - response.content_type = Mime::RSS - render :text => "hello world!" - end - - def head_with_location_header - head :location => "/foo" - end - - def head_with_symbolic_status - head :status => params[:status].intern - end - - def head_with_integer_status - head :status => params[:status].to_i - end - - def head_with_string_status - head :status => params[:status] - end - - def head_with_custom_header - head :x_custom_header => "something" - end - - def head_with_status_code_first - head :forbidden, :x_custom_header => "something" - end - - def render_with_location - render :xml => "<hello/>", :location => "http://example.com", :status => 201 - end - - def render_with_object_location - customer = Customer.new("Some guy", 1) - render :xml => "<customer/>", :location => customer_url(customer), :status => :created - end - - def render_with_to_xml - to_xmlable = Class.new do - def to_xml - "<i-am-xml/>" - end - end.new - - render :xml => to_xmlable - end - - def render_using_layout_around_block - render :action => "using_layout_around_block" - end - - def render_using_layout_around_block_with_args - render :action => "using_layout_around_block_with_args" - end - - def render_using_layout_around_block_in_main_layout_and_within_content_for_layout - render :action => "using_layout_around_block", :layout => "layouts/block_with_layout" - end - - def partial_dot_html - render :partial => 'partial.html.erb' - end - - def partial_as_rjs - render :update do |page| - page.replace :foo, :partial => 'partial' - end - end - - def respond_to_partial_as_rjs - respond_to do |format| - format.js do - render :update do |page| - page.replace :foo, :partial => 'partial' - end - end - end - end - - def partial - render :partial => 'partial' - end - - def render_alternate_default - # For this test, the method "default_render" is overridden: - @alternate_default_render = lambda do - render :update do |page| - page.replace :foo, :partial => 'partial' - end - end - end - - def partial_only_with_layout - render :partial => "partial_only", :layout => true - end - - def render_to_string_with_partial - @partial_only = render_to_string :partial => "partial_only" - @partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") } - render :action => "test/hello_world" - end - - def partial_with_counter - render :partial => "counter", :locals => { :counter_counter => 5 } - end - - def partial_with_locals - render :partial => "customer", :locals => { :customer => Customer.new("david") } - end - - def partial_with_form_builder - render :partial => ActionView::Helpers::FormBuilder.new(:post, nil, @template, {}, Proc.new {}) - end - - def partial_with_form_builder_subclass - render :partial => LabellingFormBuilder.new(:post, nil, @template, {}, Proc.new {}) - end - - def partial_collection - render :partial => "customer", :collection => [ Customer.new("david"), Customer.new("mary") ] - end - - def partial_collection_with_as - render :partial => "customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer - end - - def partial_collection_with_counter - render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ] - end - - def partial_collection_with_as_and_counter - render :partial => "customer_counter_with_as", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :client - end - - def partial_collection_with_locals - render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } - end - - def partial_collection_with_spacer - render :partial => "customer", :spacer_template => "partial_only", :collection => [ Customer.new("david"), Customer.new("mary") ] - end - - def partial_collection_shorthand_with_locals - render :partial => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } - end - - def partial_collection_shorthand_with_different_types_of_records - render :partial => [ - BadCustomer.new("mark"), - GoodCustomer.new("craig"), - BadCustomer.new("john"), - GoodCustomer.new("zach"), - GoodCustomer.new("brandon"), - BadCustomer.new("dan") ], - :locals => { :greeting => "Bonjour" } - end - - def empty_partial_collection - render :partial => "customer", :collection => [] - end - - def partial_collection_shorthand_with_different_types_of_records_with_counter - partial_collection_shorthand_with_different_types_of_records - end - - def missing_partial - render :partial => 'thisFileIsntHere' - end - - def partial_with_hash_object - render :partial => "hash_object", :object => {:first_name => "Sam"} - end - - def partial_with_nested_object - render :partial => "quiz/questions/question", :object => Quiz::Question.new("first") - end - - def partial_with_nested_object_shorthand - render Quiz::Question.new("first") - end - - def partial_hash_collection - render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ] - end - - def partial_hash_collection_with_locals - render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" } - end - - def partial_with_implicit_local_assignment - @customer = Customer.new("Marcel") - render :partial => "customer" - end - - def partial_with_implicit_local_assignment_and_nil_local - @customer = Customer.new("Marcel") - render :partial => "customer", :locals => { :customer => nil } - end - - def render_call_to_partial_with_layout - render :action => "calling_partial_with_layout" - end - - def render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - render :action => "calling_partial_with_layout", :layout => "layouts/partial_with_layout" - end - - def rescue_action(e) - raise - end - - private - def determine_layout - case action_name - when "hello_world", "layout_test", "rendering_without_layout", - "rendering_nothing_on_layout", "render_text_hello_world", - "render_text_hello_world_with_layout", - "hello_world_with_layout_false", - "partial_only", "partial_only_with_layout", - "accessing_params_in_template", - "accessing_params_in_template_with_layout", - "render_with_explicit_template", - "render_with_explicit_string_template", - "render_js_with_explicit_template", - "render_js_with_explicit_action_template", - "delete_with_js", "update_page", "update_page_with_instance_variables" - - "layouts/standard" - when "render_implicit_js_template_without_layout" - "layouts/default_html" - when "action_talk_to_layout", "layout_overriding_layout" - "layouts/talk_from_action" - when "render_implicit_html_template_from_xhr_request" - (request.xhr? ? 'layouts/xhr' : 'layouts/standard') - end - end -end - -class RenderTest < ActionController::TestCase - tests TestController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request.host = "www.nextangle.com" - end - - def test_simple_show - get :hello_world - assert_response 200 - assert_response :success - assert_template "test/hello_world" - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_renders_default_template_for_missing_action - get :'hyphen-ated' - assert_template 'test/hyphen-ated' - end - - def test_render - get :render_hello_world - assert_template "test/hello_world" - end - - def test_line_offset - begin - get :render_line_offset - flunk "the action should have raised an exception" - rescue RuntimeError => exc - line = exc.backtrace.first - assert(line =~ %r{:(\d+):}) - assert_equal "1", $1, - "The line offset is wrong, perhaps the wrong exception has been raised, exception was: #{exc.inspect}" - end - end - - def test_render_with_forward_slash - get :render_hello_world_with_forward_slash - assert_template "test/hello_world" - end - - def test_render_in_top_directory - get :render_template_in_top_directory - assert_template "shared" - assert_equal "Elastica", @response.body - end - - def test_render_in_top_directory_with_slash - get :render_template_in_top_directory_with_slash - assert_template "shared" - assert_equal "Elastica", @response.body - end - - def test_render_from_variable - get :render_hello_world_from_variable - assert_equal "hello david", @response.body - end - - def test_render_action - get :render_action_hello_world - assert_template "test/hello_world" - end - - def test_render_action_hello_world_as_string - get :render_action_hello_world_as_string - assert_equal "Hello world!", @response.body - assert_template "test/hello_world" - end - - def test_render_action_with_symbol - get :render_action_hello_world_with_symbol - assert_template "test/hello_world" - end - - def test_render_text - get :render_text_hello_world - assert_equal "hello world", @response.body - end - - def test_do_with_render_text_and_layout - get :render_text_hello_world_with_layout - assert_equal "<html>hello world, I'm here!</html>", @response.body - end - - def test_xhr_with_render_text_and_layout - xhr :get, :render_text_hello_world_with_layout - assert_equal "<html>hello world, I'm here!</html>", @response.body - end - - def test_do_with_render_action_and_layout_false - get :hello_world_with_layout_false - assert_equal 'Hello world!', @response.body - end - - def test_render_file_with_instance_variables - get :render_file_with_instance_variables - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_as_string_with_instance_variables - get :render_file_as_string_with_instance_variables - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_not_using_full_path - get :render_file_not_using_full_path - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_not_using_full_path_with_dot_in_path - get :render_file_not_using_full_path_with_dot_in_path - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_using_pathname - get :render_file_using_pathname - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_with_locals - get :render_file_with_locals - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_as_string_with_locals - get :render_file_as_string_with_locals - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_from_template - get :render_file_from_template - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_json_nil - get :render_json_nil - assert_equal 'null', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json - get :render_json_hello_world - assert_equal '{"hello":"world"}', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json_with_callback - get :render_json_hello_world_with_callback - assert_equal 'alert({"hello":"world"})', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json_with_custom_content_type - get :render_json_with_custom_content_type - assert_equal '{"hello":"world"}', @response.body - assert_equal 'text/javascript', @response.content_type - end - - def test_render_symbol_json - get :render_symbol_json - assert_equal '{"hello":"world"}', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json_with_render_to_string - get :render_json_with_render_to_string - assert_equal '{"hello":"partial html"}', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_custom_code - get :render_custom_code - assert_response 404 - assert_response :missing - assert_equal 'hello world', @response.body - end - - def test_render_custom_code_rjs - get :render_custom_code_rjs - assert_response 404 - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_render_text_with_nil - get :render_text_with_nil - assert_response 200 - assert_equal ' ', @response.body - end - - def test_render_text_with_false - get :render_text_with_false - assert_equal 'false', @response.body - end - - def test_render_nothing_with_appendix - get :render_nothing_with_appendix - assert_response 200 - assert_equal 'appended', @response.body - end - - def test_attempt_to_access_object_method - assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } - end - - def test_private_methods - assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout } - end - - def test_access_to_request_in_view - get :accessing_request_in_template - assert_equal "Hello: www.nextangle.com", @response.body - end - - def test_access_to_logger_in_view - get :accessing_logger_in_template - assert_equal "Logger", @response.body - end - - def test_access_to_action_name_in_view - get :accessing_action_name_in_template - assert_equal "accessing_action_name_in_template", @response.body - end - - def test_access_to_controller_name_in_view - get :accessing_controller_name_in_template - assert_equal "test", @response.body # name is explicitly set to 'test' inside the controller. - end - - def test_render_vanilla_js - get :render_vanilla_js_hello - assert_equal "alert('hello')", @response.body - assert_equal "text/javascript", @response.content_type - end - - def test_render_xml - get :render_xml_hello - assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body - assert_equal "application/xml", @response.content_type - end - - def test_render_xml_as_string_template - get :render_xml_hello_as_string_template - assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body - assert_equal "application/xml", @response.content_type - end - - def test_render_xml_with_default - get :greeting - assert_equal "<p>This is grand!</p>\n", @response.body - end - - def test_render_xml_with_partial - get :builder_partial_test - assert_equal "<test>\n <hello/>\n</test>\n", @response.body - end - - def test_enum_rjs_test - ActiveSupport::SecureRandom.stubs(:base64).returns("asdf") - get :enum_rjs_test - body = %{ - $$(".product").each(function(value, index) { - new Effect.Highlight(element,{}); - new Effect.Highlight(value,{}); - Sortable.create(value, {onUpdate:function(){new Ajax.Request('/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}}); - new Draggable(value, {}); - }); - }.gsub(/^ /, '').strip - assert_equal body, @response.body - end - - def test_layout_rendering - get :layout_test - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_render_xml_with_layouts - get :builder_layout_test - assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body - end - - def test_partials_list - get :partials_list - assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body - end - - def test_render_to_string - get :hello_in_a_string - assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body - end - - def test_render_to_string_resets_assigns - get :render_to_string_test - assert_equal "The value of foo is: ::this is a test::\n", @response.body - end - - def test_render_to_string_inline - get :render_to_string_with_inline_and_render - assert_template "test/hello_world" - end - - def test_nested_rendering - @controller = Fun::GamesController.new - get :hello_world - assert_equal "Living in a nested world", @response.body - end - - def test_accessing_params_in_template - get :accessing_params_in_template, :name => "David" - assert_equal "Hello: David", @response.body - end - - def test_accessing_local_assigns_in_inline_template - get :accessing_local_assigns_in_inline_template, :local_name => "Local David" - assert_equal "Goodbye, Local David", @response.body - end - - def test_render_in_an_rjs_template_should_pick_html_templates_when_available - [:js, "js"].each do |format| - assert_nothing_raised do - get :render_implicit_html_template, :format => format - assert_equal %(document.write("Hello world\\n");), @response.body - end - end - end - - def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template - [:js, "js"].each do |format| - assert_nothing_raised do - get :render_explicit_html_template, :format => format - assert_equal %(document.write("Hello world\\n");), @response.body - end - end - end - - def test_should_implicitly_render_html_template_from_xhr_request - xhr :get, :render_implicit_html_template_from_xhr_request - assert_equal "XHR!\nHello HTML!", @response.body - end - - def test_should_render_explicit_html_template_with_html_layout - xhr :get, :render_html_explicit_template_and_layout - assert_equal "<html>Hello HTML!</html>\n", @response.body - end - - def test_should_implicitly_render_js_template_without_layout - get :render_implicit_js_template_without_layout, :format => :js - assert_no_match /<html>/, @response.body - end - - def test_should_render_formatted_template - get :formatted_html_erb - assert_equal 'formatted html erb', @response.body - end - - def test_should_render_formatted_xml_erb_template - get :formatted_xml_erb, :format => :xml - assert_equal '<test>passed formatted xml erb</test>', @response.body - end - - def test_should_render_formatted_html_erb_template - get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body - end - - def test_should_render_formatted_html_erb_template_with_faulty_accepts_header - @request.accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*" - get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body - end - - def test_should_render_xml_but_keep_custom_content_type - get :render_xml_with_custom_content_type - assert_equal "application/atomsvc+xml", @response.content_type - end - - def test_render_with_default_from_accept_header - xhr :get, :greeting - assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body - end - - def test_render_rjs_with_default - get :delete_with_js - assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body - end - - def test_render_rjs_template_explicitly - get :render_js_with_explicit_template - assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body - end - - def test_rendering_rjs_action_explicitly - get :render_js_with_explicit_action_template - assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body - end - - def test_layout_test_with_different_layout - get :layout_test_with_different_layout - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_layout_test_with_different_layout_and_string_action - get :layout_test_with_different_layout_and_string_action - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_layout_test_with_different_layout_and_symbol_action - get :layout_test_with_different_layout_and_symbol_action - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_rendering_without_layout - get :rendering_without_layout - assert_equal "Hello world!", @response.body - end - - def test_layout_overriding_layout - get :layout_overriding_layout - assert_no_match %r{<title>}, @response.body - end - - def test_rendering_nothing_on_layout - get :rendering_nothing_on_layout - assert_equal " ", @response.body - end - - def test_render_to_string - assert_not_deprecated { get :hello_in_a_string } - assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body - end - - def test_render_to_string_doesnt_break_assigns - get :render_to_string_with_assigns - assert_equal "i'm before the render", assigns(:before) - assert_equal "i'm after the render", assigns(:after) - end - - def test_bad_render_to_string_still_throws_exception - assert_raise(ActionView::MissingTemplate) { get :render_to_string_with_exception } - end - - def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns - assert_nothing_raised { get :render_to_string_with_caught_exception } - assert_equal "i'm before the render", assigns(:before) - assert_equal "i'm after the render", assigns(:after) - end - - def test_accessing_params_in_template_with_layout - get :accessing_params_in_template_with_layout, :name => "David" - assert_equal "<html>Hello: David</html>", @response.body - end - - def test_render_with_explicit_template - get :render_with_explicit_template - assert_response :success - end - - def test_render_with_explicit_string_template - get :render_with_explicit_string_template - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_double_render - assert_raise(ActionController::DoubleRenderError) { get :double_render } - end - - def test_double_redirect - assert_raise(ActionController::DoubleRenderError) { get :double_redirect } - end - - def test_render_and_redirect - assert_raise(ActionController::DoubleRenderError) { get :render_and_redirect } - end - - # specify the one exception to double render rule - render_to_string followed by render - def test_render_to_string_and_render - get :render_to_string_and_render - assert_equal("Hi web users! here is some cached stuff", @response.body) - end - - def test_rendering_with_conflicting_local_vars - get :rendering_with_conflicting_local_vars - assert_equal("First: David\nSecond: Stephan\nThird: David\nFourth: David\nFifth: ", @response.body) - end - - def test_action_talk_to_layout - get :action_talk_to_layout - assert_equal "<title>Talking to the layout</title>\nAction was here!", @response.body - end - - def test_render_text_with_assigns - get :render_text_with_assigns - assert_equal "world", assigns["hello"] - end - - def test_template_with_locals - get :render_with_explicit_template_with_locals - assert_equal "The secret is area51\n", @response.body - end - - def test_update_page - get :update_page - assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'] - assert_equal 2, @response.body.split($/).length - end - - def test_update_page_with_instance_variables - get :update_page_with_instance_variables - assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"] - assert_match /balance/, @response.body - assert_match /\$37/, @response.body - end - - def test_update_page_with_view_method - get :update_page_with_view_method - assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"] - assert_match /2 people/, @response.body - end - - def test_yield_content_for - assert_not_deprecated { get :yield_content_for } - assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body - end - - def test_overwritting_rendering_relative_file_with_extension - get :hello_world_from_rxml_using_template - assert_equal "<html>\n <p>Hello</p>\n</html>\n", @response.body - - get :hello_world_from_rxml_using_action - assert_equal "<html>\n <p>Hello</p>\n</html>\n", @response.body - end - - def test_head_with_location_header - get :head_with_location_header - assert @response.body.blank? - assert_equal "/foo", @response.headers["Location"] - assert_response :ok - end - - def test_head_with_custom_header - get :head_with_custom_header - assert @response.body.blank? - assert_equal "something", @response.headers["X-Custom-Header"] - assert_response :ok - end - - def test_head_with_symbolic_status - get :head_with_symbolic_status, :status => "ok" - assert_equal "200 OK", @response.status - assert_response :ok - - get :head_with_symbolic_status, :status => "not_found" - assert_equal "404 Not Found", @response.status - assert_response :not_found - - get :head_with_symbolic_status, :status => "no_content" - assert_equal "204 No Content", @response.status - assert !@response.headers.include?('Content-Length') - assert_response :no_content - - ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE.each do |status, code| - get :head_with_symbolic_status, :status => status.to_s - assert_equal code, @response.response_code - assert_response status - end - end - - def test_head_with_integer_status - ActionController::StatusCodes::STATUS_CODES.each do |code, message| - get :head_with_integer_status, :status => code.to_s - assert_equal message, @response.message - end - end - - def test_head_with_string_status - get :head_with_string_status, :status => "404 Eat Dirt" - assert_equal 404, @response.response_code - assert_equal "Eat Dirt", @response.message - assert_response :not_found - end - - def test_head_with_status_code_first - get :head_with_status_code_first - assert_equal 403, @response.response_code - assert_equal "Forbidden", @response.message - assert_equal "something", @response.headers["X-Custom-Header"] - assert_response :forbidden - end - - def test_rendering_with_location_should_set_header - get :render_with_location - assert_equal "http://example.com", @response.headers["Location"] - end - - def test_rendering_xml_should_call_to_xml_if_possible - get :render_with_to_xml - assert_equal "<i-am-xml/>", @response.body - end - - def test_rendering_with_object_location_should_set_header_with_url_for - ActionController::Routing::Routes.draw do |map| - map.resources :customers - map.connect ':controller/:action/:id' - end - - get :render_with_object_location - assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"] - end - - def test_should_use_implicit_content_type - get :implicit_content_type, :format => 'atom' - assert_equal Mime::ATOM, @response.content_type - end - - def test_using_layout_around_block - get :render_using_layout_around_block - assert_equal "Before (David)\nInside from block\nAfter", @response.body - end - - def test_using_layout_around_block_in_main_layout_and_within_content_for_layout - get :render_using_layout_around_block_in_main_layout_and_within_content_for_layout - assert_equal "Before (Anthony)\nInside from first block in layout\nAfter\nBefore (David)\nInside from block\nAfter\nBefore (Ramm)\nInside from second block in layout\nAfter\n", @response.body - end - - def test_using_layout_around_block_with_args - get :render_using_layout_around_block_with_args - assert_equal "Before\narg1arg2\nAfter", @response.body - end - - def test_partial_only - get :partial_only - assert_equal "only partial", @response.body - end - - def test_should_render_html_formatted_partial - get :partial - assert_equal 'partial html', @response.body - end - - def test_should_render_html_partial_with_dot - get :partial_dot_html - assert_equal 'partial html', @response.body - end - - def test_should_render_html_formatted_partial_with_rjs - xhr :get, :partial_as_rjs - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_should_render_html_formatted_partial_with_rjs_and_js_format - xhr :get, :respond_to_partial_as_rjs - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_should_render_js_partial - xhr :get, :partial, :format => 'js' - assert_equal 'partial js', @response.body - end - - def test_should_render_with_alternate_default_render - xhr :get, :render_alternate_default - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_partial_only_with_layout - get :partial_only_with_layout - assert_equal "<html>only partial</html>", @response.body - end - - def test_render_to_string_partial - get :render_to_string_with_partial - assert_equal "only partial", assigns(:partial_only) - assert_equal "Hello: david", assigns(:partial_with_locals) - end - - def test_partial_with_counter - get :partial_with_counter - assert_equal "5", @response.body - end - - def test_partial_with_locals - get :partial_with_locals - assert_equal "Hello: david", @response.body - end - - def test_partial_with_form_builder - get :partial_with_form_builder - assert_match(/<label/, @response.body) - assert_template('test/_form') - end - - def test_partial_with_form_builder_subclass - get :partial_with_form_builder_subclass - assert_match(/<label/, @response.body) - assert_template('test/_labelling_form') - end - - def test_partial_collection - get :partial_collection - assert_equal "Hello: davidHello: mary", @response.body - end - - def test_partial_collection_with_as - get :partial_collection_with_as - assert_equal "david david davidmary mary mary", @response.body - end - - def test_partial_collection_with_counter - get :partial_collection_with_counter - assert_equal "david0mary1", @response.body - end - - def test_partial_collection_with_as_and_counter - get :partial_collection_with_as_and_counter - assert_equal "david0mary1", @response.body - end - - def test_partial_collection_with_locals - get :partial_collection_with_locals - assert_equal "Bonjour: davidBonjour: mary", @response.body - end - - def test_partial_collection_with_spacer - get :partial_collection_with_spacer - assert_equal "Hello: davidonly partialHello: mary", @response.body - assert_template :partial => 'test/_partial_only' - assert_template :partial => '_customer' - end - - def test_partial_collection_shorthand_with_locals - get :partial_collection_shorthand_with_locals - assert_equal "Bonjour: davidBonjour: mary", @response.body - assert_template :partial => 'customers/_customer', :count => 2 - assert_template :partial => '_completely_fake_and_made_up_template_that_cannot_possibly_be_rendered', :count => 0 - end - - def test_partial_collection_shorthand_with_different_types_of_records - get :partial_collection_shorthand_with_different_types_of_records - assert_equal "Bonjour bad customer: mark0Bonjour good customer: craig1Bonjour bad customer: john2Bonjour good customer: zach3Bonjour good customer: brandon4Bonjour bad customer: dan5", @response.body - assert_template :partial => 'good_customers/_good_customer', :count => 3 - assert_template :partial => 'bad_customers/_bad_customer', :count => 3 - end - - def test_empty_partial_collection - get :empty_partial_collection - assert_equal " ", @response.body - assert_template :partial => false - end - - def test_partial_with_hash_object - get :partial_with_hash_object - assert_equal "Sam\nmaS\n", @response.body - end - - def test_partial_with_nested_object - get :partial_with_nested_object - assert_equal "first", @response.body - end - - def test_partial_with_nested_object_shorthand - get :partial_with_nested_object_shorthand - assert_equal "first", @response.body - end - - def test_hash_partial_collection - get :partial_hash_collection - assert_equal "Pratik\nkitarP\nAmy\nymA\n", @response.body - end - - def test_partial_hash_collection_with_locals - get :partial_hash_collection_with_locals - assert_equal "Hola: PratikHola: Amy", @response.body - end - - def test_partial_with_implicit_local_assignment - assert_deprecated do - get :partial_with_implicit_local_assignment - assert_equal "Hello: Marcel", @response.body - end - end - - def test_partial_with_implicit_local_assignment_and_nil_local - assert_not_deprecated do - get :partial_with_implicit_local_assignment_and_nil_local - assert_equal "Hello: Anonymous", @response.body - end - end - - def test_render_missing_partial_template - assert_raise(ActionView::MissingTemplate) do - get :missing_partial - end - end - - def test_render_call_to_partial_with_layout - get :render_call_to_partial_with_layout - assert_equal "Before (David)\nInside from partial (David)\nAfter", @response.body - end - - def test_render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - get :render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - assert_equal "Before (Anthony)\nInside from partial (Anthony)\nAfter\nBefore (David)\nInside from partial (David)\nAfter\nBefore (Ramm)\nInside from partial (Ramm)\nAfter", @response.body - end -end - -class ExpiresInRenderTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - end - - def test_expires_in_header - get :conditional_hello_with_expires_in - assert_equal "max-age=60, private", @response.headers["Cache-Control"] - end - - def test_expires_in_header_with_public - get :conditional_hello_with_expires_in_with_public - assert_equal "max-age=60, public", @response.headers["Cache-Control"] - end - - def test_expires_in_header_with_additional_headers - get :conditional_hello_with_expires_in_with_public_with_more_keys - assert_equal "max-age=60, public, max-stale=18000", @response.headers["Cache-Control"] - end - - def test_expires_in_old_syntax - get :conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax - assert_equal "max-age=60, public, max-stale=18000", @response.headers["Cache-Control"] - end -end - - -class EtagRenderTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - @expected_bang_etag = etag_for(expand_key([:foo, 123])) - end - - def test_render_blank_body_shouldnt_set_etag - get :blank_response - assert !@response.etag?, @response.headers.inspect - end - - def test_render_200_should_set_etag - get :render_hello_world_from_variable - assert_equal etag_for("hello david"), @response.headers['ETag'] - assert_equal "private, max-age=0, must-revalidate", @response.headers['Cache-Control'] - end - - def test_render_against_etag_request_should_304_when_match - @request.if_none_match = etag_for("hello david") - get :render_hello_world_from_variable - assert_equal "304 Not Modified", @response.status - assert @response.body.empty? - end - - def test_render_against_etag_request_should_have_no_content_length_when_match - @request.if_none_match = etag_for("hello david") - get :render_hello_world_from_variable - assert_nil @response.headers["Content-Length"], @response.headers.inspect - end - - def test_render_against_etag_request_should_200_when_no_match - @request.if_none_match = etag_for("hello somewhere else") - get :render_hello_world_from_variable - assert_equal "200 OK", @response.status - assert !@response.body.empty? - end - - def test_render_should_not_set_etag_when_last_modified_has_been_specified - get :render_hello_world_with_last_modified_set - assert_equal "200 OK", @response.status - assert_not_nil @response.last_modified - assert_nil @response.etag - assert @response.body.present? - end - - def test_render_with_etag - get :render_hello_world_from_variable - expected_etag = etag_for('hello david') - assert_equal expected_etag, @response.headers['ETag'] - @response = ActionController::TestResponse.new - - @request.if_none_match = expected_etag - get :render_hello_world_from_variable - assert_equal "304 Not Modified", @response.status - - @request.if_none_match = "\"diftag\"" - get :render_hello_world_from_variable - assert_equal "200 OK", @response.status - end - - def render_with_404_shouldnt_have_etag - get :render_custom_code - assert_nil @response.headers['ETag'] - end - - def test_etag_should_not_be_changed_when_already_set - get :render_hello_world_with_etag_set - assert_equal etag_for("hello_world"), @response.headers['ETag'] - end - - def test_etag_should_govern_renders_with_layouts_too - get :builder_layout_test - assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body - assert_equal etag_for("<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n"), @response.headers['ETag'] - end - - def test_etag_with_bang_should_set_etag - get :conditional_hello_with_bangs - assert_equal @expected_bang_etag, @response.headers["ETag"] - assert_response :success - end - - def test_etag_with_bang_should_obey_if_none_match - @request.if_none_match = @expected_bang_etag - get :conditional_hello_with_bangs - assert_response :not_modified - end - - def test_etag_with_public_true_should_set_header - get :conditional_hello_with_public_header - assert_equal "public", @response.headers['Cache-Control'] - end - - def test_etag_with_public_true_should_set_header_and_retain_other_headers - get :conditional_hello_with_public_header_and_expires_at - assert_equal "max-age=60, public", @response.headers['Cache-Control'] - end - - protected - def etag_for(text) - %("#{Digest::MD5.hexdigest(text)}") - end - - def expand_key(args) - ActiveSupport::Cache.expand_cache_key(args) - end -end - -class LastModifiedRenderTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - @last_modified = Time.now.utc.beginning_of_day.httpdate - end - - def test_responds_with_last_modified - get :conditional_hello - assert_equal @last_modified, @response.headers['Last-Modified'] - end - - def test_request_not_modified - @request.if_modified_since = @last_modified - get :conditional_hello - assert_equal "304 Not Modified", @response.status - assert @response.body.blank?, @response.body - assert_equal @last_modified, @response.headers['Last-Modified'] - end - - def test_request_not_modified_but_etag_differs - @request.if_modified_since = @last_modified - @request.if_none_match = "234" - get :conditional_hello - assert_response :success - end - - def test_request_modified - @request.if_modified_since = 'Thu, 16 Jul 2008 00:00:00 GMT' - get :conditional_hello - assert_equal "200 OK", @response.status - assert !@response.body.blank? - assert_equal @last_modified, @response.headers['Last-Modified'] - end - - def test_request_with_bang_gets_last_modified - get :conditional_hello_with_bangs - assert_equal @last_modified, @response.headers['Last-Modified'] - assert_response :success - end - - def test_request_with_bang_obeys_last_modified - @request.if_modified_since = @last_modified - get :conditional_hello_with_bangs - assert_response :not_modified - end - - def test_last_modified_works_with_less_than_too - @request.if_modified_since = 5.years.ago.httpdate - get :conditional_hello_with_bangs - assert_response :success - end -end - -class RenderingLoggingTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - end - - def test_logger_prints_layout_and_template_rendering_info - @controller.logger = MockLogger.new - get :layout_test - logged = @controller.logger.logged.find_all {|l| l =~ /render/i } - assert_equal "Rendering template within layouts/standard", logged[0] - assert_equal "Rendering test/hello_world", logged[1] - end -end diff --git a/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb deleted file mode 100644 index db6cf7b3..00000000 --- a/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'abstract_unit' - -class JsonParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - end - - def teardown - TestController.last_request_parameters = nil - end - - test "parses json params for application json" do - assert_parses( - {"person" => {"name" => "David"}}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/json' } - ) - end - - test "parses json params for application jsonrequest" do - assert_parses( - {"person" => {"name" => "David"}}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/jsonrequest' } - ) - end - - test "logs error if parsing unsuccessful" do - with_test_routing do - begin - $stderr = StringIO.new - json = "[\"person]\": {\"name\": \"David\"}}" - post "/parse", json, {'CONTENT_TYPE' => 'application/json'} - assert_response :error - $stderr.rewind && err = $stderr.read - assert err =~ /Error occurred while parsing request parameters/ - ensure - $stderr = STDERR - end - end - end - - private - def assert_parses(expected, actual, headers = {}) - with_test_routing do - post "/parse", actual, headers - assert_response :ok - assert_equal(expected, TestController.last_request_parameters) - end - end - - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "json_params_parsing_test/test" - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb deleted file mode 100644 index 46aee378..00000000 --- a/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb +++ /dev/null @@ -1,177 +0,0 @@ -require 'abstract_unit' - -class MultipartParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - - def read - render :text => "File: #{params[:uploaded_data].read}" - end - - def read_complex - render :text => "File: #{params[:level0][:level1][0][:file_data].read}" - end - end - - FIXTURE_PATH = File.dirname(__FILE__) + '/../../fixtures/multipart' - - def teardown - TestController.last_request_parameters = nil - end - - test "parses single parameter" do - assert_equal({ 'foo' => 'bar' }, parse_multipart('single_parameter')) - end - - test "parses bracketed parameters" do - assert_equal({ 'foo' => { 'baz' => 'bar'}}, parse_multipart('bracketed_param')) - end - - test "parses text file" do - params = parse_multipart('text_file') - assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] - - file = params['file'] - assert_kind_of Tempfile, file - assert_equal 'file.txt', file.original_filename - assert_equal "text/plain", file.content_type - assert_equal 'contents', file.read - end - - test "parses boundary problem file" do - params = parse_multipart('boundary_problem_file') - assert_equal %w(file foo), params.keys.sort - - file = params['file'] - foo = params['foo'] - - assert_kind_of Tempfile, file - - assert_equal 'file.txt', file.original_filename - assert_equal "text/plain", file.content_type - - assert_equal 'bar', foo - end - - test "parses large text file" do - params = parse_multipart('large_text_file') - assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] - - file = params['file'] - - assert_kind_of Tempfile, file - - assert_equal 'file.txt', file.original_filename - assert_equal "text/plain", file.content_type - assert ('a' * 20480) == file.read - end - - test "parses binary file" do - params = parse_multipart('binary_file') - assert_equal %w(file flowers foo), params.keys.sort - assert_equal 'bar', params['foo'] - - file = params['file'] - assert_kind_of Tempfile, file - assert_equal 'file.csv', file.original_filename - assert_nil file.content_type - assert_equal 'contents', file.read - - file = params['flowers'] - assert_kind_of Tempfile, file - assert_equal 'flowers.jpg', file.original_filename - assert_equal "image/jpeg", file.content_type - assert_equal 19512, file.size - end - - test "parses mixed files" do - params = parse_multipart('mixed_files') - assert_equal %w(files foo), params.keys.sort - assert_equal 'bar', params['foo'] - - # Ruby CGI doesn't handle multipart/mixed for us. - files = params['files'] - assert_kind_of Tempfile, files - files.force_encoding('ASCII-8BIT') if files.respond_to?(:force_encoding) - assert_equal 19756, files.size - end - - test "does not create tempfile if no file has been selected" do - params = parse_multipart('none') - assert_equal %w(submit-name), params.keys.sort - assert_equal 'Larry', params['submit-name'] - assert_equal nil, params['files'] - end - - test "parses empty upload file" do - params = parse_multipart('empty') - assert_equal %w(files submit-name), params.keys.sort - assert_equal 'Larry', params['submit-name'] - assert params['files'] - assert_equal "", params['files'].read - end - - test "uploads and reads binary file" do - with_test_routing do - fixture = FIXTURE_PATH + "/mona_lisa.jpg" - params = { :uploaded_data => fixture_file_upload(fixture, "image/jpg") } - post '/read', params - expected_length = 'File: '.length + File.size(fixture) - assert_equal expected_length, response.content_length - end - end - - test "uploads and reads file" do - with_test_routing do - post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") - assert_equal "File: Hello", response.body - end - end - - test "uploads and reads file in complex parameter" do - with_test_routing do - post '/read_complex', - :level0 => { - :level1 => [ { :file_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") } - ] - } - assert_equal "File: Hello", response.body - end - end - - private - def fixture(name) - File.open(File.join(FIXTURE_PATH, name), 'rb') do |file| - { "rack.input" => file.read, - "CONTENT_TYPE" => "multipart/form-data; boundary=AaB03x", - "CONTENT_LENGTH" => file.stat.size.to_s } - end - end - - def parse_multipart(name) - with_test_routing do - headers = fixture(name) - post "/parse", headers.delete("rack.input"), headers - assert_response :ok - TestController.last_request_parameters - end - end - - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "multipart_params_parsing_test/test" - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/query_string_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/query_string_parsing_test.rb deleted file mode 100644 index a31e326d..00000000 --- a/vendor/rails/actionpack/test/controller/request/query_string_parsing_test.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'abstract_unit' - -class QueryStringParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_query_parameters - end - - def parse - self.class.last_query_parameters = request.query_parameters - head :ok - end - end - - def teardown - TestController.last_query_parameters = nil - end - - test "query string" do - assert_parses( - {"action" => "create_customer", "full_name" => "David Heinemeier Hansson", "customerId" => "1"}, - "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1" - ) - end - - test "deep query string" do - assert_parses( - {'x' => {'y' => {'z' => '10'}}}, - "x[y][z]=10" - ) - end - - test "deep query string with array" do - assert_parses({'x' => {'y' => {'z' => ['10']}}}, 'x[y][z][]=10') - assert_parses({'x' => {'y' => {'z' => ['10', '5']}}}, 'x[y][z][]=10&x[y][z][]=5') - end - - test "deep query string with array of hash" do - assert_parses({'x' => {'y' => [{'z' => '10'}]}}, 'x[y][][z]=10') - assert_parses({'x' => {'y' => [{'z' => '10', 'w' => '10'}]}}, 'x[y][][z]=10&x[y][][w]=10') - assert_parses({'x' => {'y' => [{'z' => '10', 'v' => {'w' => '10'}}]}}, 'x[y][][z]=10&x[y][][v][w]=10') - end - - test "deep query string with array of hashes with one pair" do - assert_parses({'x' => {'y' => [{'z' => '10'}, {'z' => '20'}]}}, 'x[y][][z]=10&x[y][][z]=20') - end - - test "deep query string with array of hashes with multiple pairs" do - assert_parses( - {'x' => {'y' => [{'z' => '10', 'w' => 'a'}, {'z' => '20', 'w' => 'b'}]}}, - 'x[y][][z]=10&x[y][][w]=a&x[y][][z]=20&x[y][][w]=b' - ) - end - - test "query string with nil" do - assert_parses( - { "action" => "create_customer", "full_name" => ''}, - "action=create_customer&full_name=" - ) - end - - test "query string with array" do - assert_parses( - { "action" => "create_customer", "selected" => ["1", "2", "3"]}, - "action=create_customer&selected[]=1&selected[]=2&selected[]=3" - ) - end - - test "query string with amps" do - assert_parses( - { "action" => "create_customer", "name" => "Don't & Does"}, - "action=create_customer&name=Don%27t+%26+Does" - ) - end - - test "query string with many equal" do - assert_parses( - { "action" => "create_customer", "full_name" => "abc=def=ghi"}, - "action=create_customer&full_name=abc=def=ghi" - ) - end - - test "query string without equal" do - assert_parses({ "action" => nil }, "action") - end - - test "query string with empty key" do - assert_parses( - { "action" => "create_customer", "full_name" => "David Heinemeier Hansson" }, - "action=create_customer&full_name=David%20Heinemeier%20Hansson&=Save" - ) - end - - test "query string with many ampersands" do - assert_parses( - { "action" => "create_customer", "full_name" => "David Heinemeier Hansson"}, - "&action=create_customer&&&full_name=David%20Heinemeier%20Hansson" - ) - end - - test "unbalanced query string with array" do - assert_parses( - {'location' => ["1", "2"], 'age_group' => ["2"]}, - "location[]=1&location[]=2&age_group[]=2" - ) - end - - private - def assert_parses(expected, actual) - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "query_string_parsing_test/test" - end - - get "/parse", actual - assert_response :ok - assert_equal(expected, TestController.last_query_parameters) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/test_request_test.rb b/vendor/rails/actionpack/test/controller/request/test_request_test.rb deleted file mode 100644 index 81551b4b..00000000 --- a/vendor/rails/actionpack/test/controller/request/test_request_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'abstract_unit' -require 'stringio' - -class ActionController::TestRequestTest < ActiveSupport::TestCase - - def setup - @request = ActionController::TestRequest.new - end - - def test_test_request_has_session_options_initialized - assert @request.session_options - end - - Rack::Session::Abstract::ID::DEFAULT_OPTIONS.each_key do |option| - test "test_rack_default_session_options_#{option}_exists_in_session_options_and_is_default" do - assert_equal(Rack::Session::Abstract::ID::DEFAULT_OPTIONS[option], - @request.session_options[option], - "Missing rack session default option #{option} in request.session_options") - end - test "test_rack_default_session_options_#{option}_exists_in_session_options" do - assert(@request.session_options.has_key?(option), - "Missing rack session option #{option} in request.session_options") - end - end - - def test_session_id_exists_by_default - assert_not_nil(@request.session_options[:id]) - end - - def test_session_id_different_on_each_call - prev_id = - assert_not_equal(@request.session_options[:id], ActionController::TestRequest.new.session_options[:id]) - end - -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb deleted file mode 100644 index 7167cdaf..00000000 --- a/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +++ /dev/null @@ -1,146 +0,0 @@ -require 'abstract_unit' - -class UrlEncodedParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters, :last_request_type - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - end - - def teardown - TestController.last_request_parameters = nil - end - - test "parses unbalanced query string with array" do - assert_parses( - {'location' => ["1", "2"], 'age_group' => ["2"]}, - "location[]=1&location[]=2&age_group[]=2" - ) - end - - test "parses nested hash" do - query = [ - "note[viewers][viewer][][type]=User", - "note[viewers][viewer][][id]=1", - "note[viewers][viewer][][type]=Group", - "note[viewers][viewer][][id]=2" - ].join("&") - - expected = { "note" => { "viewers"=>{"viewer"=>[{ "id"=>"1", "type"=>"User"}, {"type"=>"Group", "id"=>"2"} ]} } } - assert_parses(expected, query) - end - - test "parses more complex nesting" do - query = [ - "customers[boston][first][name]=David", - "customers[boston][first][url]=http://David", - "customers[boston][second][name]=Allan", - "customers[boston][second][url]=http://Allan", - "something_else=blah", - "something_nil=", - "something_empty=", - "products[first]=Apple Computer", - "products[second]=Pc", - "=Save" - ].join("&") - - expected = { - "customers" => { - "boston" => { - "first" => { - "name" => "David", - "url" => "http://David" - }, - "second" => { - "name" => "Allan", - "url" => "http://Allan" - } - } - }, - "something_else" => "blah", - "something_empty" => "", - "something_nil" => "", - "products" => { - "first" => "Apple Computer", - "second" => "Pc" - } - } - - assert_parses expected, query - end - - test "parses params with array" do - query = "selected[]=1&selected[]=2&selected[]=3" - expected = { "selected" => [ "1", "2", "3" ] } - assert_parses expected, query - end - - test "parses params with nil key" do - query = "=&test2=value1" - expected = { "test2" => "value1" } - assert_parses expected, query - end - - test "parses params with array prefix and hashes" do - query = "a[][b][c]=d" - expected = {"a" => [{"b" => {"c" => "d"}}]} - assert_parses expected, query - end - - test "parses params with complex nesting" do - query = "a[][b][c][][d][]=e" - expected = {"a" => [{"b" => {"c" => [{"d" => ["e"]}]}}]} - assert_parses expected, query - end - - test "parses params with file path" do - query = [ - "customers[boston][first][name]=David", - "something_else=blah", - "logo=#{File.expand_path(__FILE__)}" - ].join("&") - - expected = { - "customers" => { - "boston" => { - "first" => { - "name" => "David" - } - } - }, - "something_else" => "blah", - "logo" => File.expand_path(__FILE__), - } - - assert_parses expected, query - end - - test "parses params with Safari 2 trailing null character" do - query = "selected[]=1&selected[]=2&selected[]=3\0" - expected = { "selected" => [ "1", "2", "3" ] } - assert_parses expected, query - end - - private - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "url_encoded_params_parsing_test/test" - end - yield - end - end - - def assert_parses(expected, actual) - with_test_routing do - post "/parse", actual - assert_response :ok - assert_equal(expected, TestController.last_request_parameters) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb deleted file mode 100644 index 170cf77e..00000000 --- a/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb +++ /dev/null @@ -1,103 +0,0 @@ -require 'abstract_unit' - -class XmlParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - end - - def teardown - TestController.last_request_parameters = nil - end - - test "parses hash params" do - with_test_routing do - xml = "<person><name>David</name></person>" - post "/parse", xml, default_headers - assert_response :ok - assert_equal({"person" => {"name" => "David"}}, TestController.last_request_parameters) - end - end - - test "parses single file" do - with_test_routing do - xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar></person>" - post "/parse", xml, default_headers - assert_response :ok - - person = TestController.last_request_parameters - assert_equal "image/jpg", person['person']['avatar'].content_type - assert_equal "me.jpg", person['person']['avatar'].original_filename - assert_equal "ABC", person['person']['avatar'].read - end - end - - test "logs error if parsing unsuccessful" do - with_test_routing do - begin - $stderr = StringIO.new - xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar></pineapple>" - post "/parse", xml, default_headers - assert_response :error - $stderr.rewind && err = $stderr.read - assert err =~ /Error occurred while parsing request parameters/ - ensure - $stderr = STDERR - end - end - end - - test "parses multiple files" do - xml = <<-end_body - <person> - <name>David</name> - <avatars> - <avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar> - <avatar type='file' name='you.gif' content_type='image/gif'>#{ActiveSupport::Base64.encode64('DEF')}</avatar> - </avatars> - </person> - end_body - - with_test_routing do - post "/parse", xml, default_headers - assert_response :ok - end - - person = TestController.last_request_parameters - - assert_equal "image/jpg", person['person']['avatars']['avatar'].first.content_type - assert_equal "me.jpg", person['person']['avatars']['avatar'].first.original_filename - assert_equal "ABC", person['person']['avatars']['avatar'].first.read - - assert_equal "image/gif", person['person']['avatars']['avatar'].last.content_type - assert_equal "you.gif", person['person']['avatars']['avatar'].last.original_filename - assert_equal "DEF", person['person']['avatars']['avatar'].last.read - end - - private - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "xml_params_parsing_test/test" - end - yield - end - end - - def default_headers - {'CONTENT_TYPE' => 'application/xml'} - end -end - -class LegacyXmlParamsParsingTest < XmlParamsParsingTest - private - def default_headers - {'HTTP_X_POST_DATA_FORMAT' => 'xml'} - end -end diff --git a/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb b/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb deleted file mode 100644 index 75029057..00000000 --- a/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +++ /dev/null @@ -1,233 +0,0 @@ -require 'abstract_unit' -require 'digest/sha1' - -ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' -end - -# common controller actions -module RequestForgeryProtectionActions - def index - render :inline => "<%= form_tag('/') {} %>" - end - - def show_button - render :inline => "<%= button_to('New', '/') {} %>" - end - - def remote_form - render :inline => "<% form_remote_tag(:url => '/') {} %>" - end - - def unsafe - render :text => 'pwn' - end - - def meta - render :inline => "<%= csrf_meta_tag %>" - end - - def rescue_action(e) raise e end -end - -# sample controllers -class RequestForgeryProtectionController < ActionController::Base - include RequestForgeryProtectionActions - protect_from_forgery :only => :index -end - -class RequestForgeryProtectionControllerUsingOldBehaviour < ActionController::Base - include RequestForgeryProtectionActions - protect_from_forgery :only => %w(index meta) - - def handle_unverified_request - raise(ActionController::InvalidAuthenticityToken) - end -end - - -class FreeCookieController < RequestForgeryProtectionController - self.allow_forgery_protection = false - - def index - render :inline => "<%= form_tag('/') {} %>" - end - - def show_button - render :inline => "<%= button_to('New', '/') {} %>" - end -end - -class CustomAuthenticityParamController < RequestForgeryProtectionController - def form_authenticity_param - 'foobar' - end -end - - -# common test methods - -module RequestForgeryProtectionTests - def setup - @token = "cf50faa3fe97702ca1ae" - - ActiveSupport::SecureRandom.stubs(:base64).returns(@token) - ActionController::Base.request_forgery_protection_token = :authenticity_token - end - - - def test_should_render_form_with_token_tag - assert_not_blocked do - get :index - end - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token - end - - def test_should_render_button_to_with_token_tag - assert_not_blocked do - get :show_button - end - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token - end - - def test_should_allow_get - assert_not_blocked { get :index } - end - - def test_should_allow_post_without_token_on_unsafe_action - assert_not_blocked { post :unsafe } - end - - def test_should_not_allow_post_without_token - assert_blocked { post :index } - end - - def test_should_not_allow_post_without_token_irrespective_of_format - assert_blocked { post :index, :format=>'xml' } - end - - def test_should_not_allow_put_without_token - assert_blocked { put :index } - end - - def test_should_not_allow_delete_without_token - assert_blocked { delete :index } - end - - def test_should_not_allow_xhr_post_without_token - assert_blocked { xhr :post, :index } - end - - def test_should_allow_post_with_token - assert_not_blocked { post :index, :authenticity_token => @token } - end - - def test_should_allow_put_with_token - assert_not_blocked { put :index, :authenticity_token => @token } - end - - def test_should_allow_delete_with_token - assert_not_blocked { delete :index, :authenticity_token => @token } - end - - def test_should_allow_post_with_token_in_header - @request.env['HTTP_X_CSRF_TOKEN'] = @token - assert_not_blocked { post :index } - end - - def test_should_allow_delete_with_token_in_header - @request.env['HTTP_X_CSRF_TOKEN'] = @token - assert_not_blocked { delete :index } - end - - def test_should_allow_put_with_token_in_header - @request.env['HTTP_X_CSRF_TOKEN'] = @token - assert_not_blocked { put :index } - end - - def assert_blocked - session[:something_like_user_id] = 1 - yield - assert_nil session[:something_like_user_id], "session values are still present" - assert_response :success - end - - def assert_not_blocked - assert_nothing_raised { yield } - assert_response :success - end -end - -# OK let's get our test on - -class RequestForgeryProtectionControllerTest < ActionController::TestCase - include RequestForgeryProtectionTests - - test 'should emit a csrf-token meta tag' do - ActiveSupport::SecureRandom.stubs(:base64).returns(@token + '<=?') - get :meta - assert_equal %(<meta name="csrf-param" content="authenticity_token"/>\n<meta name="csrf-token" content="cf50faa3fe97702ca1ae&lt;=?"/>), @response.body - end -end - -class RequestForgeryProtectionControllerUsingOldBehaviourTest < ActionController::TestCase - include RequestForgeryProtectionTests - def assert_blocked - assert_raises(ActionController::InvalidAuthenticityToken) do - yield - end - end -end - -class FreeCookieControllerTest < ActionController::TestCase - def setup - @controller = FreeCookieController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @token = "cf50faa3fe97702ca1ae" - - ActiveSupport::SecureRandom.stubs(:base64).returns(@token) - end - - def test_should_not_render_form_with_token_tag - get :index - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token, false - end - - def test_should_not_render_button_to_with_token_tag - get :show_button - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token, false - end - - def test_should_allow_all_methods_without_token - [:post, :put, :delete].each do |method| - assert_nothing_raised { send(method, :index)} - end - end - - test 'should not emit a csrf-token meta tag' do - get :meta - assert_blank @response.body - end -end - - - - - -class CustomAuthenticityParamControllerTest < ActionController::TestCase - def setup - ActionController::Base.request_forgery_protection_token = :custom_token_name - super - end - - def teardown - ActionController::Base.request_forgery_protection_token = :authenticity_token - super - end - - def test_should_allow_custom_token - post :index, :custom_token_name => 'foobar' - assert_response :ok - end -end diff --git a/vendor/rails/actionpack/test/controller/request_test.rb b/vendor/rails/actionpack/test/controller/request_test.rb deleted file mode 100644 index c4cc63e6..00000000 --- a/vendor/rails/actionpack/test/controller/request_test.rb +++ /dev/null @@ -1,395 +0,0 @@ -require 'abstract_unit' - -class RequestTest < ActiveSupport::TestCase - def setup - ActionController::Base.relative_url_root = nil - end - - def teardown - ActionController::Base.relative_url_root = nil - end - - def test_remote_ip - request = stub_request 'REMOTE_ADDR' => '1.2.3.4' - assert_equal '1.2.3.4', request.remote_ip - - request = stub_request 'REMOTE_ADDR' => '1.2.3.4,3.4.5.6' - assert_equal '1.2.3.4', request.remote_ip - - request = stub_request 'REMOTE_ADDR' => '1.2.3.4', - 'HTTP_X_FORWARDED_FOR' => '3.4.5.6' - assert_equal '1.2.3.4', request.remote_ip - - request = stub_request 'REMOTE_ADDR' => '127.0.0.1', - 'HTTP_X_FORWARDED_FOR' => '3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => 'unknown,3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '172.16.0.1,3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '192.168.0.1,3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '10.0.0.1,3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '10.0.0.1, 10.0.0.1, 3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '127.0.0.1,3.4.5.6' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => 'unknown,192.168.0.1' - assert_equal 'unknown', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4' - assert_equal '3.4.5.6', request.remote_ip - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '1.1.1.1', - 'HTTP_CLIENT_IP' => '2.2.2.2' - e = assert_raise(ActionController::ActionControllerError) { - request.remote_ip - } - assert_match /IP spoofing attack/, e.message - assert_match /HTTP_X_FORWARDED_FOR="1.1.1.1"/, e.message - assert_match /HTTP_CLIENT_IP="2.2.2.2"/, e.message - - # turn IP Spoofing detection off. - # This is useful for sites that are aimed at non-IP clients. The typical - # example is WAP. Since the cellular network is not IP based, it's a - # leap of faith to assume that their proxies are ever going to set the - # HTTP_CLIENT_IP/HTTP_X_FORWARDED_FOR headers properly. - ActionController::Base.ip_spoofing_check = false - request = stub_request 'HTTP_X_FORWARDED_FOR' => '1.1.1.1', - 'HTTP_CLIENT_IP' => '2.2.2.2' - assert_equal '2.2.2.2', request.remote_ip - ActionController::Base.ip_spoofing_check = true - - request = stub_request 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, 9.9.9.9' - assert_equal '9.9.9.9', request.remote_ip - end - - def test_domains - request = stub_request 'HTTP_HOST' => 'www.rubyonrails.org' - assert_equal "rubyonrails.org", request.domain - - request = stub_request 'HTTP_HOST' => "www.rubyonrails.co.uk" - assert_equal "rubyonrails.co.uk", request.domain(2) - - request = stub_request 'HTTP_HOST' => "192.168.1.200" - assert_nil request.domain - - request = stub_request 'HTTP_HOST' => "foo.192.168.1.200" - assert_nil request.domain - - request = stub_request 'HTTP_HOST' => "192.168.1.200.com" - assert_equal "200.com", request.domain - end - - def test_subdomains - request = stub_request 'HTTP_HOST' => "www.rubyonrails.org" - assert_equal %w( www ), request.subdomains - - request = stub_request 'HTTP_HOST' => "www.rubyonrails.co.uk" - assert_equal %w( www ), request.subdomains(2) - - request = stub_request 'HTTP_HOST' => "dev.www.rubyonrails.co.uk" - assert_equal %w( dev www ), request.subdomains(2) - - request = stub_request 'HTTP_HOST' => "foobar.foobar.com" - assert_equal %w( foobar ), request.subdomains - - request = stub_request 'HTTP_HOST' => "192.168.1.200" - assert_equal [], request.subdomains - - request = stub_request 'HTTP_HOST' => "foo.192.168.1.200" - assert_equal [], request.subdomains - - request = stub_request 'HTTP_HOST' => "192.168.1.200.com" - assert_equal %w( 192 168 1 ), request.subdomains - - request = stub_request 'HTTP_HOST' => nil - assert_equal [], request.subdomains - end - - def test_port_string - request = stub_request 'HTTP_HOST' => 'www.example.org:80' - assert_equal "", request.port_string - - request = stub_request 'HTTP_HOST' => 'www.example.org:8080' - assert_equal ":8080", request.port_string - end - - def test_request_uri - request = stub_request 'REQUEST_URI' => "http://www.rubyonrails.org/path/of/some/uri?mapped=1" - assert_equal "/path/of/some/uri?mapped=1", request.request_uri - assert_equal "/path/of/some/uri", request.path - - request = stub_request 'REQUEST_URI' => "http://www.rubyonrails.org/path/of/some/uri" - assert_equal "/path/of/some/uri", request.request_uri - assert_equal "/path/of/some/uri", request.path - - request = stub_request 'REQUEST_URI' => "/path/of/some/uri" - assert_equal "/path/of/some/uri", request.request_uri - assert_equal "/path/of/some/uri", request.path - - request = stub_request 'REQUEST_URI' => "/" - assert_equal "/", request.request_uri - assert_equal "/", request.path - - request = stub_request 'REQUEST_URI' => "/?m=b" - assert_equal "/?m=b", request.request_uri - assert_equal "/", request.path - - request = stub_request 'REQUEST_URI' => "/", 'SCRIPT_NAME' => '/dispatch.cgi' - assert_equal "/", request.request_uri - assert_equal "/", request.path - - ActionController::Base.relative_url_root = "/hieraki" - request = stub_request 'REQUEST_URI' => "/hieraki/", 'SCRIPT_NAME' => "/hieraki/dispatch.cgi" - assert_equal "/hieraki/", request.request_uri - assert_equal "/", request.path - ActionController::Base.relative_url_root = nil - - ActionController::Base.relative_url_root = "/collaboration/hieraki" - request = stub_request 'REQUEST_URI' => "/collaboration/hieraki/books/edit/2", - 'SCRIPT_NAME' => "/collaboration/hieraki/dispatch.cgi" - assert_equal "/collaboration/hieraki/books/edit/2", request.request_uri - assert_equal "/books/edit/2", request.path - ActionController::Base.relative_url_root = nil - - # The following tests are for when REQUEST_URI is not supplied (as in IIS) - request = stub_request 'PATH_INFO' => "/path/of/some/uri?mapped=1", - 'SCRIPT_NAME' => nil, - 'REQUEST_URI' => nil - assert_equal "/path/of/some/uri?mapped=1", request.request_uri - assert_equal "/path/of/some/uri", request.path - - ActionController::Base.relative_url_root = '/path' - request = stub_request 'PATH_INFO' => "/path/of/some/uri?mapped=1", - 'SCRIPT_NAME' => "/path/dispatch.rb", - 'REQUEST_URI' => nil - assert_equal "/path/of/some/uri?mapped=1", request.request_uri - assert_equal "/of/some/uri", request.path - ActionController::Base.relative_url_root = nil - - request = stub_request 'PATH_INFO' => "/path/of/some/uri", - 'SCRIPT_NAME' => nil, - 'REQUEST_URI' => nil - assert_equal "/path/of/some/uri", request.request_uri - assert_equal "/path/of/some/uri", request.path - - request = stub_request 'PATH_INFO' => '/', 'REQUEST_URI' => nil - assert_equal "/", request.request_uri - assert_equal "/", request.path - - request = stub_request 'PATH_INFO' => '/?m=b', 'REQUEST_URI' => nil - assert_equal "/?m=b", request.request_uri - assert_equal "/", request.path - - request = stub_request 'PATH_INFO' => "/", - 'SCRIPT_NAME' => "/dispatch.cgi", - 'REQUEST_URI' => nil - assert_equal "/", request.request_uri - assert_equal "/", request.path - - ActionController::Base.relative_url_root = '/hieraki' - request = stub_request 'PATH_INFO' => "/hieraki/", - 'SCRIPT_NAME' => "/hieraki/dispatch.cgi", - 'REQUEST_URI' => nil - assert_equal "/hieraki/", request.request_uri - assert_equal "/", request.path - ActionController::Base.relative_url_root = nil - - request = stub_request 'REQUEST_URI' => '/hieraki/dispatch.cgi' - ActionController::Base.relative_url_root = '/hieraki' - assert_equal "/dispatch.cgi", request.path - ActionController::Base.relative_url_root = nil - - request = stub_request 'REQUEST_URI' => '/hieraki/dispatch.cgi' - ActionController::Base.relative_url_root = '/foo' - assert_equal "/hieraki/dispatch.cgi", request.path - ActionController::Base.relative_url_root = nil - - # This test ensures that Rails uses REQUEST_URI over PATH_INFO - ActionController::Base.relative_url_root = nil - request = stub_request 'REQUEST_URI' => "/some/path", - 'PATH_INFO' => "/another/path", - 'SCRIPT_NAME' => "/dispatch.cgi" - assert_equal "/some/path", request.request_uri - assert_equal "/some/path", request.path - end - - def test_host_with_default_port - request = stub_request 'HTTP_HOST' => 'rubyonrails.org:80' - assert_equal "rubyonrails.org", request.host_with_port - end - - def test_host_with_non_default_port - request = stub_request 'HTTP_HOST' => 'rubyonrails.org:81' - assert_equal "rubyonrails.org:81", request.host_with_port - end - - def test_server_software - request = stub_request - assert_equal nil, request.server_software - - request = stub_request 'SERVER_SOFTWARE' => 'Apache3.422' - assert_equal 'apache', request.server_software - - request = stub_request 'SERVER_SOFTWARE' => 'lighttpd(1.1.4)' - assert_equal 'lighttpd', request.server_software - end - - def test_xml_http_request - request = stub_request - - assert !request.xml_http_request? - assert !request.xhr? - - request = stub_request 'HTTP_X_REQUESTED_WITH' => 'DefinitelyNotAjax1.0' - assert !request.xml_http_request? - assert !request.xhr? - - request = stub_request 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest' - assert request.xml_http_request? - assert request.xhr? - end - - def test_reports_ssl - request = stub_request - assert !request.ssl? - - request = stub_request 'HTTPS' => 'on' - assert request.ssl? - end - - def test_reports_ssl_when_proxied_via_lighttpd - request = stub_request - assert !request.ssl? - - request = stub_request 'HTTP_X_FORWARDED_PROTO' => 'https' - assert request.ssl? - end - - def test_symbolized_request_methods - [:get, :post, :put, :delete].each do |method| - request = stub_request 'REQUEST_METHOD' => method.to_s.upcase - assert_equal method, request.method - end - end - - def test_invalid_http_method_raises_exception - assert_raise(ActionController::UnknownHttpMethod) do - request = stub_request 'REQUEST_METHOD' => 'RANDOM_METHOD' - request.request_method - end - end - - def test_allow_method_hacking_on_post - [:get, :head, :options, :put, :post, :delete].each do |method| - request = stub_request 'REQUEST_METHOD' => method.to_s.upcase - assert_equal(method == :head ? :get : method, request.method) - end - end - - def test_restrict_method_hacking - [:get, :put, :delete].each do |method| - request = stub_request 'REQUEST_METHOD' => method.to_s.upcase, - 'action_controller.request.request_parameters' => { :_method => 'put' } - assert_equal method, request.method - end - end - - def test_head_masquerading_as_get - request = stub_request 'REQUEST_METHOD' => 'HEAD' - assert_equal :get, request.method - assert request.get? - assert request.head? - end - - def test_xml_format - request = stub_request - request.expects(:parameters).at_least_once.returns({ :format => 'xml' }) - assert_equal Mime::XML, request.format - end - - def test_xhtml_format - request = stub_request - request.expects(:parameters).at_least_once.returns({ :format => 'xhtml' }) - assert_equal Mime::HTML, request.format - end - - def test_txt_format - request = stub_request - request.expects(:parameters).at_least_once.returns({ :format => 'txt' }) - assert_equal Mime::TEXT, request.format - end - - def test_xml_http_request - ActionController::Base.use_accept_header, old = - false, ActionController::Base.use_accept_header - - request = stub_request 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest' - request.expects(:parameters).at_least_once.returns({}) - assert request.xhr? - assert_equal Mime::JS, request.format - ensure - ActionController::Base.use_accept_header = old - end - - def test_content_type - request = stub_request 'CONTENT_TYPE' => 'text/html' - assert_equal Mime::HTML, request.content_type - end - - def test_can_override_format_with_parameter - request = stub_request - request.expects(:parameters).at_least_once.returns({ :format => :txt }) - assert !request.format.xml? - - request = stub_request - request.expects(:parameters).at_least_once.returns({ :format => :xml }) - assert request.format.xml? - end - - def test_content_no_type - request = stub_request - assert_equal nil, request.content_type - end - - def test_content_type_xml - request = stub_request 'CONTENT_TYPE' => 'application/xml' - assert_equal Mime::XML, request.content_type - end - - def test_content_type_with_charset - request = stub_request 'CONTENT_TYPE' => 'application/xml; charset=UTF-8' - assert_equal Mime::XML, request.content_type - end - - def test_user_agent - request = stub_request 'HTTP_USER_AGENT' => 'TestAgent' - assert_equal 'TestAgent', request.user_agent - end - - def test_parameters - request = stub_request - request.stubs(:request_parameters).returns({ "foo" => 1 }) - request.stubs(:query_parameters).returns({ "bar" => 2 }) - - assert_equal({"foo" => 1, "bar" => 2}, request.parameters) - assert_equal({"foo" => 1}, request.request_parameters) - assert_equal({"bar" => 2}, request.query_parameters) - end - -protected - - def stub_request(env={}) - ActionController::Request.new(env) - end - -end diff --git a/vendor/rails/actionpack/test/controller/rescue_test.rb b/vendor/rails/actionpack/test/controller/rescue_test.rb deleted file mode 100644 index 58fccdce..00000000 --- a/vendor/rails/actionpack/test/controller/rescue_test.rb +++ /dev/null @@ -1,541 +0,0 @@ -require 'abstract_unit' - -class RescueController < ActionController::Base - class NotAuthorized < StandardError - end - class NotAuthorizedToRescueAsString < StandardError - end - - class RecordInvalid < StandardError - end - class RecordInvalidToRescueAsString < StandardError - end - - class NotAllowed < StandardError - end - class NotAllowedToRescueAsString < StandardError - end - - class InvalidRequest < StandardError - end - class InvalidRequestToRescueAsString < StandardError - end - - class BadGateway < StandardError - end - class BadGatewayToRescueAsString < StandardError - end - - class ResourceUnavailable < StandardError - end - class ResourceUnavailableToRescueAsString < StandardError - end - - # We use a fully-qualified name in some strings, and a relative constant - # name in some other to test correct handling of both cases. - - rescue_from NotAuthorized, :with => :deny_access - rescue_from 'RescueController::NotAuthorizedToRescueAsString', :with => :deny_access - - rescue_from RecordInvalid, :with => :show_errors - rescue_from 'RescueController::RecordInvalidToRescueAsString', :with => :show_errors - - rescue_from NotAllowed, :with => proc { head :forbidden } - rescue_from 'RescueController::NotAllowedToRescueAsString', :with => proc { head :forbidden } - - rescue_from InvalidRequest, :with => proc { |exception| render :text => exception.message } - rescue_from 'InvalidRequestToRescueAsString', :with => proc { |exception| render :text => exception.message } - - rescue_from BadGateway do - head :status => 502 - end - rescue_from 'BadGatewayToRescueAsString' do - head :status => 502 - end - - rescue_from ResourceUnavailable do |exception| - render :text => exception.message - end - rescue_from 'ResourceUnavailableToRescueAsString' do |exception| - render :text => exception.message - end - - # This is a Dispatcher exception and should be in ApplicationController. - rescue_from ActionController::RoutingError do - render :text => 'no way' - end - - before_filter(:only => :before_filter_raises) { raise 'umm nice' } - - def before_filter_raises - end - - def raises - render :text => 'already rendered' - raise "don't panic!" - end - - def method_not_allowed - raise ActionController::MethodNotAllowed.new(:get, :head, :put) - end - - def not_implemented - raise ActionController::NotImplemented.new(:get, :put) - end - - def not_authorized - raise NotAuthorized - end - def not_authorized_raise_as_string - raise NotAuthorizedToRescueAsString - end - - def not_allowed - raise NotAllowed - end - def not_allowed_raise_as_string - raise NotAllowedToRescueAsString - end - - def invalid_request - raise InvalidRequest - end - def invalid_request_raise_as_string - raise InvalidRequestToRescueAsString - end - - def record_invalid - raise RecordInvalid - end - def record_invalid_raise_as_string - raise RecordInvalidToRescueAsString - end - - def bad_gateway - raise BadGateway - end - def bad_gateway_raise_as_string - raise BadGatewayToRescueAsString - end - - def resource_unavailable - raise ResourceUnavailable - end - def resource_unavailable_raise_as_string - raise ResourceUnavailableToRescueAsString - end - - def missing_template - end - - protected - def deny_access - head :forbidden - end - - def show_errors(exception) - head :unprocessable_entity - end -end - -class RescueControllerTest < ActionController::TestCase - FIXTURE_PUBLIC = "#{File.dirname(__FILE__)}/../fixtures".freeze - - setup :set_all_requests_local - setup :populate_exception_object - - def set_all_requests_local - RescueController.consider_all_requests_local = true - @request.remote_addr = '1.2.3.4' - @request.host = 'example.com' - end - - def populate_exception_object - begin - raise 'foo' - rescue => @exception - end - end - - def test_rescue_exceptions_raised_by_filters - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :before_filter_raises - end - end - - assert_response :internal_server_error - end - - def test_rescue_action_locally_if_all_requests_local - @controller.expects(:local_request?).never - @controller.expects(:rescue_action_locally).with(@exception) - @controller.expects(:rescue_action_in_public).never - - with_all_requests_local do - @controller.send :rescue_action, @exception - end - end - - def test_rescue_action_locally_if_remote_addr_is_localhost - @controller.expects(:local_request?).returns(true) - @controller.expects(:rescue_action_locally).with(@exception) - @controller.expects(:rescue_action_in_public).never - - with_all_requests_local false do - @controller.send :rescue_action, @exception - end - end - - def test_rescue_action_in_public_otherwise - @controller.expects(:local_request?).returns(false) - @controller.expects(:rescue_action_locally).never - @controller.expects(:rescue_action_in_public).with(@exception) - - with_all_requests_local false do - @controller.send :rescue_action, @exception - end - end - - def test_rescue_action_in_public_with_localized_error_file - # Change locale - old_locale = I18n.locale - I18n.locale = :da - - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :raises - end - end - - assert_response :internal_server_error - body = File.read("#{FIXTURE_PUBLIC}/public/500.da.html") - assert_equal body, @response.body - ensure - I18n.locale = old_locale - end - - def test_rescue_action_in_public_with_error_file - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :raises - end - end - - assert_response :internal_server_error - body = File.read("#{FIXTURE_PUBLIC}/public/500.html") - assert_equal body, @response.body - end - - def test_rescue_action_in_public_without_error_file - with_rails_root '/tmp' do - with_all_requests_local false do - get :raises - end - end - - assert_response :internal_server_error - assert_equal ' ', @response.body - end - - def test_rescue_unknown_action_in_public_with_error_file - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :foobar_doesnt_exist - end - end - - assert_response :not_found - body = File.read("#{FIXTURE_PUBLIC}/public/404.html") - assert_equal body, @response.body - end - - def test_rescue_unknown_action_in_public_without_error_file - with_rails_root '/tmp' do - with_all_requests_local false do - get :foobar_doesnt_exist - end - end - - assert_response :not_found - assert_equal ' ', @response.body - end - - def test_rescue_missing_template_in_public - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local true do - get :missing_template - end - end - - assert_response :internal_server_error - assert @response.body.include?('missing_template'), "Response should include the template name." - end - - def test_rescue_action_locally - get :raises - assert_response :internal_server_error - assert_template 'diagnostics.erb' - assert @response.body.include?('RescueController#raises'), "Response should include controller and action." - assert @response.body.include?("don't panic"), "Response should include exception message." - end - - def test_local_request_when_remote_addr_is_localhost - @controller.expects(:request).returns(@request).at_least(10) - ['127.0.0.1', '127.0.0.127', '::1', '0:0:0:0:0:0:0:1', '0:0:0:0:0:0:0:1%0'].each do |ip_address| - with_remote_addr ip_address do - assert @controller.send(:local_request?) - end - end - end - - def test_local_request_when_remote_addr_isnt_locahost - @controller.expects(:request).returns(@request).at_least(4) - with_remote_addr '1.2.3.4' do - assert !@controller.send(:local_request?) - end - with_remote_addr '2002::102:304' do - assert !@controller.send(:local_request?) - end - end - - def test_rescue_responses - responses = ActionController::Base.rescue_responses - - assert_equal ActionController::Rescue::DEFAULT_RESCUE_RESPONSE, responses.default - assert_equal ActionController::Rescue::DEFAULT_RESCUE_RESPONSE, responses[Exception.new] - - assert_equal :not_found, responses[ActionController::RoutingError.name] - assert_equal :not_found, responses[ActionController::UnknownAction.name] - assert_equal :not_found, responses['ActiveRecord::RecordNotFound'] - assert_equal :conflict, responses['ActiveRecord::StaleObjectError'] - assert_equal :unprocessable_entity, responses['ActiveRecord::RecordInvalid'] - assert_equal :unprocessable_entity, responses['ActiveRecord::RecordNotSaved'] - assert_equal :method_not_allowed, responses['ActionController::MethodNotAllowed'] - assert_equal :not_implemented, responses['ActionController::NotImplemented'] - end - - def test_rescue_templates - templates = ActionController::Base.rescue_templates - - assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates.default - assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates[Exception.new] - - assert_equal 'missing_template', templates[ActionView::MissingTemplate.name] - assert_equal 'routing_error', templates[ActionController::RoutingError.name] - assert_equal 'unknown_action', templates[ActionController::UnknownAction.name] - assert_equal 'template_error', templates[ActionView::TemplateError.name] - end - - def test_not_implemented - with_all_requests_local false do - with_rails_public_path(".") do - head :not_implemented - end - end - assert_response :not_implemented - assert_equal "GET, PUT", @response.headers['Allow'] - end - - def test_method_not_allowed - with_all_requests_local false do - with_rails_public_path(".") do - get :method_not_allowed - end - end - assert_response :method_not_allowed - assert_equal "GET, HEAD, PUT", @response.headers['Allow'] - end - - def test_rescue_handler - get :not_authorized - assert_response :forbidden - end - def test_rescue_handler_string - get :not_authorized_raise_as_string - assert_response :forbidden - end - - def test_rescue_handler_with_argument - @controller.expects(:show_errors).once.with { |e| e.is_a?(Exception) } - get :record_invalid - end - def test_rescue_handler_with_argument_as_string - @controller.expects(:show_errors).once.with { |e| e.is_a?(Exception) } - get :record_invalid_raise_as_string - end - - def test_proc_rescue_handler - get :not_allowed - assert_response :forbidden - end - def test_proc_rescue_handler_as_string - get :not_allowed_raise_as_string - assert_response :forbidden - end - - def test_proc_rescue_handle_with_argument - get :invalid_request - assert_equal "RescueController::InvalidRequest", @response.body - end - def test_proc_rescue_handle_with_argument_as_string - get :invalid_request_raise_as_string - assert_equal "RescueController::InvalidRequestToRescueAsString", @response.body - end - - def test_block_rescue_handler - get :bad_gateway - assert_response 502 - end - def test_block_rescue_handler_as_string - get :bad_gateway_raise_as_string - assert_response 502 - end - - def test_block_rescue_handler_with_argument - get :resource_unavailable - assert_equal "RescueController::ResourceUnavailable", @response.body - end - - def test_block_rescue_handler_with_argument_as_string - get :resource_unavailable_raise_as_string - assert_equal "RescueController::ResourceUnavailableToRescueAsString", @response.body - end - - def test_rescue_dispatcher_exceptions - env = @request.env - env["action_controller.rescue.request"] = @request - env["action_controller.rescue.response"] = @response - - RescueController.call_with_exception(env, ActionController::RoutingError.new("Route not found")) - assert_equal "no way", @response.body - end - - def test_rescue_dispatcher_exceptions_without_request_set - @request.env['REQUEST_URI'] = '/no_way' - response = RescueController.call_with_exception(@request.env, ActionController::RoutingError.new("Route not found")) - assert_kind_of ActionController::Response, response - assert_equal "no way", response.body - end - - protected - def with_all_requests_local(local = true) - old_local, ActionController::Base.consider_all_requests_local = - ActionController::Base.consider_all_requests_local, local - yield - ensure - ActionController::Base.consider_all_requests_local = old_local - end - - def with_remote_addr(addr) - old_remote_addr, @request.remote_addr = @request.remote_addr, addr - yield - ensure - @request.remote_addr = old_remote_addr - end - - def with_rails_public_path(rails_root) - old_rails = Object.const_get(:Rails) rescue nil - mod = Object.const_set(:Rails, Module.new) - (class << mod; self; end).instance_eval do - define_method(:public_path) { "#{rails_root}/public" } - end - yield - ensure - Object.module_eval { remove_const(:Rails) } if defined?(Rails) - Object.const_set(:Rails, old_rails) if old_rails - end - - def with_rails_root(path = nil,&block) - old_rails_root = RAILS_ROOT if defined?(RAILS_ROOT) - if path - silence_warnings { Object.const_set(:RAILS_ROOT, path) } - else - Object.remove_const(:RAILS_ROOT) rescue nil - end - - with_rails_public_path(path, &block) - - ensure - if old_rails_root - silence_warnings { Object.const_set(:RAILS_ROOT, old_rails_root) } - else - Object.remove_const(:RAILS_ROOT) rescue nil - end - end -end - -class ExceptionInheritanceRescueController < ActionController::Base - - class ParentException < StandardError - end - - class ChildException < ParentException - end - - class GrandchildException < ChildException - end - - rescue_from ChildException, :with => lambda { head :ok } - rescue_from ParentException, :with => lambda { head :created } - rescue_from GrandchildException, :with => lambda { head :no_content } - - def raise_parent_exception - raise ParentException - end - - def raise_child_exception - raise ChildException - end - - def raise_grandchild_exception - raise GrandchildException - end -end - -class ExceptionInheritanceRescueControllerTest < ActionController::TestCase - def test_bottom_first - get :raise_grandchild_exception - assert_response :no_content - end - - def test_inheritance_works - get :raise_child_exception - assert_response :created - end -end - -class ControllerInheritanceRescueController < ExceptionInheritanceRescueController - class FirstExceptionInChildController < StandardError - end - - class SecondExceptionInChildController < StandardError - end - - rescue_from FirstExceptionInChildController, 'SecondExceptionInChildController', :with => lambda { head :gone } - - def raise_first_exception_in_child_controller - raise FirstExceptionInChildController - end - - def raise_second_exception_in_child_controller - raise SecondExceptionInChildController - end -end - -class ControllerInheritanceRescueControllerTest < ActionController::TestCase - def test_first_exception_in_child_controller - get :raise_first_exception_in_child_controller - assert_response :gone - end - - def test_second_exception_in_child_controller - get :raise_second_exception_in_child_controller - assert_response :gone - end - - def test_exception_in_parent_controller - get :raise_parent_exception - assert_response :created - end -end diff --git a/vendor/rails/actionpack/test/controller/resources_test.rb b/vendor/rails/actionpack/test/controller/resources_test.rb deleted file mode 100644 index 0b639e36..00000000 --- a/vendor/rails/actionpack/test/controller/resources_test.rb +++ /dev/null @@ -1,1393 +0,0 @@ -require 'abstract_unit' - -class ResourcesController < ActionController::Base - def index() render :nothing => true end - alias_method :show, :index - def rescue_action(e) raise e end -end - -class ThreadsController < ResourcesController; end -class MessagesController < ResourcesController; end -class CommentsController < ResourcesController; end -class AuthorsController < ResourcesController; end -class LogosController < ResourcesController; end - -class AccountsController < ResourcesController; end -class AdminController < ResourcesController; end -class ProductsController < ResourcesController; end -class ImagesController < ResourcesController; end - -module Backoffice - class ProductsController < ResourcesController; end - class TagsController < ResourcesController; end - class ManufacturersController < ResourcesController; end - class ImagesController < ResourcesController; end - - module Admin - class ProductsController < ResourcesController; end - class ImagesController < ResourcesController; end - end -end - -class ResourcesTest < ActionController::TestCase - # The assertions in these tests are incompatible with the hash method - # optimisation. This could indicate user level problems - def setup - ActionController::Base.optimise_named_routes = false - end - - def teardown - ActionController::Base.optimise_named_routes = true - end - - def test_should_arrange_actions - resource = ActionController::Resources::Resource.new(:messages, - :collection => { :rss => :get, :reorder => :post, :csv => :post }, - :member => { :rss => :get, :atom => :get, :upload => :post, :fix => :post }, - :new => { :preview => :get, :draft => :get }) - - assert_resource_methods [:rss], resource, :collection, :get - assert_resource_methods [:csv, :reorder], resource, :collection, :post - assert_resource_methods [:edit, :rss, :atom], resource, :member, :get - assert_resource_methods [:upload, :fix], resource, :member, :post - assert_resource_methods [:new, :preview, :draft], resource, :new, :get - end - - def test_should_resource_controller_name_equal_resource_name_by_default - resource = ActionController::Resources::Resource.new(:messages, {}) - assert_equal 'messages', resource.controller - end - - def test_should_resource_controller_name_equal_controller_option - resource = ActionController::Resources::Resource.new(:messages, :controller => 'posts') - assert_equal 'posts', resource.controller - end - - def test_should_all_singleton_paths_be_the_same - [ :path, :nesting_path_prefix, :member_path ].each do |method| - resource = ActionController::Resources::SingletonResource.new(:messages, :path_prefix => 'admin') - assert_equal 'admin/messages', resource.send(method) - end - end - - def test_default_restful_routes - with_restful_routing :messages do - assert_simply_restful_for :messages - end - end - - def test_override_paths_for_member_and_collection_methods - collection_methods = { 'rss' => :get, 'reorder' => :post, 'csv' => :post } - member_methods = { 'rss' => :get, :atom => :get, :upload => :post, :fix => :post } - path_names = {:new => 'nuevo', 'rss' => 'canal', :fix => 'corrigir' } - - with_restful_routing :messages, - :collection => collection_methods, - :member => member_methods, - :path_names => path_names do - - assert_restful_routes_for :messages, - :collection => collection_methods, - :member => member_methods, - :path_names => path_names do |options| - member_methods.each do |action, method| - assert_recognizes(options.merge(:action => action.to_s, :id => '1'), - :path => "/messages/1/#{path_names[action] || action}", - :method => method) - end - - collection_methods.each do |action, method| - assert_recognizes(options.merge(:action => action), - :path => "/messages/#{path_names[action] || action}", - :method => method) - end - end - - assert_restful_named_routes_for :messages, - :collection => collection_methods, - :member => member_methods, - :path_names => path_names do |options| - - collection_methods.keys.each do |action| - assert_named_route "/messages/#{path_names[action] || action}", "#{action}_messages_path", :action => action - end - - member_methods.keys.each do |action| - assert_named_route "/messages/1/#{path_names[action] || action}", "#{action}_message_path", :action => action, :id => "1" - end - - end - end - end - - def test_override_paths_for_default_restful_actions - resource = ActionController::Resources::Resource.new(:messages, - :path_names => {:new => 'nuevo', :edit => 'editar'}) - assert_equal resource.new_path, "#{resource.path}/nuevo" - end - - def test_multiple_default_restful_routes - with_restful_routing :messages, :comments do - assert_simply_restful_for :messages - assert_simply_restful_for :comments - end - end - - def test_with_custom_conditions - with_restful_routing :messages, :conditions => { :subdomain => 'app' } do - assert_equal 'app', ActionController::Routing::Routes.named_routes.routes[:messages].conditions[:subdomain] - end - end - - def test_irregular_id_with_no_requirements_should_raise_error - expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'} - - with_restful_routing :messages do - assert_raise(ActionController::RoutingError) do - assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get) - end - end - end - - def test_irregular_id_with_requirements_should_pass - expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'} - - with_restful_routing(:messages, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}) do - assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get) - end - end - - def test_with_path_prefix_requirements - expected_options = {:controller => 'messages', :action => 'show', :thread_id => '1.1.1', :id => '1'} - with_restful_routing :messages, :path_prefix => '/thread/:thread_id', :requirements => {:thread_id => /[0-9]\.[0-9]\.[0-9]/} do - assert_recognizes(expected_options, :path => 'thread/1.1.1/messages/1', :method => :get) - end - end - - def test_irregular_id_requirements_should_get_passed_to_member_actions - expected_options = {:controller => 'messages', :action => 'custom', :id => '1.1.1'} - - with_restful_routing(:messages, :member => {:custom => :get}, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}) do - assert_recognizes(expected_options, :path => 'messages/1.1.1/custom', :method => :get) - end - end - - def test_with_path_prefix - with_restful_routing :messages, :path_prefix => '/thread/:thread_id' do - assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } - end - end - - def test_multiple_with_path_prefix - with_restful_routing :messages, :comments, :path_prefix => '/thread/:thread_id' do - assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } - assert_simply_restful_for :comments, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } - end - end - - def test_with_name_prefix - with_restful_routing :messages, :name_prefix => 'post_' do - assert_simply_restful_for :messages, :name_prefix => 'post_' - end - end - - def test_with_collection_actions - actions = { 'a' => :get, 'b' => :put, 'c' => :post, 'd' => :delete } - - with_restful_routing :messages, :collection => actions do - assert_restful_routes_for :messages do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action), :path => "/messages/#{action}", :method => method) - end - end - - assert_restful_named_routes_for :messages do |options| - actions.keys.each do |action| - assert_named_route "/messages/#{action}", "#{action}_messages_path", :action => action - end - end - end - end - - def test_with_collection_actions_and_name_prefix - actions = { 'a' => :get, 'b' => :put, 'c' => :post, 'd' => :delete } - - with_restful_routing :messages, :path_prefix => '/threads/:thread_id', :name_prefix => "thread_", :collection => actions do - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action), :path => "/threads/1/messages/#{action}", :method => method) - end - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.keys.each do |action| - assert_named_route "/threads/1/messages/#{action}", "#{action}_thread_messages_path", :action => action - end - end - end - end - - def test_with_collection_actions_and_name_prefix_and_member_action_with_same_name - actions = { 'a' => :get } - - with_restful_routing :messages, :path_prefix => '/threads/:thread_id', :name_prefix => "thread_", :collection => actions, :member => actions do - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action), :path => "/threads/1/messages/#{action}", :method => method) - end - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.keys.each do |action| - assert_named_route "/threads/1/messages/#{action}", "#{action}_thread_messages_path", :action => action - end - end - end - end - - def test_with_collection_action_and_name_prefix_and_formatted - actions = { 'a' => :get, 'b' => :put, 'c' => :post, 'd' => :delete } - - with_restful_routing :messages, :path_prefix => '/threads/:thread_id', :name_prefix => "thread_", :collection => actions do - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action, :format => 'xml'), :path => "/threads/1/messages/#{action}.xml", :method => method) - end - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.keys.each do |action| - assert_named_route "/threads/1/messages/#{action}.xml", "#{action}_thread_messages_path", :action => action, :format => 'xml' - end - end - end - end - - def test_with_member_action - [:put, :post].each do |method| - with_restful_routing :messages, :member => { :mark => method } do - mark_options = {:action => 'mark', :id => '1'} - mark_path = "/messages/1/mark" - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method) - end - - assert_restful_named_routes_for :messages do |options| - assert_named_route mark_path, :mark_message_path, mark_options - end - end - end - end - - def test_with_member_action_and_requirement - expected_options = {:controller => 'messages', :action => 'mark', :id => '1.1.1'} - - with_restful_routing(:messages, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}, :member => { :mark => :get }) do - assert_recognizes(expected_options, :path => 'messages/1.1.1/mark', :method => :get) - end - end - - def test_member_when_override_paths_for_default_restful_actions_with - [:put, :post].each do |method| - with_restful_routing :messages, :member => { :mark => method }, :path_names => {:new => 'nuevo'} do - mark_options = {:action => 'mark', :id => '1', :controller => "messages"} - mark_path = "/messages/1/mark" - - assert_restful_routes_for :messages, :path_names => {:new => 'nuevo'} do |options| - assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method) - end - - assert_restful_named_routes_for :messages, :path_names => {:new => 'nuevo'} do |options| - assert_named_route mark_path, :mark_message_path, mark_options - end - end - end - end - - def test_member_when_changed_default_restful_actions_and_path_names_not_specified - default_path_names = ActionController::Base.resources_path_names - ActionController::Base.resources_path_names = {:new => 'nuevo', :edit => 'editar'} - - with_restful_routing :messages do - new_options = { :action => 'new', :controller => 'messages' } - new_path = "/messages/nuevo" - edit_options = { :action => 'edit', :id => '1', :controller => 'messages' } - edit_path = "/messages/1/editar" - - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(new_options), :path => new_path, :method => :get) - end - - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(edit_options), :path => edit_path, :method => :get) - end - end - ensure - ActionController::Base.resources_path_names = default_path_names - end - - def test_with_two_member_actions_with_same_method - [:put, :post].each do |method| - with_restful_routing :messages, :member => { :mark => method, :unmark => method } do - %w(mark unmark).each do |action| - action_options = {:action => action, :id => '1'} - action_path = "/messages/1/#{action}" - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(action_options), :path => action_path, :method => method) - end - - assert_restful_named_routes_for :messages do |options| - assert_named_route action_path, "#{action}_message_path".to_sym, action_options - end - end - end - end - end - - def test_array_as_collection_or_member_method_value - with_restful_routing :messages, :collection => { :search => [:get, :post] }, :member => { :toggle => [:get, :post] } do - assert_restful_routes_for :messages do |options| - [:get, :post].each do |method| - assert_recognizes(options.merge(:action => 'search'), :path => "/messages/search", :method => method) - end - [:get, :post].each do |method| - assert_recognizes(options.merge(:action => 'toggle', :id => '1'), :path => '/messages/1/toggle', :method => method) - end - end - end - end - - def test_with_new_action - with_restful_routing :messages, :new => { :preview => :post } do - preview_options = {:action => 'preview'} - preview_path = "/messages/new/preview" - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) - end - - assert_restful_named_routes_for :messages do |options| - assert_named_route preview_path, :preview_new_message_path, preview_options - end - end - end - - def test_with_new_action_with_name_prefix - with_restful_routing :messages, :new => { :preview => :post }, :path_prefix => '/threads/:thread_id', :name_prefix => 'thread_' do - preview_options = {:action => 'preview', :thread_id => '1'} - preview_path = "/threads/1/messages/new/preview" - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_named_route preview_path, :preview_new_thread_message_path, preview_options - end - end - end - - def test_with_formatted_new_action_with_name_prefix - with_restful_routing :messages, :new => { :preview => :post }, :path_prefix => '/threads/:thread_id', :name_prefix => 'thread_' do - preview_options = {:action => 'preview', :thread_id => '1', :format => 'xml'} - preview_path = "/threads/1/messages/new/preview.xml" - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_named_route preview_path, :preview_new_thread_message_path, preview_options - end - end - end - - def test_override_new_method - with_restful_routing :messages do - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) - assert_raise(ActionController::MethodNotAllowed) do - ActionController::Routing::Routes.recognize_path("/messages/new", :method => :post) - end - end - end - - with_restful_routing :messages, :new => { :new => :any } do - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :post) - assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) - end - end - end - - def test_nested_restful_routes - with_routing do |set| - set.draw do |map| - map.resources :threads do |map| - map.resources :messages do |map| - map.resources :comments - end - end - end - - assert_simply_restful_for :threads - assert_simply_restful_for :messages, - :name_prefix => 'thread_', - :path_prefix => 'threads/1/', - :options => { :thread_id => '1' } - assert_simply_restful_for :comments, - :name_prefix => 'thread_message_', - :path_prefix => 'threads/1/messages/2/', - :options => { :thread_id => '1', :message_id => '2' } - end - end - - def test_nested_restful_routes_with_overwritten_defaults - with_routing do |set| - set.draw do |map| - map.resources :threads do |map| - map.resources :messages, :name_prefix => nil do |map| - map.resources :comments, :name_prefix => nil - end - end - end - - assert_simply_restful_for :threads - assert_simply_restful_for :messages, - :path_prefix => 'threads/1/', - :options => { :thread_id => '1' } - assert_simply_restful_for :comments, - :path_prefix => 'threads/1/messages/2/', - :options => { :thread_id => '1', :message_id => '2' } - end - end - - def test_shallow_nested_restful_routes - with_routing do |set| - set.draw do |map| - map.resources :threads, :shallow => true do |map| - map.resources :messages do |map| - map.resources :comments - end - end - end - - assert_simply_restful_for :threads, - :shallow => true - assert_simply_restful_for :messages, - :name_prefix => 'thread_', - :path_prefix => 'threads/1/', - :shallow => true, - :options => { :thread_id => '1' } - assert_simply_restful_for :comments, - :name_prefix => 'message_', - :path_prefix => 'messages/2/', - :shallow => true, - :options => { :message_id => '2' } - end - end - - def test_shallow_nested_restful_routes_with_namespaces - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |map| - map.namespace :admin do |map| - map.resources :products, :shallow => true do |map| - map.resources :images - end - end - end - end - - assert_simply_restful_for :products, - :controller => 'backoffice/admin/products', - :namespace => 'backoffice/admin/', - :name_prefix => 'backoffice_admin_', - :path_prefix => 'backoffice/admin/', - :shallow => true - assert_simply_restful_for :images, - :controller => 'backoffice/admin/images', - :namespace => 'backoffice/admin/', - :name_prefix => 'backoffice_admin_product_', - :path_prefix => 'backoffice/admin/products/1/', - :shallow => true, - :options => { :product_id => '1' } - end - end - - def test_restful_routes_dont_generate_duplicates - with_restful_routing :messages do - routes = ActionController::Routing::Routes.routes - routes.each do |route| - routes.each do |r| - next if route === r # skip the comparison instance - assert distinct_routes?(route, r), "Duplicate Route: #{route}" - end - end - end - end - - def test_should_create_singleton_resource_routes - with_singleton_resources :account do - assert_singleton_restful_for :account - end - end - - def test_should_create_multiple_singleton_resource_routes - with_singleton_resources :account, :logo do - assert_singleton_restful_for :account - assert_singleton_restful_for :logo - end - end - - def test_should_create_nested_singleton_resource_routes - with_routing do |set| - set.draw do |map| - map.resource :admin, :controller => 'admin' do |admin| - admin.resource :account - end - end - - assert_singleton_restful_for :admin, :controller => 'admin' - assert_singleton_restful_for :account, :name_prefix => "admin_", :path_prefix => 'admin/' - end - end - - def test_resource_has_many_should_become_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_many => [ :comments, :authors ] - end - - assert_simply_restful_for :messages - assert_simply_restful_for :comments, :name_prefix => "message_", :path_prefix => 'messages/1/', :options => { :message_id => '1' } - assert_simply_restful_for :authors, :name_prefix => "message_", :path_prefix => 'messages/1/', :options => { :message_id => '1' } - end - end - - def test_resources_has_many_hash_should_become_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :threads, :has_many => { :messages => [ :comments, { :authors => :threads } ] } - end - - assert_simply_restful_for :threads - assert_simply_restful_for :messages, :name_prefix => "thread_", :path_prefix => 'threads/1/', :options => { :thread_id => '1' } - assert_simply_restful_for :comments, :name_prefix => "thread_message_", :path_prefix => 'threads/1/messages/1/', :options => { :thread_id => '1', :message_id => '1' } - assert_simply_restful_for :authors, :name_prefix => "thread_message_", :path_prefix => 'threads/1/messages/1/', :options => { :thread_id => '1', :message_id => '1' } - assert_simply_restful_for :threads, :name_prefix => "thread_message_author_", :path_prefix => 'threads/1/messages/1/authors/1/', :options => { :thread_id => '1', :message_id => '1', :author_id => '1' } - end - end - - def test_shallow_resource_has_many_should_become_shallow_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_many => [ :comments, :authors ], :shallow => true - end - - assert_simply_restful_for :messages, :shallow => true - assert_simply_restful_for :comments, :name_prefix => "message_", :path_prefix => 'messages/1/', :shallow => true, :options => { :message_id => '1' } - assert_simply_restful_for :authors, :name_prefix => "message_", :path_prefix => 'messages/1/', :shallow => true, :options => { :message_id => '1' } - end - end - - def test_resource_has_one_should_become_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_one => :logo - end - - assert_simply_restful_for :messages - assert_singleton_restful_for :logo, :name_prefix => 'message_', :path_prefix => 'messages/1/', :options => { :message_id => '1' } - end - end - - def test_shallow_resource_has_one_should_become_shallow_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_one => :logo, :shallow => true - end - - assert_simply_restful_for :messages, :shallow => true - assert_singleton_restful_for :logo, :name_prefix => 'message_', :path_prefix => 'messages/1/', :shallow => true, :options => { :message_id => '1' } - end - end - - def test_singleton_resource_with_member_action - [:put, :post].each do |method| - with_singleton_resources :account, :member => { :reset => method } do - reset_options = {:action => 'reset'} - reset_path = "/account/reset" - assert_singleton_routes_for :account do |options| - assert_recognizes(options.merge(reset_options), :path => reset_path, :method => method) - end - - assert_singleton_named_routes_for :account do |options| - assert_named_route reset_path, :reset_account_path, reset_options - end - end - end - end - - def test_singleton_resource_with_two_member_actions_with_same_method - [:put, :post].each do |method| - with_singleton_resources :account, :member => { :reset => method, :disable => method } do - %w(reset disable).each do |action| - action_options = {:action => action} - action_path = "/account/#{action}" - assert_singleton_routes_for :account do |options| - assert_recognizes(options.merge(action_options), :path => action_path, :method => method) - end - - assert_singleton_named_routes_for :account do |options| - assert_named_route action_path, "#{action}_account_path".to_sym, action_options - end - end - end - end - end - - def test_should_nest_resources_in_singleton_resource - with_routing do |set| - set.draw do |map| - map.resource :account do |account| - account.resources :messages - end - end - - assert_singleton_restful_for :account - assert_simply_restful_for :messages, :name_prefix => "account_", :path_prefix => 'account/' - end - end - - def test_should_nest_resources_in_singleton_resource_with_path_prefix - with_routing do |set| - set.draw do |map| - map.resource(:account, :path_prefix => ':site_id') do |account| - account.resources :messages - end - end - - assert_singleton_restful_for :account, :path_prefix => '7/', :options => { :site_id => '7' } - assert_simply_restful_for :messages, :name_prefix => "account_", :path_prefix => '7/account/', :options => { :site_id => '7' } - end - end - - def test_should_nest_singleton_resource_in_resources - with_routing do |set| - set.draw do |map| - map.resources :threads do |thread| - thread.resource :admin, :controller => 'admin' - end - end - - assert_simply_restful_for :threads - assert_singleton_restful_for :admin, :controller => 'admin', :name_prefix => 'thread_', :path_prefix => 'threads/5/', :options => { :thread_id => '5' } - end - end - - def test_should_not_allow_delete_or_put_on_collection_path - controller_name = :messages - with_restful_routing controller_name do - options = { :controller => controller_name.to_s } - collection_path = "/#{controller_name}" - - assert_raise(ActionController::MethodNotAllowed) do - assert_recognizes(options.merge(:action => 'update'), :path => collection_path, :method => :put) - end - - assert_raise(ActionController::MethodNotAllowed) do - assert_recognizes(options.merge(:action => 'destroy'), :path => collection_path, :method => :delete) - end - end - end - - def test_should_not_allow_invalid_head_method_for_member_routes - with_routing do |set| - set.draw do |map| - assert_raise(ArgumentError) do - map.resources :messages, :member => {:something => :head} - end - end - end - end - - def test_should_not_allow_invalid_http_methods_for_member_routes - with_routing do |set| - set.draw do |map| - assert_raise(ArgumentError) do - map.resources :messages, :member => {:something => :invalid} - end - end - end - end - - def test_resource_action_separator - with_routing do |set| - set.draw do |map| - map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id' - map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin' - end - - action_separator = ActionController::Base.resource_action_separator - - assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' } - assert_named_route "/threads/1/messages#{action_separator}search", "search_thread_messages_path", {} - assert_named_route "/threads/1/messages/new", "new_thread_message_path", {} - assert_named_route "/threads/1/messages/new#{action_separator}preview", "preview_new_thread_message_path", {} - assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/' - assert_named_route "/admin/account#{action_separator}login", "login_admin_account_path", {} - assert_named_route "/admin/account/new", "new_admin_account_path", {} - assert_named_route "/admin/account/new#{action_separator}preview", "preview_new_admin_account_path", {} - end - end - - def test_new_style_named_routes_for_resource - with_routing do |set| - set.draw do |map| - map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id' - end - assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' } - assert_named_route "/threads/1/messages/search", "search_thread_messages_path", {} - assert_named_route "/threads/1/messages/new", "new_thread_message_path", {} - assert_named_route "/threads/1/messages/new/preview", "preview_new_thread_message_path", {} - end - end - - def test_new_style_named_routes_for_singleton_resource - with_routing do |set| - set.draw do |map| - map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin' - end - assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/' - assert_named_route "/admin/account/login", "login_admin_account_path", {} - assert_named_route "/admin/account/new", "new_admin_account_path", {} - assert_named_route "/admin/account/new/preview", "preview_new_admin_account_path", {} - end - end - - def test_resources_in_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products - end - end - - assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/' - end - end - - def test_resource_has_many_in_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products, :has_many => :tags - end - end - - assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/' - assert_simply_restful_for :tags, :controller => "backoffice/tags", :name_prefix => "backoffice_product_", :path_prefix => 'backoffice/products/1/', :options => { :product_id => '1' } - end - end - - def test_resource_has_one_in_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products, :has_one => :manufacturer - end - end - - assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/' - assert_singleton_restful_for :manufacturer, :controller => "backoffice/manufacturers", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => { :product_id => '1' } - end - end - - def test_resources_in_nested_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.namespace :admin do |admin| - admin.resources :products - end - end - end - - assert_simply_restful_for :products, :controller => "backoffice/admin/products", :name_prefix => 'backoffice_admin_', :path_prefix => 'backoffice/admin/' - end - end - - def test_resources_using_namespace - with_routing do |set| - set.draw do |map| - map.resources :products, :namespace => "backoffice/" - end - - assert_simply_restful_for :products, :controller => "backoffice/products" - end - end - - def test_nested_resources_using_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products do |products| - products.resources :images - end - end - end - - assert_simply_restful_for :images, :controller => "backoffice/images", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => {:product_id => '1'} - end - end - - def test_nested_resources_in_nested_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.namespace :admin do |admin| - admin.resources :products do |products| - products.resources :images - end - end - end - end - - assert_simply_restful_for :images, :controller => "backoffice/admin/images", :name_prefix => 'backoffice_admin_product_', :path_prefix => 'backoffice/admin/products/1/', :options => {:product_id => '1'} - end - end - - def test_with_path_segment - with_restful_routing :messages do - assert_simply_restful_for :messages - assert_recognizes({:controller => "messages", :action => "index"}, "/messages") - assert_recognizes({:controller => "messages", :action => "index"}, "/messages/") - end - - with_restful_routing :messages, :as => 'reviews' do - assert_simply_restful_for :messages, :as => 'reviews' - assert_recognizes({:controller => "messages", :action => "index"}, "/reviews") - assert_recognizes({:controller => "messages", :action => "index"}, "/reviews/") - end - end - - def test_multiple_with_path_segment_and_controller - with_routing do |set| - set.draw do |map| - map.resources :products do |products| - products.resources :product_reviews, :as => 'reviews', :controller => 'messages' - end - map.resources :tutors do |tutors| - tutors.resources :tutor_reviews, :as => 'reviews', :controller => 'comments' - end - end - - assert_simply_restful_for :product_reviews, :controller=>'messages', :as => 'reviews', :name_prefix => 'product_', :path_prefix => 'products/1/', :options => {:product_id => '1'} - assert_simply_restful_for :tutor_reviews,:controller=>'comments', :as => 'reviews', :name_prefix => 'tutor_', :path_prefix => 'tutors/1/', :options => {:tutor_id => '1'} - end - end - - def test_with_path_segment_path_prefix_requirements - expected_options = {:controller => 'messages', :action => 'show', :thread_id => '1.1.1', :id => '1'} - with_restful_routing :messages, :as => 'comments',:path_prefix => '/thread/:thread_id', :requirements => { :thread_id => /[0-9]\.[0-9]\.[0-9]/ } do - assert_recognizes(expected_options, :path => 'thread/1.1.1/comments/1', :method => :get) - end - end - - def test_resource_has_only_show_action - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :show, [:index, :new, :create, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :show, [:index, :new, :create, :edit, :update, :destroy]) - end - end - - def test_singleton_resource_has_only_show_action - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :show - end - - assert_singleton_resource_allowed_routes('accounts', {}, :show, [:index, :new, :create, :edit, :update, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :show, [:index, :new, :create, :edit, :update, :destroy]) - end - end - - def test_resource_does_not_have_destroy_action - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :destroy - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, [:index, :new, :create, :show, :edit, :update], :destroy) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, [:index, :new, :create, :show, :edit, :update], :destroy) - end - end - - def test_singleton_resource_does_not_have_destroy_action - with_routing do |set| - set.draw do |map| - map.resource :account, :except => :destroy - end - - assert_singleton_resource_allowed_routes('accounts', {}, [:new, :create, :show, :edit, :update], :destroy) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, [:new, :create, :show, :edit, :update], :destroy) - end - end - - def test_resource_has_only_create_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :create - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :create, [:index, :new, :show, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :create, [:index, :new, :show, :edit, :update, :destroy]) - - assert_not_nil set.named_routes[:products] - end - end - - def test_resource_has_only_update_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :update - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :update, [:index, :new, :create, :show, :edit, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :update, [:index, :new, :create, :show, :edit, :destroy]) - - assert_not_nil set.named_routes[:product] - end - end - - def test_resource_has_only_destroy_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :destroy - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :destroy, [:index, :new, :create, :show, :edit, :update]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :destroy, [:index, :new, :create, :show, :edit, :update]) - - assert_not_nil set.named_routes[:product] - end - end - - def test_singleton_resource_has_only_create_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :create - end - - assert_singleton_resource_allowed_routes('accounts', {}, :create, [:new, :show, :edit, :update, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :create, [:new, :show, :edit, :update, :destroy]) - - assert_not_nil set.named_routes[:account] - end - end - - def test_singleton_resource_has_only_update_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :update - end - - assert_singleton_resource_allowed_routes('accounts', {}, :update, [:new, :create, :show, :edit, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :update, [:new, :create, :show, :edit, :destroy]) - - assert_not_nil set.named_routes[:account] - end - end - - def test_singleton_resource_has_only_destroy_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :destroy - end - - assert_singleton_resource_allowed_routes('accounts', {}, :destroy, [:new, :create, :show, :edit, :update]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :destroy, [:new, :create, :show, :edit, :update]) - - assert_not_nil set.named_routes[:account] - end - end - - def test_resource_has_only_collection_action - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :all, :collection => { :sale => :get } - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - - assert_recognizes({ :controller => 'products', :action => 'sale' }, :path => 'products/sale', :method => :get) - assert_recognizes({ :controller => 'products', :action => 'sale', :format => 'xml' }, :path => 'products/sale.xml', :method => :get) - end - end - - def test_resource_has_only_member_action - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :all, :member => { :preview => :get } - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - - assert_recognizes({ :controller => 'products', :action => 'preview', :id => '1' }, :path => 'products/1/preview', :method => :get) - assert_recognizes({ :controller => 'products', :action => 'preview', :id => '1', :format => 'xml' }, :path => 'products/1/preview.xml', :method => :get) - end - end - - def test_singleton_resource_has_only_member_action - with_routing do |set| - set.draw do |map| - map.resource :account, :except => :all, :member => { :signup => :get } - end - - assert_singleton_resource_allowed_routes('accounts', {}, [], [:new, :create, :show, :edit, :update, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, [], [:new, :create, :show, :edit, :update, :destroy]) - - assert_recognizes({ :controller => 'accounts', :action => 'signup' }, :path => 'account/signup', :method => :get) - assert_recognizes({ :controller => 'accounts', :action => 'signup', :format => 'xml' }, :path => 'account/signup.xml', :method => :get) - end - end - - def test_nested_resource_has_only_show_and_member_action - with_routing do |set| - set.draw do |map| - map.resources :products, :only => [:index, :show] do |product| - product.resources :images, :member => { :thumbnail => :get }, :only => :show - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, :show, [:index, :new, :create, :edit, :update, :destroy], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, :show, [:index, :new, :create, :edit, :update, :destroy], 'products/1/images') - - assert_recognizes({ :controller => 'images', :action => 'thumbnail', :product_id => '1', :id => '2' }, :path => 'products/1/images/2/thumbnail', :method => :get) - assert_recognizes({ :controller => 'images', :action => 'thumbnail', :product_id => '1', :id => '2', :format => 'jpg' }, :path => 'products/1/images/2/thumbnail.jpg', :method => :get) - end - end - - def test_nested_resource_does_not_inherit_only_option - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show do |product| - product.resources :images, :except => :destroy - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update], :destroy, 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update], :destroy, 'products/1/images') - end - end - - def test_nested_resource_does_not_inherit_only_option_by_default - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show do |product| - product.resources :images - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destory], [], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') - end - end - - def test_nested_resource_does_not_inherit_except_option - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :show do |product| - product.resources :images, :only => :destroy - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, :destroy, [:index, :new, :create, :show, :edit, :update], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, :destroy, [:index, :new, :create, :show, :edit, :update], 'products/1/images') - end - end - - def test_nested_resource_does_not_inherit_except_option_by_default - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :show do |product| - product.resources :images - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') - end - end - - def test_default_singleton_restful_route_uses_get - with_routing do |set| - set.draw do |map| - map.resource :product - end - - assert_equal :get, set.named_routes.routes[:product].conditions[:method] - end - end - - protected - def with_restful_routing(*args) - with_routing do |set| - set.draw { |map| map.resources(*args) } - yield - end - end - - def with_singleton_resources(*args) - with_routing do |set| - set.draw { |map| map.resource(*args) } - yield - end - end - - # runs assert_restful_routes_for and assert_restful_named_routes for on the controller_name and options, without passing a block. - def assert_simply_restful_for(controller_name, options = {}) - assert_restful_routes_for controller_name, options - assert_restful_named_routes_for controller_name, nil, options - end - - def assert_singleton_restful_for(singleton_name, options = {}) - assert_singleton_routes_for singleton_name, options - assert_singleton_named_routes_for singleton_name, options - end - - def assert_restful_routes_for(controller_name, options = {}) - options[:options] ||= {} - options[:options][:controller] = options[:controller] || controller_name.to_s - - if options[:shallow] - options[:shallow_options] ||= {} - options[:shallow_options][:controller] = options[:options][:controller] - else - options[:shallow_options] = options[:options] - end - - new_action = ActionController::Base.resources_path_names[:new] || "new" - edit_action = ActionController::Base.resources_path_names[:edit] || "edit" - if options[:path_names] - new_action = options[:path_names][:new] if options[:path_names][:new] - edit_action = options[:path_names][:edit] if options[:path_names][:edit] - end - - path = "#{options[:as] || controller_name}" - collection_path = "/#{options[:path_prefix]}#{path}" - shallow_path = "/#{options[:shallow] ? options[:namespace] : options[:path_prefix]}#{path}" - member_path = "#{shallow_path}/1" - new_path = "#{collection_path}/#{new_action}" - edit_member_path = "#{member_path}/#{edit_action}" - formatted_edit_member_path = "#{member_path}/#{edit_action}.xml" - - with_options(options[:options]) do |controller| - controller.assert_routing collection_path, :action => 'index' - controller.assert_routing new_path, :action => 'new' - controller.assert_routing "#{collection_path}.xml", :action => 'index', :format => 'xml' - controller.assert_routing "#{new_path}.xml", :action => 'new', :format => 'xml' - end - - with_options(options[:shallow_options]) do |controller| - controller.assert_routing member_path, :action => 'show', :id => '1' - controller.assert_routing edit_member_path, :action => 'edit', :id => '1' - controller.assert_routing "#{member_path}.xml", :action => 'show', :id => '1', :format => 'xml' - controller.assert_routing formatted_edit_member_path, :action => 'edit', :id => '1', :format => 'xml' - end - - assert_recognizes(options[:options].merge(:action => 'index'), :path => collection_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'new'), :path => new_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'create'), :path => collection_path, :method => :post) - assert_recognizes(options[:shallow_options].merge(:action => 'show', :id => '1'), :path => member_path, :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'edit', :id => '1'), :path => edit_member_path, :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'update', :id => '1'), :path => member_path, :method => :put) - assert_recognizes(options[:shallow_options].merge(:action => 'destroy', :id => '1'), :path => member_path, :method => :delete) - - assert_recognizes(options[:options].merge(:action => 'index', :format => 'xml'), :path => "#{collection_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'new', :format => 'xml'), :path => "#{new_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'create', :format => 'xml'), :path => "#{collection_path}.xml", :method => :post) - assert_recognizes(options[:shallow_options].merge(:action => 'show', :id => '1', :format => 'xml'), :path => "#{member_path}.xml", :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'edit', :id => '1', :format => 'xml'), :path => formatted_edit_member_path, :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'update', :id => '1', :format => 'xml'), :path => "#{member_path}.xml", :method => :put) - assert_recognizes(options[:shallow_options].merge(:action => 'destroy', :id => '1', :format => 'xml'), :path => "#{member_path}.xml", :method => :delete) - - yield options[:options] if block_given? - end - - # test named routes like foo_path and foos_path map to the correct options. - def assert_restful_named_routes_for(controller_name, singular_name = nil, options = {}) - if singular_name.is_a?(Hash) - options = singular_name - singular_name = nil - end - singular_name ||= controller_name.to_s.singularize - - options[:options] ||= {} - options[:options][:controller] = options[:controller] || controller_name.to_s - - if options[:shallow] - options[:shallow_options] ||= {} - options[:shallow_options][:controller] = options[:options][:controller] - else - options[:shallow_options] = options[:options] - end - - @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index, options[:options] - options[:options].delete :action - - path = "#{options[:as] || controller_name}" - shallow_path = "/#{options[:shallow] ? options[:namespace] : options[:path_prefix]}#{path}" - full_path = "/#{options[:path_prefix]}#{path}" - name_prefix = options[:name_prefix] - shallow_prefix = options[:shallow] ? options[:namespace].try(:gsub, /\//, '_') : options[:name_prefix] - - new_action = "new" - edit_action = "edit" - if options[:path_names] - new_action = options[:path_names][:new] || "new" - edit_action = options[:path_names][:edit] || "edit" - end - - assert_named_route "#{full_path}", "#{name_prefix}#{controller_name}_path", options[:options] - assert_named_route "#{full_path}.xml", "#{name_prefix}#{controller_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{shallow_path}/1", "#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1') - assert_named_route "#{shallow_path}/1.xml", "#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1', :format => 'xml') - - assert_named_route "#{full_path}/#{new_action}", "new_#{name_prefix}#{singular_name}_path", options[:options] - assert_named_route "#{full_path}/#{new_action}.xml", "new_#{name_prefix}#{singular_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{shallow_path}/1/#{edit_action}", "edit_#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1') - assert_named_route "#{shallow_path}/1/#{edit_action}.xml", "edit_#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1', :format => 'xml') - - yield options[:options] if block_given? - end - - def assert_singleton_routes_for(singleton_name, options = {}) - options[:options] ||= {} - options[:options][:controller] = options[:controller] || singleton_name.to_s.pluralize - - full_path = "/#{options[:path_prefix]}#{options[:as] || singleton_name}" - new_path = "#{full_path}/new" - edit_path = "#{full_path}/edit" - formatted_edit_path = "#{full_path}/edit.xml" - - with_options options[:options] do |controller| - controller.assert_routing full_path, :action => 'show' - controller.assert_routing new_path, :action => 'new' - controller.assert_routing edit_path, :action => 'edit' - controller.assert_routing "#{full_path}.xml", :action => 'show', :format => 'xml' - controller.assert_routing "#{new_path}.xml", :action => 'new', :format => 'xml' - controller.assert_routing formatted_edit_path, :action => 'edit', :format => 'xml' - end - - assert_recognizes(options[:options].merge(:action => 'show'), :path => full_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'new'), :path => new_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'edit'), :path => edit_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'create'), :path => full_path, :method => :post) - assert_recognizes(options[:options].merge(:action => 'update'), :path => full_path, :method => :put) - assert_recognizes(options[:options].merge(:action => 'destroy'), :path => full_path, :method => :delete) - - assert_recognizes(options[:options].merge(:action => 'show', :format => 'xml'), :path => "#{full_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'new', :format => 'xml'), :path => "#{new_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'edit', :format => 'xml'), :path => formatted_edit_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'create', :format => 'xml'), :path => "#{full_path}.xml", :method => :post) - assert_recognizes(options[:options].merge(:action => 'update', :format => 'xml'), :path => "#{full_path}.xml", :method => :put) - assert_recognizes(options[:options].merge(:action => 'destroy', :format => 'xml'), :path => "#{full_path}.xml", :method => :delete) - - yield options[:options] if block_given? - end - - def assert_singleton_named_routes_for(singleton_name, options = {}) - (options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize - @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :show, options[:options] - options[:options].delete :action - - full_path = "/#{options[:path_prefix]}#{options[:as] || singleton_name}" - name_prefix = options[:name_prefix] - - assert_named_route "#{full_path}", "#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}.xml", "#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - - assert_named_route "#{full_path}/new", "new_#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}/new.xml", "new_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{full_path}/edit", "edit_#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}/edit.xml", "edit_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - end - - def assert_named_route(expected, route, options) - actual = @controller.send(route, options) rescue $!.class.name - assert_equal expected, actual, "Error on route: #{route}(#{options.inspect})" - end - - def assert_resource_methods(expected, resource, action_method, method) - assert_equal expected.length, resource.send("#{action_method}_methods")[method].size, "#{resource.send("#{action_method}_methods")[method].inspect}" - expected.each do |action| - assert resource.send("#{action_method}_methods")[method].include?(action), - "#{method} not in #{action_method} methods: #{resource.send("#{action_method}_methods")[method].inspect}" - end - end - - def assert_resource_allowed_routes(controller, options, shallow_options, allowed, not_allowed, path = controller) - shallow_path = "#{path}/#{shallow_options[:id]}" - format = options[:format] && ".#{options[:format]}" - options.merge!(:controller => controller) - shallow_options.merge!(options) - - assert_whether_allowed(allowed, not_allowed, options, 'index', "#{path}#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'new', "#{path}/new#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'create', "#{path}#{format}", :post) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'show', "#{shallow_path}#{format}", :get) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'edit', "#{shallow_path}/edit#{format}", :get) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'update', "#{shallow_path}#{format}", :put) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'destroy', "#{shallow_path}#{format}", :delete) - end - - def assert_singleton_resource_allowed_routes(controller, options, allowed, not_allowed, path = controller.singularize) - format = options[:format] && ".#{options[:format]}" - options.merge!(:controller => controller) - - assert_whether_allowed(allowed, not_allowed, options, 'new', "#{path}/new#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'create', "#{path}#{format}", :post) - assert_whether_allowed(allowed, not_allowed, options, 'show', "#{path}#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'edit', "#{path}/edit#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'update', "#{path}#{format}", :put) - assert_whether_allowed(allowed, not_allowed, options, 'destroy', "#{path}#{format}", :delete) - end - - def assert_whether_allowed(allowed, not_allowed, options, action, path, method) - action = action.to_sym - options = options.merge(:action => action.to_s) - path_options = { :path => path, :method => method } - - if Array(allowed).include?(action) - assert_recognizes options, path_options - elsif Array(not_allowed).include?(action) - assert_not_recognizes options, path_options - end - end - - def assert_not_recognizes(expected_options, path) - assert_raise ActionController::RoutingError, ActionController::MethodNotAllowed, Assertion do - assert_recognizes(expected_options, path) - end - end - - def distinct_routes? (r1, r2) - if r1.conditions == r2.conditions and r1.requirements == r2.requirements then - if r1.segments.collect(&:to_s) == r2.segments.collect(&:to_s) then - return false - end - end - true - end -end diff --git a/vendor/rails/actionpack/test/controller/routing_test.rb b/vendor/rails/actionpack/test/controller/routing_test.rb deleted file mode 100644 index fc4804f7..00000000 --- a/vendor/rails/actionpack/test/controller/routing_test.rb +++ /dev/null @@ -1,2592 +0,0 @@ -# encoding: us-ascii -require 'abstract_unit' -require 'controller/fake_controllers' -require 'action_controller/routing/route_set' - -class MilestonesController < ActionController::Base - def index() head :ok end - alias_method :show, :index - def rescue_action(e) raise e end -end - -RunTimeTests = ARGV.include? 'time' -ROUTING = ActionController::Routing - -class ROUTING::RouteBuilder - attr_reader :warn_output - - def warn(msg) - (@warn_output ||= []) << msg - end -end - -# See RFC 3986, section 3.3 for allowed path characters. -class UriReservedCharactersRoutingTest < Test::Unit::TestCase - def setup - ActionController::Routing.use_controllers! ['controller'] - @set = ActionController::Routing::RouteSet.new - @set.draw do |map| - map.connect ':controller/:action/:variable/*additional' - end - - safe, unsafe = %w(: @ & = + $ , ;), %w(^ / ? # [ ]) - hex = unsafe.map { |char| '%' + char.unpack('H2').first.upcase } - - @segment = "#{safe.join}#{unsafe.join}".freeze - @escaped = "#{safe.join}#{hex.join}".freeze - end - - def test_route_generation_escapes_unsafe_path_characters - assert_equal "/contr#{@segment}oller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2", - @set.generate(:controller => "contr#{@segment}oller", - :action => "act#{@segment}ion", - :variable => "var#{@segment}iable", - :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"]) - end - - def test_route_recognition_unescapes_path_components - options = { :controller => "controller", - :action => "act#{@segment}ion", - :variable => "var#{@segment}iable", - :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"] } - assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2") - end - - def test_route_generation_allows_passing_non_string_values_to_generated_helper - assert_equal "/controller/action/variable/1/2", @set.generate(:controller => "controller", - :action => "action", - :variable => "variable", - :additional => [1, 2]) - end -end - -class SegmentTest < Test::Unit::TestCase - def test_first_segment_should_interpolate_for_structure - s = ROUTING::Segment.new - def s.interpolation_statement(array) 'hello' end - assert_equal 'hello', s.continue_string_structure([]) - end - - def test_interpolation_statement - s = ROUTING::StaticSegment.new("Hello") - assert_equal "Hello", eval(s.interpolation_statement([])) - assert_equal "HelloHello", eval(s.interpolation_statement([s])) - - s2 = ROUTING::StaticSegment.new("-") - assert_equal "Hello-Hello", eval(s.interpolation_statement([s, s2])) - - s3 = ROUTING::StaticSegment.new("World") - assert_equal "Hello-World", eval(s3.interpolation_statement([s, s2])) - end -end - -class StaticSegmentTest < Test::Unit::TestCase - def test_interpolation_chunk_should_respect_raw - s = ROUTING::StaticSegment.new('Hello World') - assert !s.raw? - assert_equal 'Hello%20World', s.interpolation_chunk - - s = ROUTING::StaticSegment.new('Hello World', :raw => true) - assert s.raw? - assert_equal 'Hello World', s.interpolation_chunk - end - - def test_regexp_chunk_should_escape_specials - s = ROUTING::StaticSegment.new('Hello*World') - assert_equal 'Hello\*World', s.regexp_chunk - - s = ROUTING::StaticSegment.new('HelloWorld') - assert_equal 'HelloWorld', s.regexp_chunk - end - - def test_regexp_chunk_should_add_question_mark_for_optionals - s = ROUTING::StaticSegment.new("/", :optional => true) - assert_equal "/?", s.regexp_chunk - - s = ROUTING::StaticSegment.new("hello", :optional => true) - assert_equal "(?:hello)?", s.regexp_chunk - end -end - -class DynamicSegmentTest < ActiveSupport::TestCase - def setup - @segment = nil - end - - def segment(options = {}) - unless @segment - @segment = ROUTING::DynamicSegment.new(:a, options) - end - @segment - end - - def test_extract_value - s = ROUTING::DynamicSegment.new(:a) - - hash = {:a => '10', :b => '20'} - assert_equal '10', eval(s.extract_value) - - hash = {:b => '20'} - assert_equal nil, eval(s.extract_value) - - s.default = '20' - assert_equal '20', eval(s.extract_value) - end - - def test_default_local_name - assert_equal 'a_value', segment.local_name, - "Unexpected name -- all value_check tests will fail!" - end - - def test_presence_value_check - a_value = 10 - assert eval(segment.value_check) - end - - def test_regexp_value_check_rejects_nil - segment = segment(:regexp => /\d+/) - - a_value = nil - assert !eval(segment.value_check) - end - - def test_optional_regexp_value_check_should_accept_nil - segment = segment(:regexp => /\d+/, :optional => true) - - a_value = nil - assert eval(segment.value_check) - end - - def test_regexp_value_check_rejects_no_match - segment = segment(:regexp => /\d+/) - - a_value = "Hello20World" - assert !eval(segment.value_check) - - a_value = "20Hi" - assert !eval(segment.value_check) - end - - def test_regexp_value_check_accepts_match - segment = segment(:regexp => /\d+/) - a_value = "30" - assert eval(segment.value_check) - end - - def test_value_check_fails_on_nil - a_value = nil - assert ! eval(segment.value_check) - end - - def test_optional_value_needs_no_check - segment = segment(:optional => true) - - a_value = nil - assert_equal nil, segment.value_check - end - - def test_regexp_value_check_should_accept_match_with_default - segment = segment(:regexp => /\d+/, :default => '200') - - a_value = '100' - assert eval(segment.value_check) - end - - def test_expiry_should_not_trigger_once_expired - expired = true - hash = merged = {:a => 2, :b => 3} - options = {:b => 3} - expire_on = Hash.new { raise 'No!!!' } - - eval(segment.expiry_statement) - rescue RuntimeError - flunk "Expiry check should not have occurred!" - end - - def test_expiry_should_occur_according_to_expire_on - expired = false - hash = merged = {:a => 2, :b => 3} - options = {:b => 3} - - expire_on = {:b => true, :a => false} - eval(segment.expiry_statement) - assert !expired - assert_equal({:a => 2, :b => 3}, hash) - - expire_on = {:b => true, :a => true} - eval(segment.expiry_statement) - assert expired - assert_equal({:b => 3}, hash) - end - - def test_extraction_code_should_return_on_nil - hash = merged = {:b => 3} - options = {:b => 3} - a_value = nil - - # Local jump because of return inside eval. - assert_raise(LocalJumpError) { eval(segment.extraction_code) } - end - - def test_extraction_code_should_return_on_mismatch - segment = segment(:regexp => /\d+/) - hash = merged = {:a => 'Hi', :b => '3'} - options = {:b => '3'} - a_value = nil - - # Local jump because of return inside eval. - assert_raise(LocalJumpError) { eval(segment.extraction_code) } - end - - def test_extraction_code_should_accept_value_and_set_local - hash = merged = {:a => 'Hi', :b => '3'} - options = {:b => '3'} - a_value = nil - expired = true - - eval(segment.extraction_code) - assert_equal 'Hi', a_value - end - - def test_extraction_should_work_without_value_check - segment.default = 'hi' - hash = merged = {:b => '3'} - options = {:b => '3'} - a_value = nil - expired = true - - eval(segment.extraction_code) - assert_equal 'hi', a_value - end - - def test_extraction_code_should_perform_expiry - expired = false - hash = merged = {:a => 'Hi', :b => '3'} - options = {:b => '3'} - expire_on = {:a => true} - a_value = nil - - eval(segment.extraction_code) - assert_equal 'Hi', a_value - assert expired - assert_equal options, hash - end - - def test_interpolation_chunk_should_replace_value - a_value = 'Hi' - assert_equal a_value, eval(%("#{segment.interpolation_chunk}")) - end - - def test_interpolation_chunk_should_accept_nil - a_value = nil - assert_equal '', eval(%("#{segment.interpolation_chunk('a_value')}")) - end - - def test_value_regexp_should_be_nil_without_regexp - assert_equal nil, segment.value_regexp - end - - def test_value_regexp_should_match_exacly - segment = segment(:regexp => /\d+/) - assert_no_match segment.value_regexp, "Hello 10 World" - assert_no_match segment.value_regexp, "Hello 10" - assert_no_match segment.value_regexp, "10 World" - assert_match segment.value_regexp, "10" - end - - def test_regexp_chunk_should_return_string - segment = segment(:regexp => /\d+/) - assert_kind_of String, segment.regexp_chunk - end - - def test_build_pattern_non_optional_with_no_captures - # Non optional - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /\d+/) - assert_equal "(\\d+)stuff", a_segment.build_pattern('stuff') - end - - def test_build_pattern_non_optional_with_captures - # Non optional - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /(\d+)(.*?)/) - assert_equal "((\\d+)(.*?))stuff", a_segment.build_pattern('stuff') - end - - def test_optionality_implied - a_segment = ROUTING::DynamicSegment.new(:id) - assert a_segment.optionality_implied? - - a_segment = ROUTING::DynamicSegment.new(:action) - assert a_segment.optionality_implied? - end - - def test_modifiers_must_be_handled_sensibly - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /david|jamis/i) - assert_equal "((?i-mx:david|jamis))stuff", a_segment.build_pattern('stuff') - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /david|jamis/x) - assert_equal "((?x-mi:david|jamis))stuff", a_segment.build_pattern('stuff') - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /david|jamis/) - assert_equal "(david|jamis)stuff", a_segment.build_pattern('stuff') - end -end - -class ControllerSegmentTest < Test::Unit::TestCase - def test_regexp_should_only_match_possible_controllers - ActionController::Routing.with_controllers %w(admin/accounts admin/users account pages) do - cs = ROUTING::ControllerSegment.new :controller - regexp = %r{\A#{cs.regexp_chunk}\Z} - - ActionController::Routing.possible_controllers.each do |name| - assert_match regexp, name - assert_no_match regexp, "#{name}_fake" - - match = regexp.match name - assert_equal name, match[1] - end - end - end -end - -class PathSegmentTest < ActiveSupport::TestCase - def setup - @segment = nil - end - - def segment(options = {}) - unless @segment - @segment = ROUTING::PathSegment.new(:path, options) - end - @segment - end - - def test_regexp_chunk_should_return_string - segment = segment(:regexp => /[a-z]+/) - assert_kind_of String, segment.regexp_chunk - end - - def test_regexp_chunk_should_be_wrapped_with_parenthesis - segment = segment(:regexp => /[a-z]+/) - assert_equal "([a-z]+)", segment.regexp_chunk - end - - def test_regexp_chunk_should_respect_options - segment = segment(:regexp => /[a-z]+/i) - assert_equal "((?i-mx:[a-z]+))", segment.regexp_chunk - end -end - -class RouteBuilderTest < Test::Unit::TestCase - def builder - @builder ||= ROUTING::RouteBuilder.new - end - - def build(path, options) - builder.build(path, options) - end - - def test_options_should_not_be_modified - requirements1 = { :id => /\w+/, :controller => /(?:[a-z](?:-?[a-z]+)*)/ } - requirements2 = requirements1.dup - - assert_equal requirements1, requirements2 - - with_options(:controller => 'folder', - :requirements => requirements2) do |m| - m.build 'folders/new', :action => 'new' - end - - assert_equal requirements1, requirements2 - end - - def test_segment_for_static - segment, rest = builder.segment_for 'ulysses' - assert_equal '', rest - assert_kind_of ROUTING::StaticSegment, segment - assert_equal 'ulysses', segment.value - end - - def test_segment_for_action - segment, rest = builder.segment_for ':action' - assert_equal '', rest - assert_kind_of ROUTING::DynamicSegment, segment - assert_equal :action, segment.key - assert_equal 'index', segment.default - end - - def test_segment_for_dynamic - segment, rest = builder.segment_for ':login' - assert_equal '', rest - assert_kind_of ROUTING::DynamicSegment, segment - assert_equal :login, segment.key - assert_equal nil, segment.default - assert ! segment.optional? - end - - def test_segment_for_with_rest - segment, rest = builder.segment_for ':login/:action' - assert_equal :login, segment.key - assert_equal '/:action', rest - segment, rest = builder.segment_for rest - assert_equal '/', segment.value - assert_equal ':action', rest - segment, rest = builder.segment_for rest - assert_equal :action, segment.key - assert_equal '', rest - end - - def test_segments_for - segments = builder.segments_for_route_path '/:controller/:action/:id' - - assert_kind_of ROUTING::DividerSegment, segments[0] - assert_equal '/', segments[2].value - - assert_kind_of ROUTING::DynamicSegment, segments[1] - assert_equal :controller, segments[1].key - - assert_kind_of ROUTING::DividerSegment, segments[2] - assert_equal '/', segments[2].value - - assert_kind_of ROUTING::DynamicSegment, segments[3] - assert_equal :action, segments[3].key - - assert_kind_of ROUTING::DividerSegment, segments[4] - assert_equal '/', segments[4].value - - assert_kind_of ROUTING::DynamicSegment, segments[5] - assert_equal :id, segments[5].key - end - - def test_segment_for_action - s, r = builder.segment_for(':action/something/else') - assert_equal '/something/else', r - assert_equal :action, s.key - end - - def test_action_default_should_not_trigger_on_prefix - s, r = builder.segment_for ':action_name/something/else' - assert_equal '/something/else', r - assert_equal :action_name, s.key - assert_equal nil, s.default - end - - def test_divide_route_options - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults, requirements = builder.divide_route_options(segments, - :action => 'buy', :person => /\w+/, :car => /\w+/, - :defaults => {:person => nil, :car => nil} - ) - - assert_equal({:action => 'buy', :person => nil, :car => nil}, defaults) - assert_equal({:person => /\w+/, :car => /\w+/}, requirements) - end - - def test_assign_route_options - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults = {:action => 'buy', :person => nil, :car => nil} - requirements = {:person => /\w+/, :car => /\w+/} - - route_requirements = builder.assign_route_options(segments, defaults, requirements) - assert_equal({}, route_requirements) - - assert_equal :action, segments[3].key - assert_equal 'buy', segments[3].default - - assert_equal :person, segments[5].key - assert_equal %r/\w+/, segments[5].regexp - assert segments[5].optional? - - assert_equal :car, segments[7].key - assert_equal %r/\w+/, segments[7].regexp - assert segments[7].optional? - end - - def test_assign_route_options_with_anchor_chars - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults = {:action => 'buy', :person => nil, :car => nil} - requirements = {:person => /\w+/, :car => /^\w+$/} - - assert_raise ArgumentError do - route_requirements = builder.assign_route_options(segments, defaults, requirements) - end - - requirements[:car] = /[^\/]+/ - route_requirements = builder.assign_route_options(segments, defaults, requirements) - end - - def test_optional_segments_preceding_required_segments - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults = {:action => 'buy', :person => nil, :car => "model-t"} - assert builder.assign_route_options(segments, defaults, {}).empty? - - 0.upto(1) { |i| assert !segments[i].optional?, "segment #{i} is optional and it shouldn't be" } - assert segments[2].optional? - - assert_equal nil, builder.warn_output # should only warn on the :person segment - end - - def test_segmentation_of_dot_path - segments = builder.segments_for_route_path '/books/:action.rss' - assert builder.assign_route_options(segments, {}, {}).empty? - assert_equal 6, segments.length # "/", "books", "/", ":action", ".", "rss" - assert !segments.any? { |seg| seg.optional? } - end - - def test_segmentation_of_dynamic_dot_path - segments = builder.segments_for_route_path '/books/:action.:format' - assert builder.assign_route_options(segments, {}, {}).empty? - assert_equal 6, segments.length # "/", "books", "/", ":action", ".", ":format" - assert !segments.any? { |seg| seg.optional? } - assert_kind_of ROUTING::DynamicSegment, segments.last - end - - def test_assignment_of_default_options - segments = builder.segments_for_route_path '/:controller/:action/:id/' - action, id = segments[-4], segments[-2] - - assert_equal :action, action.key - assert_equal :id, id.key - assert ! action.optional? - assert ! id.optional? - - builder.assign_default_route_options(segments) - - assert_equal 'index', action.default - assert action.optional? - assert id.optional? - end - - def test_assignment_of_default_options_respects_existing_defaults - segments = builder.segments_for_route_path '/:controller/:action/:id/' - action, id = segments[-4], segments[-2] - - assert_equal :action, action.key - assert_equal :id, id.key - action.default = 'show' - action.is_optional = true - - id.default = 'Welcome' - id.is_optional = true - - builder.assign_default_route_options(segments) - - assert_equal 'show', action.default - assert action.optional? - assert_equal 'Welcome', id.default - assert id.optional? - end - - def test_assignment_of_default_options_respects_regexps - segments = builder.segments_for_route_path '/:controller/:action/:id/' - action = segments[-4] - - assert_equal :action, action.key - segments[-4] = ROUTING::DynamicSegment.new(:action, :regexp => /show|in/) - - builder.assign_default_route_options(segments) - - assert_equal nil, action.default - assert ! action.optional? - end - - def test_assignment_of_is_optional_when_default - segments = builder.segments_for_route_path '/books/:action.rss' - assert_equal segments[3].key, :action - segments[3].default = 'changes' - builder.ensure_required_segments(segments) - assert ! segments[3].optional? - end - - def test_is_optional_is_assigned_to_default_segments - segments = builder.segments_for_route_path '/books/:action' - builder.assign_route_options(segments, {:action => 'index'}, {}) - - assert_equal segments[3].key, :action - assert segments[3].optional? - assert_kind_of ROUTING::DividerSegment, segments[2] - assert segments[2].optional? - end - - # XXX is optional not being set right? - # /blah/:defaulted_segment <-- is the second slash optional? it should be. - - def test_route_build - ActionController::Routing.with_controllers %w(users pages) do - r = builder.build '/:controller/:action/:id/', :action => nil - - [0, 2, 4].each do |i| - assert_kind_of ROUTING::DividerSegment, r.segments[i] - assert_equal '/', r.segments[i].value - assert r.segments[i].optional? if i > 1 - end - - assert_kind_of ROUTING::DynamicSegment, r.segments[1] - assert_equal :controller, r.segments[1].key - assert_equal nil, r.segments[1].default - - assert_kind_of ROUTING::DynamicSegment, r.segments[3] - assert_equal :action, r.segments[3].key - assert_equal 'index', r.segments[3].default - - assert_kind_of ROUTING::DynamicSegment, r.segments[5] - assert_equal :id, r.segments[5].key - assert r.segments[5].optional? - end - end - - def test_slashes_are_implied - routes = [ - builder.build('/:controller/:action/:id/', :action => nil), - builder.build('/:controller/:action/:id', :action => nil), - builder.build(':controller/:action/:id', :action => nil), - builder.build('/:controller/:action/:id/', :action => nil) - ] - expected = routes.first.segments.length - routes.each_with_index do |route, i| - found = route.segments.length - assert_equal expected, found, "Route #{i + 1} has #{found} segments, expected #{expected}" - end - end -end - -class RoutingTest < Test::Unit::TestCase - def test_possible_controllers - true_controller_paths = ActionController::Routing.controller_paths - - ActionController::Routing.use_controllers! nil - - silence_warnings do - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + '/controller_fixtures') - end - - ActionController::Routing.controller_paths = [ - RAILS_ROOT, RAILS_ROOT + '/app/controllers', RAILS_ROOT + '/vendor/plugins/bad_plugin/lib' - ] - - assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort - ensure - if true_controller_paths - ActionController::Routing.controller_paths = true_controller_paths - end - ActionController::Routing.use_controllers! nil - Object.send(:remove_const, :RAILS_ROOT) rescue nil - end - - def test_possible_controllers_are_reset_on_each_load - true_possible_controllers = ActionController::Routing.possible_controllers - true_controller_paths = ActionController::Routing.controller_paths - - ActionController::Routing.use_controllers! nil - root = File.dirname(__FILE__) + '/controller_fixtures' - - ActionController::Routing.controller_paths = [] - assert_equal [], ActionController::Routing.possible_controllers - - ActionController::Routing.controller_paths = [ - root, root + '/app/controllers', root + '/vendor/plugins/bad_plugin/lib' - ] - ActionController::Routing::Routes.load! - - assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort - ensure - ActionController::Routing.controller_paths = true_controller_paths - ActionController::Routing.use_controllers! true_possible_controllers - Object.send(:remove_const, :RAILS_ROOT) rescue nil - - ActionController::Routing::Routes.clear! - ActionController::Routing::Routes.load_routes! - end - - def test_with_controllers - c = %w(admin/accounts admin/users account pages) - ActionController::Routing.with_controllers c do - assert_equal c, ActionController::Routing.possible_controllers - end - end - - def test_normalize_unix_paths - load_paths = %w(. config/../app/controllers config/../app//helpers script/../config/../vendor/rails/actionpack/lib vendor/rails/railties/builtin/rails_info app/models lib script/../config/../foo/bar/../../app/models .foo/../.bar foo.bar/../config) - paths = ActionController::Routing.normalize_paths(load_paths) - assert_equal %w(vendor/rails/railties/builtin/rails_info vendor/rails/actionpack/lib app/controllers app/helpers app/models config .bar lib .), paths - end - - def test_normalize_windows_paths - load_paths = %w(. config\\..\\app\\controllers config\\..\\app\\\\helpers script\\..\\config\\..\\vendor\\rails\\actionpack\\lib vendor\\rails\\railties\\builtin\\rails_info app\\models lib script\\..\\config\\..\\foo\\bar\\..\\..\\app\\models .foo\\..\\.bar foo.bar\\..\\config) - paths = ActionController::Routing.normalize_paths(load_paths) - assert_equal %w(vendor\\rails\\railties\\builtin\\rails_info vendor\\rails\\actionpack\\lib app\\controllers app\\helpers app\\models config .bar lib .), paths - end - - def test_routing_helper_module - assert_kind_of Module, ActionController::Routing::Helpers - - h = ActionController::Routing::Helpers - c = Class.new - assert ! c.ancestors.include?(h) - ActionController::Routing::Routes.install_helpers c - assert c.ancestors.include?(h) - end -end - -class MockController - attr_accessor :routes - - def initialize(routes) - self.routes = routes - end - - def url_for(options) - only_path = options.delete(:only_path) - - port = options.delete(:port) || 80 - port_string = port == 80 ? '' : ":#{port}" - - protocol = options.delete(:protocol) || "http" - host = options.delete(:host) || "test.host" - anchor = "##{options.delete(:anchor)}" if options.key?(:anchor) - - path = routes.generate(options) - - only_path ? "#{path}#{anchor}" : "#{protocol}://#{host}#{port_string}#{path}#{anchor}" - end - - def request - @request ||= ActionController::TestRequest.new - end -end - -class LegacyRouteSetTests < ActiveSupport::TestCase - attr_reader :rs - - def setup - # These tests assume optimisation is on, so re-enable it. - ActionController::Base.optimise_named_routes = true - - @rs = ::ActionController::Routing::RouteSet.new - - ActionController::Routing.use_controllers! %w(content admin/user admin/news_feed) - end - - def teardown - @rs.clear! - end - - def test_routes_for_controller_and_action_deprecated - assert_deprecated { @rs.routes_for_controller_and_action("controller", "action") } - end - - def test_default_setup - @rs.draw {|m| m.connect ':controller/:action/:id' } - assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/content")) - assert_equal({:controller => "content", :action => 'list'}, rs.recognize_path("/content/list")) - assert_equal({:controller => "content", :action => 'show', :id => '10'}, rs.recognize_path("/content/show/10")) - - assert_equal({:controller => "admin/user", :action => 'show', :id => '10'}, rs.recognize_path("/admin/user/show/10")) - - assert_equal '/admin/user/show/10', rs.generate(:controller => 'admin/user', :action => 'show', :id => 10) - - assert_equal '/admin/user/show', rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - assert_equal '/admin/user/list/10', rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - - assert_equal '/admin/stuff', rs.generate({:controller => 'stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - assert_equal '/stuff', rs.generate({:controller => '/stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - end - - def test_ignores_leading_slash - @rs.clear! - @rs.draw {|m| m.connect '/:controller/:action/:id'} - test_default_setup - end - - def test_time_recognition - # We create many routes to make situation more realistic - @rs = ::ActionController::Routing::RouteSet.new - @rs.draw { |map| - map.frontpage '', :controller => 'search', :action => 'new' - map.resources :videos do |video| - video.resources :comments - video.resource :file, :controller => 'video_file' - video.resource :share, :controller => 'video_shares' - video.resource :abuse, :controller => 'video_abuses' - end - map.resources :abuses, :controller => 'video_abuses' - map.resources :video_uploads - map.resources :video_visits - - map.resources :users do |user| - user.resource :settings - user.resources :videos - end - map.resources :channels do |channel| - channel.resources :videos, :controller => 'channel_videos' - end - map.resource :session - map.resource :lost_password - map.search 'search', :controller => 'search' - map.resources :pages - map.connect ':controller/:action/:id' - } - n = 1000 - if RunTimeTests - GC.start - rectime = Benchmark.realtime do - n.times do - rs.recognize_path("/videos/1234567", {:method => :get}) - rs.recognize_path("/videos/1234567/abuse", {:method => :get}) - rs.recognize_path("/users/1234567/settings", {:method => :get}) - rs.recognize_path("/channels/1234567", {:method => :get}) - rs.recognize_path("/session/new", {:method => :get}) - rs.recognize_path("/admin/user/show/10", {:method => :get}) - end - end - puts "\n\nRecognition (#{rs.routes.size} routes):" - per_url = rectime / (n * 6) - puts "#{per_url * 1000} ms/url" - puts "#{1 / per_url} url/s\n\n" - end - end - - def test_time_generation - n = 5000 - if RunTimeTests - GC.start - pairs = [ - [{:controller => 'content', :action => 'index'}, {:controller => 'content', :action => 'show'}], - [{:controller => 'content'}, {:controller => 'content', :action => 'index'}], - [{:controller => 'content', :action => 'list'}, {:controller => 'content', :action => 'index'}], - [{:controller => 'content', :action => 'show', :id => '10'}, {:controller => 'content', :action => 'list'}], - [{:controller => 'admin/user', :action => 'index'}, {:controller => 'admin/user', :action => 'show'}], - [{:controller => 'admin/user'}, {:controller => 'admin/user', :action => 'index'}], - [{:controller => 'admin/user', :action => 'list'}, {:controller => 'admin/user', :action => 'index'}], - [{:controller => 'admin/user', :action => 'show', :id => '10'}, {:controller => 'admin/user', :action => 'list'}], - ] - p = nil - gentime = Benchmark.realtime do - n.times do - pairs.each {|(a, b)| rs.generate(a, b)} - end - end - - puts "\n\nGeneration (RouteSet): (#{(n * 8)} urls)" - per_url = gentime / (n * 8) - puts "#{per_url * 1000} ms/url" - puts "#{1 / per_url} url/s\n\n" - end - end - - def test_route_with_colon_first - rs.draw do |map| - map.connect '/:controller/:action/:id', :action => 'index', :id => nil - map.connect ':url', :controller => 'tiny_url', :action => 'translate' - end - end - - def test_route_with_regexp_for_controller - rs.draw do |map| - map.connect ':controller/:admintoken/:action/:id', :controller => /admin\/.+/ - map.connect ':controller/:action/:id' - end - assert_equal({:controller => "admin/user", :admintoken => "foo", :action => "index"}, - rs.recognize_path("/admin/user/foo")) - assert_equal({:controller => "content", :action => "foo"}, rs.recognize_path("/content/foo")) - assert_equal '/admin/user/foo', rs.generate(:controller => "admin/user", :admintoken => "foo", :action => "index") - assert_equal '/content/foo', rs.generate(:controller => "content", :action => "foo") - end - - def test_route_with_regexp_and_captures_for_controller - rs.draw do |map| - map.connect ':controller/:action/:id', :controller => /admin\/(accounts|users)/ - end - assert_equal({:controller => "admin/accounts", :action => "index"}, rs.recognize_path("/admin/accounts")) - assert_equal({:controller => "admin/users", :action => "index"}, rs.recognize_path("/admin/users")) - assert_raise(ActionController::RoutingError) { rs.recognize_path("/admin/products") } - end - - def test_route_with_regexp_and_dot - rs.draw do |map| - map.connect ':controller/:action/:file', - :controller => /admin|user/, - :action => /upload|download/, - :defaults => {:file => nil}, - :requirements => {:file => %r{[^/]+(\.[^/]+)?}} - end - # Without a file extension - assert_equal '/user/download/file', - rs.generate(:controller => "user", :action => "download", :file => "file") - assert_equal( - {:controller => "user", :action => "download", :file => "file"}, - rs.recognize_path("/user/download/file")) - - # Now, let's try a file with an extension, really a dot (.) - assert_equal '/user/download/file.jpg', - rs.generate( - :controller => "user", :action => "download", :file => "file.jpg") - assert_equal( - {:controller => "user", :action => "download", :file => "file.jpg"}, - rs.recognize_path("/user/download/file.jpg")) - end - - def test_basic_named_route - rs.add_named_route :home, '', :controller => 'content', :action => 'list' - x = setup_for_named_route - assert_equal("http://test.host/", - x.send(:home_url)) - end - - def test_basic_named_route_with_relative_url_root - rs.add_named_route :home, '', :controller => 'content', :action => 'list' - x = setup_for_named_route - ActionController::Base.relative_url_root = "/foo" - assert_equal("http://test.host/foo/", - x.send(:home_url)) - assert_equal "/foo/", x.send(:home_path) - ActionController::Base.relative_url_root = nil - end - - def test_named_route_with_option - rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page' - x = setup_for_named_route - assert_equal("http://test.host/page/new%20stuff", - x.send(:page_url, :title => 'new stuff')) - end - - def test_named_route_with_default - rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage' - x = setup_for_named_route - assert_equal("http://test.host/page/AboutRails", - x.send(:page_url, :title => "AboutRails")) - - end - - def test_named_route_with_name_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_' - x = setup_for_named_route - assert_equal("http://test.host/page", - x.send(:my_page_url)) - end - - def test_named_route_with_path_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my' - x = setup_for_named_route - assert_equal("http://test.host/my/page", - x.send(:page_url)) - end - - def test_named_route_with_blank_path_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => '' - x = setup_for_named_route - assert_equal("http://test.host/page", - x.send(:page_url)) - end - - def test_named_route_with_nested_controller - rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index' - x = setup_for_named_route - assert_equal("http://test.host/admin/user", - x.send(:users_url)) - end - - def test_optimised_named_route_call_never_uses_url_for - rs.add_named_route :users, 'admin/user', :controller => '/admin/user', :action => 'index' - rs.add_named_route :user, 'admin/user/:id', :controller=>'/admin/user', :action=>'show' - x = setup_for_named_route - x.expects(:url_for).never - x.send(:users_url) - x.send(:users_path) - x.send(:user_url, 2, :foo=>"bar") - x.send(:user_path, 3, :bar=>"foo") - end - - def test_optimised_named_route_with_host - rs.add_named_route :pages, 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com' - x = setup_for_named_route - x.expects(:url_for).with(:host => 'foo.com', :only_path => false, :controller => 'content', :action => 'show_page', :use_route => :pages).once - x.send(:pages_url) - end - - def setup_for_named_route - klass = Class.new(MockController) - rs.install_helpers(klass) - klass.new(rs) - end - - def test_named_route_without_hash - rs.draw do |map| - map.normal ':controller/:action/:id' - end - end - - def test_named_route_root - rs.draw do |map| - map.root :controller => "hello" - end - x = setup_for_named_route - assert_equal("http://test.host/", x.send(:root_url)) - assert_equal("/", x.send(:root_path)) - end - - def test_named_route_with_regexps - rs.draw do |map| - map.article 'page/:year/:month/:day/:title', :controller => 'page', :action => 'show', - :year => /\d+/, :month => /\d+/, :day => /\d+/ - map.connect ':controller/:action/:id' - end - x = setup_for_named_route - # assert_equal( - # {:controller => 'page', :action => 'show', :title => 'hi', :use_route => :article, :only_path => false}, - # x.send(:article_url, :title => 'hi') - # ) - assert_equal( - "http://test.host/page/2005/6/10/hi", - x.send(:article_url, :title => 'hi', :day => 10, :year => 2005, :month => 6) - ) - end - - def test_changing_controller - @rs.draw {|m| m.connect ':controller/:action/:id' } - - assert_equal '/admin/stuff/show/10', rs.generate( - {:controller => 'stuff', :action => 'show', :id => 10}, - {:controller => 'admin/user', :action => 'index'} - ) - end - - def test_paths_escaped - rs.draw do |map| - map.path 'file/*path', :controller => 'content', :action => 'show_file' - map.connect ':controller/:action/:id' - end - - # No + to space in URI escaping, only for query params. - results = rs.recognize_path "/file/hello+world/how+are+you%3F" - assert results, "Recognition should have succeeded" - assert_equal ['hello+world', 'how+are+you?'], results[:path] - - # Use %20 for space instead. - results = rs.recognize_path "/file/hello%20world/how%20are%20you%3F" - assert results, "Recognition should have succeeded" - assert_equal ['hello world', 'how are you?'], results[:path] - - results = rs.recognize_path "/file" - assert results, "Recognition should have succeeded" - assert_equal [], results[:path] - end - - def test_paths_slashes_unescaped_with_ordered_parameters - rs.add_named_route :path, '/file/*path', :controller => 'content' - - # No / to %2F in URI, only for query params. - x = setup_for_named_route - assert_equal("/file/hello/world", x.send(:path_path, 'hello/world')) - end - - def test_non_controllers_cannot_be_matched - rs.draw do |map| - map.connect ':controller/:action/:id' - end - assert_raise(ActionController::RoutingError) { rs.recognize_path("/not_a/show/10") } - end - - def test_paths_do_not_accept_defaults - assert_raise(ActionController::RoutingError) do - rs.draw do |map| - map.path 'file/*path', :controller => 'content', :action => 'show_file', :path => %w(fake default) - map.connect ':controller/:action/:id' - end - end - - rs.draw do |map| - map.path 'file/*path', :controller => 'content', :action => 'show_file', :path => [] - map.connect ':controller/:action/:id' - end - end - - def test_should_list_options_diff_when_routing_requirements_dont_match - rs.draw do |map| - map.post 'post/:id', :controller=> 'post', :action=> 'show', :requirements => {:id => /\d+/} - end - exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'post', :action => 'show', :bad_param => "foo", :use_route => "post") } - assert_match(/^post_url failed to generate/, exception.message) - from_match = exception.message.match(/from \{[^\}]+\}/).to_s - assert_match(/:bad_param=>"foo"/, from_match) - assert_match(/:action=>"show"/, from_match) - assert_match(/:controller=>"post"/, from_match) - - expected_match = exception.message.match(/expected: \{[^\}]+\}/).to_s - assert_no_match(/:bad_param=>"foo"/, expected_match) - assert_match( /:action=>"show"/, expected_match) - assert_match( /:controller=>"post"/, expected_match) - - diff_match = exception.message.match(/diff: \{[^\}]+\}/).to_s - assert_match( /:bad_param=>"foo"/, diff_match) - assert_no_match(/:action=>"show"/, diff_match) - assert_no_match(/:controller=>"post"/, diff_match) - end - - # this specifies the case where your formerly would get a very confusing error message with an empty diff - def test_should_have_better_error_message_when_options_diff_is_empty - rs.draw do |map| - map.content '/content/:query', :controller => 'content', :action => 'show' - end - - exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'content', :action => 'show', :use_route => "content") } - assert_match %r[:action=>"show"], exception.message - assert_match %r[:controller=>"content"], exception.message - assert_match %r[you may have ambiguous routes, or you may need to supply additional parameters for this route], exception.message - assert_match %r[content_url has the following required parameters: \["content", :query\] - are they all satisfied?], exception.message - end - - def test_dynamic_path_allowed - rs.draw do |map| - map.connect '*path', :controller => 'content', :action => 'show_file' - end - - assert_equal '/pages/boo', rs.generate(:controller => 'content', :action => 'show_file', :path => %w(pages boo)) - end - - def test_dynamic_recall_paths_allowed - rs.draw do |map| - map.connect '*path', :controller => 'content', :action => 'show_file' - end - - recall_path = ActionController::Routing::PathSegment::Result.new(%w(pages boo)) - assert_equal '/pages/boo', rs.generate({}, :controller => 'content', :action => 'show_file', :path => recall_path) - end - - def test_backwards - rs.draw do |map| - map.connect 'page/:id/:action', :controller => 'pages', :action => 'show' - map.connect ':controller/:action/:id' - end - - assert_equal '/page/20', rs.generate({:id => 20}, {:controller => 'pages', :action => 'show'}) - assert_equal '/page/20', rs.generate(:controller => 'pages', :id => 20, :action => 'show') - assert_equal '/pages/boo', rs.generate(:controller => 'pages', :action => 'boo') - end - - def test_route_with_fixnum_default - rs.draw do |map| - map.connect 'page/:id', :controller => 'content', :action => 'show_page', :id => 1 - map.connect ':controller/:action/:id' - end - - assert_equal '/page', rs.generate(:controller => 'content', :action => 'show_page') - assert_equal '/page', rs.generate(:controller => 'content', :action => 'show_page', :id => 1) - assert_equal '/page', rs.generate(:controller => 'content', :action => 'show_page', :id => '1') - assert_equal '/page/10', rs.generate(:controller => 'content', :action => 'show_page', :id => 10) - - assert_equal({:controller => "content", :action => 'show_page', :id => '1'}, rs.recognize_path("/page")) - assert_equal({:controller => "content", :action => 'show_page', :id => '1'}, rs.recognize_path("/page/1")) - assert_equal({:controller => "content", :action => 'show_page', :id => '10'}, rs.recognize_path("/page/10")) - end - - # For newer revision - def test_route_with_text_default - rs.draw do |map| - map.connect 'page/:id', :controller => 'content', :action => 'show_page', :id => 1 - map.connect ':controller/:action/:id' - end - - assert_equal '/page/foo', rs.generate(:controller => 'content', :action => 'show_page', :id => 'foo') - assert_equal({:controller => "content", :action => 'show_page', :id => 'foo'}, rs.recognize_path("/page/foo")) - - token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in russian - token.force_encoding("UTF-8") if token.respond_to?(:force_encoding) - escaped_token = CGI::escape(token) - - assert_equal '/page/' + escaped_token, rs.generate(:controller => 'content', :action => 'show_page', :id => token) - assert_equal({:controller => "content", :action => 'show_page', :id => token}, rs.recognize_path("/page/#{escaped_token}")) - end - - def test_action_expiry - @rs.draw {|m| m.connect ':controller/:action/:id' } - assert_equal '/content', rs.generate({:controller => 'content'}, {:controller => 'content', :action => 'show'}) - end - - def test_recognition_with_uppercase_controller_name - @rs.draw {|m| m.connect ':controller/:action/:id' } - assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/Content")) - assert_equal({:controller => "content", :action => 'list'}, rs.recognize_path("/ConTent/list")) - assert_equal({:controller => "content", :action => 'show', :id => '10'}, rs.recognize_path("/CONTENT/show/10")) - - # these used to work, before the routes rewrite, but support for this was pulled in the new version... - #assert_equal({'controller' => "admin/news_feed", 'action' => 'index'}, rs.recognize_path("Admin/NewsFeed")) - #assert_equal({'controller' => "admin/news_feed", 'action' => 'index'}, rs.recognize_path("Admin/News_Feed")) - end - - def test_requirement_should_prevent_optional_id - rs.draw do |map| - map.post 'post/:id', :controller=> 'post', :action=> 'show', :requirements => {:id => /\d+/} - end - - assert_equal '/post/10', rs.generate(:controller => 'post', :action => 'show', :id => 10) - - assert_raise ActionController::RoutingError do - rs.generate(:controller => 'post', :action => 'show') - end - end - - def test_both_requirement_and_optional - rs.draw do |map| - map.blog('test/:year', :controller => 'post', :action => 'show', - :defaults => { :year => nil }, - :requirements => { :year => /\d{4}/ } - ) - map.connect ':controller/:action/:id' - end - - assert_equal '/test', rs.generate(:controller => 'post', :action => 'show') - assert_equal '/test', rs.generate(:controller => 'post', :action => 'show', :year => nil) - - x = setup_for_named_route - assert_equal("http://test.host/test", - x.send(:blog_url)) - end - - def test_set_to_nil_forgets - rs.draw do |map| - map.connect 'pages/:year/:month/:day', :controller => 'content', :action => 'list_pages', :month => nil, :day => nil - map.connect ':controller/:action/:id' - end - - assert_equal '/pages/2005', - rs.generate(:controller => 'content', :action => 'list_pages', :year => 2005) - assert_equal '/pages/2005/6', - rs.generate(:controller => 'content', :action => 'list_pages', :year => 2005, :month => 6) - assert_equal '/pages/2005/6/12', - rs.generate(:controller => 'content', :action => 'list_pages', :year => 2005, :month => 6, :day => 12) - - assert_equal '/pages/2005/6/4', - rs.generate({:day => 4}, {:controller => 'content', :action => 'list_pages', :year => '2005', :month => '6', :day => '12'}) - - assert_equal '/pages/2005/6', - rs.generate({:day => nil}, {:controller => 'content', :action => 'list_pages', :year => '2005', :month => '6', :day => '12'}) - - assert_equal '/pages/2005', - rs.generate({:day => nil, :month => nil}, {:controller => 'content', :action => 'list_pages', :year => '2005', :month => '6', :day => '12'}) - end - - def test_url_with_no_action_specified - rs.draw do |map| - map.connect '', :controller => 'content' - map.connect ':controller/:action/:id' - end - - assert_equal '/', rs.generate(:controller => 'content', :action => 'index') - assert_equal '/', rs.generate(:controller => 'content') - end - - def test_named_url_with_no_action_specified - rs.draw do |map| - map.home '', :controller => 'content' - map.connect ':controller/:action/:id' - end - - assert_equal '/', rs.generate(:controller => 'content', :action => 'index') - assert_equal '/', rs.generate(:controller => 'content') - - x = setup_for_named_route - assert_equal("http://test.host/", - x.send(:home_url)) - end - - def test_url_generated_when_forgetting_action - [{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash| - rs.draw do |map| - map.home '', hash - map.connect ':controller/:action/:id' - end - assert_equal '/', rs.generate({:action => nil}, {:controller => 'content', :action => 'hello'}) - assert_equal '/', rs.generate({:controller => 'content'}) - assert_equal '/content/hi', rs.generate({:controller => 'content', :action => 'hi'}) - end - end - - def test_named_route_method - rs.draw do |map| - map.categories 'categories', :controller => 'content', :action => 'categories' - map.connect ':controller/:action/:id' - end - - assert_equal '/categories', rs.generate(:controller => 'content', :action => 'categories') - assert_equal '/content/hi', rs.generate({:controller => 'content', :action => 'hi'}) - end - - def test_named_routes_array - test_named_route_method - assert_equal [:categories], rs.named_routes.names - end - - def test_nil_defaults - rs.draw do |map| - map.connect 'journal', - :controller => 'content', - :action => 'list_journal', - :date => nil, :user_id => nil - map.connect ':controller/:action/:id' - end - - assert_equal '/journal', rs.generate(:controller => 'content', :action => 'list_journal', :date => nil, :user_id => nil) - end - - def setup_request_method_routes_for(method) - @request = ActionController::TestRequest.new - @request.env["REQUEST_METHOD"] = method - @request.request_uri = "/match" - - rs.draw do |r| - r.connect '/match', :controller => 'books', :action => 'get', :conditions => { :method => :get } - r.connect '/match', :controller => 'books', :action => 'post', :conditions => { :method => :post } - r.connect '/match', :controller => 'books', :action => 'put', :conditions => { :method => :put } - r.connect '/match', :controller => 'books', :action => 'delete', :conditions => { :method => :delete } - end - end - - %w(GET POST PUT DELETE).each do |request_method| - define_method("test_request_method_recognized_with_#{request_method}") do - begin - Object.const_set(:BooksController, Class.new(ActionController::Base)) - - setup_request_method_routes_for(request_method) - - assert_nothing_raised { rs.recognize(@request) } - assert_equal request_method.downcase, @request.path_parameters[:action] - ensure - Object.send(:remove_const, :BooksController) rescue nil - end - end - end - - def test_recognize_array_of_methods - Object.const_set(:BooksController, Class.new(ActionController::Base)) - rs.draw do |r| - r.connect '/match', :controller => 'books', :action => 'get_or_post', :conditions => { :method => [:get, :post] } - r.connect '/match', :controller => 'books', :action => 'not_get_or_post' - end - - @request = ActionController::TestRequest.new - @request.env["REQUEST_METHOD"] = 'POST' - @request.request_uri = "/match" - assert_nothing_raised { rs.recognize(@request) } - assert_equal 'get_or_post', @request.path_parameters[:action] - - # have to recreate or else the RouteSet uses a cached version: - @request = ActionController::TestRequest.new - @request.env["REQUEST_METHOD"] = 'PUT' - @request.request_uri = "/match" - assert_nothing_raised { rs.recognize(@request) } - assert_equal 'not_get_or_post', @request.path_parameters[:action] - ensure - Object.send(:remove_const, :BooksController) rescue nil - end - - def test_subpath_recognized - Object.const_set(:SubpathBooksController, Class.new(ActionController::Base)) - - rs.draw do |r| - r.connect '/books/:id/edit', :controller => 'subpath_books', :action => 'edit' - r.connect '/items/:id/:action', :controller => 'subpath_books' - r.connect '/posts/new/:action', :controller => 'subpath_books' - r.connect '/posts/:id', :controller => 'subpath_books', :action => "show" - end - - hash = rs.recognize_path "/books/17/edit" - assert_not_nil hash - assert_equal %w(subpath_books 17 edit), [hash[:controller], hash[:id], hash[:action]] - - hash = rs.recognize_path "/items/3/complete" - assert_not_nil hash - assert_equal %w(subpath_books 3 complete), [hash[:controller], hash[:id], hash[:action]] - - hash = rs.recognize_path "/posts/new/preview" - assert_not_nil hash - assert_equal %w(subpath_books preview), [hash[:controller], hash[:action]] - - hash = rs.recognize_path "/posts/7" - assert_not_nil hash - assert_equal %w(subpath_books show 7), [hash[:controller], hash[:action], hash[:id]] - ensure - Object.send(:remove_const, :SubpathBooksController) rescue nil - end - - def test_subpath_generated - Object.const_set(:SubpathBooksController, Class.new(ActionController::Base)) - - rs.draw do |r| - r.connect '/books/:id/edit', :controller => 'subpath_books', :action => 'edit' - r.connect '/items/:id/:action', :controller => 'subpath_books' - r.connect '/posts/new/:action', :controller => 'subpath_books' - end - - assert_equal "/books/7/edit", rs.generate(:controller => "subpath_books", :id => 7, :action => "edit") - assert_equal "/items/15/complete", rs.generate(:controller => "subpath_books", :id => 15, :action => "complete") - assert_equal "/posts/new/preview", rs.generate(:controller => "subpath_books", :action => "preview") - ensure - Object.send(:remove_const, :SubpathBooksController) rescue nil - end - - def test_failed_requirements_raises_exception_with_violated_requirements - rs.draw do |r| - r.foo_with_requirement 'foos/:id', :controller=>'foos', :requirements=>{:id=>/\d+/} - end - - x = setup_for_named_route - assert_raise(ActionController::RoutingError) do - x.send(:foo_with_requirement_url, "I am Against the requirements") - end - end - - def test_routes_changed_correctly_after_clear - ActionController::Base.optimise_named_routes = true - rs = ::ActionController::Routing::RouteSet.new - rs.draw do |r| - r.connect 'ca', :controller => 'ca', :action => "aa" - r.connect 'cb', :controller => 'cb', :action => "ab" - r.connect 'cc', :controller => 'cc', :action => "ac" - r.connect ':controller/:action/:id' - r.connect ':controller/:action/:id.:format' - end - - hash = rs.recognize_path "/cc" - - assert_not_nil hash - assert_equal %w(cc ac), [hash[:controller], hash[:action]] - - rs.draw do |r| - r.connect 'cb', :controller => 'cb', :action => "ab" - r.connect 'cc', :controller => 'cc', :action => "ac" - r.connect ':controller/:action/:id' - r.connect ':controller/:action/:id.:format' - end - - hash = rs.recognize_path "/cc" - - assert_not_nil hash - assert_equal %w(cc ac), [hash[:controller], hash[:action]] - - end -end - -class RouteTest < Test::Unit::TestCase - def setup - @route = ROUTING::Route.new - end - - def slash_segment(is_optional = false) - ROUTING::DividerSegment.new('/', :optional => is_optional) - end - - def default_route - unless defined?(@default_route) - segments = [] - segments << ROUTING::StaticSegment.new('/', :raw => true) - segments << ROUTING::DynamicSegment.new(:controller) - segments << slash_segment(:optional) - segments << ROUTING::DynamicSegment.new(:action, :default => 'index', :optional => true) - segments << slash_segment(:optional) - segments << ROUTING::DynamicSegment.new(:id, :optional => true) - segments << slash_segment(:optional) - @default_route = ROUTING::Route.new(segments).freeze - end - @default_route - end - - def test_default_route_recognition - expected = {:controller => 'accounts', :action => 'show', :id => '10'} - assert_equal expected, default_route.recognize('/accounts/show/10') - assert_equal expected, default_route.recognize('/accounts/show/10/') - - expected[:id] = 'jamis' - assert_equal expected, default_route.recognize('/accounts/show/jamis/') - - expected.delete :id - assert_equal expected, default_route.recognize('/accounts/show') - assert_equal expected, default_route.recognize('/accounts/show/') - - expected[:action] = 'index' - assert_equal expected, default_route.recognize('/accounts/') - assert_equal expected, default_route.recognize('/accounts') - - assert_equal nil, default_route.recognize('/') - assert_equal nil, default_route.recognize('/accounts/how/goood/it/is/to/be/free') - end - - def test_default_route_should_omit_default_action - o = {:controller => 'accounts', :action => 'index'} - assert_equal '/accounts', default_route.generate(o, o, {}) - end - - def test_default_route_should_include_default_action_when_id_present - o = {:controller => 'accounts', :action => 'index', :id => '20'} - assert_equal '/accounts/index/20', default_route.generate(o, o, {}) - end - - def test_default_route_should_work_with_action_but_no_id - o = {:controller => 'accounts', :action => 'list_all'} - assert_equal '/accounts/list_all', default_route.generate(o, o, {}) - end - - def test_default_route_should_uri_escape_pluses - expected = { :controller => 'accounts', :action => 'show', :id => 'hello world' } - assert_equal expected, default_route.recognize('/accounts/show/hello world') - assert_equal expected, default_route.recognize('/accounts/show/hello%20world') - assert_equal '/accounts/show/hello%20world', default_route.generate(expected, expected, {}) - - expected[:id] = 'hello+world' - assert_equal expected, default_route.recognize('/accounts/show/hello+world') - assert_equal expected, default_route.recognize('/accounts/show/hello%2Bworld') - assert_equal '/accounts/show/hello+world', default_route.generate(expected, expected, {}) - end - - def test_matches_controller_and_action - # requirement_for should only be called for the action and controller _once_ - @route.expects(:requirement_for).with(:controller).times(1).returns('pages') - @route.expects(:requirement_for).with(:action).times(1).returns('show') - - @route.requirements = {:controller => 'pages', :action => 'show'} - assert @route.matches_controller_and_action?('pages', 'show') - assert !@route.matches_controller_and_action?('not_pages', 'show') - assert !@route.matches_controller_and_action?('pages', 'not_show') - end - - def test_parameter_shell - page_url = ROUTING::Route.new - page_url.requirements = {:controller => 'pages', :action => 'show', :id => /\d+/} - assert_equal({:controller => 'pages', :action => 'show'}, page_url.parameter_shell) - end - - def test_defaults - route = ROUTING::RouteBuilder.new.build '/users/:id.:format', :controller => "users", :action => "show", :format => "html" - assert_equal( - { :controller => "users", :action => "show", :format => "html" }, - route.defaults) - end - - def test_builder_complains_without_controller - assert_raise(ArgumentError) do - ROUTING::RouteBuilder.new.build '/contact', :contoller => "contact", :action => "index" - end - end - - def test_significant_keys_for_default_route - keys = default_route.significant_keys.sort_by {|k| k.to_s } - assert_equal [:action, :controller, :id], keys - end - - def test_significant_keys - segments = [] - segments << ROUTING::StaticSegment.new('/', :raw => true) - segments << ROUTING::StaticSegment.new('user') - segments << ROUTING::StaticSegment.new('/', :raw => true, :optional => true) - segments << ROUTING::DynamicSegment.new(:user) - segments << ROUTING::StaticSegment.new('/', :raw => true, :optional => true) - - requirements = {:controller => 'users', :action => 'show'} - - user_url = ROUTING::Route.new(segments, requirements) - keys = user_url.significant_keys.sort_by { |k| k.to_s } - assert_equal [:action, :controller, :user], keys - end - - def test_build_empty_query_string - assert_equal '', @route.build_query_string({}) - end - - def test_build_query_string_with_nil_value - assert_equal '', @route.build_query_string({:x => nil}) - end - - def test_simple_build_query_string - assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => '1', :y => '2')) - end - - def test_convert_ints_build_query_string - assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => 1, :y => 2)) - end - - def test_escape_spaces_build_query_string - assert_equal '?x=hello+world&y=goodbye+world', order_query_string(@route.build_query_string(:x => 'hello world', :y => 'goodbye world')) - end - - def test_expand_array_build_query_string - assert_equal '?x%5B%5D=1&x%5B%5D=2', order_query_string(@route.build_query_string(:x => [1, 2])) - end - - def test_escape_spaces_build_query_string_selected_keys - assert_equal '?x=hello+world', order_query_string(@route.build_query_string({:x => 'hello world', :y => 'goodbye world'}, [:x])) - end - - private - def order_query_string(qs) - '?' + qs[1..-1].split('&').sort.join('&') - end -end - -class RouteSetTest < ActiveSupport::TestCase - def set - @set ||= ROUTING::RouteSet.new - end - - def request - @request ||= ActionController::TestRequest.new - end - - def test_generate_extras - set.draw { |m| m.connect ':controller/:action/:id' } - path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal "/foo/bar/15", path - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_extra_keys - set.draw { |m| m.connect ':controller/:action/:id' } - extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_generate_extras_not_first - set.draw do |map| - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' - end - path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal "/foo/bar/15", path - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_generate_not_first - set.draw do |map| - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' - end - assert_equal "/foo/bar/15?this=hello", set.generate(:controller => "foo", :action => "bar", :id => 15, :this => "hello") - end - - def test_extra_keys_not_first - set.draw do |map| - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' - end - extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_draw - assert_equal 0, set.routes.size - set.draw do |map| - map.connect '/hello/world', :controller => 'a', :action => 'b' - end - assert_equal 1, set.routes.size - end - - def test_draw_symbol_controller_name - assert_equal 0, set.routes.size - set.draw do |map| - map.connect '/users/index', :controller => :users, :action => :index - end - @request = ActionController::TestRequest.new - @request.request_uri = '/users/index' - assert_nothing_raised { set.recognize(@request) } - assert_equal 1, set.routes.size - end - - def test_named_draw - assert_equal 0, set.routes.size - set.draw do |map| - map.hello '/hello/world', :controller => 'a', :action => 'b' - end - assert_equal 1, set.routes.size - assert_equal set.routes.first, set.named_routes[:hello] - end - - def test_later_named_routes_take_precedence - set.draw do |map| - map.hello '/hello/world', :controller => 'a', :action => 'b' - map.hello '/hello', :controller => 'a', :action => 'b' - end - assert_equal set.routes.last, set.named_routes[:hello] - end - - def setup_named_route_test - set.draw do |map| - map.show '/people/:id', :controller => 'people', :action => 'show' - map.index '/people', :controller => 'people', :action => 'index' - map.multi '/people/go/:foo/:bar/joe/:id', :controller => 'people', :action => 'multi' - map.users '/admin/users', :controller => 'admin/users', :action => 'index' - end - - klass = Class.new(MockController) - set.install_helpers(klass) - klass.new(set) - end - - def test_named_route_hash_access_method - controller = setup_named_route_test - - assert_equal( - { :controller => 'people', :action => 'show', :id => 5, :use_route => :show, :only_path => false }, - controller.send(:hash_for_show_url, :id => 5)) - - assert_equal( - { :controller => 'people', :action => 'index', :use_route => :index, :only_path => false }, - controller.send(:hash_for_index_url)) - - assert_equal( - { :controller => 'people', :action => 'show', :id => 5, :use_route => :show, :only_path => true }, - controller.send(:hash_for_show_path, :id => 5) - ) - end - - def test_named_route_url_method - controller = setup_named_route_test - - assert_equal "http://test.host/people/5", controller.send(:show_url, :id => 5) - assert_equal "/people/5", controller.send(:show_path, :id => 5) - - assert_equal "http://test.host/people", controller.send(:index_url) - assert_equal "/people", controller.send(:index_path) - - assert_equal "http://test.host/admin/users", controller.send(:users_url) - assert_equal '/admin/users', controller.send(:users_path) - assert_equal '/admin/users', set.generate(controller.send(:hash_for_users_url), {:controller => 'users', :action => 'index'}) - end - - def test_named_route_url_method_with_anchor - controller = setup_named_route_test - - assert_equal "http://test.host/people/5#location", controller.send(:show_url, :id => 5, :anchor => 'location') - assert_equal "/people/5#location", controller.send(:show_path, :id => 5, :anchor => 'location') - - assert_equal "http://test.host/people#location", controller.send(:index_url, :anchor => 'location') - assert_equal "/people#location", controller.send(:index_path, :anchor => 'location') - - assert_equal "http://test.host/admin/users#location", controller.send(:users_url, :anchor => 'location') - assert_equal '/admin/users#location', controller.send(:users_path, :anchor => 'location') - - assert_equal "http://test.host/people/go/7/hello/joe/5#location", - controller.send(:multi_url, 7, "hello", 5, :anchor => 'location') - - assert_equal "http://test.host/people/go/7/hello/joe/5?baz=bar#location", - controller.send(:multi_url, 7, "hello", 5, :baz => "bar", :anchor => 'location') - - assert_equal "http://test.host/people?baz=bar#location", - controller.send(:index_url, :baz => "bar", :anchor => 'location') - end - - def test_named_route_url_method_with_port - controller = setup_named_route_test - assert_equal "http://test.host:8080/people/5", controller.send(:show_url, 5, :port=>8080) - end - - def test_named_route_url_method_with_host - controller = setup_named_route_test - assert_equal "http://some.example.com/people/5", controller.send(:show_url, 5, :host=>"some.example.com") - end - - def test_named_route_url_method_with_protocol - controller = setup_named_route_test - assert_equal "https://test.host/people/5", controller.send(:show_url, 5, :protocol => "https") - end - - def test_named_route_url_method_with_ordered_parameters - controller = setup_named_route_test - assert_equal "http://test.host/people/go/7/hello/joe/5", - controller.send(:multi_url, 7, "hello", 5) - end - - def test_named_route_url_method_with_ordered_parameters_and_hash - controller = setup_named_route_test - assert_equal "http://test.host/people/go/7/hello/joe/5?baz=bar", - controller.send(:multi_url, 7, "hello", 5, :baz => "bar") - end - - def test_named_route_url_method_with_ordered_parameters_and_empty_hash - controller = setup_named_route_test - assert_equal "http://test.host/people/go/7/hello/joe/5", - controller.send(:multi_url, 7, "hello", 5, {}) - end - - def test_named_route_url_method_with_no_positional_arguments - controller = setup_named_route_test - assert_equal "http://test.host/people?baz=bar", - controller.send(:index_url, :baz => "bar") - end - - def test_draw_default_route - ActionController::Routing.with_controllers(['users']) do - set.draw do |map| - map.connect '/:controller/:action/:id' - end - - assert_equal 1, set.routes.size - route = set.routes.first - - assert route.segments.last.optional? - - assert_equal '/users/show/10', set.generate(:controller => 'users', :action => 'show', :id => 10) - assert_equal '/users/index/10', set.generate(:controller => 'users', :id => 10) - - assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10')) - assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10/')) - end - end - - def test_draw_default_route_with_default_controller - ActionController::Routing.with_controllers(['users']) do - set.draw do |map| - map.connect '/:controller/:action/:id', :controller => 'users' - end - assert_equal({:controller => 'users', :action => 'index'}, set.recognize_path('/')) - end - end - - def test_route_with_parameter_shell - ActionController::Routing.with_controllers(['users', 'pages']) do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/ - map.connect '/:controller/:action/:id' - end - - assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages')) - assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages/index')) - assert_equal({:controller => 'pages', :action => 'list'}, set.recognize_path('/pages/list')) - - assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/pages/show/10')) - assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) - end - end - - def test_route_requirements_with_anchor_chars_are_invalid - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /^\d+/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\A\d+/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+$/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+\Z/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+\z/ - end - end - assert_nothing_raised do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/, :name => /^(david|jamis)/ - end - assert_raise ActionController::RoutingError do - set.generate :controller => 'pages', :action => 'show', :id => 10 - end - end - end - - def test_route_requirements_with_invalid_http_method_is_invalid - assert_raise ArgumentError do - set.draw do |map| - map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :invalid} - end - end - end - - def test_route_requirements_with_options_method_condition_is_valid - assert_nothing_raised do - set.draw do |map| - map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :options} - end - end - end - - def test_route_requirements_with_head_method_condition_is_invalid - assert_raise ArgumentError do - set.draw do |map| - map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :head} - end - end - end - - def test_non_path_route_requirements_match_all - set.draw do |map| - map.connect 'page/37s', :controller => 'pages', :action => 'show', :name => /(jamis|david)/ - end - assert_equal '/page/37s', set.generate(:controller => 'pages', :action => 'show', :name => 'jamis') - assert_raise ActionController::RoutingError do - set.generate(:controller => 'pages', :action => 'show', :name => 'not_jamis') - end - assert_raise ActionController::RoutingError do - set.generate(:controller => 'pages', :action => 'show', :name => 'nor_jamis_and_david') - end - end - - def test_recognize_with_encoded_id_and_regex - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /[a-zA-Z0-9\+]+/ - end - - assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) - assert_equal({:controller => 'pages', :action => 'show', :id => 'hello+world'}, set.recognize_path('/page/hello+world')) - end - - def test_recognize_with_conditions - Object.const_set(:PeopleController, Class.new) - - set.draw do |map| - map.with_options(:controller => "people") do |people| - people.people "/people", :action => "index", :conditions => { :method => :get } - people.connect "/people", :action => "create", :conditions => { :method => :post } - people.person "/people/:id", :action => "show", :conditions => { :method => :get } - people.connect "/people/:id", :action => "update", :conditions => { :method => :put } - people.connect "/people/:id", :action => "destroy", :conditions => { :method => :delete } - end - end - - request.path = "/people" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("index", request.path_parameters[:action]) - request.recycle! - - request.env["REQUEST_METHOD"] = "POST" - assert_nothing_raised { set.recognize(request) } - assert_equal("create", request.path_parameters[:action]) - request.recycle! - - request.env["REQUEST_METHOD"] = "PUT" - assert_nothing_raised { set.recognize(request) } - assert_equal("update", request.path_parameters[:action]) - request.recycle! - - assert_raise(ActionController::UnknownHttpMethod) { - request.env["REQUEST_METHOD"] = "BACON" - set.recognize(request) - } - request.recycle! - - request.path = "/people/5" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("show", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - request.env["REQUEST_METHOD"] = "PUT" - assert_nothing_raised { set.recognize(request) } - assert_equal("update", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - request.env["REQUEST_METHOD"] = "DELETE" - assert_nothing_raised { set.recognize(request) } - assert_equal("destroy", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - begin - request.env["REQUEST_METHOD"] = "POST" - set.recognize(request) - flunk 'Should have raised MethodNotAllowed' - rescue ActionController::MethodNotAllowed => e - assert_equal [:get, :put, :delete], e.allowed_methods - end - request.recycle! - - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_recognize_with_alias_in_conditions - Object.const_set(:PeopleController, Class.new) - - set.draw do |map| - map.people "/people", :controller => 'people', :action => "index", - :conditions => { :method => :get } - map.root :people - end - - request.path = "/people" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("people", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - - request.path = "/" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("people", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_typo_recognition - Object.const_set(:ArticlesController, Class.new) - - set.draw do |map| - map.connect 'articles/:year/:month/:day/:title', - :controller => 'articles', :action => 'permalink', - :year => /\d{4}/, :day => /\d{1,2}/, :month => /\d{1,2}/ - end - - request.path = "/articles/2005/11/05/a-very-interesting-article" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("permalink", request.path_parameters[:action]) - assert_equal("2005", request.path_parameters[:year]) - assert_equal("11", request.path_parameters[:month]) - assert_equal("05", request.path_parameters[:day]) - assert_equal("a-very-interesting-article", request.path_parameters[:title]) - - ensure - Object.send(:remove_const, :ArticlesController) - end - - def test_routing_traversal_does_not_load_extra_classes - assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" - set.draw do |map| - map.connect '/profile', :controller => 'profile' - end - - request.path = '/profile' - - set.recognize(request) rescue nil - - assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" - end - - def test_recognize_with_conditions_and_format - Object.const_set(:PeopleController, Class.new) - - set.draw do |map| - map.with_options(:controller => "people") do |people| - people.person "/people/:id", :action => "show", :conditions => { :method => :get } - people.connect "/people/:id", :action => "update", :conditions => { :method => :put } - people.connect "/people/:id.:_format", :action => "show", :conditions => { :method => :get } - end - end - - request.path = "/people/5" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("show", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - request.env["REQUEST_METHOD"] = "PUT" - assert_nothing_raised { set.recognize(request) } - assert_equal("update", request.path_parameters[:action]) - request.recycle! - - request.path = "/people/5.png" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("show", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - assert_equal("png", request.path_parameters[:_format]) - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_generate_with_default_action - set.draw do |map| - map.connect "/people", :controller => "people" - map.connect "/people/list", :controller => "people", :action => "list" - end - - url = set.generate(:controller => "people", :action => "list") - assert_equal "/people/list", url - end - - def test_root_map - Object.const_set(:PeopleController, Class.new) - - set.draw { |map| map.root :controller => "people" } - - request.path = "" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("people", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_namespace - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - - map.namespace 'api' do |api| - api.route 'inventory', :controller => "products", :action => 'inventory' - end - - end - - request.path = "/api/inventory" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("inventory", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_namespaced_root_map - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - - map.namespace 'api' do |api| - api.root :controller => "products" - end - - end - - request.path = "/api" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_namespace_with_path_prefix - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - map.namespace 'api', :path_prefix => 'prefix' do |api| - api.route 'inventory', :controller => "products", :action => 'inventory' - end - end - - request.path = "/prefix/inventory" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("inventory", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_namespace_with_blank_path_prefix - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - map.namespace 'api', :path_prefix => '' do |api| - api.route 'inventory', :controller => "products", :action => 'inventory' - end - end - - request.path = "/inventory" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("inventory", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_generate_finds_best_fit - set.draw do |map| - map.connect "/people", :controller => "people", :action => "index" - map.connect "/ws/people", :controller => "people", :action => "index", :ws => true - end - - url = set.generate(:controller => "people", :action => "index", :ws => true) - assert_equal "/ws/people", url - end - - def test_generate_changes_controller_module - set.draw { |map| map.connect ':controller/:action/:id' } - current = { :controller => "bling/bloop", :action => "bap", :id => 9 } - url = set.generate({:controller => "foo/bar", :action => "baz", :id => 7}, current) - assert_equal "/foo/bar/baz/7", url - end - - def test_id_is_not_impossibly_sticky - set.draw do |map| - map.connect 'foo/:number', :controller => "people", :action => "index" - map.connect ':controller/:action/:id' - end - - url = set.generate({:controller => "people", :action => "index", :number => 3}, - {:controller => "people", :action => "index", :id => "21"}) - assert_equal "/foo/3", url - end - - def test_id_is_sticky_when_it_ought_to_be - set.draw do |map| - map.connect ':controller/:id/:action' - end - - url = set.generate({:action => "destroy"}, {:controller => "people", :action => "show", :id => "7"}) - assert_equal "/people/7/destroy", url - end - - def test_use_static_path_when_possible - set.draw do |map| - map.connect 'about', :controller => "welcome", :action => "about" - map.connect ':controller/:action/:id' - end - - url = set.generate({:controller => "welcome", :action => "about"}, - {:controller => "welcome", :action => "get", :id => "7"}) - assert_equal "/about", url - end - - def test_generate - set.draw { |map| map.connect ':controller/:action/:id' } - - args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } - assert_equal "/foo/bar/7?x=y", set.generate(args) - assert_equal ["/foo/bar/7", [:x]], set.generate_extras(args) - assert_equal [:x], set.extra_keys(args) - end - - def test_generate_with_path_prefix - set.draw { |map| map.connect ':controller/:action/:id', :path_prefix => 'my' } - - args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } - assert_equal "/my/foo/bar/7?x=y", set.generate(args) - end - - def test_generate_with_blank_path_prefix - set.draw { |map| map.connect ':controller/:action/:id', :path_prefix => '' } - - args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } - assert_equal "/foo/bar/7?x=y", set.generate(args) - end - - def test_named_routes_are_never_relative_to_modules - set.draw do |map| - map.connect "/connection/manage/:action", :controller => 'connection/manage' - map.connect "/connection/connection", :controller => "connection/connection" - map.family_connection "/connection", :controller => "connection" - end - - url = set.generate({:controller => "connection"}, {:controller => 'connection/manage'}) - assert_equal "/connection/connection", url - - url = set.generate({:use_route => :family_connection, :controller => "connection"}, {:controller => 'connection/manage'}) - assert_equal "/connection", url - end - - def test_action_left_off_when_id_is_recalled - set.draw do |map| - map.connect ':controller/:action/:id' - end - assert_equal '/post', set.generate( - {:controller => 'post', :action => 'index'}, - {:controller => 'post', :action => 'show', :id => '10'} - ) - end - - def test_query_params_will_be_shown_when_recalled - set.draw do |map| - map.connect 'show_post/:parameter', :controller => 'post', :action => 'show' - map.connect ':controller/:action/:id' - end - assert_equal '/post/edit?parameter=1', set.generate( - {:action => 'edit', :parameter => 1}, - {:controller => 'post', :action => 'show', :parameter => 1} - ) - end - - def test_format_is_not_inherit - set.draw do |map| - map.connect '/posts.:format', :controller => 'posts' - end - - assert_equal '/posts', set.generate( - {:controller => 'posts'}, - {:controller => 'posts', :action => 'index', :format => 'xml'} - ) - - assert_equal '/posts.xml', set.generate( - {:controller => 'posts', :format => 'xml'}, - {:controller => 'posts', :action => 'index', :format => 'xml'} - ) - end - - def test_expiry_determination_should_consider_values_with_to_param - set.draw { |map| map.connect 'projects/:project_id/:controller/:action' } - assert_equal '/projects/1/post/show', set.generate( - {:action => 'show', :project_id => 1}, - {:controller => 'post', :action => 'show', :project_id => '1'}) - end - - def test_generate_all - set.draw do |map| - map.connect 'show_post/:id', :controller => 'post', :action => 'show' - map.connect ':controller/:action/:id' - end - all = set.generate( - {:action => 'show', :id => 10, :generate_all => true}, - {:controller => 'post', :action => 'show'} - ) - assert_equal 2, all.length - assert_equal '/show_post/10', all.first - assert_equal '/post/show/10', all.last - end - - def test_named_route_in_nested_resource - set.draw do |map| - map.resources :projects do |project| - project.milestones 'milestones', :controller => 'milestones', :action => 'index' - end - end - - request.path = "/projects/1/milestones" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("milestones", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - end - - def test_setting_root_in_namespace_using_symbol - assert_nothing_raised do - set.draw do |map| - map.namespace :admin do |admin| - admin.root :controller => 'home' - end - end - end - end - - def test_setting_root_in_namespace_using_string - assert_nothing_raised do - set.draw do |map| - map.namespace 'admin' do |admin| - admin.root :controller => 'home' - end - end - end - end - - def test_route_requirements_with_unsupported_regexp_options_must_error - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/m} - end - end - end - - def test_route_requirements_with_supported_options_must_not_error - assert_nothing_raised do - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/i} - end - end - assert_nothing_raised do - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/x} - end - end - end - - def test_route_requirement_recognize_with_ignore_case - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/i} - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) - assert_raise ActionController::RoutingError do - set.recognize_path('/page/davidjamis') - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'DAVID'}, set.recognize_path('/page/DAVID')) - end - - def test_route_requirement_generate_with_ignore_case - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/i} - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'david'}) - assert_equal "/page/david", url - assert_raise ActionController::RoutingError do - url = set.generate({:controller => 'pages', :action => 'show', :name => 'davidjamis'}) - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) - assert_equal "/page/JAMIS", url - end - - def test_route_requirement_recognize_with_extended_syntax - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/x} - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) - assert_equal({:controller => 'pages', :action => 'show', :name => 'david'}, set.recognize_path('/page/david')) - assert_raise ActionController::RoutingError do - set.recognize_path('/page/david #The Creator') - end - assert_raise ActionController::RoutingError do - set.recognize_path('/page/David') - end - end - - def test_route_requirement_generate_with_extended_syntax - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/x} - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'david'}) - assert_equal "/page/david", url - assert_raise ActionController::RoutingError do - url = set.generate({:controller => 'pages', :action => 'show', :name => 'davidjamis'}) - end - assert_raise ActionController::RoutingError do - url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) - end - end - - def test_route_requirement_generate_with_xi_modifiers - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/xi} - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) - assert_equal "/page/JAMIS", url - end - - def test_route_requirement_recognize_with_xi_modifiers - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/xi} - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'JAMIS'}, set.recognize_path('/page/JAMIS')) - end - - def test_routes_with_symbols - set.draw do |map| - map.connect 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol - map.named 'named', :controller => :pages, :action => :show, :name => :as_symbol - end - assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/unnamed')) - assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named')) - end - -end - -class RouteLoadingTest < Test::Unit::TestCase - def setup - routes.instance_variable_set '@routes_last_modified', nil - silence_warnings { Object.const_set :RAILS_ROOT, '.' } - routes.add_configuration_file(File.join(RAILS_ROOT, 'config', 'routes.rb')) - - @stat = stub_everything - end - - def teardown - ActionController::Routing::Routes.configuration_files.clear - Object.send :remove_const, :RAILS_ROOT - end - - def test_load - File.expects(:stat).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)) - - routes.reload - end - - def test_no_reload_when_not_modified - @stat.expects(:mtime).times(2).returns(1) - File.expects(:stat).times(2).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)).at_most_once - - 2.times { routes.reload } - end - - def test_reload_when_modified - @stat.expects(:mtime).at_least(2).returns(1, 2) - File.expects(:stat).at_least(2).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)).times(2) - - 2.times { routes.reload } - end - - def test_bang_forces_reload - @stat.expects(:mtime).at_least(2).returns(1) - File.expects(:stat).at_least(2).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)).times(2) - - 2.times { routes.reload! } - end - - def test_adding_inflections_forces_reload - ActiveSupport::Inflector::Inflections.instance.expects(:uncountable).with('equipment') - routes.expects(:reload!) - - ActiveSupport::Inflector.inflections { |inflect| inflect.uncountable('equipment') } - end - - def test_load_with_configuration - routes.configuration_files.clear - routes.add_configuration_file("foobarbaz") - File.expects(:stat).returns(@stat) - routes.expects(:load).with("foobarbaz") - - routes.reload - end - - def test_load_multiple_configurations - routes.add_configuration_file("engines.rb") - - File.expects(:stat).at_least_once.returns(@stat) - - routes.expects(:load).with('./config/routes.rb') - routes.expects(:load).with('engines.rb') - - routes.reload - end - - private - def routes - ActionController::Routing::Routes - end -end diff --git a/vendor/rails/actionpack/test/controller/selector_test.rb b/vendor/rails/actionpack/test/controller/selector_test.rb deleted file mode 100644 index 9d0613d1..00000000 --- a/vendor/rails/actionpack/test/controller/selector_test.rb +++ /dev/null @@ -1,628 +0,0 @@ -#-- -# Copyright (c) 2006 Assaf Arkin (http://labnotes.org) -# Under MIT and/or CC By license. -#++ - -require 'abstract_unit' -require 'controller/fake_controllers' - -class SelectorTest < Test::Unit::TestCase - # - # Basic selector: element, id, class, attributes. - # - - def test_element - parse(%Q{<div id="1"></div><p></p><div id="2"></div>}) - # Match element by name. - select("div") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Not case sensitive. - select("DIV") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Universal match (all elements). - select("*") - assert_equal 3, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal nil, @matches[1].attributes["id"] - assert_equal "2", @matches[2].attributes["id"] - end - - - def test_identifier - parse(%Q{<div id="1"></div><p></p><div id="2"></div>}) - # Match element by ID. - select("div#1") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match element by ID, substitute value. - select("div#?", 2) - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Element name does not match ID. - select("p#?", 2) - assert_equal 0, @matches.size - # Use regular expression. - select("#?", /\d/) - assert_equal 2, @matches.size - end - - - def test_class_name - parse(%Q{<div id="1" class=" foo "></div><p id="2" class=" foo bar "></p><div id="3" class="bar"></div>}) - # Match element with specified class. - select("div.foo") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match any element with specified class. - select("*.foo") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Match elements with other class. - select("*.bar") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Match only element with both class names. - select("*.bar.foo") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - end - - - def test_attribute - parse(%Q{<div id="1"></div><p id="2" title="" bar="foo"></p><div id="3" title="foo"></div>}) - # Match element with attribute. - select("div[title]") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Match any element with attribute. - select("*[title]") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Match element with attribute value. - select("*[title=foo]") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Match element with attribute and attribute value. - select("[bar=foo][title]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Not case sensitive. - select("[BAR=foo][TiTle]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - end - - - def test_attribute_quoted - parse(%Q{<div id="1" title="foo"></div><div id="2" title="bar"></div><div id="3" title=" bar "></div>}) - # Match without quotes. - select("[title = bar]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match with single quotes. - select("[title = 'bar' ]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match with double quotes. - select("[title = \"bar\" ]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match with spaces. - select("[title = \" bar \" ]") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - end - - - def test_attribute_equality - parse(%Q{<div id="1" title="foo bar"></div><div id="2" title="barbaz"></div>}) - # Match (fail) complete value. - select("[title=bar]") - assert_equal 0, @matches.size - # Match space-separate word. - select("[title~=foo]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("[title~=bar]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match beginning of value. - select("[title^=ba]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match end of value. - select("[title$=ar]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match text in value. - select("[title*=bar]") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Match first space separated word. - select("[title|=foo]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("[title|=bar]") - assert_equal 0, @matches.size - end - - - # - # Selector composition: groups, sibling, children - # - - - def test_selector_group - parse(%Q{<h1 id="1"></h1><h2 id="2"></h2><h3 id="3"></h3>}) - # Simple group selector. - select("h1,h3") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("h1 , h3") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Complex group selector. - parse(%Q{<h1 id="1"><a href="foo"></a></h1><h2 id="2"><a href="bar"></a></h2><h3 id="2"><a href="baz"></a></h3>}) - select("h1 a, h3 a") - assert_equal 2, @matches.size - assert_equal "foo", @matches[0].attributes["href"] - assert_equal "baz", @matches[1].attributes["href"] - # And now for the three selector challenge. - parse(%Q{<h1 id="1"><a href="foo"></a></h1><h2 id="2"><a href="bar"></a></h2><h3 id="2"><a href="baz"></a></h3>}) - select("h1 a, h2 a, h3 a") - assert_equal 3, @matches.size - assert_equal "foo", @matches[0].attributes["href"] - assert_equal "bar", @matches[1].attributes["href"] - assert_equal "baz", @matches[2].attributes["href"] - end - - - def test_sibling_selector - parse(%Q{<h1 id="1"></h1><h2 id="2"></h2><h3 id="3"></h3>}) - # Test next sibling. - select("h1+*") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select("h1+h2") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select("h1+h3") - assert_equal 0, @matches.size - select("*+h3") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Test any sibling. - select("h1~*") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("h2~*") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - end - - - def test_children_selector - parse(%Q{<div><p id="1"><span id="2"></span></p></div><div><p id="3"><span id="4" class="foo"></span></p></div>}) - # Test child selector. - select("div>p") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("div>span") - assert_equal 0, @matches.size - select("div>p#3") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - select("div>p>span") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - # Test descendant selector. - select("div p") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("div span") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - select("div *#3") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - select("div *#4") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - # This is here because it failed before when whitespaces - # were not properly stripped. - select("div .foo") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - end - - - # - # Pseudo selectors: root, nth-child, empty, content, etc - # - - - def test_root_selector - parse(%Q{<div id="1"><div id="2"></div></div>}) - # Can only find element if it's root. - select(":root") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("#1:root") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("#2:root") - assert_equal 0, @matches.size - # Opposite for nth-child. - select("#1:nth-child(1)") - assert_equal 0, @matches.size - end - - - def test_nth_child_odd_even - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Test odd nth children. - select("tr:nth-child(odd)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Test even nth children. - select("tr:nth-child(even)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - end - - - def test_nth_child_a_is_zero - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Test the third child. - select("tr:nth-child(0n+3)") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Same but an can be omitted when zero. - select("tr:nth-child(3)") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Second element (but not every second element). - select("tr:nth-child(0n+2)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Before first and past last returns nothing.: - assert_raise(ArgumentError) { select("tr:nth-child(-1)") } - select("tr:nth-child(0)") - assert_equal 0, @matches.size - select("tr:nth-child(5)") - assert_equal 0, @matches.size - end - - - def test_nth_child_a_is_one - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # a is group of one, pick every element in group. - select("tr:nth-child(1n+0)") - assert_equal 4, @matches.size - # Same but a can be omitted when one. - select("tr:nth-child(n+0)") - assert_equal 4, @matches.size - # Same but b can be omitted when zero. - select("tr:nth-child(n)") - assert_equal 4, @matches.size - end - - - def test_nth_child_b_is_zero - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # If b is zero, pick the n-th element (here each one). - select("tr:nth-child(n+0)") - assert_equal 4, @matches.size - # If b is zero, pick the n-th element (here every second). - select("tr:nth-child(2n+0)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # If a and b are both zero, no element selected. - select("tr:nth-child(0n+0)") - assert_equal 0, @matches.size - select("tr:nth-child(0)") - assert_equal 0, @matches.size - end - - - def test_nth_child_a_is_negative - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Since a is -1, picks the first three elements. - select("tr:nth-child(-n+3)") - assert_equal 3, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - assert_equal "3", @matches[2].attributes["id"] - # Since a is -2, picks the first in every second of first four elements. - select("tr:nth-child(-2n+3)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Since a is -2, picks the first in every second of first three elements. - select("tr:nth-child(-2n+2)") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - end - - - def test_nth_child_b_is_negative - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Select last of four. - select("tr:nth-child(4n-1)") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - # Select first of four. - select("tr:nth-child(4n-4)") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Select last of every second. - select("tr:nth-child(2n-1)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - # Select nothing since an+b always < 0 - select("tr:nth-child(-1n-1)") - assert_equal 0, @matches.size - end - - - def test_nth_child_substitution_values - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Test with ?n?. - select("tr:nth-child(?n?)", 2, 1) - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("tr:nth-child(?n?)", 2, 2) - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - select("tr:nth-child(?n?)", 4, 2) - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Test with ? (b only). - select("tr:nth-child(?)", 3) - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - select("tr:nth-child(?)", 5) - assert_equal 0, @matches.size - end - - - def test_nth_last_child - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Last two elements. - select("tr:nth-last-child(-n+2)") - assert_equal 2, @matches.size - assert_equal "3", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - # All old elements counting from last one. - select("tr:nth-last-child(odd)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - end - - - def test_nth_of_type - parse(%Q{<table><thead></thead><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # First two elements. - select("tr:nth-of-type(-n+2)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # All old elements counting from last one. - select("tr:nth-last-of-type(odd)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - end - - - def test_first_and_last - parse(%Q{<table><thead></thead><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # First child. - select("tr:first-child") - assert_equal 0, @matches.size - select(":first-child") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - # First of type. - select("tr:first-of-type") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("thead:first-of-type") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - select("div:first-of-type") - assert_equal 0, @matches.size - # Last child. - select("tr:last-child") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - # Last of type. - select("tr:last-of-type") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - select("thead:last-of-type") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - select("div:last-of-type") - assert_equal 0, @matches.size - end - - - def test_first_and_last - # Only child. - parse(%Q{<table><tr></tr></table>}) - select("table:only-child") - assert_equal 0, @matches.size - select("tr:only-child") - assert_equal 1, @matches.size - assert_equal "tr", @matches[0].name - parse(%Q{<table><tr></tr><tr></tr></table>}) - select("tr:only-child") - assert_equal 0, @matches.size - # Only of type. - parse(%Q{<table><thead></thead><tr></tr><tr></tr></table>}) - select("thead:only-of-type") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - select("td:only-of-type") - assert_equal 0, @matches.size - end - - - def test_empty - parse(%Q{<table><tr></tr></table>}) - select("table:empty") - assert_equal 0, @matches.size - select("tr:empty") - assert_equal 1, @matches.size - parse(%Q{<div> </div>}) - select("div:empty") - assert_equal 1, @matches.size - end - - - def test_content - parse(%Q{<div> </div>}) - select("div:content()") - assert_equal 1, @matches.size - parse(%Q{<div>something </div>}) - select("div:content()") - assert_equal 0, @matches.size - select("div:content(something)") - assert_equal 1, @matches.size - select("div:content( 'something' )") - assert_equal 1, @matches.size - select("div:content( \"something\" )") - assert_equal 1, @matches.size - select("div:content(?)", "something") - assert_equal 1, @matches.size - select("div:content(?)", /something/) - assert_equal 1, @matches.size - end - - - # - # Test negation. - # - - - def test_element_negation - parse(%Q{<p></p><div></div>}) - select("*") - assert_equal 2, @matches.size - select("*:not(p)") - assert_equal 1, @matches.size - assert_equal "div", @matches[0].name - select("*:not(div)") - assert_equal 1, @matches.size - assert_equal "p", @matches[0].name - select("*:not(span)") - assert_equal 2, @matches.size - end - - - def test_id_negation - parse(%Q{<p id="1"></p><p id="2"></p>}) - select("p") - assert_equal 2, @matches.size - select(":not(#1)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select(":not(#2)") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - end - - - def test_class_name_negation - parse(%Q{<p class="foo"></p><p class="bar"></p>}) - select("p") - assert_equal 2, @matches.size - select(":not(.foo)") - assert_equal 1, @matches.size - assert_equal "bar", @matches[0].attributes["class"] - select(":not(.bar)") - assert_equal 1, @matches.size - assert_equal "foo", @matches[0].attributes["class"] - end - - - def test_attribute_negation - parse(%Q{<p title="foo"></p><p title="bar"></p>}) - select("p") - assert_equal 2, @matches.size - select(":not([title=foo])") - assert_equal 1, @matches.size - assert_equal "bar", @matches[0].attributes["title"] - select(":not([title=bar])") - assert_equal 1, @matches.size - assert_equal "foo", @matches[0].attributes["title"] - end - - - def test_pseudo_class_negation - parse(%Q{<div><p id="1"></p><p id="2"></p></div>}) - select("p") - assert_equal 2, @matches.size - select("p:not(:first-child)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select("p:not(:nth-child(2))") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - end - - - def test_negation_details - parse(%Q{<p id="1"></p><p id="2"></p><p id="3"></p>}) - assert_raise(ArgumentError) { select(":not(") } - assert_raise(ArgumentError) { select(":not(:not())") } - select("p:not(#1):not(#3)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - end - - - def test_select_from_element - parse(%Q{<div><p id="1"></p><p id="2"></p></div>}) - select("div") - @matches = @matches[0].select("p") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - end - - -protected - - def parse(html) - @html = HTML::Document.new(html).root - end - - def select(*selector) - @matches = HTML.selector(*selector).select(@html) - end - -end diff --git a/vendor/rails/actionpack/test/controller/send_file_test.rb b/vendor/rails/actionpack/test/controller/send_file_test.rb deleted file mode 100644 index a8e1afc7..00000000 --- a/vendor/rails/actionpack/test/controller/send_file_test.rb +++ /dev/null @@ -1,171 +0,0 @@ -# encoding: utf-8 -require 'abstract_unit' - -module TestFileUtils - def file_name() File.basename(__FILE__) end - def file_path() File.expand_path(__FILE__) end - def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end -end - -class SendFileController < ActionController::Base - include TestFileUtils - layout "layouts/standard" # to make sure layouts don't interfere - - attr_writer :options - def options() @options ||= {} end - - def file() send_file(file_path, options) end - def data() send_data(file_data, options) end - def multibyte_text_data() send_data("Кирилица\n祝您好運", options) end - - def rescue_action(e) raise end -end - -class SendFileTest < ActionController::TestCase - tests SendFileController - include TestFileUtils - - Mime::Type.register "image/png", :png unless defined? Mime::PNG - - def setup - @controller = SendFileController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_file_nostream - @controller.options = { :stream => false } - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_kind_of String, response.body - assert_equal file_data, response.body - end - - def test_file_stream - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_kind_of Proc, response.body - - require 'stringio' - output = StringIO.new - output.binmode - output.string.force_encoding(file_data.encoding) if output.string.respond_to?(:force_encoding) - assert_nothing_raised { response.body.call(response, output) } - assert_equal file_data, output.string - end - - def test_file_url_based_filename - @controller.options = { :url_based_filename => true } - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_equal "attachment", response.headers["Content-Disposition"] - end - - def test_x_sendfile_header - @controller.options = { :x_sendfile => true } - - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - - assert_equal @controller.file_path, response.headers['X-Sendfile'] - assert response.body.blank? - assert !response.etag?, response.headers.inspect - end - - def test_data - response = nil - assert_nothing_raised { response = process('data') } - assert_not_nil response - - assert_kind_of String, response.body - assert_equal file_data, response.body - end - - def test_headers_after_send_shouldnt_include_charset - response = process('data') - assert_equal "application/octet-stream", response.content_type - - response = process('file') - assert_equal "application/octet-stream", response.content_type - end - - # Test that send_file_headers! is setting the correct HTTP headers. - def test_send_file_headers! - options = { - :length => 1, - :type => Mime::PNG, - :disposition => 'disposition', - :filename => 'filename' - } - - # Do it a few times: the resulting headers should be identical - # no matter how many times you send with the same options. - # Test resolving Ticket #458. - @controller.headers = {} - @controller.send(:send_file_headers!, options) - @controller.send(:send_file_headers!, options) - @controller.send(:send_file_headers!, options) - - h = @controller.headers - assert_equal '1', h['Content-Length'] - assert_equal 'image/png', h['Content-Type'] - assert_equal 'disposition; filename="filename"', h['Content-Disposition'] - assert_equal 'binary', h['Content-Transfer-Encoding'] - - # test overriding Cache-Control: no-cache header to fix IE open/save dialog - @controller.headers = { 'Cache-Control' => 'no-cache' } - @controller.send(:send_file_headers!, options) - h = @controller.headers - assert_equal 'private', h['Cache-Control'] - end - - def test_send_file_headers_with_mime_lookup_with_symbol - options = { - :length => 1, - :type => :png - } - - @controller.headers = {} - @controller.send(:send_file_headers!, options) - - headers = @controller.headers - - assert_equal 'image/png', headers['Content-Type'] - end - - - def test_send_file_headers_with_bad_symbol - options = { - :length => 1, - :type => :this_type_is_not_registered - } - - @controller.headers = {} - assert_raise(ArgumentError){ @controller.send(:send_file_headers!, options) } - end - - %w(file data).each do |method| - define_method "test_send_#{method}_status" do - @controller.options = { :stream => false, :status => 500 } - assert_nothing_raised { assert_not_nil process(method) } - assert_equal '500 Internal Server Error', @response.status - end - - define_method "test_default_send_#{method}_status" do - @controller.options = { :stream => false } - assert_nothing_raised { assert_not_nil process(method) } - assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @response.status - end - end - - def test_send_data_content_length_header - @controller.headers = {} - @controller.options = { :type => :text, :filename => 'file_with_utf8_text' } - process('multibyte_text_data') - assert_equal '29', @controller.headers['Content-Length'] - end -end diff --git a/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb b/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb deleted file mode 100644 index 2df66a2e..00000000 --- a/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'abstract_unit' - -# You need to start a memcached server inorder to run these tests -class AbstractStoreTest < ActionController::IntegrationTest - SessionKey = '_myapp_session' - DispatcherApp = ActionController::Dispatcher.new - - class TestController < ActionController::Base - def get_session - session[:test] = 'test' - head :ok - end - end - - def test_expiry_after - with_test_route_set(:expire_after => 5 * 60) do - get 'get_session' - assert_response :success - assert_match /expires=\S+/, headers['Set-Cookie'] - end - end - -protected - - def with_test_route_set(options = {}) - with_routing do |set| - set.draw do |map| - map.with_options :controller => "abstract_store_test/test" do |c| - c.connect "/:action" - end - end - - options = { :key => SessionKey, :secret => 'SessionSecret' }.merge!(options) - @integration_session = open_session(TestStore.new(DispatcherApp, options)) - - yield - end - end - - class TestStore < ActionController::Session::AbstractStore - def initialize(app, options = {}) - super - @_store = Hash.new({}) - end - - private - - def get_session(env, sid) - sid ||= generate_sid - session = @_store[sid] - [sid, session] - end - - def set_session(env, sid, session_data) - @_store[sid] = session_data - end - - def destroy(env) - @_store.delete(sid) - end - end - -end - diff --git a/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb b/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb deleted file mode 100644 index 8d02fffa..00000000 --- a/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +++ /dev/null @@ -1,354 +0,0 @@ -require 'abstract_unit' -require 'stringio' - -class CookieStoreTest < ActionController::IntegrationTest - SessionKey = '_myapp_session' - SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33' - - DispatcherApp = ActionController::Dispatcher.new - - Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1') - - SignedBar = "BAh7BjoIZm9vIghiYXI%3D--fef868465920f415f2c0652d6910d3af288a0367" - - class TestController < ActionController::Base - def no_session_access - head :ok - end - - def persistent_session_id - render :text => session[:session_id] - end - - def set_session_value - session[:foo] = "bar" - render :text => Rack::Utils.escape(Verifier.generate(session.to_hash)) - end - - def get_session_value - render :text => "foo: #{session[:foo].inspect}" - end - - def get_session_id - render :text => "foo: #{session[:foo].inspect}; id: #{request.session_options[:id]}" - end - - def get_session_id_only - render :text => "id: #{request.session_options[:id]}" - end - - def call_session_clear - session.clear - head :ok - end - - def call_reset_session_twice - reset_session - reset_session - head :ok - end - - def call_reset_session - reset_session - head :ok - end - - def raise_data_overflow - session[:foo] = 'bye!' * 1024 - head :ok - end - - def set_session_value_and_cookie - cookies["foo"] = "bar" - session[:foo] = "bar" - render :text => Rack::Utils.escape(Verifier.generate(session.to_hash)) - end - - def rescue_action(e) raise end - end - - def test_raises_argument_error_if_missing_session_key - assert_raise(ArgumentError, nil.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => nil, :secret => SessionSecret) - } - - assert_raise(ArgumentError, ''.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => '', :secret => SessionSecret) - } - end - - def test_raises_argument_error_if_missing_secret - assert_raise(ArgumentError, nil.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => nil) - } - - assert_raise(ArgumentError, ''.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => '') - } - end - - def test_raises_argument_error_if_secret_is_probably_insecure - assert_raise(ArgumentError, "password".inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => "password") - } - - assert_raise(ArgumentError, "secret".inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => "secret") - } - - assert_raise(ArgumentError, "12345678901234567890123456789".inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => "12345678901234567890123456789") - } - end - - def test_setting_session_value - with_test_route_set do - get '/set_session_value' - assert_response :success - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - end - end - - def test_getting_session_value - with_test_route_set do - cookies[SessionKey] = SignedBar - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - end - end - - def test_getting_session_id - with_test_route_set do - cookies[SessionKey] = SignedBar - get '/persistent_session_id' - assert_response :success - assert_equal response.body.size, 32 - session_id = response.body - - get '/get_session_id' - assert_response :success - assert_equal "foo: \"bar\"; id: #{session_id}", response.body - - get '/get_session_id_only' - assert_response :success - assert_equal "id: #{session_id}", response.body, "should be able to read session id without accessing the session hash" - end - end - - def test_disregards_tampered_sessions - with_test_route_set do - cookies[SessionKey] = "BAh7BjoIZm9vIghiYXI%3D--123456780" - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_does_not_set_secure_cookies_over_http - with_test_route_set(:secure => true) do - get '/set_session_value' - assert_response :success - assert_equal nil, headers['Set-Cookie'] - end - end - - def test_does_set_secure_cookies_over_https - with_test_route_set(:secure => true) do - get '/set_session_value', nil, 'HTTPS' => 'on' - assert_response :success - assert_equal "_myapp_session=#{response.body}; path=/; secure; HttpOnly", - headers['Set-Cookie'] - end - end - - def test_close_raises_when_data_overflows - with_test_route_set do - assert_raise(ActionController::Session::CookieStore::CookieOverflow) { - get '/raise_data_overflow' - } - end - end - - def test_doesnt_write_session_cookie_if_session_is_not_accessed - with_test_route_set do - get '/no_session_access' - assert_response :success - assert_equal nil, headers['Set-Cookie'] - end - end - - def test_doesnt_write_session_cookie_if_session_is_unchanged - with_test_route_set do - cookies[SessionKey] = "BAh7BjoIZm9vIghiYXI%3D--" + - "fef868465920f415f2c0652d6910d3af288a0367" - get '/no_session_access' - assert_response :success - assert_equal nil, headers['Set-Cookie'] - end - end - - def test_calling_session_reset_twice - with_test_route_set do - get '/set_session_value' - assert_response :success - session_payload = response.body - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - - get '/call_reset_session_twice' - assert_response :success - assert_not_equal "", headers['Set-Cookie'] - assert_not_equal session_payload, cookies[SessionKey] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - session_payload = response.body - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - - get '/call_reset_session' - assert_response :success - assert_not_equal "", headers['Set-Cookie'] - assert_not_equal session_payload, cookies[SessionKey] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - session_payload = response.body - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - - get '/call_reset_session' - assert_response :success - assert_not_equal "", headers['Set-Cookie'] - assert_not_equal session_payload, cookies[SessionKey] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_clear - with_test_route_set do - get '/set_session_value' - assert_response :success - session_payload = response.body - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - - get '/call_session_clear' - assert_response :success - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_getting_from_nonexistent_session - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - assert_nil headers['Set-Cookie'], "should only create session on write, not read" - end - end - - # {:foo=>#<SessionAutoloadTest::Foo bar:"baz">, :session_id=>"ce8b0752a6ab7c7af3cdb8a80e6b9e46"} - SignedSerializedCookie = "BAh7BzoIZm9vbzodU2Vzc2lvbkF1dG9sb2FkVGVzdDo6Rm9vBjoJQGJhciIIYmF6Og9zZXNzaW9uX2lkIiVjZThiMDc1MmE2YWI3YzdhZjNjZGI4YTgwZTZiOWU0Ng==--2bf3af1ae8bd4e52b9ac2099258ace0c380e601c" - - def test_deserializes_unloaded_classes_on_get_id - with_test_route_set do - with_autoload_path "session_autoload_test" do - cookies[SessionKey] = SignedSerializedCookie - get '/get_session_id_only' - assert_response :success - assert_equal 'id: ce8b0752a6ab7c7af3cdb8a80e6b9e46', response.body, "should auto-load unloaded class" - end - end - end - - def test_deserializes_unloaded_classes_on_get_value - with_test_route_set do - with_autoload_path "session_autoload_test" do - cookies[SessionKey] = SignedSerializedCookie - get '/get_session_value' - assert_response :success - assert_equal 'foo: #<SessionAutoloadTest::Foo bar:"baz">', response.body, "should auto-load unloaded class" - end - end - end - - def test_persistent_session_id - with_test_route_set do - cookies[SessionKey] = SignedBar - get '/persistent_session_id' - assert_response :success - assert_equal response.body.size, 32 - session_id = response.body - get '/persistent_session_id' - assert_equal session_id, response.body - reset! - get '/persistent_session_id' - assert_not_equal session_id, response.body - end - end - - def test_setting_session_value_and_cookie - with_test_route_set do - get '/set_session_value_and_cookie' - assert_response :success - assert_equal({"_myapp_session" => response.body, "foo" => "bar"}, cookies) - end - end - - private - def with_test_route_set(options = {}) - with_routing do |set| - set.draw do |map| - map.with_options :controller => "cookie_store_test/test" do |c| - c.connect "/:action" - end - end - - options = { :key => SessionKey, :secret => SessionSecret }.merge!(options) - @integration_session = open_session(ActionController::Session::CookieStore.new(DispatcherApp, options)) - - yield - end - end - - def unmarshal_session(cookie_string) - session = Rack::Utils.parse_query(cookie_string, ';,').inject({}) {|h,(k,v)| - h[k] = Array === v ? v.first : v - h - }[SessionKey] - verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1') - verifier.verify(session) - end -end diff --git a/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb b/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb deleted file mode 100644 index 2714ee52..00000000 --- a/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb +++ /dev/null @@ -1,187 +0,0 @@ -require 'abstract_unit' - -# You need to start a memcached server inorder to run these tests -class MemCacheStoreTest < ActionController::IntegrationTest - class TestController < ActionController::Base - def no_session_access - head :ok - end - - def set_session_value - session[:foo] = "bar" - head :ok - end - - def set_serialized_session_value - session[:foo] = SessionAutoloadTest::Foo.new - head :ok - end - - def get_session_value - render :text => "foo: #{session[:foo].inspect}" - end - - def get_session_id - render :text => "#{request.session_options[:id]}" - end - - def call_reset_session - session[:bar] - reset_session - session[:bar] = "baz" - head :ok - end - - def rescue_action(e) raise end - end - - begin - DispatcherApp = ActionController::Dispatcher.new - - def test_setting_and_getting_session_value - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - end - end - - def test_getting_nil_session_value - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - - get '/get_session_id' - assert_response :success - assert_not_equal session_id, response.body - end - end - - def test_getting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies["_session_id"] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - - cookies["_session_id"] = session_id # replace our new session_id with our old, pre-reset session_id - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body, "data for this session should have been obliterated from memcached" - end - end - - def test_getting_from_nonexistent_session - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - assert_nil cookies['_session_id'], "should only create session on write, not read" - end - end - - def test_getting_session_id - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/get_session_id' - assert_response :success - assert_equal session_id, response.body, "should be able to read session id without accessing the session hash" - end - end - - def test_doesnt_write_session_cookie_if_session_id_is_already_exists - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal nil, headers['Set-Cookie'], "should not resend the cookie again if session_id cookie is already exists" - end - end - - def test_deserializes_unloaded_class - with_test_route_set do - with_autoload_path "session_autoload_test" do - get '/set_serialized_session_value' - assert_response :success - assert cookies['_session_id'] - end - with_autoload_path "session_autoload_test" do - get '/get_session_id' - assert_response :success - end - with_autoload_path "session_autoload_test" do - get '/get_session_value' - assert_response :success - assert_equal 'foo: #<SessionAutoloadTest::Foo bar:"baz">', response.body, "should auto-load unloaded class" - end - end - end - - def test_prevents_session_fixation - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - session_id = cookies['_session_id'] - - reset! - - get '/set_session_value', :_session_id => session_id - assert_response :success - assert_equal nil, cookies['_session_id'] - end - end - rescue LoadError, RuntimeError - $stderr.puts "Skipping MemCacheStoreTest tests. Start memcached and try again." - end - - private - def with_test_route_set(options = {}) - with_routing do |set| - set.draw do |map| - map.with_options :controller => "mem_cache_store_test/test" do |c| - c.connect "/:action" - end - end - - options = { :key => '_session_id' }.merge!(options) - @integration_session = open_session(ActionController::Session::MemCacheStore.new(DispatcherApp, options)) - - yield - end - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/session/test_session_test.rb b/vendor/rails/actionpack/test/controller/session/test_session_test.rb deleted file mode 100644 index 86926322..00000000 --- a/vendor/rails/actionpack/test/controller/session/test_session_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'abstract_unit' -require 'stringio' - -class ActionController::TestSessionTest < ActiveSupport::TestCase - - def test_calling_delete_without_parameters_raises_deprecation_warning_and_calls_to_clear_test_session - assert_deprecated(/use clear instead/){ ActionController::TestSession.new.delete } - end - - def test_calling_update_without_parameters_raises_deprecation_warning_and_calls_to_clear_test_session - assert_deprecated(/use replace instead/){ ActionController::TestSession.new.update } - end - - def test_calling_close_raises_deprecation_warning - assert_deprecated(/sessions should no longer be closed/){ ActionController::TestSession.new.close } - end - - def test_defaults - session = ActionController::TestSession.new - assert_equal({}, session.data) - assert_equal('', session.session_id) - end - - def test_ctor_allows_setting - session = ActionController::TestSession.new({:one => 'one', :two => 'two'}) - assert_equal('one', session[:one]) - assert_equal('two', session[:two]) - end - - def test_setting_session_item_sets_item - session = ActionController::TestSession.new - session[:key] = 'value' - assert_equal('value', session[:key]) - end - - def test_calling_delete_removes_item_and_returns_its_value - session = ActionController::TestSession.new - session[:key] = 'value' - assert_equal('value', session[:key]) - assert_equal('value', session.delete(:key)) - assert_nil(session[:key]) - end - - def test_calling_update_with_params_passes_to_attributes - session = ActionController::TestSession.new() - session.update('key' => 'value') - assert_equal('value', session[:key]) - end - - def test_clear_emptys_session - params = {:one => 'one', :two => 'two'} - session = ActionController::TestSession.new({:one => 'one', :two => 'two'}) - session.clear - assert_nil(session[:one]) - assert_nil(session[:two]) - end - -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/test_test.rb b/vendor/rails/actionpack/test/controller/test_test.rb deleted file mode 100644 index 3924b282..00000000 --- a/vendor/rails/actionpack/test/controller/test_test.rb +++ /dev/null @@ -1,700 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_controllers' - -class TestTest < ActionController::TestCase - class TestController < ActionController::Base - def no_op - render :text => 'dummy' - end - - def set_flash - flash["test"] = ">#{flash["test"]}<" - render :text => 'ignore me' - end - - def set_flash_now - flash.now["test_now"] = ">#{flash["test_now"]}<" - render :text => 'ignore me' - end - - def set_session - session['string'] = 'A wonder' - session[:symbol] = 'it works' - render :text => 'Success' - end - - def reset_the_session - reset_session - render :text => 'ignore me' - end - - def render_raw_post - raise ActiveSupport::TestCase::Assertion, "#raw_post is blank" if request.raw_post.blank? - render :text => request.raw_post - end - - def render_body - render :text => request.body.read - end - - def test_params - render :text => params.inspect - end - - def test_uri - render :text => request.request_uri - end - - def test_query_string - render :text => request.query_string - end - - def test_html_output - render :text => <<HTML -<html> - <body> - <a href="/"><img src="/images/button.png" /></a> - <div id="foo"> - <ul> - <li class="item">hello</li> - <li class="item">goodbye</li> - </ul> - </div> - <div id="bar"> - <form action="/somewhere"> - Name: <input type="text" name="person[name]" id="person_name" /> - </form> - </div> - </body> -</html> -HTML - end - - def test_xml_output - response.content_type = "application/xml" - render :text => <<XML -<?xml version="1.0" encoding="UTF-8"?> -<root> - <area>area is an empty tag in HTML, raising an error if not in xml mode</area> -</root> -XML - end - - def test_only_one_param - render :text => (params[:left] && params[:right]) ? "EEP, Both here!" : "OK" - end - - def test_remote_addr - render :text => (request.remote_addr || "not specified") - end - - def test_file_upload - render :text => params[:file].size - end - - def test_send_file - send_file(File.expand_path(__FILE__)) - end - - def redirect_to_same_controller - redirect_to :controller => 'test', :action => 'test_uri', :id => 5 - end - - def redirect_to_different_controller - redirect_to :controller => 'fail', :id => 5 - end - - def create - head :created, :location => 'created resource' - end - - private - def rescue_action(e) - raise e - end - - def generate_url(opts) - url_for(opts.merge(:action => "test_uri")) - end - end - - def setup - @controller = TestController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - ActionController::Routing.use_controllers! %w(content admin/user test_test/test) - ActionController::Routing::Routes.load_routes! - end - - def teardown - ActionController::Routing::Routes.reload - end - - def test_raw_post_handling - params = {:page => {:name => 'page name'}, 'some key' => 123} - post :render_raw_post, params.dup - - assert_equal params.to_query, @response.body - end - - def test_body_stream - params = { :page => { :name => 'page name' }, 'some key' => 123 } - - post :render_body, params.dup - - assert_equal params.to_query, @response.body - end - - def test_process_without_flash - process :set_flash - assert_equal '><', flash['test'] - end - - def test_process_with_flash - process :set_flash, nil, nil, { "test" => "value" } - assert_equal '>value<', flash['test'] - end - - def test_process_with_flash_now - process :set_flash_now, nil, nil, { "test_now" => "value_now" } - assert_equal '>value_now<', flash['test_now'] - end - - def test_process_with_session - process :set_session - assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" - assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" - assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" - assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" - end - - def test_process_with_session_arg - process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' } - assert_equal 'value1', session['string'] - assert_equal 'value1', session[:string] - assert_equal 'value2', session['symbol'] - assert_equal 'value2', session[:symbol] - end - - def test_session_is_cleared_from_controller_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @controller.session.to_hash - end - - def test_session_is_cleared_from_response_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @response.session.to_hash - end - - def test_session_is_cleared_from_request_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @request.session.to_hash - end - - def test_process_with_request_uri_with_no_params - process :test_uri - assert_equal "/test_test/test/test_uri", @response.body - end - - def test_process_with_request_uri_with_params - process :test_uri, :id => 7 - assert_equal "/test_test/test/test_uri/7", @response.body - end - - def test_process_with_request_uri_with_params_with_explicit_uri - @request.set_REQUEST_URI "/explicit/uri" - process :test_uri, :id => 7 - assert_equal "/explicit/uri", @response.body - end - - def test_process_with_query_string - process :test_query_string, :q => 'test' - assert_equal "q=test", @response.body - end - - def test_process_with_query_string_with_explicit_uri - @request.set_REQUEST_URI "/explicit/uri?q=test?extra=question" - process :test_query_string - assert_equal "q=test?extra=question", @response.body - end - - def test_multiple_calls - process :test_only_one_param, :left => true - assert_equal "OK", @response.body - process :test_only_one_param, :right => true - assert_equal "OK", @response.body - end - - def test_assert_tag_tag - process :test_html_output - - # there is a 'form' tag - assert_tag :tag => 'form' - # there is not an 'hr' tag - assert_no_tag :tag => 'hr' - end - - def test_assert_tag_attributes - process :test_html_output - - # there is a tag with an 'id' of 'bar' - assert_tag :attributes => { :id => "bar" } - # there is no tag with a 'name' of 'baz' - assert_no_tag :attributes => { :name => "baz" } - end - - def test_assert_tag_parent - process :test_html_output - - # there is a tag with a parent 'form' tag - assert_tag :parent => { :tag => "form" } - # there is no tag with a parent of 'input' - assert_no_tag :parent => { :tag => "input" } - end - - def test_assert_tag_child - process :test_html_output - - # there is a tag with a child 'input' tag - assert_tag :child => { :tag => "input" } - # there is no tag with a child 'strong' tag - assert_no_tag :child => { :tag => "strong" } - end - - def test_assert_tag_ancestor - process :test_html_output - - # there is a 'li' tag with an ancestor having an id of 'foo' - assert_tag :ancestor => { :attributes => { :id => "foo" } }, :tag => "li" - # there is no tag of any kind with an ancestor having an href matching 'foo' - assert_no_tag :ancestor => { :attributes => { :href => /foo/ } } - end - - def test_assert_tag_descendant - process :test_html_output - - # there is a tag with a descendant 'li' tag - assert_tag :descendant => { :tag => "li" } - # there is no tag with a descendant 'html' tag - assert_no_tag :descendant => { :tag => "html" } - end - - def test_assert_tag_sibling - process :test_html_output - - # there is a tag with a sibling of class 'item' - assert_tag :sibling => { :attributes => { :class => "item" } } - # there is no tag with a sibling 'ul' tag - assert_no_tag :sibling => { :tag => "ul" } - end - - def test_assert_tag_after - process :test_html_output - - # there is a tag following a sibling 'div' tag - assert_tag :after => { :tag => "div" } - # there is no tag following a sibling tag with id 'bar' - assert_no_tag :after => { :attributes => { :id => "bar" } } - end - - def test_assert_tag_before - process :test_html_output - - # there is a tag preceding a tag with id 'bar' - assert_tag :before => { :attributes => { :id => "bar" } } - # there is no tag preceding a 'form' tag - assert_no_tag :before => { :tag => "form" } - end - - def test_assert_tag_children_count - process :test_html_output - - # there is a tag with 2 children - assert_tag :children => { :count => 2 } - # in particular, there is a <ul> tag with two children (a nameless pair of <li>s) - assert_tag :tag => 'ul', :children => { :count => 2 } - # there is no tag with 4 children - assert_no_tag :children => { :count => 4 } - end - - def test_assert_tag_children_less_than - process :test_html_output - - # there is a tag with less than 5 children - assert_tag :children => { :less_than => 5 } - # there is no 'ul' tag with less than 2 children - assert_no_tag :children => { :less_than => 2 }, :tag => "ul" - end - - def test_assert_tag_children_greater_than - process :test_html_output - - # there is a 'body' tag with more than 1 children - assert_tag :children => { :greater_than => 1 }, :tag => "body" - # there is no tag with more than 10 children - assert_no_tag :children => { :greater_than => 10 } - end - - def test_assert_tag_children_only - process :test_html_output - - # there is a tag containing only one child with an id of 'foo' - assert_tag :children => { :count => 1, - :only => { :attributes => { :id => "foo" } } } - # there is no tag containing only one 'li' child - assert_no_tag :children => { :count => 1, :only => { :tag => "li" } } - end - - def test_assert_tag_content - process :test_html_output - - # the output contains the string "Name" - assert_tag :content => /Name/ - # the output does not contain the string "test" - assert_no_tag :content => /test/ - end - - def test_assert_tag_multiple - process :test_html_output - - # there is a 'div', id='bar', with an immediate child whose 'action' - # attribute matches the regexp /somewhere/. - assert_tag :tag => "div", :attributes => { :id => "bar" }, - :child => { :attributes => { :action => /somewhere/ } } - - # there is no 'div', id='foo', with a 'ul' child with more than - # 2 "li" children. - assert_no_tag :tag => "div", :attributes => { :id => "foo" }, - :child => { - :tag => "ul", - :children => { :greater_than => 2, - :only => { :tag => "li" } } } - end - - def test_assert_tag_children_without_content - process :test_html_output - - # there is a form tag with an 'input' child which is a self closing tag - assert_tag :tag => "form", - :children => { :count => 1, - :only => { :tag => "input" } } - - # the body tag has an 'a' child which in turn has an 'img' child - assert_tag :tag => "body", - :children => { :count => 1, - :only => { :tag => "a", - :children => { :count => 1, - :only => { :tag => "img" } } } } - end - - def test_should_not_impose_childless_html_tags_in_xml - process :test_xml_output - - begin - $stderr = StringIO.new - assert_select 'area' #This will cause a warning if content is processed as HTML - $stderr.rewind && err = $stderr.read - ensure - $stderr = STDERR - end - - assert err.empty? - end - - def test_assert_tag_attribute_matching - @response.body = '<input type="text" name="my_name">' - assert_tag :tag => 'input', - :attributes => { :name => /my/, :type => 'text' } - assert_no_tag :tag => 'input', - :attributes => { :name => 'my', :type => 'text' } - assert_no_tag :tag => 'input', - :attributes => { :name => /^my$/, :type => 'text' } - end - - def test_assert_tag_content_matching - @response.body = "<p>hello world</p>" - assert_tag :tag => "p", :content => "hello world" - assert_tag :tag => "p", :content => /hello/ - assert_no_tag :tag => "p", :content => "hello" - end - - def test_assert_generates - assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5' - assert_generates 'controller/action/7', {:id => "7"}, {:controller => "controller", :action => "action"} - assert_generates 'controller/action/5', {:controller => "controller", :action => "action", :id => "5", :name => "bob"}, {}, {:name => "bob"} - assert_generates 'controller/action/7', {:id => "7", :name => "bob"}, {:controller => "controller", :action => "action"}, {:name => "bob"} - assert_generates 'controller/action/7', {:id => "7"}, {:controller => "controller", :action => "action", :name => "bob"}, {} - end - - def test_assert_routing - assert_routing 'content', :controller => 'content', :action => 'index' - end - - def test_assert_routing_with_method - with_routing do |set| - set.draw { |map| map.resources(:content) } - assert_routing({ :method => 'post', :path => 'content' }, { :controller => 'content', :action => 'create' }) - end - end - - def test_assert_routing_in_module - assert_routing 'admin/user', :controller => 'admin/user', :action => 'index' - end - - def test_params_passing - get :test_params, :page => {:name => "Page name", :month => '4', :year => '2004', :day => '6'} - parsed_params = eval(@response.body) - assert_equal( - {'controller' => 'test_test/test', 'action' => 'test_params', - 'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}}, - parsed_params - ) - end - - def test_id_converted_to_string - get :test_params, :id => 20, :foo => Object.new - assert_kind_of String, @request.path_parameters['id'] - end - - def test_array_path_parameter_handled_properly - with_routing do |set| - set.draw do |map| - map.connect 'file/*path', :controller => 'test_test/test', :action => 'test_params' - map.connect ':controller/:action/:id' - end - - get :test_params, :path => ['hello', 'world'] - assert_equal ['hello', 'world'], @request.path_parameters['path'] - assert_equal 'hello/world', @request.path_parameters['path'].to_s - end - end - - def test_assert_realistic_path_parameters - get :test_params, :id => 20, :foo => Object.new - - # All elements of path_parameters should use string keys - @request.path_parameters.keys.each do |key| - assert_kind_of String, key - end - end - - def test_with_routing_places_routes_back - assert ActionController::Routing::Routes - routes_id = ActionController::Routing::Routes.object_id - - begin - with_routing { raise 'fail' } - fail 'Should not be here.' - rescue RuntimeError - end - - assert ActionController::Routing::Routes - assert_equal routes_id, ActionController::Routing::Routes.object_id - end - - def test_remote_addr - get :test_remote_addr - assert_equal "0.0.0.0", @response.body - - @request.remote_addr = "192.0.0.1" - get :test_remote_addr - assert_equal "192.0.0.1", @response.body - end - - def test_header_properly_reset_after_remote_http_request - xhr :get, :test_params - assert_nil @request.env['HTTP_X_REQUESTED_WITH'] - end - - def test_header_properly_reset_after_get_request - get :test_params - @request.recycle! - assert_nil @request.instance_variable_get("@request_method") - end - - def test_params_reset_after_post_request - post :no_op, :foo => "bar" - assert_equal "bar", @request.params[:foo] - @request.recycle! - post :no_op - assert @request.params[:foo].blank? - end - - %w(controller response request).each do |variable| - %w(get post put delete head process).each do |method| - define_method("test_#{variable}_missing_for_#{method}_raises_error") do - remove_instance_variable "@#{variable}" - begin - send(method, :test_remote_addr) - assert false, "expected RuntimeError, got nothing" - rescue RuntimeError => error - assert true - assert_match %r{@#{variable} is nil}, error.message - rescue => error - assert false, "expected RuntimeError, got #{error.class}" - end - end - end - end - - FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart' - - if RUBY_VERSION < '1.9' - READ_BINARY = 'rb' - READ_PLAIN = 'r' - else - READ_BINARY = 'rb:binary' - READ_PLAIN = 'r:binary' - end - - def test_test_uploaded_file - filename = 'mona_lisa.jpg' - path = "#{FILES_DIR}/#{filename}" - content_type = 'image/png' - expected = File.read(path) - expected.force_encoding(Encoding::BINARY) if expected.respond_to?(:force_encoding) - - file = ActionController::TestUploadedFile.new(path, content_type) - assert_equal filename, file.original_filename - assert_equal content_type, file.content_type - assert_equal file.path, file.local_path - assert_equal expected, file.read - - new_content_type = "new content_type" - file.content_type = new_content_type - assert_equal new_content_type, file.content_type - - end - - def test_test_uploaded_file_with_binary - filename = 'mona_lisa.jpg' - path = "#{FILES_DIR}/#{filename}" - content_type = 'image/png' - - binary_uploaded_file = ActionController::TestUploadedFile.new(path, content_type, :binary) - assert_equal File.open(path, READ_BINARY).read, binary_uploaded_file.read - - plain_uploaded_file = ActionController::TestUploadedFile.new(path, content_type) - assert_equal File.open(path, READ_PLAIN).read, plain_uploaded_file.read - end - - def test_fixture_file_upload_with_binary - filename = 'mona_lisa.jpg' - path = "#{FILES_DIR}/#{filename}" - content_type = 'image/jpg' - - binary_file_upload = fixture_file_upload(path, content_type, :binary) - assert_equal File.open(path, READ_BINARY).read, binary_file_upload.read - - plain_file_upload = fixture_file_upload(path, content_type) - assert_equal File.open(path, READ_PLAIN).read, plain_file_upload.read - end - - def test_fixture_file_upload - post :test_file_upload, :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") - assert_equal '159528', @response.body - end - - def test_test_uploaded_file_exception_when_file_doesnt_exist - assert_raise(RuntimeError) { ActionController::TestUploadedFile.new('non_existent_file') } - end - - def test_redirect_url_only_cares_about_location_header - get :create - assert_response :created - - # Redirect url doesn't care that it wasn't a :redirect response. - assert_equal 'created resource', @response.redirect_url - assert_equal @response.redirect_url, redirect_to_url - - # Must be a :redirect response. - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to 'created resource' - end - end - - def test_binary_content_works_with_send_file - get :test_send_file - assert_nothing_raised(NoMethodError) { @response.binary_content } - end - - protected - def with_foo_routing - with_routing do |set| - set.draw do |map| - map.generate_url 'foo', :controller => 'test' - map.connect ':controller/:action/:id' - end - yield set - end - end -end - -class CleanBacktraceTest < ActionController::TestCase - def test_should_reraise_the_same_object - exception = ActiveSupport::TestCase::Assertion.new('message') - clean_backtrace { raise exception } - rescue Exception => caught - assert_equal exception.object_id, caught.object_id - assert_equal exception.message, caught.message - end - - def test_should_clean_assertion_lines_from_backtrace - path = File.expand_path("#{File.dirname(__FILE__)}/../../lib/action_controller") - exception = ActiveSupport::TestCase::Assertion.new('message') - exception.set_backtrace ["#{path}/abc", "#{path}/assertions/def"] - clean_backtrace { raise exception } - rescue Exception => caught - assert_equal ["#{path}/abc"], caught.backtrace - end - - def test_should_only_clean_assertion_failure_errors - clean_backtrace do - raise "can't touch this", [File.expand_path("#{File.dirname(__FILE__)}/../../lib/action_controller/assertions/abc")] - end - rescue => caught - assert !caught.backtrace.empty? - end -end - -class InferringClassNameTest < ActionController::TestCase - def test_determine_controller_class - assert_equal ContentController, determine_class("ContentControllerTest") - end - - def test_determine_controller_class_with_nonsense_name - assert_nil determine_class("HelloGoodBye") - end - - def test_determine_controller_class_with_sensible_name_where_no_controller_exists - assert_nil determine_class("NoControllerWithThisNameTest") - end - - private - def determine_class(name) - ActionController::TestCase.determine_default_controller_class(name) - end -end - -class CrazyNameTest < ActionController::TestCase - tests ContentController - - def test_controller_class_can_be_set_manually_not_just_inferred - assert_equal ContentController, self.class.controller_class - end -end - -class NamedRoutesControllerTest < ActionController::TestCase - tests ContentController - - def test_should_be_able_to_use_named_routes_before_a_request_is_done - with_routing do |set| - set.draw { |map| map.resources :contents } - assert_equal 'http://test.host/contents/new', new_content_url - assert_equal 'http://test.host/contents/1', content_url(:id => 1) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/translation_test.rb b/vendor/rails/actionpack/test/controller/translation_test.rb deleted file mode 100644 index 0bf61a65..00000000 --- a/vendor/rails/actionpack/test/controller/translation_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'abstract_unit' - -# class TranslatingController < ActionController::Base -# end - -class TranslationControllerTest < Test::Unit::TestCase - def setup - @controller = ActionController::Base.new - end - - def test_action_controller_base_responds_to_translate - assert @controller.respond_to?(:translate) - end - - def test_action_controller_base_responds_to_t - assert @controller.respond_to?(:t) - end - - def test_action_controller_base_responds_to_localize - assert @controller.respond_to?(:localize) - end - - def test_action_controller_base_responds_to_l - assert @controller.respond_to?(:l) - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/url_rewriter_test.rb b/vendor/rails/actionpack/test/controller/url_rewriter_test.rb deleted file mode 100644 index 11add3a8..00000000 --- a/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +++ /dev/null @@ -1,395 +0,0 @@ -require 'abstract_unit' - -ActionController::UrlRewriter - -class UrlRewriterTests < ActionController::TestCase - def setup - @request = ActionController::TestRequest.new - @params = {} - @rewriter = ActionController::UrlRewriter.new(@request, @params) - end - - def test_port - assert_equal('http://test.host:1271/c/a/i', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :port => 1271) - ) - end - - def test_protocol_with_and_without_separator - assert_equal('https://test.host/c/a/i', - @rewriter.rewrite(:protocol => 'https', :controller => 'c', :action => 'a', :id => 'i') - ) - - assert_equal('https://test.host/c/a/i', - @rewriter.rewrite(:protocol => 'https://', :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_user_name_and_password - assert_equal( - 'http://david:secret@test.host/c/a/i', - @rewriter.rewrite(:user => "david", :password => "secret", :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_user_name_and_password_with_escape_codes - assert_equal( - 'http://openid.aol.com%2Fnextangler:one+two%3F@test.host/c/a/i', - @rewriter.rewrite(:user => "openid.aol.com/nextangler", :password => "one two?", :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_anchor - assert_equal( - 'http://test.host/c/a/i#anchor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => 'anchor') - ) - end - - def test_anchor_should_call_to_param - assert_equal( - 'http://test.host/c/a/i#anchor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anchor')) - ) - end - - def test_anchor_should_be_cgi_escaped - assert_equal( - 'http://test.host/c/a/i#anc%2Fhor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anc/hor')) - ) - end - - def test_overwrite_params - @params[:controller] = 'hi' - @params[:action] = 'bye' - @params[:id] = '2' - - assert_deprecated /overwrite_params/ do - assert_equal '/hi/hi/2', @rewriter.rewrite(:only_path => true, :overwrite_params => {:action => 'hi'}) - u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:action => 'hi'}) - assert_match %r(/hi/hi/2$), u - end - end - - def test_overwrite_removes_original - @params[:controller] = 'search' - @params[:action] = 'list' - @params[:list_page] = 1 - - assert_deprecated /overwrite_params/ do - assert_equal '/search/list?list_page=2', @rewriter.rewrite(:only_path => true, :overwrite_params => {"list_page" => 2}) - u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:list_page => 2}) - assert_equal 'http://test.host/search/list?list_page=2', u - end - end - - def test_to_str - @params[:controller] = 'hi' - @params[:action] = 'bye' - @request.parameters[:id] = '2' - - assert_equal 'http://, test.host, /, hi, bye, {"id"=>"2"}', @rewriter.to_str - end - - def test_trailing_slash - options = {:controller => 'foo', :action => 'bar', :id => '3', :only_path => true} - assert_equal '/foo/bar/3', @rewriter.rewrite(options) - assert_equal '/foo/bar/3?query=string', @rewriter.rewrite(options.merge({:query => 'string'})) - options.update({:trailing_slash => true}) - assert_equal '/foo/bar/3/', @rewriter.rewrite(options) - options.update({:query => 'string'}) - assert_equal '/foo/bar/3/?query=string', @rewriter.rewrite(options) - end -end - -class UrlWriterTests < ActionController::TestCase - class W - include ActionController::UrlWriter - end - - def teardown - W.default_url_options.clear - end - - def add_host! - W.default_url_options[:host] = 'www.basecamphq.com' - end - - def test_exception_is_thrown_without_host - assert_raise RuntimeError do - W.new.url_for :controller => 'c', :action => 'a', :id => 'i' - end - end - - def test_anchor - assert_equal('/c/a#anchor', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => 'anchor') - ) - end - - def test_anchor_should_call_to_param - assert_equal('/c/a#anchor', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => Struct.new(:to_param).new('anchor')) - ) - end - - def test_anchor_should_escape_unsafe_pchar - assert_equal('/c/a#%23anchor', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => Struct.new(:to_param).new('#anchor')) - ) - end - - def test_anchor_should_not_escape_safe_pchar - assert_equal('/c/a#name=user&email=user@domain.com', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => Struct.new(:to_param).new('name=user&email=user@domain.com')) - ) - end - - def test_default_host - add_host! - assert_equal('http://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_host_may_be_overridden - add_host! - assert_equal('http://37signals.basecamphq.com/c/a/i', - W.new.url_for(:host => '37signals.basecamphq.com', :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_port - add_host! - assert_equal('http://www.basecamphq.com:3000/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :port => 3000) - ) - end - - def test_protocol - add_host! - assert_equal('https://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') - ) - end - - def test_protocol_with_and_without_separator - add_host! - assert_equal('https://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') - ) - assert_equal('https://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https://') - ) - end - - def test_trailing_slash - add_host! - options = {:controller => 'foo', :trailing_slash => true, :action => 'bar', :id => '33'} - assert_equal('http://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) ) - end - - def test_trailing_slash_with_protocol - add_host! - options = { :trailing_slash => true,:protocol => 'https', :controller => 'foo', :action => 'bar', :id => '33'} - assert_equal('https://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) ) - assert_equal 'https://www.basecamphq.com/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string'})) - end - - def test_trailing_slash_with_only_path - options = {:controller => 'foo', :trailing_slash => true} - assert_equal '/foo/', W.new.url_for(options.merge({:only_path => true})) - options.update({:action => 'bar', :id => '33'}) - assert_equal '/foo/bar/33/', W.new.url_for(options.merge({:only_path => true})) - assert_equal '/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string',:only_path => true})) - end - - def test_trailing_slash_with_anchor - options = {:trailing_slash => true, :controller => 'foo', :action => 'bar', :id => '33', :only_path => true, :anchor=> 'chapter7'} - assert_equal '/foo/bar/33/#chapter7', W.new.url_for(options) - assert_equal '/foo/bar/33/?query=string#chapter7', W.new.url_for(options.merge({:query => 'string'})) - end - - def test_trailing_slash_with_params - url = W.new.url_for(:trailing_slash => true, :only_path => true, :controller => 'cont', :action => 'act', :p1 => 'cafe', :p2 => 'link') - params = extract_params(url) - assert_equal params[0], { :p1 => 'cafe' }.to_query - assert_equal params[1], { :p2 => 'link' }.to_query - end - - def test_relative_url_root_is_respected - orig_relative_url_root = ActionController::Base.relative_url_root - ActionController::Base.relative_url_root = '/subdir' - - add_host! - assert_equal('https://www.basecamphq.com/subdir/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') - ) - ensure - ActionController::Base.relative_url_root = orig_relative_url_root - end - - def test_named_routes - ActionController::Routing::Routes.draw do |map| - map.no_args '/this/is/verbose', :controller => 'home', :action => 'index' - map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' - map.connect ':controller/:action/:id' - end - - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - assert controller.respond_to?(:home_url) - assert_equal 'http://www.basecamphq.com/home/sweet/home/again', - controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') - - assert_equal("/home/sweet/home/alabama", controller.send(:home_path, :user => 'alabama', :host => 'unused')) - assert_equal("http://www.basecamphq.com/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'www.basecamphq.com')) - assert_equal("http://www.basecamphq.com/this/is/verbose", controller.send(:no_args_url, :host=>'www.basecamphq.com')) - ensure - ActionController::Routing::Routes.load! - end - - def test_relative_url_root_is_respected_for_named_routes - orig_relative_url_root = ActionController::Base.relative_url_root - ActionController::Base.relative_url_root = '/subdir' - - ActionController::Routing::Routes.draw do |map| - map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' - end - - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - - assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again', - controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') - ensure - ActionController::Routing::Routes.load! - ActionController::Base.relative_url_root = orig_relative_url_root - end - - def test_only_path - ActionController::Routing::Routes.draw do |map| - map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' - map.connect ':controller/:action/:id' - end - - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - assert controller.respond_to?(:home_url) - assert_equal '/brave/new/world', - controller.send(:url_for, :controller => 'brave', :action => 'new', :id => 'world', :only_path => true) - - assert_equal("/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'unused', :only_path => true)) - assert_equal("/home/sweet/home/alabama", controller.send(:home_path, 'alabama')) - ensure - ActionController::Routing::Routes.load! - end - - def test_one_parameter - assert_equal('/c/a?param=val', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :param => 'val') - ) - end - - def test_two_parameters - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :p1 => 'X1', :p2 => 'Y2') - params = extract_params(url) - assert_equal params[0], { :p1 => 'X1' }.to_query - assert_equal params[1], { :p2 => 'Y2' }.to_query - end - - def test_hash_parameter - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => {:name => 'Bob', :category => 'prof'}) - params = extract_params(url) - assert_equal params[0], { 'query[category]' => 'prof' }.to_query - assert_equal params[1], { 'query[name]' => 'Bob' }.to_query - end - - def test_array_parameter - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => ['Bob', 'prof']) - params = extract_params(url) - assert_equal params[0], { 'query[]' => 'Bob' }.to_query - assert_equal params[1], { 'query[]' => 'prof' }.to_query - end - - def test_hash_recursive_parameters - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => {:person => {:name => 'Bob', :position => 'prof'}, :hobby => 'piercing'}) - params = extract_params(url) - assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query - assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query - assert_equal params[2], { 'query[person][position]' => 'prof' }.to_query - end - - def test_hash_recursive_and_array_parameters - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :id => 101, :query => {:person => {:name => 'Bob', :position => ['prof', 'art director']}, :hobby => 'piercing'}) - assert_match %r(^/c/a/101), url - params = extract_params(url) - assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query - assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query - assert_equal params[2], { 'query[person][position][]' => 'prof' }.to_query - assert_equal params[3], { 'query[person][position][]' => 'art director' }.to_query - end - - def test_path_generation_for_symbol_parameter_keys - assert_generates("/image", :controller=> :image) - end - - def test_named_routes_with_nil_keys - ActionController::Routing::Routes.clear! - ActionController::Routing::Routes.draw do |map| - map.main '', :controller => 'posts', :format => nil - map.resources :posts - map.connect ':controller/:action/:id' - end - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - kls.default_url_options[:host] = 'www.basecamphq.com' - - controller = kls.new - params = {:action => :index, :controller => :posts, :format => :xml} - assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params)) - params[:format] = nil - assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params)) - ensure - ActionController::Routing::Routes.load! - end - - def test_formatted_url_methods_are_deprecated - ActionController::Routing::Routes.draw do |map| - map.resources :posts - end - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - params = {:id => 1, :format => :xml} - assert_deprecated do - assert_equal("/posts/1.xml", controller.send(:formatted_post_path, params)) - end - assert_deprecated do - assert_equal("/posts/1.xml", controller.send(:formatted_post_path, 1, :xml)) - end - ensure - ActionController::Routing::Routes.load! - end - - def test_multiple_includes_maintain_distinct_options - first_class = Class.new { include ActionController::UrlWriter } - second_class = Class.new { include ActionController::UrlWriter } - - first_host, second_host = 'firsthost.com', 'secondhost.com' - - first_class.default_url_options[:host] = first_host - second_class.default_url_options[:host] = second_host - - assert_equal first_class.default_url_options[:host], first_host - assert_equal second_class.default_url_options[:host], second_host - end - - private - def extract_params(url) - url.split('?', 2).last.split('&') - end -end diff --git a/vendor/rails/actionpack/test/controller/verification_test.rb b/vendor/rails/actionpack/test/controller/verification_test.rb deleted file mode 100644 index 418a81ba..00000000 --- a/vendor/rails/actionpack/test/controller/verification_test.rb +++ /dev/null @@ -1,270 +0,0 @@ -require 'abstract_unit' - -class VerificationTest < ActionController::TestCase - class TestController < ActionController::Base - verify :only => :guarded_one, :params => "one", - :add_flash => { :error => 'unguarded' }, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_two, :params => %w( one two ), - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_with_flash, :params => "one", - :add_flash => { :notice => "prereqs failed" }, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_in_session, :session => "one", - :redirect_to => { :action => "unguarded" } - - verify :only => [:multi_one, :multi_two], :session => %w( one two ), - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_by_method, :method => :post, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_by_xhr, :xhr => true, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_by_not_xhr, :xhr => false, - :redirect_to => { :action => "unguarded" } - - before_filter :unconditional_redirect, :only => :two_redirects - verify :only => :two_redirects, :method => :post, - :redirect_to => { :action => "unguarded" } - - verify :only => :must_be_post, :method => :post, :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } - - verify :only => :guarded_one_for_named_route_test, :params => "one", - :redirect_to => :foo_url - - verify :only => :no_default_action, :params => "santa" - - verify :only => :guarded_with_back, :method => :post, - :redirect_to => :back - - def guarded_one - render :text => "#{params[:one]}" - end - - def guarded_one_for_named_route_test - render :text => "#{params[:one]}" - end - - def guarded_with_flash - render :text => "#{params[:one]}" - end - - def guarded_two - render :text => "#{params[:one]}:#{params[:two]}" - end - - def guarded_in_session - render :text => "#{session["one"]}" - end - - def multi_one - render :text => "#{session["one"]}:#{session["two"]}" - end - - def multi_two - render :text => "#{session["two"]}:#{session["one"]}" - end - - def guarded_by_method - render :text => "#{request.method}" - end - - def guarded_by_xhr - render :text => "#{request.xhr?}" - end - - def guarded_by_not_xhr - render :text => "#{request.xhr?}" - end - - def unguarded - render :text => "#{params[:one]}" - end - - def two_redirects - render :nothing => true - end - - def must_be_post - render :text => "Was a post!" - end - - def guarded_with_back - render :text => "#{params[:one]}" - end - - def no_default_action - # Will never run - end - - protected - def rescue_action(e) raise end - - def unconditional_redirect - redirect_to :action => "unguarded" - end - end - - def setup - @controller = TestController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo' - end - - def test_using_symbol_back_with_no_referrer - assert_raise(ActionController::RedirectBackError) { get :guarded_with_back } - end - - def test_using_symbol_back_redirects_to_referrer - @request.env["HTTP_REFERER"] = "/foo" - get :guarded_with_back - assert_redirected_to '/foo' - end - - def test_no_deprecation_warning_for_named_route - assert_not_deprecated do - get :guarded_one_for_named_route_test, :two => "not one" - assert_redirected_to '/foo' - end - end - - def test_guarded_one_with_prereqs - get :guarded_one, :one => "here" - assert_equal "here", @response.body - end - - def test_guarded_one_without_prereqs - get :guarded_one - assert_redirected_to :action => "unguarded" - assert_equal 'unguarded', flash[:error] - end - - def test_guarded_with_flash_with_prereqs - get :guarded_with_flash, :one => "here" - assert_equal "here", @response.body - assert flash.empty? - end - - def test_guarded_with_flash_without_prereqs - get :guarded_with_flash - assert_redirected_to :action => "unguarded" - assert_equal "prereqs failed", flash[:notice] - end - - def test_guarded_two_with_prereqs - get :guarded_two, :one => "here", :two => "there" - assert_equal "here:there", @response.body - end - - def test_guarded_two_without_prereqs_one - get :guarded_two, :two => "there" - assert_redirected_to :action => "unguarded" - end - - def test_guarded_two_without_prereqs_two - get :guarded_two, :one => "here" - assert_redirected_to :action => "unguarded" - end - - def test_guarded_two_without_prereqs_both - get :guarded_two - assert_redirected_to :action => "unguarded" - end - - def test_unguarded_with_params - get :unguarded, :one => "here" - assert_equal "here", @response.body - end - - def test_unguarded_without_params - get :unguarded - assert_equal "", @response.body - end - - def test_guarded_in_session_with_prereqs - get :guarded_in_session, {}, "one" => "here" - assert_equal "here", @response.body - end - - def test_guarded_in_session_without_prereqs - get :guarded_in_session - assert_redirected_to :action => "unguarded" - end - - def test_multi_one_with_prereqs - get :multi_one, {}, "one" => "here", "two" => "there" - assert_equal "here:there", @response.body - end - - def test_multi_one_without_prereqs - get :multi_one - assert_redirected_to :action => "unguarded" - end - - def test_multi_two_with_prereqs - get :multi_two, {}, "one" => "here", "two" => "there" - assert_equal "there:here", @response.body - end - - def test_multi_two_without_prereqs - get :multi_two - assert_redirected_to :action => "unguarded" - end - - def test_guarded_by_method_with_prereqs - post :guarded_by_method - assert_equal "post", @response.body - end - - def test_guarded_by_method_without_prereqs - get :guarded_by_method - assert_redirected_to :action => "unguarded" - end - - def test_guarded_by_xhr_with_prereqs - xhr :post, :guarded_by_xhr - assert_equal "true", @response.body - end - - def test_guarded_by_xhr_without_prereqs - get :guarded_by_xhr - assert_redirected_to :action => "unguarded" - end - - def test_guarded_by_not_xhr_with_prereqs - get :guarded_by_not_xhr - assert_equal "false", @response.body - end - - def test_guarded_by_not_xhr_without_prereqs - xhr :post, :guarded_by_not_xhr - assert_redirected_to :action => "unguarded" - end - - def test_guarded_post_and_calls_render_succeeds - post :must_be_post - assert_equal "Was a post!", @response.body - end - - def test_default_failure_should_be_a_bad_request - post :no_default_action - assert_response :bad_request - end - - def test_guarded_post_and_calls_render_fails_and_sets_allow_header - get :must_be_post - assert_response 405 - assert_equal "Must be post", @response.body - assert_equal "POST", @response.headers["Allow"] - end - - def test_second_redirect - assert_nothing_raised { get :two_redirects } - end -end diff --git a/vendor/rails/actionpack/test/controller/view_paths_test.rb b/vendor/rails/actionpack/test/controller/view_paths_test.rb deleted file mode 100644 index 8ea13fbe..00000000 --- a/vendor/rails/actionpack/test/controller/view_paths_test.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'abstract_unit' - -class ViewLoadPathsTest < ActionController::TestCase - class TestController < ActionController::Base - def self.controller_path() "test" end - def rescue_action(e) raise end - - before_filter :add_view_path, :only => :hello_world_at_request_time - - def hello_world() end - def hello_world_at_request_time() render(:action => 'hello_world') end - - private - def add_view_path - prepend_view_path "#{FIXTURE_LOAD_PATH}/override" - end - end - - class Test::SubController < ActionController::Base - layout 'test/sub' - def hello_world; render(:template => 'test/hello_world'); end - end - - def setup - TestController.view_paths = nil - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @controller = TestController.new - # Following is needed in order to setup @controller.template object properly - @controller.send :initialize_template_class, @response - @controller.send :assign_shortcuts, @request, @response - - # Track the last warning. - @old_behavior = ActiveSupport::Deprecation.behavior - @last_message = nil - ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message } - end - - def teardown - ActiveSupport::Deprecation.behavior = @old_behavior - end - - def test_template_load_path_was_set_correctly - assert_equal [FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - end - - def test_controller_appends_view_path_correctly - @controller.append_view_path 'foo' - assert_equal [FIXTURE_LOAD_PATH, 'foo'], @controller.view_paths.map(&:to_s) - - @controller.append_view_path(%w(bar baz)) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths.map(&:to_s) - - @controller.append_view_path(FIXTURE_LOAD_PATH) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - end - - def test_controller_prepends_view_path_correctly - @controller.prepend_view_path 'baz' - assert_equal ['baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - - @controller.prepend_view_path(%w(foo bar)) - assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - - @controller.prepend_view_path(FIXTURE_LOAD_PATH) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - end - - def test_template_appends_view_path_correctly - @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) - class_view_paths = TestController.view_paths - - @controller.append_view_path 'foo' - assert_equal [FIXTURE_LOAD_PATH, 'foo'], @controller.view_paths.map(&:to_s) - - @controller.append_view_path(%w(bar baz)) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths.map(&:to_s) - assert_equal class_view_paths, TestController.view_paths - end - - def test_template_prepends_view_path_correctly - @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) - class_view_paths = TestController.view_paths - - @controller.prepend_view_path 'baz' - assert_equal ['baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - - @controller.prepend_view_path(%w(foo bar)) - assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - assert_equal class_view_paths, TestController.view_paths - end - - def test_view_paths - get :hello_world - assert_response :success - assert_equal "Hello world!", @response.body - end - - def test_view_paths_override - TestController.prepend_view_path "#{FIXTURE_LOAD_PATH}/override" - get :hello_world - assert_response :success - assert_equal "Hello overridden world!", @response.body - end - - def test_view_paths_override_for_layouts_in_controllers_with_a_module - @controller = Test::SubController.new - Test::SubController.view_paths = [ "#{FIXTURE_LOAD_PATH}/override", FIXTURE_LOAD_PATH, "#{FIXTURE_LOAD_PATH}/override2" ] - get :hello_world - assert_response :success - assert_equal "layout: Hello overridden world!", @response.body - end - - def test_view_paths_override_at_request_time - get :hello_world_at_request_time - assert_response :success - assert_equal "Hello overridden world!", @response.body - end - - def test_inheritance - original_load_paths = ActionController::Base.view_paths - - self.class.class_eval %{ - class A < ActionController::Base; end - class B < A; end - class C < ActionController::Base; end - } - - A.view_paths = ['a/path'] - - assert_equal ['a/path'], A.view_paths.map(&:to_s) - assert_equal A.view_paths, B.view_paths - assert_equal original_load_paths, C.view_paths - - C.view_paths = [] - assert_nothing_raised { C.view_paths << 'c/path' } - assert_equal ['c/path'], C.view_paths.map(&:to_s) - end -end diff --git a/vendor/rails/actionpack/test/controller/webservice_test.rb b/vendor/rails/actionpack/test/controller/webservice_test.rb deleted file mode 100644 index e89d6bb9..00000000 --- a/vendor/rails/actionpack/test/controller/webservice_test.rb +++ /dev/null @@ -1,260 +0,0 @@ -require 'abstract_unit' - -class WebServiceTest < ActionController::IntegrationTest - class TestController < ActionController::Base - def assign_parameters - if params[:full] - render :text => dump_params_keys - else - render :text => (params.keys - ['controller', 'action']).sort.join(", ") - end - end - - def dump_params_keys(hash = params) - hash.keys.sort.inject("") do |s, k| - value = hash[k] - value = Hash === value ? "(#{dump_params_keys(value)})" : "" - s << ", " unless s.empty? - s << "#{k}#{value}" - end - end - - def rescue_action(e) raise end - end - - def setup - @controller = TestController.new - @default_param_parsers = ActionController::Base.param_parsers.dup - end - - def teardown - ActionController::Base.param_parsers = @default_param_parsers - end - - def test_check_parameters - with_test_route_set do - get "/" - assert_equal '', @controller.response.body - end - end - - def test_post_xml - with_test_route_set do - post "/", '<entry attributed="true"><summary>content...</summary></entry>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'content...', @controller.params["entry"]['summary'] - assert_equal 'true', @controller.params["entry"]['attributed'] - end - end - - def test_put_xml - with_test_route_set do - put "/", '<entry attributed="true"><summary>content...</summary></entry>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'content...', @controller.params["entry"]['summary'] - assert_equal 'true', @controller.params["entry"]['attributed'] - end - end - - def test_put_xml_using_a_type_node - with_test_route_set do - put "/", '<type attributed="true"><summary>content...</summary></type>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'type', @controller.response.body - assert @controller.params.has_key?(:type) - assert_equal 'content...', @controller.params["type"]['summary'] - assert_equal 'true', @controller.params["type"]['attributed'] - end - end - - def test_put_xml_using_a_type_node_and_attribute - with_test_route_set do - put "/", '<type attributed="true"><summary type="boolean">false</summary></type>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'type', @controller.response.body - assert @controller.params.has_key?(:type) - assert_equal false, @controller.params["type"]['summary'] - assert_equal 'true', @controller.params["type"]['attributed'] - end - end - - def test_post_xml_using_a_type_node - with_test_route_set do - post "/", '<font attributed="true"><type>arial</type></font>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'font', @controller.response.body - assert @controller.params.has_key?(:font) - assert_equal 'arial', @controller.params['font']['type'] - assert_equal 'true', @controller.params["font"]['attributed'] - end - end - - def test_post_xml_using_a_root_node_named_type - with_test_route_set do - post "/", '<type type="integer">33</type>', - {'CONTENT_TYPE' => 'application/xml'} - - assert @controller.params.has_key?(:type) - assert_equal 33, @controller.params['type'] - end - end - - def test_post_xml_using_an_attributted_node_named_type - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = Proc.new { |data| Hash.from_xml(data)['request'].with_indifferent_access } - post "/", '<request><type type="string">Arial,12</type><z>3</z></request>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'type, z', @controller.response.body - assert @controller.params.has_key?(:type) - assert_equal 'Arial,12', @controller.params['type'], @controller.params.inspect - assert_equal '3', @controller.params['z'], @controller.params.inspect - end - end - - def test_register_and_use_yaml - with_test_route_set do - ActionController::Base.param_parsers[Mime::YAML] = Proc.new { |d| YAML.load(d) } - post "/", {"entry" => "loaded from yaml"}.to_yaml, - {'CONTENT_TYPE' => 'application/x-yaml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'loaded from yaml', @controller.params["entry"] - end - end - - def test_register_and_use_yaml_as_symbol - with_test_route_set do - ActionController::Base.param_parsers[Mime::YAML] = :yaml - post "/", {"entry" => "loaded from yaml"}.to_yaml, - {'CONTENT_TYPE' => 'application/x-yaml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'loaded from yaml', @controller.params["entry"] - end - end - - def test_register_and_use_xml_simple - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = Proc.new { |data| Hash.from_xml(data)['request'].with_indifferent_access } - post "/", '<request><summary>content...</summary><title>SimpleXml</title></request>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'summary, title', @controller.response.body - assert @controller.params.has_key?(:summary) - assert @controller.params.has_key?(:title) - assert_equal 'content...', @controller.params["summary"] - assert_equal 'SimpleXml', @controller.params["title"] - end - end - - def test_use_xml_ximple_with_empty_request - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - assert_nothing_raised { post "/", "", {'CONTENT_TYPE' => 'application/xml'} } - assert_equal "", @controller.response.body - end - end - - def test_dasherized_keys_as_xml - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - post "/?full=1", "<first-key>\n<sub-key>...</sub-key>\n</first-key>", - {'CONTENT_TYPE' => 'application/xml'} - assert_equal 'action, controller, first_key(sub_key), full', @controller.response.body - assert_equal "...", @controller.params[:first_key][:sub_key] - end - end - - def test_typecast_as_xml - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - xml = <<-XML - <data> - <a type="integer">15</a> - <b type="boolean">false</b> - <c type="boolean">true</c> - <d type="date">2005-03-17</d> - <e type="datetime">2005-03-17T21:41:07Z</e> - <f>unparsed</f> - <g type="integer">1</g> - <g>hello</g> - <g type="date">1974-07-25</g> - </data> - XML - post "/", xml, {'CONTENT_TYPE' => 'application/xml'} - - params = @controller.params - assert_equal 15, params[:data][:a] - assert_equal false, params[:data][:b] - assert_equal true, params[:data][:c] - assert_equal Date.new(2005,3,17), params[:data][:d] - assert_equal Time.utc(2005,3,17,21,41,7), params[:data][:e] - assert_equal "unparsed", params[:data][:f] - assert_equal [1, "hello", Date.new(1974,7,25)], params[:data][:g] - end - end - - def test_entities_unescaped_as_xml_simple - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - xml = <<-XML - <data>&lt;foo &quot;bar&apos;s&quot; &amp; friends&gt;</data> - XML - post "/", xml, {'CONTENT_TYPE' => 'application/xml'} - assert_equal %(<foo "bar's" & friends>), @controller.params[:data] - end - end - - def test_typecast_as_yaml - with_test_route_set do - ActionController::Base.param_parsers[Mime::YAML] = :yaml - yaml = <<-YAML - --- - data: - a: 15 - b: false - c: true - d: 2005-03-17 - e: 2005-03-17T21:41:07Z - f: unparsed - g: - - 1 - - hello - - 1974-07-25 - YAML - post "/", yaml, {'CONTENT_TYPE' => 'application/x-yaml'} - params = @controller.params - assert_equal 15, params[:data][:a] - assert_equal false, params[:data][:b] - assert_equal true, params[:data][:c] - assert_equal Date.new(2005,3,17), params[:data][:d] - assert_equal Time.utc(2005,3,17,21,41,7), params[:data][:e] - assert_equal "unparsed", params[:data][:f] - assert_equal [1, "hello", Date.new(1974,7,25)], params[:data][:g] - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "web_service_test/test" do |c| - c.connect "/", :action => "assign_parameters" - end - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/fixtures/_top_level_partial.html.erb b/vendor/rails/actionpack/test/fixtures/_top_level_partial.html.erb deleted file mode 100644 index 0b1c2e46..00000000 --- a/vendor/rails/actionpack/test/fixtures/_top_level_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -top level partial html \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb b/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb deleted file mode 100644 index 44f25b61..00000000 --- a/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb +++ /dev/null @@ -1 +0,0 @@ -top level partial \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/addresses/list.erb b/vendor/rails/actionpack/test/fixtures/addresses/list.erb deleted file mode 100644 index c75e01ee..00000000 --- a/vendor/rails/actionpack/test/fixtures/addresses/list.erb +++ /dev/null @@ -1 +0,0 @@ -We only need to get this far! diff --git a/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb b/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb deleted file mode 100644 index a956fce6..00000000 --- a/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module FooHelper - def baz() end -end diff --git a/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb b/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb deleted file mode 100644 index d22af431..00000000 --- a/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %> bad customer: <%= bad_customer.name %><%= bad_customer_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/companies.yml b/vendor/rails/actionpack/test/fixtures/companies.yml deleted file mode 100644 index 707f72ab..00000000 --- a/vendor/rails/actionpack/test/fixtures/companies.yml +++ /dev/null @@ -1,24 +0,0 @@ -thirty_seven_signals: - id: 1 - name: 37Signals - rating: 4 - -TextDrive: - id: 2 - name: TextDrive - rating: 4 - -PlanetArgon: - id: 3 - name: Planet Argon - rating: 4 - -Google: - id: 4 - name: Google - rating: 4 - -Ionist: - id: 5 - name: Ioni.st - rating: 4 \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/company.rb b/vendor/rails/actionpack/test/fixtures/company.rb deleted file mode 100644 index cbbd0edb..00000000 --- a/vendor/rails/actionpack/test/fixtures/company.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Company < ActiveRecord::Base - has_one :mascot - attr_protected :rating - set_sequence_name :companies_nonstd_seq - - validates_presence_of :name - def validate - errors.add('rating', 'rating should not be 2') if rating == 2 - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml b/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml deleted file mode 100644 index 25dc7468..00000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +++ /dev/null @@ -1 +0,0 @@ -<hello>world</hello> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml b/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml deleted file mode 100644 index c7926d48..00000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%= 'hello world!' %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs b/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs deleted file mode 100644 index 8d614d04..00000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs +++ /dev/null @@ -1 +0,0 @@ -page.alert 'hello world!' \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml b/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml deleted file mode 100644 index 598d62e2..00000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml +++ /dev/null @@ -1 +0,0 @@ -xml.p "Hello world!" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb b/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb deleted file mode 100644 index 483571e2..00000000 --- a/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %>: <%= customer.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql b/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql deleted file mode 100644 index 8e1947d1..00000000 --- a/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql +++ /dev/null @@ -1,49 +0,0 @@ -CREATE TABLE 'companies' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL, - 'rating' INTEGER DEFAULT 1 -); - -CREATE TABLE 'replies' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'content' text, - 'created_at' datetime, - 'updated_at' datetime, - 'topic_id' integer, - 'developer_id' integer -); - -CREATE TABLE 'topics' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'title' varchar(255), - 'subtitle' varchar(255), - 'content' text, - 'created_at' datetime, - 'updated_at' datetime -); - -CREATE TABLE 'developers' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL, - 'salary' INTEGER DEFAULT 70000, - 'created_at' DATETIME DEFAULT NULL, - 'updated_at' DATETIME DEFAULT NULL -); - -CREATE TABLE 'projects' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL -); - -CREATE TABLE 'developers_projects' ( - 'developer_id' INTEGER NOT NULL, - 'project_id' INTEGER NOT NULL, - 'joined_on' DATE DEFAULT NULL, - 'access_level' INTEGER DEFAULT 1 -); - -CREATE TABLE 'mascots' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'company_id' INTEGER NOT NULL, - 'name' TEXT DEFAULT NULL -); \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/developer.rb b/vendor/rails/actionpack/test/fixtures/developer.rb deleted file mode 100644 index c70eda34..00000000 --- a/vendor/rails/actionpack/test/fixtures/developer.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects - has_many :replies - has_many :topics, :through => :replies -end - -class DeVeLoPeR < ActiveRecord::Base - set_table_name "developers" -end diff --git a/vendor/rails/actionpack/test/fixtures/developers.yml b/vendor/rails/actionpack/test/fixtures/developers.yml deleted file mode 100644 index 308bf75d..00000000 --- a/vendor/rails/actionpack/test/fixtures/developers.yml +++ /dev/null @@ -1,21 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - -jamis: - id: 2 - name: Jamis - salary: 150000 - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/developers/_developer.erb b/vendor/rails/actionpack/test/fixtures/developers/_developer.erb deleted file mode 100644 index 904a3137..00000000 --- a/vendor/rails/actionpack/test/fixtures/developers/_developer.erb +++ /dev/null @@ -1 +0,0 @@ -<%= developer.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/developers_projects.yml b/vendor/rails/actionpack/test/fixtures/developers_projects.yml deleted file mode 100644 index cee359c7..00000000 --- a/vendor/rails/actionpack/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,13 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/failsafe/500.html b/vendor/rails/actionpack/test/fixtures/failsafe/500.html deleted file mode 100644 index f3af84d6..00000000 --- a/vendor/rails/actionpack/test/fixtures/failsafe/500.html +++ /dev/null @@ -1 +0,0 @@ -hello <%= "my" %> world \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/fun/games/_game.erb b/vendor/rails/actionpack/test/fixtures/fun/games/_game.erb deleted file mode 100644 index d51b7b3e..00000000 --- a/vendor/rails/actionpack/test/fixtures/fun/games/_game.erb +++ /dev/null @@ -1 +0,0 @@ -<%= game.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb b/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb deleted file mode 100644 index 1ebfbe25..00000000 --- a/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb +++ /dev/null @@ -1 +0,0 @@ -Living in a nested world \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/fun/serious/games/_game.erb b/vendor/rails/actionpack/test/fixtures/fun/serious/games/_game.erb deleted file mode 100644 index d51b7b3e..00000000 --- a/vendor/rails/actionpack/test/fixtures/fun/serious/games/_game.erb +++ /dev/null @@ -1 +0,0 @@ -<%= game.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb deleted file mode 100644 index d0e4f72b..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% cache do %> -Fragment caching in a partial -<% end %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb deleted file mode 100644 index d7f43ad9..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<body> -<% cache do %><p>ERB</p><% end %> -</body> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs b/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs deleted file mode 100644 index 057f15e6..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +++ /dev/null @@ -1,6 +0,0 @@ -page.assign 'title', 'Hey' -cache do - page['element_1'].visual_effect :highlight - page['element_2'].visual_effect :highlight -end -page.assign 'footer', 'Bye' diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder b/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder deleted file mode 100644 index efdcc28e..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +++ /dev/null @@ -1,5 +0,0 @@ -xml.body do - cache do - xml.p "Builder" - end -end diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb deleted file mode 100644 index 268a298a..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Hello -<% cache do %>This bit's fragment cached<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb deleted file mode 100644 index a9462d34..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => 'partial' %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb deleted file mode 100644 index 87309b8c..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= render :inline => 'Some inline content' %> -<% cache do %>Some cached content<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs b/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs deleted file mode 100644 index 248842c9..00000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page.replace_html 'notices', :partial => 'partial' \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb b/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb deleted file mode 100644 index a2d97ebc..00000000 --- a/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %> good customer: <%= good_customer.name %><%= good_customer_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb b/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb deleted file mode 100644 index 7104ff37..00000000 --- a/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module AbcHelper - def bare_a() end - def bare_b() end - def bare_c() end -end diff --git a/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb b/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb deleted file mode 100644 index bf60d9db..00000000 --- a/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Fun::GamesHelper - def stratego() "Iz guuut!" end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb b/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb deleted file mode 100644 index c4aea5a3..00000000 --- a/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Fun::PdfHelper - def foobar() 'baz' end -end diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/abs_path_layout.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/abs_path_layout.rhtml deleted file mode 100644 index 8ba6e704..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/abs_path_layout.rhtml +++ /dev/null @@ -1 +0,0 @@ -abs_path_layout.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml deleted file mode 100644 index fcda6cf9..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml +++ /dev/null @@ -1 +0,0 @@ -alt/hello.rhtml diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/alt/layouts/alt.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/alt/layouts/alt.rhtml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml deleted file mode 100644 index 5f86a7de..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +++ /dev/null @@ -1 +0,0 @@ -controller_name_space/nested.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml deleted file mode 100644 index 1bc7cbda..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml +++ /dev/null @@ -1 +0,0 @@ -item.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml deleted file mode 100644 index c0f2642b..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml +++ /dev/null @@ -1 +0,0 @@ -layout_test.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb deleted file mode 100644 index 3b65e54f..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +++ /dev/null @@ -1 +0,0 @@ -multiple_extensions.html.erb <%= yield %> diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab deleted file mode 100644 index 018abfb0..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab +++ /dev/null @@ -1 +0,0 @@ -Mab \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml deleted file mode 100644 index bbccf091..00000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml +++ /dev/null @@ -1 +0,0 @@ -hello.rhtml \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb b/vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb deleted file mode 100644 index 96db002b..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<div id="column"><%= yield :column %></div> -<div id="content"><%= yield %></div> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb b/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb deleted file mode 100644 index 6a8b4191..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% render(:layout => "layout_for_partial", :locals => { :name => "Anthony" }) do %>Inside from first block in layout<% end %> -<%= yield %> -<% render(:layout => "layout_for_partial", :locals => { :name => "Ramm" }) do %>Inside from second block in layout<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/layouts/builder.builder b/vendor/rails/actionpack/test/fixtures/layouts/builder.builder deleted file mode 100644 index 729af4b8..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/builder.builder +++ /dev/null @@ -1,3 +0,0 @@ -xml.wrapper do - xml << @content_for_layout -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/default_html.html.erb b/vendor/rails/actionpack/test/fixtures/layouts/default_html.html.erb deleted file mode 100644 index edd71911..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/default_html.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><%= @content_for_layout %></html> diff --git a/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb b/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb deleted file mode 100644 index a0349d73..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= render( :layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => {:name => 'Anthony' } ) %> -<%= yield %> -<%= render( :layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => {:name => 'Ramm' } ) %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/standard.erb b/vendor/rails/actionpack/test/fixtures/layouts/standard.erb deleted file mode 100644 index 368764e6..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/standard.erb +++ /dev/null @@ -1 +0,0 @@ -<html><%= @content_for_layout %><%= @variable_for_layout %></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb b/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb deleted file mode 100644 index 187aab07..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb +++ /dev/null @@ -1,2 +0,0 @@ -<title><%= @title || @content_for_title %></title> -<%= @content_for_layout -%> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb b/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb deleted file mode 100644 index 85285324..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -XHR! -<%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/yield.erb b/vendor/rails/actionpack/test/fixtures/layouts/yield.erb deleted file mode 100644 index 482dc902..00000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/yield.erb +++ /dev/null @@ -1,2 +0,0 @@ -<title><%= yield :title %></title> -<%= yield %> diff --git a/vendor/rails/actionpack/test/fixtures/localized/hello_world.de.html b/vendor/rails/actionpack/test/fixtures/localized/hello_world.de.html deleted file mode 100644 index 4727d7a7..00000000 --- a/vendor/rails/actionpack/test/fixtures/localized/hello_world.de.html +++ /dev/null @@ -1 +0,0 @@ -Gutten Tag \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/localized/hello_world.en.html b/vendor/rails/actionpack/test/fixtures/localized/hello_world.en.html deleted file mode 100644 index 5e1c309d..00000000 --- a/vendor/rails/actionpack/test/fixtures/localized/hello_world.en.html +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/mascot.rb b/vendor/rails/actionpack/test/fixtures/mascot.rb deleted file mode 100644 index f9f1448b..00000000 --- a/vendor/rails/actionpack/test/fixtures/mascot.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Mascot < ActiveRecord::Base - belongs_to :company -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/mascots.yml b/vendor/rails/actionpack/test/fixtures/mascots.yml deleted file mode 100644 index 17b7dff4..00000000 --- a/vendor/rails/actionpack/test/fixtures/mascots.yml +++ /dev/null @@ -1,4 +0,0 @@ -upload_bird: - id: 1 - company_id: 1 - name: The Upload Bird \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb b/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb deleted file mode 100644 index 432773a1..00000000 --- a/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= mascot.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/multipart/binary_file b/vendor/rails/actionpack/test/fixtures/multipart/binary_file deleted file mode 100644 index 556187ac..00000000 Binary files a/vendor/rails/actionpack/test/fixtures/multipart/binary_file and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file b/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file deleted file mode 100644 index 889c4aab..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="file"; filename="file.txt" -Content-Type: text/plain - -bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param b/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param deleted file mode 100644 index 096bd8a1..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param +++ /dev/null @@ -1,5 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo[baz]" - -bar ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/empty b/vendor/rails/actionpack/test/fixtures/multipart/empty deleted file mode 100644 index f0f79835..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/empty +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="file1.txt" -Content-Type: text/plain - - ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/hello.txt b/vendor/rails/actionpack/test/fixtures/multipart/hello.txt deleted file mode 100644 index 5ab2f8a4..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/hello.txt +++ /dev/null @@ -1 +0,0 @@ -Hello \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/multipart/large_text_file b/vendor/rails/actionpack/test/fixtures/multipart/large_text_file deleted file mode 100644 index 7f97fb1d..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x -Content-Disposition: form-data; name="file"; filename="file.txt" -Content-Type: text/plain - -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/mixed_files b/vendor/rails/actionpack/test/fixtures/multipart/mixed_files deleted file mode 100644 index 5eba7a6b..00000000 Binary files a/vendor/rails/actionpack/test/fixtures/multipart/mixed_files and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg b/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg deleted file mode 100644 index 5cf3bef3..00000000 Binary files a/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/multipart/none b/vendor/rails/actionpack/test/fixtures/multipart/none deleted file mode 100644 index d66f4730..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/none +++ /dev/null @@ -1,9 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="" - - ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/single_parameter b/vendor/rails/actionpack/test/fixtures/multipart/single_parameter deleted file mode 100644 index 8962c354..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +++ /dev/null @@ -1,5 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/text_file b/vendor/rails/actionpack/test/fixtures/multipart/text_file deleted file mode 100644 index e0367d68..00000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/text_file +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x -Content-Disposition: form-data; name="file"; filename="file.txt" -Content-Type: text/plain - -contents ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb b/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb deleted file mode 100644 index 3e308d3d..00000000 --- a/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb +++ /dev/null @@ -1 +0,0 @@ -Hello overridden world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb b/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb deleted file mode 100644 index 3863d5a8..00000000 --- a/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb +++ /dev/null @@ -1 +0,0 @@ -layout: <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb b/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb deleted file mode 100644 index c6c1a586..00000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="html"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb b/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb deleted file mode 100644 index db0e4369..00000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="super_iphone"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb b/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb deleted file mode 100644 index b349b256..00000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello Firefox \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb b/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb deleted file mode 100644 index d741e443..00000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -Hello iPhone \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb b/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb deleted file mode 100644 index 7fc2eb19..00000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -Super Firefox \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb b/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb deleted file mode 100644 index 99063a8d..00000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -Super iPhone \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/project.rb b/vendor/rails/actionpack/test/fixtures/project.rb deleted file mode 100644 index 2b53d39e..00000000 --- a/vendor/rails/actionpack/test/fixtures/project.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true -end diff --git a/vendor/rails/actionpack/test/fixtures/projects.yml b/vendor/rails/actionpack/test/fixtures/projects.yml deleted file mode 100644 index 02800c78..00000000 --- a/vendor/rails/actionpack/test/fixtures/projects.yml +++ /dev/null @@ -1,7 +0,0 @@ -action_controller: - id: 2 - name: Active Controller - -active_record: - id: 1 - name: Active Record diff --git a/vendor/rails/actionpack/test/fixtures/projects/_project.erb b/vendor/rails/actionpack/test/fixtures/projects/_project.erb deleted file mode 100644 index 480c4c2a..00000000 --- a/vendor/rails/actionpack/test/fixtures/projects/_project.erb +++ /dev/null @@ -1 +0,0 @@ -<%= project.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/404.html b/vendor/rails/actionpack/test/fixtures/public/404.html deleted file mode 100644 index 497397cc..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/404.html +++ /dev/null @@ -1 +0,0 @@ -404 error fixture diff --git a/vendor/rails/actionpack/test/fixtures/public/500.da.html b/vendor/rails/actionpack/test/fixtures/public/500.da.html deleted file mode 100644 index a497c136..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/500.da.html +++ /dev/null @@ -1 +0,0 @@ -500 localized error fixture diff --git a/vendor/rails/actionpack/test/fixtures/public/500.html b/vendor/rails/actionpack/test/fixtures/public/500.html deleted file mode 100644 index 7c66c7a9..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/500.html +++ /dev/null @@ -1 +0,0 @@ -500 error fixture diff --git a/vendor/rails/actionpack/test/fixtures/public/absolute/test.css b/vendor/rails/actionpack/test/fixtures/public/absolute/test.css deleted file mode 100644 index 6e09025b..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/absolute/test.css +++ /dev/null @@ -1,23 +0,0 @@ -/* bank.css */ - -/* robber.css */ - -/* version.1.0.css */ - -/* bank.css */ - -/* bank.css */ - -/* robber.css */ - -/* version.1.0.css */ - -/* bank.css */ - -/* robber.css */ - -/* version.1.0.css */ - -/* robber.css */ - -/* version.1.0.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/absolute/test.js b/vendor/rails/actionpack/test/fixtures/public/absolute/test.js deleted file mode 100644 index 4c4292a3..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/absolute/test.js +++ /dev/null @@ -1,63 +0,0 @@ -// prototype js - -// effects js - -// dragdrop js - -// controls js - -// prototype js - -// effects js - -// dragdrop js - -// controls js - -// application js - -// bank js - -// robber js - -// version.1.0 js - -// application js - -// bank js - -// prototype js - -// effects js - -// dragdrop js - -// controls js - -// prototype js - -// effects js - -// dragdrop js - -// controls js - -// application js - -// bank js - -// robber js - -// version.1.0 js - -// application js - -// bank js - -// robber js - -// version.1.0 js - -// robber js - -// version.1.0 js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/images/rails.png b/vendor/rails/actionpack/test/fixtures/public/images/rails.png deleted file mode 100644 index b8441f18..00000000 Binary files a/vendor/rails/actionpack/test/fixtures/public/images/rails.png and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js deleted file mode 100644 index 97026929..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js +++ /dev/null @@ -1 +0,0 @@ -// application js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js deleted file mode 100644 index 4a1bee71..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js +++ /dev/null @@ -1 +0,0 @@ -// bank js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js deleted file mode 100644 index 88168d9f..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js +++ /dev/null @@ -1 +0,0 @@ -// controls js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js deleted file mode 100644 index c07061ac..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js +++ /dev/null @@ -1 +0,0 @@ -// dragdrop js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js deleted file mode 100644 index b555d630..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js +++ /dev/null @@ -1 +0,0 @@ -// effects js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js deleted file mode 100644 index 9780064a..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js +++ /dev/null @@ -1 +0,0 @@ -// prototype js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js deleted file mode 100644 index eb82fcbd..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js +++ /dev/null @@ -1 +0,0 @@ -// robber js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/subdir/subdir.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/subdir/subdir.js deleted file mode 100644 index 9d23a67a..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/subdir/subdir.js +++ /dev/null @@ -1 +0,0 @@ -// subdir js diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js deleted file mode 100644 index cfd5fce7..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js +++ /dev/null @@ -1 +0,0 @@ -// version.1.0 js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css deleted file mode 100644 index ea161b12..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css +++ /dev/null @@ -1 +0,0 @@ -/* bank.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css deleted file mode 100644 index 0fdd00a6..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css +++ /dev/null @@ -1 +0,0 @@ -/* robber.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css deleted file mode 100644 index 241152a9..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css +++ /dev/null @@ -1 +0,0 @@ -/* subdir.css */ diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css deleted file mode 100644 index 30f5f9ba..00000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css +++ /dev/null @@ -1 +0,0 @@ -/* version.1.0.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/quiz/questions/_question.html.erb b/vendor/rails/actionpack/test/fixtures/quiz/questions/_question.html.erb deleted file mode 100644 index fb4dcfee..00000000 --- a/vendor/rails/actionpack/test/fixtures/quiz/questions/_question.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= question.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/replies.yml b/vendor/rails/actionpack/test/fixtures/replies.yml deleted file mode 100644 index 66020b70..00000000 --- a/vendor/rails/actionpack/test/fixtures/replies.yml +++ /dev/null @@ -1,15 +0,0 @@ -witty_retort: - id: 1 - topic_id: 1 - developer_id: 1 - content: Birdman is better! - created_at: <%= 6.hours.ago.to_s(:db) %> - updated_at: nil - -another: - id: 2 - topic_id: 2 - developer_id: 1 - content: Nuh uh! - created_at: <%= 1.hour.ago.to_s(:db) %> - updated_at: nil diff --git a/vendor/rails/actionpack/test/fixtures/replies/_reply.erb b/vendor/rails/actionpack/test/fixtures/replies/_reply.erb deleted file mode 100644 index 68baf548..00000000 --- a/vendor/rails/actionpack/test/fixtures/replies/_reply.erb +++ /dev/null @@ -1 +0,0 @@ -<%= reply.content %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/reply.rb b/vendor/rails/actionpack/test/fixtures/reply.rb deleted file mode 100644 index 04598437..00000000 --- a/vendor/rails/actionpack/test/fixtures/reply.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Reply < ActiveRecord::Base - named_scope :base - belongs_to :topic, :include => [:replies] - belongs_to :developer - - validates_presence_of :content -end diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb deleted file mode 100644 index 84a84049..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +++ /dev/null @@ -1 +0,0 @@ -HTML for all_types_with_layout \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs b/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs deleted file mode 100644 index b7aec7c5..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page << "RJS for all_types_with_layout" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb b/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb deleted file mode 100644 index 0cdfa414..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +++ /dev/null @@ -1 +0,0 @@ -Mobile \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb deleted file mode 100644 index 1f3f1c65..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello future from <%= @type -%>! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb b/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb deleted file mode 100644 index 17888ac3..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -Hello iPhone future from <%= @type -%>! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb deleted file mode 100644 index d6f92a31..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="html_missing"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb deleted file mode 100644 index c6c1a586..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="html"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb b/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb deleted file mode 100644 index 84444517..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="iphone"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb deleted file mode 100644 index 6769dd60..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs deleted file mode 100644 index 469fcd8e..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page[:body].visual_effect :highlight \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder deleted file mode 100644 index 598d62e2..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +++ /dev/null @@ -1 +0,0 @@ -xml.p "Hello world!" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb deleted file mode 100644 index 6769dd60..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs deleted file mode 100644 index 469fcd8e..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page[:body].visual_effect :highlight \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder deleted file mode 100644 index 598d62e2..00000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +++ /dev/null @@ -1 +0,0 @@ -xml.p "Hello world!" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb b/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb deleted file mode 100644 index 8947726e..00000000 --- a/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb +++ /dev/null @@ -1 +0,0 @@ -<p>Beautiful modules!</p> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb b/vendor/rails/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb deleted file mode 100644 index 145c92e1..00000000 --- a/vendor/rails/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +++ /dev/null @@ -1,10 +0,0 @@ -module SessionAutoloadTest - class Foo - def initialize(bar='baz') - @bar = bar - end - def inspect - "#<#{self.class} bar:#{@bar.inspect}>" - end - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/shared.html.erb b/vendor/rails/actionpack/test/fixtures/shared.html.erb deleted file mode 100644 index af262fc9..00000000 --- a/vendor/rails/actionpack/test/fixtures/shared.html.erb +++ /dev/null @@ -1 +0,0 @@ -Elastica \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb b/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb deleted file mode 100644 index bda57d0f..00000000 --- a/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb +++ /dev/null @@ -1,5 +0,0 @@ -This is my layout - -<%= yield %> - -End. diff --git a/vendor/rails/actionpack/test/fixtures/test/_counter.html.erb b/vendor/rails/actionpack/test/fixtures/test/_counter.html.erb deleted file mode 100644 index fd245bfc..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_counter.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= counter_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer.erb b/vendor/rails/actionpack/test/fixtures/test/_customer.erb deleted file mode 100644 index d8220afe..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer.erb +++ /dev/null @@ -1 +0,0 @@ -Hello: <%= customer.name rescue "Anonymous" %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb deleted file mode 100644 index 3435979d..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb +++ /dev/null @@ -1 +0,0 @@ -<%= customer_counter.name %><%= customer_counter_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_counter_with_as.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_counter_with_as.erb deleted file mode 100644 index 1241eb60..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_counter_with_as.erb +++ /dev/null @@ -1 +0,0 @@ -<%= client.name %><%= client_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb deleted file mode 100644 index 6acbcb20..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %>: <%= customer_greeting.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_with_var.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_with_var.erb deleted file mode 100644 index 3379246b..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_with_var.erb +++ /dev/null @@ -1 +0,0 @@ -<%= customer.name %> <%= object.name %> <%= customer_with_var.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_form.erb b/vendor/rails/actionpack/test/fixtures/test/_form.erb deleted file mode 100644 index 01107f1c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_form.erb +++ /dev/null @@ -1 +0,0 @@ -<%= form.label :title %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_from_helper.erb b/vendor/rails/actionpack/test/fixtures/test/_from_helper.erb deleted file mode 100644 index 16de7c0f..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_from_helper.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render_from_helper %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb b/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb deleted file mode 100644 index fc54a36f..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %>: <%= hash_greeting[:first_name] %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb b/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb deleted file mode 100644 index 55c03afb..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= hash_object[:first_name] %> -<%= object[:first_name].reverse %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_hello.builder b/vendor/rails/actionpack/test/fixtures/test/_hello.builder deleted file mode 100644 index ef52f632..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_hello.builder +++ /dev/null @@ -1 +0,0 @@ -xm.hello \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb b/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb deleted file mode 100644 index 1b957631..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb +++ /dev/null @@ -1 +0,0 @@ -<%= labelling_form.label :title %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb b/vendor/rails/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb deleted file mode 100644 index 30753320..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -Before -<%= yield 'arg1', 'arg2' %> -After \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb b/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb deleted file mode 100644 index 666efadb..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -Before (<%= name %>) -<%= yield %> -After \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_local_inspector.html.erb b/vendor/rails/actionpack/test/fixtures/test/_local_inspector.html.erb deleted file mode 100644 index c5a6e3e5..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_local_inspector.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= local_assigns.keys.map(&:to_s).sort.join(",") -%> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_one.html.erb b/vendor/rails/actionpack/test/fixtures/test/_one.html.erb deleted file mode 100644 index f796291c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_one.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "two" %> world diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial.erb b/vendor/rails/actionpack/test/fixtures/test/_partial.erb deleted file mode 100644 index e466dcbd..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial.erb +++ /dev/null @@ -1 +0,0 @@ -invalid \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb b/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb deleted file mode 100644 index e39f6c98..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -partial html \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb b/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb deleted file mode 100644 index b350cdd7..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb +++ /dev/null @@ -1 +0,0 @@ -partial js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb b/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb deleted file mode 100644 index 3a03a64e..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb +++ /dev/null @@ -1 +0,0 @@ -Inside from partial (<%= name %>) \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb b/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb deleted file mode 100644 index a44b3eed..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb +++ /dev/null @@ -1 +0,0 @@ -only partial \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb b/vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb deleted file mode 100644 index 00e6b6d6..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb +++ /dev/null @@ -1 +0,0 @@ -partial with only html version \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_person.erb b/vendor/rails/actionpack/test/fixtures/test/_person.erb deleted file mode 100644 index b2e56889..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_person.erb +++ /dev/null @@ -1,2 +0,0 @@ -Second: <%= name %> -Third: <%= @name %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb b/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb deleted file mode 100644 index 68b08181..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= doesnt_exist %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_two.html.erb b/vendor/rails/actionpack/test/fixtures/test/_two.html.erb deleted file mode 100644 index 5ab2f8a4..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_two.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_utf8_partial.html.erb b/vendor/rails/actionpack/test/fixtures/test/_utf8_partial.html.erb deleted file mode 100644 index 8d717fd4..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_utf8_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= "текст" %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_utf8_partial_magic.html.erb b/vendor/rails/actionpack/test/fixtures/test/_utf8_partial_magic.html.erb deleted file mode 100644 index 4e222461..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/_utf8_partial_magic.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%# encoding: utf-8 -%> -<%= "текст" %> diff --git a/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb b/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb deleted file mode 100644 index 36e896da..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% @title = "Talking to the layout" -%> -Action was here! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/array_translation.erb b/vendor/rails/actionpack/test/fixtures/test/array_translation.erb deleted file mode 100644 index bcdeea4c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/array_translation.erb +++ /dev/null @@ -1 +0,0 @@ -<% translation = t(['foo', 'bar', 'baz_html']) %><%= translation.first %>, <%= translation.second %>, <%= translation.third %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb b/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb deleted file mode 100644 index ac44bc0d..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render(:layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => { :name => "David" }) %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/capturing.erb b/vendor/rails/actionpack/test/fixtures/test/capturing.erb deleted file mode 100644 index cdca9763..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/capturing.erb +++ /dev/null @@ -1,4 +0,0 @@ -<% days = capture do %> - <p>Dreamy days</p> -<% end %> -<%= days %> diff --git a/vendor/rails/actionpack/test/fixtures/test/content_for.erb b/vendor/rails/actionpack/test/fixtures/test/content_for.erb deleted file mode 100644 index 0e47ca8c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/content_for.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% content_for :title do %>Putting stuff in the title!<% end %> -Great stuff! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb b/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb deleted file mode 100644 index fb6b4b05..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, "Putting stuff " - content_for :title, "in the title!" %> -Great stuff! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb b/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb deleted file mode 100644 index 57aecbac..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% content_for :title, "Putting stuff in the title!" %> -Great stuff! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs b/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs deleted file mode 100644 index 4b75a955..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs +++ /dev/null @@ -1,2 +0,0 @@ -page.remove 'person' -page.visual_effect :highlight, "project-#{@project_id}" diff --git a/vendor/rails/actionpack/test/fixtures/test/dont_pick_me b/vendor/rails/actionpack/test/fixtures/test/dont_pick_me deleted file mode 100644 index 0157c9e5..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/dont_pick_me +++ /dev/null @@ -1 +0,0 @@ -non-template file \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb b/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb deleted file mode 100644 index 8b8a4492..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +++ /dev/null @@ -1 +0,0 @@ -The secret is <%= @secret %> diff --git a/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs b/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs deleted file mode 100644 index e3004076..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs +++ /dev/null @@ -1,6 +0,0 @@ -page.select('.product').each do |value| - page.visual_effect :highlight - page.visual_effect :highlight, value - page.sortable(value, :url => { :action => "order" }) - page.draggable(value) -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb b/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb deleted file mode 100644 index 1c64efab..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb +++ /dev/null @@ -1 +0,0 @@ -formatted html erb \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder b/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder deleted file mode 100644 index 14fd3549..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder +++ /dev/null @@ -1 +0,0 @@ -xml.test 'failed' \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb b/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb deleted file mode 100644 index 0c855a60..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +++ /dev/null @@ -1 +0,0 @@ -<test>passed formatted html erb</test> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb b/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb deleted file mode 100644 index 6ca09d53..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +++ /dev/null @@ -1 +0,0 @@ -<test>passed formatted xml erb</test> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/greeting.erb b/vendor/rails/actionpack/test/fixtures/test/greeting.erb deleted file mode 100644 index 62fb0293..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/greeting.erb +++ /dev/null @@ -1 +0,0 @@ -<p>This is grand!</p> diff --git a/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs b/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs deleted file mode 100644 index 469fcd8e..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page[:body].visual_effect :highlight \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello.builder b/vendor/rails/actionpack/test/fixtures/test/hello.builder deleted file mode 100644 index a4715539..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello.builder +++ /dev/null @@ -1,4 +0,0 @@ -xml.html do - xml.p "Hello #{@name}" - xml << render(:file => "test/greeting") -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world.da.html.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world.da.html.erb deleted file mode 100644 index 10ec4432..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world.da.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hey verden \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world.erb deleted file mode 100644 index 6769dd60..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb deleted file mode 100644 index 773b3c8c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb +++ /dev/null @@ -1 +0,0 @@ -Ola mundo \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder b/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder deleted file mode 100644 index e48d75c4..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder +++ /dev/null @@ -1,3 +0,0 @@ -xml.test do - render :partial => 'hello', :locals => { :xm => xml } -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder b/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder deleted file mode 100644 index 8455b11e..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder +++ /dev/null @@ -1,4 +0,0 @@ -xml.html do - xml.p "Hello" -end -"String return value" diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb deleted file mode 100644 index 6769dd60..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder b/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder deleted file mode 100644 index 02b14fe8..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder +++ /dev/null @@ -1,11 +0,0 @@ -xml.html do - xml.head do - xml.title "Hello World" - end - - xml.body do - xml.p "abes" - xml.p "monks" - xml.p "wiseguys" - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hyphen-ated.erb b/vendor/rails/actionpack/test/fixtures/test/hyphen-ated.erb deleted file mode 100644 index cd087558..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/hyphen-ated.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder b/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder deleted file mode 100644 index 2fcb32d2..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder +++ /dev/null @@ -1,2 +0,0 @@ -xml.atom do -end diff --git a/vendor/rails/actionpack/test/fixtures/test/list.erb b/vendor/rails/actionpack/test/fixtures/test/list.erb deleted file mode 100644 index 0a4bda58..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/list.erb +++ /dev/null @@ -1 +0,0 @@ -<%= @test_unchanged = 'goodbye' %><%= render :partial => 'customer', :collection => @customers %><%= @test_unchanged %> diff --git a/vendor/rails/actionpack/test/fixtures/test/nested_layout.erb b/vendor/rails/actionpack/test/fixtures/test/nested_layout.erb deleted file mode 100644 index 7b6dcbb6..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/nested_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, "title" -%> -<% content_for :column do -%>column<% end -%> -<% render :layout => 'layouts/column' do -%>content<% end -%> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder b/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder deleted file mode 100644 index a9464356..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder +++ /dev/null @@ -1,4 +0,0 @@ -content_for :title do - 'Putting stuff in the title!' -end -xml << "\nGreat stuff!" diff --git a/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb b/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb deleted file mode 100644 index a5e964e3..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb +++ /dev/null @@ -1,4 +0,0 @@ -First: <%= @name %> -<%= render :partial => "person", :locals => { :name => "Stephan" } -%> -Fourth: <%= @name %> -Fifth: <%= name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/render_explicit_html_template.js.rjs b/vendor/rails/actionpack/test/fixtures/test/render_explicit_html_template.js.rjs deleted file mode 100644 index 4eb12fd6..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_explicit_html_template.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page.call "document.write", render(:partial => "one.html.erb") diff --git a/vendor/rails/actionpack/test/fixtures/test/render_file_from_template.html.erb b/vendor/rails/actionpack/test/fixtures/test/render_file_from_template.html.erb deleted file mode 100644 index fde9f4bb..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_file_from_template.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :file => @path %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb b/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb deleted file mode 100644 index 8b8a4492..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb +++ /dev/null @@ -1 +0,0 @@ -The secret is <%= @secret %> diff --git a/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb b/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb deleted file mode 100644 index ebe09fae..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb +++ /dev/null @@ -1 +0,0 @@ -The secret is <%= secret %> diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template.js.rjs b/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template.js.rjs deleted file mode 100644 index 3d680417..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page.call "document.write", render(:partial => "one") diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb b/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb deleted file mode 100644 index 0740b2d0..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hey HTML! diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb b/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb deleted file mode 100644 index 4a11845c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello HTML! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb b/vendor/rails/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb deleted file mode 100644 index d5b94af5..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb +++ /dev/null @@ -1 +0,0 @@ -alert('hello'); diff --git a/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb b/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb deleted file mode 100644 index 6e267e86..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb +++ /dev/null @@ -1 +0,0 @@ -The value of foo is: ::<%= @foo %>:: diff --git a/vendor/rails/actionpack/test/fixtures/test/scoped_array_translation.erb b/vendor/rails/actionpack/test/fixtures/test/scoped_array_translation.erb deleted file mode 100644 index cb07fca8..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/scoped_array_translation.erb +++ /dev/null @@ -1 +0,0 @@ -<%= t(['.foo', '.bar']).join(", ") %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/sub_template_raise.html.erb b/vendor/rails/actionpack/test/fixtures/test/sub_template_raise.html.erb deleted file mode 100644 index f38c0bda..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/sub_template_raise.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "test/raise" %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/template.erb b/vendor/rails/actionpack/test/fixtures/test/template.erb deleted file mode 100644 index 785afa8f..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/template.erb +++ /dev/null @@ -1 +0,0 @@ -<%= template.path %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/translation.erb b/vendor/rails/actionpack/test/fixtures/test/translation.erb deleted file mode 100644 index 81a837d1..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/translation.erb +++ /dev/null @@ -1 +0,0 @@ -<%= t('.helper') %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb b/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb deleted file mode 100644 index fa3ef200..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% replacement_function = update_element_function("products", :action => :update) do %> - <p>Product 1</p> - <p>Product 2</p> -<% end %> -<%= javascript_tag(replacement_function) %> - -<% update_element_function("status", :action => :update, :binding => binding) do %> - <b>You bought something!</b> -<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb b/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb deleted file mode 100644 index a93fa02c..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb +++ /dev/null @@ -1 +0,0 @@ -<% render(:layout => "layout_for_partial", :locals => { :name => "David" }) do %>Inside from block<% end %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb b/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb deleted file mode 100644 index 71b1f30a..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb +++ /dev/null @@ -1 +0,0 @@ -<% render(:layout => "layout_for_block_with_args") do |*args| %><%= args.join %><% end %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/utf8.html.erb b/vendor/rails/actionpack/test/fixtures/test/utf8.html.erb deleted file mode 100644 index ac98c2f0..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/utf8.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -Русский <%= render :partial => 'test/utf8_partial' %> -<%= "日".encoding %> -<%= @output_buffer.encoding %> -<%= __ENCODING__ %> diff --git a/vendor/rails/actionpack/test/fixtures/test/utf8_magic.html.erb b/vendor/rails/actionpack/test/fixtures/test/utf8_magic.html.erb deleted file mode 100644 index 257279c2..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/utf8_magic.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%# encoding: utf-8 -%> -Русский <%= render :partial => 'test/utf8_partial_magic' %> -<%= "日".encoding %> -<%= @output_buffer.encoding %> -<%= __ENCODING__ %> diff --git a/vendor/rails/actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb b/vendor/rails/actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb deleted file mode 100644 index cb22692f..00000000 --- a/vendor/rails/actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%# encoding: utf-8 -%> -Русский <%= render :partial => 'test/utf8_partial' %> -<%= "日".encoding %> -<%= @output_buffer.encoding %> -<%= __ENCODING__ %> diff --git a/vendor/rails/actionpack/test/fixtures/topic.rb b/vendor/rails/actionpack/test/fixtures/topic.rb deleted file mode 100644 index 9fa97465..00000000 --- a/vendor/rails/actionpack/test/fixtures/topic.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy -end diff --git a/vendor/rails/actionpack/test/fixtures/topics.yml b/vendor/rails/actionpack/test/fixtures/topics.yml deleted file mode 100644 index 61ea02d7..00000000 --- a/vendor/rails/actionpack/test/fixtures/topics.yml +++ /dev/null @@ -1,22 +0,0 @@ -futurama: - id: 1 - title: Isnt futurama awesome? - subtitle: It really is, isnt it. - content: I like futurama - created_at: <%= 1.day.ago.to_s(:db) %> - updated_at: - -harvey_birdman: - id: 2 - title: Harvey Birdman is the king of all men - subtitle: yup - content: It really is - created_at: <%= 2.hours.ago.to_s(:db) %> - updated_at: - -rails: - id: 3 - title: Rails is nice - subtitle: It makes me happy - content: except when I have to hack internals to fix pagination. even then really. - created_at: <%= 20.minutes.ago.to_s(:db) %> diff --git a/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb b/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb deleted file mode 100644 index 98659ca0..00000000 --- a/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= topic.title %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb deleted file mode 100644 index cac04c8e..00000000 --- a/vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'abstract_unit' - -class ActiveRecordHelperI18nTest < Test::Unit::TestCase - include ActionView::Helpers::ActiveRecordHelper - - attr_reader :request - def setup - @object = stub :errors => stub(:count => 1, :full_messages => ['full_messages']) - @object_name = 'book' - stubs(:content_tag).returns 'content_tag' - - I18n.stubs(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').returns "1 error prohibited this from being saved" - I18n.stubs(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:' - end - - def test_error_messages_for_given_a_header_option_it_does_not_translate_header_message - I18n.expects(:translate).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').never - error_messages_for(:object => @object, :header_message => 'header message', :locale => 'en') - end - - def test_error_messages_for_given_no_header_option_it_translates_header_message - I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').returns 'header message' - I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns '' - error_messages_for(:object => @object, :locale => 'en') - end - - def test_error_messages_for_given_a_message_option_it_does_not_translate_message - I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).never - I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns '' - error_messages_for(:object => @object, :message => 'message', :locale => 'en') - end - - def test_error_messages_for_given_no_message_option_it_translates_message - I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:' - I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns '' - error_messages_for(:object => @object, :locale => 'en') - end - - def test_error_messages_for_given_object_name_it_translates_object_name - I18n.expects(:t).with(:header, :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => @object_name).returns "1 error prohibited this #{@object_name} from being saved" - I18n.expects(:t).with(@object_name, :default => @object_name, :count => 1, :scope => [:activerecord, :models]).once.returns @object_name - error_messages_for(:object => @object, :locale => 'en', :object_name => @object_name) - end - - def test_error_messages_for_given_object_name_with_underscore_it_translates_object_name - I18n.expects(:t).with('bank_account', :default => 'bank account', :count => 1, :scope => [:activerecord, :models]).once.returns 'bank account' - I18n.expects(:t).with(:header, :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => 'bank account').returns "1 error prohibited this bank account from being saved" - error_messages_for(:object => @object, :locale => 'en', :object_name => 'bank_account') - end -end - diff --git a/vendor/rails/actionpack/test/template/active_record_helper_test.rb b/vendor/rails/actionpack/test/template/active_record_helper_test.rb deleted file mode 100644 index 6ec4c84a..00000000 --- a/vendor/rails/actionpack/test/template/active_record_helper_test.rb +++ /dev/null @@ -1,302 +0,0 @@ -require 'abstract_unit' - -class ActiveRecordHelperTest < ActionView::TestCase - tests ActionView::Helpers::ActiveRecordHelper - - silence_warnings do - Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on) - Post.class_eval do - alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) - alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) - alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) - end - - User = Struct.new("User", :email) - User.class_eval do - alias_method :email_before_type_cast, :email unless respond_to?(:email_before_type_cast) - end - - Column = Struct.new("Column", :type, :name, :human_name) - end - - class DirtyPost - class Errors - def empty? - false - end - - def count - 1 - end - - def full_messages - ["Author name can't be <em>empty</em>"] - end - - def on(field) - "can't be <em>empty</em>" - end - end - - def errors - Errors.new - end - end - - def setup_post - @post = Post.new - def @post.errors - Class.new { - def on(field) - case field.to_s - when "author_name" - "can't be empty" - when "body" - true - else - false - end - end - def empty?() false end - def count() 1 end - def full_messages() [ "Author name can't be empty" ] end - }.new - end - - def @post.new_record?() true end - def @post.to_param() nil end - - def @post.column_for_attribute(attr_name) - Post.content_columns.select { |column| column.name == attr_name }.first - end - - silence_warnings do - def Post.content_columns() [ Column.new(:string, "title", "Title"), Column.new(:text, "body", "Body") ] end - end - - @post.title = "Hello World" - @post.author_name = "" - @post.body = "Back to the hill and over it again!" - @post.secret = 1 - @post.written_on = Date.new(2004, 6, 15) - end - - def setup_user - @user = User.new - def @user.errors - Class.new { - def on(field) field == "email" end - def empty?() false end - def count() 1 end - def full_messages() [ "User email can't be empty" ] end - }.new - end - - def @user.new_record?() true end - def @user.to_param() nil end - - def @user.column_for_attribute(attr_name) - User.content_columns.select { |column| column.name == attr_name }.first - end - - silence_warnings do - def User.content_columns() [ Column.new(:string, "email", "Email") ] end - end - - @user.email = "" - end - - def protect_against_forgery? - @protect_against_forgery ? true : false - end - attr_accessor :request_forgery_protection_token, :form_authenticity_token - - def setup - setup_post - setup_user - - @response = ActionController::TestResponse.new - - @controller = Object.new - def @controller.url_for(options) - options = options.symbolize_keys - - [options[:action], options[:id].to_param].compact.join('/') - end - end - - def test_generic_input_tag - assert_dom_equal( - %(<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />), input("post", "title") - ) - end - - def test_text_area_with_errors - assert_dom_equal( - %(<div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div>), - text_area("post", "body") - ) - end - - def test_text_field_with_errors - assert_dom_equal( - %(<div class="fieldWithErrors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /></div>), - text_field("post", "author_name") - ) - end - - def test_form_with_string - assert_dom_equal( - %(<form action="create" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - - silence_warnings do - class << @post - def new_record?() false end - def to_param() id end - def id() 1 end - end - end - - assert_dom_equal( - %(<form action="update/1" method="post"><input id="post_id" name="post[id]" type="hidden" value="1" /><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Update" /></form>), - form("post") - ) - end - - def test_form_with_protect_against_forgery - @protect_against_forgery = true - @request_forgery_protection_token = 'authenticity_token' - @form_authenticity_token = '123' - assert_dom_equal( - %(<form action="create" method="post"><div style='margin:0;padding:0;display:inline'><input type='hidden' name='authenticity_token' value='123' /></div><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - end - - def test_form_with_method_option - assert_dom_equal( - %(<form action="create" method="get"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post", :method=>'get') - ) - end - - def test_form_with_action_option - output_buffer << form("post", :action => "sign") - assert_select "form[action=sign]" do |form| - assert_select "input[type=submit][value=Sign]" - end - end - - def test_form_with_date - silence_warnings do - def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end - end - - assert_dom_equal( - %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select id="post_written_on_1i" name="post[written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n</select>\n<select id="post_written_on_2i" name="post[written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n</select>\n<select id="post_written_on_3i" name="post[written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n</select>\n</p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - end - - def test_form_with_datetime - silence_warnings do - def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end - end - @post.written_on = Time.gm(2004, 6, 15, 16, 30) - - assert_dom_equal( - %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select id="post_written_on_1i" name="post[written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n</select>\n<select id="post_written_on_2i" name="post[written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n</select>\n<select id="post_written_on_3i" name="post[written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n</select>\n &mdash; <select id="post_written_on_4i" name="post[written_on(4i)]">\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n</select>\n : <select id="post_written_on_5i" name="post[written_on(5i)]">\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30" selected="selected">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n</select>\n</p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - end - - def test_error_for_block - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post") - assert_equal %(<div class="errorDeathByClass" id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1") - assert_equal %(<div id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => nil, :id => "errorDeathById", :header_tag => "h1") - assert_equal %(<div class="errorDeathByClass"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => nil, :header_tag => "h1") - end - - def test_error_messages_for_escapes_html - @dirty_post = DirtyPost.new - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this dirty post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be &lt;em&gt;empty&lt;/em&gt;</li></ul></div>), error_messages_for("dirty_post") - end - - def test_error_messages_for_handles_nil - assert_equal "", error_messages_for("notthere") - end - - def test_error_message_on_escapes_html - @dirty_post = DirtyPost.new - assert_dom_equal "<div class=\"formError\">can't be &lt;em&gt;empty&lt;/em&gt;</div>", error_message_on(:dirty_post, :author_name) - end - - def test_error_message_on_handles_nil - assert_equal "", error_message_on("notthere", "notthere") - end - - def test_error_message_on - assert_dom_equal "<div class=\"formError\">can't be empty</div>", error_message_on(:post, :author_name) - end - - def test_error_message_on_no_instance_variable - other_post = @post - assert_dom_equal "<div class=\"formError\">can't be empty</div>", error_message_on(other_post, :author_name) - end - - def test_error_message_on_with_options_hash - assert_dom_equal "<div class=\"differentError\">beforecan't be emptyafter</div>", error_message_on(:post, :author_name, :css_class => 'differentError', :prepend_text => 'before', :append_text => 'after') - end - - def test_error_messages_for_many_objects - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li><li>User email can't be empty</li></ul></div>), error_messages_for("post", "user") - - # reverse the order, error order changes and so does the title - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this user from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for("user", "post") - - # add the default to put post back in the title - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for("user", "post", :object_name => "post") - - # symbols work as well - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => :post) - - # any default works too - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this monkey from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => "monkey") - - # should space object name - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this chunky bacon from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => "chunky_bacon") - - # hide header and explanation messages with nil or empty string - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :header_message => nil, :message => "") - - # override header and explanation messages - header_message = "Yikes! Some errors" - message = "Please fix the following fields and resubmit:" - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>#{header_message}</h2><p>#{message}</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :header_message => header_message, :message => message) - end - - def test_error_messages_for_non_instance_variable - actual_user = @user - actual_post = @post - @user = nil - @post = nil - - #explicitly set object - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :object => actual_post) - - #multiple objects - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this user from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for("user", "post", :object => [actual_user, actual_post]) - - #nil object - assert_equal '', error_messages_for('user', :object => nil) - end - - def test_form_with_string_multipart - assert_dom_equal( - %(<form action="create" enctype="multipart/form-data" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post", :multipart => true) - ) - end -end diff --git a/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb b/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb deleted file mode 100644 index a4e0d264..00000000 --- a/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +++ /dev/null @@ -1,770 +0,0 @@ -require 'abstract_unit' - -class AssetTagHelperTest < ActionView::TestCase - tests ActionView::Helpers::AssetTagHelper - - def setup - silence_warnings do - ActionView::Helpers::AssetTagHelper.send( - :const_set, - :JAVASCRIPTS_DIR, - File.dirname(__FILE__) + "/../fixtures/public/javascripts" - ) - - ActionView::Helpers::AssetTagHelper.send( - :const_set, - :STYLESHEETS_DIR, - File.dirname(__FILE__) + "/../fixtures/public/stylesheets" - ) - - ActionView::Helpers::AssetTagHelper.send( - :const_set, - :ASSETS_DIR, - File.dirname(__FILE__) + "/../fixtures/public" - ) - end - - @controller = Class.new do - attr_accessor :request - def url_for(*args) "http://www.example.com" end - end.new - - @request = Class.new do - def protocol() 'http://' end - def ssl?() false end - def host_with_port() 'localhost' end - end.new - - @controller.request = @request - - ActionView::Helpers::AssetTagHelper::reset_javascript_include_default - end - - def teardown - ActionController::Base.perform_caching = false - ActionController::Base.asset_host = nil - ENV.delete('RAILS_ASSET_ID') - end - - AutoDiscoveryToTag = { - %(auto_discovery_link_tag) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss)) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:atom)) => %(<link href="http://www.example.com" rel="alternate" title="ATOM" type="application/atom+xml" />), - %(auto_discovery_link_tag(:xml)) => %(<link href="http://www.example.com" rel="alternate" title="XML" type="application/xml" />), - %(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss, "http://localhost/feed")) => %(<link href="http://localhost/feed" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(nil, {}, {:type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="" type="text/html" />), - %(auto_discovery_link_tag(nil, {}, {:title => "No stream.. really", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="No stream.. really" type="text/html" />), - %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="text/html" />), - %(auto_discovery_link_tag(:atom, {}, {:rel => "Not so alternate"})) => %(<link href="http://www.example.com" rel="Not so alternate" title="ATOM" type="application/atom+xml" />), - } - - JavascriptPathToTag = { - %(javascript_path("xmlhr")) => %(/javascripts/xmlhr.js), - %(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js), - %(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js) - } - - PathToJavascriptToTag = { - %(path_to_javascript("xmlhr")) => %(/javascripts/xmlhr.js), - %(path_to_javascript("super/xmlhr")) => %(/javascripts/super/xmlhr.js), - %(path_to_javascript("/super/xmlhr.js")) => %(/super/xmlhr.js) - } - - JavascriptIncludeToTag = { - %(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>), - %(javascript_include_tag("xmlhr.js")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>), - %(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>), - %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>), - %(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), - %(javascript_include_tag(:all)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - %(javascript_include_tag(:all, :recursive => true)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/subdir/subdir.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - %(javascript_include_tag(:defaults, "test")) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), - %(javascript_include_tag("test", :defaults)) => %(<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>) - } - - StylePathToTag = { - %(stylesheet_path("style")) => %(/stylesheets/style.css), - %(stylesheet_path("style.css")) => %(/stylesheets/style.css), - %(stylesheet_path('dir/file')) => %(/stylesheets/dir/file.css), - %(stylesheet_path('/dir/file.rcss')) => %(/dir/file.rcss) - } - - PathToStyleToTag = { - %(path_to_stylesheet("style")) => %(/stylesheets/style.css), - %(path_to_stylesheet("style.css")) => %(/stylesheets/style.css), - %(path_to_stylesheet('dir/file')) => %(/stylesheets/dir/file.css), - %(path_to_stylesheet('/dir/file.rcss')) => %(/dir/file.rcss) - } - - StyleLinkToTag = { - %(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("style.css")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("/dir/file")) => %(<link href="/dir/file.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("dir/file")) => %(<link href="/stylesheets/dir/file.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("style", :media => "all")) => %(<link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag(:all)) => %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag(:all, :recursive => true)) => %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag(:all, :media => "all")) => %(<link href="/stylesheets/bank.css" media="all" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="all" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="all" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("http://www.example.com/styles/style")) => %(<link href="http://www.example.com/styles/style.css" media="screen" rel="stylesheet" type="text/css" />) - } - - ImagePathToTag = { - %(image_path("xml")) => %(/images/xml), - %(image_path("xml.png")) => %(/images/xml.png), - %(image_path("dir/xml.png")) => %(/images/dir/xml.png), - %(image_path("/dir/xml.png")) => %(/dir/xml.png) - } - - PathToImageToTag = { - %(path_to_image("xml")) => %(/images/xml), - %(path_to_image("xml.png")) => %(/images/xml.png), - %(path_to_image("dir/xml.png")) => %(/images/dir/xml.png), - %(path_to_image("/dir/xml.png")) => %(/dir/xml.png) - } - - ImageLinkToTag = { - %(image_tag("xml.png")) => %(<img alt="Xml" src="/images/xml.png" />), - %(image_tag("rss.gif", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.gif" />), - %(image_tag("gold.png", :size => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />), - %(image_tag("gold.png", "size" => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />), - %(image_tag("error.png", "size" => "45")) => %(<img alt="Error" src="/images/error.png" />), - %(image_tag("error.png", "size" => "45 x 70")) => %(<img alt="Error" src="/images/error.png" />), - %(image_tag("error.png", "size" => "x")) => %(<img alt="Error" src="/images/error.png" />), - %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />), - %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />), - %(image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />), - %(image_tag("mouse.png", :mouseover => image_path("mouse_over.png"))) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />) - } - - - def test_auto_discovery_link_tag - AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_javascript_path - JavascriptPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_path_to_javascript_alias_for_javascript_path - PathToJavascriptToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_javascript_include_tag_with_blank_asset_id - ENV["RAILS_ASSET_ID"] = "" - JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_javascript_include_tag_with_given_asset_id - ENV["RAILS_ASSET_ID"] = "1" - assert_dom_equal(%(<script src="/javascripts/prototype.js?1" type="text/javascript"></script>\n<script src="/javascripts/effects.js?1" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js?1" type="text/javascript"></script>\n<script src="/javascripts/controls.js?1" type="text/javascript"></script>\n<script src="/javascripts/application.js?1" type="text/javascript"></script>), javascript_include_tag(:defaults)) - end - - def test_javascript_include_tag_is_html_safe - assert javascript_include_tag(:defaults).html_safe? - assert javascript_include_tag("prototype").html_safe? - end - - def test_register_javascript_include_default - ENV["RAILS_ASSET_ID"] = "" - ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' - assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults) - end - - def test_register_javascript_include_default_mixed_defaults - ENV["RAILS_ASSET_ID"] = "" - ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' - ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2' - assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults) - end - - def test_custom_javascript_expansions - ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => ["head", "body", "tail"] - assert_dom_equal %(<script src="/javascripts/first.js" type="text/javascript"></script>\n<script src="/javascripts/head.js" type="text/javascript"></script>\n<script src="/javascripts/body.js" type="text/javascript"></script>\n<script src="/javascripts/tail.js" type="text/javascript"></script>\n<script src="/javascripts/last.js" type="text/javascript"></script>), javascript_include_tag('first', :monkey, 'last') - end - - def test_custom_javascript_expansions_and_defaults_puts_application_js_at_the_end - ENV["RAILS_ASSET_ID"] = "" - ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => ["head", "body", "tail"] - assert_dom_equal %(<script src="/javascripts/first.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/head.js" type="text/javascript"></script>\n<script src="/javascripts/body.js" type="text/javascript"></script>\n<script src="/javascripts/tail.js" type="text/javascript"></script>\n<script src="/javascripts/last.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag('first', :defaults, :monkey, 'last') - end - - def test_custom_javascript_expansions_with_undefined_symbol - ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => nil - assert_raise(ArgumentError) { javascript_include_tag('first', :monkey, 'last') } - end - - def test_stylesheet_path - StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_path_to_stylesheet_alias_for_stylesheet_path - PathToStyleToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_stylesheet_link_tag - ENV["RAILS_ASSET_ID"] = "" - StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_stylesheet_link_tag_is_html_safe - ENV["RAILS_ASSET_ID"] = "" - assert stylesheet_link_tag('dir/file').html_safe? - assert stylesheet_link_tag('dir/other/file', 'dir/file2').html_safe? - assert stylesheet_tag('dir/file', {}).html_safe? - end - - def test_custom_stylesheet_expansions - ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => ["head", "body", "tail"] - assert_dom_equal %(<link href="/stylesheets/first.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/head.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/body.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/tail.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/last.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag('first', :monkey, 'last') - end - - def test_custom_stylesheet_expansions_with_undefined_symbol - ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => nil - assert_raise(ArgumentError) { stylesheet_link_tag('first', :monkey, 'last') } - end - - def test_image_path - ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_path_to_image_alias_for_image_path - PathToImageToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_image_tag - ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_image_tag_windows_behaviour - old_asset_id, ENV["RAILS_ASSET_ID"] = ENV["RAILS_ASSET_ID"], "1" - # This simulates the behaviour of File#exist? on windows when testing a file ending in "." - # If the file "rails.png" exists, windows will return true when asked if "rails.png." exists (notice trailing ".") - # OS X, linux etc will return false in this case. - File.stubs(:exist?).with('template/../fixtures/public/images/rails.png.').returns(true) - assert_equal '<img alt="Rails" src="/images/rails.png?1" />', image_tag('rails.png') - ensure - if old_asset_id - ENV["RAILS_ASSET_ID"] = old_asset_id - else - ENV.delete("RAILS_ASSET_ID") - end - end - - def test_timebased_asset_id - expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s - assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png") - end - - def test_timebased_asset_id_with_relative_url_root - ActionController::Base.relative_url_root = "/collaboration/hieraki" - expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s - assert_equal %(<img alt="Rails" src="#{ActionController::Base.relative_url_root}/images/rails.png?#{expected_time}" />), image_tag("rails.png") - ensure - ActionController::Base.relative_url_root = "" - end - - def test_should_skip_asset_id_on_complete_url - assert_equal %(<img alt="Rails" src="http://www.example.com/rails.png" />), image_tag("http://www.example.com/rails.png") - end - - def test_should_use_preset_asset_id - ENV["RAILS_ASSET_ID"] = "4500" - assert_equal %(<img alt="Rails" src="/images/rails.png?4500" />), image_tag("rails.png") - end - - def test_preset_empty_asset_id - ENV["RAILS_ASSET_ID"] = "" - assert_equal %(<img alt="Rails" src="/images/rails.png" />), image_tag("rails.png") - end - - def test_should_not_modify_source_string - source = '/images/rails.png' - copy = source.dup - image_tag(source) - assert_equal copy, source - end - - def test_caching_image_path_with_caching_and_proc_asset_host_using_request - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Proc.new do |source, request| - if request.ssl? - "#{request.protocol}#{request.host_with_port}" - else - "#{request.protocol}assets#{source.length}.example.com" - end - end - - ActionController::Base.perform_caching = true - - - @controller.request.stubs(:ssl?).returns(false) - assert_equal "http://assets15.example.com/images/xml.png", image_path("xml.png") - - @controller.request.stubs(:ssl?).returns(true) - assert_equal "http://localhost/images/xml.png", image_path("xml.png") - end - - def test_caching_javascript_include_tag_when_caching_on - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/all.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true) - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/money.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - - assert_dom_equal( - %(<script src="http://a0.example.com/absolute/test.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "/absolute/test") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute', 'test.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute')) - end - - def test_caching_javascript_include_tag_when_caching_on_with_proc_asset_host - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" } - ActionController::Base.perform_caching = true - - assert_equal '/javascripts/scripts.js'.length, 23 - assert_dom_equal( - %(<script src="http://a23.example.com/javascripts/scripts.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'scripts') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'scripts.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'scripts.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_with_2_argument_proc_asset_host - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Proc.new { |source, request| - if request.ssl? - "#{request.protocol}#{request.host_with_port}" - else - "#{request.protocol}assets#{source.length}.example.com" - end - } - ActionController::Base.perform_caching = true - - assert_equal '/javascripts/vanilla.js'.length, 23 - assert_dom_equal( - %(<script src="http://assets23.example.com/javascripts/vanilla.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'vanilla') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - - class << @controller.request - def protocol() 'https://' end - def ssl?() true end - end - - assert_equal '/javascripts/secure.js'.length, 22 - assert_dom_equal( - %(<script src="https://localhost/javascripts/secure.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'secure') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_with_2_argument_object_asset_host - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Class.new do - def call(source, request) - if request.ssl? - "#{request.protocol}#{request.host_with_port}" - else - "#{request.protocol}assets#{source.length}.example.com" - end - end - end.new - - ActionController::Base.perform_caching = true - - assert_equal '/javascripts/vanilla.js'.length, 23 - assert_dom_equal( - %(<script src="http://assets23.example.com/javascripts/vanilla.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'vanilla') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - - class << @controller.request - def protocol() 'https://' end - def ssl?() true end - end - - assert_equal '/javascripts/secure.js'.length, 22 - assert_dom_equal( - %(<script src="https://localhost/javascripts/secure.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'secure') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a%d.example.com' - ActionController::Base.perform_caching = true - - hash = '/javascripts/cache/money.js'.hash % 4 - assert_dom_equal( - %(<script src="http://a#{hash}.example.com/javascripts/cache/money.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "cache/money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) - end - - def test_caching_javascript_include_tag_with_all_and_recursive_puts_defaults_at_the_start_of_the_file - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/combined.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "combined", :recursive => true) - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - - assert_equal( - %(// prototype js\n\n// effects js\n\n// dragdrop js\n\n// controls js\n\n// application js\n\n// bank js\n\n// robber js\n\n// subdir js\n\n\n// version.1.0 js), - IO.read(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - ) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - end - - def test_caching_javascript_include_tag_with_all_puts_defaults_at_the_start_of_the_file - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/combined.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "combined") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - - assert_equal( - %(// prototype js\n\n// effects js\n\n// dragdrop js\n\n// controls js\n\n// application js\n\n// bank js\n\n// robber js\n\n// version.1.0 js), - IO.read(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - ) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - end - - def test_caching_javascript_include_tag_with_relative_url_root - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.relative_url_root = "/collaboration/hieraki" - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="/collaboration/hieraki/javascripts/all.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true) - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - - assert_dom_equal( - %(<script src="/collaboration/hieraki/javascripts/money.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - - ensure - ActionController::Base.relative_url_root = nil - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - end - - def test_caching_javascript_include_tag_when_caching_off - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.perform_caching = false - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true) - ) - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/subdir/subdir.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true, :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money") - ) - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/subdir/subdir.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money", :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - end - - def test_caching_stylesheet_link_tag_when_caching_on - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<link href="http://a0.example.com/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true) - ) - - expected = Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max - assert_equal expected, File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="http://a0.example.com/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - - assert_dom_equal( - %(<link href="http://a0.example.com/absolute/test.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "/absolute/test") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute', 'test.css')) - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute')) - end - - def test_concat_stylesheet_link_tag_when_caching_off - ENV["RAILS_ASSET_ID"] = "" - - assert_dom_equal( - %(<link href="/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :concat => true) - ) - - expected = Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max - assert_equal expected, File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :concat => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - - assert_dom_equal( - %(<link href="/absolute/test.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :concat => "/absolute/test") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute', 'test.css')) - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute')) - end - - def test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" } - ActionController::Base.perform_caching = true - - assert_equal '/stylesheets/styles.css'.length, 23 - assert_dom_equal( - %(<link href="http://a23.example.com/stylesheets/styles.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => 'styles') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'styles.css')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'styles.css')) - end - - def test_caching_stylesheet_link_tag_with_relative_url_root - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.relative_url_root = "/collaboration/hieraki" - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<link href="/collaboration/hieraki/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true) - ) - - expected = Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max - assert_equal expected, File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="/collaboration/hieraki/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - ensure - ActionController::Base.relative_url_root = nil - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - end - - def test_caching_stylesheet_include_tag_when_caching_off - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.perform_caching = false - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true) - ) - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true, :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money") - ) - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money", :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - end -end - -class AssetTagHelperNonVhostTest < ActionView::TestCase - tests ActionView::Helpers::AssetTagHelper - - def setup - ActionController::Base.relative_url_root = "/collaboration/hieraki" - - @controller = Class.new do - attr_accessor :request - - def url_for(options) - "http://www.example.com/collaboration/hieraki" - end - end.new - - @request = Class.new do - def protocol - 'gopher://' - end - end.new - - @controller.request = @request - - ActionView::Helpers::AssetTagHelper::reset_javascript_include_default - end - - def teardown - ActionController::Base.relative_url_root = nil - end - - def test_should_compute_proper_path - assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag) - assert_dom_equal(%(/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr")) - assert_dom_equal(%(/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style")) - assert_dom_equal(%(/collaboration/hieraki/images/xml.png), image_path("xml.png")) - assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse.png'" src="/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) - assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse2.png'" src="/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png"))) - end - - def test_should_ignore_relative_root_path_on_complete_url - assert_dom_equal(%(http://www.example.com/images/xml.png), image_path("http://www.example.com/images/xml.png")) - end - - def test_should_compute_proper_path_with_asset_host - ActionController::Base.asset_host = "http://assets.example.com" - assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag) - assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr")) - assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style")) - assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png")) - assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) - assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse2.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png"))) - ensure - ActionController::Base.asset_host = "" - end - - def test_should_ignore_asset_host_on_complete_url - ActionController::Base.asset_host = "http://assets.example.com" - assert_dom_equal(%(<link href="http://bar.example.com/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag("http://bar.example.com/stylesheets/style.css")) - ensure - ActionController::Base.asset_host = "" - end - - def test_should_wildcard_asset_host_between_zero_and_four - ActionController::Base.asset_host = 'http://a%d.example.com' - assert_match %r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png') - ensure - ActionController::Base.asset_host = nil - end - - def test_asset_host_without_protocol_should_use_request_protocol - ActionController::Base.asset_host = 'a.example.com' - assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_path('xml.png') - ensure - ActionController::Base.asset_host = nil - end - - def test_asset_host_without_protocol_should_use_request_protocol_even_if_path_present - ActionController::Base.asset_host = 'a.example.com/files/go/here' - assert_equal 'gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png', image_path('xml.png') - ensure - ActionController::Base.asset_host = nil - end - - def test_assert_css_and_js_of_the_same_name_return_correct_extension - assert_dom_equal(%(/collaboration/hieraki/javascripts/foo.js), javascript_path("foo")) - assert_dom_equal(%(/collaboration/hieraki/stylesheets/foo.css), stylesheet_path("foo")) - - end -end diff --git a/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb b/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb deleted file mode 100644 index 01a4178b..00000000 --- a/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +++ /dev/null @@ -1,315 +0,0 @@ -require 'abstract_unit' - -Scroll = Struct.new(:id, :to_param, :title, :body, :updated_at, :created_at) - -class ScrollsController < ActionController::Base - FEEDS = {} - FEEDS["defaults"] = <<-EOT - atom_feed(:schema_date => '2008') do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["entry_options"] = <<-EOT - atom_feed do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll, :url => "/otherstuff/" + scroll.to_param, :updated => Time.utc(2007, 1, scroll.id)) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["xml_block"] = <<-EOT - atom_feed do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - feed.author do |author| - author.name("DHH") - end - - for scroll in @scrolls - feed.entry(scroll, :url => "/otherstuff/" + scroll.to_param, :updated => Time.utc(2007, 1, scroll.id)) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - end - end - end - EOT - FEEDS["feed_with_atomPub_namespace"] = <<-EOT - atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', - 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - entry.tag!('app:edited', Time.now) - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_overridden_ids"] = <<-EOT - atom_feed({:id => 'tag:test.rubyonrails.org,2008:test/'}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll, :id => "tag:test.rubyonrails.org,2008:"+scroll.id.to_s) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - entry.tag!('app:edited', Time.now) - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_xml_processing_instructions"] = <<-EOT - atom_feed(:schema_date => '2008', - :instruct => {'xml-stylesheet' => { :href=> 't.css', :type => 'text/css' }}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_xml_processing_instructions_duplicate_targets"] = <<-EOT - atom_feed(:schema_date => '2008', - :instruct => {'target1' => [{ :a => '1', :b => '2' }, { :c => '3', :d => '4' }]}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_xhtml_content"] = <<-'EOT' - atom_feed do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.summary(:type => 'xhtml') do |xhtml| - xhtml.p "before #{scroll.id}" - xhtml.p {xhtml << scroll.body} - xhtml.p "after #{scroll.id}" - end - entry.tag!('app:edited', Time.now) - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["provide_builder"] = <<-'EOT' - # we pass in the new_xml to the helper so it doesn't - # call anything on the original builder - new_xml = Builder::XmlMarkup.new(:target=>'') - atom_feed(:xml => new_xml) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - def index - @scrolls = [ - Scroll.new(1, "1", "Hello One", "Something <i>COOL!</i>", Time.utc(2007, 12, 12, 15), Time.utc(2007, 12, 12, 15)), - Scroll.new(2, "2", "Hello Two", "Something Boring", Time.utc(2007, 12, 12, 15)), - ] - - render :inline => FEEDS[params[:id]], :type => :builder - end - - protected - - def rescue_action(e) - raise(e) - end -end - -class AtomFeedTest < ActionController::TestCase - tests ScrollsController - - def setup - @request.host = "www.nextangle.com" - end - - def test_feed_should_use_default_language_if_none_is_given - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_match %r{xml:lang="en-US"}, @response.body - end - end - - def test_feed_should_include_two_entries - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "entry", 2 - end - end - - def test_entry_should_only_use_published_if_created_at_is_present - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "published", 1 - end - end - - def test_providing_builder_to_atom_feed - with_restful_routing(:scrolls) do - get :index, :id=>"provide_builder" - # because we pass in the non-default builder, the content generated by the - # helper should go 'nowhere'. Leaving the response body blank. - assert @response.body.blank? - end - end - - def test_entry_with_prefilled_options_should_use_those_instead_of_querying_the_record - with_restful_routing(:scrolls) do - get :index, :id => "entry_options" - - assert_select "updated", Time.utc(2007, 1, 1).xmlschema - assert_select "updated", Time.utc(2007, 1, 2).xmlschema - end - end - - def test_self_url_should_default_to_current_request_url - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "link[rel=self][href=http://www.nextangle.com/scrolls?id=defaults]" - end - end - - def test_feed_id_should_be_a_valid_tag - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "id", :text => "tag:www.nextangle.com,2008:/scrolls?id=defaults" - end - end - - def test_entry_id_should_be_a_valid_tag - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "entry id", :text => "tag:www.nextangle.com,2008:Scroll/1" - assert_select "entry id", :text => "tag:www.nextangle.com,2008:Scroll/2" - end - end - - def test_feed_should_allow_nested_xml_blocks - with_restful_routing(:scrolls) do - get :index, :id => "xml_block" - assert_select "author name", :text => "DHH" - end - end - - def test_feed_should_include_atomPub_namespace - with_restful_routing(:scrolls) do - get :index, :id => "feed_with_atomPub_namespace" - assert_match %r{xml:lang="en-US"}, @response.body - assert_match %r{xmlns="http://www.w3.org/2005/Atom"}, @response.body - assert_match %r{xmlns:app="http://www.w3.org/2007/app"}, @response.body - end - end - - def test_feed_should_allow_overriding_ids - with_restful_routing(:scrolls) do - get :index, :id => "feed_with_overridden_ids" - assert_select "id", :text => "tag:test.rubyonrails.org,2008:test/" - assert_select "entry id", :text => "tag:test.rubyonrails.org,2008:1" - assert_select "entry id", :text => "tag:test.rubyonrails.org,2008:2" - end - end - - def test_feed_xml_processing_instructions - with_restful_routing(:scrolls) do - get :index, :id => 'feed_with_xml_processing_instructions' - assert_match %r{<\?xml-stylesheet [^\?]*type="text/css"}, @response.body - assert_match %r{<\?xml-stylesheet [^\?]*href="t.css"}, @response.body - end - end - - def test_feed_xml_processing_instructions_duplicate_targets - with_restful_routing(:scrolls) do - get :index, :id => 'feed_with_xml_processing_instructions_duplicate_targets' - assert_match %r{<\?target1 (a="1" b="2"|b="2" a="1")\?>}, @response.body - assert_match %r{<\?target1 (c="3" d="4"|d="4" c="3")\?>}, @response.body - end - end - - def test_feed_xhtml - with_restful_routing(:scrolls) do - get :index, :id => "feed_with_xhtml_content" - assert_match %r{xmlns="http://www.w3.org/1999/xhtml"}, @response.body - assert_select "summary div p", :text => "Something Boring" - assert_select "summary div p", :text => "after 2" - end - end -private - def with_restful_routing(resources) - with_routing do |set| - set.draw do |map| - map.resources(resources) - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/template/benchmark_helper_test.rb b/vendor/rails/actionpack/test/template/benchmark_helper_test.rb deleted file mode 100644 index ac31fc65..00000000 --- a/vendor/rails/actionpack/test/template/benchmark_helper_test.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'abstract_unit' -require 'action_view/helpers/benchmark_helper' - -class BenchmarkHelperTest < ActionView::TestCase - tests ActionView::Helpers::BenchmarkHelper - - def setup - super - controller.logger = ActiveSupport::BufferedLogger.new(StringIO.new) - controller.logger.auto_flushing = false - end - - def teardown - controller.logger.send(:clear_buffer) - end - - def test_without_block - assert_raise(LocalJumpError) { benchmark } - assert buffer.empty? - end - - def test_defaults - i_was_run = false - benchmark { i_was_run = true } - assert i_was_run - assert_last_logged - end - - def test_with_message - i_was_run = false - benchmark('test_run') { i_was_run = true } - assert i_was_run - assert_last_logged 'test_run' - end - - def test_with_message_and_deprecated_level - i_was_run = false - - assert_deprecated do - benchmark('debug_run', :debug) { i_was_run = true } - end - - assert i_was_run - assert_last_logged 'debug_run' - end - - def test_within_level - controller.logger.level = ActiveSupport::BufferedLogger::DEBUG - benchmark('included_debug_run', :level => :debug) { } - assert_last_logged 'included_debug_run' - end - - def test_outside_level - controller.logger.level = ActiveSupport::BufferedLogger::ERROR - benchmark('skipped_debug_run', :level => :debug) { } - assert_no_match(/skipped_debug_run/, buffer.last) - ensure - controller.logger.level = ActiveSupport::BufferedLogger::DEBUG - end - - def test_without_silencing - benchmark('debug_run', :silence => false) do - controller.logger.info "not silenced!" - end - - assert_equal 2, buffer.size - end - - def test_with_silencing - benchmark('debug_run', :silence => true) do - controller.logger.info "silenced!" - end - - assert_equal 1, buffer.size - end - - - private - def buffer - controller.logger.send(:buffer) - end - - def assert_last_logged(message = 'Benchmarking') - assert_match(/^#{message} \(.*\)$/, buffer.last) - end -end diff --git a/vendor/rails/actionpack/test/template/compiled_templates_test.rb b/vendor/rails/actionpack/test/template/compiled_templates_test.rb deleted file mode 100644 index 760f9be5..00000000 --- a/vendor/rails/actionpack/test/template/compiled_templates_test.rb +++ /dev/null @@ -1,204 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_models' - -class CompiledTemplatesTest < Test::Unit::TestCase - - def setup - @explicit_view_paths = nil - @compiled_templates = ActionView::Base::CompiledTemplates - @compiled_templates.instance_methods.each do |m| - @compiled_templates.send(:remove_method, m) if m =~ /^_run_/ - end - end - - def test_template_gets_compiled - with_caching(true) do - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - assert_equal 1, @compiled_templates.instance_methods.size - end - end - - def test_template_gets_recompiled_when_using_different_keys_in_local_assigns - with_caching(true) do - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - assert_equal "Hello world!", render(:file => "test/hello_world.erb", :locals => {:foo => "bar"}) - assert_equal 2, @compiled_templates.instance_methods.size - end - end - - def test_compiled_template_will_not_be_recompiled_when_rendered_with_identical_local_assigns - with_caching(true) do - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - ActionView::Template.any_instance.expects(:compile!).never - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - end - - def test_template_changes_are_not_reflected_with_cached_template_loading - with_caching(true) do - with_reloading(false) do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - end - end - - def test_template_changes_are_reflected_without_cached_template_loading - with_caching(true) do - with_reloading(true) do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Goodbye world!", render(:file => "test/hello_world.erb") - end - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - end - end - - def test_template_becomes_missing_if_deleted_without_cached_template_loading - with_reloading(true) do - assert_equal 'Hello world!', render(:file => 'test/hello_world.erb') - delete_template 'test/hello_world.erb' do - assert_raise(ActionView::MissingTemplate) { render(:file => 'test/hello_world.erb') } - end - assert_equal 'Hello world!', render(:file => 'test/hello_world.erb') - end - end - - def test_swapping_template_handler_is_working_without_cached_template_loading - with_reloading(true) do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - delete_template 'test/hello_world.erb' do - rename_template 'test/hello_world_from_rxml.builder', 'test/hello_world.builder' do - assert_equal "<html>\n <p>Hello</p>\n</html>\n", render(:file => 'test/hello_world') - end - end - assert_equal 'Hello world!', render(:file => 'test/hello_world') - end - end - - def test_adding_localized_template_will_take_precedence_without_cached_template_loading - with_reloading(true) do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - rename_template 'test/hello_world.da.html.erb', 'test/hello_world.en.html.erb' do - assert_equal 'Hey verden', render(:file => 'test/hello_world') - end - end - end - - def test_deleting_localized_template_will_fall_back_to_non_localized_template_without_cached_template_loading - with_reloading(true) do - rename_template 'test/hello_world.da.html.erb', 'test/hello_world.en.html.erb' do - assert_equal 'Hey verden', render(:file => 'test/hello_world') - delete_template 'test/hello_world.en.html.erb' do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - end - assert_equal 'Hey verden', render(:file => 'test/hello_world') - end - end - end - - def test_parallel_reloadable_view_paths_are_working - with_reloading(true) do - view_paths_copy = new_reloadable_view_paths - assert_equal 'Hello world!', render(:file => 'test/hello_world') - with_view_paths(view_paths_copy, new_reloadable_view_paths) do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - end - modify_template 'test/hello_world.erb', 'Goodbye world!' do - assert_equal 'Goodbye world!', render(:file => 'test/hello_world') - modify_template 'test/hello_world.erb', 'So long, world!' do - with_view_paths(view_paths_copy, new_reloadable_view_paths) do - assert_equal 'So long, world!', render(:file => 'test/hello_world') - end - assert_equal 'So long, world!', render(:file => 'test/hello_world') - end - end - end - end - - private - def render(*args) - view_paths = @explicit_view_paths || ActionController::Base.view_paths - ActionView::Base.new(view_paths, {}).render(*args) - end - - def with_view_paths(*args) - args.each do |view_paths| - begin - @explicit_view_paths = view_paths - yield - ensure - @explicit_view_paths = nil - end - end - end - - def reset_mtime_of(template_name, view_paths_to_use) - view_paths_to_use.find_template(template_name).previously_last_modified = 10.seconds.ago unless ActionView::Base.cache_template_loading? - end - - def modify_template(template, content, view_paths_to_use = ActionController::Base.view_paths) - filename = filename_for(template) - old_content = File.read(filename) - begin - File.open(filename, "wb+") { |f| f.write(content) } - reset_mtime_of(template, view_paths_to_use) - yield - ensure - File.open(filename, "wb+") { |f| f.write(old_content) } - reset_mtime_of(template, view_paths_to_use) - end - end - - def filename_for(template) - File.join(FIXTURE_LOAD_PATH, template) - end - - def rename_template(old_name, new_name) - File.rename(filename_for(old_name), filename_for(new_name)) - yield - ensure - File.rename(filename_for(new_name), filename_for(old_name)) - end - - def delete_template(template, &block) - rename_template(template, File.join(File.dirname(template), "__#{File.basename(template)}"), &block) - end - - def with_caching(perform_caching) - old_perform_caching = ActionController::Base.perform_caching - begin - ActionController::Base.perform_caching = perform_caching - yield - ensure - ActionController::Base.perform_caching = old_perform_caching - end - end - - def with_reloading(reload_templates, view_paths_owner = ActionController::Base) - old_view_paths, old_cache_templates = view_paths_owner.view_paths, ActionView::Base.cache_template_loading - begin - ActionView::Base.cache_template_loading = !reload_templates - view_paths_owner.view_paths = view_paths_for(reload_templates) - yield - ensure - view_paths_owner.view_paths, ActionView::Base.cache_template_loading = old_view_paths, old_cache_templates - end - end - - def new_reloadable_view_paths - ActionView::PathSet.new(CACHED_VIEW_PATHS.map(&:to_s)) - end - - def view_paths_for(reload_templates) - # reloadable paths are cheap to create - reload_templates ? new_reloadable_view_paths : CACHED_VIEW_PATHS - end -end diff --git a/vendor/rails/actionpack/test/template/date_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/date_helper_i18n_test.rb deleted file mode 100644 index b69a4496..00000000 --- a/vendor/rails/actionpack/test/template/date_helper_i18n_test.rb +++ /dev/null @@ -1,121 +0,0 @@ -require 'abstract_unit' - -class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase - include ActionView::Helpers::DateHelper - attr_reader :request - - def setup - @from = Time.mktime(2004, 6, 6, 21, 45, 0) - end - - # distance_of_time_in_words - - def test_distance_of_time_in_words_calls_i18n - { # with include_seconds - [2.seconds, true] => [:'less_than_x_seconds', 5], - [9.seconds, true] => [:'less_than_x_seconds', 10], - [19.seconds, true] => [:'less_than_x_seconds', 20], - [30.seconds, true] => [:'half_a_minute', nil], - [59.seconds, true] => [:'less_than_x_minutes', 1], - [60.seconds, true] => [:'x_minutes', 1], - - # without include_seconds - [29.seconds, false] => [:'less_than_x_minutes', 1], - [60.seconds, false] => [:'x_minutes', 1], - [44.minutes, false] => [:'x_minutes', 44], - [61.minutes, false] => [:'about_x_hours', 1], - [24.hours, false] => [:'x_days', 1], - [30.days, false] => [:'about_x_months', 1], - [60.days, false] => [:'x_months', 2], - [1.year, false] => [:'about_x_years', 1], - [3.years + 6.months, false] => [:'over_x_years', 3], - [3.years + 10.months, false] => [:'almost_x_years', 4] - - }.each do |passed, expected| - assert_distance_of_time_in_words_translates_key passed, expected - end - end - - def assert_distance_of_time_in_words_translates_key(passed, expected) - diff, include_seconds = *passed - key, count = *expected - to = @from + diff - - options = {:locale => 'en', :scope => :'datetime.distance_in_words'} - options[:count] = count if count - - I18n.expects(:t).with(key, options) - distance_of_time_in_words(@from, to, include_seconds, :locale => 'en') - end - - def test_distance_of_time_pluralizations - { [:'less_than_x_seconds', 1] => 'less than 1 second', - [:'less_than_x_seconds', 2] => 'less than 2 seconds', - [:'less_than_x_minutes', 1] => 'less than a minute', - [:'less_than_x_minutes', 2] => 'less than 2 minutes', - [:'x_minutes', 1] => '1 minute', - [:'x_minutes', 2] => '2 minutes', - [:'about_x_hours', 1] => 'about 1 hour', - [:'about_x_hours', 2] => 'about 2 hours', - [:'x_days', 1] => '1 day', - [:'x_days', 2] => '2 days', - [:'about_x_years', 1] => 'about 1 year', - [:'about_x_years', 2] => 'about 2 years', - [:'over_x_years', 1] => 'over 1 year', - [:'over_x_years', 2] => 'over 2 years' - - }.each do |args, expected| - key, count = *args - assert_equal expected, I18n.t(key, :count => count, :scope => 'datetime.distance_in_words') - end - end -end - -class DateHelperSelectTagsI18nTests < Test::Unit::TestCase - include ActionView::Helpers::DateHelper - attr_reader :request - - def setup - @prompt_defaults = {:year => 'Year', :month => 'Month', :day => 'Day', :hour => 'Hour', :minute => 'Minute', :second => 'Seconds'} - - I18n.stubs(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES - end - - # select_month - - def test_select_month_given_use_month_names_option_does_not_translate_monthnames - I18n.expects(:translate).never - select_month(8, :locale => 'en', :use_month_names => Date::MONTHNAMES) - end - - def test_select_month_translates_monthnames - I18n.expects(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES - select_month(8, :locale => 'en') - end - - def test_select_month_given_use_short_month_option_translates_abbr_monthnames - I18n.expects(:translate).with(:'date.abbr_month_names', :locale => 'en').returns Date::ABBR_MONTHNAMES - select_month(8, :locale => 'en', :use_short_month => true) - end - - def test_date_or_time_select_translates_prompts - @prompt_defaults.each do |key, prompt| - I18n.expects(:translate).with(('datetime.prompts.' + key.to_s).to_sym, :locale => 'en').returns prompt - end - - I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day] - datetime_select('post', 'updated_at', :locale => 'en', :include_seconds => true, :prompt => true) - end - - # date_or_time_select - - def test_date_or_time_select_given_an_order_options_does_not_translate_order - I18n.expects(:translate).never - datetime_select('post', 'updated_at', :order => [:year, :month, :day], :locale => 'en') - end - - def test_date_or_time_select_given_no_order_options_translates_order - I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day] - datetime_select('post', 'updated_at', :locale => 'en') - end -end diff --git a/vendor/rails/actionpack/test/template/date_helper_test.rb b/vendor/rails/actionpack/test/template/date_helper_test.rb deleted file mode 100644 index 9a2d4908..00000000 --- a/vendor/rails/actionpack/test/template/date_helper_test.rb +++ /dev/null @@ -1,2603 +0,0 @@ -require 'abstract_unit' - -class DateHelperTest < ActionView::TestCase - tests ActionView::Helpers::DateHelper - - silence_warnings do - Post = Struct.new("Post", :id, :written_on, :updated_at) - Post.class_eval do - def id - 123 - end - def id_before_type_cast - 123 - end - def to_param - '123' - end - end - end - - def assert_distance_of_time_in_words(from, to=nil) - to ||= from - - # 0..1 with include_seconds - assert_equal "less than 5 seconds", distance_of_time_in_words(from, to + 0.seconds, true) - assert_equal "less than 5 seconds", distance_of_time_in_words(from, to + 4.seconds, true) - assert_equal "less than 10 seconds", distance_of_time_in_words(from, to + 5.seconds, true) - assert_equal "less than 10 seconds", distance_of_time_in_words(from, to + 9.seconds, true) - assert_equal "less than 20 seconds", distance_of_time_in_words(from, to + 10.seconds, true) - assert_equal "less than 20 seconds", distance_of_time_in_words(from, to + 19.seconds, true) - assert_equal "half a minute", distance_of_time_in_words(from, to + 20.seconds, true) - assert_equal "half a minute", distance_of_time_in_words(from, to + 39.seconds, true) - assert_equal "less than a minute", distance_of_time_in_words(from, to + 40.seconds, true) - assert_equal "less than a minute", distance_of_time_in_words(from, to + 59.seconds, true) - assert_equal "1 minute", distance_of_time_in_words(from, to + 60.seconds, true) - assert_equal "1 minute", distance_of_time_in_words(from, to + 89.seconds, true) - - # First case 0..1 - assert_equal "less than a minute", distance_of_time_in_words(from, to + 0.seconds) - assert_equal "less than a minute", distance_of_time_in_words(from, to + 29.seconds) - assert_equal "1 minute", distance_of_time_in_words(from, to + 30.seconds) - assert_equal "1 minute", distance_of_time_in_words(from, to + 1.minutes + 29.seconds) - - # 2..44 - assert_equal "2 minutes", distance_of_time_in_words(from, to + 1.minutes + 30.seconds) - assert_equal "44 minutes", distance_of_time_in_words(from, to + 44.minutes + 29.seconds) - - # 45..89 - assert_equal "about 1 hour", distance_of_time_in_words(from, to + 44.minutes + 30.seconds) - assert_equal "about 1 hour", distance_of_time_in_words(from, to + 89.minutes + 29.seconds) - - # 90..1439 - assert_equal "about 2 hours", distance_of_time_in_words(from, to + 89.minutes + 30.seconds) - assert_equal "about 24 hours", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 29.seconds) - - # 1440..2529 - assert_equal "1 day", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 30.seconds) - assert_equal "1 day", distance_of_time_in_words(from, to + 41.hours + 59.minutes + 29.seconds) - - # 2530..43199 - assert_equal "2 days", distance_of_time_in_words(from, to + 42.hours + 59.minutes + 30.seconds) - assert_equal "3 days", distance_of_time_in_words(from, to + 2.days + 12.hours) - assert_equal "30 days", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 29.seconds) - - # 43200..86399 - assert_equal "about 1 month", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 30.seconds) - assert_equal "about 1 month", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 29.seconds) - - # 86400..525599 - assert_equal "2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 30.seconds) - assert_equal "12 months", distance_of_time_in_words(from, to + 1.years - 31.seconds) - - # > 525599 - assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years - 30.seconds) - assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years + 3.months - 1.day) - assert_equal "over 1 year", distance_of_time_in_words(from, to + 1.years + 6.months) - - assert_equal "almost 2 years", distance_of_time_in_words(from, to + 2.years - 3.months + 1.day) - assert_equal "about 2 years", distance_of_time_in_words(from, to + 2.years + 3.months - 1.day) - assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 3.months + 1.day) - assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 9.months - 1.day) - assert_equal "almost 3 years", distance_of_time_in_words(from, to + 2.years + 9.months + 1.day) - - assert_equal "almost 5 years", distance_of_time_in_words(from, to + 5.years - 3.months + 1.day) - assert_equal "about 5 years", distance_of_time_in_words(from, to + 5.years + 3.months - 1.day) - assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 3.months + 1.day) - assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 9.months - 1.day) - assert_equal "almost 6 years", distance_of_time_in_words(from, to + 5.years + 9.months + 1.day) - - assert_equal "almost 10 years", distance_of_time_in_words(from, to + 10.years - 3.months + 1.day) - assert_equal "about 10 years", distance_of_time_in_words(from, to + 10.years + 3.months - 1.day) - assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years + 3.months + 1.day) - assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years + 9.months - 1.day) - assert_equal "almost 11 years", distance_of_time_in_words(from, to + 10.years + 9.months + 1.day) - - # test to < from - assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to) - assert_equal "less than 20 seconds", distance_of_time_in_words(from + 19.seconds, to, true) - end - - def test_distance_in_words - from = Time.mktime(2004, 6, 6, 21, 45, 0) - assert_distance_of_time_in_words(from) - end - - def test_distance_in_words_with_time_zones - from = Time.mktime(2004, 6, 6, 21, 45, 0) - assert_distance_of_time_in_words(from.in_time_zone('Alaska')) - assert_distance_of_time_in_words(from.in_time_zone('Hawaii')) - end - - def test_distance_in_words_with_different_time_zones - from = Time.mktime(2004, 6, 6, 21, 45, 0) - assert_distance_of_time_in_words( - from.in_time_zone('Alaska'), - from.in_time_zone('Hawaii') - ) - end - - def test_distance_in_words_with_dates - start_date = Date.new 1975, 1, 31 - end_date = Date.new 1977, 1, 31 - assert_equal("about 2 years", distance_of_time_in_words(start_date, end_date)) - end - - def test_distance_in_words_with_integers - assert_equal "less than a minute", distance_of_time_in_words(59) - assert_equal "about 1 hour", distance_of_time_in_words(60*60) - assert_equal "less than a minute", distance_of_time_in_words(0, 59) - assert_equal "about 1 hour", distance_of_time_in_words(60*60, 0) - end - - def test_time_ago_in_words - assert_equal "about 1 year", time_ago_in_words(1.year.ago - 1.day) - end - - def test_select_day - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16)) - assert_dom_equal expected, select_day(16) - end - - def test_select_day_with_blank - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value=""></option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true) - assert_dom_equal expected, select_day(16, :include_blank => true) - end - - def test_select_day_nil_with_blank - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value=""></option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(nil, :include_blank => true) - end - - def test_select_day_with_html_options - expected = %(<select id="date_day" name="date[day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), {}, :class => 'selector') - assert_dom_equal expected, select_day(16, {}, :class => 'selector') - end - - def test_select_day_with_default_prompt - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(16, :prompt => true) - end - - def test_select_day_with_custom_prompt - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(16, :prompt => 'Choose day') - end - - def test_select_month - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16)) - assert_dom_equal expected, select_month(8) - end - - def test_select_month_with_disabled - expected = %(<select id="date_month" name="date[month]" disabled="disabled">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :disabled => true) - assert_dom_equal expected, select_month(8, :disabled => true) - end - - def test_select_month_with_field_name_override - expected = %(<select id="date_mois" name="date[mois]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :field_name => 'mois') - assert_dom_equal expected, select_month(8, :field_name => 'mois') - end - - def test_select_month_with_blank - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :include_blank => true) - assert_dom_equal expected, select_month(8, :include_blank => true) - end - - def test_select_month_nil_with_blank - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(nil, :include_blank => true) - end - - def test_select_month_with_numbers - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8" selected="selected">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true) - assert_dom_equal expected, select_month(8, :use_month_numbers => true) - end - - def test_select_month_with_numbers_and_names - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">1 - January</option>\n<option value="2">2 - February</option>\n<option value="3">3 - March</option>\n<option value="4">4 - April</option>\n<option value="5">5 - May</option>\n<option value="6">6 - June</option>\n<option value="7">7 - July</option>\n<option value="8" selected="selected">8 - August</option>\n<option value="9">9 - September</option>\n<option value="10">10 - October</option>\n<option value="11">11 - November</option>\n<option value="12">12 - December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true) - assert_dom_equal expected, select_month(8, :add_month_numbers => true) - end - - def test_select_month_with_numbers_and_names_with_abbv - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">1 - Jan</option>\n<option value="2">2 - Feb</option>\n<option value="3">3 - Mar</option>\n<option value="4">4 - Apr</option>\n<option value="5">5 - May</option>\n<option value="6">6 - Jun</option>\n<option value="7">7 - Jul</option>\n<option value="8" selected="selected">8 - Aug</option>\n<option value="9">9 - Sep</option>\n<option value="10">10 - Oct</option>\n<option value="11">11 - Nov</option>\n<option value="12">12 - Dec</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true, :use_short_month => true) - assert_dom_equal expected, select_month(8, :add_month_numbers => true, :use_short_month => true) - end - - def test_select_month_with_abbv - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">Jan</option>\n<option value="2">Feb</option>\n<option value="3">Mar</option>\n<option value="4">Apr</option>\n<option value="5">May</option>\n<option value="6">Jun</option>\n<option value="7">Jul</option>\n<option value="8" selected="selected">Aug</option>\n<option value="9">Sep</option>\n<option value="10">Oct</option>\n<option value="11">Nov</option>\n<option value="12">Dec</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_short_month => true) - assert_dom_equal expected, select_month(8, :use_short_month => true) - end - - def test_select_month_with_custom_names - month_names = %w(nil Januar Februar Marts April Maj Juni Juli August September Oktober November December) - - expected = %(<select id="date_month" name="date[month]">\n) - 1.upto(12) { |month| expected << %(<option value="#{month}"#{' selected="selected"' if month == 8}>#{month_names[month]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) - assert_dom_equal expected, select_month(8, :use_month_names => month_names) - end - - def test_select_month_with_zero_indexed_custom_names - month_names = %w(Januar Februar Marts April Maj Juni Juli August September Oktober November December) - - expected = %(<select id="date_month" name="date[month]">\n) - 1.upto(12) { |month| expected << %(<option value="#{month}"#{' selected="selected"' if month == 8}>#{month_names[month-1]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) - assert_dom_equal expected, select_month(8, :use_month_names => month_names) - end - - def test_select_month_with_hidden - assert_dom_equal "<input type=\"hidden\" id=\"date_month\" name=\"date[month]\" value=\"8\" />\n", select_month(8, :use_hidden => true) - end - - def test_select_month_with_hidden_and_field_name - assert_dom_equal "<input type=\"hidden\" id=\"date_mois\" name=\"date[mois]\" value=\"8\" />\n", select_month(8, :use_hidden => true, :field_name => 'mois') - end - - def test_select_month_with_html_options - expected = %(<select id="date_month" name="date[month]" class="selector" accesskey="M">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), {}, :class => 'selector', :accesskey => 'M') - #result = select_month(Time.mktime(2003, 8, 16), {}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_month" name="date[month]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="1">January') - end - - def test_select_month_with_default_prompt - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(8, :prompt => true) - end - - def test_select_month_with_custom_prompt - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(8, :prompt => 'Choose month') - end - - def test_select_year - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005) - assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005) - end - - def test_select_year_with_disabled - expected = %(<select id="date_year" name="date[year]" disabled="disabled">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :disabled => true, :start_year => 2003, :end_year => 2005) - assert_dom_equal expected, select_year(2003, :disabled => true, :start_year => 2003, :end_year => 2005) - end - - def test_select_year_with_field_name_override - expected = %(<select id="date_annee" name="date[annee]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :field_name => 'annee') - assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005, :field_name => 'annee') - end - - def test_select_year_with_type_discarding - expected = %(<select id="date_year" name="date_year">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year( - Time.mktime(2003, 8, 16), :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005) - assert_dom_equal expected, select_year( - 2003, :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005) - end - - def test_select_year_descending - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="2005" selected="selected">2005</option>\n<option value="2004">2004</option>\n<option value="2003">2003</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2005, 8, 16), :start_year => 2005, :end_year => 2003) - assert_dom_equal expected, select_year(2005, :start_year => 2005, :end_year => 2003) - end - - def test_select_year_with_hidden - assert_dom_equal "<input type=\"hidden\" id=\"date_year\" name=\"date[year]\" value=\"2007\" />\n", select_year(2007, :use_hidden => true) - end - - def test_select_year_with_hidden_and_field_name - assert_dom_equal "<input type=\"hidden\" id=\"date_anno\" name=\"date[anno]\" value=\"2007\" />\n", select_year(2007, :use_hidden => true, :field_name => 'anno') - end - - def test_select_year_with_html_options - expected = %(<select id="date_year" name="date[year]" class="selector" accesskey="M">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005}, :class => 'selector', :accesskey => 'M') - #result = select_year(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_year" name="date[year]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="2003"') - end - - def test_select_year_with_default_prompt - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="">Year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => true) - end - - def test_select_year_with_custom_prompt - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="">Choose year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => 'Choose year') - end - - def test_select_hour - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18)) - end - - def test_select_hour_with_disabled - expected = %(<select id="date_hour" name="date[hour]" disabled="disabled">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) - end - - def test_select_hour_with_field_name_override - expected = %(<select id="date_heure" name="date[heure]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'heure') - end - - def test_select_hour_with_blank - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) - end - - def test_select_hour_nil_with_blank - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(nil, :include_blank => true) - end - - def test_select_hour_with_html_options - expected = %(<select id="date_hour" name="date[hour]" class="selector" accesskey="M">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - end - - def test_select_hour_with_default_prompt - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true) - end - - def test_select_hour_with_custom_prompt - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose hour') - end - - def test_select_minute - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)) - end - - def test_select_minute_with_disabled - expected = %(<select id="date_minute" name="date[minute]" disabled="disabled">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) - end - - def test_select_minute_with_field_name_override - expected = %(<select id="date_minuto" name="date[minuto]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'minuto') - end - - def test_select_minute_with_blank - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) - end - - def test_select_minute_with_blank_and_step - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), { :include_blank => true , :minute_step => 15 }) - end - - def test_select_minute_nil_with_blank - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(nil, :include_blank => true) - end - - def test_select_minute_nil_with_blank_and_step - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(nil, { :include_blank => true , :minute_step => 15 }) - end - - def test_select_minute_with_hidden - assert_dom_equal "<input type=\"hidden\" id=\"date_minute\" name=\"date[minute]\" value=\"8\" />\n", select_minute(8, :use_hidden => true) - end - - def test_select_minute_with_hidden_and_field_name - assert_dom_equal "<input type=\"hidden\" id=\"date_minuto\" name=\"date[minuto]\" value=\"8\" />\n", select_minute(8, :use_hidden => true, :field_name => 'minuto') - end - - def test_select_minute_with_html_options - expected = expected = %(<select id="date_minute" name="date[minute]" class="selector" accesskey="M">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - - #result = select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_minute" name="date[minute]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="00">00') - end - - def test_select_minute_with_default_prompt - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true) - end - - def test_select_minute_with_custom_prompt - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose minute') - end - - def test_select_second - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18)) - end - - def test_select_second_with_disabled - expected = %(<select id="date_second" name="date[second]" disabled="disabled">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) - end - - def test_select_second_with_field_name_override - expected = %(<select id="date_segundo" name="date[segundo]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'segundo') - end - - def test_select_second_with_blank - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) - end - - def test_select_second_nil_with_blank - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(nil, :include_blank => true) - end - - def test_select_second_with_html_options - expected = %(<select id="date_second" name="date[second]" class="selector" accesskey="M">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - - #result = select_second(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_second" name="date[second]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="00">00') - end - - def test_select_second_with_default_prompt - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true) - end - - def test_select_second_with_custom_prompt - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Choose seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose seconds') - end - - def test_select_date - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") - end - - def test_select_date_with_order - expected = %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:month, :day, :year]) - end - - def test_select_date_with_incomplete_order - # NOTE: modified this test because of minimal API change - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day]) - end - - def test_select_date_with_disabled - expected = %(<select id="date_first_year" name="date[first][year]" disabled="disabled">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]" disabled="disabled">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]" disabled="disabled">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :disabled => true) - end - - def test_select_date_with_no_start_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+1) do |y| - if y == Date.today.year - expected << %(<option value="#{y}" selected="selected">#{y}</option>\n) - else - expected << %(<option value="#{y}">#{y}</option>\n) - end - end - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date( - Time.mktime(Date.today.year, 8, 16), :end_year => Date.today.year+1, :prefix => "date[first]" - ) - end - - def test_select_date_with_no_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - 2003.upto(2008) do |y| - if y == 2003 - expected << %(<option value="#{y}" selected="selected">#{y}</option>\n) - else - expected << %(<option value="#{y}">#{y}</option>\n) - end - end - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date( - Time.mktime(2003, 8, 16), :start_year => 2003, :prefix => "date[first]" - ) - end - - def test_select_date_with_no_start_or_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) do |y| - if y == Date.today.year - expected << %(<option value="#{y}" selected="selected">#{y}</option>\n) - else - expected << %(<option value="#{y}">#{y}</option>\n) - end - end - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date( - Time.mktime(Date.today.year, 8, 16), :prefix => "date[first]" - ) - end - - def test_select_date_with_zero_value - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]") - end - - def test_select_date_with_zero_value_and_no_start_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") - end - - def test_select_date_with_zero_value_and_no_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - last_year = Time.now.year + 5 - 2003.upto(last_year) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") - end - - def test_select_date_with_zero_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :prefix => "date[first]") - end - - def test_select_date_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(nil, :prefix => "date[first]") - end - - def test_select_date_with_html_options - expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => "selector") - end - - def test_select_date_with_separator - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << " / " - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << " / " - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), { :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]"}) - end - - def test_select_datetime - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") - end - - def test_select_datetime_with_separators - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << " &mdash; " - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :datetime_separator => ' &mdash; ', :time_separator => ' : ') - end - - def test_select_datetime_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]") - end - - def test_select_datetime_with_html_options - expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), {:start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => 'selector') - end - - def test_select_datetime_with_all_separators - expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << "/" - - expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << "/" - - expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << "&mdash;" - - expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << ":" - - expected << %(<select id="date_first_minute" name="date[first][minute]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), { :datetime_separator => "&mdash;", :date_separator => "/", :time_separator => ":", :start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => 'selector') - end - - def test_select_datetime_should_work_with_date - assert_nothing_raised { select_datetime(Date.today) } - end - - def test_select_datetime_with_default_prompt - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="">Year</option>\n<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, - :prefix => "date[first]", :prompt => true) - end - - def test_select_datetime_with_custom_prompt - - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="">Choose year</option>\n<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", - :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year', :hour => 'Choose hour', :minute => 'Choose minute'}) - end - - def test_select_time - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18)) - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => false) - end - - def test_select_time_with_separator - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ') - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ', :include_seconds => false) - end - - def test_select_time_with_seconds - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true) - end - - def test_select_time_with_seconds_and_separator - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :time_separator => ' : ') - end - - def test_select_time_with_html_options - expected = %(<select id="date_hour" name="date[hour]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector') - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {:include_seconds => false}, :class => 'selector') - end - - def test_select_time_should_work_with_date - assert_nothing_raised { select_time(Date.today) } - end - - def test_select_time_with_default_prompt - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :prompt => true) - end - - def test_select_time_with_custom_prompt - - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Choose seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true, :include_seconds => true, - :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'}) - end - - def test_date_select - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on") - end - - def test_date_select_without_day - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = "<input type=\"hidden\" id=\"post_written_on_3i\" name=\"post[written_on(3i)]\" value=\"1\" />\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ]) - end - - def test_date_select_without_day_and_with_disabled_html_option - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = "<input type=\"hidden\" id=\"post_written_on_3i\" disabled=\"disabled\" name=\"post[written_on(3i)]\" value=\"1\" />\n" - - expected << %{<select id="post_written_on_2i" disabled="disabled" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_1i" disabled="disabled" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", { :order => [ :month, :year ] }, :disabled => true) - end - - def test_date_select_within_fields_for - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - fields_for :post, @post do |f| - concat f.date_select(:written_on) - end - - expected = "<select id='post_written_on_1i' name='post[written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_written_on_2i' name='post[written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_written_on_3i' name='post[written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - - assert_dom_equal(expected, output_buffer) - end - - def test_date_select_within_fields_for_with_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = 27 - - fields_for :post, @post, :index => id do |f| - concat f.date_select(:written_on) - end - - expected = "<select id='post_#{id}_written_on_1i' name='post[#{id}][written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_2i' name='post[#{id}][written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_3i' name='post[#{id}][written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - - assert_dom_equal(expected, output_buffer) - end - - def test_date_select_within_fields_for_with_blank_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = nil - - fields_for :post, @post, :index => id do |f| - concat f.date_select(:written_on) - end - - expected = "<select id='post_#{id}_written_on_1i' name='post[#{id}][written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_2i' name='post[#{id}][written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_3i' name='post[#{id}][written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - - assert_dom_equal(expected, output_buffer) - end - - def test_date_select_with_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = 456 - - expected = %{<select id="post_456_written_on_1i" name="post[#{id}][written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_written_on_2i" name="post[#{id}][written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_written_on_3i" name="post[#{id}][written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :index => id) - end - - def test_date_select_with_auto_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = 123 - - expected = %{<select id="post_123_written_on_1i" name="post[#{id}][written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_written_on_2i" name="post[#{id}][written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_written_on_3i" name="post[#{id}][written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post[]", "written_on") - end - - def test_date_select_with_different_order - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order => [:day, :month, :year]) - end - - def test_date_select_with_nil - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - start_year.upto(end_year) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.year}>#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.month}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.day}>#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on") - end - - def test_date_select_with_nil_and_blank - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << "<option value=\"\"></option>\n" - start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(31) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :include_blank => true) - end - - def test_date_select_with_nil_and_blank_and_order - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - - expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n" - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << "<option value=\"\"></option>\n" - start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true) - end - - def test_date_select_with_nil_and_blank_and_order - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - - expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n" - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << "<option value=\"\"></option>\n" - start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true) - end - - def test_date_select_cant_override_discard_hour - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :discard_hour => false) - end - - def test_date_select_with_html_options - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]" class="selector">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]" class="selector">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]" class="selector">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", {}, :class => 'selector') - end - - def test_date_select_with_html_options_within_fields_for - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - fields_for :post, @post do |f| - concat f.date_select(:written_on, {}, :class => 'selector') - end - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]" class="selector">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]" class="selector">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]" class="selector">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_date_select_with_separator - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", { :date_separator => " / " }) - end - - def test_date_select_with_default_prompt - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="">Year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :prompt => true) - end - - def test_date_select_with_custom_prompt - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="">Choose year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day'}) - end - - def test_time_select - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on") - end - - def test_time_select_without_date_hidden_fields - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :ignore_date => true) - end - - def test_time_select_with_seconds - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_6i" name="post[written_on(6i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :include_seconds => true) - end - - def test_time_select_with_html_options - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]" class="selector">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]" class="selector">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", {}, :class => 'selector') - end - - def test_time_select_with_html_options_within_fields_for - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - fields_for :post, @post do |f| - concat f.time_select(:written_on, {}, :class => 'selector') - end - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]" class="selector">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]" class="selector">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_time_select_with_separator - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_written_on_6i" name="post[written_on(6i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", { :time_separator => " - ", :include_seconds => true }) - end - - def test_time_select_with_default_prompt - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - expected << %(<option value="">Hour</option>\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - expected << %(<option value="">Minute</option>\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :prompt => true) - end - - def test_time_select_with_custom_prompt - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - expected << %(<option value="">Choose hour</option>\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - expected << %(<option value="">Choose minute</option>\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute'}) - end - - def test_time_select_with_disabled_html_option - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" disabled="disabled" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" disabled="disabled" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" disabled="disabled" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" disabled="disabled" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" disabled="disabled" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", {}, :disabled => true) - end - - def test_datetime_select - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at") - end - - def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set - time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0) - time_zone = mock() - time_zone.expects(:now).returns time - Time.zone_default = time_zone - @post = Post.new - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at") - ensure - Time.zone_default = nil - end - - def test_datetime_select_with_html_options_within_fields_for - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - - fields_for :post, @post do |f| - concat f.datetime_select(:updated_at, {}, :class => 'selector') - end - - expected = "<select id='post_updated_at_1i' name='post[updated_at(1i)]' class='selector'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_updated_at_2i' name='post[updated_at(2i)]' class='selector'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_updated_at_3i' name='post[updated_at(3i)]' class='selector'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - expected << " &mdash; <select id='post_updated_at_4i' name='post[updated_at(4i)]' class='selector'>\n<option value='00'>00</option>\n<option value='01'>01</option>\n<option value='02'>02</option>\n<option value='03'>03</option>\n<option value='04'>04</option>\n<option value='05'>05</option>\n<option value='06'>06</option>\n<option value='07'>07</option>\n<option value='08'>08</option>\n<option value='09'>09</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option value='15'>15</option>\n<option selected='selected' value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n</select>\n" - expected << " : <select id='post_updated_at_5i' name='post[updated_at(5i)]' class='selector'>\n<option value='00'>00</option>\n<option value='01'>01</option>\n<option value='02'>02</option>\n<option value='03'>03</option>\n<option value='04'>04</option>\n<option value='05'>05</option>\n<option value='06'>06</option>\n<option value='07'>07</option>\n<option value='08'>08</option>\n<option value='09'>09</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n<option value='32'>32</option>\n<option value='33'>33</option>\n<option value='34'>34</option>\n<option selected='selected' value='35'>35</option>\n<option value='36'>36</option>\n<option value='37'>37</option>\n<option value='38'>38</option>\n<option value='39'>39</option>\n<option value='40'>40</option>\n<option value='41'>41</option>\n<option value='42'>42</option>\n<option value='43'>43</option>\n<option value='44'>44</option>\n<option value='45'>45</option>\n<option value='46'>46</option>\n<option value='47'>47</option>\n<option value='48'>48</option>\n<option value='49'>49</option>\n<option value='50'>50</option>\n<option value='51'>51</option>\n<option value='52'>52</option>\n<option value='53'>53</option>\n<option value='54'>54</option>\n<option value='55'>55</option>\n<option value='56'>56</option>\n<option value='57'>57</option>\n<option value='58'>58</option>\n<option value='59'>59</option>\n</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_datetime_select_with_separators - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " , " - - expected << %(<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_updated_at_6i" name="post[updated_at(6i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", { :date_separator => " / ", :datetime_separator => " , ", :time_separator => " - ", :include_seconds => true }) - end - - def test_datetime_select_with_default_prompt - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="">Year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => true) - end - - def test_datetime_select_with_custom_prompt - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="">Choose year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day', :hour => 'Choose hour', :minute => 'Choose minute'}) - end - - def test_date_select_with_zero_value_and_no_start_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") - end - - def test_date_select_with_zero_value_and_no_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - last_year = Time.now.year + 5 - 2003.upto(last_year) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") - end - - def test_date_select_with_zero_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :prefix => "date[first]") - end - - def test_date_select_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(nil, :prefix => "date[first]") - end - - def test_datetime_select_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]") - end - - def test_datetime_select_with_options_index - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - id = 456 - - expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :index => id) - end - - def test_datetime_select_within_fields_for_with_options_index - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - id = 456 - - fields_for :post, @post, :index => id do |f| - concat f.datetime_select(:updated_at) - end - - expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_datetime_select_with_auto_index - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - id = @post.id - - expected = %{<select id="post_123_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_123_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_123_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post[]", "updated_at") - end - - def test_datetime_select_with_seconds - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_6i" name="post[updated_at(6i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :include_seconds => true) - end - - def test_datetime_select_discard_year - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true) - end - - def test_datetime_select_discard_month - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n} - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_month => true) - end - - def test_datetime_select_discard_year_and_month - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n} - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true, :discard_month => true) - end - - def test_datetime_select_discard_year_and_month_with_disabled_html_option - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" disabled="disabled" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_updated_at_2i" disabled="disabled" name="post[updated_at(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_updated_at_3i" disabled="disabled" name="post[updated_at(3i)]" value="15" />\n} - - expected << %{<select id="post_updated_at_4i" disabled="disabled" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" disabled="disabled" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", { :discard_year => true, :discard_month => true }, :disabled => true) - end - - def test_datetime_select_discard_hour - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_hour => true) - end - - def test_datetime_select_discard_minute - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << %{<input type="hidden" id="post_updated_at_5i" name="post[updated_at(5i)]" value="16" />\n} - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_minute => true) - end - - def test_datetime_select_invalid_order - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:minute, :day, :hour, :month, :year, :second]) - end - - def test_datetime_select_discard_with_order - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:day, :month]) - end - - def test_datetime_select_with_default_value_as_time - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 2001.upto(2011) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2006}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 9}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 19}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35)) - end - - def test_include_blank_overrides_default_option - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %(<option value=""></option>\n) - (Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %(<option value=""></option>\n) - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %(<option value=""></option>\n) - 1.upto(31) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true) - end - - def test_datetime_select_with_default_value_as_hash - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - (Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.year}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 10}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.day}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 9}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 42}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :default => { :month => 10, :minute => 42, :hour => 9 }) - end - - def test_datetime_select_with_html_options - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]" class="selector">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]" class="selector">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]" class="selector">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]" class="selector">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]" class="selector">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", {}, :class => 'selector') - end - - def test_date_select_should_not_change_passed_options_hash - @post = Post.new - @post.updated_at = Time.local(2008, 7, 16, 23, 30) - - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - date_select(@post, :updated_at, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_datetime_select_should_not_change_passed_options_hash - @post = Post.new - @post.updated_at = Time.local(2008, 7, 16, 23, 30) - - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - datetime_select(@post, :updated_at, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_time_select_should_not_change_passed_options_hash - @post = Post.new - @post.updated_at = Time.local(2008, 7, 16, 23, 30) - - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - time_select(@post, :updated_at, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_date_should_not_change_passed_options_hash - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - select_date(Date.today, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_datetime_should_not_change_passed_options_hash - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - select_datetime(Time.now, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_time_should_not_change_passed_options_hash - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - select_time(Time.now, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_html_safety - assert select_day(16).html_safe? - assert select_month(8).html_safe? - assert select_year(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe? - assert select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe? - assert select_second(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe? - - assert select_minute(8, :use_hidden => true).html_safe? - assert select_month(8, :prompt => 'Choose month').html_safe? - - assert select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector').html_safe? - assert select_date(Time.mktime(2003, 8, 16), :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]").html_safe? - end - - def test_object_select_html_safety - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - assert date_select("post", "written_on", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true).html_safe? - assert time_select("post", "written_on", :ignore_date => true).html_safe? - end - - protected - def with_env_tz(new_tz = 'US/Eastern') - old_tz, ENV['TZ'] = ENV['TZ'], new_tz - yield - ensure - old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') - end -end diff --git a/vendor/rails/actionpack/test/template/erb_util_test.rb b/vendor/rails/actionpack/test/template/erb_util_test.rb deleted file mode 100644 index 06f09547..00000000 --- a/vendor/rails/actionpack/test/template/erb_util_test.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'abstract_unit' - -class ErbUtilTest < Test::Unit::TestCase - include ERB::Util - - ERB::Util::HTML_ESCAPE.each do |given, expected| - define_method "test_html_escape_#{expected.gsub /\W/, ''}" do - assert_equal expected, html_escape(given) - end - - unless given == '"' - define_method "test_json_escape_#{expected.gsub /\W/, ''}" do - assert_equal ERB::Util::JSON_ESCAPE[given], json_escape(given) - end - end - end - - def test_html_escape_is_html_safe - escaped = h("<p>") - assert_equal "&lt;p&gt;", escaped - assert escaped.html_safe? - end - - def test_html_escape_passes_html_escpe_unmodified - escaped = h("<p>".html_safe) - assert_equal "<p>", escaped - assert escaped.html_safe? - end - - def test_rest_in_ascii - (0..127).to_a.map(&:chr).each do |chr| - next if %w(& " < >).include?(chr) - assert_equal chr, html_escape(chr) - end - end -end diff --git a/vendor/rails/actionpack/test/template/form_helper_test.rb b/vendor/rails/actionpack/test/template/form_helper_test.rb deleted file mode 100644 index 5b62674f..00000000 --- a/vendor/rails/actionpack/test/template/form_helper_test.rb +++ /dev/null @@ -1,1447 +0,0 @@ -require 'abstract_unit' - -silence_warnings do - Post = Struct.new(:title, :author_name, :body, :secret, :written_on, :cost) - Post.class_eval do - alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) - alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) - alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) - alias_method :secret?, :secret - - def new_record=(boolean) - @new_record = boolean - end - - def new_record? - @new_record - end - - attr_accessor :author - def author_attributes=(attributes); end - - attr_accessor :comments - def comments_attributes=(attributes); end - - attr_accessor :tags - def tags_attributes=(attributes); end - end - - class Comment - attr_reader :id - attr_reader :post_id - def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end - def save; @id = 1; @post_id = 1 end - def new_record?; @id.nil? end - def to_param; @id; end - def name - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end - - attr_accessor :relevances - def relevances_attributes=(attributes); end - - end - - class Tag - attr_reader :id - attr_reader :post_id - def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end - def save; @id = 1; @post_id = 1 end - def new_record?; @id.nil? end - def to_param; @id; end - def value - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end - - attr_accessor :relevances - def relevances_attributes=(attributes); end - - end - - class CommentRelevance - attr_reader :id - attr_reader :comment_id - def initialize(id = nil, comment_id = nil); @id, @comment_id = id, comment_id end - def save; @id = 1; @comment_id = 1 end - def new_record?; @id.nil? end - def to_param; @id; end - def value - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end - end - - class TagRelevance - attr_reader :id - attr_reader :tag_id - def initialize(id = nil, tag_id = nil); @id, @tag_id = id, tag_id end - def save; @id = 1; @tag_id = 1 end - def new_record?; @id.nil? end - def to_param; @id; end - def value - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end - end - - class Author < Comment - attr_accessor :post - def post_attributes=(attributes); end - end -end - -class FormHelperTest < ActionView::TestCase - tests ActionView::Helpers::FormHelper - - def setup - super - - # Create "label" locale for testing I18n label helpers - I18n.backend.store_translations 'label', { - :helpers => { - :label => { - :post => { - :body => "Write entire text here" - } - } - } - } - - @post = Post.new - @comment = Comment.new - def @post.errors() - Class.new{ - def on(field); "can't be empty" if field == "author_name"; end - def empty?() false end - def count() 1 end - def full_messages() [ "Author name can't be empty" ] end - }.new - end - def @post.id; 123; end - def @post.id_before_type_cast; 123; end - def @post.to_param; '123'; end - - @post.title = "Hello World" - @post.author_name = "" - @post.body = "Back to the hill and over it again!" - @post.secret = 1 - @post.written_on = Date.new(2004, 6, 15) - - def Post.human_attribute_name(attribute) - attribute.to_s == "cost" ? "Total cost" : attribute.to_s.humanize - end - - @controller = Class.new do - attr_reader :url_for_options - def url_for(options) - @url_for_options = options - "http://www.example.com" - end - end - @controller = @controller.new - end - - def test_label - assert_dom_equal('<label for="post_title">Title</label>', label("post", "title")) - assert_dom_equal('<label for="post_title">The title goes here</label>', label("post", "title", "The title goes here")) - assert_dom_equal( - '<label class="title_label" for="post_title">Title</label>', - label("post", "title", nil, :class => 'title_label') - ) - assert_dom_equal('<label for="post_secret">Secret?</label>', label("post", "secret?")) - end - - def test_label_with_symbols - assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title)) - assert_dom_equal('<label for="post_secret">Secret?</label>', label(:post, :secret?)) - end - - def test_label_with_locales_strings - old_locale, I18n.locale = I18n.locale, :label - assert_dom_equal('<label for="post_body">Write entire text here</label>', label("post", "body")) - ensure - I18n.locale = old_locale - end - - def test_label_with_human_attribute_name - old_locale, I18n.locale = I18n.locale, :label - assert_dom_equal('<label for="post_cost">Total cost</label>', label(:post, :cost)) - ensure - I18n.locale = old_locale - end - - def test_label_with_locales_symbols - old_locale, I18n.locale = I18n.locale, :label - assert_dom_equal('<label for="post_body">Write entire text here</label>', label(:post, :body)) - ensure - I18n.locale = old_locale - end - - def test_label_with_for_attribute_as_symbol - assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, :for => "my_for")) - end - - def test_label_with_for_attribute_as_string - assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, "for" => "my_for")) - end - - def test_label_with_id_attribute_as_symbol - assert_dom_equal('<label for="post_title" id="my_id">Title</label>', label(:post, :title, nil, :id => "my_id")) - end - - def test_label_with_id_attribute_as_string - assert_dom_equal('<label for="post_title" id="my_id">Title</label>', label(:post, :title, nil, "id" => "my_id")) - end - - def test_label_with_for_and_id_attributes_as_symbol - assert_dom_equal('<label for="my_for" id="my_id">Title</label>', label(:post, :title, nil, :for => "my_for", :id => "my_id")) - end - - def test_label_with_for_and_id_attributes_as_string - assert_dom_equal('<label for="my_for" id="my_id">Title</label>', label(:post, :title, nil, "for" => "my_for", "id" => "my_id")) - end - - def test_label_for_radio_buttons_with_value - assert_dom_equal('<label for="post_title_great_title">The title goes here</label>', label("post", "title", "The title goes here", :value => "great_title")) - assert_dom_equal('<label for="post_title_great_title">The title goes here</label>', label("post", "title", "The title goes here", :value => "great title")) - end - - def test_text_field - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title") - ) - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World" />', password_field("post", "title") - ) - assert_dom_equal( - '<input id="person_name" name="person[name]" size="30" type="password" />', password_field("person", "name") - ) - end - - def test_text_field_with_escapes - @post.title = "<b>Hello World</b>" - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="text" value="&lt;b&gt;Hello World&lt;/b&gt;" />', text_field("post", "title") - ) - end - - def test_text_field_with_html_entities - @post.title = "The HTML Entity for & is &amp;" - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="text" value="The HTML Entity for &amp; is &amp;amp;" />', - text_field("post", "title") - ) - end - - def test_text_field_with_options - expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />' - assert_dom_equal expected, text_field("post", "title", "size" => 35) - assert_dom_equal expected, text_field("post", "title", :size => 35) - end - - def test_text_field_assuming_size - expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />' - assert_dom_equal expected, text_field("post", "title", "maxlength" => 35) - assert_dom_equal expected, text_field("post", "title", :maxlength => 35) - end - - def test_text_field_removing_size - expected = '<input id="post_title" maxlength="35" name="post[title]" type="text" value="Hello World" />' - assert_dom_equal expected, text_field("post", "title", "maxlength" => 35, "size" => nil) - assert_dom_equal expected, text_field("post", "title", :maxlength => 35, :size => nil) - end - - def test_text_field_doesnt_change_param_values - object_name = 'post[]' - expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />' - assert_equal expected, text_field(object_name, "title") - assert_equal object_name, "post[]" - end - - def test_hidden_field - assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Hello World" />', - hidden_field("post", "title") - assert_dom_equal '<input id="post_secret" name="post[secret]" type="hidden" value="1" />', - hidden_field("post", "secret?") - end - - def test_hidden_field_with_escapes - @post.title = "<b>Hello World</b>" - assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="&lt;b&gt;Hello World&lt;/b&gt;" />', - hidden_field("post", "title") - end - - def test_text_field_with_options - assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Something Else" />', - hidden_field("post", "title", :value => "Something Else") - end - - def test_check_box - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - @post.secret = 0 - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret" ,{"checked"=>"checked"}) - ) - @post.secret = true - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret?") - ) - - @post.secret = ['0'] - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - @post.secret = ['1'] - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - end - - def test_check_box_with_explicit_checked_and_unchecked_values - @post.secret = "on" - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="off" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />', - check_box("post", "secret", {}, "on", "off") - ) - end - - def test_checkbox_disabled_still_submits_checked_value - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret", { :disabled => :true }) - ) - end - - def test_radio_button - assert_dom_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />', - radio_button("post", "title", "Hello World") - ) - assert_dom_equal('<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />', - radio_button("post", "title", "Goodbye World") - ) - assert_dom_equal('<input id="item_subobject_title_inside_world" name="item[subobject][title]" type="radio" value="inside world"/>', - radio_button("item[subobject]", "title", "inside world") - ) - end - - def test_radio_button_is_checked_with_integers - assert_dom_equal('<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />', - radio_button("post", "secret", "1") - ) - end - - def test_radio_button_respects_passed_in_id - assert_dom_equal('<input checked="checked" id="foo" name="post[secret]" type="radio" value="1" />', - radio_button("post", "secret", "1", :id=>"foo") - ) - end - - def test_radio_button_with_booleans - assert_dom_equal('<input id="post_secret_true" name="post[secret]" type="radio" value="true" />', - radio_button("post", "secret", true) - ) - - assert_dom_equal('<input id="post_secret_false" name="post[secret]" type="radio" value="false" />', - radio_button("post", "secret", false) - ) - end - - def test_text_area - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>', - text_area("post", "body") - ) - end - - def test_text_area_with_escapes - @post.body = "Back to <i>the</i> hill and over it again!" - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to &lt;i&gt;the&lt;/i&gt; hill and over it again!</textarea>', - text_area("post", "body") - ) - end - - def test_text_area_with_alternate_value - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">Testing alternate values.</textarea>', - text_area("post", "body", :value => 'Testing alternate values.') - ) - end - - def test_text_area_with_html_entities - @post.body = "The HTML Entity for & is &amp;" - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">The HTML Entity for &amp; is &amp;amp;</textarea>', - text_area("post", "body") - ) - end - - def test_text_area_with_size_option - assert_dom_equal( - '<textarea cols="183" id="post_body" name="post[body]" rows="820">Back to the hill and over it again!</textarea>', - text_area("post", "body", :size => "183x820") - ) - end - - def test_explicit_name - assert_dom_equal( - '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />', text_field("post", "title", "name" => "dont guess") - ) - assert_dom_equal( - '<textarea cols="40" id="post_body" name="really!" rows="20">Back to the hill and over it again!</textarea>', - text_area("post", "body", "name" => "really!") - ) - assert_dom_equal( - '<input name="i mean it" type="hidden" value="0" /><input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />', - check_box("post", "secret", "name" => "i mean it") - ) - assert_dom_equal text_field("post", "title", "name" => "dont guess"), - text_field("post", "title", :name => "dont guess") - assert_dom_equal text_area("post", "body", "name" => "really!"), - text_area("post", "body", :name => "really!") - assert_dom_equal check_box("post", "secret", "name" => "i mean it"), - check_box("post", "secret", :name => "i mean it") - end - - def test_explicit_id - assert_dom_equal( - '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title", "id" => "dont guess") - ) - assert_dom_equal( - '<textarea cols="40" id="really!" name="post[body]" rows="20">Back to the hill and over it again!</textarea>', - text_area("post", "body", "id" => "really!") - ) - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret", "id" => "i mean it") - ) - assert_dom_equal text_field("post", "title", "id" => "dont guess"), - text_field("post", "title", :id => "dont guess") - assert_dom_equal text_area("post", "body", "id" => "really!"), - text_area("post", "body", :id => "really!") - assert_dom_equal check_box("post", "secret", "id" => "i mean it"), - check_box("post", "secret", :id => "i mean it") - end - - def test_auto_index - pid = @post.id - assert_dom_equal( - "<label for=\"post_#{pid}_title\">Title</label>", - label("post[]", "title") - ) - assert_dom_equal( - "<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"text\" value=\"Hello World\" />", text_field("post[]","title") - ) - assert_dom_equal( - "<textarea cols=\"40\" id=\"post_#{pid}_body\" name=\"post[#{pid}][body]\" rows=\"20\">Back to the hill and over it again!</textarea>", - text_area("post[]", "body") - ) - assert_dom_equal( - "<input name=\"post[#{pid}][secret]\" type=\"hidden\" value=\"0\" /><input checked=\"checked\" id=\"post_#{pid}_secret\" name=\"post[#{pid}][secret]\" type=\"checkbox\" value=\"1\" />", - check_box("post[]", "secret") - ) - assert_dom_equal( -"<input checked=\"checked\" id=\"post_#{pid}_title_hello_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />", - radio_button("post[]", "title", "Hello World") - ) - assert_dom_equal("<input id=\"post_#{pid}_title_goodbye_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />", - radio_button("post[]", "title", "Goodbye World") - ) - end - - def test_form_for - form_for(:post, @post, :html => { :id => 'create-post' }) do |f| - concat f.label(:title) - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - concat f.submit('Create post') - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<label for='post_title'>Title</label>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + - "<input name='commit' id='post_submit' type='submit' value='Create post' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_method - form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_without_object - form_for(:post, :html => { :id => 'create-post' }) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_index - form_for("post[]", @post) do |f| - concat f.label(:title) - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<label for=\"post_123_title\">Title</label>" + - "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + - "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[123][secret]' type='hidden' value='0' />" + - "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_nil_index_option_override - form_for("post[]", @post, :index => nil) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" + - "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[][secret]' type='hidden' value='0' />" + - "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for - form_for(:post, @post) do |f| - f.fields_for(:comment, @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[comment][title]' size='30' type='text' id='post_comment_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_nested_collections - form_for('post[]', @post) do |f| - concat f.text_field(:title) - f.fields_for('comment[]', @comment) do |c| - concat c.text_field(:name) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + - "<input name='post[123][comment][][name]' size='30' type='text' id='post_123_comment__name' value='new comment' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_and_parent_fields - form_for('post', @post, :index => 1) do |c| - concat c.text_field(:title) - c.fields_for('comment', @comment, :index => 1) do |r| - concat r.text_field(:name) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][title]' size='30' type='text' id='post_1_title' value='Hello World' />" + - "<input name='post[1][comment][1][name]' size='30' type='text' id='post_1_comment_1_name' value='new comment' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_index_and_nested_fields_for - form_for(:post, @post, :index => 1) do |f| - f.fields_for(:comment, @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][comment][title]' size='30' type='text' id='post_1_comment_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_on_both - form_for(:post, @post, :index => 1) do |f| - f.fields_for(:comment, @post, :index => 5) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][comment][5][title]' size='30' type='text' id='post_1_comment_5_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_auto_index - form_for("post[]", @post) do |f| - f.fields_for(:comment, @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][comment][title]' size='30' type='text' id='post_123_comment_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_radio_button - form_for(:post, @post) do |f| - f.fields_for(:comment, @post, :index => 5) do |c| - concat c.radio_button(:title, "hello") - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[comment][5][title]' type='radio' id='post_comment_5_title_hello' value='hello' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_auto_index_on_both - form_for("post[]", @post) do |f| - f.fields_for("comment[]", @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][comment][123][title]' size='30' type='text' id='post_123_comment_123_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_and_auto_index - form_for("post[]", @post) do |f| - f.fields_for(:comment, @post, :index => 5) do |c| - concat c.text_field(:title) - end - end - - form_for(:post, @post, :index => 1) do |f| - f.fields_for("comment[]", @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][comment][5][title]' size='30' type='text' id='post_123_comment_5_title' value='Hello World' />" + - "</form>" + - "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][comment][123][title]' size='30' type='text' id='post_1_comment_123_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association - @post.author = Author.new - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:author) do |af| - concat af.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="new author" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association - form_for(:post, @post) do |f| - f.fields_for(:author, Author.new(123)) do |af| - assert_not_nil af.object - assert_equal 123, af.object.id - end - end - end - - def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association - @post.author = Author.new(321) - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:author) do |af| - concat af.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' + - '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_records_on_a_nested_attributes_one_to_one_association_with_explicit_hidden_field_placement - @post.author = Author.new(321) - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:author) do |af| - concat af.hidden_field(:id) - concat af.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' + - '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association - @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' + - '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_explicit_hidden_field_placement - @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.hidden_field(:id) - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' + - '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association - @post.comments = [Comment.new, Comment.new] - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="new comment" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association - @post.comments = [Comment.new(321), Comment.new] - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_an_empty_supplied_attributes_collection - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:comments, []) do |cf| - concat cf.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection - @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:comments, @post.comments) do |cf| - concat cf.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' + - '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_only_builder - @post.comments = [Comment.new(321), Comment.new] - yielded_comments = [] - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:comments) do |cf| - concat cf.text_field(:name) - yielded_comments << cf.object - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' + - '</form>' - - assert_dom_equal expected, output_buffer - assert_equal yielded_comments, @post.comments - end - - def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association - @post.comments = [] - - form_for(:post, @post) do |f| - f.fields_for(:comments, Comment.new(321), :child_index => 'abc') do |cf| - concat cf.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" size="30" type="text" value="comment #321" />' + - '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_uses_unique_indices_for_different_collection_associations - @post.comments = [Comment.new(321)] - @post.tags = [Tag.new(123), Tag.new(456)] - @post.comments[0].relevances = [] - @post.tags[0].relevances = [] - @post.tags[1].relevances = [] - form_for(:post, @post) do |f| - f.fields_for(:comments, @post.comments[0]) do |cf| - concat cf.text_field(:name) - cf.fields_for(:relevances, CommentRelevance.new(314)) do |crf| - concat crf.text_field(:value) - end - end - f.fields_for(:tags, @post.tags[0]) do |tf| - concat tf.text_field(:value) - tf.fields_for(:relevances, TagRelevance.new(3141)) do |trf| - concat trf.text_field(:value) - end - end - f.fields_for('tags', @post.tags[1]) do |tf| - concat tf.text_field(:value) - tf.fields_for(:relevances, TagRelevance.new(31415)) do |trf| - concat trf.text_field(:value) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' + - '<input id="post_comments_attributes_0_relevances_attributes_0_value" name="post[comments_attributes][0][relevances_attributes][0][value]" size="30" type="text" value="commentrelevance #314" />' + - '<input id="post_comments_attributes_0_relevances_attributes_0_id" name="post[comments_attributes][0][relevances_attributes][0][id]" type="hidden" value="314" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' + - '<input id="post_tags_attributes_0_value" name="post[tags_attributes][0][value]" size="30" type="text" value="tag #123" />' + - '<input id="post_tags_attributes_0_relevances_attributes_0_value" name="post[tags_attributes][0][relevances_attributes][0][value]" size="30" type="text" value="tagrelevance #3141" />' + - '<input id="post_tags_attributes_0_relevances_attributes_0_id" name="post[tags_attributes][0][relevances_attributes][0][id]" type="hidden" value="3141" />' + - '<input id="post_tags_attributes_0_id" name="post[tags_attributes][0][id]" type="hidden" value="123" />' + - '<input id="post_tags_attributes_1_value" name="post[tags_attributes][1][value]" size="30" type="text" value="tag #456" />' + - '<input id="post_tags_attributes_1_relevances_attributes_0_value" name="post[tags_attributes][1][relevances_attributes][0][value]" size="30" type="text" value="tagrelevance #31415" />' + - '<input id="post_tags_attributes_1_relevances_attributes_0_id" name="post[tags_attributes][1][relevances_attributes][0][id]" type="hidden" value="31415" />' + - '<input id="post_tags_attributes_1_id" name="post[tags_attributes][1][id]" type="hidden" value="456" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_fields_for - fields_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_index - fields_for("post[]", @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + - "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[123][secret]' type='hidden' value='0' />" + - "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_nil_index_option_override - fields_for("post[]", @post, :index => nil) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" + - "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[][secret]' type='hidden' value='0' />" + - "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_index_option_override - fields_for("post[]", @post, :index => "abc") do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[abc][title]' size='30' type='text' id='post_abc_title' value='Hello World' />" + - "<textarea name='post[abc][body]' id='post_abc_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[abc][secret]' type='hidden' value='0' />" + - "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_without_object - fields_for(:post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_only_object - fields_for(@post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_object_with_bracketed_name - fields_for("author[post]", @post) do |f| - concat f.label(:title) - concat f.text_field(:title) - end - - assert_dom_equal "<label for=\"author_post_title\">Title</label>" + - "<input name='author[post][title]' size='30' type='text' id='author_post_title' value='Hello World' />", - output_buffer - end - - def test_fields_for_object_with_bracketed_name_and_index - fields_for("author[post]", @post, :index => 1) do |f| - concat f.label(:title) - concat f.text_field(:title) - end - - assert_dom_equal "<label for=\"author_post_1_title\">Title</label>" + - "<input name='author[post][1][title]' size='30' type='text' id='author_post_1_title' value='Hello World' />", - output_buffer - end - - def test_form_builder_does_not_have_form_for_method - assert ! ActionView::Helpers::FormBuilder.instance_methods.include?('form_for') - end - - def test_form_for_and_fields_for - form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| - concat post_form.text_field(:title) - concat post_form.text_area(:body) - - fields_for(:parent_post, @post) do |parent_fields| - concat parent_fields.check_box(:secret) - end - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='parent_post[secret]' type='hidden' value='0' />" + - "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_and_fields_for_with_object - form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| - concat post_form.text_field(:title) - concat post_form.text_area(:body) - - post_form.fields_for(@comment) do |comment_fields| - concat comment_fields.text_field(:name) - end - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' size='30' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - class LabelledFormBuilder < ActionView::Helpers::FormBuilder - (field_helpers - %w(hidden_field)).each do |selector| - src, line = <<-END_SRC, __LINE__ + 1 - def #{selector}(field, *args, &proc) - ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe - end - END_SRC - class_eval src, __FILE__, line - end - end - - def test_form_for_with_labelled_builder - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_default_form_builder - old_default_form_builder, ActionView::Base.default_form_builder = - ActionView::Base.default_form_builder, LabelledFormBuilder - - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" + - "</form>" - - assert_dom_equal expected, output_buffer - ensure - ActionView::Base.default_form_builder = old_default_form_builder - end - - def test_default_form_builder_with_active_record_helpers - form_for(:post, @post) do |f| - concat f.error_message_on('author_name') - concat f.error_messages - end - - expected = %(<form action='http://www.example.com' method='post'>) + - %(<div class='formError'>can't be empty</div>) + - %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + - %(</form>) - - assert_dom_equal expected, output_buffer - - end - - def test_default_form_builder_no_instance_variable - post = @post - @post = nil - - form_for(:post, post) do |f| - concat f.error_message_on('author_name') - concat f.error_messages - end - - expected = %(<form action='http://www.example.com' method='post'>) + - %(<div class='formError'>can't be empty</div>) + - %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + - %(</form>) - - assert_dom_equal expected, output_buffer - - end - - def test_default_form_builder_without_object - - form_for(:post) do |f| - concat f.error_message_on('author_name') - concat f.error_messages - end - - expected = %(<form action='http://www.example.com' method='post'>) + - %(<div class='formError'>can't be empty</div>) + - %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + - %(</form>) - - assert_dom_equal expected, output_buffer - - end - - # Perhaps this test should be moved to prototype helper tests. - def test_remote_form_for_with_labelled_builder - self.extend ActionView::Helpers::PrototypeHelper - - remote_form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - %(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) + - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_labelled_builder - fields_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_labelled_builder_with_nested_fields_for_without_options_hash - klass = nil - - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new) do |nested_fields| - klass = nested_fields.class - '' - end - end - - assert_equal LabelledFormBuilder, klass - end - - def test_form_for_with_labelled_builder_with_nested_fields_for_with_options_hash - klass = nil - - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, :index => 'foo') do |nested_fields| - klass = nested_fields.class - '' - end - end - - assert_equal LabelledFormBuilder, klass - end - - class LabelledFormBuilderSubclass < LabelledFormBuilder; end - - def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_builder - klass = nil - - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, :builder => LabelledFormBuilderSubclass) do |nested_fields| - klass = nested_fields.class - '' - end - end - - assert_equal LabelledFormBuilderSubclass, klass - end - - def test_form_for_with_html_options_adds_options_to_form_tag - form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end - expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_string_url_option - form_for(:post, @post, :url => 'http://www.otherdomain.com') do |f| end - - assert_equal '<form action="http://www.otherdomain.com" method="post"></form>', output_buffer - end - - def test_form_for_with_hash_url_option - form_for(:post, @post, :url => {:controller => 'controller', :action => 'action'}) do |f| end - - assert_equal 'controller', @controller.url_for_options[:controller] - assert_equal 'action', @controller.url_for_options[:action] - end - - def test_form_for_with_record_url_option - form_for(:post, @post, :url => @post) do |f| end - - expected = "<form action=\"/posts/123\" method=\"post\"></form>" - assert_equal expected, output_buffer - end - - def test_form_for_with_existing_object - form_for(@post) do |f| end - - expected = "<form action=\"/posts/123\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"_method\" type=\"hidden\" value=\"put\" /></div></form>" - assert_equal expected, output_buffer - end - - def test_form_for_with_new_object - post = Post.new - post.new_record = true - def post.id() nil end - - form_for(post) do |f| end - - expected = "<form action=\"/posts\" class=\"new_post\" id=\"new_post\" method=\"post\"></form>" - assert_equal expected, output_buffer - end - - def test_form_for_with_existing_object_in_list - @post.new_record = false - @comment.save - - form_for([@post, @comment]) {} - - expected = %(<form action="#{comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_new_object_in_list - @post.new_record = false - - form_for([@post, @comment]) {} - - expected = %(<form action="#{comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_existing_object_and_namespace_in_list - @post.new_record = false - @comment.save - - form_for([:admin, @post, @comment]) {} - - expected = %(<form action="#{admin_comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_new_object_and_namespace_in_list - @post.new_record = false - - form_for([:admin, @post, @comment]) {} - - expected = %(<form action="#{admin_comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_existing_object_and_custom_url - form_for(@post, :url => "/super_posts") do |f| end - - expected = "<form action=\"/super_posts\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"_method\" type=\"hidden\" value=\"put\" /></div></form>" - assert_equal expected, output_buffer - end - - def test_remote_form_for_with_html_options_adds_options_to_form_tag - self.extend ActionView::Helpers::PrototypeHelper - - remote_form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end - expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\" onsubmit=\"new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"></form>" - - assert_dom_equal expected, output_buffer - end - - protected - def comments_path(post) - "/posts/#{post.id}/comments" - end - alias_method :post_comments_path, :comments_path - - def comment_path(post, comment) - "/posts/#{post.id}/comments/#{comment.id}" - end - alias_method :post_comment_path, :comment_path - - def admin_comments_path(post) - "/admin/posts/#{post.id}/comments" - end - alias_method :admin_post_comments_path, :admin_comments_path - - def admin_comment_path(post, comment) - "/admin/posts/#{post.id}/comments/#{comment.id}" - end - alias_method :admin_post_comment_path, :admin_comment_path - - def posts_path - "/posts" - end - - def post_path(post) - "/posts/#{post.id}" - end - - def protect_against_forgery? - false - end -end diff --git a/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb deleted file mode 100644 index 91e370ef..00000000 --- a/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'abstract_unit' - -class FormOptionsHelperI18nTests < ActionView::TestCase - tests ActionView::Helpers::FormOptionsHelper - - def setup - @prompt_message = 'Select!' - I18n.backend.send(:init_translations) - I18n.backend.store_translations :en, :support => { :select => { :prompt => @prompt_message } } - end - - def teardown - I18n.backend = I18n::Backend::Simple.new - end - - def test_select_with_prompt_true_translates_prompt_message - I18n.expects(:translate).with('support.select.prompt', { :default => 'Please select' }) - select('post', 'category', [], :prompt => true) - end - - def test_select_with_translated_prompt - assert_dom_equal( - %Q(<select id="post_category" name="post[category]"><option value="">#{@prompt_message}</option>\n</select>), - select('post', 'category', [], :prompt => true) - ) - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/template/form_options_helper_test.rb b/vendor/rails/actionpack/test/template/form_options_helper_test.rb deleted file mode 100644 index 9c65abfc..00000000 --- a/vendor/rails/actionpack/test/template/form_options_helper_test.rb +++ /dev/null @@ -1,811 +0,0 @@ -require 'abstract_unit' -require 'tzinfo' - -TZInfo::Timezone.cattr_reader :loaded_zones - -class FormOptionsHelperTest < ActionView::TestCase - tests ActionView::Helpers::FormOptionsHelper - - silence_warnings do - Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin) - Continent = Struct.new('Continent', :continent_name, :countries) - Country = Struct.new('Country', :country_id, :country_name) - Firm = Struct.new('Firm', :time_zone) - Album = Struct.new('Album', :id, :title, :genre) - end - - def setup - @fake_timezones = %w(A B C D E).inject([]) do |zones, id| - tz = TZInfo::Timezone.loaded_zones[id] = stub(:name => id, :to_s => id) - ActiveSupport::TimeZone.stubs(:[]).with(id).returns(tz) - zones << tz - end - ActiveSupport::TimeZone.stubs(:all).returns(@fake_timezones) - end - - def test_collection_options - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title") - ) - end - - - def test_collection_options_with_preselected_value - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", "Babe") - ) - end - - def test_collection_options_with_preselected_value_array - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\" selected=\"selected\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", [ "Babe", "Cabe" ]) - ) - end - - def test_collection_options_with_proc_for_selected - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", lambda{|p| p.author_name == 'Babe' }) - ) - end - - def test_collection_options_with_disabled_value - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => "Babe") - ) - end - - def test_collection_options_with_disabled_array - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\" disabled=\"disabled\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => [ "Babe", "Cabe" ]) - ) - end - - def test_collection_options_with_preselected_and_disabled_value - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\" selected=\"selected\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :selected => "Cabe", :disabled => "Babe") - ) - end - - def test_collection_options_with_proc_for_disabled - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\" disabled=\"disabled\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => lambda{|p| %w(Babe Cabe).include? p.author_name }) - ) - end - - def test_string_options_for_select - options = "<option value=\"Denmark\">Denmark</option><option value=\"USA\">USA</option><option value=\"Sweden\">Sweden</option>" - assert_dom_equal( - options, - options_for_select(options) - ) - end - - def test_array_options_for_select - assert_dom_equal( - "<option value=\"&lt;Denmark&gt;\">&lt;Denmark&gt;</option>\n<option value=\"USA\">USA</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "<Denmark>", "USA", "Sweden" ]) - ) - end - - def test_array_options_for_select_with_selection - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], "<USA>") - ) - end - - def test_array_options_for_select_with_selection_array - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\" selected=\"selected\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], [ "<USA>", "Sweden" ]) - ) - end - - def test_array_options_for_select_with_disabled_value - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" disabled=\"disabled\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], :disabled => "<USA>") - ) - end - - def test_array_options_for_select_with_disabled_array - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" disabled=\"disabled\">&lt;USA&gt;</option>\n<option value=\"Sweden\" disabled=\"disabled\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], :disabled => ["<USA>", "Sweden"]) - ) - end - - def test_array_options_for_select_with_selection_and_disabled_value - assert_dom_equal( - "<option value=\"Denmark\" selected=\"selected\">Denmark</option>\n<option value=\"&lt;USA&gt;\" disabled=\"disabled\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], :selected => "Denmark", :disabled => "<USA>") - ) - end - - def test_array_options_for_string_include_in_other_string_bug_fix - assert_dom_equal( - "<option value=\"ruby\">ruby</option>\n<option value=\"rubyonrails\" selected=\"selected\">rubyonrails</option>", - options_for_select([ "ruby", "rubyonrails" ], "rubyonrails") - ) - assert_dom_equal( - "<option value=\"ruby\" selected=\"selected\">ruby</option>\n<option value=\"rubyonrails\">rubyonrails</option>", - options_for_select([ "ruby", "rubyonrails" ], "ruby") - ) - assert_dom_equal( - %(<option value="ruby" selected="selected">ruby</option>\n<option value="rubyonrails">rubyonrails</option>\n<option value=""></option>), - options_for_select([ "ruby", "rubyonrails", nil ], "ruby") - ) - end - - def test_hash_options_for_select - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>", - options_for_select("$" => "Dollar", "<DKR>" => "<Kroner>").split("\n").sort.join("\n") - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar").split("\n").sort.join("\n") - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ]).split("\n").sort.join("\n") - ) - end - - def test_ducktyped_options_for_select - quack = Struct.new(:first, :last) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>", - options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")]) - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], "Dollar") - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], ["Dollar", "<Kroner>"]) - ) - end - - def test_option_groups_from_collection_for_select - @continents = [ - Continent.new("<Africa>", [Country.new("<sa>", "<South Africa>"), Country.new("so", "Somalia")] ), - Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] ) - ] - - assert_dom_equal( - "<optgroup label=\"&lt;Africa&gt;\"><option value=\"&lt;sa&gt;\">&lt;South Africa&gt;</option>\n<option value=\"so\">Somalia</option></optgroup><optgroup label=\"Europe\"><option value=\"dk\" selected=\"selected\">Denmark</option>\n<option value=\"ie\">Ireland</option></optgroup>", - option_groups_from_collection_for_select(@continents, "countries", "continent_name", "country_id", "country_name", "dk") - ) - end - - def test_grouped_options_for_select_with_array - assert_dom_equal( - "<optgroup label=\"North America\"><option value=\"US\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"GB\">Great Britain</option>\n<option value=\"Germany\">Germany</option></optgroup>", - grouped_options_for_select([ - ["North America", - [['United States','US'],"Canada"]], - ["Europe", - [["Great Britain","GB"], "Germany"]] - ]) - ) - end - - def test_grouped_options_for_select_with_selected_and_prompt - assert_dom_equal( - "<option value=\"\">Choose a product...</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option selected=\"selected\" value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>", - grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], "Cowboy Hat", "Choose a product...") - ) - end - - def test_optgroups_with_with_options_with_hash - assert_dom_equal( - "<optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup><optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup>", - grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']}) - ) - end - - def test_time_zone_options_no_parms - opts = time_zone_options_for_select - assert_dom_equal "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>\n" + - "<option value=\"E\">E</option>", - opts - end - - def test_time_zone_options_with_selected - opts = time_zone_options_for_select( "D" ) - assert_dom_equal "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>", - opts - end - - def test_time_zone_options_with_unknown_selected - opts = time_zone_options_for_select( "K" ) - assert_dom_equal "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>\n" + - "<option value=\"E\">E</option>", - opts - end - - def test_time_zone_options_with_priority_zones - zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] - opts = time_zone_options_for_select( nil, zones ) - assert_dom_equal "<option value=\"B\">B</option>\n" + - "<option value=\"E\">E</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>", - opts - end - - def test_time_zone_options_with_selected_priority_zones - zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] - opts = time_zone_options_for_select( "E", zones ) - assert_dom_equal "<option value=\"B\">B</option>\n" + - "<option value=\"E\" selected=\"selected\">E</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>", - opts - end - - def test_time_zone_options_with_unselected_priority_zones - zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] - opts = time_zone_options_for_select( "C", zones ) - assert_dom_equal "<option value=\"B\">B</option>\n" + - "<option value=\"E\">E</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"C\" selected=\"selected\">C</option>\n" + - "<option value=\"D\">D</option>", - opts - end - - def test_time_zone_options_returns_html_safe_string - assert time_zone_options_for_select.html_safe? - end - - def test_select - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest)) - ) - end - - def test_select_under_fields_for - @post = Post.new - @post.category = "<mus>" - - fields_for :post, @post do |f| - concat f.select(:category, %w( abe <mus> hest)) - end - - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - output_buffer - ) - end - - def test_select_under_fields_for_with_index - @post = Post.new - @post.category = "<mus>" - - fields_for :post, @post, :index => 108 do |f| - concat f.select(:category, %w( abe <mus> hest)) - end - - assert_dom_equal( - "<select id=\"post_108_category\" name=\"post[108][category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - output_buffer - ) - end - - def test_select_under_fields_for_with_auto_index - @post = Post.new - @post.category = "<mus>" - def @post.to_param; 108; end - - fields_for "post[]", @post do |f| - concat f.select(:category, %w( abe <mus> hest)) - end - - assert_dom_equal( - "<select id=\"post_108_category\" name=\"post[108][category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - output_buffer - ) - end - - def test_select_under_fields_for_with_string_and_given_prompt - @post = Post.new - options = "<option value=\"abe\">abe</option><option value=\"mus\">mus</option><option value=\"hest\">hest</option>" - - fields_for :post, @post do |f| - concat f.select(:category, options, :prompt => 'The prompt') - end - - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">The prompt</option>\n#{options}</select>", - output_buffer - ) - end - - def test_select_with_blank - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\"></option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :include_blank => true) - ) - end - - def test_select_with_blank_as_string - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">None</option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :include_blank => 'None') - ) - end - - def test_select_with_default_prompt - @post = Post.new - @post.category = "" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">Please select</option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => true) - ) - end - - def test_select_no_prompt_when_select_has_value - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => true) - ) - end - - def test_select_with_given_prompt - @post = Post.new - @post.category = "" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">The prompt</option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => 'The prompt') - ) - end - - def test_select_with_prompt_and_blank - @post = Post.new - @post.category = "" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">Please select</option>\n<option value=\"\"></option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => true, :include_blank => true) - ) - end - - def test_select_with_selected_value - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\" selected=\"selected\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :selected => 'abe') - ) - end - - def test_select_with_index_option - @album = Album.new - @album.id = 1 - - expected = "<select id=\"album__genre\" name=\"album[][genre]\"><option value=\"rap\">rap</option>\n<option value=\"rock\">rock</option>\n<option value=\"country\">country</option></select>" - - assert_dom_equal( - expected, - select("album[]", "genre", %w[rap rock country], {}, { :index => nil }) - ) - end - - def test_select_with_selected_nil - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :selected => nil) - ) - end - - def test_select_with_disabled_value - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\" disabled=\"disabled\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :disabled => 'hest') - ) - end - - def test_select_with_disabled_array - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\" disabled=\"disabled\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\" disabled=\"disabled\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :disabled => ['hest', 'abe']) - ) - end - - def test_collection_select - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name") - ) - end - - def test_collection_select_under_fields_for - @post = Post.new - @post.author_name = "Babe" - - fields_for :post, @post do |f| - concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name) - end - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - output_buffer - ) - end - - def test_collection_select_under_fields_for_with_index - @post = Post.new - @post.author_name = "Babe" - - fields_for :post, @post, :index => 815 do |f| - concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name) - end - - assert_dom_equal( - "<select id=\"post_815_author_name\" name=\"post[815][author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - output_buffer - ) - end - - def test_collection_select_under_fields_for_with_auto_index - @post = Post.new - @post.author_name = "Babe" - def @post.to_param; 815; end - - fields_for "post[]", @post do |f| - concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name) - end - - assert_dom_equal( - "<select id=\"post_815_author_name\" name=\"post[815][author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - output_buffer - ) - end - - def test_collection_select_with_blank_and_style - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option value=\"\"></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true }, "style" => "width: 200px") - ) - end - - def test_collection_select_with_blank_as_string_and_style - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option value=\"\">No Selection</option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => 'No Selection' }, "style" => "width: 200px") - ) - end - - def test_collection_select_with_multiple_option_appends_array_brackets - @post = Post.new - @post.author_name = "Babe" - - expected = "<select id=\"post_author_name\" name=\"post[author_name][]\" multiple=\"multiple\"><option value=\"\"></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>" - - # Should suffix default name with []. - assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true }, :multiple => true) - - # Shouldn't suffix custom name with []. - assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true, :name => 'post[author_name][]' }, :multiple => true) - end - - def test_collection_select_with_blank_and_selected - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - %{<select id="post_author_name" name="post[author_name]"><option value=""></option>\n<option value="&lt;Abe&gt;" selected="selected">&lt;Abe&gt;</option>\n<option value="Babe">Babe</option>\n<option value="Cabe">Cabe</option></select>}, - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", {:include_blank => true, :selected => "<Abe>"}) - ) - end - - def test_collection_select_with_disabled - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\" disabled=\"disabled\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", :disabled => 'Cabe') - ) - end - - def test_time_zone_select - @firm = Firm.new("D") - html = time_zone_select( "firm", "time_zone" ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_under_fields_for - @firm = Firm.new("D") - - fields_for :firm, @firm do |f| - concat f.time_zone_select(:time_zone) - end - - assert_dom_equal( - "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - output_buffer - ) - end - - def test_time_zone_select_under_fields_for_with_index - @firm = Firm.new("D") - - fields_for :firm, @firm, :index => 305 do |f| - concat f.time_zone_select(:time_zone) - end - - assert_dom_equal( - "<select id=\"firm_305_time_zone\" name=\"firm[305][time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - output_buffer - ) - end - - def test_time_zone_select_under_fields_for_with_auto_index - @firm = Firm.new("D") - def @firm.to_param; 305; end - - fields_for "firm[]", @firm do |f| - concat f.time_zone_select(:time_zone) - end - - assert_dom_equal( - "<select id=\"firm_305_time_zone\" name=\"firm[305][time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - output_buffer - ) - end - - def test_time_zone_select_with_blank - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, :include_blank => true) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"\"></option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_blank_as_string - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, :include_blank => 'No Zone') - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"\">No Zone</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_style - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, {}, - "style" => "color: red") - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - assert_dom_equal html, time_zone_select("firm", "time_zone", nil, {}, - :style => "color: red") - end - - def test_time_zone_select_with_blank_and_style - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, - { :include_blank => true }, "style" => "color: red") - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" + - "<option value=\"\"></option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - assert_dom_equal html, time_zone_select("firm", "time_zone", nil, - { :include_blank => true }, :style => "color: red") - end - - def test_time_zone_select_with_blank_as_string_and_style - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, - { :include_blank => 'No Zone' }, "style" => "color: red") - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" + - "<option value=\"\">No Zone</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - assert_dom_equal html, time_zone_select("firm", "time_zone", nil, - { :include_blank => 'No Zone' }, :style => "color: red") - end - - def test_time_zone_select_with_priority_zones - @firm = Firm.new("D") - zones = [ ActiveSupport::TimeZone.new("A"), ActiveSupport::TimeZone.new("D") ] - html = time_zone_select("firm", "time_zone", zones ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_priority_zones_as_regexp - @firm = Firm.new("D") - @fake_timezones.each_with_index do |tz, i| - tz.stubs(:=~).returns(i.zero? || i == 3) - end - - html = time_zone_select("firm", "time_zone", /A|D/) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_default_time_zone_and_nil_value - @firm = Firm.new() - @firm.time_zone = nil - html = time_zone_select( "firm", "time_zone", nil, :default => 'B' ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\" selected=\"selected\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_default_time_zone_and_value - @firm = Firm.new('D') - html = time_zone_select( "firm", "time_zone", nil, :default => 'B' ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_grouped_collection_select - @continents = [ - Continent.new("<Africa>", [Country.new("<sa>", "<South Africa>"), Country.new("so", "Somalia")] ), - Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] ) - ] - - @post = Post.new - @post.origin = 'dk' - - assert_dom_equal( - %Q{<select id="post_origin" name="post[origin]"><optgroup label="&lt;Africa&gt;"><option value="&lt;sa&gt;">&lt;South Africa&gt;</option>\n<option value="so">Somalia</option></optgroup><optgroup label="Europe"><option value="dk" selected="selected">Denmark</option>\n<option value="ie">Ireland</option></optgroup></select>}, - grouped_collection_select("post", "origin", @continents, :countries, :continent_name, :country_id, :country_name) - ) - end - - def test_grouped_collection_select_under_fields_for - @continents = [ - Continent.new("<Africa>", [Country.new("<sa>", "<South Africa>"), Country.new("so", "Somalia")] ), - Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] ) - ] - - @post = Post.new - @post.origin = 'dk' - - fields_for :post, @post do |f| - concat f.grouped_collection_select("origin", @continents, :countries, :continent_name, :country_id, :country_name) - end - - assert_dom_equal( - %Q{<select id="post_origin" name="post[origin]"><optgroup label="&lt;Africa&gt;"><option value="&lt;sa&gt;">&lt;South Africa&gt;</option>\n<option value="so">Somalia</option></optgroup><optgroup label="Europe"><option value="dk" selected="selected">Denmark</option>\n<option value="ie">Ireland</option></optgroup></select>}, - output_buffer - ) - end - - private - - def dummy_posts - [ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"), - Post.new("Babe went home", "Babe", "To a little house", "shh!"), - Post.new("Cabe went home", "Cabe", "To a little house", "shh!") ] - end -end diff --git a/vendor/rails/actionpack/test/template/form_tag_helper_test.rb b/vendor/rails/actionpack/test/template/form_tag_helper_test.rb deleted file mode 100644 index 95778ac6..00000000 --- a/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +++ /dev/null @@ -1,356 +0,0 @@ -require 'abstract_unit' - -class FormTagHelperTest < ActionView::TestCase - tests ActionView::Helpers::FormTagHelper - - def setup - @controller = Class.new do - def url_for(options) - "http://www.example.com" - end - end - @controller = @controller.new - end - - VALID_HTML_ID = /^[A-Za-z][-_:.A-Za-z0-9]*$/ # see http://www.w3.org/TR/html4/types.html#type-name - - def test_check_box_tag - actual = check_box_tag "admin" - expected = %(<input id="admin" name="admin" type="checkbox" value="1" />) - assert_dom_equal expected, actual - end - - def test_check_box_tag_id_sanitized - label_elem = root_elem(check_box_tag("project[2][admin]")) - assert_match VALID_HTML_ID, label_elem['id'] - end - - def test_form_tag - actual = form_tag - expected = %(<form action="http://www.example.com" method="post">) - assert_dom_equal expected, actual - end - - def test_form_tag_multipart - actual = form_tag({}, { 'multipart' => true }) - expected = %(<form action="http://www.example.com" enctype="multipart/form-data" method="post">) - assert_dom_equal expected, actual - end - - def test_form_tag_with_method_put - actual = form_tag({}, { :method => :put }) - expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0;display:inline'><input type="hidden" name="_method" value="put" /></div>) - assert_dom_equal expected, actual - end - - def test_form_tag_with_method_delete - actual = form_tag({}, { :method => :delete }) - expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0;display:inline'><input type="hidden" name="_method" value="delete" /></div>) - assert_dom_equal expected, actual - end - - def test_form_tag_with_block_in_erb - __in_erb_template = '' - form_tag("http://example.com") { concat "Hello world!" } - - expected = %(<form action="http://example.com" method="post">Hello world!</form>) - assert_dom_equal expected, output_buffer - end - - def test_form_tag_with_block_and_method_in_erb - __in_erb_template = '' - form_tag("http://example.com", :method => :put) { concat "Hello world!" } - - expected = %(<form action="http://example.com" method="post"><div style='margin:0;padding:0;display:inline'><input type="hidden" name="_method" value="put" /></div>Hello world!</form>) - assert_dom_equal expected, output_buffer - end - - def test_hidden_field_tag - actual = hidden_field_tag "id", 3 - expected = %(<input id="id" name="id" type="hidden" value="3" />) - assert_dom_equal expected, actual - end - - def test_hidden_field_tag_id_sanitized - input_elem = root_elem(hidden_field_tag("item[][title]")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_file_field_tag - assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" />", file_field_tag("picsplz") - end - - def test_file_field_tag_with_options - assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" class=\"pix\"/>", file_field_tag("picsplz", :class => "pix") - end - - def test_password_field_tag - actual = password_field_tag - expected = %(<input id="password" name="password" type="password" />) - assert_dom_equal expected, actual - end - - def test_radio_button_tag - actual = radio_button_tag "people", "david" - expected = %(<input id="people_david" name="people" type="radio" value="david" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("num_people", 5) - expected = %(<input id="num_people_5" name="num_people" type="radio" value="5" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("gender", "m") + radio_button_tag("gender", "f") - expected = %(<input id="gender_m" name="gender" type="radio" value="m" /><input id="gender_f" name="gender" type="radio" value="f" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("opinion", "-1") + radio_button_tag("opinion", "1") - expected = %(<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("person[gender]", "m") - expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />) - assert_dom_equal expected, actual - end - - def test_select_tag - actual = select_tag "people", "<option>david</option>".html_safe - expected = %(<select id="people" name="people"><option>david</option></select>) - assert_dom_equal expected, actual - end - - def test_select_tag_with_multiple - actual = select_tag "colors", "<option>Red</option><option>Blue</option><option>Green</option>".html_safe, :multiple => :true - expected = %(<select id="colors" multiple="multiple" name="colors"><option>Red</option><option>Blue</option><option>Green</option></select>) - assert_dom_equal expected, actual - end - - def test_select_tag_disabled - actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>".html_safe, :disabled => :true - expected = %(<select id="places" disabled="disabled" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>) - assert_dom_equal expected, actual - end - - def test_select_tag_id_sanitized - input_elem = root_elem(select_tag("project[1]people", "<option>david</option>")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_select_tag_with_array_options - assert_deprecated /array/ do - select_tag "people", ["<option>david</option>"] - end - end - - def test_text_area_tag_size_string - actual = text_area_tag "body", "hello world", "size" => "20x40" - expected = %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_size_symbol - actual = text_area_tag "body", "hello world", :size => "20x40" - expected = %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_should_disregard_size_if_its_given_as_an_integer - actual = text_area_tag "body", "hello world", :size => 20 - expected = %(<textarea id="body" name="body">hello world</textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_id_sanitized - input_elem = root_elem(text_area_tag("item[][description]")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_text_area_tag_escape_content - actual = text_area_tag "body", "<b>hello world</b>", :size => "20x40" - expected = %(<textarea cols="20" id="body" name="body" rows="40">&lt;b&gt;hello world&lt;/b&gt;</textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_unescaped_content - actual = text_area_tag "body", "<b>hello world</b>", :size => "20x40", :escape => false - expected = %(<textarea cols="20" id="body" name="body" rows="40"><b>hello world</b></textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_unescaped_nil_content - actual = text_area_tag "body", nil, :escape => false - expected = %(<textarea id="body" name="body"></textarea>) - assert_dom_equal expected, actual - end - - def test_text_field_tag - actual = text_field_tag "title", "Hello!" - expected = %(<input id="title" name="title" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_class_string - actual = text_field_tag "title", "Hello!", "class" => "admin" - expected = %(<input class="admin" id="title" name="title" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_size_symbol - actual = text_field_tag "title", "Hello!", :size => 75 - expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_size_string - actual = text_field_tag "title", "Hello!", "size" => "75" - expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_maxlength_symbol - actual = text_field_tag "title", "Hello!", :maxlength => 75 - expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_maxlength_string - actual = text_field_tag "title", "Hello!", "maxlength" => "75" - expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_disabled - actual = text_field_tag "title", "Hello!", :disabled => :true - expected = %(<input id="title" name="title" disabled="disabled" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_with_multiple_options - actual = text_field_tag "title", "Hello!", :size => 70, :maxlength => 80 - expected = %(<input id="title" name="title" size="70" maxlength="80" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_id_sanitized - input_elem = root_elem(text_field_tag("item[][title]")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_label_tag_without_text - actual = label_tag "title" - expected = %(<label for="title">Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_with_symbol - actual = label_tag :title - expected = %(<label for="title">Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_with_text - actual = label_tag "title", "My Title" - expected = %(<label for="title">My Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_class_string - actual = label_tag "title", "My Title", "class" => "small_label" - expected = %(<label for="title" class="small_label">My Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_id_sanitized - label_elem = root_elem(label_tag("item[title]")) - assert_match VALID_HTML_ID, label_elem['for'] - end - - def test_boolean_options - assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") - assert_dom_equal %(<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) - assert_dom_equal %(<input type="checkbox" />), tag(:input, :type => "checkbox", :checked => false) - assert_dom_equal %(<select id="people" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people", "<option>david</option>".html_safe, :multiple => true) - assert_dom_equal %(<select id="people_" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people[]", "<option>david</option>".html_safe, :multiple => true) - assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>".html_safe, :multiple => nil) - end - - def test_stringify_symbol_keys - actual = text_field_tag "title", "Hello!", :id => "admin" - expected = %(<input id="admin" name="title" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_submit_tag - assert_dom_equal( - %(<input name='commit' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';alert('hello!');result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" type="submit" value="Save" />), - submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')") - ) - end - - def test_submit_tag_with_no_onclick_options - assert_dom_equal( - %(<input name='commit' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" type="submit" value="Save" />), - submit_tag("Save", :disable_with => "Saving...") - ) - end - - def test_submit_tag_with_confirmation - assert_dom_equal( - %(<input name='commit' type='submit' value='Save' onclick="if (!confirm('Are you sure?')) return false; return true;"/>), - submit_tag("Save", :confirm => "Are you sure?") - ) - end - - def test_submit_tag_with_confirmation_and_with_disable_with - assert_dom_equal( - %(<input name="commit" onclick="if (!confirm('Are you sure?')) return false; if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" type="submit" value="Save" />), - submit_tag("Save", :disable_with => "Saving...", :confirm => "Are you sure?") - ) - end - - def test_image_submit_tag_with_confirmation - assert_dom_equal( - %(<input type="image" src="/images/save.gif" onclick="return confirm('Are you sure?');"/>), - image_submit_tag("save.gif", :confirm => "Are you sure?") - ) - end - - def test_pass - assert_equal 1, 1 - end - - def test_field_set_tag_in_erb - __in_erb_template = '' - field_set_tag("Your details") { concat "Hello world!" } - - expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - - self.output_buffer = ''.html_safe - field_set_tag { concat "Hello world!" } - - expected = %(<fieldset>Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - - self.output_buffer = ''.html_safe - field_set_tag('') { concat "Hello world!" } - - expected = %(<fieldset>Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - - self.output_buffer = ''.html_safe - field_set_tag('', :class => 'format') { concat "Hello world!" } - - expected = %(<fieldset class="format">Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - end - - def protect_against_forgery? - false - end - - private - - def root_elem(rendered_content) - HTML::Document.new(rendered_content).root.children[0] - end -end diff --git a/vendor/rails/actionpack/test/template/javascript_helper_test.rb b/vendor/rails/actionpack/test/template/javascript_helper_test.rb deleted file mode 100644 index d2fb24e3..00000000 --- a/vendor/rails/actionpack/test/template/javascript_helper_test.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'abstract_unit' - -class JavaScriptHelperTest < ActionView::TestCase - tests ActionView::Helpers::JavaScriptHelper - - attr_accessor :template_format, :output_buffer - - def setup - @template = self - end - - def test_escape_javascript - assert_equal '', escape_javascript(nil) - assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) - assert_equal %(backslash\\\\test), escape_javascript( %(backslash\\test) ) - assert_equal %(dont <\\/close> tags), escape_javascript(%(dont </close> tags)) - end - - def test_link_to_function - assert_dom_equal %(<a href="#" onclick="alert('Hello world!'); return false;">Greeting</a>), - link_to_function("Greeting", "alert('Hello world!')") - end - - def test_link_to_function_with_existing_onclick - assert_dom_equal %(<a href="#" onclick="confirm('Sanity!'); alert('Hello world!'); return false;">Greeting</a>), - link_to_function("Greeting", "alert('Hello world!')", :onclick => "confirm('Sanity!')") - end - - def test_link_to_function_with_rjs_block - html = link_to_function( "Greet me!" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);; return false;">Greet me!</a>), html - end - - def test_link_to_function_with_rjs_block_and_options - html = link_to_function( "Greet me!", :class => "updater" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);; return false;">Greet me!</a>), html - end - - def test_link_to_function_with_href - assert_dom_equal %(<a href="http://example.com/" onclick="alert('Hello world!'); return false;">Greeting</a>), - link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/') - end - - def test_button_to_function - assert_dom_equal %(<input type="button" onclick="alert('Hello world!');" value="Greeting" />), - button_to_function("Greeting", "alert('Hello world!')") - end - - def test_button_to_function_with_rjs_block - html = button_to_function( "Greet me!" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<input type="button" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);;" value="Greet me!" />), html - end - - def test_button_to_function_with_rjs_block_and_options - html = button_to_function( "Greet me!", :class => "greeter" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C\/h1\\u003E&quot;);;" value="Greet me!" />), html - end - - def test_button_to_function_with_onclick - assert_dom_equal "<input onclick=\"alert('Goodbye World :('); alert('Hello world!');\" type=\"button\" value=\"Greeting\" />", - button_to_function("Greeting", "alert('Hello world!')", :onclick => "alert('Goodbye World :(')") - end - - def test_button_to_function_without_function - assert_dom_equal "<input onclick=\";\" type=\"button\" value=\"Greeting\" />", - button_to_function("Greeting") - end - - def test_javascript_tag - self.output_buffer = 'foo' - - assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", - javascript_tag("alert('hello')") - - assert_equal 'foo', output_buffer, 'javascript_tag without a block should not concat to output_buffer' - end - - def test_javascript_tag_with_options - assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", - javascript_tag("alert('hello')", :id => "the_js_tag") - end - - def test_javascript_tag_with_block_in_erb - __in_erb_template = '' - javascript_tag { concat "alert('hello')" } - assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", output_buffer - end - - def test_javascript_tag_with_block_and_options_in_erb - __in_erb_template = '' - javascript_tag(:id => "the_js_tag") { concat "alert('hello')" } - assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", output_buffer - end - - def test_javascript_cdata_section - assert_dom_equal "\n//<![CDATA[\nalert('hello')\n//]]>\n", javascript_cdata_section("alert('hello')") - end -end diff --git a/vendor/rails/actionpack/test/template/number_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/number_helper_i18n_test.rb deleted file mode 100644 index bf5b8129..00000000 --- a/vendor/rails/actionpack/test/template/number_helper_i18n_test.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'abstract_unit' - -class NumberHelperI18nTests < Test::Unit::TestCase - include ActionView::Helpers::NumberHelper - - attr_reader :request - - def setup - @number_defaults = { :precision => 3, :delimiter => ',', :separator => '.' } - @currency_defaults = { :unit => '$', :format => '%u%n', :precision => 2 } - @human_defaults = { :precision => 1 } - @human_storage_units_format_default = "%n %u" - @human_storage_units_units_byte_other = "Bytes" - @human_storage_units_units_kb_other = "KB" - @percentage_defaults = { :delimiter => '' } - @precision_defaults = { :delimiter => '' } - - I18n.backend.store_translations 'en', :number => { :format => @number_defaults, - :currency => { :format => @currency_defaults }, :human => @human_defaults } - end - - def test_number_to_currency_translates_currency_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.currency.format', :locale => 'en', - :raise => true).returns(@currency_defaults) - number_to_currency(1, :locale => 'en') - end - - def test_number_with_precision_translates_number_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.precision.format', :locale => 'en', - :raise => true).returns(@precision_defaults) - number_with_precision(1, :locale => 'en') - end - - def test_number_with_delimiter_translates_number_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - number_with_delimiter(1, :locale => 'en') - end - - def test_number_to_percentage_translates_number_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.percentage.format', :locale => 'en', - :raise => true).returns(@percentage_defaults) - number_to_percentage(1, :locale => 'en') - end - - def test_number_to_human_size_translates_human_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.human.format', :locale => 'en', - :raise => true).returns(@human_defaults) - I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en', - :raise => true).returns(@human_storage_units_format_default) - I18n.expects(:translate).with(:'number.human.storage_units.units.kb', :locale => 'en', :count => 2, - :raise => true).returns(@human_storage_units_units_kb_other) - # 2KB - number_to_human_size(2048, :locale => 'en') - - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.human.format', :locale => 'en', - :raise => true).returns(@human_defaults) - I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en', - :raise => true).returns(@human_storage_units_format_default) - I18n.expects(:translate).with(:'number.human.storage_units.units.byte', :locale => 'en', :count => 42, - :raise => true).returns(@human_storage_units_units_byte_other) - # 42 Bytes - number_to_human_size(42, :locale => 'en') - end -end diff --git a/vendor/rails/actionpack/test/template/number_helper_test.rb b/vendor/rails/actionpack/test/template/number_helper_test.rb deleted file mode 100644 index b6542ef2..00000000 --- a/vendor/rails/actionpack/test/template/number_helper_test.rb +++ /dev/null @@ -1,132 +0,0 @@ -require 'abstract_unit' - -class NumberHelperTest < ActionView::TestCase - tests ActionView::Helpers::NumberHelper - - def test_number_to_phone - assert_equal("555-1234", number_to_phone(5551234)) - assert_equal("800-555-1212", number_to_phone(8005551212)) - assert_equal("(800) 555-1212", number_to_phone(8005551212, {:area_code => true})) - assert_equal("800 555 1212", number_to_phone(8005551212, {:delimiter => " "})) - assert_equal("(800) 555-1212 x 123", number_to_phone(8005551212, {:area_code => true, :extension => 123})) - assert_equal("800-555-1212", number_to_phone(8005551212, :extension => " ")) - assert_equal("800-555-1212", number_to_phone("8005551212")) - assert_equal("+1-800-555-1212", number_to_phone(8005551212, :country_code => 1)) - assert_equal("+18005551212", number_to_phone(8005551212, :country_code => 1, :delimiter => '')) - assert_equal("22-555-1212", number_to_phone(225551212)) - assert_equal("+45-22-555-1212", number_to_phone(225551212, :country_code => 45)) - assert_equal("x", number_to_phone("x")) - assert_nil number_to_phone(nil) - end - - def test_number_to_currency - assert_equal("$1,234,567,890.50", number_to_currency(1234567890.50)) - assert_equal("$1,234,567,890.51", number_to_currency(1234567890.506)) - assert_equal("$1,234,567,892", number_to_currency(1234567891.50, {:precision => 0})) - assert_equal("$1,234,567,890.5", number_to_currency(1234567890.50, {:precision => 1})) - assert_equal("&pound;1234567890,50", number_to_currency(1234567890.50, {:unit => "&pound;", :separator => ",", :delimiter => ""})) - assert_equal("$1,234,567,890.50", number_to_currency("1234567890.50")) - assert_equal("1,234,567,890.50 K&#269;", number_to_currency("1234567890.50", {:unit => "K&#269;", :format => "%n %u"})) - #assert_equal("$x.", number_to_currency("x")) # fails due to API consolidation - assert_equal("$x", number_to_currency("x")) - assert_nil number_to_currency(nil) - end - - def test_number_to_percentage - assert_equal("100.000%", number_to_percentage(100)) - assert_equal("100%", number_to_percentage(100, {:precision => 0})) - assert_equal("302.06%", number_to_percentage(302.0574, {:precision => 2})) - assert_equal("100.000%", number_to_percentage("100")) - assert_equal("1000.000%", number_to_percentage("1000")) - assert_equal("x%", number_to_percentage("x")) - assert_equal("1.000,000%", number_to_percentage(1000, :delimiter => '.', :separator => ',')) - assert_nil number_to_percentage(nil) - end - - def test_number_with_delimiter - assert_equal("12,345,678", number_with_delimiter(12345678)) - assert_equal("0", number_with_delimiter(0)) - assert_equal("123", number_with_delimiter(123)) - assert_equal("123,456", number_with_delimiter(123456)) - assert_equal("123,456.78", number_with_delimiter(123456.78)) - assert_equal("123,456.789", number_with_delimiter(123456.789)) - assert_equal("123,456.78901", number_with_delimiter(123456.78901)) - assert_equal("123,456,789.78901", number_with_delimiter(123456789.78901)) - assert_equal("0.78901", number_with_delimiter(0.78901)) - assert_equal("123,456.78", number_with_delimiter("123456.78")) - assert_equal("x", number_with_delimiter("x")) - assert_nil number_with_delimiter(nil) - end - - def test_number_with_delimiter_with_options_hash - assert_equal '12 345 678', number_with_delimiter(12345678, :delimiter => ' ') - assert_equal '12,345,678-05', number_with_delimiter(12345678.05, :separator => '-') - assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :separator => ',', :delimiter => '.') - assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',') - end - - def test_number_with_precision - assert_equal("111.235", number_with_precision(111.2346)) - assert_equal("31.83", number_with_precision(31.825, :precision => 2)) - assert_equal("111.23", number_with_precision(111.2346, :precision => 2)) - assert_equal("111.00", number_with_precision(111, :precision => 2)) - assert_equal("111.235", number_with_precision("111.2346")) - assert_equal("31.83", number_with_precision("31.825", :precision => 2)) - assert_equal("112", number_with_precision(111.50, :precision => 0)) - assert_equal("1234567892", number_with_precision(1234567891.50, :precision => 0)) - - # Return non-numeric params unchanged. - assert_equal("x", number_with_precision("x")) - assert_nil number_with_precision(nil) - end - - def test_number_with_precision_with_custom_delimiter_and_separator - assert_equal '31,83', number_with_precision(31.825, :precision => 2, :separator => ',') - assert_equal '1.231,83', number_with_precision(1231.825, :precision => 2, :separator => ',', :delimiter => '.') - end - - def test_number_to_human_size - assert_equal '0 Bytes', number_to_human_size(0) - assert_equal '1 Byte', number_to_human_size(1) - assert_equal '3 Bytes', number_to_human_size(3.14159265) - assert_equal '123 Bytes', number_to_human_size(123.0) - assert_equal '123 Bytes', number_to_human_size(123) - assert_equal '1.2 KB', number_to_human_size(1234) - assert_equal '12.1 KB', number_to_human_size(12345) - assert_equal '1.2 MB', number_to_human_size(1234567) - assert_equal '1.1 GB', number_to_human_size(1234567890) - assert_equal '1.1 TB', number_to_human_size(1234567890123) - assert_equal '1025 TB', number_to_human_size(1025.terabytes) - assert_equal '444 KB', number_to_human_size(444.kilobytes) - assert_equal '1023 MB', number_to_human_size(1023.megabytes) - assert_equal '3 TB', number_to_human_size(3.terabytes) - assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2) - assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4) - assert_equal("123 Bytes", number_to_human_size("123")) - assert_equal '1.01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2) - assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4) - assert_equal '10 KB', number_to_human_size(10.000.kilobytes, :precision => 4) - assert_equal '1 Byte', number_to_human_size(1.1) - assert_equal '10 Bytes', number_to_human_size(10) - #assert_nil number_to_human_size('x') # fails due to API consolidation - assert_nil number_to_human_size(nil) - end - - def test_number_to_human_size_with_options_hash - assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2) - assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4) - assert_equal '1.01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2) - assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4) - assert_equal '10 KB', number_to_human_size(10.000.kilobytes, :precision => 4) - assert_equal '1 TB', number_to_human_size(1234567890123, :precision => 0) - assert_equal '500 MB', number_to_human_size(524288000, :precision=>0) - assert_equal '40 KB', number_to_human_size(41010, :precision => 0) - assert_equal '40 KB', number_to_human_size(41100, :precision => 0) - end - - def test_number_to_human_size_with_custom_delimiter_and_separator - assert_equal '1,01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2, :separator => ',') - assert_equal '1,01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4, :separator => ',') - assert_equal '1.000,1 TB', number_to_human_size(1000.1.terabytes, :delimiter => '.', :separator => ',') - end -end diff --git a/vendor/rails/actionpack/test/template/prototype_helper_test.rb b/vendor/rails/actionpack/test/template/prototype_helper_test.rb deleted file mode 100644 index 3bcf5327..00000000 --- a/vendor/rails/actionpack/test/template/prototype_helper_test.rb +++ /dev/null @@ -1,639 +0,0 @@ -require 'abstract_unit' - -Bunny = Struct.new(:Bunny, :id) - -class Author - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new author' : "author ##{@id}" - end -end - -class Article - attr_reader :id - attr_reader :author_id - def save; @id = 1; @author_id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new article' : "article ##{@id}" - end -end - -class Author::Nested < Author; end - - -class PrototypeHelperBaseTest < ActionView::TestCase - attr_accessor :template_format, :output_buffer - - def setup - @template = self - @controller = Class.new do - def url_for(options) - if options.is_a?(String) - options - else - url = "http://www.example.com/" - url << options[:action].to_s if options and options[:action] - url << "?a=#{options[:a]}" if options && options[:a] - url << "&b=#{options[:b]}" if options && options[:a] && options[:b] - url - end - end - end.new - end - - protected - def request_forgery_protection_token - nil - end - - def protect_against_forgery? - false - end - - def create_generator - block = Proc.new { |*args| yield *args if block_given? } - JavaScriptGenerator.new self, &block - end -end - -class PrototypeHelperTest < PrototypeHelperBaseTest - def setup - @record = @author = Author.new - @article = Article.new - super - end - - def test_link_to_remote - assert_dom_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }}, { :class => "fine" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :complete => "alert(request.responseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :success => "alert(request.responseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :failure => "alert(request.responseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :failure => "alert(request.responseText)", :url => { :action => "whatnot", :a => '10', :b => '20' }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:false, evalScripts:true}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :type => :synchronous) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, insertion:'bottom'}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom) - end - - def test_link_to_remote_html_options - assert_dom_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } }) - end - - def test_link_to_remote_url_quote_escaping - assert_dom_equal %(<a href="#" onclick="new Ajax.Request('http://www.example.com/whatnot\\\'s', {asynchronous:true, evalScripts:true}); return false;">Remote</a>), - link_to_remote("Remote", { :url => { :action => "whatnot's" } }) - end - - def test_button_to_remote - assert_dom_equal %(<input class=\"fine\" type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true});\" />), - button_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :class => "fine" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :complete => "alert(request.reponseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :success => "alert(request.reponseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot", :a => '10', :b => '20' }) - end - - def test_periodically_call_remote - assert_dom_equal %(<script type="text/javascript">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)\n//]]>\n</script>), - periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" }) - end - - def test_periodically_call_remote_with_frequency - assert_dom_equal( - "<script type=\"text/javascript\">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true})}, 2)\n//]]>\n</script>", - periodically_call_remote(:frequency => 2) - ) - end - - def test_form_remote_tag - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }) - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => { :success => "glass_of_beer" }, :url => { :action => :fast }) - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => { :failure => "glass_of_water" }, :url => { :action => :fast }) - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => { :success => 'glass_of_beer', :failure => "glass_of_water" }, :url => { :action => :fast }) - end - - def test_form_remote_tag_with_method - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"><div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div>), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, :html => { :method => :put }) - end - - def test_form_remote_tag_with_block_in_erb - __in_erb_template = '' - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }) { concat "Hello world!" } - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">Hello world!</form>), output_buffer - end - - def test_remote_form_for_with_record_identification_with_new_record - remote_form_for(@record, {:html => { :id => 'create-author' }}) {} - - expected = %(<form action='#{authors_path}' onsubmit="new Ajax.Request('#{authors_path}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='new_author' id='create-author' method='post'></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_record_identification_without_html_options - remote_form_for(@record) {} - - expected = %(<form action='#{authors_path}' onsubmit="new Ajax.Request('#{authors_path}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='new_author' method='post' id='new_author'></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_record_identification_with_existing_record - @record.save - remote_form_for(@record) {} - - expected = %(<form action='#{author_path(@record)}' id='edit_author_1' method='post' onsubmit="new Ajax.Request('#{author_path(@record)}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='edit_author'><div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_new_object_in_list - remote_form_for([@author, @article]) {} - - expected = %(<form action='#{author_articles_path(@author)}' onsubmit="new Ajax.Request('#{author_articles_path(@author)}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='new_article' method='post' id='new_article'></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_existing_object_in_list - @author.save - @article.save - remote_form_for([@author, @article]) {} - - expected = %(<form action='#{author_article_path(@author, @article)}' id='edit_article_1' method='post' onsubmit="new Ajax.Request('#{author_article_path(@author, @article)}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='edit_article'><div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_on_callbacks - callbacks = [:uninitialized, :loading, :loaded, :interactive, :complete, :success, :failure] - callbacks.each do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => { :success => "glass_of_beer" }, :url => { :action => :fast }, callback=>"monkeys();") - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({failure:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => { :failure => "glass_of_beer" }, :url => { :action => :fast }, callback=>"monkeys();") - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => { :success => "glass_of_beer", :failure => "glass_of_water" }, :url => { :action => :fast }, callback=>"monkeys();") - end - - #HTTP status codes 200 up to 599 have callbacks - #these should work - 100.upto(599) do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - end - - #test 200 and 404 - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on200:function(request){monkeys();}, on404:function(request){bananas();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, 200=>"monkeys();", 404=>"bananas();") - - #these shouldn't - 1.upto(99) do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - end - 600.upto(999) do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - end - - #test ultimate combo - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on200:function(request){monkeys();}, on404:function(request){bananas();}, onComplete:function(request){c();}, onFailure:function(request){f();}, onLoading:function(request){c1()}, onSuccess:function(request){s()}, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, :loading => "c1()", :success => "s()", :failure => "f();", :complete => "c();", 200=>"monkeys();", 404=>"bananas();") - - end - - def test_submit_to_remote - assert_dom_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});\" type=\"button\" value=\"1000000\" />), - submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle") - end - - def test_observe_field - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/reorder_if_empty', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>), - observe_field("glass", :frequency => 5.minutes, :url => { :action => "reorder_if_empty" }) - end - - def test_observe_field_using_with_option - expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(value)})})\n//]]>\n</script>) - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id') - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + encodeURIComponent(value)") - end - - def test_observe_field_using_json_in_with_option - expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:{'id':value}})})\n//]]>\n</script>) - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "{'id':value}") - end - - def test_observe_field_using_function_for_callback - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {alert('Element changed')})\n//]]>\n</script>), - observe_field("glass", :frequency => 5.minutes, :function => "alert('Element changed')") - end - - def test_observe_form - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>), - observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" }) - end - - def test_observe_form_using_function_for_callback - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {alert('Form changed')})\n//]]>\n</script>), - observe_form("cart", :frequency => 2, :function => "alert('Form changed')") - end - - def test_observe_field_without_frequency - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.EventObserver('glass', function(element, value) {new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>), - observe_field("glass") - end - - def test_update_page - old_output_buffer = output_buffer - - block = Proc.new { |page| page.replace_html('foo', 'bar') } - assert_equal create_generator(&block).to_s, update_page(&block) - - assert_equal old_output_buffer, output_buffer - end - - def test_update_page_tag - block = Proc.new { |page| page.replace_html('foo', 'bar') } - assert_equal javascript_tag(create_generator(&block).to_s), update_page_tag(&block) - end - - def test_update_page_tag_with_html_options - block = Proc.new { |page| page.replace_html('foo', 'bar') } - assert_equal javascript_tag(create_generator(&block).to_s, {:defer => 'true'}), update_page_tag({:defer => 'true'}, &block) - end - - - protected - def author_path(record) - "/authors/#{record.id}" - end - - def authors_path - "/authors" - end - - def author_articles_path(author) - "/authors/#{author.id}/articles" - end - - def author_article_path(author, article) - "/authors/#{author.id}/articles/#{article.id}" - end -end - -class JavaScriptGeneratorTest < PrototypeHelperBaseTest - def setup - super - @generator = create_generator - end - - def test_insert_html_with_string - assert_equal 'Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" });', - @generator.insert_html(:top, 'element', '<p>This is a test</p>') - assert_equal 'Element.insert("element", { bottom: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', - @generator.insert_html(:bottom, 'element', '<p>This is a test</p>') - assert_equal 'Element.insert("element", { before: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', - @generator.insert_html(:before, 'element', '<p>This is a test</p>') - assert_equal 'Element.insert("element", { after: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', - @generator.insert_html(:after, 'element', '<p>This is a test</p>') - end - - def test_replace_html_with_string - assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E");', - @generator.replace_html('element', '<p>This is a test</p>') - end - - def test_replace_element_with_string - assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C/p\\u003E\\u003C/div\\u003E");', - @generator.replace('element', '<div id="element"><p>This is a test</p></div>') - end - - def test_remove - assert_equal 'Element.remove("foo");', - @generator.remove('foo') - assert_equal '["foo","bar","baz"].each(Element.remove);', - @generator.remove('foo', 'bar', 'baz') - end - - def test_show - assert_equal 'Element.show("foo");', - @generator.show('foo') - assert_equal '["foo","bar","baz"].each(Element.show);', - @generator.show('foo', 'bar', 'baz') - end - - def test_hide - assert_equal 'Element.hide("foo");', - @generator.hide('foo') - assert_equal '["foo","bar","baz"].each(Element.hide);', - @generator.hide('foo', 'bar', 'baz') - end - - def test_toggle - assert_equal 'Element.toggle("foo");', - @generator.toggle('foo') - assert_equal '["foo","bar","baz"].each(Element.toggle);', - @generator.toggle('foo', 'bar', 'baz') - end - - def test_alert - assert_equal 'alert("hello");', @generator.alert('hello') - end - - def test_redirect_to - assert_equal 'window.location.href = "http://www.example.com/welcome";', - @generator.redirect_to(:action => 'welcome') - assert_equal 'window.location.href = "http://www.example.com/welcome?a=b&c=d";', - @generator.redirect_to("http://www.example.com/welcome?a=b&c=d") - end - - def test_reload - assert_equal 'window.location.reload();', - @generator.reload - end - - def test_delay - @generator.delay(20) do - @generator.hide('foo') - end - - assert_equal "setTimeout(function() {\n;\nElement.hide(\"foo\");\n}, 20000);", @generator.to_s - end - - def test_to_s - @generator.insert_html(:top, 'element', '<p>This is a test</p>') - @generator.insert_html(:bottom, 'element', '<p>This is a test</p>') - @generator.remove('foo', 'bar') - @generator.replace_html('baz', '<p>This is a test</p>') - - assert_equal <<-EOS.chomp, @generator.to_s -Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" }); -Element.insert("element", { bottom: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" }); -["foo","bar"].each(Element.remove); -Element.update("baz", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E"); - EOS - end - - def test_element_access - assert_equal %($("hello");), @generator['hello'] - end - - def test_element_access_on_records - assert_equal %($("bunny_5");), @generator[Bunny.new(:id => 5)] - assert_equal %($("new_bunny");), @generator[Bunny.new] - end - - def test_element_proxy_one_deep - @generator['hello'].hide - assert_equal %($("hello").hide();), @generator.to_s - end - - def test_element_proxy_variable_access - @generator['hello']['style'] - assert_equal %($("hello").style;), @generator.to_s - end - - def test_element_proxy_variable_access_with_assignment - @generator['hello']['style']['color'] = 'red' - assert_equal %($("hello").style.color = "red";), @generator.to_s - end - - def test_element_proxy_assignment - @generator['hello'].width = 400 - assert_equal %($("hello").width = 400;), @generator.to_s - end - - def test_element_proxy_two_deep - @generator['hello'].hide("first").clean_whitespace - assert_equal %($("hello").hide("first").cleanWhitespace();), @generator.to_s - end - - def test_select_access - assert_equal %($$("div.hello");), @generator.select('div.hello') - end - - def test_select_proxy_one_deep - @generator.select('p.welcome b').first.hide - assert_equal %($$("p.welcome b").first().hide();), @generator.to_s - end - - def test_visual_effect - assert_equal %(new Effect.Puff("blah",{});), - @generator.visual_effect(:puff,'blah') - end - - def test_visual_effect_toggle - assert_equal %(Effect.toggle("blah",'appear',{});), - @generator.visual_effect(:toggle_appear,'blah') - end - - def test_sortable - assert_equal %(Sortable.create("blah", {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("blah")})}});), - @generator.sortable('blah', :url => { :action => "order" }) - assert_equal %(Sortable.create("blah", {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:false, evalScripts:true, parameters:Sortable.serialize("blah")})}});), - @generator.sortable('blah', :url => { :action => "order" }, :type => :synchronous) - end - - def test_draggable - assert_equal %(new Draggable("blah", {});), - @generator.draggable('blah') - end - - def test_drop_receiving - assert_equal %(Droppables.add("blah", {onDrop:function(element){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}});), - @generator.drop_receiving('blah', :url => { :action => "order" }) - assert_equal %(Droppables.add("blah", {onDrop:function(element){new Ajax.Request('http://www.example.com/order', {asynchronous:false, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}});), - @generator.drop_receiving('blah', :url => { :action => "order" }, :type => :synchronous) - end - - def test_collection_first_and_last - @generator.select('p.welcome b').first.hide() - @generator.select('p.welcome b').last.show() - assert_equal <<-EOS.strip, @generator.to_s -$$("p.welcome b").first().hide(); -$$("p.welcome b").last().show(); - EOS - end - - def test_collection_proxy_with_each - @generator.select('p.welcome b').each do |value| - value.remove_class_name 'selected' - end - @generator.select('p.welcome b').each do |value, index| - @generator.visual_effect :highlight, value - end - assert_equal <<-EOS.strip, @generator.to_s -$$("p.welcome b").each(function(value, index) { -value.removeClassName("selected"); -}); -$$("p.welcome b").each(function(value, index) { -new Effect.Highlight(value,{}); -}); - EOS - end - - def test_collection_proxy_on_collect - @generator.select('p').collect('a') { |para| para.show } - @generator.select('p').collect { |para| para.hide } - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").collect(function(value, index) { -return value.show(); -}); -$$("p").collect(function(value, index) { -return value.hide(); -}); - EOS - @generator = create_generator - end - - def test_collection_proxy_with_grep - @generator.select('p').grep 'a', /^a/ do |value| - @generator << '(value.className == "welcome")' - end - @generator.select('p').grep 'b', /b$/ do |value, index| - @generator.call 'alert', value - @generator << '(value.className == "welcome")' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").grep(/^a/, function(value, index) { -return (value.className == "welcome"); -}); -var b = $$("p").grep(/b$/, function(value, index) { -alert(value); -return (value.className == "welcome"); -}); - EOS - end - - def test_collection_proxy_with_inject - @generator.select('p').inject 'a', [] do |memo, value| - @generator << '(value.className == "welcome")' - end - @generator.select('p').inject 'b', nil do |memo, value, index| - @generator.call 'alert', memo - @generator << '(value.className == "welcome")' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").inject([], function(memo, value, index) { -return (value.className == "welcome"); -}); -var b = $$("p").inject(null, function(memo, value, index) { -alert(memo); -return (value.className == "welcome"); -}); - EOS - end - - def test_collection_proxy_with_pluck - @generator.select('p').pluck('a', 'className') - assert_equal %(var a = $$("p").pluck("className");), @generator.to_s - end - - def test_collection_proxy_with_zip - ActionView::Helpers::JavaScriptCollectionProxy.new(@generator, '[1, 2, 3]').zip('a', [4, 5, 6], [7, 8, 9]) - ActionView::Helpers::JavaScriptCollectionProxy.new(@generator, '[1, 2, 3]').zip('b', [4, 5, 6], [7, 8, 9]) do |array| - @generator.call 'array.reverse' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = [1, 2, 3].zip([4,5,6], [7,8,9]); -var b = [1, 2, 3].zip([4,5,6], [7,8,9], function(array) { -return array.reverse(); -}); - EOS - end - - def test_collection_proxy_with_find_all - @generator.select('p').find_all 'a' do |value, index| - @generator << '(value.className == "welcome")' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").findAll(function(value, index) { -return (value.className == "welcome"); -}); - EOS - end - - def test_collection_proxy_with_in_groups_of - @generator.select('p').in_groups_of('a', 3) - @generator.select('p').in_groups_of('a', 3, 'x') - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").inGroupsOf(3); -var a = $$("p").inGroupsOf(3, "x"); - EOS - end - - def test_collection_proxy_with_each_slice - @generator.select('p').each_slice('a', 3) - @generator.select('p').each_slice('a', 3) do |group, index| - group.reverse - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").eachSlice(3); -var a = $$("p").eachSlice(3, function(value, index) { -return value.reverse(); -}); - EOS - end - - def test_debug_rjs - ActionView::Base.debug_rjs = true - @generator['welcome'].replace_html 'Welcome' - assert_equal "try {\n$(\"welcome\").update(\"Welcome\");\n} catch (e) { alert('RJS error:\\n\\n' + e.toString()); alert('$(\\\"welcome\\\").update(\\\"Welcome\\\");'); throw e }", @generator.to_s - ensure - ActionView::Base.debug_rjs = false - end - - def test_literal - literal = @generator.literal("function() {}") - assert_equal "function() {}", ActiveSupport::JSON.encode(literal) - assert_equal "", @generator.to_s - end - - def test_class_proxy - @generator.form.focus('my_field') - assert_equal "Form.focus(\"my_field\");", @generator.to_s - end - - def test_call_with_block - @generator.call(:before) - @generator.call(:my_method) do |p| - p[:one].show - p[:two].hide - end - @generator.call(:in_between) - @generator.call(:my_method_with_arguments, true, "hello") do |p| - p[:three].visual_effect(:highlight) - end - assert_equal "before();\nmy_method(function() { $(\"one\").show();\n$(\"two\").hide(); });\nin_between();\nmy_method_with_arguments(true, \"hello\", function() { $(\"three\").visualEffect(\"highlight\"); });", @generator.to_s - end - - def test_class_proxy_call_with_block - @generator.my_object.my_method do |p| - p[:one].show - p[:two].hide - end - assert_equal "MyObject.myMethod(function() { $(\"one\").show();\n$(\"two\").hide(); });", @generator.to_s - end -end - diff --git a/vendor/rails/actionpack/test/template/raw_output_helper_test.rb b/vendor/rails/actionpack/test/template/raw_output_helper_test.rb deleted file mode 100644 index 598aa5b1..00000000 --- a/vendor/rails/actionpack/test/template/raw_output_helper_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'abstract_unit' -require 'testing_sandbox' - -class RawOutputHelperTest < ActionView::TestCase - tests ActionView::Helpers::RawOutputHelper - include TestingSandbox - - def setup - @string = "hello" - end - - test "raw returns the safe string" do - result = raw(@string) - assert_equal @string, result - assert result.html_safe? - end - - test "raw handles nil values correctly" do - assert_equal "", raw(nil) - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/template/record_tag_helper_test.rb b/vendor/rails/actionpack/test/template/record_tag_helper_test.rb deleted file mode 100644 index 67aa0477..00000000 --- a/vendor/rails/actionpack/test/template/record_tag_helper_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'abstract_unit' - -class Post - def id - 45 - end - def body - "What a wonderful world!" - end -end - -class RecordTagHelperTest < ActionView::TestCase - tests ActionView::Helpers::RecordTagHelper - - def setup - @post = Post.new - end - - def test_content_tag_for - expected = %(<li class="post bar" id="post_45"></li>) - actual = content_tag_for(:li, @post, :class => 'bar') { } - assert_dom_equal expected, actual - end - - def test_content_tag_for_prefix - expected = %(<ul class="post" id="archived_post_45"></ul>) - actual = content_tag_for(:ul, @post, :archived) { } - assert_dom_equal expected, actual - end - - def test_content_tag_for_with_extra_html_tags - expected = %(<tr class="post bar" id="post_45" style='background-color: #f0f0f0'></tr>) - actual = content_tag_for(:tr, @post, {:class => "bar", :style => "background-color: #f0f0f0"}) { } - assert_dom_equal expected, actual - end - - def test_block_not_in_erb_multiple_calls - expected = %(<div class="post bar" id="post_45">#{@post.body}</div>) - actual = div_for(@post, :class => "bar") { @post.body } - assert_dom_equal expected, actual - actual = div_for(@post, :class => "bar") { @post.body } - assert_dom_equal expected, actual - end - - def test_block_works_with_content_tag_for_in_erb - __in_erb_template = '' - expected = %(<tr class="post" id="post_45">#{@post.body}</tr>) - actual = content_tag_for(:tr, @post) { concat @post.body } - assert_dom_equal expected, actual - end - - def test_div_for_in_erb - __in_erb_template = '' - expected = %(<div class="post bar" id="post_45">#{@post.body}</div>) - actual = div_for(@post, :class => "bar") { concat @post.body } - assert_dom_equal expected, actual - end -end diff --git a/vendor/rails/actionpack/test/template/render_test.rb b/vendor/rails/actionpack/test/template/render_test.rb deleted file mode 100644 index 454aa4c9..00000000 --- a/vendor/rails/actionpack/test/template/render_test.rb +++ /dev/null @@ -1,329 +0,0 @@ -# encoding: utf-8 -require 'abstract_unit' -require 'controller/fake_models' - -module RenderTestCases - def setup_view(paths) - @assigns = { :secret => 'in the sauce' } - @view = ActionView::Base.new(paths, @assigns) - - # Reload and register danish language for testing - I18n.reload! - I18n.backend.store_translations 'da', {} - I18n.backend.store_translations 'pt-BR', {} - - # Ensure original are still the same since we are reindexing view paths - assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort - end - - def test_render_file - assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb") - end - - def test_render_file_not_using_full_path - assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb") - end - - def test_render_file_without_specific_extension - assert_equal "Hello world!", @view.render(:file => "test/hello_world") - end - - def test_render_file_with_localization - old_locale = I18n.locale - I18n.locale = :da - assert_equal "Hey verden", @view.render(:file => "test/hello_world") - ensure - I18n.locale = old_locale - end - - def test_render_file_with_dashed_locale - old_locale = I18n.locale - I18n.locale = :"pt-BR" - assert_equal "Ola mundo", @view.render(:file => "test/hello_world") - ensure - I18n.locale = old_locale - end - - def test_render_implicit_html_template_from_xhr_request - old_format = @view.template_format - @view.template_format = :js - assert_equal "Hello HTML!", @view.render(:file => "test/render_implicit_html_template_from_xhr_request") - ensure - @view.template_format = old_format - end - - def test_render_implicit_html_template_from_xhr_request_with_localization - old_locale = I18n.locale - old_format = @view.template_format - I18n.locale = :da - @view.template_format = :js - assert_equal "Hey HTML!\n", @view.render(:file => "test/render_implicit_html_template_from_xhr_request") - ensure - I18n.locale = old_locale - @view.template_format = old_format - end - - def test_render_file_at_top_level - assert_equal 'Elastica', @view.render(:file => '/shared') - end - - def test_render_file_with_full_path - template_path = File.join(File.dirname(__FILE__), '../fixtures/test/hello_world.erb') - assert_equal "Hello world!", @view.render(:file => template_path) - end - - def test_render_file_with_instance_variables - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_ivar.erb") - end - - def test_render_file_with_locals - locals = { :secret => 'in the sauce' } - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_locals.erb", :locals => locals) - end - - def test_render_file_not_using_full_path_with_dot_in_path - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/dot.directory/render_file_with_ivar") - end - - def test_render_has_access_current_template - assert_equal "test/template.erb", @view.render(:file => "test/template.erb") - end - - def test_render_update - # TODO: You should not have to stub out template because template is self! - @view.instance_variable_set(:@template, @view) - assert_equal 'alert("Hello, World!");', @view.render(:update) { |page| page.alert('Hello, World!') } - end - - def test_render_partial_from_default - assert_equal "only partial", @view.render("test/partial_only") - end - - def test_render_partial - assert_equal "only partial", @view.render(:partial => "test/partial_only") - end - - def test_render_partial_with_format - assert_equal 'partial html', @view.render(:partial => 'test/partial') - end - - def test_render_partial_at_top_level - # file fixtures/_top_level_partial_only.erb (not fixtures/test) - assert_equal 'top level partial', @view.render(:partial => '/top_level_partial_only') - end - - def test_render_partial_with_format_at_top_level - # file fixtures/_top_level_partial.html.erb (not fixtures/test, with format extension) - assert_equal 'top level partial html', @view.render(:partial => '/top_level_partial') - end - - def test_render_partial_with_locals - assert_equal "5", @view.render(:partial => "test/counter", :locals => { :counter_counter => 5 }) - end - - def test_render_partial_with_locals_from_default - assert_equal "only partial", @view.render("test/partial_only", :counter_counter => 5) - end - - def test_render_partial_with_errors - @view.render(:partial => "test/raise") - flunk "Render did not raise TemplateError" - rescue ActionView::TemplateError => e - assert_match "undefined local variable or method `doesnt_exist'", e.message - assert_equal "", e.sub_template_message - assert_equal "1", e.line_number - assert_equal File.expand_path("#{FIXTURE_LOAD_PATH}/test/_raise.html.erb"), e.file_name - end - - def test_render_sub_template_with_errors - @view.render(:file => "test/sub_template_raise") - flunk "Render did not raise TemplateError" - rescue ActionView::TemplateError => e - assert_match "undefined local variable or method `doesnt_exist'", e.message - assert_equal "Trace of template inclusion: #{File.expand_path("#{FIXTURE_LOAD_PATH}/test/sub_template_raise.html.erb")}", e.sub_template_message - assert_equal "1", e.line_number - assert_equal File.expand_path("#{FIXTURE_LOAD_PATH}/test/_raise.html.erb"), e.file_name - end - - def test_render_object - assert_equal "Hello: david", @view.render(:partial => "test/customer", :object => Customer.new("david")) - end - - def test_render_partial_collection - assert_equal "Hello: davidHello: mary", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), Customer.new("mary") ]) - end - - def test_render_partial_collection_as - assert_equal "david david davidmary mary mary", - @view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer) - end - - def test_render_partial_collection_without_as - assert_equal "local_inspector,local_inspector_counter,object", - @view.render(:partial => "test/local_inspector", :collection => [ Customer.new("mary") ]) - end - - def test_render_partial_with_empty_collection_should_return_nil - assert_nil @view.render(:partial => "test/customer", :collection => []) - end - - def test_render_partial_with_nil_collection_should_return_nil - assert_nil @view.render(:partial => "test/customer", :collection => nil) - end - - def test_render_partial_with_nil_values_in_collection - assert_equal "Hello: davidHello: Anonymous", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), nil ]) - end - - def test_render_partial_with_empty_array_should_return_nil - assert_nil @view.render(:partial => []) - end - - # TODO: The reason for this test is unclear, improve documentation - def test_render_partial_and_fallback_to_layout - assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" }) - end - - # TODO: The reason for this test is unclear, improve documentation - def test_render_missing_xml_partial_and_raise_missing_template - @view.template_format = :xml - assert_raise(ActionView::MissingTemplate) { @view.render(:partial => "test/layout_for_partial") } - end - - def test_render_inline - assert_equal "Hello, World!", @view.render(:inline => "Hello, World!") - end - - def test_render_inline_with_locals - assert_equal "Hello, Josh!", @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }) - end - - def test_render_fallbacks_to_erb_for_unknown_types - assert_equal "Hello, World!", @view.render(:inline => "Hello, World!", :type => :bar) - end - - CustomHandler = lambda do |template| - "@output_buffer = ''\n" + - "@output_buffer << 'source: #{template.source.inspect}'\n" - end - - def test_render_inline_with_compilable_custom_type - ActionView::Template.register_template_handler :foo, CustomHandler - assert_equal 'source: "Hello, World!"', @view.render(:inline => "Hello, World!", :type => :foo) - end - - def test_render_inline_with_locals_and_compilable_custom_type - ActionView::Template.register_template_handler :foo, CustomHandler - assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) - end - - class LegacyHandler < ActionView::TemplateHandler - def render(template, local_assigns) - "source: #{template.source}; locals: #{local_assigns.inspect}" - end - end - - def test_render_legacy_handler_with_custom_type - ActionView::Template.register_template_handler :foo, LegacyHandler - assert_equal 'source: Hello, <%= name %>!; locals: {:name=>"Josh"}', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) - end - - def test_render_ignores_templates_with_malformed_template_handlers - %w(malformed malformed.erb malformed.html.erb malformed.en.html.erb).each do |name| - assert_raise(ActionView::MissingTemplate) { @view.render(:file => "test/malformed/#{name}") } - end - end - - def test_template_with_malformed_template_handler_is_reachable_through_its_exact_filename - assert_equal "Don't render me!", @view.render(:file => 'test/malformed/malformed.html.erb~') - end - - def test_render_with_layout - assert_equal %(<title></title>\nHello world!\n), - @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield") - end - - def test_render_with_nested_layout - assert_equal %(<title>title</title>\n<div id="column">column</div>\n<div id="content">content</div>\n), - @view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield") - end -end - -module TemplatesSetupTeardown - def setup_view_paths_for(new_cache_template_loading) - @previous_cache_template_loading, ActionView::Base.cache_template_loading = ActionView::Base.cache_template_loading, new_cache_template_loading - view_paths = new_cache_template_loading ? CACHED_VIEW_PATHS : ActionView::Base.process_view_paths(CACHED_VIEW_PATHS.map(&:to_s)) - assert_equal(new_cache_template_loading ? ActionView::Template::EagerPath : ActionView::ReloadableTemplate::ReloadablePath, view_paths.first.class) - setup_view(view_paths) - end - - def teardown - ActionView::Base.cache_template_loading = @previous_cache_template_loading - end -end - -class CachedRenderTest < Test::Unit::TestCase - include TemplatesSetupTeardown - include RenderTestCases - - def setup - setup_view_paths_for(cache_templates = true) - end -end - -class ReloadableRenderTest < Test::Unit::TestCase - include TemplatesSetupTeardown - include RenderTestCases - - def setup - setup_view_paths_for(cache_templates = false) - end - - if '1.9'.respond_to?(:force_encoding) - def test_render_utf8_template_with_magic_comment - with_external_encoding Encoding::ASCII_8BIT do - result = @view.render(:file => "test/utf8_magic.html.erb", :layouts => "layouts/yield") - assert_equal Encoding::UTF_8, result.encoding - assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result - end - end - - def test_render_utf8_template_with_default_external_encoding - with_external_encoding Encoding::UTF_8 do - result = @view.render(:file => "test/utf8.html.erb", :layouts => "layouts/yield") - assert_equal Encoding::UTF_8, result.encoding - assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result - end - end - - def test_render_utf8_template_with_incompatible_external_encoding - with_external_encoding Encoding::SJIS do - begin - result = @view.render(:file => "test/utf8.html.erb", :layouts => "layouts/yield") - flunk 'Should have raised incompatible encoding error' - rescue ActionView::TemplateError => error - assert_match 'invalid byte sequence in Shift_JIS', error.original_exception.message - end - end - end - - def test_render_utf8_template_with_partial_with_incompatible_encoding - with_external_encoding Encoding::SJIS do - begin - result = @view.render(:file => "test/utf8_magic_with_bare_partial.html.erb", :layouts => "layouts/yield") - flunk 'Should have raised incompatible encoding error' - rescue ActionView::TemplateError => error - assert_match 'invalid byte sequence in Shift_JIS', error.original_exception.message - end - end - end - - def with_external_encoding(encoding) - old, Encoding.default_external = Encoding.default_external, encoding - yield - ensure - Encoding.default_external = old - end - end -end - diff --git a/vendor/rails/actionpack/test/template/sanitize_helper_test.rb b/vendor/rails/actionpack/test/template/sanitize_helper_test.rb deleted file mode 100644 index 222d4dbf..00000000 --- a/vendor/rails/actionpack/test/template/sanitize_helper_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'abstract_unit' -require 'testing_sandbox' - -# The exhaustive tests are in test/controller/html/sanitizer_test.rb. -# This tests the that the helpers hook up correctly to the sanitizer classes. -class SanitizeHelperTest < ActionView::TestCase - tests ActionView::Helpers::SanitizeHelper - include TestingSandbox - - def test_strip_links - assert_equal "Dont touch me", strip_links("Dont touch me") - assert_equal "<a<a", strip_links("<a<a") - assert_equal "on my mind\nall day long", strip_links("<a href='almost'>on my mind</a>\n<A href='almost'>all day long</A>") - assert_equal "0wn3d", strip_links("<a href='http://www.rubyonrails.com/'><a href='http://www.rubyonrails.com/' onlclick='steal()'>0wn3d</a></a>") - assert_equal "Magic", strip_links("<a href='http://www.rubyonrails.com/'>Mag<a href='http://www.ruby-lang.org/'>ic") - assert_equal "FrrFox", strip_links("<href onlclick='steal()'>FrrFox</a></href>") - assert_equal "My mind\nall <b>day</b> long", strip_links("<a href='almost'>My mind</a>\n<A href='almost'>all <b>day</b> long</A>") - assert_equal "all <b>day</b> long", strip_links("<<a>a href='hello'>all <b>day</b> long<</A>/a>") - end - - def test_sanitize_form - assert_sanitized "<form action=\"/foo/bar\" method=\"post\"><input></form>", '' - end - - def test_should_sanitize_illegal_style_properties - raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;) - expected = %(display: block; width: 100%; height: 100%; background-color: black; background-image: ; background-x: center; background-y: center;) - assert_equal expected, sanitize_css(raw) - end - - def test_strip_tags - assert_equal("<<<bad html", strip_tags("<<<bad html")) - assert_equal("<<", strip_tags("<<<bad html>")) - assert_equal("Dont touch me", strip_tags("Dont touch me")) - assert_equal("This is a test.", strip_tags("<p>This <u>is<u> a <a href='test.html'><strong>test</strong></a>.</p>")) - assert_equal("Weirdos", strip_tags("Wei<<a>a onclick='alert(document.cookie);'</a>/>rdos")) - assert_equal("This is a test.", strip_tags("This is a test.")) - assert_equal( - %{This is a test.\n\n\nIt no longer contains any HTML.\n}, strip_tags( - %{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n})) - assert_equal "This has a here.", strip_tags("This has a <!-- comment --> here.") - [nil, '', ' '].each do |blank| - stripped = strip_tags(blank) - assert_equal blank, stripped - assert stripped.html_safe? unless blank.nil? - end - assert strip_tags("<script>").html_safe? - end - - def test_sanitize_is_marked_safe - assert sanitize("<html><script></script></html>").html_safe? - end - - def assert_sanitized(text, expected = nil) - assert_equal((expected || text), sanitize(text)) - end -end diff --git a/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb b/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb deleted file mode 100644 index 690a7751..00000000 --- a/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'abstract_unit' - -class ScriptaculousHelperTest < ActionView::TestCase - tests ActionView::Helpers::ScriptaculousHelper - - def setup - @controller = Class.new do - def url_for(options) - url = "http://www.example.com/" - url << options[:action].to_s if options and options[:action] - url - end - end.new - end - - def test_effect - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, "posts") - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect("highlight", :posts) - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, :posts) - assert_equal "new Effect.Fade(\"fademe\",{duration:4.0});", visual_effect(:fade, "fademe", :duration => 4.0) - assert_equal "new Effect.Shake(element,{});", visual_effect(:shake) - assert_equal "new Effect.DropOut(\"dropme\",{queue:'end'});", visual_effect(:drop_out, 'dropme', :queue => :end) - assert_equal "new Effect.Highlight(\"status\",{endcolor:'#EEEEEE'});", visual_effect(:highlight, 'status', :endcolor => '#EEEEEE') - assert_equal "new Effect.Highlight(\"status\",{restorecolor:'#500000', startcolor:'#FEFEFE'});", visual_effect(:highlight, 'status', :restorecolor => '#500000', :startcolor => '#FEFEFE') - - # chop the queue params into a comma separated list - beginning, ending = 'new Effect.DropOut("dropme",{queue:{', '}});' - ve = [ - visual_effect(:drop_out, 'dropme', :queue => {:position => "end", :scope => "test", :limit => 2}), - visual_effect(:drop_out, 'dropme', :queue => {:scope => :list, :limit => 2}), - visual_effect(:drop_out, 'dropme', :queue => {:position => :end, :scope => :test, :limit => 2}) - ].collect { |v| v[beginning.length..-ending.length-1].split(',') } - - assert ve[0].include?("limit:2") - assert ve[0].include?("scope:'test'") - assert ve[0].include?("position:'end'") - - assert ve[1].include?("limit:2") - assert ve[1].include?("scope:'list'") - - assert ve[2].include?("limit:2") - assert ve[2].include?("scope:'test'") - assert ve[2].include?("position:'end'") - end - - def test_toggle_effects - assert_equal "Effect.toggle(\"posts\",'appear',{});", visual_effect(:toggle_appear, "posts") - assert_equal "Effect.toggle(\"posts\",'slide',{});", visual_effect(:toggle_slide, "posts") - assert_equal "Effect.toggle(\"posts\",'blind',{});", visual_effect(:toggle_blind, "posts") - assert_equal "Effect.toggle(\"posts\",'appear',{});", visual_effect("toggle_appear", "posts") - assert_equal "Effect.toggle(\"posts\",'slide',{});", visual_effect("toggle_slide", "posts") - assert_equal "Effect.toggle(\"posts\",'blind',{});", visual_effect("toggle_blind", "posts") - end - - - def test_sortable_element - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}})\n//]]>\n</script>), - sortable_element("mylist", :url => { :action => "order" }) - assert_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {constraint:'horizontal', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}, tag:'div'})\n//]]>\n</script>), - sortable_element("mylist", :tag => "div", :constraint => "horizontal", :url => { :action => "order" }) - assert_dom_equal %|<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {constraint:'horizontal', containment:['list1','list2'], onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}})\n//]]>\n</script>|, - sortable_element("mylist", :containment => ['list1','list2'], :constraint => "horizontal", :url => { :action => "order" }) - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {constraint:'horizontal', containment:'list1', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}})\n//]]>\n</script>), - sortable_element("mylist", :containment => 'list1', :constraint => "horizontal", :url => { :action => "order" }) - end - - def test_draggable_element - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Draggable(\"product_13\", {})\n//]]>\n</script>), - draggable_element("product_13") - assert_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Draggable(\"product_13\", {revert:true})\n//]]>\n</script>), - draggable_element("product_13", :revert => true) - end - - def test_drop_receiving_element - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {onDrop:function(element){new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1") - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:'products', onDrop:function(element){new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1", :accept => 'products') - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:'products', onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1", :accept => 'products', :update => 'infobox') - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:['tshirts','mugs'], onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1", :accept => ['tshirts','mugs'], :update => 'infobox') - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add("droptarget1", {hoverclass:'dropready', onDrop:function(element){if (confirm('Are you sure?')) { new Ajax.Request('http://www.example.com/update_drop', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}})\n//]]>\n</script>), - drop_receiving_element('droptarget1', :hoverclass=>'dropready', :url=>{:action=>'update_drop'}, :confirm => 'Are you sure?') - - end - def protect_against_forgery? - false - end -end diff --git a/vendor/rails/actionpack/test/template/tag_helper_test.rb b/vendor/rails/actionpack/test/template/tag_helper_test.rb deleted file mode 100644 index 2acf6af1..00000000 --- a/vendor/rails/actionpack/test/template/tag_helper_test.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'abstract_unit' - -class TagHelperTest < ActionView::TestCase - tests ActionView::Helpers::TagHelper - - def test_tag - assert_equal "<br />", tag("br") - assert_equal "<br clear=\"left\" />", tag(:br, :clear => "left") - assert_equal "<br>", tag("br", nil, true) - end - - def test_tag_options - str = tag("p", "class" => "show", :class => "elsewhere") - assert_match /class="show"/, str - assert_match /class="elsewhere"/, str - end - - def test_tag_options_rejects_nil_option - assert_equal "<p />", tag("p", :ignored => nil) - end - - def test_tag_options_accepts_false_option - assert_equal "<p value=\"false\" />", tag("p", :value => false) - end - - def test_tag_options_accepts_blank_option - assert_equal "<p included=\"\" />", tag("p", :included => '') - end - - def test_tag_options_converts_boolean_option - assert_equal '<p disabled="disabled" multiple="multiple" readonly="readonly" />', - tag("p", :disabled => true, :multiple => true, :readonly => true) - end - - def test_content_tag - assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create") - assert content_tag("a", "Create", "href" => "create").html_safe? - assert_equal content_tag("a", "Create", "href" => "create"), - content_tag("a", "Create", :href => "create") - end - - def test_content_tag_with_block_in_erb - __in_erb_template = '' - content_tag(:div) { concat "Hello world!" } - assert_dom_equal "<div>Hello world!</div>", output_buffer - end - - def test_content_tag_with_block_and_options_in_erb - __in_erb_template = '' - content_tag(:div, :class => "green") { concat "Hello world!" } - assert_dom_equal %(<div class="green">Hello world!</div>), output_buffer - end - - def test_content_tag_with_block_and_options_out_of_erb - assert_dom_equal %(<div class="green">Hello world!</div>), content_tag(:div, :class => "green") { "Hello world!" } - end - - def test_content_tag_with_block_and_options_outside_out_of_erb - assert_equal content_tag("a", "Create", :href => "create"), - content_tag("a", "href" => "create") { "Create" } - end - - def test_content_tag_nested_in_content_tag_out_of_erb - assert_equal content_tag("p", content_tag("b", "Hello")), - content_tag("p") { content_tag("b", "Hello") }, - output_buffer - end - - def test_content_tag_nested_in_content_tag_in_erb - __in_erb_template = true - content_tag("p") { concat content_tag("b", "Hello") } - assert_equal '<p><b>Hello</b></p>', output_buffer - end - - def test_cdata_section - assert_equal "<![CDATA[<hello world>]]>", cdata_section("<hello world>") - end - - def test_escape_once - assert_equal '1 &lt; 2 &amp; 3', escape_once('1 < 2 &amp; 3') - end - - def test_double_escaping_attributes - ['1&amp;2', '1 &lt; 2', '&#8220;test&#8220;'].each do |escaped| - assert_equal %(<a href="#{escaped}" />), tag('a', :href => escaped) - end - end - - def test_skip_invalid_escaped_attributes - ['&1;', '&#1dfa3;', '& #123;'].each do |escaped| - assert_equal %(<a href="#{escaped.gsub /&/, '&amp;'}" />), tag('a', :href => escaped) - end - end - - def test_disable_escaping - assert_equal '<a href="&amp;" />', tag('a', { :href => '&amp;' }, false, false) - end -end diff --git a/vendor/rails/actionpack/test/template/template_test.rb b/vendor/rails/actionpack/test/template/template_test.rb deleted file mode 100644 index 7caec7ad..00000000 --- a/vendor/rails/actionpack/test/template/template_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'abstract_unit' - -class TemplateTest < Test::Unit::TestCase - def test_template_path_parsing - with_options :base_path => nil, :name => 'abc', :locale => nil, :format => 'html', :extension => 'erb' do |t| - t.assert_parses_template_path 'abc.en.html.erb', :locale => 'en' - t.assert_parses_template_path 'abc.en.plain.html.erb', :locale => 'en', :format => 'plain.html' - t.assert_parses_template_path 'abc.html.erb' - t.assert_parses_template_path 'abc.plain.html.erb', :format => 'plain.html' - t.assert_parses_template_path 'abc.erb', :format => nil - t.assert_parses_template_path 'abc.html', :extension => nil - - t.assert_parses_template_path '_abc.html.erb', :name => '_abc' - - t.assert_parses_template_path 'test/abc.html.erb', :base_path => 'test' - t.assert_parses_template_path './test/abc.html.erb', :base_path => './test' - t.assert_parses_template_path '../test/abc.html.erb', :base_path => '../test' - - t.assert_parses_template_path 'abc', :extension => nil, :format => nil, :name => nil - t.assert_parses_template_path 'abc.xxx', :extension => nil, :format => 'xxx', :name => 'abc' - t.assert_parses_template_path 'abc.html.xxx', :extension => nil, :format => 'xxx', :name => 'abc' - end - end - - private - def assert_parses_template_path(path, parse_results) - template = ActionView::Template.new(path, '') - parse_results.each_pair do |k, v| - assert_block(%Q{Expected template to parse #{k.inspect} from "#{path}" as #{v.inspect}, but got #{template.send(k).inspect}}) { v == template.send(k) } - end - end -end diff --git a/vendor/rails/actionpack/test/template/test_test.rb b/vendor/rails/actionpack/test/template/test_test.rb deleted file mode 100644 index ccd299f4..00000000 --- a/vendor/rails/actionpack/test/template/test_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'abstract_unit' - -module PeopleHelper - def title(text) - content_tag(:h1, text) - end - - def homepage_path - people_path - end - - def homepage_url - people_url - end - - def link_to_person(person) - link_to person.name, person - end -end - -class PeopleHelperTest < ActionView::TestCase - def setup - ActionController::Routing::Routes.draw do |map| - map.people 'people', :controller => 'people', :action => 'index' - map.connect ':controller/:action/:id' - end - end - - def test_title - assert_equal "<h1>Ruby on Rails</h1>", title("Ruby on Rails") - end - - def test_homepage_path - assert_equal "/people", homepage_path - end - - def test_homepage_url - assert_equal "http://test.host/people", homepage_url - end - - def test_link_to_person - person = mock(:name => "David") - expects(:mocha_mock_path).with(person).returns("/people/1") - assert_equal '<a href="/people/1">David</a>', link_to_person(person) - end -end - -class CrazyHelperTest < ActionView::TestCase - tests PeopleHelper - - def test_helper_class_can_be_set_manually_not_just_inferred - assert_equal PeopleHelper, self.class.helper_class - end -end diff --git a/vendor/rails/actionpack/test/template/text_helper_test.rb b/vendor/rails/actionpack/test/template/text_helper_test.rb deleted file mode 100644 index 03c2611a..00000000 --- a/vendor/rails/actionpack/test/template/text_helper_test.rb +++ /dev/null @@ -1,597 +0,0 @@ -# encoding: us-ascii -require 'abstract_unit' -require 'testing_sandbox' -begin - require 'redcloth' -rescue LoadError - $stderr.puts "Skipping textilize tests. `gem install RedCloth` to enable." -end - -class TextHelperTest < ActionView::TestCase - tests ActionView::Helpers::TextHelper - include TestingSandbox - - def setup - # This simulates the fact that instance variables are reset every time - # a view is rendered. The cycle helper depends on this behavior. - @_cycles = nil if (defined? @_cycles) - end - - def test_concat - self.output_buffer = ActiveSupport::SafeBuffer.new('foo') - assert_equal 'foobar', concat('bar') - assert_equal 'foobar', output_buffer - end - - def test_simple_format - assert_equal "<p></p>", simple_format(nil) - - assert_equal "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>", simple_format("crazy\r\n cross\r platform linebreaks") - assert_equal "<p>A paragraph</p>\n\n<p>and another one!</p>", simple_format("A paragraph\n\nand another one!") - assert_equal "<p>A paragraph\n<br /> With a newline</p>", simple_format("A paragraph\n With a newline") - - text = "A\nB\nC\nD".freeze - assert_equal "<p>A\n<br />B\n<br />C\n<br />D</p>", simple_format(text) - - text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze - assert_equal "<p>A\n<br /> \n<br />B</p>\n\n<p>\t\n<br />C\n<br />D</p>", simple_format(text) - - assert_equal %q(<p class="test">This is a classy test</p>), simple_format("This is a classy test", :class => 'test') - assert_equal %Q(<p class="test">para 1</p>\n\n<p class="test">para 2</p>), simple_format("para 1\n\npara 2", :class => 'test') - end - - def test_simple_format_should_be_html_safe - assert simple_format("<b> test with html tags </b>").html_safe? - end - - def test_simple_format_should_not_escape_safe_input - assert_equal "<p><b> test with safe string </b></p>", simple_format("<b> test with safe string </b>".html_safe) - end - - def test_truncate - assert_equal "Hello World!", truncate("Hello World!", :length => 12) - assert_equal "Hello Wor...", truncate("Hello World!!", :length => 12) - end - - def test_truncate_should_use_default_length_of_30 - str = "This is a string that will go longer then the default truncate length of 30" - assert_equal str[0...27] + "...", truncate(str) - end - - def test_truncate_with_options_hash - assert_equal "This is a string that wil[...]", truncate("This is a string that will go longer then the default truncate length of 30", :omission => "[...]") - assert_equal "Hello W...", truncate("Hello World!", :length => 10) - assert_equal "Hello[...]", truncate("Hello World!", :omission => "[...]", :length => 10) - end - - if RUBY_VERSION < '1.9.0' - def test_truncate_multibyte - with_kcode 'none' do - assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", :length => 10) - end - with_kcode 'u' do - assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...", - truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244", :length => 10) - end - end - else - def test_truncate_multibyte - assert_equal "\354\225\210\353\205\225\355...", - truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", :length => 10) - - assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'), - truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8'), :length => 10) - end - end - - def test_highlighter - assert_equal( - "This is a <strong class=\"highlight\">beautiful</strong> morning", - highlight("This is a beautiful morning", "beautiful") - ) - - assert_equal( - "This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day", - highlight("This is a beautiful morning, but also a beautiful day", "beautiful") - ) - - assert_equal( - "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day", - highlight("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\1</b>') - ) - - assert_equal( - "This text is not changed because we supplied an empty phrase", - highlight("This text is not changed because we supplied an empty phrase", nil) - ) - - assert_equal ' ', highlight(' ', 'blank text is returned verbatim') - end - - def test_highlight_with_regexp - assert_equal( - "This is a <strong class=\"highlight\">beautiful!</strong> morning", - highlight("This is a beautiful! morning", "beautiful!") - ) - - assert_equal( - "This is a <strong class=\"highlight\">beautiful! morning</strong>", - highlight("This is a beautiful! morning", "beautiful! morning") - ) - - assert_equal( - "This is a <strong class=\"highlight\">beautiful? morning</strong>", - highlight("This is a beautiful? morning", "beautiful? morning") - ) - end - - def test_highlight_with_multiple_phrases_in_one_pass - assert_equal %(<em>wow</em> <em>em</em>), highlight('wow em', %w(wow em), '<em>\1</em>') - end - - def test_highlight_with_options_hash - assert_equal( - "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day", - highlight("This is a beautiful morning, but also a beautiful day", "beautiful", :highlighter => '<b>\1</b>') - ) - end - - def test_highlight_with_html - assert_equal( - "<p>This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p>This is a beautiful morning, but also a beautiful day</p>", "beautiful") - ) - assert_equal( - "<p>This is a <em><strong class=\"highlight\">beautiful</strong></em> morning, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p>This is a <em>beautiful</em> morning, but also a beautiful day</p>", "beautiful") - ) - assert_equal( - "<p>This is a <em class=\"error\"><strong class=\"highlight\">beautiful</strong></em> morning, but also a <strong class=\"highlight\">beautiful</strong> <span class=\"last\">day</span></p>", - highlight("<p>This is a <em class=\"error\">beautiful</em> morning, but also a beautiful <span class=\"last\">day</span></p>", "beautiful") - ) - assert_equal( - "<p class=\"beautiful\">This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p class=\"beautiful\">This is a beautiful morning, but also a beautiful day</p>", "beautiful") - ) - assert_equal( - "<p>This is a <strong class=\"highlight\">beautiful</strong> <a href=\"http://example.com/beautiful\#top?what=beautiful%20morning&when=now+then\">morning</a>, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p>This is a beautiful <a href=\"http://example.com/beautiful\#top?what=beautiful%20morning&when=now+then\">morning</a>, but also a beautiful day</p>", "beautiful") - ) - end - - def test_excerpt - assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", 5)) - assert_equal("This is a...", excerpt("This is a beautiful morning", "this", 5)) - assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", 5)) - assert_nil excerpt("This is a beautiful morning", "day") - end - - def test_excerpt_in_borderline_cases - assert_equal("", excerpt("", "", 0)) - assert_equal("a", excerpt("a", "a", 0)) - assert_equal("...b...", excerpt("abc", "b", 0)) - assert_equal("abc", excerpt("abc", "b", 1)) - assert_equal("abc...", excerpt("abcd", "b", 1)) - assert_equal("...abc", excerpt("zabc", "b", 1)) - assert_equal("...abc...", excerpt("zabcd", "b", 1)) - assert_equal("zabcd", excerpt("zabcd", "b", 2)) - - # excerpt strips the resulting string before ap-/prepending excerpt_string. - # whether this behavior is meaningful when excerpt_string is not to be - # appended is questionable. - assert_equal("zabcd", excerpt(" zabcd ", "b", 4)) - assert_equal("...abc...", excerpt("z abc d", "b", 1)) - end - - def test_excerpt_with_regex - assert_equal('...is a beautiful! mor...', excerpt('This is a beautiful! morning', 'beautiful', 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', 'beautiful', 5)) - end - - def test_excerpt_with_options_hash - assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", :radius => 5)) - assert_equal("[...]is a beautiful morn[...]", excerpt("This is a beautiful morning", "beautiful", :omission => "[...]",:radius => 5)) - assert_equal( - "This is the ultimate supercalifragilisticexpialidoceous very looooooooooooooooooong looooooooooooong beautiful morning with amazing sunshine and awesome tempera[...]", - excerpt("This is the ultimate supercalifragilisticexpialidoceous very looooooooooooooooooong looooooooooooong beautiful morning with amazing sunshine and awesome temperatures. So what are you gonna do about it?", "very", - :omission => "[...]") - ) - end - - if RUBY_VERSION < '1.9' - def test_excerpt_with_utf8 - with_kcode('u') do - assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8)) - end - with_kcode('none') do - assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8)) - end - end - else - def test_excerpt_with_utf8 - assert_equal("...\357\254\203ciency could not be...".force_encoding('UTF-8'), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding('UTF-8'), 'could', 8)) - assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8)) - end - end - - def test_word_wrap - assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", 15)) - end - - def test_word_wrap_with_extra_newlines - assert_equal("my very very\nvery long\nstring\n\nwith another\nline", word_wrap("my very very very long string\n\nwith another line", 15)) - end - - def test_word_wrap_with_options_hash - assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", :line_width => 15)) - end - - def test_pluralization - assert_equal("1 count", pluralize(1, "count")) - assert_equal("2 counts", pluralize(2, "count")) - assert_equal("1 count", pluralize('1', "count")) - assert_equal("2 counts", pluralize('2', "count")) - assert_equal("1,066 counts", pluralize('1,066', "count")) - assert_equal("1.25 counts", pluralize('1.25', "count")) - assert_equal("1.0 count", pluralize('1.0', "count")) - assert_equal("1.00 count", pluralize('1.00', "count")) - assert_equal("2 counters", pluralize(2, "count", "counters")) - assert_equal("0 counters", pluralize(nil, "count", "counters")) - assert_equal("2 people", pluralize(2, "person")) - assert_equal("10 buffaloes", pluralize(10, "buffalo")) - assert_equal("1 berry", pluralize(1, "berry")) - assert_equal("12 berries", pluralize(12, "berry")) - end - - def test_auto_link_parsing - urls = %w( - http://www.rubyonrails.com - http://www.rubyonrails.com:80 - http://www.rubyonrails.com/~minam - https://www.rubyonrails.com/~minam - http://www.rubyonrails.com/~minam/url%20with%20spaces - http://www.rubyonrails.com/foo.cgi?something=here - http://www.rubyonrails.com/foo.cgi?something=here&and=here - http://www.rubyonrails.com/contact;new - http://www.rubyonrails.com/contact;new%20with%20spaces - http://www.rubyonrails.com/contact;new?with=query&string=params - http://www.rubyonrails.com/~minam/contact;new?with=query&string=params - http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007 - http://www.mail-archive.com/rails@lists.rubyonrails.org/ - http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1 - http://en.wikipedia.org/wiki/Texas_hold'em - https://www.google.com/doku.php?id=gps:resource:scs:start - http://connect.oraclecorp.com/search?search[q]=green+france&search[type]=Group - http://of.openfoundry.org/projects/492/download#4th.Release.3 - http://maps.google.co.uk/maps?f=q&q=the+london+eye&ie=UTF8&ll=51.503373,-0.11939&spn=0.007052,0.012767&z=16&iwloc=A - ) - - urls.each do |url| - assert_equal generate_result(url), auto_link(url) - end - end - - def generate_result(link_text, href = nil) - href ||= link_text - %{<a href="#{CGI::escapeHTML href}">#{CGI::escapeHTML link_text}</a>} - end - - def test_auto_linking - email_raw = 'david@loudthinking.com' - email_result = %{<a href="mailto:#{email_raw}">#{email_raw}</a>} - link_raw = 'http://www.rubyonrails.com' - link_result = generate_result(link_raw) - link_result_with_options = %{<a href="#{link_raw}" target="_blank">#{link_raw}</a>} - - assert_equal '', auto_link(nil) - assert_equal '', auto_link('') - assert_equal "#{link_result} #{link_result} #{link_result}", auto_link("#{link_raw} #{link_raw} #{link_raw}") - - assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses) - assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls) - assert_equal %(Go to #{link_raw}), auto_link("Go to #{link_raw}", :email_addresses) - assert_equal %(Go to #{link_result} and say hello to #{email_result}), auto_link("Go to #{link_raw} and say hello to #{email_raw}") - assert_equal %(<p>Link #{link_result}</p>), auto_link("<p>Link #{link_raw}</p>") - assert_equal %(<p>#{link_result} Link</p>), auto_link("<p>#{link_raw} Link</p>") - assert_equal %(<p>Link #{link_result_with_options}</p>), auto_link("<p>Link #{link_raw}</p>", :all, {:target => "_blank"}) - assert_equal %(Go to #{link_result}.), auto_link(%(Go to #{link_raw}.)) - assert_equal %(<p>Go to #{link_result}, then say hello to #{email_result}.</p>), auto_link(%(<p>Go to #{link_raw}, then say hello to #{email_raw}.</p>)) - assert_equal %(#{link_result} #{link_result}), auto_link(%(#{link_result} #{link_raw})) - - email2_raw = '+david@loudthinking.com' - email2_result = %{<a href="mailto:#{email2_raw}">#{email2_raw}</a>} - assert_equal email2_result, auto_link(email2_raw) - - email3_raw = '+david@loudthinking.com' - email3_result = %{<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;+%64%61%76%69%64@%6c%6f%75%64%74%68%69%6e%6b%69%6e%67.%63%6f%6d">#{email3_raw}</a>} - assert_equal email3_result, auto_link(email3_raw, :all, :encode => :hex) - assert_equal email3_result, auto_link(email3_raw, :email_addresses, :encode => :hex) - - link2_raw = 'www.rubyonrails.com' - link2_result = generate_result(link2_raw, "http://#{link2_raw}") - assert_equal %(Go to #{link2_result}), auto_link("Go to #{link2_raw}", :urls) - assert_equal %(Go to #{link2_raw}), auto_link("Go to #{link2_raw}", :email_addresses) - assert_equal %(<p>Link #{link2_result}</p>), auto_link("<p>Link #{link2_raw}</p>") - assert_equal %(<p>#{link2_result} Link</p>), auto_link("<p>#{link2_raw} Link</p>") - assert_equal %(Go to #{link2_result}.), auto_link(%(Go to #{link2_raw}.)) - assert_equal %(<p>Say hello to #{email_result}, then go to #{link2_result}.</p>), auto_link(%(<p>Say hello to #{email_raw}, then go to #{link2_raw}.</p>)) - - link3_raw = 'http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281' - link3_result = generate_result(link3_raw) - assert_equal %(Go to #{link3_result}), auto_link("Go to #{link3_raw}", :urls) - assert_equal %(Go to #{link3_raw}), auto_link("Go to #{link3_raw}", :email_addresses) - assert_equal %(<p>Link #{link3_result}</p>), auto_link("<p>Link #{link3_raw}</p>") - assert_equal %(<p>#{link3_result} Link</p>), auto_link("<p>#{link3_raw} Link</p>") - assert_equal %(Go to #{link3_result}.), auto_link(%(Go to #{link3_raw}.)) - assert_equal %(<p>Go to #{link3_result}. Seriously, #{link3_result}? I think I'll say hello to #{email_result}. Instead.</p>), - auto_link(%(<p>Go to #{link3_raw}. Seriously, #{link3_raw}? I think I'll say hello to #{email_raw}. Instead.</p>)) - - link4_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor123' - link4_result = generate_result(link4_raw) - assert_equal %(<p>Link #{link4_result}</p>), auto_link("<p>Link #{link4_raw}</p>") - assert_equal %(<p>#{link4_result} Link</p>), auto_link("<p>#{link4_raw} Link</p>") - - link5_raw = 'http://foo.example.com:3000/controller/action' - link5_result = generate_result(link5_raw) - assert_equal %(<p>#{link5_result} Link</p>), auto_link("<p>#{link5_raw} Link</p>") - - link6_raw = 'http://foo.example.com:3000/controller/action+pack' - link6_result = generate_result(link6_raw) - assert_equal %(<p>#{link6_result} Link</p>), auto_link("<p>#{link6_raw} Link</p>") - - link7_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123' - link7_result = generate_result(link7_raw) - assert_equal %(<p>#{link7_result} Link</p>), auto_link("<p>#{link7_raw} Link</p>") - - link8_raw = 'http://foo.example.com:3000/controller/action.html' - link8_result = generate_result(link8_raw) - assert_equal %(Go to #{link8_result}), auto_link("Go to #{link8_raw}", :urls) - assert_equal %(Go to #{link8_raw}), auto_link("Go to #{link8_raw}", :email_addresses) - assert_equal %(<p>Link #{link8_result}</p>), auto_link("<p>Link #{link8_raw}</p>") - assert_equal %(<p>#{link8_result} Link</p>), auto_link("<p>#{link8_raw} Link</p>") - assert_equal %(Go to #{link8_result}.), auto_link(%(Go to #{link8_raw}.)) - assert_equal %(<p>Go to #{link8_result}. Seriously, #{link8_result}? I think I'll say hello to #{email_result}. Instead.</p>), - auto_link(%(<p>Go to #{link8_raw}. Seriously, #{link8_raw}? I think I'll say hello to #{email_raw}. Instead.</p>)) - - link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html' - link9_result = generate_result(link9_raw) - assert_equal %(Go to #{link9_result}), auto_link("Go to #{link9_raw}", :urls) - assert_equal %(Go to #{link9_raw}), auto_link("Go to #{link9_raw}", :email_addresses) - assert_equal %(<p>Link #{link9_result}</p>), auto_link("<p>Link #{link9_raw}</p>") - assert_equal %(<p>#{link9_result} Link</p>), auto_link("<p>#{link9_raw} Link</p>") - assert_equal %(Go to #{link9_result}.), auto_link(%(Go to #{link9_raw}.)) - assert_equal %(<p>Go to #{link9_result}. Seriously, #{link9_result}? I think I'll say hello to #{email_result}. Instead.</p>), - auto_link(%(<p>Go to #{link9_raw}. Seriously, #{link9_raw}? I think I'll say hello to #{email_raw}. Instead.</p>)) - - link10_raw = 'http://www.mail-archive.com/ruby-talk@ruby-lang.org/' - link10_result = generate_result(link10_raw) - assert_equal %(<p>#{link10_result} Link</p>), auto_link("<p>#{link10_raw} Link</p>") - end - - def test_auto_link_other_protocols - ftp_raw = 'ftp://example.com/file.txt' - assert_equal %(Download #{generate_result(ftp_raw)}), auto_link("Download #{ftp_raw}") - - file_scheme = 'file:///home/username/RomeoAndJuliet.pdf' - z39_scheme = 'z39.50r://host:696/db' - chrome_scheme = 'chrome://package/section/path' - view_source = 'view-source:http://en.wikipedia.org/wiki/URI_scheme' - assert_equal generate_result(z39_scheme), auto_link(z39_scheme) - assert_equal generate_result(chrome_scheme), auto_link(chrome_scheme) - assert_equal generate_result(view_source), auto_link(view_source) - end - - def test_auto_link_already_linked - linked1 = generate_result('Ruby On Rails', 'http://www.rubyonrails.com') - linked2 = %('<a href="http://www.example.com">www.example.com</a>') - linked3 = %('<a href="http://www.example.com" rel="nofollow">www.example.com</a>') - linked4 = %('<a href="http://www.example.com"><b>www.example.com</b></a>') - linked5 = %('<a href="#close">close</a> <a href="http://www.example.com"><b>www.example.com</b></a>') - assert_equal linked1, auto_link(linked1) - assert_equal linked2, auto_link(linked2) - assert_equal linked3, auto_link(linked3) - assert_equal linked4, auto_link(linked4) - assert_equal linked5, auto_link(linked5) - - linked_email = %Q(<a href="mailto:david@loudthinking.com">Mail me</a>) - assert_equal linked_email, auto_link(linked_email) - end - - def test_auto_link_within_tags - link_raw = 'http://www.rubyonrails.org/images/rails.png' - link_result = %Q(<img src="#{link_raw}" />) - assert_equal link_result, auto_link(link_result) - end - - def test_auto_link_with_brackets - link1_raw = 'http://en.wikipedia.org/wiki/Sprite_(computer_graphics)' - link1_result = generate_result(link1_raw) - assert_equal link1_result, auto_link(link1_raw) - assert_equal "(link: #{link1_result})", auto_link("(link: #{link1_raw})") - - link2_raw = 'http://en.wikipedia.org/wiki/Sprite_[computer_graphics]' - link2_result = generate_result(link2_raw) - assert_equal link2_result, auto_link(link2_raw) - assert_equal "[link: #{link2_result}]", auto_link("[link: #{link2_raw}]") - - link3_raw = 'http://en.wikipedia.org/wiki/Sprite_{computer_graphics}' - link3_result = generate_result(link3_raw) - assert_equal link3_result, auto_link(link3_raw) - assert_equal "{link: #{link3_result}}", auto_link("{link: #{link3_raw}}") - end - - def test_auto_link_at_eol - url1 = "http://api.rubyonrails.com/Foo.html" - url2 = "http://www.ruby-doc.org/core/Bar.html" - - assert_equal %(<p><a href="#{url1}">#{url1}</a><br /><a href="#{url2}">#{url2}</a><br /></p>), auto_link("<p>#{url1}<br />#{url2}<br /></p>") - end - - def test_auto_link_with_block - url = "http://api.rubyonrails.com/Foo.html" - email = "fantabulous@shiznadel.ic" - - assert_equal %(<p><a href="#{url}">#{url[0...7]}...</a><br /><a href="mailto:#{email}">#{email[0...7]}...</a><br /></p>), auto_link("<p>#{url}<br />#{email}<br /></p>") { |url| truncate(url, :length => 10) } - end - - def test_auto_link_with_block_with_html - pic = "http://example.com/pic.png" - url = "http://example.com/album?a&b=c" - - assert_equal %(My pic: <a href="#{pic}"><img src="#{pic}" width="160px"></a> -- full album here #{generate_result(url)}), auto_link("My pic: #{pic} -- full album here #{url}") { |link| - if link =~ /\.(jpg|gif|png|bmp|tif)$/i - raw %(<img src="#{link}" width="160px">) - else - link - end - } - end - - def test_auto_link_with_options_hash - assert_dom_equal 'Welcome to my new blog at <a href="http://www.myblog.com/" class="menu" target="_blank">http://www.myblog.com/</a>. Please e-mail me at <a href="mailto:me@email.com" class="menu" target="_blank">me@email.com</a>.', - auto_link("Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com.", - :link => :all, :html => { :class => "menu", :target => "_blank" }) - end - - def test_auto_link_with_multiple_trailing_punctuations - url = "http://youtube.com" - url_result = generate_result(url) - assert_equal url_result, auto_link(url) - assert_equal "(link: #{url_result}).", auto_link("(link: #{url}).") - end - - def test_cycle_class - value = Cycle.new("one", 2, "3") - assert_equal("one", value.to_s) - assert_equal("2", value.to_s) - assert_equal("3", value.to_s) - assert_equal("one", value.to_s) - value.reset - assert_equal("one", value.to_s) - assert_equal("2", value.to_s) - assert_equal("3", value.to_s) - end - - def test_cycle_class_with_no_arguments - assert_raise(ArgumentError) { value = Cycle.new() } - end - - def test_cycle - assert_equal("one", cycle("one", 2, "3")) - assert_equal("2", cycle("one", 2, "3")) - assert_equal("3", cycle("one", 2, "3")) - assert_equal("one", cycle("one", 2, "3")) - assert_equal("2", cycle("one", 2, "3")) - assert_equal("3", cycle("one", 2, "3")) - end - - def test_cycle_with_no_arguments - assert_raise(ArgumentError) { value = cycle() } - end - - def test_cycle_resets_with_new_values - assert_equal("even", cycle("even", "odd")) - assert_equal("odd", cycle("even", "odd")) - assert_equal("even", cycle("even", "odd")) - assert_equal("1", cycle(1, 2, 3)) - assert_equal("2", cycle(1, 2, 3)) - assert_equal("3", cycle(1, 2, 3)) - assert_equal("1", cycle(1, 2, 3)) - end - - def test_named_cycles - assert_equal("1", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - assert_equal("2", cycle(1, 2, 3, :name => "numbers")) - assert_equal("blue", cycle("red", "blue", :name => "colors")) - assert_equal("3", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - end - - def test_current_cycle_with_default_name - cycle("even","odd") - assert_equal "even", current_cycle - cycle("even","odd") - assert_equal "odd", current_cycle - cycle("even","odd") - assert_equal "even", current_cycle - end - - def test_current_cycle_with_named_cycles - cycle("red", "blue", :name => "colors") - assert_equal "red", current_cycle("colors") - cycle("red", "blue", :name => "colors") - assert_equal "blue", current_cycle("colors") - cycle("red", "blue", :name => "colors") - assert_equal "red", current_cycle("colors") - end - - def test_current_cycle_safe_call - assert_nothing_raised { current_cycle } - assert_nothing_raised { current_cycle("colors") } - end - - def test_current_cycle_with_more_than_two_names - cycle(1,2,3) - assert_equal "1", current_cycle - cycle(1,2,3) - assert_equal "2", current_cycle - cycle(1,2,3) - assert_equal "3", current_cycle - cycle(1,2,3) - assert_equal "1", current_cycle - end - - def test_default_named_cycle - assert_equal("1", cycle(1, 2, 3)) - assert_equal("2", cycle(1, 2, 3, :name => "default")) - assert_equal("3", cycle(1, 2, 3)) - end - - def test_reset_cycle - assert_equal("1", cycle(1, 2, 3)) - assert_equal("2", cycle(1, 2, 3)) - reset_cycle - assert_equal("1", cycle(1, 2, 3)) - end - - def test_reset_unknown_cycle - reset_cycle("colors") - end - - def test_recet_named_cycle - assert_equal("1", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - reset_cycle("numbers") - assert_equal("1", cycle(1, 2, 3, :name => "numbers")) - assert_equal("blue", cycle("red", "blue", :name => "colors")) - assert_equal("2", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - end - - def test_cycle_no_instance_variable_clashes - @cycles = %w{Specialized Fuji Giant} - assert_equal("red", cycle("red", "blue")) - assert_equal("blue", cycle("red", "blue")) - assert_equal("red", cycle("red", "blue")) - assert_equal(%w{Specialized Fuji Giant}, @cycles) - end - - if defined? RedCloth - def test_textilize - assert_equal("<p><strong>This is Textile!</strong> Rejoice!</p>", textilize("*This is Textile!* Rejoice!")) - end - - def test_textilize_with_blank - assert_equal("", textilize("")) - end - - def test_textilize_with_options - assert_equal("<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>", textilize("This is worded <strong>strongly</strong>", :filter_html)) - end - - def test_textilize_with_hard_breaks - assert_equal("<p>This is one scary world.<br />\n True.</p>", textilize("This is one scary world.\n True.")) - end - end -end diff --git a/vendor/rails/actionpack/test/template/translation_helper_test.rb b/vendor/rails/actionpack/test/template/translation_helper_test.rb deleted file mode 100644 index 6555eaa3..00000000 --- a/vendor/rails/actionpack/test/template/translation_helper_test.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'abstract_unit' - -class TranslationHelperTest < ActiveSupport::TestCase - include ActionView::Helpers::TagHelper - include ActionView::Helpers::TranslationHelper - - attr_reader :request - def setup - end - - def test_delegates_to_i18n_setting_the_raise_option - I18n.expects(:translate).with(['foo'], :locale => 'en', :raise => true).returns([""]) - translate :foo, :locale => 'en' - end - - def test_returns_missing_translation_message_wrapped_into_span - expected = '<span class="translation_missing">en, foo</span>' - assert_equal expected, translate(:foo) - end - - def test_translation_returning_an_array - I18n.expects(:translate).with(["foo"], :raise => true).returns(["foo", "bar"]) - assert_equal ["foo", "bar"], translate(:foo) - end - - def test_translation_of_an_array - assert_deprecated do - I18n.expects(:translate).with(["foo", "bar"], :raise => true).returns(["foo", "bar"]) - assert_equal ["foo", "bar"], translate(["foo", "bar"]) - end - end - - def test_translation_of_an_array_returning_an_array - assert_deprecated do - I18n.expects(:translate).with(["foo", "bar"], :raise => true).returns(["foo", ["bar", "baz"]]) - assert_equal ["foo", ["bar", "baz"]], translate(["foo", "bar"]) - end - end - - def test_translation_of_an_array_with_html - assert_deprecated do - translate_expected = ['<a href="#">foo</a>', '<a href="#">bar</a>', '<a href="#">baz</a>'] - I18n.expects(:translate).with(["foo", "bar", "baz_html"], :raise => true).returns(translate_expected) - @view = ActionView::Base.new(ActionController::Base.view_paths, {}) - expected = '<a href="#">foo</a>, <a href="#">bar</a>, <a href="#">baz</a>' - assert_equal expected, @view.render(:file => "test/array_translation") - end - end - - def test_delegates_localize_to_i18n - @time = Time.utc(2008, 7, 8, 12, 18, 38) - I18n.expects(:localize).with(@time) - localize @time - end - - def test_scoping_by_partial - I18n.expects(:translate).with(["test.translation.helper"], :raise => true).returns(["helper"]) - @view = ActionView::Base.new(ActionController::Base.view_paths, {}) - assert_equal "helper", @view.render(:file => "test/translation") - end - - def test_scoping_by_partial_of_an_array - assert_deprecated do - I18n.expects(:translate).with(["test.scoped_array_translation.foo", "test.scoped_array_translation.bar"], :raise => true).returns(["foo", "bar"]) - @view = ActionView::Base.new(ActionController::Base.view_paths, {}) - assert_equal "foo, bar", @view.render(:file => "test/scoped_array_translation") - end - end - - def test_translate_works_with_symbols - I18n.expects(:translate).with(["hello"], :raise => true).returns(["Hello World"]) - assert_equal "Hello World", translate(:hello) - end - - - def test_translate_does_not_mark_plain_text_as_safe_html - I18n.expects(:translate).with(["hello"], :raise => true).returns(["Hello World"]) - assert_equal false, translate("hello").html_safe? - end - - def test_translate_marks_translations_named_html_as_safe_html - I18n.expects(:translate).with(["html"], :raise => true).returns(["<a>Hello World</a>"]) - assert translate("html").html_safe? - end - - def test_translate_marks_translations_with_a_html_suffix_as_safe_html - I18n.expects(:translate).with(["hello_html"], :raise => true).returns(["<a>Hello World</a>"]) - assert translate("hello_html").html_safe? - end - - def test_translation_returning_an_array_ignores_html_suffix - I18n.expects(:translate).with(["foo_html"], :raise => true).returns(["foo", "bar"]) - assert_equal ["foo", "bar"], translate(:foo_html) - end -end diff --git a/vendor/rails/actionpack/test/template/url_helper_test.rb b/vendor/rails/actionpack/test/template/url_helper_test.rb deleted file mode 100644 index 480624f4..00000000 --- a/vendor/rails/actionpack/test/template/url_helper_test.rb +++ /dev/null @@ -1,641 +0,0 @@ -# encoding: utf-8 -require 'abstract_unit' - -RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env) - -class UrlHelperTest < ActionView::TestCase - tests ActionView::Helpers::UrlHelper - - def setup - @controller = Class.new do - attr_accessor :url, :request - def url_for(options) - url - end - end - @controller = @controller.new - @controller.url = "http://www.example.com" - end - - def test_url_for_escapes_urls - @controller.url = "http://www.example.com?a=b&c=d" - assert_equal "http://www.example.com?a=b&amp;c=d", url_for(:a => 'b', :c => 'd') - assert_equal "http://www.example.com?a=b&amp;c=d", url_for(:a => 'b', :c => 'd', :escape => true) - assert_equal "http://www.example.com?a=b&c=d", url_for(:a => 'b', :c => 'd', :escape => false) - end - - def test_url_for_escapes_url_once - @controller.url = "http://www.example.com?a=b&amp;c=d" - assert_equal "http://www.example.com?a=b&amp;c=d", url_for("http://www.example.com?a=b&amp;c=d") - end - - def test_url_for_with_back - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) - assert_equal 'http://www.example.com/referer', url_for(:back) - end - - def test_url_for_with_back_and_no_referer - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) - assert_equal 'javascript:history.back()', url_for(:back) - end - - # todo: missing test cases - def test_button_to_with_straight_url - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com") - end - - def test_button_to_with_query - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com/q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com/q1=v1&q2=v2") - end - - def test_button_to_with_escaped_query - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com/q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com/q1=v1&amp;q2=v2") - end - - def test_button_to_with_query_and_no_name - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com?q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"http://www.example.com?q1=v1&amp;q2=v2\" /></div></form>", button_to(nil, "http://www.example.com?q1=v1&q2=v2") - end - - def test_button_to_with_javascript_confirm - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input onclick=\"return confirm('Are you sure?');\" type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :confirm => "Are you sure?") - ) - end - - def test_button_to_enabled_disabled - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :disabled => false) - ) - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input disabled=\"disabled\" type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :disabled => true) - ) - end - - def test_button_to_with_method_delete - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"hidden\" name=\"_method\" value=\"delete\" /><input type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :method => :delete) - ) - end - - def test_button_to_with_method_get - assert_dom_equal( - "<form method=\"get\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :method => :get) - ) - end - - def test_button_to_returns_an_html_safe_string - assert button_to("Hello", "http://www.example.com").html_safe? - end - - def test_link_tag_with_straight_url - assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com") - end - - def test_link_tag_without_host_option - ActionController::Base.class_eval { attr_accessor :url } - url = {:controller => 'weblog', :action => 'show'} - @controller = ActionController::Base.new - @controller.request = ActionController::TestRequest.new - @controller.url = ActionController::UrlRewriter.new(@controller.request, url) - assert_dom_equal(%q{<a href="/weblog/show">Test Link</a>}, link_to('Test Link', url)) - end - - def test_link_tag_with_host_option - ActionController::Base.class_eval { attr_accessor :url } - url = {:controller => 'weblog', :action => 'show', :host => 'www.example.com'} - @controller = ActionController::Base.new - @controller.request = ActionController::TestRequest.new - @controller.url = ActionController::UrlRewriter.new(@controller.request, url) - assert_dom_equal(%q{<a href="http://www.example.com/weblog/show">Test Link</a>}, link_to('Test Link', url)) - end - - def test_link_tag_with_query - assert_dom_equal "<a href=\"http://www.example.com?q1=v1&amp;q2=v2\">Hello</a>", link_to("Hello", "http://www.example.com?q1=v1&amp;q2=v2") - end - - def test_link_tag_with_query_and_no_name - assert_dom_equal "<a href=\"http://www.example.com?q1=v1&amp;q2=v2\">http://www.example.com?q1=v1&amp;q2=v2</a>", link_to(nil, "http://www.example.com?q1=v1&amp;q2=v2") - end - - def test_link_tag_with_back - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) - assert_dom_equal "<a href=\"http://www.example.com/referer\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_back_and_no_referer - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) - assert_dom_equal "<a href=\"javascript:history.back()\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_back - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) - assert_dom_equal "<a href=\"http://www.example.com/referer\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_back_and_no_referer - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) - assert_dom_equal "<a href=\"javascript:history.back()\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_img - assert_dom_equal "<a href=\"http://www.example.com\"><img src='/favicon.jpg' /></a>", link_to("<img src='/favicon.jpg' />", "http://www.example.com") - end - - def test_link_with_nil_html_options - assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil) - end - - def test_link_tag_with_custom_onclick - assert_dom_equal "<a href=\"http://www.example.com\" onclick=\"alert('yay!')\">Hello</a>", link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')") - end - - def test_link_tag_with_javascript_confirm - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>", - link_to("Hello", "http://www.example.com", :confirm => "Are you sure?") - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure, can you?');\">Hello</a>", - link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure, can you?") - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure,\\n can you?');\">Hello</a>", - link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure,\n can you?") - ) - end - - def test_link_tag_with_popup - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :popup => true) - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :popup => 'true') - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"window.open(this.href,'window_name','width=300,height=300');return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :popup => ['window_name', 'width=300,height=300']) - ) - end - - def test_link_tag_with_popup_and_javascript_confirm - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Fo\\' sho\\'?')) { window.open(this.href); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", { :popup => true, :confirm => "Fo' sho'?" }) - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { window.open(this.href,'window_name','width=300,height=300'); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", { :popup => ['window_name', 'width=300,height=300'], :confirm => "Are you serious?" }) - ) - end - - def test_link_tag_using_post_javascript - assert_dom_equal( - "<a href='http://www.example.com' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :method => :post) - ) - end - - def test_link_tag_using_delete_javascript - assert_dom_equal( - "<a href='http://www.example.com' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();return false;\">Destroy</a>", - link_to("Destroy", "http://www.example.com", :method => :delete) - ) - end - - def test_link_tag_using_delete_javascript_and_href - assert_dom_equal( - "<a href='\#' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = 'http://www.example.com';var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();return false;\">Destroy</a>", - link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#') - ) - end - - def test_link_tag_using_post_javascript_and_confirm - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit(); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :method => :post, :confirm => "Are you serious?") - ) - end - - def test_link_tag_using_delete_javascript_and_href_and_confirm - assert_dom_equal( - "<a href='\#' onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = 'http://www.example.com';var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;\">Destroy</a>", - link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#', :confirm => "Are you serious?"), - "When specifying url, form should be generated with it, but not this.href" - ) - end - - def test_link_tag_using_post_javascript_and_popup - assert_raise(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") } - end - - def test_link_tag_using_block_in_erb - __in_erb_template = '' - - link_to("http://example.com") { concat("Example site") } - - assert_equal '<a href="http://example.com">Example site</a>', output_buffer - end - - def test_link_to_unless - assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog") - assert_dom_equal "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog") - assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) - assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name, options, html_options| - "<strong>#{name}</strong>" - } - assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name| - "<strong>#{name}</strong>" - } - assert_equal "test", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { - "test" - } - end - - def test_link_to_if - assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog") - assert_dom_equal "<a href=\"http://www.example.com\">Listing</a>", link_to_if(true, "Listing", :action => "list", :controller => "weblog") - assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog", :id => 1) - end - - def test_current_page_with_simple_url - @controller.request = RequestMock.new("http://www.example.com/weblog/show") - @controller.url = "http://www.example.com/weblog/show" - assert current_page?({ :action => "show", :controller => "weblog" }) - assert current_page?("http://www.example.com/weblog/show") - end - - def test_current_page_ignoring_params - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=1" - assert current_page?({ :action => "show", :controller => "weblog" }) - assert current_page?("http://www.example.com/weblog/show") - end - - def test_current_page_with_params_that_match - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=1" - assert current_page?({ :action => "show", :controller => "weblog", :order => "desc", :page => "1" }) - assert current_page?("http://www.example.com/weblog/show?order=desc&amp;page=1") - end - - def test_link_unless_current - @controller.request = RequestMock.new("http://www.example.com/weblog/show") - @controller.url = "http://www.example.com/weblog/show" - assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc") - @controller.url = "http://www.example.com/weblog/show" - assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=1" - assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog", :order=>'desc', :page=>'1' }) - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=desc&amp;page=1") - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=desc&page=1") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc") - @controller.url = "http://www.example.com/weblog/show?order=asc" - assert_equal "<a href=\"http://www.example.com/weblog/show?order=asc\">Showing</a>", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "<a href=\"http://www.example.com/weblog/show?order=asc\">Showing</a>", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=asc") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=2" - assert_equal "<a href=\"http://www.example.com/weblog/show?order=desc&amp;page=2\">Showing</a>", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "<a href=\"http://www.example.com/weblog/show?order=desc&amp;page=2\">Showing</a>", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=desc&page=2") - - - @controller.request = RequestMock.new("http://www.example.com/weblog/show") - @controller.url = "http://www.example.com/weblog/list" - assert_equal "<a href=\"http://www.example.com/weblog/list\">Listing</a>", - link_to_unless_current("Listing", :action => "list", :controller => "weblog") - assert_equal "<a href=\"http://www.example.com/weblog/list\">Listing</a>", - link_to_unless_current("Listing", "http://www.example.com/weblog/list") - end - - def test_mail_to - assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com") - assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson") - assert_dom_equal( - "<a class=\"admin\" href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", - mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin") - ) - assert_equal mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin"), - mail_to("david@loudthinking.com", "David Heinemeier Hansson", :class => "admin") - end - - def test_mail_to_with_javascript - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%4d%79%20%65%6d%61%69%6c%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript") - end - - def test_mail_to_with_javascript_unicode - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%75%6e%69%63%6f%64%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%5c%22%3e%c3%ba%6e%69%63%6f%64%65%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("unicode@example.com", "únicode", :encode => "javascript") - end - - def test_mail_with_options - assert_dom_equal( - %(<a href="mailto:me@example.com?cc=ccaddress%40example.com&amp;bcc=bccaddress%40example.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>), - mail_to("me@example.com", "My email", :cc => "ccaddress@example.com", :bcc => "bccaddress@example.com", :subject => "This is an example email", :body => "This is the body of the message.") - ) - end - - def test_mail_to_with_img - assert_dom_equal %(<a href="mailto:feedback@example.com"><img src="/feedback.png" /></a>), mail_to('feedback@example.com', '<img src="/feedback.png" />'.html_safe) - end - - def test_mail_to_with_hex - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex") - end - - def test_mail_to_with_replace_options - assert_dom_equal "<a href=\"mailto:wolfgang@stufenlos.net\">wolfgang(at)stufenlos(dot)net</a>", mail_to("wolfgang@stufenlos.net", nil, :replace_at => "(at)", :replace_dot => "(dot)") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#40;&#97;&#116;&#41;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#40;&#97;&#116;&#41;&#100;&#111;&#109;&#97;&#105;&#110;&#40;&#100;&#111;&#116;&#41;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)") - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%4d%79%20%65%6d%61%69%6c%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%6d%65%28%61%74%29%64%6f%6d%61%69%6e%28%64%6f%74%29%63%6f%6d%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", nil, :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") - end - - def protect_against_forgery? - false - end -end - -class UrlHelperWithControllerTest < ActionView::TestCase - class UrlHelperController < ActionController::Base - def self.controller_path; 'url_helper_with_controller' end - - def show_url_for - render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>" - end - - def show_named_route - render :inline => "<%= show_named_route_#{params[:kind]} %>" - end - - def nil_url_for - render :inline => '<%= url_for(nil) %>' - end - - def rescue_action(e) raise e end - end - - tests ActionView::Helpers::UrlHelper - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = UrlHelperController.new - end - - def test_url_for_shows_only_path - get :show_url_for - assert_equal '/url_helper_with_controller/show_url_for', @response.body - end - - def test_named_route_url_shows_host_and_path - with_url_helper_routing do - get :show_named_route, :kind => 'url' - assert_equal 'http://test.host/url_helper_with_controller/show_named_route', @response.body - end - end - - def test_named_route_path_shows_only_path - with_url_helper_routing do - get :show_named_route, :kind => 'path' - assert_equal '/url_helper_with_controller/show_named_route', @response.body - end - end - - def test_url_for_nil_returns_current_path - get :nil_url_for - assert_equal '/url_helper_with_controller/nil_url_for', @response.body - end - - def test_named_route_should_show_host_and_path_using_controller_default_url_options - class << @controller - def default_url_options(options = nil) - {:host => 'testtwo.host'} - end - end - - with_url_helper_routing do - get :show_named_route, :kind => 'url' - assert_equal 'http://testtwo.host/url_helper_with_controller/show_named_route', @response.body - end - end - - protected - def with_url_helper_routing - with_routing do |set| - set.draw do |map| - map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper_with_controller', :action => 'show_named_route' - end - yield - end - end -end - -class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase - class TasksController < ActionController::Base - def self.controller_path; 'tasks' end - - def index - render_default - end - - def show - render_default - end - - def rescue_action(e) raise e end - - protected - def render_default - render :inline => - "<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" + - "<%= link_to_unless_current(\"tasks\", tasks_url) %>" - end - end - - tests ActionView::Helpers::UrlHelper - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = TasksController.new - end - - def test_link_to_unless_current_to_current - with_restful_routing do - get :index - assert_equal "tasks\ntasks", @response.body - end - end - - def test_link_to_unless_current_shows_link - with_restful_routing do - get :show, :id => 1 - assert_equal "<a href=\"/tasks\">tasks</a>\n" + - "<a href=\"#{@request.protocol}#{@request.host_with_port}/tasks\">tasks</a>", - @response.body - end - end - - protected - def with_restful_routing - with_routing do |set| - set.draw do |map| - map.resources :tasks - end - yield - end - end -end - -class Workshop - attr_accessor :id, :new_record - - def initialize(id, new_record) - @id, @new_record = id, new_record - end - - def new_record? - @new_record - end - - def to_s - id.to_s - end -end - -class Session - attr_accessor :id, :workshop_id, :new_record - - def initialize(id, new_record) - @id, @new_record = id, new_record - end - - def new_record? - @new_record - end - - def to_s - id.to_s - end -end - -class PolymorphicControllerTest < ActionView::TestCase - class WorkshopsController < ActionController::Base - def self.controller_path; 'workshops' end - - def index - @workshop = Workshop.new(1, true) - render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" - end - - def show - @workshop = Workshop.new(params[:id], false) - render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" - end - - def rescue_action(e) raise e end - end - - class SessionsController < ActionController::Base - def self.controller_path; 'sessions' end - - def index - @workshop = Workshop.new(params[:workshop_id], false) - @session = Session.new(1, true) - render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" - end - - def show - @workshop = Workshop.new(params[:workshop_id], false) - @session = Session.new(params[:id], false) - render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" - end - - def show_workshop_of_nil_sessions - render :inline => "<%= workshop_sessions_path(nil) %>" - end - - def rescue_action(e) raise e end - end - - tests ActionView::Helpers::UrlHelper - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_new_resource - @controller = WorkshopsController.new - - with_restful_routing do - get :index - assert_equal "/workshops\n<a href=\"/workshops\">Workshop</a>", @response.body - end - end - - def test_existing_resource - @controller = WorkshopsController.new - - with_restful_routing do - get :show, :id => 1 - assert_equal "/workshops/1\n<a href=\"/workshops/1\">Workshop</a>", @response.body - end - end - - def test_new_nested_resource - @controller = SessionsController.new - - with_restful_routing do - get :index, :workshop_id => 1 - assert_equal "/workshops/1/sessions\n<a href=\"/workshops/1/sessions\">Session</a>", @response.body - end - end - - def test_existing_nested_resource - @controller = SessionsController.new - - with_restful_routing do - get :show, :workshop_id => 1, :id => 1 - assert_equal "/workshops/1/sessions/1\n<a href=\"/workshops/1/sessions/1\">Session</a>", @response.body - end - end - - def test_existing_nested_resource_with_nil_id - @controller = SessionsController.new - - with_restful_routing do - assert_raise ActionController::RoutingError do - get :show_workshop_of_nil_sessions - end - end - end - - protected - def with_restful_routing - with_routing do |set| - set.draw do |map| - map.resources :workshops do |w| - w.resources :sessions - end - map.show_workshop_of_nil_sessions 'sessions/show_workshop_of_nil_sessions', :controller => 'sessions', :action => 'show_workshop_of_nil_sessions' - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/testing_sandbox.rb b/vendor/rails/actionpack/test/testing_sandbox.rb deleted file mode 100644 index c3658510..00000000 --- a/vendor/rails/actionpack/test/testing_sandbox.rb +++ /dev/null @@ -1,15 +0,0 @@ -module TestingSandbox - # Temporarily replaces KCODE for the block - def with_kcode(kcode) - if RUBY_VERSION < '1.9' - old_kcode, $KCODE = $KCODE, kcode - begin - yield - ensure - $KCODE = old_kcode - end - else - yield - end - end -end diff --git a/vendor/rails/actionpack/test/view/test_case_test.rb b/vendor/rails/actionpack/test/view/test_case_test.rb deleted file mode 100644 index ace3ee4f..00000000 --- a/vendor/rails/actionpack/test/view/test_case_test.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'abstract_unit' - -module ActionView - class TestCase - module ATestHelper - end - - module AnotherTestHelper - def from_another_helper - 'Howdy!' - end - end - - module ASharedTestHelper - def from_shared_helper - 'Holla!' - end - end - helper ASharedTestHelper - - module SharedTests - def self.included(test_case) - test_case.class_eval do - test "helpers defined on ActionView::TestCase are available" do - assert test_case.ancestors.include?(ASharedTestHelper) - assert_equal 'Holla!', from_shared_helper - end - end - end - end - - class GeneralViewTest < ActionView::TestCase - include SharedTests - test_case = self - - test "works without testing a helper module" do - assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy')) - end - - test "can render a layout with block" do - assert_equal "Before (ChrisCruft)\n!\nAfter", - render(:layout => "test/layout_for_partial", :locals => {:name => "ChrisCruft"}) {"!"} - end - - helper AnotherTestHelper - test "additional helper classes can be specified as in a controller" do - assert test_case.ancestors.include?(AnotherTestHelper) - assert_equal 'Howdy!', from_another_helper - end - end - - class ClassMethodsTest < ActionView::TestCase - include SharedTests - test_case = self - - tests ATestHelper - test "tests the specified helper module" do - assert_equal ATestHelper, test_case.helper_class - assert test_case.ancestors.include?(ATestHelper) - end - - helper AnotherTestHelper - test "additional helper classes can be specified as in a controller" do - assert test_case.ancestors.include?(AnotherTestHelper) - assert_equal 'Howdy!', from_another_helper - - test_case.helper_class.module_eval do - def render_from_helper - from_another_helper - end - end - assert_equal 'Howdy!', render(:partial => 'test/from_helper') - end - end - - class ATestHelperTest < ActionView::TestCase - include SharedTests - test_case = self - - test "inflects the name of the helper module to test from the test case class" do - assert_equal ATestHelper, test_case.helper_class - assert test_case.ancestors.include?(ATestHelper) - end - - test "a configured test controller is available" do - assert_kind_of ActionController::Base, controller - assert_equal '', controller.controller_path - end - - test "helper class that is being tested is always included in view instance" do - self.class.helper_class.module_eval do - def render_from_helper - render :partial => 'customer', :collection => @customers - end - end - - TestController.stubs(:controller_path).returns('test') - - @customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')] - assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper') - end - - test "no additional helpers should shared across test cases" do - assert !test_case.ancestors.include?(AnotherTestHelper) - assert_raise(NoMethodError) { send :from_another_helper } - end - - test "is able to use routes" do - controller.request.assign_parameters('foo', 'index') - assert_equal '/foo', url_for - assert_equal '/bar', url_for(:controller => 'bar') - end - - test "is able to use named routes" do - with_routing do |set| - set.draw { |map| map.resources :contents } - assert_equal 'http://test.host/contents/new', new_content_url - assert_equal 'http://test.host/contents/1', content_url(:id => 1) - end - end - - test "named routes can be used from helper included in view" do - with_routing do |set| - set.draw { |map| map.resources :contents } - master_helper_module.module_eval do - def render_from_helper - new_content_url - end - end - - assert_equal 'http://test.host/contents/new', render(:partial => 'test/from_helper') - end - end - - test "is able to render partials with local variables" do - assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy')) - assert_equal 'Eloy', render(:partial => 'developers/developer', - :locals => { :developer => stub(:name => 'Eloy') }) - end - - test "is able to render partials from templates and also use instance variables" do - TestController.stubs(:controller_path).returns('test') - - @customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')] - assert_match /Hello: EloyHello: Manfred/, render(:file => 'test/list') - end - - test "is able to make methods available to the view" do - master_helper_module.module_eval do - def render_from_helper; from_test_case end - end - assert_equal 'Word!', render(:partial => 'test/from_helper') - end - - def from_test_case; 'Word!'; end - helper_method :from_test_case - end - - class AssertionsTest < ActionView::TestCase - def render_from_helper - form_tag('/foo') do - concat render(:text => '<ul><li>foo</li></ul>'.html_safe) - end - end - helper_method :render_from_helper - - test "uses the output_buffer for assert_select" do - render(:partial => 'test/from_helper') - - assert_select 'form' do - assert_select 'li', :text => 'foo' - end - end - end - end -end diff --git a/vendor/rails/activerecord/CHANGELOG b/vendor/rails/activerecord/CHANGELOG deleted file mode 100644 index a8fb4dbb..00000000 --- a/vendor/rails/activerecord/CHANGELOG +++ /dev/null @@ -1,5904 +0,0 @@ -*2.3.11 (February 9, 2011)* - -*2.3.10 (October 15, 2010)* - -* Security Release to fix CVE-2010-3933 - -*2.3.9 (September 4, 2010)* -*2.3.8 (May 24, 2010)* -*2.3.7 (May 24, 2010)* - -* Version bump. - - -*2.3.6 (May 23, 2010)* - -* Add index length support for MySQL. #1852 [Emili Parreno, Pratik Naik] - - Example: - - add_index(:accounts, :name, :name => 'by_name', :length => 10) - => CREATE INDEX by_name ON accounts(name(10)) - - add_index(:accounts, [:name, :surname], :name => 'by_name_surname', :length => {:name => 10, :surname => 15}) - => CREATE INDEX by_name_surname ON accounts(name(10), surname(15)) - -* find_or_create_by_attr(value, ...) works when attr is protected. #4457 [Santiago Pastorino, Marc-André Lafortune] - -* JSON supports a custom root option: to_json(:root => 'custom') #4515 [Jatinder Singh] - -* Destroy uses optimistic locking. If lock_version on the record you're destroying doesn't match lock_version in the database, a StaleObjectError is raised. #1966 [Curtis Hawthorne] - -* To prefix the table names of all models in a module, define self.table_name_prefix on the module. #4032 [Andrew White] - -* Association inverses for belongs_to, has_one, and has_many. Optimization to reduce database queries. #3533 [Murray Steele] - - # post.comments sets each comment's post without needing to :include - class Post < ActiveRecord::Base - has_many :comments, :inverse_of => :post - end - -* MySQL: add_ and change_column support positioning. #3286 [Ben Marini] - -* Reset your Active Record counter caches with the reset_counter_cache class method. #1211 [Mike Breen, Gabe da Silveira] - - -*2.3.5 (November 25, 2009)* - -* Minor Bug Fixes and deprecation warnings - -* 1.9 Compatibility - -* Numerous fixes to the nested attributes functionality - - -*2.3.4 (September 4, 2009)* - -* PostgreSQL: XML datatype support. #1874 [Leonardo Borges] - -* SQLite: deprecate the 'dbfile' option in favor of 'database.' #2363 [Paul Hinze, Jeremy Kemper] - - -*2.3.3 (July 12, 2009)* - -* Added :primary_key option to belongs_to associations. #765 [Szymon Nowak, Philip Hallstrom, Noel Rocha] - # employees.company_name references companies.name - Employee.belongs_to :company, :primary_key => 'name', :foreign_key => 'company_name' - -* Added :touch option to belongs_to associations that will touch the parent record when the current record is saved or destroyed [DHH] - -* Added ActiveRecord::Base#touch to update the updated_at/on attributes (or another specified timestamp) with the current time [DHH] - - -*2.3.2 [Final] (March 15, 2009)* - -* Added ActiveRecord::Base.find_each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck] - -* Added that ActiveRecord::Base.exists? can be called with no arguments #1817 [Scott Taylor] - -* Add Support for updating deeply nested models from a single form. #1202 [Eloy Duran] - - class Book < ActiveRecord::Base - has_one :author - has_many :pages - - accepts_nested_attributes_for :author, :pages - end - -* Make after_save callbacks fire only if the record was successfully saved. #1735 [Michael Lovitt] - - Previously the callbacks would fire if a before_save cancelled saving. - -* Support nested transactions using database savepoints. #383 [Jonathan Viney, Hongli Lai] - -* Added dynamic scopes ala dynamic finders #1648 [Yaroslav Markin] - -* Fixed that ActiveRecord::Base#new_record? should return false (not nil) for existing records #1219 [Yaroslav Markin] - -* I18n the word separator for error messages. Introduces the activerecord.errors.format.separator translation key. #1294 [Akira Matsuda] - -* Add :having as a key to find and the relevant associations. [Emilio Tagua] - -* Added default_scope to Base #1381 [Paweł Kondzior]. Example: - - class Person < ActiveRecord::Base - default_scope :order => 'last_name, first_name' - end - - class Company < ActiveRecord::Base - has_many :people - end - - Person.all # => Person.find(:all, :order => 'last_name, first_name') - Company.find(1).people # => Person.find(:all, :order => 'last_name, first_name', :conditions => { :company_id => 1 }) - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster] - -* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper] - -* Add Model#delete instance method, similar to Model.delete class method. #1086 [Hongli Lai (Phusion)] - -* MySQL: cope with quirky default values for not-null text columns. #1043 [Frederick Cheung] - -* Multiparameter attributes skip time zone conversion for time-only columns [#1030 state:resolved] [Geoff Buesing] - -* Base.skip_time_zone_conversion_for_attributes uses class_inheritable_accessor, so that subclasses don't overwrite Base [#346 state:resolved] [Emilio Tagua] - -* Added find_last_by dynamic finder #762 [Emilio Tagua] - -* Internal API: configurable association options and build_association method for reflections so plugins may extend and override. #985 [Hongli Lai (Phusion)] - -* Changed benchmarks to be reported in milliseconds [David Heinemeier Hansson] - -* Connection pooling. #936 [Nick Sieger] - -* Merge scoped :joins together instead of overwriting them. May expose scoping bugs in your code! #501 [Andrew White] - -* before_save, before_validation and before_destroy callbacks that return false will now ROLLBACK the transaction. Previously this would have been committed before the processing was aborted. #891 [Xavier Noria] - -* Transactional migrations for databases which support them. #834 [divoxx, Adam Wiggins, Tarmo Tänav] - -* Set config.active_record.timestamped_migrations = false to have migrations with numeric prefix instead of UTC timestamp. #446. [Andrew Stone, Nik Wakelin] - -* change_column_default preserves the not-null constraint. #617 [Tarmo Tänav] - -* Fixed that create database statements would always include "DEFAULT NULL" (Nick Sieger) [#334] - -* Add :tokenizer option to validates_length_of to specify how to split up the attribute string. #507. [David Lowenfels] Example : - - # Ensure essay contains at least 100 words. - validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %d words."), :tokenizer => lambda {|str| str.scan(/\w+/) } - -* Allow conditions on multiple tables to be specified using hash. [Pratik Naik]. Example: - - User.all :joins => :items, :conditions => { :age => 10, :items => { :color => 'black' } } - Item.first :conditions => { :items => { :color => 'red' } } - -* Always treat integer :limit as byte length. #420 [Tarmo Tänav] - -* Partial updates don't update lock_version if nothing changed. #426 [Daniel Morrison] - -* Fix column collision with named_scope and :joins. #46 [Duncan Beevers, Mark Catley] - -* db:migrate:down and :up update schema_migrations. #369 [Michael Raidel, RaceCondition] - -* PostgreSQL: support :conditions => [':foo::integer', { :foo => 1 }] without treating the ::integer typecast as a bind variable. [Tarmo Tänav] - -* MySQL: rename_column preserves column defaults. #466 [Diego Algorta] - -* Add :from option to calculations. #397 [Ben Munat] - -* Add :validate option to associations to enable/disable the automatic validation of associated models. Resolves #301. [Jan De Poorter] - -* PostgreSQL: use 'INSERT ... RETURNING id' for 8.2 and later. [Jeremy Kemper] - -* Added SQL escaping for :limit and :offset in MySQL [Jonathan Wiess] - - -*2.1.0 (May 31st, 2008)* - -* Add ActiveRecord::Base.sti_name that checks ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [Rick Olson] - -* Add first/last methods to associations/named_scope. Resolved #226. [Ryan Bates] - -* Added SQL escaping for :limit and :offset #288 [Aaron Bedra, Steven Bristol, Jonathan Wiess] - -* Added first/last methods to associations/named_scope. Resolved #226. [Ryan Bates] - -* Ensure hm:t preloading honours reflection options. Resolves #137. [Frederick Cheung] - -* Added protection against duplicate migration names (Aslak Hellesøy) [#112] - -* Base#instantiate_time_object: eliminate check for Time.zone, since we can assume this is set if time_zone_aware_attributes is set to true [Geoff Buesing] - -* Time zone aware attribute methods use Time.zone.parse instead of #to_time for String arguments, so that offset information in String is respected. Resolves #105. [Scott Fleckenstein, Geoff Buesing] - -* Added change_table for migrations (Jeff Dean) [#71]. Example: - - change_table :videos do |t| - t.timestamps # adds created_at, updated_at - t.belongs_to :goat # adds goat_id integer - t.string :name, :email, :limit => 20 # adds name and email both with a 20 char limit - t.remove :name, :email # removes the name and email columns - end - -* Fixed has_many :through .create with no parameters caused a "can't dup NilClass" error (Steven Soroka) [#85] - -* Added block-setting of attributes for Base.create like Base.new already has (Adam Meehan) [#39] - -* Fixed that pessimistic locking you reference the quoted table name (Josh Susser) [#67] - -* Fixed that change_column should be able to use :null => true on a field that formerly had false [Nate Wiger] [#26] - -* Added that the MySQL adapter should map integer to either smallint, int, or bigint depending on the :limit just like PostgreSQL [David Heinemeier Hansson] - -* Change validates_uniqueness_of :case_sensitive option default back to true (from [9160]). Love your database columns, don't LOWER them. [Rick Olson] - -* Add support for interleaving migrations by storing which migrations have run in the new schema_migrations table. Closes #11493 [Jordi Bunster] - -* ActiveRecord::Base#sum defaults to 0 if no rows are returned. Closes #11550 [Kamal Fariz Mahyuddin] - -* Ensure that respond_to? considers dynamic finder methods. Closes #11538. [James Mead] - -* Ensure that save on parent object fails for invalid has_one association. Closes #10518. [Pratik Naik] - -* Remove duplicate code from associations. [Pratik Naik] - -* Refactor HasManyThroughAssociation to inherit from HasManyAssociation. Association callbacks and <association>_ids= now work with hm:t. #11516 [Ruy Asan] - -* Ensure HABTM#create and HABTM#build do not load entire association. [Pratik Naik] - -* Improve documentation. [Xavier Noria, Jack Danger Canty, leethal] - -* Tweak ActiveRecord::Base#to_json to include a root value in the returned hash: {"post": {"title": ...}} [Rick Olson] - - Post.find(1).to_json # => {"title": ...} - config.active_record.include_root_in_json = true - Post.find(1).to_json # => {"post": {"title": ...}} - -* Add efficient #include? to AssociationCollection (for has_many/has_many :through/habtm). [stopdropandrew] - -* PostgreSQL: create_ and drop_database support. #9042 [ez, pedz, Nick Sieger] - -* Ensure that validates_uniqueness_of works with with_scope. Closes #9235. [Nik Wakelin, cavalle] - -* Partial updates include only unsaved attributes. Off by default; set YourClass.partial_updates = true to enable. [Jeremy Kemper] - -* Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing] - -* Fixed that validates_size_of :within works in associations #11295, #10019 [cavalle] - -* Track changes to unsaved attributes. [Jeremy Kemper] - -* Switched to UTC-timebased version numbers for migrations and the schema. This will as good as eliminate the problem of multiple migrations getting the same version assigned in different branches. Also added rake db:migrate:up/down to apply individual migrations that may need to be run when you merge branches #11458 [John Barnette] - -* Fixed that has_many :through would ignore the hash conditions #11447 [Emilio Tagua] - -* Fix issue where the :uniq option of a has_many :through association is ignored when find(:all) is called. Closes #9407 [cavalle] - -* Fix duplicate table alias error when including an association with a has_many :through association on the same join table. Closes #7310 [cavalle] - -* More efficient association preloading code that compacts a through_records array in a central location. Closes #11427 [Jack Danger Canty] - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Fixed that ActiveRecord#Base.find_or_create/initialize would not honor attr_protected/accessible when used with a hash #11422 [Emilio Tagua] - -* Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) #11413 [nkallen, Chris O'Sullivan] - -* Merge the has_finder gem, renamed as 'named_scope'. #11404 [nkallen] - - class Article < ActiveRecord::Base - named_scope :published, :conditions => {:published => true} - named_scope :popular, :conditions => ... - end - - Article.published.paginate(:page => 1) - Article.published.popular.count - Article.popular.find(:first) - Article.popular.find(:all, :conditions => {...}) - - See http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries - -* Add has_one :through support. #4756 [Chris O'Sullivan] - -* Migrations: create_table supports primary_key_prefix_type. #10314 [student, Chris O'Sullivan] - -* Added logging for dependency load errors with fixtures #11056 [stuthulhu] - -* Time zone aware attributes use Time#in_time_zone [Geoff Buesing] - -* Fixed that scoped joins would not always be respected #6821 [Theory/Jack Danger Canty] - -* Ensure that ActiveRecord::Calculations disambiguates field names with the table name. #11027 [cavalle] - -* Added add/remove_timestamps to the schema statements for adding the created_at/updated_at columns on existing tables #11129 [jramirez] - -* Added ActiveRecord::Base.find(:last) #11338 [Emilio Tagua] - -* test_native_types expects DateTime.local_offset instead of DateTime.now.offset; fixes test breakage due to dst transition [Geoff Buesing] - -* Add :readonly option to HasManyThrough associations. #11156 [Emilio Tagua] - -* Improve performance on :include/:conditions/:limit queries by selectively joining in the pre-query. #9560 [dasil003] - -* Perf fix: Avoid the use of named block arguments. Closes #11109 [adymo] - -* PostgreSQL: support server versions 7.4 through 8.0 and the ruby-pg driver. #11127 [jdavis] - -* Ensure association preloading doesn't break when an association returns nil. ##11145 [GMFlash] - -* Make dynamic finders respect the :include on HasManyThrough associations. #10998. [cpytel] - -* Base#instantiate_time_object only uses Time.zone when Base.time_zone_aware_attributes is true; leverages Time#time_with_datetime_fallback for readability [Geoff Buesing] - -* Refactor ConnectionAdapters::Column.new_time: leverage DateTime failover behavior of Time#time_with_datetime_fallback [Geoff Buesing] - -* Improve associations performance by using symbol callbacks instead of string callbacks. #11108 [adymo] - -* Optimise the BigDecimal conversion code. #11110 [adymo] - -* Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [Emilio Tagua] - -* Multiparameter attributes for time columns fail over to DateTime when out of range of Time [Geoff Buesing] - -* Base#instantiate_time_object uses Time.zone.local() [Geoff Buesing] - -* Add timezone-aware attribute readers and writers. #10982 [Geoff Buesing] - -* Instantiating time objects in multiparameter attributes uses Time.zone if available. #10982 [Rick Olson] - -* Add note about how ActiveRecord::Observer classes are initialized in a Rails app. #10980 [Xavier Noria] - -* MySQL: omit text/blob defaults from the schema instead of using an empty string. #10963 [mdeiters] - -* belongs_to supports :dependent => :destroy and :delete. #10592 [Jonathan Viney] - -* Introduce preload query strategy for eager :includes. #9640 [Frederick Cheung, Aliaksey Kandratsenka, codafoo] - -* Support aggregations in finder conditions. #10572 [Ryan Kinderman] - -* Organize and clean up the Active Record test suite. #10742 [John Barnette] - -* Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews] - -* Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu] - -* Fixtures: removed support for the ancient pre-YAML file format. #10736 [John Barnette] - -* More thoroughly quote table names. #10698 [dimdenis, lotswholetime, Jeremy Kemper] - -* update_all ignores scoped :order and :limit, so post.comments.update_all doesn't try to include the comment order in the update statement. #10686 [Brendan Ribera] - -* Added ActiveRecord::Base.cache_key to make it easier to cache Active Records in combination with the new ActiveSupport::Cache::* libraries [David Heinemeier Hansson] - -* Make sure CSV fixtures are compatible with ruby 1.9's new csv implementation. [JEG2] - -* Added by parameter to increment, decrement, and their bang varieties so you can do player1.increment!(:points, 5) #10542 [Sam] - -* Optimize ActiveRecord::Base#exists? to use #select_all instead of #find. Closes #10605 [jamesh, Frederick Cheung, protocool] - -* Don't unnecessarily load has_many associations in after_update callbacks. Closes #6822 [stopdropandrew, canadaduane] - -* Eager belongs_to :include infers the foreign key from the association name rather than the class name. #10517 [Jonathan Viney] - -* SQLite: fix rename_ and remove_column for columns with unique indexes. #10576 [Brandon Keepers] - -* Ruby 1.9 compatibility. #10655 [Jeremy Kemper, Dirkjan Bussink] - - -*2.0.2* (December 16th, 2007) - -* Ensure optimistic locking handles nil #lock_version values properly. Closes #10510 [Rick Olson] - -* Make the Fixtures Test::Unit enhancements more supporting for double-loaded test cases. Closes #10379 [brynary] - -* Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases). Closes #10474 [Josh Susser] - -* Ensure that the :uniq option for has_many :through associations retains the order. #10463 [remvee] - -* Base.exists? doesn't rescue exceptions to avoid hiding SQL errors. #10458 [Michael Klishin] - -* Documentation: Active Record exceptions, destroy_all and delete_all. #10444, #10447 [Michael Klishin] - - -*2.0.1* (December 7th, 2007) - -* Removed query cache rescue as it could cause code to be run twice (closes #10408) [David Heinemeier Hansson] - - -*2.0.0* (December 6th, 2007) - -* Anchor DateTimeTest to fixed DateTime instead of a variable value based on Time.now#advance#to_datetime, so that this test passes on 64-bit platforms running Ruby 1.8.6+ [Geoff Buesing] - -* Fixed that the Query Cache should just be ignored if the database is misconfigured (so that the "About your applications environment" works even before the database has been created) [David Heinemeier Hansson] - -* Fixed that the truncation of strings longer than 50 chars should use inspect -so newlines etc are escaped #10385 [Norbert Crombach] - -* Fixed that habtm associations should be able to set :select as part of their definition and have that honored [David Heinemeier Hansson] - -* Document how the :include option can be used in Calculations::calculate. Closes #7446 [adamwiggins, ultimoamore] - -* Fix typo in documentation for polymorphic associations w/STI. Closes #7461 [johnjosephbachir] - -* Reveal that the type option in migrations can be any supported column type for your database but also include caveat about agnosticism. Closes #7531 [adamwiggins, mikong] - -* More complete documentation for find_by_sql. Closes #7912 [fearoffish] - -* Added ActiveRecord::Base#becomes to turn a record into one of another class (mostly relevant for STIs) [David Heinemeier Hansson]. Example: - - render :partial => @client.becomes(Company) # renders companies/company instead of clients/client - -* Fixed that to_xml should not automatically pass :procs to associations included with :include #10162 [Cheah Chu Yeow] - -* Fix documentation typo introduced in [8250]. Closes #10339 [Henrik N] - -* Foxy fixtures: support single-table inheritance. #10234 [tom] - -* Foxy fixtures: allow mixed usage to make migration easier and more attractive. #10004 [lotswholetime] - -* Make the record_timestamps class-inheritable so it can be set per model. #10004 [tmacedo] - -* Allow validates_acceptance_of to use a real attribute instead of only virtual (so you can record that the acceptance occured) #7457 [ambethia] - -* DateTimes use Ruby's default calendar reform setting. #10201 [Geoff Buesing] - -* Dynamic finders on association collections respect association :order and :limit. #10211, #10227 [Patrick Joyce, Rick Olson, Jack Danger Canty] - -* Add 'foxy' support for fixtures of polymorphic associations. #10183 [John Barnette, David Lowenfels] - -* validates_inclusion_of and validates_exclusion_of allow formatted :message strings. #8132 [devrieda, Mike Naberezny] - -* attr_readonly behaves well with optimistic locking. #10188 [Nick Bugajski] - -* Base#to_xml supports the nil="true" attribute like Hash#to_xml. #8268 [Jonathan del Strother] - -* Change plings to the more conventional quotes in the documentation. Closes #10104 [Jack Danger Canty] - -* Fix HasManyThrough Association so it uses :conditions on the HasMany Association. Closes #9729 [Jack Danger Canty] - -* Ensure that column names are quoted. Closes #10134 [wesley.moxam] - -* Smattering of grammatical fixes to documentation. Closes #10083 [Bob Silva] - -* Enhance explanation with more examples for attr_accessible macro. Closes #8095 [fearoffish, Marcel Molina Jr.] - -* Update association/method mapping table to refected latest collection methods for has_many :through. Closes #8772 [Pratik Naik] - -* Explain semantics of having several different AR instances in a transaction block. Closes #9036 [jacobat, Marcel Molina Jr.] - -* Update Schema documentation to use updated sexy migration notation. Closes #10086 [Sam Granieri] - -* Make fixtures work with the new test subclasses. [Tarmo Tänav, Michael Koziarski] - -* Introduce finder :joins with associations. Same :include syntax but with inner rather than outer joins. #10012 [RubyRedRick] - # Find users with an avatar - User.find(:all, :joins => :avatar) - - # Find posts with a high-rated comment. - Post.find(:all, :joins => :comments, :conditions => 'comments.rating > 3') - -* Associations: speedup duplicate record check. #10011 [Pratik Naik] - -* Make sure that << works on has_many associations on unsaved records. Closes #9989 [Josh Susser] - -* Allow association redefinition in subclasses. #9346 [wildchild] - -* Fix has_many :through delete with custom foreign keys. #6466 [naffis] - -* Foxy fixtures, from rathole (http://svn.geeksomnia.com/rathole/trunk/README) - - stable, autogenerated IDs - - specify associations (belongs_to, has_one, has_many) by label, not ID - - specify HABTM associations as inline lists - - autofill timestamp columns - - support YAML defaults - - fixture label interpolation - Enabled for fixtures that correspond to a model class and don't specify a primary key value. #9981 [John Barnette] - -* Add docs explaining how to protect all attributes using attr_accessible with no arguments. Closes #9631 [boone, rmm5t] - -* Update add_index documentation to use new options api. Closes #9787 [Kamal Fariz Mahyuddin] - -* Allow find on a has_many association defined with :finder_sql to accept id arguments as strings like regular find does. Closes #9916 [krishna] - -* Use VALID_FIND_OPTIONS when resolving :find scoping rather than hard coding the list of valid find options. Closes #9443 [sur] - -* Limited eager loading no longer ignores scoped :order. Closes #9561 [Jack Danger Canty, Josh Peek] - -* Assigning an instance of a foreign class to a composed_of aggregate calls an optional conversion block. Refactor and simplify composed_of implementation. #6322 [brandon, Chris Cruft] - -* Assigning nil to a composed_of aggregate also sets its immediate value to nil. #9843 [Chris Cruft] - -* Ensure that mysql quotes table names with database names correctly. Closes #9911 [crayz] - - "foo.bar" => "`foo`.`bar`" - -* Complete the assimilation of Sexy Migrations from ErrFree [Chris Wanstrath, PJ Hyett] - http://errtheblog.com/post/2381 - -* Qualified column names work in hash conditions, like :conditions => { 'comments.created_at' => ... }. #9733 [Jack Danger Canty] - -* Fix regression where the association would not construct new finder SQL on save causing bogus queries for "WHERE owner_id = NULL" even after owner was saved. #8713 [Bryan Helmkamp] - -* Refactor association create and build so before & after callbacks behave consistently. #8854 [Pratik Naik, mortent] - -* Quote table names. Defaults to column quoting. #4593 [Justin Lynn, gwcoffey, eadz, Dmitry V. Sabanin, Jeremy Kemper] - -* Alias association #build to #new so it behaves predictably. #8787 [Pratik Naik] - -* Add notes to documentation regarding attr_readonly behavior with counter caches and polymorphic associations. Closes #9835 [saimonmoore, Rick Olson] - -* Observers can observe model names as symbols properly now. Closes #9869 [queso] - -* find_and_(initialize|create)_by methods can now properly initialize protected attributes [Tobias Lütke] - -* belongs_to infers the foreign key from the association name instead of from the class name. [Jeremy Kemper] - -* PostgreSQL: support multiline default values. #7533 [Carl Lerche, aguynamedryan, Rein Henrichs, Tarmo Tänav] - -* MySQL: fix change_column on not-null columns that don't accept dfeault values of ''. #6663 [Jonathan Viney, Tarmo Tänav] - -* validates_uniqueness_of behaves well with abstract superclasses and -single-table inheritance. #3833, #9886 [Gabriel Gironda, rramdas, François Beausoleil, Josh Peek, Tarmo Tänav, pat] - -* Warn about protected attribute assigments in development and test environments when mass-assigning to an attr_protected attribute. #9802 [Henrik N] - -* Speedup database date/time parsing. [Jeremy Kemper, Tarmo Tänav] - -* Fix calling .clear on a has_many :dependent=>:delete_all association. [Tarmo Tänav] - -* Allow change_column to set NOT NULL in the PostgreSQL adapter [Tarmo Tänav] - -* Fix that ActiveRecord would create attribute methods and override custom attribute getters if the method is also defined in Kernel.methods. [Rick Olson] - -* Don't call attr_readonly on polymorphic belongs_to associations, in case it matches the name of some other non-ActiveRecord class/module. [Rick Olson] - -* Try loading activerecord-<adaptername>-adapter gem before trying a plain require so you can use custom gems for the bundled adapters. Also stops gems from requiring an adapter from an old Active Record gem. [Jeremy Kemper, Derrick Spell] - - -*2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.14.2 - 1.15.3] - -* Add attr_readonly to specify columns that are skipped during a normal ActiveRecord #save operation. Closes #6896 [Dan Manges] - - class Comment < ActiveRecord::Base - # Automatically sets Article#comments_count as readonly. - belongs_to :article, :counter_cache => :comments_count - end - - class Article < ActiveRecord::Base - attr_readonly :approved_comments_count - end - -* Make size for has_many :through use counter cache if it exists. Closes #9734 [Xavier Shay] - -* Remove DB2 adapter since IBM chooses to maintain their own adapter instead. [Jeremy Kemper] - -* Extract Oracle, SQLServer, and Sybase adapters into gems. [Jeremy Kemper] - -* Added fixture caching that'll speed up a normal fixture-powered test suite between 50% and 100% #9682 [Frederick Cheung] - -* Correctly quote id list for limited eager loading. #7482 [tmacedo] - -* Fixed that using version-targetted migrates would fail on loggers other than the default one #7430 [valeksenko] - -* Fixed rename_column for SQLite when using symbols for the column names #8616 [drodriguez] - -* Added the possibility of using symbols in addition to concrete classes with ActiveRecord::Observer#observe. #3998 [Robby Russell, Tarmo Tänav] - -* Added ActiveRecord::Base#to_json/from_json [David Heinemeier Hansson, Cheah Chu Yeow] - -* Added ActiveRecord::Base#from_xml [David Heinemeier Hansson]. Example: - - xml = "<person><name>David</name></person>" - Person.new.from_xml(xml).name # => "David" - -* Define dynamic finders as real methods after first usage. [bscofield] - -* Deprecation: remove deprecated threaded_connections methods. Use allow_concurrency instead. [Jeremy Kemper] - -* Associations macros accept extension blocks alongside modules. #9346 [Josh Peek] - -* Speed up and simplify query caching. [Jeremy Kemper] - -* connection.select_rows 'sql' returns an array (rows) of arrays (field values). #2329 [Michael Schuerig] - -* Eager loading respects explicit :joins. #9496 [dasil003] - -* Extract Firebird, FrontBase, and OpenBase adapters into gems. #9508, #9509, #9510 [Jeremy Kemper] - -* RubyGem database adapters: expects a gem named activerecord-<database>-adapter with active_record/connection_adapters/<database>_adapter.rb in its load path. [Jeremy Kemper] - -* Fixed that altering join tables in migrations would fail w/ sqlite3 #7453 [TimoMihaljov/brandon] - -* Fix association writer with :dependent => :nullify. #7314 [Jonathan Viney] - -* OpenBase: update for new lib and latest Rails. Support migrations. #8748 [dcsesq] - -* Moved acts_as_tree into a plugin of the same name on the official Rails svn. #9514 [Pratik Naik] - -* Moved acts_as_nested_set into a plugin of the same name on the official Rails svn. #9516 [Josh Peek] - -* Moved acts_as_list into a plugin of the same name on the official Rails svn. [Josh Peek] - -* Explicitly require active_record/query_cache before using it. [Jeremy Kemper] - -* Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick Olson, marclove] - -* Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper] - -* Fixed that eager loading queries and with_scope should respect the :group option [David Heinemeier Hansson] - -* Improve performance and functionality of the postgresql adapter. Closes #8049 [roderickvd] - - For more information see: http://dev.rubyonrails.org/ticket/8049 - -* Don't clobber includes passed to has_many.count [Jack Danger Canty] - -* Make sure has_many uses :include when counting [Jack Danger Canty] - -* Change the implementation of ActiveRecord's attribute reader and writer methods [Michael Koziarski] - - Generate Reader and Writer methods which cache attribute values in hashes. This is to avoid repeatedly parsing the same date or integer columns. - - Change exception raised when users use find with :select then try to access a skipped column. Plugins could override missing_attribute() to lazily load the columns. - - Move method definition to the class, instead of the instance - - Always generate the readers, writers and predicate methods. - -* Perform a deep #dup on query cache results so that modifying activerecord attributes does not modify the cached attributes. [Rick Olson] - -# Ensure that has_many :through associations use a count query instead of loading the target when #size is called. Closes #8800 [Pratik Naik] - -* Added :unless clause to validations #8003 [monki]. Example: - - def using_open_id? - !identity_url.blank? - end - - validates_presence_of :identity_url, :if => using_open_id? - validates_presence_of :username, :unless => using_open_id? - validates_presence_of :password, :unless => using_open_id? - -* Fix #count on a has_many :through association so that it recognizes the :uniq option. Closes #8801 [Pratik Naik] - -* Fix and properly document/test count(column_name) usage. Closes #8999 [Pratik Naik] - -* Remove deprecated count(conditions=nil, joins=nil) usage. Closes #8993 [Pratik Naik] - -* Change belongs_to so that the foreign_key assumption is taken from the association name, not the class name. Closes #8992 [Josh Susser] - - OLD - belongs_to :visitor, :class_name => 'User' # => inferred foreign_key is user_id - - NEW - belongs_to :visitor, :class_name => 'User' # => inferred foreign_key is visitor_id - -* Remove spurious tests from deprecated_associations_test, most of these aren't deprecated, and are duplicated in associations_test. Closes #8987 [Pratik Naik] - -* Make create! on a has_many :through association return the association object. Not the collection. Closes #8786 [Pratik Naik] - -* Move from select * to select tablename.* to avoid clobbering IDs. Closes #8889 [dasil003] - -* Don't call unsupported methods on associated objects when using :include, :method with to_xml #7307, [Manfred Stienstra, jwilger] - -* Define collection singular ids method for has_many :through associations. #8763 [Pratik Naik] - -* Array attribute conditions work with proxied association collections. #8318 [Kamal Fariz Mahyuddin, theamazingrando] - -* Fix polymorphic has_one associations declared in an abstract class. #8638 [Pratik Naik, Dax Huiberts] - -* Fixed validates_associated should not stop on the first error. #4276 [mrj, Manfred Stienstra, Josh Peek] - -* Rollback if commit raises an exception. #8642 [kik, Jeremy Kemper] - -* Update tests' use of fixtures for the new collections api. #8726 [Kamal Fariz Mahyuddin] - -* Save associated records only if the association is already loaded. #8713 [Blaine] - -* MySQL: fix show_variable. #8448 [matt, Jeremy Kemper] - -* Fixtures: correctly delete and insert fixtures in a single transaction. #8553 [Michael Schuerig] - -* Fixtures: people(:technomancy, :josh) returns both fixtures. #7880 [technomancy, Josh Peek] - -* Calculations support non-numeric foreign keys. #8154 [Kamal Fariz Mahyuddin] - -* with_scope is protected. #8524 [Josh Peek] - -* Quickref for association methods. #7723 [marclove, Mindsweeper] - -* Calculations: return nil average instead of 0 when there are no rows to average. #8298 [davidw] - -* acts_as_nested_set: direct_children is sorted correctly. #4761 [Josh Peek, rails@33lc0.net] - -* Raise an exception if both attr_protected and attr_accessible are declared. #8507 [stellsmi] - -* SQLite, MySQL, PostgreSQL, Oracle: quote column names in column migration SQL statements. #8466 [marclove, lorenjohnson] - -* Allow nil serialized attributes with a set class constraint. #7293 [sandofsky] - -* Oracle: support binary fixtures. #7987 [Michael Schoen] - -* Fixtures: pull fixture insertion into the database adapters. #7987 [Michael Schoen] - -* Announce migration versions as they're performed. [Jeremy Kemper] - -* find gracefully copes with blank :conditions. #7599 [Dan Manges, johnnyb] - -* validates_numericality_of takes :greater_than, :greater_than_or_equal_to, :equal_to, :less_than, :less_than_or_equal_to, :odd, and :even options. #3952 [Bob Silva, Dan Kubb, Josh Peek] - -* MySQL: create_database takes :charset and :collation options. Charset defaults to utf8. #8448 [matt] - -* Find with a list of ids supports limit/offset. #8437 [hrudududu] - -* Optimistic locking: revert the lock version when an update fails. #7840 [plang] - -* Migrations: add_column supports custom column types. #7742 [jsgarvin, Theory] - -* Load database adapters on demand. Eliminates config.connection_adapters and RAILS_CONNECTION_ADAPTERS. Add your lib directory to the $LOAD_PATH and put your custom adapter in lib/active_record/connection_adapters/adaptername_adapter.rb. This way you can provide custom adapters as plugins or gems without modifying Rails. [Jeremy Kemper] - -* Ensure that associations with :dependent => :delete_all respect :conditions option. Closes #8034 [Jack Danger Canty, Josh Peek, Rick Olson] - -* belongs_to assignment creates a new proxy rather than modifying its target in-place. #8412 [mmangino@elevatedrails.com] - -* Fix column type detection while loading fixtures. Closes #7987 [roderickvd] - -* Document deep eager includes. #6267 [Josh Susser, Dan Manges] - -* Document warning that associations names shouldn't be reserved words. #4378 [murphy@cYcnus.de, Josh Susser] - -* Sanitize Base#inspect. #8392, #8623 [Nik Wakelin, jnoon] - -* Replace the transaction {|transaction|..} semantics with a new Exception ActiveRecord::Rollback. [Michael Koziarski] - -* Oracle: extract column length for CHAR also. #7866 [ymendel] - -* Document :allow_nil option for validates_acceptance_of since it defaults to true. [tzaharia] - -* Update documentation for :dependent declaration so that it explicitly uses the non-deprecated API. [Jack Danger Canty] - -* Add documentation caveat about when to use count_by_sql. [fearoffish] - -* Enhance documentation for increment_counter and decrement_counter. [fearoffish] - -* Provide brief introduction to what optimistic locking is. [fearoffish] - -* Add documentation for :encoding option to mysql adapter. [marclove] - -* Added short-hand declaration style to migrations (inspiration from Sexy Migrations, http://errtheblog.com/post/2381) [David Heinemeier Hansson]. Example: - - create_table "products" do |t| - t.column "shop_id", :integer - t.column "creator_id", :integer - t.column "name", :string, :default => "Untitled" - t.column "value", :string, :default => "Untitled" - t.column "created_at", :datetime - t.column "updated_at", :datetime - end - - ...can now be written as: - - create_table :products do |t| - t.integer :shop_id, :creator_id - t.string :name, :value, :default => "Untitled" - t.timestamps - end - -* Use association name for the wrapper element when using .to_xml. Previous behavior lead to non-deterministic situations with STI and polymorphic associations. [Michael Koziarski, jstrachan] - -* Improve performance of calling .create on has_many :through associations. [evan] - -* Improved cloning performance by relying less on exception raising #8159 [Blaine] - -* Added ActiveRecord::Base.inspect to return a column-view like #<Post id:integer, title:string, body:text> [David Heinemeier Hansson] - -* Added yielding of Builder instance for ActiveRecord::Base#to_xml calls [David Heinemeier Hansson] - -* Small additions and fixes for ActiveRecord documentation. Closes #7342 [Jeremy McAnally] - -* Add helpful debugging info to the ActiveRecord::StatementInvalid exception in ActiveRecord::ConnectionAdapters::SqliteAdapter#table_structure. Closes #7925. [court3nay] - -* SQLite: binary escaping works with $KCODE='u'. #7862 [tsuka] - -* Base#to_xml supports serialized attributes. #7502 [jonathan] - -* Base.update_all :order and :limit options. Useful for MySQL updates that must be ordered to avoid violating unique constraints. [Jeremy Kemper] - -* Remove deprecated object transactions. People relying on this functionality should install the object_transactions plugin at http://code.bitsweat.net/svn/object_transactions. Closes #5637 [Michael Koziarski, Jeremy Kemper] - -* PostgreSQL: remove DateTime -> Time downcast. Warning: do not enable translate_results for the C bindings if you have timestamps outside Time's domain. [Jeremy Kemper] - -* find_or_create_by_* takes a hash so you can create with more attributes than are in the method name. For example, Person.find_or_create_by_name(:name => 'Henry', :comments => 'Hi new user!') is equivalent to Person.find_by_name('Henry') || Person.create(:name => 'Henry', :comments => 'Hi new user!'). #7368 [Josh Susser] - -* Make sure with_scope takes both :select and :joins into account when setting :readonly. Allows you to save records you retrieve using method_missing on a has_many :through associations. [Michael Koziarski] - -* Allow a polymorphic :source for has_many :through associations. Closes #7143 [protocool] - -* Consistent public/protected/private visibility for chained methods. #7813 [Dan Manges] - -* Oracle: fix quoted primary keys and datetime overflow. #7798 [Michael Schoen] - -* Consistently quote primary key column names. #7763 [toolmantim] - -* Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley] - -* DateTimes assume the default timezone. #7764 [Geoff Buesing] - -* Sybase: hide timestamp columns since they're inherently read-only. #7716 [Mike Joyce] - -* Oracle: overflow Time to DateTime. #7718 [Michael Schoen] - -* PostgreSQL: don't use async_exec and async_query with postgres-pr. #7727, #7762 [flowdelic, toolmantim] - -* Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins] - -* Test DateTime native type in migrations, including an edge case with dates -during calendar reform. #7649, #7724 [fedot, Geoff Buesing] - -* SQLServer: correctly schema-dump tables with no indexes or descending indexes. #7333, #7703 [Jakob Skjerning, Tom Ward] - -* SQLServer: recognize real column type as Ruby float. #7057 [sethladd, Tom Ward] - -* Added fixtures :all as a way of loading all fixtures in the fixture directory at once #7214 [Manfred Stienstra] - -* Added database connection as a yield parameter to ActiveRecord::Base.transaction so you can manually rollback [David Heinemeier Hansson]. Example: - - transaction do |transaction| - david.withdrawal(100) - mary.deposit(100) - transaction.rollback! # rolls back the transaction that was otherwise going to be successful - end - -* Made increment_counter/decrement_counter play nicely with optimistic locking, and added a more general update_counters method [Jamis Buck] - -* Reworked David's query cache to be available as Model.cache {...}. For the duration of the block no select query should be run more then once. Any inserts/deletes/executes will flush the whole cache however [Tobias Lütke] - Task.cache { Task.find(1); Task.find(1) } #=> 1 query - -* When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck] - -* Oracle: fix lob and text default handling. #7344 [gfriedrich, Michael Schoen] - -* SQLServer: don't choke on strings containing 'null'. #7083 [Jakob Skjerning] - -* MySQL: blob and text columns may not have defaults in 5.x. Update fixtures schema for strict mode. #6695 [Dan Kubb] - -* update_all can take a Hash argument. sanitize_sql splits into two methods for conditions and assignment since NULL values and delimiters are handled differently. #6583, #7365 [sandofsky, Assaf] - -* MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc] - -* Use Date#to_s(:db) for quoted dates. #7411 [Michael Schoen] - -* Don't create instance writer methods for class attributes. Closes #7401 [Rick Olson] - -* Docs: validations examples. #7343 [zackchandler] - -* Add missing tests ensuring callbacks work with class inheritance. Closes #7339 [sandofsky] - -* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden] - -* Remove useless code in #attribute_present? since 0 != blank?. Closes #7249 [Josh Susser] - -* Fix minor doc typos. Closes #7157 [Josh Susser] - -* Fix incorrect usage of #classify when creating the eager loading join statement. Closes #7044 [Josh Susser] - -* SQLServer: quote table name in indexes query. #2928 [keithm@infused.org] - -* Subclasses of an abstract class work with single-table inheritance. #5704, #7284 [BertG, nick+rails@ag.arizona.edu] - -* Make sure sqlite3 driver closes open connections on disconnect [Rob Rasmussen] - -* [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [Jeremy McAnally] - -* change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [Dan Manges, Jeremy Kemper] - -* MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, Manfred Stienstra, altano@bigfoot.com] - -* Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen] - -* MySQL: retain SSL settings on reconnect. #6976 [randyv2] - -* Apply scoping during initialize instead of create. Fixes setting of foreign key when using find_or_initialize_by with scoping. [Cody Fauser] - -* SQLServer: handle [quoted] table names. #6635 [rrich] - -* acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser] - -* PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen] - -* Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [Dan Manges] - Student.find(:all, :conditions => { :grade => 9..12 }) - -* Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler] - -* [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell] - -* [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot] - -* Bring the sybase adapter up to scratch for 1.2 release. [jsheets] - -* Rollback new_record? and id when an exception is raised in a save callback. #6910 [Ben Curren, outerim] - -* Pushing a record on an association collection doesn't unnecessarily load all the associated records. [Obie Fernandez, Jeremy Kemper] - -* Oracle: fix connection reset failure. #6846 [leonlleslie] - -* Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper] - -* fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool] - -* Consolidated different create and create! versions to call through to the base class with scope. This fixes inconsistencies, especially related to protected attribtues. Closes #5847 [Alexander Dymo, Tobias Lütke] - -* find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper] - -* Add AssociationCollection#create! to be consistent with AssociationCollection#create when dealing with a foreign key that is a protected attribute [Cody Fauser] - -* Added counter optimization for AssociationCollection#any? so person.friends.any? won't actually load the full association if we have the count in a cheaper form [David Heinemeier Hansson] - -* Change fixture_path to a class inheritable accessor allowing test cases to have their own custom set of fixtures. #6672 [Zach Dennis] - -* Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov] - -* Simplify query_attribute by typecasting the attribute value and checking whether it's nil, false, zero or blank. #6659 [Jonathan Viney] - -* validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz] - -* Run validations in the order they were declared. #6657 [obrie] - -* MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper] - -* Simplify association proxy implementation by factoring construct_scope out of method_missing. #6643 [martin] - -* Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen] - -* Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen] - -* Don't inspect unloaded associations. #2905 [lmarlow] - -* SQLite: use AUTOINCREMENT primary key in >= 3.1.0. #6588, #6616 [careo, lukfugl] - -* Cache inheritance_column. #6592 [Stefan Kaes] - -* Firebird: decimal/numeric support. #6408 [macrnic] - -* make add_order a tad faster. #6567 [Stefan Kaes] - -* Find with :include respects scoped :order. #5850 - -* Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper] - find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil } - -* Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si] - -* SQLite: fix calculations workaround, remove count(distinct) query rewrite, cleanup test connection scripts. [Jeremy Kemper] - -* SQLite: count(distinct) queries supported in >= 3.2.6. #6544 [Bob Silva] - -* Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes] - -* Deprecation: object transactions warning. [Jeremy Kemper] - -* has_one :dependent => :nullify ignores nil associates. #4848, #6528 [bellis@deepthought.org, janovetz, Jeremy Kemper] - -* Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen] - -* Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie] - -* Document other options available to migration's add_column. #6419 [grg] - -* MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper] - -* Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney] - -* fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick Olson] - -* Restore eager condition interpolation, document it's differences [Rick Olson] - -* Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper] - -* Add #delete support to has_many :through associations. Closes #6049 [Martin Landers] - -* Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick Olson] - -* Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com] - -* Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com] - -* Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan] - -* Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [Bob Silva] - -* The has_many create method works with polymorphic associations. #6361 [Dan Peterson] - -* MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes] - -* save! shouldn't validate twice. #6324 [maiha, Bob Silva] - -* Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig] - -* Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson] - -* Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva] - -* has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper] - -* Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Michael Koziarski] - -* Add a :namespace option to AR::Base#to_xml [Michael Koziarski] - -* Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper] - -* Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson] - -* Improve yaml fixtures error reporting. #6205 [Bruce Williams] - -* Rename AR::Base#quote so people can use that name in their models. #3628 [Michael Koziarski] - -* Add deprecation warning for inferred foreign key. #6029 [Josh Susser] - -* Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com] - -* Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser] - -* Document validates_presences_of behavior with booleans: you probably want validates_inclusion_of :attr, :in => [true, false]. #2253 [Bob Silva] - -* Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward] - -* to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher] - -* Deprecation: update docs. #5998 [Jakob Skjerning, Kevin Clark] - -* Add some XmlSerialization tests for ActiveRecord [Rick Olson] - -* has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck] - -* has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney] - -* Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney] - -* SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi] - -* SQLServer: fix eager association test. #5901 [Tom Ward] - -* Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark] - -* Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com] - -* Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com] - -* MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward] - -* to_xml: correct naming of included associations. #5831 [Josh Starcher] - -* Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [Josh Susser] - -* Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper] - - # Create a tagging to associate the post and tag. - post.tags << Tag.find_by_name('old') - post.tags.create! :name => 'general' - - # Would have been: - post.taggings.create!(:tag => Tag.find_by_name('finally') - transaction do - post.taggings.create!(:tag => Tag.create!(:name => 'general')) - end - -* Cache nil results for :included has_one associations also. #5787 [Michael Schoen] - -* Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Lütke] - -* Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper] - Example: Invoice::Lineitem is given table name invoice_lineitems - -* Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper] - # people_active_last_name_index, people_active_deactivated_at_index - add_index :people, [:active, :last_name] - add_index :people, [:active, :deactivated_at] - remove_index :people, [:active, :last_name] - remove_index :people, [:active, :deactivated_at] - - WARNING: backward-incompatibility. Multicolumn indexes created before this - revision were named using the first column name only. Now they're uniquely - named using all indexed columns. - - To remove an old multicolumn index, remove_index :table_name, :first_column - -* Fix for deep includes on the same association. [richcollins@gmail.com] - -* Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark] - -* Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson] - -* Document find's :from option. Closes #5762. [andrew@redlinesoftware.com] - -* PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael Schoen] - -* Add documentation for how to disable timestamps on a per model basis. Closes #5684. [matt@mattmargolis.net Marcel Molina Jr.] - -* Don't save has_one associations unnecessarily. #5735 [Jonathan Viney] - -* Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson] - -* Formally deprecate the deprecated finders. [Michael Koziarski] - -* Formally deprecate rich associations. [Michael Koziarski] - -* Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com] - -* Fix announcement of very long migration names. #5722 [blake@near-time.com] - -* The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com] - -* Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com] - -* Added support for conditions on Base.exists? #5689 [Josh Peek]. Examples: - - assert (Topic.exists?(:author_name => "David")) - assert (Topic.exists?(:author_name => "Mary", :approved => true)) - assert (Topic.exists?(["parent_id = ?", 1])) - -* Schema dumper quotes date :default values. [Dave Thomas] - -* Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson] - -* Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper] - -* Patch sql injection vulnerability when using integer or float columns. [Jamis Buck] - -* Allow #count through a has_many association to accept :include. [Dan Peterson] - -* create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw] - -* PostgreSQL: return array fields as strings. #4664 [Robby Russell] - -* SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward] - -* SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers] - -* Oracle: BigDecimal support. #5667 [Michael Schoen] - -* Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk] - -* Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>] - -* PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com] - -* Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>] - -* PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net] - -* PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com] - -* Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net] - -* Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [Michael Schoen] - -* Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [Michael Schoen] - -* Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org] - -* Minor tweak to improve performance of ActiveRecord::Base#to_param. - -* Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au] - -* Removed deprecated timestamps_gmt class methods. [Jeremy Kemper] - -* rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com] - -* PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com] - -* Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum. - -* Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson] - -* Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda] - # Obtain an exclusive lock on person 1 so we can safely increment visits. - Person.transaction do - # select * from people where id=1 for update - person = Person.find(1, :lock => true) - person.visits += 1 - person.save! - end - -* PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper] - -* Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper] - -* Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar] - -* Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de) - -* Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [David Heinemeier Hansson] - -* Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [Hampton Catlin]. Example: - - Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2) - -...is the same as: - - Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2) - - This makes it easier to pass in the options from a form or otherwise outside. - - -* Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com] - -* Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net] - -* Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com] - -* Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com] - -* Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp] - -* Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net] - -* Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>] - -* PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp] - -* Records and arrays of records are bound as quoted ids. [Jeremy Kemper] - Foo.find(:all, :conditions => ['bar_id IN (?)', bars]) - Foo.find(:first, :conditions => ['bar_id = ?', bar]) - -* Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [David Heinemeier Hansson] - -* Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick Olson] - -* Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [Josh Susser] - -* Provide Association Extensions access to the instance that the association is being accessed from. - Closes #4433 [Josh Susser] - -* Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell] - -* Add a quick note about :select and eagerly included associations. [Rick Olson] - -* Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com] - -* Fixed that has_many collections shouldn't load the entire association to do build or create [David Heinemeier Hansson] - -* Added :allow_nil option for aggregations #5091 [Ian White] - -* Fix Oracle boolean support and tests. Closes #5139. [Michael Schoen] - -* create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper] - -* Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com] - -* Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk] - -* PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org] - -* Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com] - -* Allow :uniq => true with has_many :through associations. [Jeremy Kemper] - -* Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.] - -* Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com] - -* Replace superfluous name_to_class_name variant with camelize. [Marcel Molina Jr.] - -* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>] - -* Update FrontBase adapter to check binding version. Closes #4920. [mlaster@metavillage.com] - -* New Frontbase connections don't start in auto-commit mode. Closes #4922. [mlaster@metavillage.com] - -* When grouping, use the appropriate option key. [Marcel Molina Jr.] - -* Only modify the sequence name in the FrontBase adapter if the FrontBase adapter is actually being used. [Marcel Molina Jr.] - -* Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com] - -* Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>] - -* Fix syntax error in documentation. Closes #4679. [Mislav Marohnić] - -* Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu] - -* Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com] - -* Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net] - -* Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>] - -* Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com] - -* Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net] - -* Fix bug where calculations with long alias names return null. [Rick Olson] - -* Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick Olson] - - @post.tags << @tag # BAD - @post.taggings.create(:tag => @tag) # GOOD - -* Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick Olson] - -* Update inconsistent migrations documentation. #4683 [machomagna@gmail.com] - -* Add ActiveRecord::Errors#to_xml [Jamis Buck] - -* Properly quote index names in migrations (closes #4764) [John Long] - -* Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick Olson] - -* Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick Olson] - -* Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick Olson] - -* DRY up association collection reader method generation. [Marcel Molina Jr.] - -* DRY up and tweak style of the validation error object. [Marcel Molina Jr.] - -* Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick Olson] - - class Account < ActiveRecord::Base - validates_uniqueness_of :email, :case_sensitive => false - end - -* Allow multiple association extensions with :extend option (closes #4666) [Josh Susser] - - class Account < ActiveRecord::Base - has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] - end - - *1.15.3* (March 12th, 2007) - - * Allow a polymorphic :source for has_many :through associations. Closes #7143 [protocool] - - * Consistently quote primary key column names. #7763 [toolmantim] - - * Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley] - - * Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins] - - -*1.15.2* (February 5th, 2007) - -* Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [Dan Manges] - Student.find(:all, :conditions => { :grade => 9..12 }) - -* Don't create instance writer methods for class attributes. [Rick Olson] - -* When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck] - -* SQLServer: don't choke on strings containing 'null'. #7083 [Jakob Skjerning] - -* Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si] - -* MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc] - -* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden] - -* SQLServer: quote table name in indexes query. #2928 [keithm@infused.org] - - -*1.15.1* (January 17th, 2007) - -* Fix nodoc breaking of adapters - - -*1.15.0* (January 16th, 2007) - -* [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [Jeremy McAnally] - -* change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [Dan Manges, Jeremy Kemper] - -* MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, Manfred Stienstra, altano@bigfoot.com] - -* Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen] - -* MySQL: retain SSL settings on reconnect. #6976 [randyv2] - -* SQLServer: handle [quoted] table names. #6635 [rrich] - -* acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser] - -* PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen] - -* Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler] - -* [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell] - -* [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot] - -* Bring the sybase adapter up to scratch for 1.2 release. [jsheets] - -* Oracle: fix connection reset failure. #6846 [leonlleslie] - -* Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper] - -* fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool] - -* find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper] - -* Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper] - find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil } - -* Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov] - -* MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper] - -* validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz] - -* Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen] - -* Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen] - -* Firebird: decimal/numeric support. #6408 [macrnic] - -* Find with :include respects scoped :order. #5850 - -* Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes] - -* Deprecation: object transactions warning. [Jeremy Kemper] - -* has_one :dependent => :nullify ignores nil associates. #6528 [janovetz, Jeremy Kemper] - -* Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen] - -* Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie] - -* Document other options available to migration's add_column. #6419 [grg] - -* MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper] - -* Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney] - -* fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick Olson] - -* Restore eager condition interpolation, document it's differences [Rick Olson] - -* Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper] - -* Add #delete support to has_many :through associations. Closes #6049 [Martin Landers] - -* Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick Olson] - -* Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com] - -* Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com] - -* Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan] - -* Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [Bob Silva] - -* The has_many create method works with polymorphic associations. #6361 [Dan Peterson] - -* MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes] - -* save! shouldn't validate twice. #6324 [maiha, Bob Silva] - -* Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig] - -* Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson] - -* Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva] - -* has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper] - -* Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Michael Koziarski] - -* Add a :namespace option to AR::Base#to_xml [Michael Koziarski] - -* Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper] - -* Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson] - -* Improve yaml fixtures error reporting. #6205 [Bruce Williams] - -* Rename AR::Base#quote so people can use that name in their models. #3628 [Michael Koziarski] - -* Add deprecation warning for inferred foreign key. #6029 [Josh Susser] - -* Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com] - -* Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser] - -* Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward] - -* to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher] - -* has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com] - -* Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck] - -* has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney] - -* Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney] - -* SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi] - -* Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark] - -* Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com] - -* Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com] - -* MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward] - -* to_xml: correct naming of included associations. #5831 [Josh Starcher] - -* Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [Josh Susser] - -* Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper] - - # Create a tagging to associate the post and tag. - post.tags << Tag.find_by_name('old') - post.tags.create! :name => 'general' - - # Would have been: - post.taggings.create!(:tag => Tag.find_by_name('finally') - transaction do - post.taggings.create!(:tag => Tag.create!(:name => 'general')) - end - -* Cache nil results for :included has_one associations also. #5787 [Michael Schoen] - -* Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Lütke] - -* Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper] - Example: Invoice::Lineitem is given table name invoice_lineitems - -* Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper] - # people_active_last_name_index, people_active_deactivated_at_index - add_index :people, [:active, :last_name] - add_index :people, [:active, :deactivated_at] - remove_index :people, [:active, :last_name] - remove_index :people, [:active, :deactivated_at] - - WARNING: backward-incompatibility. Multicolumn indexes created before this - revision were named using the first column name only. Now they're uniquely - named using all indexed columns. - - To remove an old multicolumn index, remove_index :table_name, :first_column - -* Fix for deep includes on the same association. [richcollins@gmail.com] - -* Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark] - -* Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson] - -* PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael Schoen] - -* Don't save has_one associations unnecessarily. #5735 [Jonathan Viney] - -* Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson] - -* Formally deprecate the deprecated finders. [Michael Koziarski] - -* Formally deprecate rich associations. [Michael Koziarski] - -* Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com] - -* Fix announcement of very long migration names. #5722 [blake@near-time.com] - -* The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com] - -* Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com] - -* Added support for conditions on Base.exists? #5689 [Josh Peek]. Examples: - - assert (Topic.exists?(:author_name => "David")) - assert (Topic.exists?(:author_name => "Mary", :approved => true)) - assert (Topic.exists?(["parent_id = ?", 1])) - -* Schema dumper quotes date :default values. [Dave Thomas] - -* Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson] - -* Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper] - -* Patch sql injection vulnerability when using integer or float columns. [Jamis Buck] - -* Allow #count through a has_many association to accept :include. [Dan Peterson] - -* create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw] - -* PostgreSQL: return array fields as strings. #4664 [Robby Russell] - -* SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward] - -* SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers] - -* Oracle: BigDecimal support. #5667 [Michael Schoen] - -* Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk] - -* Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>] - -* PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com] - -* PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net] - -* PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com] - -* Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net] - -* Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [Michael Schoen] - -* Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [Michael Schoen] - -* Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org] - -* Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au] - -* Removed deprecated timestamps_gmt class methods. [Jeremy Kemper] - -* rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com] - -* PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com] - -* Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum. - -* Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson] - -* Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda] - # Obtain an exclusive lock on person 1 so we can safely increment visits. - Person.transaction do - # select * from people where id=1 for update - person = Person.find(1, :lock => true) - person.visits += 1 - person.save! - end - -* PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper] - -* Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper] - -* Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar] - -* Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de) - -* Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [David Heinemeier Hansson] - -* Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [Hampton Catlin]. Example: - - Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2) - -...is the same as: - - Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2) - - This makes it easier to pass in the options from a form or otherwise outside. - - -* Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com] - -* Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net] - -* Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com] - -* Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com] - -* Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp] - -* Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net] - -* Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>] - -* PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp] - -* Records and arrays of records are bound as quoted ids. [Jeremy Kemper] - Foo.find(:all, :conditions => ['bar_id IN (?)', bars]) - Foo.find(:first, :conditions => ['bar_id = ?', bar]) - -* Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [David Heinemeier Hansson] - -* Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick Olson] - -* Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [Josh Susser] - -* Provide Association Extensions access to the instance that the association is being accessed from. - Closes #4433 [Josh Susser] - -* Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell] - -* Add a quick note about :select and eagerly included associations. [Rick Olson] - -* Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com] - -* Fixed that has_many collections shouldn't load the entire association to do build or create [David Heinemeier Hansson] - -* Added :allow_nil option for aggregations #5091 [Ian White] - -* Fix Oracle boolean support and tests. Closes #5139. [Michael Schoen] - -* create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper] - -* Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com] - -* Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk] - -* PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org] - -* Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com] - -* Allow :uniq => true with has_many :through associations. [Jeremy Kemper] - -* Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.] - -* Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com] - -* Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>] - -* When grouping, use the appropriate option key. [Marcel Molina Jr.] - -* Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com] - -* Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>] - -* Fix syntax error in documentation. Closes #4679. [Mislav Marohnić] - -* Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu] - -* Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com] - -* Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net] - -* Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>] - -* Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com] - -* Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net] - -* Fix bug where calculations with long alias names return null. [Rick Olson] - -* Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick Olson] - - @post.tags << @tag # BAD - @post.taggings.create(:tag => @tag) # GOOD - -* Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick Olson] - -* Add ActiveRecord::Errors#to_xml [Jamis Buck] - -* Properly quote index names in migrations (closes #4764) [John Long] - -* Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick Olson] - -* Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick Olson] - -* Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick Olson] - -* Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick Olson] - - class Account < ActiveRecord::Base - validates_uniqueness_of :email, :case_sensitive => false - end - -* Allow multiple association extensions with :extend option (closes #4666) [Josh Susser] - - class Account < ActiveRecord::Base - has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] - end - - -*1.14.4* (August 8th, 2006) - -* Add warning about the proper way to validate the presence of a foreign key. #4147 [Francois Beausoleil <francois.beausoleil@gmail.com>] - -* Fix syntax error in documentation. #4679 [Mislav Marohnić] - -* Update inconsistent migrations documentation. #4683 [machomagna@gmail.com] - - -*1.14.3* (June 27th, 2006) - -* Fix announcement of very long migration names. #5722 [blake@near-time.com] - -* Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>] - -* Properly quote index names in migrations (closes #4764) [John Long] - -* Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick Olson] - -* Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick Olson] - - -*1.14.2* (April 9th, 2006) - -* Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen] - - -*1.14.1* (April 6th, 2006) - -* Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar] - -* Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind] - -* Enable Limit/Offset in Calculations (closes #4558) [lmarlow] - -* Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick Olson] - -* Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr] - -* Allow AR::Base#respond_to? to behave when @attributes is nil [Ryan Davis] - -* Support eager includes when going through a polymorphic has_many association. [Rick Olson] - -* Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick Olson] - - class Post < ActiveRecord::Base - has_one :tagging, :as => :taggable - end - - Post.find :all, :include => :tagging - -* Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick Olson] - -* Added support for going through a polymorphic has_many association: (closes #4401) [Rick Olson] - - class PhotoCollection < ActiveRecord::Base - has_many :photos, :as => :photographic - belongs_to :firm - end - - class Firm < ActiveRecord::Base - has_many :photo_collections - has_many :photos, :through => :photo_collections - end - -* Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com] - -* Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber] - -* Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan] - -* Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick Olson] - -* DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [David Heinemeier Hansson] - -* Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [David Heinemeier Hansson] - -* Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.] - -* Fixed broken OCIAdapter #4457 [Michael Schoen] - - -*1.14.0* (March 27th, 2006) - -* Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar] - -* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick Olson] - -* Add support for :include to with_scope [andrew@redlinesoftware.com] - -* Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [Michael Schoen] - -* Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com] - -* Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick Olson] - -* Fixed issue that kept :select options from being scoped [Rick Olson] - -* Fixed db_schema_import when binary types are present #3101 [David Heinemeier Hansson] - -* Fixed that MySQL enums should always be returned as strings #3501 [David Heinemeier Hansson] - -* Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson] - - class Connection < ActiveRecord::Base - belongs_to :user - belongs_to :channel - end - - class Channel < ActiveRecord::Base - has_many :connections - has_many :contacts, :through => :connections, :class_name => 'User' # OLD - has_many :contacts, :through => :connections, :source => :user # NEW - end - -* Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de] - -* Allow overriding of find parameters in scoped has_many :through calls [Rick Olson] - - In this example, :include => false disables the default eager association from loading. :select changes the standard - select clause. :joins specifies a join that is added to the end of the has_many :through query. - - class Post < ActiveRecord::Base - has_many :tags, :through => :taggings, :include => :tagging do - def add_joins_and_select - find :all, :select => 'tags.*, authors.id as author_id', :include => false, - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id' - end - end - end - -* Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson] - -* Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [Jonathan Viney] - -* Quit ignoring default :include options in has_many :through calls [Mark James] - -* Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [Jonathan Viney] - -* Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson] - -* Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example: - - class Firm < ActiveRecord::Base - has_many :clients - has_many :invoices, :through => :clients - end - - class Client < ActiveRecord::Base - belongs_to :firm - has_many :invoices - end - - class Invoice < ActiveRecord::Base - belongs_to :client - end - -* Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [Josh Susser] - -* Fixed has_many :through to include :conditions set on the :through association. closes #4020 [Jonathan Viney] - -* Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick Olson] - -* SQL Server adapter gets some love #4298 [Ryan Tomayko] - -* Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com] - -* Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI): - - Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body') - -* Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick Olson] - -* Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Michael Koziarski] - -* Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Michael Koziarski] - -* Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom Ward] - -* Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com] - -* Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck] - -* Use association's :conditions when eager loading. [Jeremy Evans] #4144 - -* Alias the has_and_belongs_to_many join table on eager includes. #4106 [Jeremy Evans] - - This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous. - - Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL') - -* Oracle adapter gets some love #4230 [Michael Schoen] - - * Changes :text to CLOB rather than BLOB [Moses Hohman] - * Fixes an issue with nil numeric length/scales (several) - * Implements support for XMLTYPE columns [wilig / Kubo Takehiro] - * Tweaks a unit test to get it all green again - * Adds support for #current_database - -* Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson] - - class CachedModel < ActiveRecord::Base - self.abstract_class = true - end - - class Post < CachedModel - end - - CachedModel.abstract_class? - => true - - Post.abstract_class? - => false - - Post.base_class - => Post - - Post.table_name - => 'posts' - -* Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson] - - class Foo < ActiveRecord::Base - has_many :attachments, :as => :attachable, :dependent => :delete_all - end - -* Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay] - -* Upgrade to Transaction::Simple 1.3 [Jamis Buck] - -* Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson] - -* Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com] - -* Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com] - -* Dynamically set allow_concurrency. #4044 [Stefan Kaes] - -* Added Base#to_xml that'll turn the current record into a XML representation [David Heinemeier Hansson]. Example: - - topic.to_xml - - ...returns: - - <?xml version="1.0" encoding="UTF-8"?> - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <id type="integer">1</id> - <approved type="boolean">false</approved> - <replies-count type="integer">0</replies-count> - <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time> - <written-on type="datetime">2003-07-16 09:28:00</written-on> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - ...and you can configure with: - - topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ]) - - ...that'll return: - - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <approved type="boolean">false</approved> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - You can even do load first-level associations as part of the document: - - firm.to_xml :include => [ :account, :clients ] - - ...that'll return something like: - - <?xml version="1.0" encoding="UTF-8"?> - <firm> - <id type="integer">1</id> - <rating type="integer">1</rating> - <name>37signals</name> - <clients> - <client> - <rating type="integer">1</rating> - <name>Summit</name> - </client> - <client> - <rating type="integer">1</rating> - <name>Microsoft</name> - </client> - </clients> - <account> - <id type="integer">1</id> - <credit-limit type="integer">50</credit-limit> - </account> - </firm> - -* Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck] - -* Documentation fixes for :dependent [robby@planetargon.com] - -* Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney] - -* Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org] - -* Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson] - -* Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>] - -* Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson] - - * The first time a table is referenced in a join, no alias is used. - * After that, the parent class name and the reflection name are used. - - Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ... - - * Any additional join references get a numerical suffix like '_2', '_3', etc. - -* Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to. - -* Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples: - - # cascaded in two levels - >> Author.find(:all, :include=>{:posts=>:comments}) - => authors - +- posts - +- comments - - # cascaded in two levels and normal association - >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations]) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in two levels with two has_many associations - >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in three levels - >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}}) - => companies - +- groups - +- members - +- favorites - -* Make counter cache work when replacing an association #3245 [eugenol@gmail.com] - -* Make migrations verbose [Jamis Buck] - -* Make counter_cache work with polymorphic belongs_to [Jamis Buck] - -* Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp] - -* Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats: - - * Does not support DATE SQL column types; use DATETIME instead. - * Date columns on HABTM join tables are returned as String, not Time. - * Insertions are potentially broken for :polymorphic join tables - * BLOB column access not yet fully supported - -* Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper] - -* CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper] - -* Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [Michael Schoen] - -* Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [David Heinemeier Hansson] - -* Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes] - -* Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark] - -* Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net] - -* Define attribute query methods to avoid method_missing calls. #3677 [Jonathan Viney] - -* ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward] - -* Added support for nested scopes #3407 [anna@wota.jp]. Examples: - - Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10 - - # inner rule is used. (all previous parameters are ignored) - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis') - end - - # parameters are merged - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10 - end - end - -* Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com] - -* Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh] - -* Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [Lars Pind] - -* Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples: - - Person.average :age - Person.minimum :age - Person.maximum :age - Person.sum :salary, :group => :last_name - -* Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [Luke Redpath] - -* Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper] - -* Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net] - -* Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de] - -* Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [Stefan Kaes] - -* Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva] - -* Allow :include to be used with has_many :through associations #3611 [Michael Schoen] - -* PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac] - -* SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward] - -* Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson] - -* PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org] - -* Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark] - -* ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Lütke] - -* Using AssociationCollection#build with arrays of hashes should call build, not create [David Heinemeier Hansson] - -* Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar] - -* Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt] - -* Support the :column option for remove_index with the PostgreSQL adapter. #3661 [Shugo Maeda] - -* Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>] - -* If the OCI library is not available, raise an exception indicating as much. #3593 [Michael Schoen] - -* Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson] - -* Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.] - -* Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar] - -* Make .count work for has_many associations with multi line finder sql [Michael Schoen] - -* Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck] - -* Allow configuration of the column used for optimistic locking [wilsonb@gmail.com] - -* Don't hardcode 'id' in acts as list. [ror@philippeapril.com] - -* Fix date errors for SQLServer in association tests. #3406 [Kevin Clark] - -* Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp] - -* Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com] - -* .with_scope imposed create parameters now bypass attr_protected [Tobias Lütke] - -* Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.] - -* Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de] - -* Sanitize scoped conditions. [Marcel Molina Jr.] - -* Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [David Heinemeier Hansson] - -* Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [Tobias Lütke] - -* SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [Tobias Lütke] - -* Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber] - -* Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron] - -* removed :piggyback in favor of just allowing :select on :through associations. [Tobias Lütke] - -* made method missing delegation to class methods on relation target work on :through associations. [Tobias Lütke] - -* made .find() work on :through relations. [Tobias Lütke] - -* Fix typo in association docs. #3296. [Blair Zajac] - -* Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Lütke] - -*1.13.2* (December 13th, 2005) - -* Become part of Rails 1.0 - -* MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper] - -* Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson]. Example: - - class Post - has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author - end - - post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors - post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors - post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors - -* Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson] - -* MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder] - -* SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com] - -* SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org] - -* SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com] - -* SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko] - -* SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com] - -* Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen] - -* MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes] - -* Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausoleil] - -* Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond] - -* PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson] - -* Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen] - -* MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper] - -* Added preliminary support for polymorphic associations [David Heinemeier Hansson] - -* Added preliminary support for join models [David Heinemeier Hansson] - -* Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.] - -* Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>] - -* Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>] - -* MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper] - -* Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen] - -* SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com] - -* Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper] - -* Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen] - -* MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda] - -* has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper] - -* MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda] - -* Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.] - -* Correct boolean handling in generated reader methods. #2945 [Don Park, Stefan Kaes] - -* Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes] - -* Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>] - -* Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>] - -* SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com] - -* SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>] - -* Correct documentation for Base.delete_all. #1568 [Newhydra] - -* Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>] - -* Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>] - -* When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper] - -* Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>] - -* Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper] - -* PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper] - -* PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper] - -* SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko] - -* Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>] - -* Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de] - -* Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>] - -* acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com] - -* Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar] - -* Fixed acts_as_list for definitions without an explicit :order #2803 [Jonathan Viney] - -* Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper] - -* Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.] - -* Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com] - -* Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper] - -* Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper] - -* More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>] - - -*1.13.0* (November 7th, 2005) - -* Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko] - -* Added :include as an option for association declarations [David Heinemeier Hansson]. Example: - - has_many :posts, :include => [ :author, :comments ] - -* Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example: - - Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do - # Find where name = ? and active=true - Comment.find :all, :conditions => ['name = ?', name] - # Create comment associated with :post_id - Comment.create :body => "Hello world" - end - -* Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko] - -* Added constrain scoping for creates using a hash of attributes bound to the :creation key [David Heinemeier Hansson]. Example: - - Comment.constrain(:creation => { :post_id => 5 }) do - # Associated with :post_id - Comment.create :body => "Hello world" - end - - This is rarely used directly, but allows for find_or_create on associations. So you can do: - - # If the tag doesn't exist, a new one is created that's associated with the person - person.tags.find_or_create_by_name("Summer") - -* Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [David Heinemeier Hansson]. Example: - - # No 'Summer' tag exists - Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") - - # Now the 'Summer' tag does exist - Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer") - -* Added extension capabilities to has_many and has_and_belongs_to_many proxies [David Heinemeier Hansson]. Example: - - class Account < ActiveRecord::Base - has_many :people do - def find_or_create_by_name(name) - first_name, *last_name = name.split - last_name = last_name.join " " - - find_or_create_by_first_name_and_last_name(first_name, last_name) - end - end - end - - person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson") - person.first_name # => "David" - person.last_name # => "Heinemeier Hansson" - - Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation). - -* Omit internal dtproperties table from SQLServer table list. #2729 [Ryan Tomayko] - -* Quote column names in generated SQL. #2728 [Ryan Tomayko] - -* Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper] - -* Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper] - -* Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>] - -* Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson] - -* Added migration support for Oracle #2647 [Michael Schoen] - -* Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>] - -* Fixed SQL Server adapter to pass even more tests and do even better #2634 [Ryan Tomayko] - -* Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward] - -* Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward] - -* Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com] - -* Constraints are cloned so they can't be inadvertently modified while they're -in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>] - -* Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com] - -* Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [Michael Schoen] - -* Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt] - - -*1.12.2* (October 26th, 2005) - -* Allow symbols to rename columns when using SQLite adapter. #2531 [Kevin Clark] - -* Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>] - -* Clarify semantics of ActiveRecord::Base#respond_to? #2560 [Stefan Kaes] - -* Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>] - -* HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>] - -* Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>] - - -*1.12.1* (October 19th, 2005) - -* Always parenthesize :conditions options so they may be safely combined with STI and constraints. - -* Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com] - -* Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations - - -*1.12.0* (October 16th, 2005) - -* Update/clean up documentation (rdoc) - -* PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>] - -* Change default logging colors to work on both white and black backgrounds. [Sam Stephenson] - -* YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net] - -* :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>] - -* Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around. - -* Avoid memleak in dev mode when using fcgi - -* Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>] - -* Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>] - -* Fix errors caused by assigning a has-one or belongs-to property to itself - -* Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson] - -* Update DB2 adapter. #2206. [contact@maik-schmidt.de] - -* Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com] - -* Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency. - -* Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>] - -* Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code] - -* Add test coverage for content_columns. #2432. [coffee2code] - -* Speed up for unthreaded environments. #2431. [Stefan Kaes] - -* Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [Stefan Kaes] - -* Speed up the setting of table_name. #2428. [Stefan Kaes] - -* Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [Stefan Kaes] - -* Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>] - -* Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [Stefan Kaes] - -* Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>] - -* Add geometric type for postgresql adapter. #2233 [Andrew Kaspick] - -* Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [Stefan Kaes] - -* Add convenience predicate methods on Column class. In partial fullfilment of #1236. [Stefan Kaes] - -* Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar] - -* Added :force option to create_table that'll try to drop the table if it already exists before creating - -* Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar] - -* Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>] - -* model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>] - -* Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman] - -* Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>] - -* Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>] - -* Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>] - -* Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>] - -* Make update_attribute use the same writer method that update_attributes uses. - #2237 [trevor@protocool.com] - -* Make migrations honor table name prefixes and suffixes. #2298 [Jakob Skjerning, Marcel Molina Jr.] - -* Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org] - -* Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com] - -* Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior) - -* Added new symbol-driven approach to activating observers with Base#observers= [David Heinemeier Hansson]. Example: - - ActiveRecord::Base.observers = :cacher, :garbage_collector - -* Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com] - -* Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck] - -* Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck] - -* Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck] - -* Fixed migrations for Windows when using more than 10 [David Naseby] - -* Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber] - -* Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Lütke] - -* Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar] - -* Fixed that Observers didn't observe sub-classes #627 [Florian Weber] - -* Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina Jr.] - -* Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae] - -* Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber] - -* Added better exception error when unknown column types are used with migrations #1814 [François Beausoleil] - -* Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com] - -* Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg] - -* Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward] - -* Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code] - -* Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net] - -* Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/ - -* Make sure the schema_info table is created before querying the current version #1903 - -* Fixtures ignore table name prefix and suffix #1987 [Jakob Skjerning] - -* Add documentation for index_type argument to add_index method for migrations #2005 [Blaine] - -* Modify read_attribute to allow a symbol argument #2024 [Ken Kunz] - -* Make destroy return self #1913 [Sebastian Kanthak] - -* Fix typo in validations documentation #1938 [court3nay] - -* Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org] - -* Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky] - -* Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com] - -* Fix create_table so that id column is implicitly added [Rick Olson] - -* Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798 - -* OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798 - -* Fixed the handling of camelCase columns names in Oracle #1798 - -* Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798 - -* Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798 - -* Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Lütke] - - class Comment < AR:B - def self.search(q) - find(:all, :conditions => ["body = ?", q]) - end - end - - class Post < AR:B - has_many :comments - end - - Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi' - - NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as - by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on - details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself - noticed :) - -* Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson] - -* Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar] - -* Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions - -* Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt] - -* Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes] - - -*1.11.1* (11 July, 2005) - -* Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olson] - -* Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com] - -* Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson] - -* Correct reflected table name for singular associations. #1688 [court3nay] - -* Fixed optimistic locking with SQL Server #1660 [tom@popdog.net] - -* Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current - -* Added better error message for "packets out of order" #1630 [court3nay] - -* Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640 - - -*1.11.0* (6 July, 2005) - -* Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar] - -* Changed logging of SQL statements to use the DEBUG level instead of INFO - -* Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Lütke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator. - -* Added callback hooks to association collections #1549 [Florian Weber]. Example: - - class Project - has_and_belongs_to_many :developers, :before_add => :evaluate_velocity - - def evaluate_velocity(developer) - ... - end - end - - ..raising an exception will cause the object not to be added (or removed, with before_remove). - - -* Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry] - -* Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato] - -* Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber] - -* Speed up ActiveRecord#method_missing for the common case (read_attribute). - -* Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [Stefan Kaes] - -* Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath] - -* Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at] - -* Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [Michael Schuerig] - -* Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry] - -* Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry] - -* Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net] - -* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl] - -* Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be: - - Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1' - - ...should instead be: - - Developer.find( - :all, - :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id', - :conditions => 'project_id=1' - ) - -* Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina Jr.] - -* Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon] - -* Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379 - -* Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid] - -* Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice - -* Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper] - -* Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak]. - Example: - - david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")] - david.save - - If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new - project is saved when david.save is called. - - Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do: - - david.project_ids = [1, 5, 7] - -* Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com] - -* Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Lütke] - -* Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org] - -* Corrected @@configurations typo #1410 [david@ruppconsulting.com] - -* Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com] - -* Allow before/after update hooks to work on models using optimistic locking - -* Eager loading of dependent has_one associations won't delete the association #1212 - -* Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it. - -* Using transactional fixtures now causes the data to be loaded only once. - -* Added fixture accessor methods that can be used when instantiated fixtures are disabled. - - fixtures :web_sites - - def test_something - assert_equal "Ruby on Rails", web_sites(:rubyonrails).name - end - -* Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar] - -* Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar] - -* CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309 - -* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead - -* Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples: - - Conditional validations such as the following are made possible: - validates_numericality_of :income, :if => :employed? - - Conditional validations can also solve the salted login generator problem: - validates_confirmation_of :password, :if => :new_password? - - Using blocks: - validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 } - -* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net] - -* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson] - -* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper] - -* Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed. - -* Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first. - -* Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example: - - # SELECT * FROM topics WHERE title IN ('First', 'Second') - Topic.find_all_by_title(["First", "Second"]) - -* Added compatibility with camelCase column names for dynamic finders #533 [Dee Zsombor] - -* Fixed extraneous comma in count() function that made it not work with joins #1156 [Jarkko Laine/Dee Zsombor] - -* Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid] - -* Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com] - -* Added encoding and min_messages options for PostgreSQL #1205 [Shugo Maeda]. Configuration example: - - development: - adapter: postgresql - database: rails_development - host: localhost - username: postgres - password: - encoding: UTF8 - min_messages: ERROR - -* Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck] - -* Added validates_exclusion_of as a negative of validates_inclusion_of - -* Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls - - -*1.10.1* (20th April, 2005) - -* Fixed frivilous database queries being triggered with eager loading on empty associations and other things - -* Fixed order of loading in eager associations - -* Fixed stray comma when using eager loading and ordering together from has_many associations #1143 - - -*1.10.0* (19th April, 2005) - -* Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example: - - for post in Post.find(:all, :limit => 100) - puts "Post: " + post.title - puts "Written by: " + post.author.name - puts "Last comment on: " + post.comments.first.created_on - end - - This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as: - - for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ]) - - ...and the number of database queries needed is now 1. - -* Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples: - - Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(:first, :order => "created_on DESC", :offset => 5) - Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50) - Person.find(:all, :offset => 10, :limit => 10) - -* Added acts_as_nested_set #1000 [wschenk]. Introduction: - - This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with - the added feature that you can select the children and all of it's descendants with - a single query. A good use case for this is a threaded post system, where you want - to display every reply to a comment without multiple selects. - -* Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [Dave Thomas] - -* Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com] - -* Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com] - -* Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com] - -* Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher] - -* Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle] - -* Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com] - -* Added insert_at(position) to acts_as_list #1083 [DeLynnB] - -* Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order) - -* Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com] - -* Fixed boolean saving on Oracle #1093 [mparrish@pearware.org] - -* Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864 - -* Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt] - -* Added quoting of column names for fixtures #997 [jcfischer@gmail.com] - -* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis] - -* Fixed that benchmarking times for rendering included db runtimes #987 [Stefan Kaes] - -* Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org] - -* Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper] - -* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org] - -* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [Stefan Kaes] - -* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [Stefan Kaes] - -* Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas] - -* Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias) - - -*1.9.1* (27th March, 2005) - -* Fixed that Active Record objects with float attribute could not be cloned #808 - -* Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar] - -* Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count - -* Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron] - -* Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb] - - -*1.9.0* (22th March, 2005) - -* Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example: - - Developer.find_all nil, 'id ASC', 5 # return the first five developers - Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward - - This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged. - -* Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson] - -* Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins] - -* Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org] - -* Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel] - -* Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid] - -* Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com] - -* Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net] - -* Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak] - -* Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak] - -* Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm] - -* Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself - -* Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body) - - -*1.8.0* (7th March, 2005) - -* Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default) - -* Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron] - -* Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation: - - * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the - +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+ - objects that should be inspected to determine which attributes triggered the errors. - * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method. - You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error. - -* Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k] - -* Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper] - -* Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example: - - class Account < ActiveRecord::Base - has_one :credit_card, :dependent => true - end - class CreditCard < ActiveRecord::Base - belongs_to :account - end - - account.credit_card # => returns existing credit card, lets say id = 12 - account.credit_card = CreditCard.create("number" => "123") - account.save # => CC with id = 12 is destroyed - - -* Added validates_numericality_of #716 [Sebastian Kanthak/Chris McGrath]. Docuemntation: - - Validates whether the value of the specified attribute is numeric by trying to convert it to - a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression - <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true). - - class Person < ActiveRecord::Base - validates_numericality_of :value, :on => :create - end - - Configuration options: - * <tt>message</tt> - A custom error message (default is: "is not a number") - * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update) - * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false) - - -* Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron] - -* Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed) - -* Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com] - - -*1.7.0* (24th February, 2005) - -* Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck] - -* Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes: - - 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple - and safe way of passing table-specific sequence information to the adapter.) - 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to - resort to some hacks to get data converted to Date or Time in Ruby. - If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the - hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time. - This is nasty - but if you use Duck Typing you'll probably not care very much. - In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is - valid - too many databases use DATE for both. - Timezones and sub-second precision on timestamps are not supported. - 3. Default values that are functions (such as "SYSDATE") are not supported. This is a - restriction of the way active record supports default values. - 4. Referential integrity constraints are not fully supported. Under at least - some circumstances, active record appears to delete parent and child records out of - sequence and out of transaction scope. (Or this may just be a problem of test setup.) - - The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/ - -* Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke] - -* Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm] - -* Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka] - -* Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar] - -* Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com] - -* Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au] - -* Fixed that find_by_* would fail when column names had numbers #670 [demetrius] - -* Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn] - - 1. Created a new columns method that is much cleaner. - 2. Corrected a problem with the select and select_all methods - that didn't account for the LIMIT clause being passed into raw SQL statements. - 3. Implemented the string_to_time method in order to create proper instances of the time class. - 4. Added logic to the simplified_type method that allows the database to specify the scale of float data. - 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string. - -* Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow] - -* Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example: - - class Person < ActiveRecord::Base - validates_each :first_name, :last_name do |record, attr| - record.errors.add attr, 'starts with z.' if attr[0] == ?z - end - end - -* Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper] - -* Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example: - - class Person < ActiveRecord::Base - validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID } - end - -* Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates] - -* Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example: - - class Project < ActiveRecord::Base - primary_key "sysid" - table_name "XYZ_PROJECT" - inheritance_column { original_inheritance_column + "_id" } - end - -* Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu] - - -*1.6.0* (January 25th, 2005) - -* Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once. - -* Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336 - -* Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once. - -* Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example - - people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} } - Person.update(people.keys, people.values) - -* Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron] - -* Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat] - -* Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius] - -* Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper] - -* Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson] - -* Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson] - -* Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not - -* Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription - -* Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius] - -* Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron] - - -*1.5.1* (January 18th, 2005) - -* Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates] - -* Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle] - - -*1.5.0* (January 17th, 2005) - -* Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel] - -* Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example: - - class Book < ActiveRecord::Base - has_many :pages - belongs_to :library - - validates_associated :pages, :library - end - -* Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition: - - == Unsaved objects and associations - - You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be - aware of, mostly involving the saving of associated objects. - - === One-to-one associations - - * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in - order to update their primary keys - except if the parent object is unsaved (new_record? == true). - * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment - is cancelled. - * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below). - * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does - not save the parent either. - - === Collections - - * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object - (the owner of the collection) is not yet stored in the database. - * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false. - * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below). - * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved. - -* Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates] - -* Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates] - -* Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates] - -* Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates] - -* Fixed binary support for PostgreSQL #444 [alex@byzantine.no] - -* Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the - collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If - it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards, - it'll take one less SELECT query if you use length. - -* Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de] - -* Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson] - -* Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey] - -* Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz] - -* Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper] - -* Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower] - -* Added that Observers can use the observes class method instead of overwriting self.observed_class(). - - Before: - class ListSweeper < ActiveRecord::Base - def self.observed_class() [ List, Item ] - end - - After: - class ListSweeper < ActiveRecord::Base - observes List, Item - end - -* Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is - -* Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name - -* Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag. - - Before: topic.update_attribute(:approved, !approved?) - After : topic.toggle!(:approved) - -* Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example: - - page.views # => 1 - page.increment!(:views) # executes an UPDATE statement - page.views # => 2 - - page.increment(:views).increment!(:views) - page.views # => 4 - -* Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns. - - - - -*1.14.2* (April 9th, 2005) - -* Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen] - - -*1.14.1* (April 6th, 2006) - -* Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar] - -* Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind] - -* Enable Limit/Offset in Calculations (closes #4558) [lmarlow] - -* Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick Olson] - -* Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr] - -* Allow AR::Base#respond_to? to behave when @attributes is nil [Ryan Davis] - -* Support eager includes when going through a polymorphic has_many association. [Rick Olson] - -* Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick Olson] - - class Post < ActiveRecord::Base - has_one :tagging, :as => :taggable - end - - Post.find :all, :include => :tagging - -* Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick Olson] - -* Added support for going through a polymorphic has_many association: (closes #4401) [Rick Olson] - - class PhotoCollection < ActiveRecord::Base - has_many :photos, :as => :photographic - belongs_to :firm - end - - class Firm < ActiveRecord::Base - has_many :photo_collections - has_many :photos, :through => :photo_collections - end - -* Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com] - -* Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber] - -* Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan] - -* Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick Olson] - -* DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [David Heinemeier Hansson] - -* Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [David Heinemeier Hansson] - -* Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.] - -* Fixed broken OCIAdapter #4457 [Michael Schoen] - - -*1.14.0* (March 27th, 2006) - -* Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar] - -* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick Olson] - -* Add support for :include to with_scope [andrew@redlinesoftware.com] - -* Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [Michael Schoen] - -* Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com] - -* Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick Olson] - -* Fixed issue that kept :select options from being scoped [Rick Olson] - -* Fixed db_schema_import when binary types are present #3101 [David Heinemeier Hansson] - -* Fixed that MySQL enums should always be returned as strings #3501 [David Heinemeier Hansson] - -* Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson] - - class Connection < ActiveRecord::Base - belongs_to :user - belongs_to :channel - end - - class Channel < ActiveRecord::Base - has_many :connections - has_many :contacts, :through => :connections, :class_name => 'User' # OLD - has_many :contacts, :through => :connections, :source => :user # NEW - end - -* Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de] - -* Allow overriding of find parameters in scoped has_many :through calls [Rick Olson] - - In this example, :include => false disables the default eager association from loading. :select changes the standard - select clause. :joins specifies a join that is added to the end of the has_many :through query. - - class Post < ActiveRecord::Base - has_many :tags, :through => :taggings, :include => :tagging do - def add_joins_and_select - find :all, :select => 'tags.*, authors.id as author_id', :include => false, - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id' - end - end - end - -* Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson] - -* Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [Jonathan Viney] - -* Quit ignoring default :include options in has_many :through calls [Mark James] - -* Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [Jonathan Viney] - -* Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson] - -* Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example: - - class Firm < ActiveRecord::Base - has_many :clients - has_many :invoices, :through => :clients - end - - class Client < ActiveRecord::Base - belongs_to :firm - has_many :invoices - end - - class Invoice < ActiveRecord::Base - belongs_to :client - end - -* Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [Josh Susser] - -* Fixed has_many :through to include :conditions set on the :through association. closes #4020 [Jonathan Viney] - -* Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick Olson] - -* SQL Server adapter gets some love #4298 [Ryan Tomayko] - -* Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com] - -* Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI): - - Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body') - -* Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick Olson] - -* Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Michael Koziarski] - -* Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Michael Koziarski] - -* Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom Ward] - -* Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com] - -* Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck] - -* Use association's :conditions when eager loading. [Jeremy Evans] #4144 - -* Alias the has_and_belongs_to_many join table on eager includes. #4106 [Jeremy Evans] - - This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous. - - Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL') - -* Oracle adapter gets some love #4230 [Michael Schoen] - - * Changes :text to CLOB rather than BLOB [Moses Hohman] - * Fixes an issue with nil numeric length/scales (several) - * Implements support for XMLTYPE columns [wilig / Kubo Takehiro] - * Tweaks a unit test to get it all green again - * Adds support for #current_database - -* Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson] - - class CachedModel < ActiveRecord::Base - self.abstract_class = true - end - - class Post < CachedModel - end - - CachedModel.abstract_class? - => true - - Post.abstract_class? - => false - - Post.base_class - => Post - - Post.table_name - => 'posts' - -* Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson] - - class Foo < ActiveRecord::Base - has_many :attachments, :as => :attachable, :dependent => :delete_all - end - -* Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay] - -* Upgrade to Transaction::Simple 1.3 [Jamis Buck] - -* Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson] - -* Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com] - -* Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com] - -* Dynamically set allow_concurrency. #4044 [Stefan Kaes] - -* Added Base#to_xml that'll turn the current record into a XML representation [David Heinemeier Hansson]. Example: - - topic.to_xml - - ...returns: - - <?xml version="1.0" encoding="UTF-8"?> - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <id type="integer">1</id> - <approved type="boolean">false</approved> - <replies-count type="integer">0</replies-count> - <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time> - <written-on type="datetime">2003-07-16 09:28:00</written-on> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - ...and you can configure with: - - topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ]) - - ...that'll return: - - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <approved type="boolean">false</approved> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - You can even do load first-level associations as part of the document: - - firm.to_xml :include => [ :account, :clients ] - - ...that'll return something like: - - <?xml version="1.0" encoding="UTF-8"?> - <firm> - <id type="integer">1</id> - <rating type="integer">1</rating> - <name>37signals</name> - <clients> - <client> - <rating type="integer">1</rating> - <name>Summit</name> - </client> - <client> - <rating type="integer">1</rating> - <name>Microsoft</name> - </client> - </clients> - <account> - <id type="integer">1</id> - <credit-limit type="integer">50</credit-limit> - </account> - </firm> - -* Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck] - -* Documentation fixes for :dependent [robby@planetargon.com] - -* Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney] - -* Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org] - -* Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson] - -* Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>] - -* Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson] - - * The first time a table is referenced in a join, no alias is used. - * After that, the parent class name and the reflection name are used. - - Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ... - - * Any additional join references get a numerical suffix like '_2', '_3', etc. - -* Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to. - -* Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples: - - # cascaded in two levels - >> Author.find(:all, :include=>{:posts=>:comments}) - => authors - +- posts - +- comments - - # cascaded in two levels and normal association - >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations]) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in two levels with two has_many associations - >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in three levels - >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}}) - => companies - +- groups - +- members - +- favorites - -* Make counter cache work when replacing an association #3245 [eugenol@gmail.com] - -* Make migrations verbose [Jamis Buck] - -* Make counter_cache work with polymorphic belongs_to [Jamis Buck] - -* Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp] - -* Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats: - - * Does not support DATE SQL column types; use DATETIME instead. - * Date columns on HABTM join tables are returned as String, not Time. - * Insertions are potentially broken for :polymorphic join tables - * BLOB column access not yet fully supported - -* Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper] - -* CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper] - -* Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [Michael Schoen] - -* Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [David Heinemeier Hansson] - -* Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes] - -* Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark] - -* Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net] - -* Define attribute query methods to avoid method_missing calls. #3677 [Jonathan Viney] - -* ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward] - -* Added support for nested scopes #3407 [anna@wota.jp]. Examples: - - Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10 - - # inner rule is used. (all previous parameters are ignored) - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis') - end - - # parameters are merged - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10 - end - end - -* Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com] - -* Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh] - -* Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [Lars Pind] - -* Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples: - - Person.average :age - Person.minimum :age - Person.maximum :age - Person.sum :salary, :group => :last_name - -* Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [Luke Redpath] - -* Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper] - -* Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net] - -* Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de] - -* Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [Stefan Kaes] - -* Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva] - -* Allow :include to be used with has_many :through associations #3611 [Michael Schoen] - -* PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac] - -* SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward] - -* Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson] - -* PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org] - -* Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark] - -* ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Lütke] - -* Using AssociationCollection#build with arrays of hashes should call build, not create [David Heinemeier Hansson] - -* Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar] - -* Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt] - -* Support the :column option for remove_index with the PostgreSQL adapter. #3661 [Shugo Maeda] - -* Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>] - -* If the OCI library is not available, raise an exception indicating as much. #3593 [Michael Schoen] - -* Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson] - -* Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.] - -* Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar] - -* Make .count work for has_many associations with multi line finder sql [Michael Schoen] - -* Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck] - -* Allow configuration of the column used for optimistic locking [wilsonb@gmail.com] - -* Don't hardcode 'id' in acts as list. [ror@philippeapril.com] - -* Fix date errors for SQLServer in association tests. #3406 [Kevin Clark] - -* Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp] - -* Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com] - -* .with_scope imposed create parameters now bypass attr_protected [Tobias Lütke] - -* Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.] - -* Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de] - -* Sanitize scoped conditions. [Marcel Molina Jr.] - -* Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [David Heinemeier Hansson] - -* Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [Tobias Lütke] - -* SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [Tobias Lütke] - -* Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber] - -* Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron] - -* removed :piggyback in favor of just allowing :select on :through associations. [Tobias Lütke] - -* made method missing delegation to class methods on relation target work on :through associations. [Tobias Lütke] - -* made .find() work on :through relations. [Tobias Lütke] - -* Fix typo in association docs. #3296. [Blair Zajac] - -* Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Lütke] - -*1.13.2* (December 13th, 2005) - -* Become part of Rails 1.0 - -* MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper] - -* Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson]. Example: - - class Post - has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author - end - - post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors - post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors - post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors - -* Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson] - -* MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder] - -* SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com] - -* SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org] - -* SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com] - -* SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko] - -* SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com] - -* Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen] - -* MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes] - -* Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausoleil] - -* Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond] - -* PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson] - -* Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen] - -* MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper] - -* Added preliminary support for polymorphic associations [David Heinemeier Hansson] - -* Added preliminary support for join models [David Heinemeier Hansson] - -* Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.] - -* Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>] - -* Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>] - -* MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper] - -* Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen] - -* SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com] - -* Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper] - -* Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen] - -* MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda] - -* has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper] - -* MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda] - -* Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.] - -* Correct boolean handling in generated reader methods. #2945 [Don Park, Stefan Kaes] - -* Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes] - -* Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>] - -* Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>] - -* SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com] - -* SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>] - -* Correct documentation for Base.delete_all. #1568 [Newhydra] - -* Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>] - -* Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>] - -* When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper] - -* Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>] - -* Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper] - -* PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper] - -* PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper] - -* SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko] - -* Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>] - -* Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de] - -* Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>] - -* acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com] - -* Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar] - -* Fixed acts_as_list for definitions without an explicit :order #2803 [Jonathan Viney] - -* Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper] - -* Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.] - -* Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com] - -* Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper] - -* Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper] - -* More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>] - - -*1.13.0* (November 7th, 2005) - -* Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko] - -* Added :include as an option for association declarations [David Heinemeier Hansson]. Example: - - has_many :posts, :include => [ :author, :comments ] - -* Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example: - - Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do - # Find where name = ? and active=true - Comment.find :all, :conditions => ['name = ?', name] - # Create comment associated with :post_id - Comment.create :body => "Hello world" - end - -* Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko] - -* Added constrain scoping for creates using a hash of attributes bound to the :creation key [David Heinemeier Hansson]. Example: - - Comment.constrain(:creation => { :post_id => 5 }) do - # Associated with :post_id - Comment.create :body => "Hello world" - end - - This is rarely used directly, but allows for find_or_create on associations. So you can do: - - # If the tag doesn't exist, a new one is created that's associated with the person - person.tags.find_or_create_by_name("Summer") - -* Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [David Heinemeier Hansson]. Example: - - # No 'Summer' tag exists - Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") - - # Now the 'Summer' tag does exist - Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer") - -* Added extension capabilities to has_many and has_and_belongs_to_many proxies [David Heinemeier Hansson]. Example: - - class Account < ActiveRecord::Base - has_many :people do - def find_or_create_by_name(name) - first_name, *last_name = name.split - last_name = last_name.join " " - - find_or_create_by_first_name_and_last_name(first_name, last_name) - end - end - end - - person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson") - person.first_name # => "David" - person.last_name # => "Heinemeier Hansson" - - Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation). - -* Omit internal dtproperties table from SQLServer table list. #2729 [Ryan Tomayko] - -* Quote column names in generated SQL. #2728 [Ryan Tomayko] - -* Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper] - -* Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper] - -* Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>] - -* Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson] - -* Added migration support for Oracle #2647 [Michael Schoen] - -* Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>] - -* Fixed SQL Server adapter to pass even more tests and do even better #2634 [Ryan Tomayko] - -* Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward] - -* Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward] - -* Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com] - -* Constraints are cloned so they can't be inadvertently modified while they're -in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>] - -* Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com] - -* Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [Michael Schoen] - -* Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt] - - -*1.12.2* (October 26th, 2005) - -* Allow symbols to rename columns when using SQLite adapter. #2531 [Kevin Clark] - -* Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>] - -* Clarify semantics of ActiveRecord::Base#respond_to? #2560 [Stefan Kaes] - -* Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>] - -* HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>] - -* Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>] - - -*1.12.1* (October 19th, 2005) - -* Always parenthesize :conditions options so they may be safely combined with STI and constraints. - -* Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com] - -* Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations - - -*1.12.0* (October 16th, 2005) - -* Update/clean up documentation (rdoc) - -* PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>] - -* Change default logging colors to work on both white and black backgrounds. [Sam Stephenson] - -* YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net] - -* :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>] - -* Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around. - -* Avoid memleak in dev mode when using fcgi - -* Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>] - -* Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>] - -* Fix errors caused by assigning a has-one or belongs-to property to itself - -* Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson] - -* Update DB2 adapter. #2206. [contact@maik-schmidt.de] - -* Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com] - -* Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency. - -* Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>] - -* Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code] - -* Add test coverage for content_columns. #2432. [coffee2code] - -* Speed up for unthreaded environments. #2431. [Stefan Kaes] - -* Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [Stefan Kaes] - -* Speed up the setting of table_name. #2428. [Stefan Kaes] - -* Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [Stefan Kaes] - -* Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>] - -* Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [Stefan Kaes] - -* Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>] - -* Add geometric type for postgresql adapter. #2233 [Andrew Kaspick] - -* Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [Stefan Kaes] - -* Add convenience predicate methods on Column class. In partial fullfilment of #1236. [Stefan Kaes] - -* Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar] - -* Added :force option to create_table that'll try to drop the table if it already exists before creating - -* Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar] - -* Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>] - -* model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>] - -* Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman] - -* Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>] - -* Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>] - -* Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>] - -* Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>] - -* Make update_attribute use the same writer method that update_attributes uses. - #2237 [trevor@protocool.com] - -* Make migrations honor table name prefixes and suffixes. #2298 [Jakob Skjerning, Marcel Molina Jr.] - -* Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org] - -* Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com] - -* Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior) - -* Added new symbol-driven approach to activating observers with Base#observers= [David Heinemeier Hansson]. Example: - - ActiveRecord::Base.observers = :cacher, :garbage_collector - -* Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com] - -* Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck] - -* Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck] - -* Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck] - -* Fixed migrations for Windows when using more than 10 [David Naseby] - -* Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber] - -* Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Lütke] - -* Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar] - -* Fixed that Observers didn't observe sub-classes #627 [Florian Weber] - -* Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina Jr.] - -* Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae] - -* Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber] - -* Added better exception error when unknown column types are used with migrations #1814 [François Beausoleil] - -* Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com] - -* Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg] - -* Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward] - -* Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code] - -* Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net] - -* Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/ - -* Make sure the schema_info table is created before querying the current version #1903 - -* Fixtures ignore table name prefix and suffix #1987 [Jakob Skjerning] - -* Add documentation for index_type argument to add_index method for migrations #2005 [Blaine] - -* Modify read_attribute to allow a symbol argument #2024 [Ken Kunz] - -* Make destroy return self #1913 [Sebastian Kanthak] - -* Fix typo in validations documentation #1938 [court3nay] - -* Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org] - -* Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky] - -* Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com] - -* Fix create_table so that id column is implicitly added [Rick Olson] - -* Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798 - -* OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798 - -* Fixed the handling of camelCase columns names in Oracle #1798 - -* Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798 - -* Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798 - -* Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Lütke] - - class Comment < AR:B - def self.search(q) - find(:all, :conditions => ["body = ?", q]) - end - end - - class Post < AR:B - has_many :comments - end - - Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi' - - NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as - by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on - details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself - noticed :) - -* Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson] - -* Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar] - -* Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions - -* Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt] - -* Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes] - - -*1.11.1* (11 July, 2005) - -* Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olson] - -* Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com] - -* Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson] - -* Correct reflected table name for singular associations. #1688 [court3nay] - -* Fixed optimistic locking with SQL Server #1660 [tom@popdog.net] - -* Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current - -* Added better error message for "packets out of order" #1630 [court3nay] - -* Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640 - - -*1.11.0* (6 July, 2005) - -* Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar] - -* Changed logging of SQL statements to use the DEBUG level instead of INFO - -* Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Lütke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator. - -* Added callback hooks to association collections #1549 [Florian Weber]. Example: - - class Project - has_and_belongs_to_many :developers, :before_add => :evaluate_velocity - - def evaluate_velocity(developer) - ... - end - end - - ..raising an exception will cause the object not to be added (or removed, with before_remove). - - -* Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry] - -* Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato] - -* Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber] - -* Speed up ActiveRecord#method_missing for the common case (read_attribute). - -* Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [Stefan Kaes] - -* Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath] - -* Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at] - -* Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [Michael Schuerig] - -* Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry] - -* Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry] - -* Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net] - -* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl] - -* Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be: - - Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1' - - ...should instead be: - - Developer.find( - :all, - :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id', - :conditions => 'project_id=1' - ) - -* Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina Jr.] - -* Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon] - -* Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379 - -* Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid] - -* Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice - -* Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper] - -* Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak]. - Example: - - david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")] - david.save - - If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new - project is saved when david.save is called. - - Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do: - - david.project_ids = [1, 5, 7] - -* Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com] - -* Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Lütke] - -* Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org] - -* Corrected @@configurations typo #1410 [david@ruppconsulting.com] - -* Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com] - -* Allow before/after update hooks to work on models using optimistic locking - -* Eager loading of dependent has_one associations won't delete the association #1212 - -* Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it. - -* Using transactional fixtures now causes the data to be loaded only once. - -* Added fixture accessor methods that can be used when instantiated fixtures are disabled. - - fixtures :web_sites - - def test_something - assert_equal "Ruby on Rails", web_sites(:rubyonrails).name - end - -* Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar] - -* Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar] - -* CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309 - -* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead - -* Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples: - - Conditional validations such as the following are made possible: - validates_numericality_of :income, :if => :employed? - - Conditional validations can also solve the salted login generator problem: - validates_confirmation_of :password, :if => :new_password? - - Using blocks: - validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 } - -* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net] - -* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson] - -* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper] - -* Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed. - -* Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first. - -* Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example: - - # SELECT * FROM topics WHERE title IN ('First', 'Second') - Topic.find_all_by_title(["First", "Second"]) - -* Added compatibility with camelCase column names for dynamic finders #533 [Dee Zsombor] - -* Fixed extraneous comma in count() function that made it not work with joins #1156 [Jarkko Laine/Dee Zsombor] - -* Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid] - -* Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com] - -* Added encoding and min_messages options for PostgreSQL #1205 [Shugo Maeda]. Configuration example: - - development: - adapter: postgresql - database: rails_development - host: localhost - username: postgres - password: - encoding: UTF8 - min_messages: ERROR - -* Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck] - -* Added validates_exclusion_of as a negative of validates_inclusion_of - -* Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls - - -*1.10.1* (20th April, 2005) - -* Fixed frivilous database queries being triggered with eager loading on empty associations and other things - -* Fixed order of loading in eager associations - -* Fixed stray comma when using eager loading and ordering together from has_many associations #1143 - - -*1.10.0* (19th April, 2005) - -* Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example: - - for post in Post.find(:all, :limit => 100) - puts "Post: " + post.title - puts "Written by: " + post.author.name - puts "Last comment on: " + post.comments.first.created_on - end - - This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as: - - for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ]) - - ...and the number of database queries needed is now 1. - -* Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples: - - Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(:first, :order => "created_on DESC", :offset => 5) - Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50) - Person.find(:all, :offset => 10, :limit => 10) - -* Added acts_as_nested_set #1000 [wschenk]. Introduction: - - This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with - the added feature that you can select the children and all of it's descendants with - a single query. A good use case for this is a threaded post system, where you want - to display every reply to a comment without multiple selects. - -* Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [Dave Thomas] - -* Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com] - -* Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com] - -* Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com] - -* Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher] - -* Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle] - -* Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com] - -* Added insert_at(position) to acts_as_list #1083 [DeLynnB] - -* Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order) - -* Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com] - -* Fixed boolean saving on Oracle #1093 [mparrish@pearware.org] - -* Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864 - -* Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt] - -* Added quoting of column names for fixtures #997 [jcfischer@gmail.com] - -* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis] - -* Fixed that benchmarking times for rendering included db runtimes #987 [Stefan Kaes] - -* Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org] - -* Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper] - -* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org] - -* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [Stefan Kaes] - -* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [Stefan Kaes] - -* Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas] - -* Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias) - - -*1.9.1* (27th March, 2005) - -* Fixed that Active Record objects with float attribute could not be cloned #808 - -* Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar] - -* Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count - -* Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron] - -* Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb] - - -*1.9.0* (22th March, 2005) - -* Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example: - - Developer.find_all nil, 'id ASC', 5 # return the first five developers - Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward - - This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged. - -* Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson] - -* Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins] - -* Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org] - -* Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel] - -* Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid] - -* Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com] - -* Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net] - -* Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak] - -* Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak] - -* Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm] - -* Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself - -* Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body) - - -*1.8.0* (7th March, 2005) - -* Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default) - -* Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron] - -* Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation: - - * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the - +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+ - objects that should be inspected to determine which attributes triggered the errors. - * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method. - You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error. - -* Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k] - -* Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper] - -* Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example: - - class Account < ActiveRecord::Base - has_one :credit_card, :dependent => true - end - class CreditCard < ActiveRecord::Base - belongs_to :account - end - - account.credit_card # => returns existing credit card, lets say id = 12 - account.credit_card = CreditCard.create("number" => "123") - account.save # => CC with id = 12 is destroyed - - -* Added validates_numericality_of #716 [Sebastian Kanthak/Chris McGrath]. Docuemntation: - - Validates whether the value of the specified attribute is numeric by trying to convert it to - a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression - <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true). - - class Person < ActiveRecord::Base - validates_numericality_of :value, :on => :create - end - - Configuration options: - * <tt>message</tt> - A custom error message (default is: "is not a number") - * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update) - * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false) - - -* Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron] - -* Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed) - -* Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com] - - -*1.7.0* (24th February, 2005) - -* Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck] - -* Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes: - - 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple - and safe way of passing table-specific sequence information to the adapter.) - 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to - resort to some hacks to get data converted to Date or Time in Ruby. - If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the - hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time. - This is nasty - but if you use Duck Typing you'll probably not care very much. - In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is - valid - too many databases use DATE for both. - Timezones and sub-second precision on timestamps are not supported. - 3. Default values that are functions (such as "SYSDATE") are not supported. This is a - restriction of the way active record supports default values. - 4. Referential integrity constraints are not fully supported. Under at least - some circumstances, active record appears to delete parent and child records out of - sequence and out of transaction scope. (Or this may just be a problem of test setup.) - - The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/ - -* Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke] - -* Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm] - -* Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka] - -* Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar] - -* Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com] - -* Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au] - -* Fixed that find_by_* would fail when column names had numbers #670 [demetrius] - -* Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn] - - 1. Created a new columns method that is much cleaner. - 2. Corrected a problem with the select and select_all methods - that didn't account for the LIMIT clause being passed into raw SQL statements. - 3. Implemented the string_to_time method in order to create proper instances of the time class. - 4. Added logic to the simplified_type method that allows the database to specify the scale of float data. - 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string. - -* Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow] - -* Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example: - - class Person < ActiveRecord::Base - validates_each :first_name, :last_name do |record, attr| - record.errors.add attr, 'starts with z.' if attr[0] == ?z - end - end - -* Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper] - -* Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example: - - class Person < ActiveRecord::Base - validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID } - end - -* Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates] - -* Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example: - - class Project < ActiveRecord::Base - primary_key "sysid" - table_name "XYZ_PROJECT" - inheritance_column { original_inheritance_column + "_id" } - end - -* Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu] - - -*1.6.0* (January 25th, 2005) - -* Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once. - -* Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336 - -* Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once. - -* Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example - - people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} } - Person.update(people.keys, people.values) - -* Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron] - -* Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat] - -* Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius] - -* Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper] - -* Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson] - -* Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson] - -* Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not - -* Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription - -* Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius] - -* Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron] - - -*1.5.1* (January 18th, 2005) - -* Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates] - -* Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle] - - -*1.5.0* (January 17th, 2005) - -* Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel] - -* Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example: - - class Book < ActiveRecord::Base - has_many :pages - belongs_to :library - - validates_associated :pages, :library - end - -* Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition: - - == Unsaved objects and associations - - You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be - aware of, mostly involving the saving of associated objects. - - === One-to-one associations - - * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in - order to update their primary keys - except if the parent object is unsaved (new_record? == true). - * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment - is cancelled. - * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below). - * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does - not save the parent either. - - === Collections - - * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object - (the owner of the collection) is not yet stored in the database. - * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false. - * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below). - * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved. - -* Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates] - -* Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates] - -* Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates] - -* Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates] - -* Fixed binary support for PostgreSQL #444 [alex@byzantine.no] - -* Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the - collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If - it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards, - it'll take one less SELECT query if you use length. - -* Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de] - -* Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson] - -* Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey] - -* Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz] - -* Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper] - -* Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower] - -* Added that Observers can use the observes class method instead of overwriting self.observed_class(). - - Before: - class ListSweeper < ActiveRecord::Base - def self.observed_class() [ List, Item ] - end - - After: - class ListSweeper < ActiveRecord::Base - observes List, Item - end - -* Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is - -* Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name - -* Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag. - - Before: topic.update_attribute(:approved, !approved?) - After : topic.toggle!(:approved) - -* Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example: - - page.views # => 1 - page.increment!(:views) # executes an UPDATE statement - page.views # => 2 - - page.increment(:views).increment!(:views) - page.views # => 4 - -* Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns. - - -*1.4.0* (January 4th, 2005) - -* Added automated optimistic locking if the field <tt>lock_version</tt> is present. Each update to the - record increments the lock_version column and the locking facilities ensure that records instantiated twice - will let the last one saved raise a StaleObjectError if the first was also updated. Example: - - p1 = Person.find(1) - p2 = Person.find(1) - - p1.first_name = "Michael" - p1.save - - p2.first_name = "should fail" - p2.save # Raises a ActiveRecord::StaleObjectError - - You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging, - or otherwise apply the business logic needed to resolve the conflict. - - #384 [Michael Koziarski] - -* Added dynamic attribute-based finders as a cleaner way of getting objects by simple queries without turning to SQL. - They work by appending the name of an attribute to <tt>find_by_</tt>, so you get finders like <tt>Person.find_by_user_name, - Payment.find_by_transaction_id</tt>. So instead of writing <tt>Person.find_first(["user_name = ?", user_name])</tt>, you just do - <tt>Person.find_by_user_name(user_name)</tt>. - - It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like - <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing - <tt>Person.find_first(["user_name = ? AND password = ?", user_name, password])</tt>, you just do - <tt>Person.find_by_user_name_and_password(user_name, password)</tt>. - - While primarily a construct for easier find_firsts, it can also be used as a construct for find_all by using calls like - <tt>Payment.find_all_by_amount(50)</tt> that is turned into <tt>Payment.find_all(["amount = ?", 50])</tt>. This is something not as equally useful, - though, as it's not possible to specify the order in which the objects are returned. - -* Added block-style for callbacks #332 [Jeremy Kemper]. - - Before: - before_destroy(Proc.new{ |record| Person.destroy_all "firm_id = #{record.id}" }) - - After: - before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" } - -* Added :counter_cache option to acts_as_tree that works just like the one you can define on belongs_to #371 [Josh Peek] - -* Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates - and times from the database. This is set to :local by default. - -* Added the possibility for adapters to overwrite add_limit! to implement a different limiting scheme than "LIMIT X" used by MySQL, PostgreSQL, and SQLite. - -* Added the possibility of having objects with acts_as_list created before their scope is available or... - -* Added a db2 adapter that only depends on the Ruby/DB2 bindings (http://raa.ruby-lang.org/project/ruby-db2/) #386 [Maik Schmidt] - -* Added the final touches to the Microsoft SQL Server adapter by Joey Gibson that makes it suitable for actual use #394 [DeLynn Barry] - -* Added that Base#find takes an optional options hash, including :conditions. Base#find_on_conditions deprecated in favor of #find with :conditions #407 [Jeremy Kemper] - -* Added HasManyAssociation#count that works like Base#count #413 [intinig] - -* Fixed handling of binary content in blobs and similar fields for Ruby/MySQL and SQLite #409 [xal] - -* Fixed a bug in the Ruby/MySQL that caused binary content to be escaped badly and come back mangled #405 [Tobias Lütke] - -* Fixed that the const_missing autoload assumes the requested constant is set by require_association and calls const_get to retrieve it. - If require_association did not set the constant then const_get will call const_missing, resulting in an infinite loop #380 [Jeremy Kemper] - -* Fixed broken transactions that were actually only running object-level and not db level transactions [andreas] - -* Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406 - -* Fixed that the overwritten respond_to? method didn't take two parameters like the original #391 - -* Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin] - - -*1.3.0* (December 23, 2004) - -* Added a require_association hook on const_missing that makes it possible to use any model class without requiring it first. This makes STI look like: - - before: - require_association 'person' - class Employee < Person - end - - after: - class Employee < Person - end - - This also reduces the usefulness of Controller.model in Action Pack to currently only being for documentation purposes. - -* Added that Base.update_all and Base.delete_all return an integer of the number of affected rows #341 - -* Added scope option to validation_uniqueness #349 [Kent Sibilev] - -* Added respondence to *_before_type_cast for all attributes to return their string-state before they were type casted by the column type. - This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100". - -* Added allow_nil options to validates_inclusion_of so that validation is only triggered if the attribute is not nil [what-a-day] - -* Added work-around for PostgreSQL and the problem of getting fixtures to be created from id 1 on each test case. - This only works for auto-incrementing primary keys called "id" for now #359 [Scott Baron] - -* Added Base#clear_association_cache to empty all the cached associations #347 [Tobias Lütke] - -* Added more informative exceptions in establish_connection #356 [Jeremy Kemper] - -* Added Base#update_attributes that'll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise). - - Before: - person.attributes = @params["person"] - person.save - - Now: - person.update_attributes(@params["person"]) - -* Added Base.destroy and Base.delete to remove records without holding a reference to them first. - -* Added that query benchmarking will only happen if its going to be logged anyway #344 - -* Added higher_item and lower_item as public methods for acts_as_list #342 [Tobias Lütke] - -* Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [Jeremy Kemper] - -* Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used - the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten] - -* Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz] - -* Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction. - If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction - bubble up even when you've dealt with local issues. Closes #231 and #340. - -* Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy@gmail.com] - -* Changed the interface on AbstractAdapter to require that adapters return the number of affected rows on delete and update operations. - -* Fixed the automated timestamping feature when running under Rails' development environment that resets the inheritable attributes on each request. - - - -*1.2.0* - -* Added Base.validates_inclusion_of that validates whether the value of the specified attribute is available in a particular enumerable - object. [what-a-day] - - class Person < ActiveRecord::Base - validates_inclusion_of :gender, :in=>%w( m f ), :message=>"woah! what are you then!??!!" - validates_inclusion_of :age, :in=>0..99 - end - -* Added acts_as_list that can decorates an existing class with methods like move_higher/lower, move_to_top/bottom. [Tobias Lütke] Example: - - class TodoItem < ActiveRecord::Base - acts_as_list :scope => :todo_list_id - belongs_to :todo_list - end - -* Added acts_as_tree that can decorates an existing class with a many to many relationship with itself. Perfect for categories in - categories and the likes. [Tobias Lütke] - -* Added that Active Records will automatically record creation and/or update timestamps of database objects if fields of the names - created_at/created_on or updated_at/updated_on are present. [Tobias Lütke] - -* Added Base.default_error_messages as a hash of all the error messages used in the validates_*_of so they can be changed in one place [Tobias Lütke] - -* Added automatic transaction block around AssociationCollection.<<, AssociationCollection.delete, and AssociationCollection.destroy_all - -* Fixed that Base#find will return an array if given an array -- regardless of the number of elements #270 [Marten] - -* Fixed that has_and_belongs_to_many would generate bad sql when naming conventions differed from using vanilla "id" everywhere [RedTerror] - -* Added a better exception for when a type column is used in a table without the intention of triggering single-table inheritance. Example: - - ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'bad_class!'. - This error is raised because the column 'type' is reserved for storing the class in case of inheritance. - Please rename this column if you didn't intend it to be used for storing the inheritance class or - overwrite Company.inheritance_column to use another column for that information. - -* Added that single-table inheritance will only kick in if the inheritance_column (by default "type") is present. Otherwise, inheritance won't - have any magic side effects. - -* Added the possibility of marking fields as being in error without adding a message (using nil) to it that'll get displayed wth full_messages #208 [mjobin] - -* Fixed Base.errors to be indifferent as to whether strings or symbols are used. Examples: - - Before: - errors.add(:name, "must be shorter") if name.size > 10 - errors.on(:name) # => "must be shorter" - errors.on("name") # => nil - - After: - errors.add(:name, "must be shorter") if name.size > 10 - errors.on(:name) # => "must be shorter" - errors.on("name") # => "must be shorter" - -* Added Base.validates_format_of that Validates whether the value of the specified attribute is of the correct form by matching - it against the regular expression provided. [Marcel Molina Jr.] - - class Person < ActiveRecord::Base - validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :on => :create - end - -* Added Base.validates_length_of that delegates to add_on_boundary_breaking #312 [Tobias Lütke]. Example: - - Validates that the specified attribute matches the length restrictions supplied in either: - - - configuration[:minimum] - - configuration[:maximum] - - configuration[:is] - - configuration[:within] (aka. configuration[:in]) - - Only one option can be used at a time. - - class Person < ActiveRecord::Base - validates_length_of :first_name, :maximum=>30 - validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don't mind" - validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name" - validates_length_of :fav_bra_size, :minimum=>1, :too_short=>"please enter at least %d character" - validates_length_of :smurf_leader, :is=>4, :message=>"papa is spelled with %d characters... don't play me." - end - -* Added Base.validate_presence as an alternative to implementing validate and doing errors.add_on_empty yourself. - -* Added Base.validates_uniqueness_of that alidates whether the value of the specified attributes are unique across the system. - Useful for making sure that only one user can be named "davidhh". - - class Person < ActiveRecord::Base - validates_uniqueness_of :user_name - end - - When the record is created, a check is performed to make sure that no record exist in the database with the given value for the specified - attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. - - -* Added Base.validates_confirmation_of that encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example: - - Model: - class Person < ActiveRecord::Base - validates_confirmation_of :password - end - - View: - <%= password_field "person", "password" %> - <%= password_field "person", "password_confirmation" %> - - The person has to already have a password attribute (a column in the people table), but the password_confirmation is virtual. - It exists only as an in-memory variable for validating the password. This check is performed both on create and update. - - -* Added Base.validates_acceptance_of that encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example: - - class Person < ActiveRecord::Base - validates_acceptance_of :terms_of_service - end - - The terms_of_service attribute is entirely virtual. No database column is needed. This check is performed both on create and update. - - NOTE: The agreement is considered valid if it's set to the string "1". This makes it easy to relate it to an HTML checkbox. - - -* Added validation macros to make the stackable just like the lifecycle callbacks. Examples: - - class Person < ActiveRecord::Base - validate { |record| record.errors.add("name", "too short") unless name.size > 10 } - validate { |record| record.errors.add("name", "too long") unless name.size < 20 } - validate_on_create :validate_password - - private - def validate_password - errors.add("password", "too short") unless password.size > 6 - end - end - -* Added the option for sanitizing find_by_sql and the offset parts in regular finds [Sam Stephenson]. Examples: - - Project.find_all ["category = ?", category_name], "created ASC", ["? OFFSET ?", 15, 20] - Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date] - -* Fixed value quoting in all generated SQL statements, so that integers are not surrounded in quotes and that all sanitation are happening - through the database's own quoting routine. This should hopefully make it lots easier for new adapters that doesn't accept '1' for integer - columns. - -* Fixed has_and_belongs_to_many guessing of foreign key so that keys are generated correctly for models like SomeVerySpecialClient - [Florian Weber] - -* Added counter_sql option for has_many associations [Jeremy Kemper]. Documentation: - - <tt>:counter_sql</tt> - specify a complete SQL statement to fetch the size of the association. If +:finder_sql+ is - specified but +:counter_sql+, +:counter_sql+ will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM. - -* Fixed that methods wrapped in callbacks still return their original result #260 [Jeremy Kemper] - -* Fixed the Inflector to handle the movie/movies pair correctly #261 [Scott Baron] - -* Added named bind-style variable interpolation #281 [Michael Koziarski]. Example: - - Person.find(["id = :id and first_name = :first_name", { :id => 5, :first_name = "bob' or 1=1" }]) - -* Added bind-style variable interpolation for the condition arrays that uses the adapter's quote method [Michael Koziarski] - - Before: - find_first([ "user_name = '%s' AND password = '%s'", user_name, password ])] - find_first([ "firm_id = %s", firm_id ])] # unsafe! - - After: - find_first([ "user_name = ? AND password = ?", user_name, password ])] - find_first([ "firm_id = ?", firm_id ])] - -* Added CSV format for fixtures #272 [what-a-day]. (See the new and expanded documentation on fixtures for more information) - -* Fixed fixtures using primary key fields called something else than "id" [dave] - -* Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon] - -* Added reverse order of deleting fixtures, so referential keys can be maintained #247 [Tim Bates] - -* Added relative path search for sqlite dbfiles in database.yml (if RAILS_ROOT is defined) #233 [Jeremy Kemper] - -* Added option to establish_connection where you'll be able to leave out the parameter to have it use the RAILS_ENV environment variable - -* Fixed problems with primary keys and postgresql sequences (#230) [Tim Bates] - -* Added reloading for associations under cached environments like FastCGI and mod_ruby. This makes it possible to use those environments for development. - This is turned on by default, but can be turned off with ActiveRecord::Base.reload_dependencies = false in production environments. - - NOTE: This will only have an effect if you let the associations manage the requiring of model classes. All libraries loaded through - require will be "forever" cached. You can, however, use ActiveRecord::Base.load_or_require("library") to get this behavior outside of the - auto-loading associations. - -* Added ERB capabilities to the fixture files for dynamic fixture generation. You don't need to do anything, just include ERB blocks like: - - david: - id: 1 - name: David - - jamis: - id: 2 - name: Jamis - - <% for digit in 3..10 %> - dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - <% end %> - -* Changed the yaml fixture searcher to look in the root of the fixtures directory, so when you before could have something like: - - fixtures/developers/fixtures.yaml - fixtures/accounts/fixtures.yaml - - ...you now need to do: - - fixtures/developers.yaml - fixtures/accounts.yaml - -* Changed the fixture format from: - - name: david - data: - id: 1 - name: David Heinemeier Hansson - birthday: 1979-10-15 - profession: Systems development - --- - name: steve - data: - id: 2 - name: Steve Ross Kellock - birthday: 1974-09-27 - profession: guy with keyboard - - ...to: - - david: - id: 1 - name: David Heinemeier Hansson - birthday: 1979-10-15 - profession: Systems development - - steve: - id: 2 - name: Steve Ross Kellock - birthday: 1974-09-27 - profession: guy with keyboard - - The change is NOT backwards compatible. Fixtures written in the old YAML style needs to be rewritten! - -* All associations will now attempt to require the classes that they associate to. Relieving the need for most explicit 'require' statements. - - -*1.1.0* (34) - -* Added automatic fixture setup and instance variable availability. Fixtures can also be automatically - instantiated in instance variables relating to their names using the following style: - - class FixturesTest < Test::Unit::TestCase - fixtures :developers # you can add more with comma separation - - def test_developers - assert_equal 3, @developers.size # the container for all the fixtures is automatically set - assert_kind_of Developer, @david # works like @developers["david"].find - assert_equal "David Heinemeier Hansson", @david.name - end - end - -* Added HasAndBelongsToManyAssociation#push_with_attributes(object, join_attributes) that can create associations in the join table with additional - attributes. This is really useful when you have information that's only relevant to the join itself, such as a "added_on" column for an association - between post and category. The added attributes will automatically be injected into objects retrieved through the association similar to the piggy-back - approach: - - post.categories.push_with_attributes(category, :added_on => Date.today) - post.categories.first.added_on # => Date.today - - NOTE: The categories table doesn't have a added_on column, it's the categories_post join table that does! - -* Fixed that :exclusively_dependent and :dependent can't be activated at the same time on has_many associations [Jeremy Kemper] - -* Fixed that database passwords couldn't be all numeric [Jeremy Kemper] - -* Fixed that calling id would create the instance variable for new_records preventing them from being saved correctly [Jeremy Kemper] - -* Added sanitization feature to HasManyAssociation#find_all so it works just like Base.find_all [Sam Stephenson/Jeremy Kemper] - -* Added that you can pass overlapping ids to find without getting duplicated records back [Jeremy Kemper] - -* Added that Base.benchmark returns the result of the block [Jeremy Kemper] - -* Fixed problem with unit tests on Windows with SQLite [paterno] - -* Fixed that quotes would break regular non-yaml fixtures [Dmitry Sabanin/daft] - -* Fixed fixtures on windows with line endings cause problems under unix / mac [Tobias Lütke] - -* Added HasAndBelongsToManyAssociation#find(id) that'll search inside the collection and find the object or record with that id - -* Added :conditions option to has_and_belongs_to_many that works just like the one on all the other associations - -* Added AssociationCollection#clear to remove all associations from has_many and has_and_belongs_to_many associations without destroying the records [geech] - -* Added type-checking and remove in 1-instead-of-N sql statements to AssociationCollection#delete [geech] - -* Added a return of self to AssociationCollection#<< so appending can be chained, like project << Milestone.create << Milestone.create [geech] - -* Added Base#hash and Base#eql? which means that all of the equality using features of array and other containers now works: - - [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ] - -* Added :uniq as an option to has_and_belongs_to_many which will automatically ensure that AssociateCollection#uniq is called - before pulling records out of the association. This is especially useful for three-way (and above) has_and_belongs_to_many associations. - -* Added AssociateCollection#uniq which is especially useful for has_and_belongs_to_many associations that can include duplicates, - which is common on associations that also use metadata. Usage: post.categories.uniq - -* Fixed respond_to? to use a subclass specific hash instead of an Active Record-wide one - -* Fixed has_and_belongs_to_many to treat associations between classes in modules properly [Florian Weber] - -* Added a NoMethod exception to be raised when query and writer methods are called for attributes that doesn't exist [geech] - -* Added a more robust version of Fixtures that throws meaningful errors when on formatting issues [geech] - -* Added Base#transaction as a compliment to Base.transaction for prettier use in instance methods [geech] - -* Improved the speed of respond_to? by placing the dynamic methods lookup table in a hash [geech] - -* Added that any additional fields added to the join table in a has_and_belongs_to_many association - will be placed as attributes when pulling records out through has_and_belongs_to_many associations. - This is helpful when have information about the association itself that you want available on retrival. - -* Added better loading exception catching and RubyGems retries to the database adapters [alexeyv] - -* Fixed bug with per-model transactions [daniel] - -* Fixed Base#transaction so that it returns the result of the last expression in the transaction block [alexeyv] - -* Added Fixture#find to find the record corresponding to the fixture id. The record - class name is guessed by using Inflector#classify (also new) on the fixture directory name. - - Before: Document.find(@documents["first"]["id"]) - After : @documents["first"].find - -* Fixed that the table name part of column names ("TABLE.COLUMN") wasn't removed properly [Andreas Schwarz] - -* Fixed a bug with Base#size when a finder_sql was used that didn't capitalize SELECT and FROM [geech] - -* Fixed quoting problems on SQLite by adding quote_string to the AbstractAdapter that can be overwritten by the concrete - adapters for a call to the dbm. [Andreas Schwarz] - -* Removed RubyGems backup strategy for requiring SQLite-adapter -- if people want to use gems, they're already doing it with AR. - - -*1.0.0 (35)* - -* Added OO-style associations methods [Florian Weber]. Examples: - - Project#milestones_count => Project#milestones.size - Project#build_to_milestones => Project#milestones.build - Project#create_for_milestones => Project#milestones.create - Project#find_in_milestones => Project#milestones.find - Project#find_all_in_milestones => Project#milestones.find_all - -* Added serialize as a new class method to control when text attributes should be YAMLized or not. This means that automated - serialization of hashes, arrays, and so on WILL NO LONGER HAPPEN (#10). You need to do something like this: - - class User < ActiveRecord::Base - serialize :settings - end - - This will assume that settings is a text column and will now YAMLize any object put in that attribute. You can also specify - an optional :class_name option that'll raise an exception if a serialized object is retrieved as a descendant of a class not in - the hierarchy. Example: - - class User < ActiveRecord::Base - serialize :settings, :class_name => "Hash" - end - - user = User.create("settings" => %w( one two three )) - User.find(user.id).settings # => raises SerializationTypeMismatch - -* Added the option to connect to a different database for one model at a time. Just call establish_connection on the class - you want to have connected to another database than Base. This will automatically also connect decendents of that class - to the different database [Renald Buter]. - -* Added transactional protection for Base#save. Validations can now check for values knowing that it happens in a transaction and callbacks - can raise exceptions knowing that the save will be rolled back. [Suggested by Alexey Verkhovsky] - -* Added column name quoting so reserved words, such as "references", can be used as column names [Ryan Platte] - -* Added the possibility to chain the return of what happened inside a logged block [geech]: - - This now works: - log { ... }.map { ... } - - Instead of doing: - result = [] - log { result = ... } - result.map { ... } - -* Added "socket" option for the MySQL adapter, so you can change it to something else than "/tmp/mysql.sock" [Anna Lissa Cruz] - -* Added respond_to? answers for all the attribute methods. So if Person has a name attribute retrieved from the table schema, - person.respond_to? "name" will return true. - -* Added Base.benchmark which can be used to aggregate logging and benchmark, so you can measure and represent multiple statements in a single block. - Usage (hides all the SQL calls for the individual actions and calculates total runtime for them all): - - Project.benchmark("Creating project") do - project = Project.create("name" => "stuff") - project.create_manager("name" => "David") - project.milestones << Milestone.find_all - end - -* Added logging of invalid SQL statements [Daniel Von Fange] - -* Added alias Errors#[] for Errors#on, so you can now say person.errors["name"] to retrieve the errors for name [Andreas Schwarz] - -* Added RubyGems require attempt if sqlite-ruby is not available through regular methods. - -* Added compatibility with 2.x series of sqlite-ruby drivers. [Jamis Buck] - -* Added type safety for association assignments, so a ActiveRecord::AssociationTypeMismatch will be raised if you attempt to - assign an object that's not of the associated class. This cures the problem with nil giving id = 4 and fixnums giving id = 1 on - mistaken association assignments. [Reported by Andreas Schwarz] - -* Added the option to keep many fixtures in one single YAML document [what-a-day] - -* Added the class method "inheritance_column" that can be overwritten to return the name of an alternative column than "type" for storing - the type for inheritance hierarchies. [Dave Steinberg] - -* Added [] and []= as an alternative way to access attributes when the regular methods have been overwritten [Dave Steinberg] - -* Added the option to observer more than one class at the time by specifying observed_class as an array - -* Added auto-id propagation support for tables with arbitrary primary keys that have autogenerated sequences associated with them - on PostgreSQL. [Dave Steinberg] - -* Changed that integer and floats set to "" through attributes= remain as NULL. This was especially a problem for scaffolding and postgresql. (#49) - -* Changed the MySQL Adapter to rely on MySQL for its defaults for socket, host, and port [Andreas Schwarz] - -* Changed ActionControllerError to decent from StandardError instead of Exception. It can now be caught by a generic rescue. - -* Changed class inheritable attributes to not use eval [Caio Chassot] - -* Changed Errors#add to now use "invalid" as the default message instead of true, which means full_messages work with those [Marcel Molina Jr.] - -* Fixed spelling on Base#add_on_boundry_breaking to Base#add_on_boundary_breaking (old naming still works) [Marcel Molina Jr.] - -* Fixed that entries in the has_and_belongs_to_many join table didn't get removed when an associated object was destroyed. - -* Fixed unnecessary calls to SET AUTOCOMMIT=0/1 for MySQL adapter [Andreas Schwarz] - -* Fixed PostgreSQL defaults are now handled gracefully [Dave Steinberg] - -* Fixed increment/decrement_counter are now atomic updates [Andreas Schwarz] - -* Fixed the problems the Inflector had turning Attachment into attuchments and Cases into Casis [radsaq/Florian Gross] - -* Fixed that cloned records would point attribute references on the parent object [Andreas Schwarz] - -* Fixed SQL for type call on inheritance hierarchies [Caio Chassot] - -* Fixed bug with typed inheritance [Florian Weber] - -* Fixed a bug where has_many collection_count wouldn't use the conditions specified for that association - - -*0.9.5* - -* Expanded the table_name guessing rules immensely [Florian Green]. Documentation: - - Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending - directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used - to guess the table name from even when called on Reply. The guessing rules are as follows: - * Class name ends in "x", "ch" or "ss": "es" is appended, so a Search class becomes a searches table. - * Class name ends in "y" preceded by a consonant or "qu": The "y" is replaced with "ies", - so a Category class becomes a categories table. - * Class name ends in "fe": The "fe" is replaced with "ves", so a Wife class becomes a wives table. - * Class name ends in "lf" or "rf": The "f" is replaced with "ves", so a Half class becomes a halves table. - * Class name ends in "person": The "person" is replaced with "people", so a Salesperson class becomes a salespeople table. - * Class name ends in "man": The "man" is replaced with "men", so a Spokesman class becomes a spokesmen table. - * Class name ends in "sis": The "i" is replaced with an "e", so a Basis class becomes a bases table. - * Class name ends in "tum" or "ium": The "um" is replaced with an "a", so a Datum class becomes a data table. - * Class name ends in "child": The "child" is replaced with "children", so a NodeChild class becomes a node_children table. - * Class name ends in an "s": No additional characters are added or removed. - * Class name doesn't end in "s": An "s" is appended, so a Comment class becomes a comments table. - * Class name with word compositions: Compositions are underscored, so CreditCard class becomes a credit_cards table. - Additionally, the class-level table_name_prefix is prepended to the table_name and the table_name_suffix is appended. - So if you have "myapp_" as a prefix, the table name guess for an Account class becomes "myapp_accounts". - - You can also overwrite this class method to allow for unguessable links, such as a Mouse class with a link to a - "mice" table. Example: - - class Mouse < ActiveRecord::Base - def self.table_name() "mice" end - end - - This conversion is now done through an external class called Inflector residing in lib/active_record/support/inflector.rb. - -* Added find_all_in_collection to has_many defined collections. Works like this: - - class Firm < ActiveRecord::Base - has_many :clients - end - - firm.id # => 1 - firm.find_all_in_clients "revenue > 1000" # SELECT * FROM clients WHERE firm_id = 1 AND revenue > 1000 - - [Requested by Dave Thomas] - -* Fixed finders for inheritance hierarchies deeper than one level [Florian Weber] - -* Added add_on_boundry_breaking to errors to accompany add_on_empty as a default validation method. It's used like this: - - class Person < ActiveRecord::Base - protected - def validation - errors.add_on_boundry_breaking "password", 3..20 - end - end - - This will add an error to the tune of "is too short (minimum is 3 characters)" or "is too long (minimum is 20 characters)" if - the password is outside the boundry. The messages can be changed by passing a third and forth parameter as message strings. - -* Implemented a clone method that works properly with AR. It returns a clone of the record that - hasn't been assigned an id yet and is treated as a new record. - -* Allow for domain sockets in PostgreSQL by not assuming localhost when no host is specified [Scott Barron] - -* Fixed that bignums are saved properly instead of attempted to be YAMLized [Andreas Schwartz] - -* Fixed a bug in the GEM where the rdoc options weren't being passed according to spec [Chad Fowler] - -* Fixed a bug with the exclusively_dependent option for has_many - - -*0.9.4* - -* Correctly guesses the primary key when the class is inside a module [Dave Steinberg]. - -* Added [] and []= as alternatives to read_attribute and write_attribute [Dave Steinberg] - -* has_and_belongs_to_many now accepts an :order key to determine in which order the collection is returned [radsaq]. - -* The ids passed to find and find_on_conditions are now automatically sanitized. - -* Added escaping of plings in YAML content. - -* Multi-parameter assigns where all the parameters are empty will now be set to nil instead of a new instance of their class. - -* Proper type within an inheritance hierarchy is now ensured already at object initialization (instead of first at create) - - -*0.9.3* - -* Fixed bug with using a different primary key name together with has_and_belongs_to_many [Investigation by Scott] - -* Added :exclusively_dependent option to the has_many association macro. The doc reads: - - If set to true all the associated object are deleted in one SQL statement without having their - before_destroy callback run. This should only be used on associations that depend solely on - this class and don't need to do any clean-up in before_destroy. The upside is that it's much - faster, especially if there's a counter_cache involved. - -* Added :port key to connection options, so the PostgreSQL and MySQL adapters can connect to a database server - running on another port than the default. - -* Converted the new natural singleton methods that prevented AR objects from being saved by PStore - (and hence be placed in a Rails session) to a module. [Florian Weber] - -* Fixed the use of floats (was broken since 0.9.0+) - -* Fixed PostgreSQL adapter so default values are displayed properly when used in conjunction with - Action Pack scaffolding. - -* Fixed booleans support for PostgreSQL (use real true/false on boolean fields instead of 0/1 on tinyints) [radsaq] - - -*0.9.2* - -* Added static method for instantly updating a record - -* Treat decimal and numeric as Ruby floats [Andreas Schwartz] - -* Treat chars as Ruby strings (fixes problem for Action Pack form helpers too) - -* Removed debugging output accidently left in (which would screw web applications) - - -*0.9.1* - -* Added MIT license - -* Added natural object-style assignment for has_and_belongs_to_many associations. Consider the following model: - - class Event < ActiveRecord::Base - has_one_and_belongs_to_many :sponsors - end - - class Sponsor < ActiveRecord::Base - has_one_and_belongs_to_many :sponsors - end - - Earlier, you'd have to use synthetic methods for creating associations between two objects of the above class: - - roskilde_festival.add_to_sponsors(carlsberg) - roskilde_festival.remove_from_sponsors(carlsberg) - - nike.add_to_events(world_cup) - nike.remove_from_events(world_cup) - - Now you can use regular array-styled methods: - - roskilde_festival.sponsors << carlsberg - roskilde_festival.sponsors.delete(carlsberg) - - nike.events << world_cup - nike.events.delete(world_cup) - -* Added delete method for has_many associations. Using this will nullify an association between the has_many and the belonging - object by setting the foreign key to null. Consider this model: - - class Post < ActiveRecord::Base - has_many :comments - end - - class Comment < ActiveRecord::Base - belongs_to :post - end - - You could do something like: - - funny_comment.has_post? # => true - announcement.comments.delete(funny_comment) - funny_comment.has_post? # => false - - -*0.9.0* - -* Active Record is now thread safe! (So you can use it with Cerise and WEBrick applications) - [Implementation idea by Michael Neumann, debugging assistance by Jamis Buck] - -* Improved performance by roughly 400% on a basic test case of pulling 100 records and querying one attribute. - This brings the tax for using Active Record instead of "riding on the metal" (using MySQL-ruby C-driver directly) down to ~50%. - Done by doing lazy type conversions and caching column information on the class-level. - -* Added callback objects and procs as options for implementing the target for callback macros. - -* Added "counter_cache" option to belongs_to that automates the usage of increment_counter and decrement_counter. Consider: - - class Post < ActiveRecord::Base - has_many :comments - end - - class Comment < ActiveRecord::Base - belongs_to :post - end - - Iterating over 100 posts like this: - - <% for post in @posts %> - <%= post.title %> has <%= post.comments_count %> comments - <% end %> - - Will generate 100 SQL count queries -- one for each call to post.comments_count. If you instead add a "comments_count" int column - to the posts table and rewrite the comments association macro with: - - class Comment < ActiveRecord::Base - belongs_to :post, :counter_cache => true - end - - Those 100 SQL count queries will be reduced to zero. Beware that counter caching is only appropriate for objects that begin life - with the object it's specified to belong with and is destroyed like that as well. Typically objects where you would also specify - :dependent => true. If your objects switch from one belonging to another (like a post that can be move from one category to another), - you'll have to manage the counter yourself. - -* Added natural object-style assignment for has_one and belongs_to associations. Consider the following model: - - class Project < ActiveRecord::Base - has_one :manager - end - - class Manager < ActiveRecord::Base - belongs_to :project - end - - Earlier, assignments would work like following regardless of which way the assignment told the best story: - - active_record.manager_id = david.id - - Now you can do it either from the belonging side: - - david.project = active_record - - ...or from the having side: - - active_record.manager = david - - If the assignment happens from the having side, the assigned object is automatically saved. So in the example above, the - project_id attribute on david would be set to the id of active_record, then david would be saved. - -* Added natural object-style assignment for has_many associations [Florian Weber]. Consider the following model: - - class Project < ActiveRecord::Base - has_many :milestones - end - - class Milestone < ActiveRecord::Base - belongs_to :project - end - - Earlier, assignments would work like following regardless of which way the assignment told the best story: - - deadline.project_id = active_record.id - - Now you can do it either from the belonging side: - - deadline.project = active_record - - ...or from the having side: - - active_record.milestones << deadline - - The milestone is automatically saved with the new foreign key. - -* API CHANGE: Attributes for text (or blob or similar) columns will now have unknown classes stored using YAML instead of using - to_s. (Known classes that won't be yamelized are: String, NilClass, TrueClass, FalseClass, Fixnum, Date, and Time). - Likewise, data pulled out of text-based attributes will be attempted converged using Yaml if they have the "--- " header. - This was primarily done to be enable the storage of hashes and arrays without wrapping them in aggregations, so now you can do: - - user = User.find(1) - user.preferences = { "background" => "black", "display" => large } - user.save - - User.find(1).preferences # => { "background" => "black", "display" => large } - - Please note that this method should only be used when you don't care about representing the object in proper columns in - the database. A money object consisting of an amount and a currency is still a much better fit for a value object done through - aggregations than this new option. - -* POSSIBLE CODE BREAKAGE: As a consequence of the lazy type conversions, it's a bad idea to reference the @attributes hash - directly (it always was, but now it's paramount that you don't). If you do, you won't get the type conversion. So to implement - new accessors for existing attributes, use read_attribute(attr_name) and write_attribute(attr_name, value) instead. Like this: - - class Song < ActiveRecord::Base - # Uses an integer of seconds to hold the length of the song - - def length=(minutes) - write_attribute("length", minutes * 60) - end - - def length - read_attribute("length") / 60 - end - end - - The clever kid will notice that this opens a door to sidestep the automated type conversion by using @attributes directly. - This is not recommended as read/write_attribute may be granted additional responsibilities in the future, but if you think - you know what you're doing and aren't afraid of future consequences, this is an option. - -* Applied a few minor bug fixes reported by Daniel Von Fange. - - -*0.8.4* - -_Reflection_ - -* Added ActiveRecord::Reflection with a bunch of methods and classes for reflecting in aggregations and associations. - -* Added Base.columns and Base.content_columns which returns arrays of column description (type, default, etc) objects. - -* Added Base#attribute_names which returns an array of names for the attributes available on the object. - -* Added Base#column_for_attribute(name) which returns the column description object for the named attribute. - - -_Misc_ - -* Added multi-parameter assignment: - - # Instantiate objects for all attribute classes that needs more than one constructor parameter. This is done - # by calling new on the column type or aggregation type (through composed_of) object with these parameters. - # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate - # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the - # parenteses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float, - # s for String, and a for Array. - - This is incredibly useful for assigning dates from HTML drop-downs of month, year, and day. - -* Fixed bug with custom primary key column name and Base.find on multiple parameters. - -* Fixed bug with dependent option on has_one associations if there was no associated object. - - -*0.8.3* - -_Transactions_ - -* Added transactional protection for destroy (important for the new :dependent option) [Suggested by Carl Youngblood] - -* Fixed so transactions are ignored on MyISAM tables for MySQL (use InnoDB to get transactions) - -* Changed transactions so only exceptions will cause a rollback, not returned false. - - -_Mapping_ - -* Added support for non-integer primary keys [Aredridel/earlier work by Michael Neumann] - - User.find "jdoe" - Product.find "PDKEY-INT-12" - -* Added option to specify naming method for primary key column. ActiveRecord::Base.primary_key_prefix_type can either - be set to nil, :table_name, or :table_name_with_underscore. :table_name will assume that Product class has a primary key - of "productid" and :table_name_with_underscore will assume "product_id". The default nil will just give "id". - -* Added an overwriteable primary_key method that'll instruct AR to the name of the - id column [Aredridele/earlier work by Guan Yang] - - class Project < ActiveRecord::Base - def self.primary_key() "project_id" end - end - -* Fixed that Active Records can safely associate inside and out of modules. - - class MyApplication::Account < ActiveRecord::Base - has_many :clients # will look for MyApplication::Client - has_many :interests, :class_name => "Business::Interest" # will look for Business::Interest - end - -* Fixed that Active Records can safely live inside modules [Aredridel] - - class MyApplication::Account < ActiveRecord::Base - end - - -_Misc_ - -* Added freeze call to value object assignments to ensure they remain immutable [Spotted by Gavin Sinclair] - -* Changed interface for specifying observed class in observers. Was OBSERVED_CLASS constant, now is - observed_class() class method. This is more consistant with things like self.table_name(). Works like this: - - class AuditObserver < ActiveRecord::Observer - def self.observed_class() Account end - def after_update(account) - AuditTrail.new(account, "UPDATED") - end - end - - [Suggested by Gavin Sinclair] - -* Create new Active Record objects by setting the attributes through a block. Like this: - - person = Person.new do |p| - p.name = 'Freddy' - p.age = 19 - end - - [Suggested by Gavin Sinclair] - - -*0.8.2* - -* Added inheritable callback queues that can ensure that certain callback methods or inline fragments are - run throughout the entire inheritance hierarchy. Regardless of whether a descendant overwrites the callback - method: - - class Topic < ActiveRecord::Base - before_destroy :destroy_author, 'puts "I'm an inline fragment"' - end - - Learn more in link:classes/ActiveRecord/Callbacks.html - -* Added :dependent option to has_many and has_one, which will automatically destroy associated objects when - the holder is destroyed: - - class Album < ActiveRecord::Base - has_many :tracks, :dependent => true - end - - All the associated tracks are destroyed when the album is. - -* Added Base.create as a factory that'll create, save, and return a new object in one step. - -* Automatically convert strings in config hashes to symbols for the _connection methods. This allows you - to pass the argument hashes directly from yaml. (Luke) - -* Fixed the install.rb to include simple.rb [Spotted by Kevin Bullock] - -* Modified block syntax to better follow our code standards outlined in - http://www.rubyonrails.org/CodingStandards - - -*0.8.1* - -* Added object-level transactions [Austin Ziegler] - -* Changed adapter-specific connection methods to use centralized ActiveRecord::Base.establish_connection, - which is parametized through a config hash with symbol keys instead of a regular parameter list. - This will allow for database connections to be opened in a more generic fashion. (Luke) - - NOTE: This requires all *_connections to be updated! Read more in: - http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000081 - -* Fixed SQLite adapter so objects fetched from has_and_belongs_to_many have proper attributes - (t.name is now name). [Spotted by Garrett Rooney] - -* Fixed SQLite adapter so dates are returned as Date objects, not Time objects [Spotted by Gavin Sinclair] - -* Fixed requirement of date class, so date conversions are succesful regardless of whether you - manually require date or not. - - -*0.8.0* - -* Added transactions - -* Changed Base.find to also accept either a list (1, 5, 6) or an array of ids ([5, 7]) - as parameter and then return an array of objects instead of just an object - -* Fixed method has_collection? for has_and_belongs_to_many macro to behave as a - collection, not an association - -* Fixed SQLite adapter so empty or nil values in columns of datetime, date, or time type - aren't treated as current time [Spotted by Gavin Sinclair] - - -*0.7.6* - -* Fixed the install.rb to create the lib/active_record/support directory [Spotted by Gavin Sinclair] -* Fixed that has_association? would always return true [Daniel Von Fange] diff --git a/vendor/rails/activerecord/README b/vendor/rails/activerecord/README deleted file mode 100644 index d68eb28a..00000000 --- a/vendor/rails/activerecord/README +++ /dev/null @@ -1,351 +0,0 @@ -= Active Record -- Object-relation mapping put on rails - -Active Record connects business objects and database tables to create a persistable -domain model where logic and data are presented in one wrapping. It's an implementation -of the object-relational mapping (ORM) pattern[http://www.martinfowler.com/eaaCatalog/activeRecord.html] -by the same name as described by Martin Fowler: - - "An object that wraps a row in a database table or view, encapsulates - the database access, and adds domain logic on that data." - -Active Record's main contribution to the pattern is to relieve the original of two stunting problems: -lack of associations and inheritance. By adding a simple domain language-like set of macros to describe -the former and integrating the Single Table Inheritance pattern for the latter, Active Record narrows the -gap of functionality between the data mapper and active record approach. - -A short rundown of the major features: - -* Automated mapping between classes and tables, attributes and columns. - - class Product < ActiveRecord::Base; end - - ...is automatically mapped to the table named "products", such as: - - CREATE TABLE products ( - id int(11) NOT NULL auto_increment, - name varchar(255), - PRIMARY KEY (id) - ); - - ...which again gives Product#name and Product#name=(new_name) - - {Learn more}[link:classes/ActiveRecord/Base.html] - - -* Associations between objects controlled by simple meta-programming macros. - - class Firm < ActiveRecord::Base - has_many :clients - has_one :account - belongs_to :conglomorate - end - - {Learn more}[link:classes/ActiveRecord/Associations/ClassMethods.html] - - -* Aggregations of value objects controlled by simple meta-programming macros. - - class Account < ActiveRecord::Base - composed_of :balance, :class_name => "Money", - :mapping => %w(balance amount) - composed_of :address, - :mapping => [%w(address_street street), %w(address_city city)] - end - - {Learn more}[link:classes/ActiveRecord/Aggregations/ClassMethods.html] - - -* Validation rules that can differ for new or existing objects. - - class Account < ActiveRecord::Base - validates_presence_of :subdomain, :name, :email_address, :password - validates_uniqueness_of :subdomain - validates_acceptance_of :terms_of_service, :on => :create - validates_confirmation_of :password, :email_address, :on => :create - end - - {Learn more}[link:classes/ActiveRecord/Validations.html] - -* Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc). - - class Person < ActiveRecord::Base - def before_destroy # is called just before Person#destroy - CreditCard.find(credit_card_id).destroy - end - end - - class Account < ActiveRecord::Base - after_find :eager_load, 'self.class.announce(#{id})' - end - - {Learn more}[link:classes/ActiveRecord/Callbacks.html] - - -* Observers for the entire lifecycle - - class CommentObserver < ActiveRecord::Observer - def after_create(comment) # is called just after Comment#save - Notifications.deliver_new_comment("david@loudthinking.com", comment) - end - end - - {Learn more}[link:classes/ActiveRecord/Observer.html] - - -* Inheritance hierarchies - - class Company < ActiveRecord::Base; end - class Firm < Company; end - class Client < Company; end - class PriorityClient < Client; end - - {Learn more}[link:classes/ActiveRecord/Base.html] - - -* Transactions - - # Database transaction - Account.transaction do - david.withdrawal(100) - mary.deposit(100) - end - - {Learn more}[link:classes/ActiveRecord/Transactions/ClassMethods.html] - - -* Reflections on columns, associations, and aggregations - - reflection = Firm.reflect_on_association(:clients) - reflection.klass # => Client (class) - Firm.columns # Returns an array of column descriptors for the firms table - - {Learn more}[link:classes/ActiveRecord/Reflection/ClassMethods.html] - - -* Direct manipulation (instead of service invocation) - - So instead of (Hibernate[http://www.hibernate.org/] example): - - long pkId = 1234; - DomesticCat pk = (DomesticCat) sess.load( Cat.class, new Long(pkId) ); - // something interesting involving a cat... - sess.save(cat); - sess.flush(); // force the SQL INSERT - - Active Record lets you: - - pkId = 1234 - cat = Cat.find(pkId) - # something even more interesting involving the same cat... - cat.save - - {Learn more}[link:classes/ActiveRecord/Base.html] - - -* Database abstraction through simple adapters (~100 lines) with a shared connector - - ActiveRecord::Base.establish_connection(:adapter => "sqlite", :database => "dbfile") - - ActiveRecord::Base.establish_connection( - :adapter => "mysql", - :host => "localhost", - :username => "me", - :password => "secret", - :database => "activerecord" - ) - - {Learn more}[link:classes/ActiveRecord/Base.html#M000081] and read about the built-in support for - MySQL[link:classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html], PostgreSQL[link:classes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html], SQLite[link:classes/ActiveRecord/ConnectionAdapters/SQLiteAdapter.html], Oracle[link:classes/ActiveRecord/ConnectionAdapters/OracleAdapter.html], SQLServer[link:classes/ActiveRecord/ConnectionAdapters/SQLServerAdapter.html], and DB2[link:classes/ActiveRecord/ConnectionAdapters/DB2Adapter.html]. - - -* Logging support for Log4r[http://log4r.sourceforge.net] and Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc] - - ActiveRecord::Base.logger = Logger.new(STDOUT) - ActiveRecord::Base.logger = Log4r::Logger.new("Application Log") - - -* Database agnostic schema management with Migrations - - class AddSystemSettings < ActiveRecord::Migration - def self.up - create_table :system_settings do |t| - t.string :name - t.string :label - t.text :value - t.string :type - t.integer :position - end - - SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1 - end - - def self.down - drop_table :system_settings - end - end - - {Learn more}[link:classes/ActiveRecord/Migration.html] - -== Simple example (1/2): Defining tables and classes (using MySQL) - -Data definitions are specified only in the database. Active Record queries the database for -the column names (that then serves to determine which attributes are valid) on regular -object instantiation through the new constructor and relies on the column names in the rows -with the finders. - - # CREATE TABLE companies ( - # id int(11) unsigned NOT NULL auto_increment, - # client_of int(11), - # name varchar(255), - # type varchar(100), - # PRIMARY KEY (id) - # ) - -Active Record automatically links the "Company" object to the "companies" table - - class Company < ActiveRecord::Base - has_many :people, :class_name => "Person" - end - - class Firm < Company - has_many :clients - - def people_with_all_clients - clients.inject([]) { |people, client| people + client.people } - end - end - -The foreign_key is only necessary because we didn't use "firm_id" in the data definition - - class Client < Company - belongs_to :firm, :foreign_key => "client_of" - end - - # CREATE TABLE people ( - # id int(11) unsigned NOT NULL auto_increment, - # name text, - # company_id text, - # PRIMARY KEY (id) - # ) - -Active Record will also automatically link the "Person" object to the "people" table - - class Person < ActiveRecord::Base - belongs_to :company - end - -== Simple example (2/2): Using the domain - -Picking a database connection for all the Active Records - - ActiveRecord::Base.establish_connection( - :adapter => "mysql", - :host => "localhost", - :username => "me", - :password => "secret", - :database => "activerecord" - ) - -Create some fixtures - - firm = Firm.new("name" => "Next Angle") - # SQL: INSERT INTO companies (name, type) VALUES("Next Angle", "Firm") - firm.save - - client = Client.new("name" => "37signals", "client_of" => firm.id) - # SQL: INSERT INTO companies (name, client_of, type) VALUES("37signals", 1, "Firm") - client.save - -Lots of different finders - - # SQL: SELECT * FROM companies WHERE id = 1 - next_angle = Company.find(1) - - # SQL: SELECT * FROM companies WHERE id = 1 AND type = 'Firm' - next_angle = Firm.find(1) - - # SQL: SELECT * FROM companies WHERE id = 1 AND name = 'Next Angle' - next_angle = Company.find(:first, :conditions => "name = 'Next Angle'") - - next_angle = Firm.find_by_sql("SELECT * FROM companies WHERE id = 1").first - -The supertype, Company, will return subtype instances - - Firm === next_angle - -All the dynamic methods added by the has_many macro - - next_angle.clients.empty? # true - next_angle.clients.size # total number of clients - all_clients = next_angle.clients - -Constrained finds makes access security easier when ID comes from a web-app - - # SQL: SELECT * FROM companies WHERE client_of = 1 AND type = 'Client' AND id = 2 - thirty_seven_signals = next_angle.clients.find(2) - -Bi-directional associations thanks to the "belongs_to" macro - - thirty_seven_signals.firm.nil? # true - - -== Philosophy - -Active Record attempts to provide a coherent wrapper as a solution for the inconvenience that is -object-relational mapping. The prime directive for this mapping has been to minimize -the amount of code needed to build a real-world domain model. This is made possible -by relying on a number of conventions that make it easy for Active Record to infer -complex relations and structures from a minimal amount of explicit direction. - -Convention over Configuration: -* No XML-files! -* Lots of reflection and run-time extension -* Magic is not inherently a bad word - -Admit the Database: -* Lets you drop down to SQL for odd cases and performance -* Doesn't attempt to duplicate or replace data definitions - - -== Download - -The latest version of Active Record can be found at - -* http://rubyforge.org/project/showfiles.php?group_id=182 - -Documentation can be found at - -* http://ar.rubyonrails.com - - -== Installation - -The prefered method of installing Active Record is through its GEM file. You'll need to have -RubyGems[http://rubygems.rubyforge.org/wiki/wiki.pl] installed for that, though. If you have, -then use: - - % [sudo] gem install activerecord-1.10.0.gem - -You can also install Active Record the old-fashioned way with the following command: - - % [sudo] ruby install.rb - -from its distribution directory. - - -== License - -Active Record is released under the MIT license. - - -== Support - -The Active Record homepage is http://www.rubyonrails.com. You can find the Active Record -RubyForge page at http://rubyforge.org/projects/activerecord. And as Jim from Rake says: - - Feel free to submit commits or feature requests. If you send a patch, - remember to update the corresponding unit tests. If fact, I prefer - new feature to be submitted in the form of new unit tests. - -For other information, feel free to ask on the rubyonrails-talk -(http://groups.google.com/group/rubyonrails-talk) mailing list. diff --git a/vendor/rails/activerecord/RUNNING_UNIT_TESTS b/vendor/rails/activerecord/RUNNING_UNIT_TESTS deleted file mode 100644 index 39fc8675..00000000 --- a/vendor/rails/activerecord/RUNNING_UNIT_TESTS +++ /dev/null @@ -1,36 +0,0 @@ -== Creating the test database - -The default names for the test databases are "activerecord_unittest" and -"activerecord_unittest2". If you want to use another database name then be sure -to update the connection adapter setups you want to test with in -test/connections/<your database>/connection.rb. -When you have the database online, you can import the fixture tables with -the test/schema/*.sql files. - -Make sure that you create database objects with the same user that you specified in -connection.rb otherwise (on Postgres, at least) tests for default values will fail. - -== Running with Rake - -The easiest way to run the unit tests is through Rake. The default task runs -the entire test suite for all the adapters. You can also run the suite on just -one adapter by using the tasks test_mysql, test_sqlite, test_postgresql or any -of the other test_ tasks. For more information, checkout the full array of rake -tasks with "rake -T" - -Rake can be found at http://rake.rubyforge.org - -== Running by hand - -Unit tests are located in test/cases directory. If you only want to run a single test suite, -you can do so with: - - rake test_mysql TEST=test/cases/base_test.rb - -That'll run the base suite using the MySQL-Ruby adapter. Some tests rely on the schema -being initialized - you can initialize the schema with: - - rake test_mysql TEST=test/cases/aaa_create_tables_test.rb - - - diff --git a/vendor/rails/activerecord/Rakefile b/vendor/rails/activerecord/Rakefile deleted file mode 100644 index 50210c02..00000000 --- a/vendor/rails/activerecord/Rakefile +++ /dev/null @@ -1,268 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rdoc/task' -require 'rake/packagetask' -require 'rubygems/package_task' - -require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version') -require File.expand_path(File.dirname(__FILE__)) + "/test/config" - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'activerecord' -PKG_VERSION = ActiveRecord::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "activerecord" -RUBY_FORGE_USER = "webster132" - -MYSQL_DB_USER = 'rails' - -PKG_FILES = FileList[ - "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile" -].exclude(/\bCVS\b|~$/) - -def run_without_aborting(*tasks) - errors = [] - - tasks.each do |task| - begin - Rake::Task[task].invoke - rescue Exception - errors << task - end - end - - abort "Errors running #{errors.join(', ')}" if errors.any? -end - -desc 'Run mysql, sqlite, and postgresql tests by default' -task :default => :test - -desc 'Run mysql, sqlite, and postgresql tests' -task :test do - tasks = defined?(JRUBY_VERSION) ? - %w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) : - %w(test_mysql test_sqlite3 test_postgresql) - run_without_aborting(*tasks) -end - -for adapter in %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ) - Rake::TestTask.new("test_#{adapter}") { |t| - if adapter =~ /jdbc/ - t.libs << "test" << "test/connections/jdbc_#{adapter}" - else - t.libs << "test" << "test/connections/native_#{adapter}" - end - adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/] - t.test_files=Dir.glob( "test/cases/**/*_test{,_#{adapter_short}}.rb" ).sort - t.verbose = true - } - - namespace adapter do - task :test => "test_#{adapter}" - end -end - -namespace :mysql do - desc 'Build the MySQL test databases' - task :build_databases do - %x( echo "create DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER}) - %x( echo "create DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER}) - end - - desc 'Drop the MySQL test databases' - task :drop_databases do - %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest ) - %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 ) - end - - desc 'Rebuild the MySQL test databases' - task :rebuild_databases => [:drop_databases, :build_databases] -end - -task :build_mysql_databases => 'mysql:build_databases' -task :drop_mysql_databases => 'mysql:drop_databases' -task :rebuild_mysql_databases => 'mysql:rebuild_databases' - - -namespace :postgresql do - desc 'Build the PostgreSQL test databases' - task :build_databases do - %x( createdb -E UTF8 activerecord_unittest ) - %x( createdb -E UTF8 activerecord_unittest2 ) - end - - desc 'Drop the PostgreSQL test databases' - task :drop_databases do - %x( dropdb activerecord_unittest ) - %x( dropdb activerecord_unittest2 ) - end - - desc 'Rebuild the PostgreSQL test databases' - task :rebuild_databases => [:drop_databases, :build_databases] -end - -task :build_postgresql_databases => 'postgresql:build_databases' -task :drop_postgresql_databases => 'postgresql:drop_databases' -task :rebuild_postgresql_databases => 'postgresql:rebuild_databases' - - -namespace :frontbase do - desc 'Build the FrontBase test databases' - task :build_databases => :rebuild_frontbase_databases - - desc 'Rebuild the FrontBase test databases' - task :rebuild_databases do - build_frontbase_database = Proc.new do |db_name, sql_definition_file| - %( - STOP DATABASE #{db_name}; - DELETE DATABASE #{db_name}; - CREATE DATABASE #{db_name}; - - CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM; - SET COMMIT FALSE; - - CREATE USER RAILS; - CREATE SCHEMA RAILS AUTHORIZATION RAILS; - COMMIT; - - SET SESSION AUTHORIZATION RAILS; - SCRIPT '#{sql_definition_file}'; - - COMMIT; - - DISCONNECT ALL; - ) - end - create_activerecord_unittest = build_frontbase_database['activerecord_unittest', File.join(SCHEMA_ROOT, 'frontbase.sql')] - create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_ROOT, 'frontbase2.sql')] - execute_frontbase_sql = Proc.new do |sql| - system(<<-SHELL) - /Library/FrontBase/bin/sql92 <<-SQL - #{sql} - SQL - SHELL - end - execute_frontbase_sql[create_activerecord_unittest] - execute_frontbase_sql[create_activerecord_unittest2] - end -end - -task :build_frontbase_databases => 'frontbase:build_databases' -task :rebuild_frontbase_databases => 'frontbase:rebuild_databases' - - -# Generate the RDoc documentation - -RDoc::Task.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Active Record -- Object-relation mapping put on rails" - rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG') - rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.rdoc_files.exclude('lib/active_record/vendor/*') - rdoc.rdoc_files.include('dev-utils/*.rb') -} - -# Enhance rdoc task to copy referenced images also -task :rdoc do - FileUtils.mkdir_p "doc/files/examples/" - FileUtils.copy "examples/associations.png", "doc/files/examples/associations.png" -end - - -# Create compressed packages - -dist_dirs = [ "lib", "test", "examples" ] - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = PKG_NAME - s.version = PKG_VERSION - s.summary = "Implements the ActiveRecord pattern for ORM." - s.description = %q{Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.} - - s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG" ] - dist_dirs.each do |dir| - s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } - end - - s.add_dependency('activesupport', '= 2.3.14' + PKG_BUILD) - - s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite" - s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite" - s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite3" - s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite3" - s.require_path = 'lib' - - s.extra_rdoc_files = %w( README ) - s.rdoc_options.concat ['--main', 'README'] - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activerecord" -end - -Gem::PackageTask.new(spec) do |p| - p.gem_spec = spec - p.need_tar = true - p.need_zip = true -end - -task :lines do - lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 - - for file_name in FileList["lib/active_record/**/*.rb"] - next if file_name =~ /vendor/ - f = File.open(file_name) - - while line = f.gets - lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - codelines += 1 - end - puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" - - total_lines += lines - total_codelines += codelines - - lines, codelines = 0, 0 - end - - puts "Total: Lines #{total_lines}, LOC #{total_codelines}" -end - - -# Publishing ------------------------------------------------------ - -desc "Publish the beta gem" -task :pgem => [:package] do - require 'rake/contrib/sshpublisher' - Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` -end - -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - require 'rake/contrib/sshpublisher' - Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - require 'rubyforge' - require 'rake/contrib/rubyforgepublisher' - - packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" } - - rubyforge = RubyForge.new - rubyforge.login - rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages) -end diff --git a/vendor/rails/activerecord/examples/associations.png b/vendor/rails/activerecord/examples/associations.png deleted file mode 100644 index 661c7a8b..00000000 Binary files a/vendor/rails/activerecord/examples/associations.png and /dev/null differ diff --git a/vendor/rails/activerecord/examples/performance.rb b/vendor/rails/activerecord/examples/performance.rb deleted file mode 100755 index 893d32be..00000000 --- a/vendor/rails/activerecord/examples/performance.rb +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env ruby -KU - -TIMES = (ENV['N'] || 10000).to_i - -require 'rubygems' -gem 'addressable', '~>2.0' -gem 'faker', '~>0.3.1' -gem 'rbench', '~>0.2.3' -require 'addressable/uri' -require 'faker' -require 'rbench' - -__DIR__ = File.dirname(__FILE__) -$:.unshift "#{__DIR__}/../lib" -$:.unshift "#{__DIR__}/../../activesupport/lib" - -require 'active_record' - -conn = { :adapter => 'mysql', - :database => 'activerecord_unittest', - :username => 'rails', :password => '', - :encoding => 'utf8' } - -conn[:socket] = Pathname.glob(%w[ - /opt/local/var/run/mysql5/mysqld.sock - /tmp/mysqld.sock - /tmp/mysql.sock - /var/mysql/mysql.sock - /var/run/mysqld/mysqld.sock -]).find { |path| path.socket? }.to_s - -ActiveRecord::Base.establish_connection(conn) - -class User < ActiveRecord::Base - connection.create_table :users, :force => true do |t| - t.string :name, :email - t.timestamps - end - - has_many :exhibits -end - -class Exhibit < ActiveRecord::Base - connection.create_table :exhibits, :force => true do |t| - t.belongs_to :user - t.string :name - t.text :notes - t.timestamps - end - - belongs_to :user - - def look; attributes end - def feel; look; user.name end - - def self.look(exhibits) exhibits.each { |e| e.look } end - def self.feel(exhibits) exhibits.each { |e| e.feel } end -end - -sqlfile = "#{__DIR__}/performance.sql" - -if File.exists?(sqlfile) - mysql_bin = %w[mysql mysql5].detect { |bin| `which #{bin}`.length > 0 } - `#{mysql_bin} -u #{conn[:username]} #{"-p#{conn[:password]}" unless conn[:password].blank?} #{conn[:database]} < #{sqlfile}` -else - puts 'Generating data...' - - # pre-compute the insert statements and fake data compilation, - # so the benchmarks below show the actual runtime for the execute - # method, minus the setup steps - - # Using the same paragraph for all exhibits because it is very slow - # to generate unique paragraphs for all exhibits. - notes = Faker::Lorem.paragraphs.join($/) - today = Date.today - - puts 'Inserting 10,000 users and exhibits...' - 10_000.times do - user = User.create( - :created_at => today, - :name => Faker::Name.name, - :email => Faker::Internet.email - ) - - Exhibit.create( - :created_at => today, - :name => Faker::Company.name, - :user => user, - :notes => notes - ) - end - - mysqldump_bin = %w[mysqldump mysqldump5].detect { |bin| `which #{bin}`.length > 0 } - `#{mysqldump_bin} -u #{conn[:username]} #{"-p#{conn[:password]}" unless conn[:password].blank?} #{conn[:database]} exhibits users > #{sqlfile}` -end - -RBench.run(TIMES) do - column :times - column :ar - - report 'Model#id', (TIMES * 100).ceil do - ar_obj = Exhibit.find(1) - - ar { ar_obj.id } - end - - report 'Model.new (instantiation)' do - ar { Exhibit.new } - end - - report 'Model.new (setting attributes)' do - attrs = { :name => 'sam' } - ar { Exhibit.new(attrs) } - end - - report 'Model.first' do - ar { Exhibit.first.look } - end - - report 'Model.all limit(100)', (TIMES / 10).ceil do - ar { Exhibit.look Exhibit.all(:limit => 100) } - end - - report 'Model.all limit(100) with relationship', (TIMES / 10).ceil do - ar { Exhibit.feel Exhibit.all(:limit => 100, :include => :user) } - end - - report 'Model.all limit(10,000)', (TIMES / 1000).ceil do - ar { Exhibit.look Exhibit.all(:limit => 10000) } - end - - exhibit = { - :name => Faker::Company.name, - :notes => Faker::Lorem.paragraphs.join($/), - :created_at => Date.today - } - - report 'Model.create' do - ar { Exhibit.create(exhibit) } - end - - report 'Resource#attributes=' do - attrs_first = { :name => 'sam' } - attrs_second = { :name => 'tom' } - ar { exhibit = Exhibit.new(attrs_first); exhibit.attributes = attrs_second } - end - - report 'Resource#update' do - ar { Exhibit.first.update_attributes(:name => 'bob') } - end - - report 'Resource#destroy' do - ar { Exhibit.first.destroy } - end - - report 'Model.transaction' do - ar { Exhibit.transaction { Exhibit.new } } - end - - report 'Model.find(id)' do - id = Exhibit.first.id - ar { Exhibit.find(id) } - end - - report 'Model.find_by_sql' do - ar { Exhibit.find_by_sql("SELECT * FROM exhibits WHERE id = #{(rand * 1000 + 1).to_i}").first } - end - - report 'Model.log', (TIMES * 10) do - ar { Exhibit.connection.send(:log, "hello", "world") {} } - end - - report 'AR.execute(query)', (TIMES / 2) do - ar { ActiveRecord::Base.connection.execute("Select * from exhibits where id = #{(rand * 1000 + 1).to_i}") } - end - - report 'Model.find(id)' do - id = Exhibit.first.id - ar { Exhibit.find(id) } - end - - report 'Model.find_by_sql' do - ar { Exhibit.find_by_sql("SELECT * FROM exhibits WHERE id = #{(rand * 1000 + 1).to_i}").first } - end - - report 'Model.log', (TIMES * 10) do - ar { Exhibit.connection.send(:log, "hello", "world") {} } - end - - report 'AR.execute(query)', (TIMES / 2) do - ar { ActiveRecord::Base.connection.execute("Select * from exhibits where id = #{(rand * 1000 + 1).to_i}") } - end - - summary 'Total' -end - -ActiveRecord::Migration.drop_table "exhibits" -ActiveRecord::Migration.drop_table "users" diff --git a/vendor/rails/activerecord/install.rb b/vendor/rails/activerecord/install.rb deleted file mode 100644 index c87398b1..00000000 --- a/vendor/rails/activerecord/install.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rbconfig' -require 'find' -require 'ftools' - -include Config - -# this was adapted from rdoc's install.rb by ways of Log4r - -$sitedir = CONFIG["sitelibdir"] -unless $sitedir - version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"] - $libdir = File.join(CONFIG["libdir"], "ruby", version) - $sitedir = $:.find {|x| x =~ /site_ruby/ } - if !$sitedir - $sitedir = File.join($libdir, "site_ruby") - elsif $sitedir !~ Regexp.quote(version) - $sitedir = File.join($sitedir, version) - end -end - -# the actual gruntwork -Dir.chdir("lib") - -Find.find("active_record", "active_record.rb") { |f| - if f[-3..-1] == ".rb" - File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true) - else - File::makedirs(File.join($sitedir, *f.split(/\//))) - end -} diff --git a/vendor/rails/activerecord/lib/active_record.rb b/vendor/rails/activerecord/lib/active_record.rb deleted file mode 100644 index 0d0ada9f..00000000 --- a/vendor/rails/activerecord/lib/active_record.rb +++ /dev/null @@ -1,83 +0,0 @@ -#-- -# Copyright (c) 2004-2010 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end - -module ActiveRecord - # TODO: Review explicit loads to see if they will automatically be handled by the initilizer. - def self.load_all! - [Base, DynamicFinderMatch, ConnectionAdapters::AbstractAdapter] - end - - autoload :VERSION, 'active_record/version' - - autoload :ActiveRecordError, 'active_record/base' - autoload :ConnectionNotEstablished, 'active_record/base' - - autoload :Aggregations, 'active_record/aggregations' - autoload :AssociationPreload, 'active_record/association_preload' - autoload :Associations, 'active_record/associations' - autoload :AttributeMethods, 'active_record/attribute_methods' - autoload :AutosaveAssociation, 'active_record/autosave_association' - autoload :Base, 'active_record/base' - autoload :Batches, 'active_record/batches' - autoload :Calculations, 'active_record/calculations' - autoload :Callbacks, 'active_record/callbacks' - autoload :Dirty, 'active_record/dirty' - autoload :DynamicFinderMatch, 'active_record/dynamic_finder_match' - autoload :DynamicScopeMatch, 'active_record/dynamic_scope_match' - autoload :Migration, 'active_record/migration' - autoload :Migrator, 'active_record/migration' - autoload :NamedScope, 'active_record/named_scope' - autoload :NestedAttributes, 'active_record/nested_attributes' - autoload :Observing, 'active_record/observer' - autoload :QueryCache, 'active_record/query_cache' - autoload :Reflection, 'active_record/reflection' - autoload :Schema, 'active_record/schema' - autoload :SchemaDumper, 'active_record/schema_dumper' - autoload :Serialization, 'active_record/serialization' - autoload :SessionStore, 'active_record/session_store' - autoload :TestCase, 'active_record/test_case' - autoload :Timestamp, 'active_record/timestamp' - autoload :Transactions, 'active_record/transactions' - autoload :Validations, 'active_record/validations' - - module Locking - autoload :Optimistic, 'active_record/locking/optimistic' - autoload :Pessimistic, 'active_record/locking/pessimistic' - end - - module ConnectionAdapters - autoload :AbstractAdapter, 'active_record/connection_adapters/abstract_adapter' - end -end - -I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml' diff --git a/vendor/rails/activerecord/lib/active_record/aggregations.rb b/vendor/rails/activerecord/lib/active_record/aggregations.rb deleted file mode 100644 index 1eefebb3..00000000 --- a/vendor/rails/activerecord/lib/active_record/aggregations.rb +++ /dev/null @@ -1,261 +0,0 @@ -module ActiveRecord - module Aggregations # :nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - def clear_aggregation_cache #:nodoc: - self.class.reflect_on_all_aggregations.to_a.each do |assoc| - instance_variable_set "@#{assoc.name}", nil - end unless self.new_record? - end - - # Active Record implements aggregation through a macro-like class method called +composed_of+ for representing attributes - # as value objects. It expresses relationships like "Account [is] composed of Money [among other things]" or "Person [is] - # composed of [an] address". Each call to the macro adds a description of how the value objects are created from the - # attributes of the entity object (when the entity is initialized either as a new object or from finding an existing object) - # and how it can be turned back into attributes (when the entity is saved to the database). Example: - # - # class Customer < ActiveRecord::Base - # composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) - # composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] - # end - # - # The customer class now has the following methods to manipulate the value objects: - # * <tt>Customer#balance, Customer#balance=(money)</tt> - # * <tt>Customer#address, Customer#address=(address)</tt> - # - # These methods will operate with value objects like the ones described below: - # - # class Money - # include Comparable - # attr_reader :amount, :currency - # EXCHANGE_RATES = { "USD_TO_DKK" => 6 } - # - # def initialize(amount, currency = "USD") - # @amount, @currency = amount, currency - # end - # - # def exchange_to(other_currency) - # exchanged_amount = (amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor - # Money.new(exchanged_amount, other_currency) - # end - # - # def ==(other_money) - # amount == other_money.amount && currency == other_money.currency - # end - # - # def <=>(other_money) - # if currency == other_money.currency - # amount <=> amount - # else - # amount <=> other_money.exchange_to(currency).amount - # end - # end - # end - # - # class Address - # attr_reader :street, :city - # def initialize(street, city) - # @street, @city = street, city - # end - # - # def close_to?(other_address) - # city == other_address.city - # end - # - # def ==(other_address) - # city == other_address.city && street == other_address.street - # end - # end - # - # Now it's possible to access attributes from the database through the value objects instead. If you choose to name the - # composition the same as the attribute's name, it will be the only way to access that attribute. That's the case with our - # +balance+ attribute. You interact with the value objects just like you would any other attribute, though: - # - # customer.balance = Money.new(20) # sets the Money value object and the attribute - # customer.balance # => Money value object - # customer.balance.exchange_to("DKK") # => Money.new(120, "DKK") - # customer.balance > Money.new(10) # => true - # customer.balance == Money.new(20) # => true - # customer.balance < Money.new(5) # => false - # - # Value objects can also be composed of multiple attributes, such as the case of Address. The order of the mappings will - # determine the order of the parameters. Example: - # - # customer.address_street = "Hyancintvej" - # customer.address_city = "Copenhagen" - # customer.address # => Address.new("Hyancintvej", "Copenhagen") - # customer.address = Address.new("May Street", "Chicago") - # customer.address_street # => "May Street" - # customer.address_city # => "Chicago" - # - # == Writing value objects - # - # Value objects are immutable and interchangeable objects that represent a given value, such as a Money object representing - # $5. Two Money objects both representing $5 should be equal (through methods such as <tt>==</tt> and <tt><=></tt> from Comparable if ranking - # makes sense). This is unlike entity objects where equality is determined by identity. An entity class such as Customer can - # easily have two different objects that both have an address on Hyancintvej. Entity identity is determined by object or - # relational unique identifiers (such as primary keys). Normal ActiveRecord::Base classes are entity objects. - # - # It's also important to treat the value objects as immutable. Don't allow the Money object to have its amount changed after - # creation. Create a new Money object with the new value instead. This is exemplified by the Money#exchange_to method that - # returns a new value object instead of changing its own values. Active Record won't persist value objects that have been - # changed through means other than the writer method. - # - # The immutable requirement is enforced by Active Record by freezing any object assigned as a value object. Attempting to - # change it afterwards will result in a ActiveSupport::FrozenObjectError. - # - # Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not keeping value objects - # immutable on http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable - # - # == Custom constructors and converters - # - # By default value objects are initialized by calling the <tt>new</tt> constructor of the value class passing each of the - # mapped attributes, in the order specified by the <tt>:mapping</tt> option, as arguments. If the value class doesn't support - # this convention then +composed_of+ allows a custom constructor to be specified. - # - # When a new value is assigned to the value object the default assumption is that the new value is an instance of the value - # class. Specifying a custom converter allows the new value to be automatically converted to an instance of value class if - # necessary. - # - # For example, the NetworkResource model has +network_address+ and +cidr_range+ attributes that should be aggregated using the - # NetAddr::CIDR value class (http://netaddr.rubyforge.org). The constructor for the value class is called +create+ and it - # expects a CIDR address string as a parameter. New values can be assigned to the value object using either another - # NetAddr::CIDR object, a string or an array. The <tt>:constructor</tt> and <tt>:converter</tt> options can be used to - # meet these requirements: - # - # class NetworkResource < ActiveRecord::Base - # composed_of :cidr, - # :class_name => 'NetAddr::CIDR', - # :mapping => [ %w(network_address network), %w(cidr_range bits) ], - # :allow_nil => true, - # :constructor => Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") }, - # :converter => Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) } - # end - # - # # This calls the :constructor - # network_resource = NetworkResource.new(:network_address => '192.168.0.1', :cidr_range => 24) - # - # # These assignments will both use the :converter - # network_resource.cidr = [ '192.168.2.1', 8 ] - # network_resource.cidr = '192.168.0.1/24' - # - # # This assignment won't use the :converter as the value is already an instance of the value class - # network_resource.cidr = NetAddr::CIDR.create('192.168.2.1/8') - # - # # Saving and then reloading will use the :constructor on reload - # network_resource.save - # network_resource.reload - # - # == Finding records by a value object - # - # Once a +composed_of+ relationship is specified for a model, records can be loaded from the database by specifying an instance - # of the value object in the conditions hash. The following example finds all customers with +balance_amount+ equal to 20 and - # +balance_currency+ equal to "USD": - # - # Customer.find(:all, :conditions => {:balance => Money.new(20, "USD")}) - # - module ClassMethods - # Adds reader and writer methods for manipulating a value object: - # <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods. - # - # Options are: - # * <tt>:class_name</tt> - Specifies the class name of the association. Use it only if that name can't be inferred - # from the part id. So <tt>composed_of :address</tt> will by default be linked to the Address class, but - # if the real class name is CompanyAddress, you'll have to specify it with this option. - # * <tt>:mapping</tt> - Specifies the mapping of entity attributes to attributes of the value object. Each mapping - # is represented as an array where the first item is the name of the entity attribute and the second item is the - # name the attribute in the value object. The order in which mappings are defined determine the order in which - # attributes are sent to the value class constructor. - # * <tt>:allow_nil</tt> - Specifies that the value object will not be instantiated when all mapped - # attributes are +nil+. Setting the value object to +nil+ has the effect of writing +nil+ to all mapped attributes. - # This defaults to +false+. - # * <tt>:constructor</tt> - A symbol specifying the name of the constructor method or a Proc that is called to - # initialize the value object. The constructor is passed all of the mapped attributes, in the order that they - # are defined in the <tt>:mapping option</tt>, as arguments and uses them to instantiate a <tt>:class_name</tt> object. - # The default is <tt>:new</tt>. - # * <tt>:converter</tt> - A symbol specifying the name of a class method of <tt>:class_name</tt> or a Proc that is - # called when a new value is assigned to the value object. The converter is passed the single value that is used - # in the assignment and is only called if the new value is not an instance of <tt>:class_name</tt>. - # - # Option examples: - # composed_of :temperature, :mapping => %w(reading celsius) - # composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money } - # composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] - # composed_of :gps_location - # composed_of :gps_location, :allow_nil => true - # composed_of :ip_address, - # :class_name => 'IPAddr', - # :mapping => %w(ip to_i), - # :constructor => Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) }, - # :converter => Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) } - # - def composed_of(part_id, options = {}, &block) - options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter) - - name = part_id.id2name - class_name = options[:class_name] || name.camelize - mapping = options[:mapping] || [ name, name ] - mapping = [ mapping ] unless mapping.first.is_a?(Array) - allow_nil = options[:allow_nil] || false - constructor = options[:constructor] || :new - converter = options[:converter] || block - - ActiveSupport::Deprecation.warn('The conversion block has been deprecated, use the :converter option instead.', caller) if block_given? - - reader_method(name, class_name, mapping, allow_nil, constructor) - writer_method(name, class_name, mapping, allow_nil, converter) - - create_reflection(:composed_of, part_id, options, self) - end - - private - def reader_method(name, class_name, mapping, allow_nil, constructor) - module_eval do - define_method(name) do |*args| - force_reload = args.first || false - if (instance_variable_get("@#{name}").nil? || force_reload) && (!allow_nil || mapping.any? {|pair| !read_attribute(pair.first).nil? }) - attrs = mapping.collect {|pair| read_attribute(pair.first)} - object = case constructor - when Symbol - class_name.constantize.send(constructor, *attrs) - when Proc, Method - constructor.call(*attrs) - else - raise ArgumentError, 'Constructor must be a symbol denoting the constructor method to call or a Proc to be invoked.' - end - instance_variable_set("@#{name}", object) - end - instance_variable_get("@#{name}") - end - end - - end - - def writer_method(name, class_name, mapping, allow_nil, converter) - module_eval do - define_method("#{name}=") do |part| - if part.nil? && allow_nil - mapping.each { |pair| self[pair.first] = nil } - instance_variable_set("@#{name}", nil) - else - unless part.is_a?(class_name.constantize) || converter.nil? - part = case converter - when Symbol - class_name.constantize.send(converter, part) - when Proc, Method - converter.call(part) - else - raise ArgumentError, 'Converter must be a symbol denoting the converter method to call or a Proc to be invoked.' - end - end - mapping.each { |pair| self[pair.first] = part.send(pair.last) } - instance_variable_set("@#{name}", part.freeze) - end - end - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/association_preload.rb b/vendor/rails/activerecord/lib/active_record/association_preload.rb deleted file mode 100644 index 7acc4151..00000000 --- a/vendor/rails/activerecord/lib/active_record/association_preload.rb +++ /dev/null @@ -1,406 +0,0 @@ -module ActiveRecord - # See ActiveRecord::AssociationPreload::ClassMethods for documentation. - module AssociationPreload #:nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # Implements the details of eager loading of ActiveRecord associations. - # Application developers should not use this module directly. - # - # ActiveRecord::Base is extended with this module. The source code in - # ActiveRecord::Base references methods defined in this module. - # - # Note that 'eager loading' and 'preloading' are actually the same thing. - # However, there are two different eager loading strategies. - # - # The first one is by using table joins. This was only strategy available - # prior to Rails 2.1. Suppose that you have an Author model with columns - # 'name' and 'age', and a Book model with columns 'name' and 'sales'. Using - # this strategy, ActiveRecord would try to retrieve all data for an author - # and all of its books via a single query: - # - # SELECT * FROM authors - # LEFT OUTER JOIN books ON authors.id = books.id - # WHERE authors.name = 'Ken Akamatsu' - # - # However, this could result in many rows that contain redundant data. After - # having received the first row, we already have enough data to instantiate - # the Author object. In all subsequent rows, only the data for the joined - # 'books' table is useful; the joined 'authors' data is just redundant, and - # processing this redundant data takes memory and CPU time. The problem - # quickly becomes worse and worse as the level of eager loading increases - # (i.e. if ActiveRecord is to eager load the associations' assocations as - # well). - # - # The second strategy is to use multiple database queries, one for each - # level of association. Since Rails 2.1, this is the default strategy. In - # situations where a table join is necessary (e.g. when the +:conditions+ - # option references an association's column), it will fallback to the table - # join strategy. - # - # See also ActiveRecord::Associations::ClassMethods, which explains eager - # loading in a more high-level (application developer-friendly) manner. - module ClassMethods - protected - - # Eager loads the named associations for the given ActiveRecord record(s). - # - # In this description, 'association name' shall refer to the name passed - # to an association creation method. For example, a model that specifies - # <tt>belongs_to :author</tt>, <tt>has_many :buyers</tt> has association - # names +:author+ and +:buyers+. - # - # == Parameters - # +records+ is an array of ActiveRecord::Base. This array needs not be flat, - # i.e. +records+ itself may also contain arrays of records. In any case, - # +preload_associations+ will preload the associations all records by - # flattening +records+. - # - # +associations+ specifies one or more associations that you want to - # preload. It may be: - # - a Symbol or a String which specifies a single association name. For - # example, specifiying +:books+ allows this method to preload all books - # for an Author. - # - an Array which specifies multiple association names. This array - # is processed recursively. For example, specifying <tt>[:avatar, :books]</tt> - # allows this method to preload an author's avatar as well as all of his - # books. - # - a Hash which specifies multiple association names, as well as - # association names for the to-be-preloaded association objects. For - # example, specifying <tt>{ :author => :avatar }</tt> will preload a - # book's author, as well as that author's avatar. - # - # +:associations+ has the same format as the +:include+ option for - # <tt>ActiveRecord::Base.find</tt>. So +associations+ could look like this: - # - # :books - # [ :books, :author ] - # { :author => :avatar } - # [ :books, { :author => :avatar } ] - # - # +preload_options+ contains options that will be passed to ActiveRecord#find - # (which is called under the hood for preloading records). But it is passed - # only one level deep in the +associations+ argument, i.e. it's not passed - # to the child associations when +associations+ is a Hash. - def preload_associations(records, associations, preload_options={}) - records = [records].flatten.compact.uniq - return if records.empty? - case associations - when Array then associations.each {|association| preload_associations(records, association, preload_options)} - when Symbol, String then preload_one_association(records, associations.to_sym, preload_options) - when Hash then - associations.each do |parent, child| - raise "parent must be an association name" unless parent.is_a?(String) || parent.is_a?(Symbol) - preload_associations(records, parent, preload_options) - reflection = reflections[parent] - parents = records.map {|record| record.send(reflection.name)}.flatten.compact - unless parents.empty? - parents.first.class.preload_associations(parents, child) - end - end - end - end - - private - - # Preloads a specific named association for the given records. This is - # called by +preload_associations+ as its base case. - def preload_one_association(records, association, preload_options={}) - class_to_reflection = {} - # Not all records have the same class, so group then preload - # group on the reflection itself so that if various subclass share the same association then we do not split them - # unnecessarily - records.group_by {|record| class_to_reflection[record.class] ||= record.class.reflections[association]}.each do |reflection, records| - raise ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?" unless reflection - - # 'reflection.macro' can return 'belongs_to', 'has_many', etc. Thus, - # the following could call 'preload_belongs_to_association', - # 'preload_has_many_association', etc. - send("preload_#{reflection.macro}_association", records, reflection, preload_options) - end - end - - def add_preloaded_records_to_collection(parent_records, reflection_name, associated_record) - parent_records.each do |parent_record| - association_proxy = parent_record.send(reflection_name) - association_proxy.loaded - association_proxy.target.push(*[associated_record].flatten) - association_proxy.__send__(:set_inverse_instance, associated_record, parent_record) - end - end - - def add_preloaded_record_to_collection(parent_records, reflection_name, associated_record) - parent_records.each do |parent_record| - parent_record.send("set_#{reflection_name}_target", associated_record) - end - end - - def set_association_collection_records(id_to_record_map, reflection_name, associated_records, key) - associated_records.each do |associated_record| - mapped_records = id_to_record_map[associated_record[key].to_s] - add_preloaded_records_to_collection(mapped_records, reflection_name, associated_record) - end - end - - def set_association_single_records(id_to_record_map, reflection_name, associated_records, key) - seen_keys = {} - associated_records.each do |associated_record| - #this is a has_one or belongs_to: there should only be one record. - #Unfortunately we can't (in portable way) ask the database for 'all records where foo_id in (x,y,z), but please - # only one row per distinct foo_id' so this where we enforce that - next if seen_keys[associated_record[key].to_s] - seen_keys[associated_record[key].to_s] = true - mapped_records = id_to_record_map[associated_record[key].to_s] - mapped_records.each do |mapped_record| - association_proxy = mapped_record.send("set_#{reflection_name}_target", associated_record) - association_proxy.__send__(:set_inverse_instance, associated_record, mapped_record) - end - end - - id_to_record_map.each do |id, records| - next if seen_keys.include?(id.to_s) - records.each {|record| record.send("set_#{reflection_name}_target", nil) } - end - end - - # Given a collection of ActiveRecord objects, constructs a Hash which maps - # the objects' IDs to the relevant objects. Returns a 2-tuple - # <tt>(id_to_record_map, ids)</tt> where +id_to_record_map+ is the Hash, - # and +ids+ is an Array of record IDs. - def construct_id_map(records, primary_key=nil) - id_to_record_map = {} - ids = [] - records.each do |record| - primary_key ||= record.class.primary_key - ids << record[primary_key] - mapped_records = (id_to_record_map[ids.last.to_s] ||= []) - mapped_records << record - end - ids.uniq! - return id_to_record_map, ids - end - - def preload_has_and_belongs_to_many_association(records, reflection, preload_options={}) - table_name = reflection.klass.quoted_table_name - id_to_record_map, ids = construct_id_map(records) - records.each {|record| record.send(reflection.name).loaded} - options = reflection.options - - conditions = "t0.#{reflection.primary_key_name} #{in_or_equals_for_ids(ids)}" - conditions << append_conditions(reflection, preload_options) - - associated_records = reflection.klass.with_exclusive_scope do - reflection.klass.find(:all, :conditions => [conditions, ids], - :include => options[:include], - :joins => "INNER JOIN #{connection.quote_table_name options[:join_table]} t0 ON #{reflection.klass.quoted_table_name}.#{reflection.klass.primary_key} = t0.#{reflection.association_foreign_key}", - :select => "#{options[:select] || table_name+'.*'}, t0.#{reflection.primary_key_name} as the_parent_record_id", - :order => options[:order]) - end - set_association_collection_records(id_to_record_map, reflection.name, associated_records, 'the_parent_record_id') - end - - def preload_has_one_association(records, reflection, preload_options={}) - return if records.first.send("loaded_#{reflection.name}?") - id_to_record_map, ids = construct_id_map(records, reflection.options[:primary_key]) - options = reflection.options - records.each {|record| record.send("set_#{reflection.name}_target", nil)} - if options[:through] - through_records = preload_through_records(records, reflection, options[:through]) - through_reflection = reflections[options[:through]] - through_primary_key = through_reflection.primary_key_name - unless through_records.empty? - source = reflection.source_reflection.name - through_records.first.class.preload_associations(through_records, source) - if through_reflection.macro == :belongs_to - rev_id_to_record_map, rev_ids = construct_id_map(records, through_primary_key) - rev_primary_key = through_reflection.klass.primary_key - through_records.each do |through_record| - add_preloaded_record_to_collection(rev_id_to_record_map[through_record[rev_primary_key].to_s], - reflection.name, through_record.send(source)) - end - else - through_records.each do |through_record| - add_preloaded_record_to_collection(id_to_record_map[through_record[through_primary_key].to_s], - reflection.name, through_record.send(source)) - end - end - end - else - set_association_single_records(id_to_record_map, reflection.name, find_associated_records(ids, reflection, preload_options), reflection.primary_key_name) - end - end - - def preload_has_many_association(records, reflection, preload_options={}) - return if records.first.send(reflection.name).loaded? - options = reflection.options - - primary_key_name = reflection.through_reflection_primary_key_name - id_to_record_map, ids = construct_id_map(records, primary_key_name || reflection.options[:primary_key]) - records.each {|record| record.send(reflection.name).loaded} - - if options[:through] - through_records = preload_through_records(records, reflection, options[:through]) - through_reflection = reflections[options[:through]] - unless through_records.empty? - source = reflection.source_reflection.name - through_records.first.class.preload_associations(through_records, source, options) - through_records.each do |through_record| - through_record_id = through_record[reflection.through_reflection_primary_key].to_s - add_preloaded_records_to_collection(id_to_record_map[through_record_id], reflection.name, through_record.send(source)) - end - end - - else - set_association_collection_records(id_to_record_map, reflection.name, find_associated_records(ids, reflection, preload_options), - reflection.primary_key_name) - end - end - - def preload_through_records(records, reflection, through_association) - through_reflection = reflections[through_association] - through_primary_key = through_reflection.primary_key_name - - if reflection.options[:source_type] - interface = reflection.source_reflection.options[:foreign_type] - preload_options = {:conditions => ["#{connection.quote_column_name interface} = ?", reflection.options[:source_type]]} - - records.compact! - records.first.class.preload_associations(records, through_association, preload_options) - - # Dont cache the association - we would only be caching a subset - through_records = [] - records.each do |record| - proxy = record.send(through_association) - - if proxy.respond_to?(:target) - through_records << proxy.target - proxy.reset - else # this is a has_one :through reflection - through_records << proxy if proxy - end - end - through_records.flatten! - else - options = {} - options[:include] = reflection.options[:include] || reflection.options[:source] if reflection.options[:conditions] || reflection.options[:order] - options[:order] = reflection.options[:order] - options[:conditions] = reflection.options[:conditions] - records.first.class.preload_associations(records, through_association, options) - through_records = records.map {|record| record.send(through_association)}.flatten - end - through_records.compact! - through_records - end - - def preload_belongs_to_association(records, reflection, preload_options={}) - return if records.first.send("loaded_#{reflection.name}?") - options = reflection.options - primary_key_name = reflection.primary_key_name - - if options[:polymorphic] - polymorph_type = options[:foreign_type] - klasses_and_ids = {} - - # Construct a mapping from klass to a list of ids to load and a mapping of those ids back to their parent_records - records.each do |record| - if klass = record.send(polymorph_type) - klass_id = record.send(primary_key_name) - if klass_id - id_map = klasses_and_ids[klass] ||= {} - id_list_for_klass_id = (id_map[klass_id.to_s] ||= []) - id_list_for_klass_id << record - end - end - end - klasses_and_ids = klasses_and_ids.to_a - else - id_map = {} - records.each do |record| - key = record.send(primary_key_name) - if key - mapped_records = (id_map[key.to_s] ||= []) - mapped_records << record - end - end - klasses_and_ids = [[reflection.klass.name, id_map]] - end - - klasses_and_ids.each do |klass_and_id| - klass_name, id_map = *klass_and_id - next if id_map.empty? - klass = klass_name.constantize - - table_name = klass.quoted_table_name - primary_key = reflection.options[:primary_key] || klass.primary_key - column_type = klass.columns.detect{|c| c.name == primary_key}.type - ids = id_map.keys.map do |id| - if column_type == :integer - id.to_i - elsif column_type == :float - id.to_f - else - id - end - end - conditions = "#{table_name}.#{connection.quote_column_name(primary_key)} #{in_or_equals_for_ids(ids)}" - conditions << append_conditions(reflection, preload_options) - associated_records = klass.with_exclusive_scope do - klass.find(:all, :conditions => [conditions, ids], - :include => options[:include], - :select => options[:select], - :joins => options[:joins], - :order => options[:order]) - end - set_association_single_records(id_map, reflection.name, associated_records, primary_key) - end - end - - def find_associated_records(ids, reflection, preload_options) - options = reflection.options - table_name = reflection.klass.quoted_table_name - - if interface = reflection.options[:as] - parent_type = if reflection.active_record.abstract_class? - self.base_class.sti_name - else - reflection.active_record.sti_name - end - - conditions = "#{reflection.klass.quoted_table_name}.#{connection.quote_column_name "#{interface}_id"} #{in_or_equals_for_ids(ids)} and #{reflection.klass.quoted_table_name}.#{connection.quote_column_name "#{interface}_type"} = '#{parent_type}'" - else - foreign_key = reflection.primary_key_name - conditions = "#{reflection.klass.quoted_table_name}.#{foreign_key} #{in_or_equals_for_ids(ids)}" - end - - conditions << append_conditions(reflection, preload_options) - - reflection.klass.with_exclusive_scope do - reflection.klass.find(:all, - :select => (preload_options[:select] || options[:select] || "#{table_name}.*"), - :include => preload_options[:include] || options[:include], - :conditions => [conditions, ids], - :joins => options[:joins], - :group => preload_options[:group] || options[:group], - :order => preload_options[:order] || options[:order]) - end - end - - - def interpolate_sql_for_preload(sql) - instance_eval("%@#{sql.gsub('@', '\@')}@") - end - - def append_conditions(reflection, preload_options) - sql = "" - sql << " AND (#{interpolate_sql_for_preload(reflection.sanitized_conditions)})" if reflection.sanitized_conditions - sql << " AND (#{sanitize_sql preload_options[:conditions]})" if preload_options[:conditions] - sql - end - - def in_or_equals_for_ids(ids) - ids.size > 1 ? "IN (?)" : "= ?" - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations.rb b/vendor/rails/activerecord/lib/active_record/associations.rb deleted file mode 100755 index 3a325815..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations.rb +++ /dev/null @@ -1,2251 +0,0 @@ -module ActiveRecord - class InverseOfAssociationNotFoundError < ActiveRecordError #:nodoc: - def initialize(reflection, associated_class = nil) - super("Could not find the inverse association for #{reflection.name} (#{reflection.options[:inverse_of].inspect} in #{associated_class.nil? ? reflection.class_name : associated_class.name})") - end - end - - class HasManyThroughAssociationNotFoundError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection) - super("Could not find the association #{reflection.options[:through].inspect} in model #{owner_class_name}") - end - end - - class HasManyThroughAssociationPolymorphicError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection, source_reflection) - super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' on the polymorphic object '#{source_reflection.class_name}##{source_reflection.name}'.") - end - end - - class HasManyThroughAssociationPointlessSourceTypeError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection, source_reflection) - super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' with a :source_type option if the '#{reflection.through_reflection.class_name}##{source_reflection.name}' is not polymorphic. Try removing :source_type on your association.") - end - end - - class HasManyThroughSourceAssociationNotFoundError < ActiveRecordError #:nodoc: - def initialize(reflection) - through_reflection = reflection.through_reflection - source_reflection_names = reflection.source_reflection_names - source_associations = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect } - super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?") - end - end - - class HasManyThroughSourceAssociationMacroError < ActiveRecordError #:nodoc: - def initialize(reflection) - through_reflection = reflection.through_reflection - source_reflection = reflection.source_reflection - super("Invalid source reflection macro :#{source_reflection.macro}#{" :through" if source_reflection.options[:through]} for has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}. Use :source to specify the source reflection.") - end - end - - class HasManyThroughCantAssociateThroughHasOneOrManyReflection < ActiveRecordError #:nodoc: - def initialize(owner, reflection) - super("Cannot modify association '#{owner.class.name}##{reflection.name}' because the source reflection class '#{reflection.source_reflection.class_name}' is associated to '#{reflection.through_reflection.class_name}' via :#{reflection.source_reflection.macro}.") - end - end - HasManyThroughCantAssociateThroughHasManyReflection = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection', 'ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection') - - class HasManyThroughCantAssociateNewRecords < ActiveRecordError #:nodoc: - def initialize(owner, reflection) - super("Cannot associate new records through '#{owner.class.name}##{reflection.name}' on '#{reflection.source_reflection.class_name rescue nil}##{reflection.source_reflection.name rescue nil}'. Both records must have an id in order to create the has_many :through record associating them.") - end - end - - class HasManyThroughCantDissociateNewRecords < ActiveRecordError #:nodoc: - def initialize(owner, reflection) - super("Cannot dissociate new records through '#{owner.class.name}##{reflection.name}' on '#{reflection.source_reflection.class_name rescue nil}##{reflection.source_reflection.name rescue nil}'. Both records must have an id in order to delete the has_many :through record associating them.") - end - end - - class HasAndBelongsToManyAssociationForeignKeyNeeded < ActiveRecordError #:nodoc: - def initialize(reflection) - super("Cannot create self referential has_and_belongs_to_many association on '#{reflection.class_name rescue nil}##{reflection.name rescue nil}'. :association_foreign_key cannot be the same as the :foreign_key.") - end - end - - class EagerLoadPolymorphicError < ActiveRecordError #:nodoc: - def initialize(reflection) - super("Can not eagerly load the polymorphic association #{reflection.name.inspect}") - end - end - - class ReadOnlyAssociation < ActiveRecordError #:nodoc: - def initialize(reflection) - super("Can not add to a has_many :through association. Try adding to #{reflection.through_reflection.name.inspect}.") - end - end - - # See ActiveRecord::Associations::ClassMethods for documentation. - module Associations # :nodoc: - # These classes will be loaded when associations are created. - # So there is no need to eager load them. - autoload :AssociationCollection, 'active_record/associations/association_collection' - autoload :AssociationProxy, 'active_record/associations/association_proxy' - autoload :BelongsToAssociation, 'active_record/associations/belongs_to_association' - autoload :BelongsToPolymorphicAssociation, 'active_record/associations/belongs_to_polymorphic_association' - autoload :HasAndBelongsToManyAssociation, 'active_record/associations/has_and_belongs_to_many_association' - autoload :HasManyAssociation, 'active_record/associations/has_many_association' - autoload :HasManyThroughAssociation, 'active_record/associations/has_many_through_association' - autoload :HasOneAssociation, 'active_record/associations/has_one_association' - autoload :HasOneThroughAssociation, 'active_record/associations/has_one_through_association' - - def self.included(base) - base.extend(ClassMethods) - end - - # Clears out the association cache - def clear_association_cache #:nodoc: - self.class.reflect_on_all_associations.to_a.each do |assoc| - instance_variable_set "@#{assoc.name}", nil - end unless self.new_record? - end - - private - # Gets the specified association instance if it responds to :loaded?, nil otherwise. - def association_instance_get(name) - association = instance_variable_get("@#{name}") - association if association.respond_to?(:loaded?) - end - - # Set the specified association instance. - def association_instance_set(name, association) - instance_variable_set("@#{name}", association) - end - - # Associations are a set of macro-like class methods for tying objects together through foreign keys. They express relationships like - # "Project has one Project Manager" or "Project belongs to a Portfolio". Each macro adds a number of methods to the class which are - # specialized according to the collection or association symbol and the options hash. It works much the same way as Ruby's own <tt>attr*</tt> - # methods. Example: - # - # class Project < ActiveRecord::Base - # belongs_to :portfolio - # has_one :project_manager - # has_many :milestones - # has_and_belongs_to_many :categories - # end - # - # The project class now has the following methods (and more) to ease the traversal and manipulation of its relationships: - # * <tt>Project#portfolio, Project#portfolio=(portfolio), Project#portfolio.nil?</tt> - # * <tt>Project#project_manager, Project#project_manager=(project_manager), Project#project_manager.nil?,</tt> - # * <tt>Project#milestones.empty?, Project#milestones.size, Project#milestones, Project#milestones<<(milestone),</tt> - # <tt>Project#milestones.delete(milestone), Project#milestones.find(milestone_id), Project#milestones.find(:all, options),</tt> - # <tt>Project#milestones.build, Project#milestones.create</tt> - # * <tt>Project#categories.empty?, Project#categories.size, Project#categories, Project#categories<<(category1),</tt> - # <tt>Project#categories.delete(category1)</tt> - # - # === A word of warning - # - # Don't create associations that have the same name as instance methods of ActiveRecord::Base. Since the association - # adds a method with that name to its model, it will override the inherited method and break things. - # For instance, +attributes+ and +connection+ would be bad choices for association names. - # - # == Auto-generated methods - # - # === Singular associations (one-to-one) - # | | belongs_to | - # generated methods | belongs_to | :polymorphic | has_one - # ----------------------------------+------------+--------------+--------- - # other | X | X | X - # other=(other) | X | X | X - # build_other(attributes={}) | X | | X - # create_other(attributes={}) | X | | X - # other.create!(attributes={}) | | | X - # - # ===Collection associations (one-to-many / many-to-many) - # | | | has_many - # generated methods | habtm | has_many | :through - # ----------------------------------+-------+----------+---------- - # others | X | X | X - # others=(other,other,...) | X | X | X - # other_ids | X | X | X - # other_ids=(id,id,...) | X | X | X - # others<< | X | X | X - # others.push | X | X | X - # others.concat | X | X | X - # others.build(attributes={}) | X | X | X - # others.create(attributes={}) | X | X | X - # others.create!(attributes={}) | X | X | X - # others.size | X | X | X - # others.length | X | X | X - # others.count | X | X | X - # others.sum(args*,&block) | X | X | X - # others.empty? | X | X | X - # others.clear | X | X | X - # others.delete(other,other,...) | X | X | X - # others.delete_all | X | X | - # others.destroy_all | X | X | X - # others.find(*args) | X | X | X - # others.find_first | X | | - # others.exists? | X | X | X - # others.uniq | X | X | X - # others.reset | X | X | X - # - # == Cardinality and associations - # - # Active Record associations can be used to describe one-to-one, one-to-many and many-to-many - # relationships between models. Each model uses an association to describe its role in - # the relation. The +belongs_to+ association is always used in the model that has - # the foreign key. - # - # === One-to-one - # - # Use +has_one+ in the base, and +belongs_to+ in the associated model. - # - # class Employee < ActiveRecord::Base - # has_one :office - # end - # class Office < ActiveRecord::Base - # belongs_to :employee # foreign key - employee_id - # end - # - # === One-to-many - # - # Use +has_many+ in the base, and +belongs_to+ in the associated model. - # - # class Manager < ActiveRecord::Base - # has_many :employees - # end - # class Employee < ActiveRecord::Base - # belongs_to :manager # foreign key - manager_id - # end - # - # === Many-to-many - # - # There are two ways to build a many-to-many relationship. - # - # The first way uses a +has_many+ association with the <tt>:through</tt> option and a join model, so - # there are two stages of associations. - # - # class Assignment < ActiveRecord::Base - # belongs_to :programmer # foreign key - programmer_id - # belongs_to :project # foreign key - project_id - # end - # class Programmer < ActiveRecord::Base - # has_many :assignments - # has_many :projects, :through => :assignments - # end - # class Project < ActiveRecord::Base - # has_many :assignments - # has_many :programmers, :through => :assignments - # end - # - # For the second way, use +has_and_belongs_to_many+ in both models. This requires a join table - # that has no corresponding model or primary key. - # - # class Programmer < ActiveRecord::Base - # has_and_belongs_to_many :projects # foreign keys in the join table - # end - # class Project < ActiveRecord::Base - # has_and_belongs_to_many :programmers # foreign keys in the join table - # end - # - # Choosing which way to build a many-to-many relationship is not always simple. - # If you need to work with the relationship model as its own entity, - # use <tt>has_many :through</tt>. Use +has_and_belongs_to_many+ when working with legacy schemas or when - # you never work directly with the relationship itself. - # - # == Is it a +belongs_to+ or +has_one+ association? - # - # Both express a 1-1 relationship. The difference is mostly where to place the foreign key, which goes on the table for the class - # declaring the +belongs_to+ relationship. Example: - # - # class User < ActiveRecord::Base - # # I reference an account. - # belongs_to :account - # end - # - # class Account < ActiveRecord::Base - # # One user references me. - # has_one :user - # end - # - # The tables for these classes could look something like: - # - # CREATE TABLE users ( - # id int(11) NOT NULL auto_increment, - # account_id int(11) default NULL, - # name varchar default NULL, - # PRIMARY KEY (id) - # ) - # - # CREATE TABLE accounts ( - # id int(11) NOT NULL auto_increment, - # name varchar default NULL, - # PRIMARY KEY (id) - # ) - # - # == Unsaved objects and associations - # - # You can manipulate objects and associations before they are saved to the database, but there is some special behavior you should be - # aware of, mostly involving the saving of associated objects. - # - # Unless you set the :autosave option on a <tt>has_one</tt>, <tt>belongs_to</tt>, - # <tt>has_many</tt>, or <tt>has_and_belongs_to_many</tt> association. Setting it - # to +true+ will _always_ save the members, whereas setting it to +false+ will - # _never_ save the members. - # - # === One-to-one associations - # - # * Assigning an object to a +has_one+ association automatically saves that object and the object being replaced (if there is one), in - # order to update their primary keys - except if the parent object is unsaved (<tt>new_record? == true</tt>). - # * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns +false+ and the assignment - # is cancelled. - # * If you wish to assign an object to a +has_one+ association without saving it, use the <tt>association.build</tt> method (documented below). - # * Assigning an object to a +belongs_to+ association does not save the object, since the foreign key field belongs on the parent. It - # does not save the parent either. - # - # === Collections - # - # * Adding an object to a collection (+has_many+ or +has_and_belongs_to_many+) automatically saves that object, except if the parent object - # (the owner of the collection) is not yet stored in the database. - # * If saving any of the objects being added to a collection (via <tt>push</tt> or similar) fails, then <tt>push</tt> returns +false+. - # * You can add an object to a collection without automatically saving it by using the <tt>collection.build</tt> method (documented below). - # * All unsaved (<tt>new_record? == true</tt>) members of the collection are automatically saved when the parent is saved. - # - # === Association callbacks - # - # Similar to the normal callbacks that hook into the lifecycle of an Active Record object, you can also define callbacks that get - # triggered when you add an object to or remove an object from an association collection. Example: - # - # class Project - # has_and_belongs_to_many :developers, :after_add => :evaluate_velocity - # - # def evaluate_velocity(developer) - # ... - # end - # end - # - # It's possible to stack callbacks by passing them as an array. Example: - # - # class Project - # has_and_belongs_to_many :developers, :after_add => [:evaluate_velocity, Proc.new { |p, d| p.shipping_date = Time.now}] - # end - # - # Possible callbacks are: +before_add+, +after_add+, +before_remove+ and +after_remove+. - # - # Should any of the +before_add+ callbacks throw an exception, the object does not get added to the collection. Same with - # the +before_remove+ callbacks; if an exception is thrown the object doesn't get removed. - # - # === Association extensions - # - # The proxy objects that control the access to associations can be extended through anonymous modules. This is especially - # beneficial for adding new finders, creators, and other factory-type methods that are only used as part of this association. - # Example: - # - # class Account < ActiveRecord::Base - # has_many :people do - # def find_or_create_by_name(name) - # first_name, last_name = name.split(" ", 2) - # find_or_create_by_first_name_and_last_name(first_name, last_name) - # end - # end - # end - # - # person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson") - # person.first_name # => "David" - # person.last_name # => "Heinemeier Hansson" - # - # If you need to share the same extensions between many associations, you can use a named extension module. Example: - # - # module FindOrCreateByNameExtension - # def find_or_create_by_name(name) - # first_name, last_name = name.split(" ", 2) - # find_or_create_by_first_name_and_last_name(first_name, last_name) - # end - # end - # - # class Account < ActiveRecord::Base - # has_many :people, :extend => FindOrCreateByNameExtension - # end - # - # class Company < ActiveRecord::Base - # has_many :people, :extend => FindOrCreateByNameExtension - # end - # - # If you need to use multiple named extension modules, you can specify an array of modules with the <tt>:extend</tt> option. - # In the case of name conflicts between methods in the modules, methods in modules later in the array supercede - # those earlier in the array. Example: - # - # class Account < ActiveRecord::Base - # has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] - # end - # - # Some extensions can only be made to work with knowledge of the association proxy's internals. - # Extensions can access relevant state using accessors on the association proxy: - # - # * +proxy_owner+ - Returns the object the association is part of. - # * +proxy_reflection+ - Returns the reflection object that describes the association. - # * +proxy_target+ - Returns the associated object for +belongs_to+ and +has_one+, or the collection of associated objects for +has_many+ and +has_and_belongs_to_many+. - # - # === Association Join Models - # - # Has Many associations can be configured with the <tt>:through</tt> option to use an explicit join model to retrieve the data. This - # operates similarly to a +has_and_belongs_to_many+ association. The advantage is that you're able to add validations, - # callbacks, and extra attributes on the join model. Consider the following schema: - # - # class Author < ActiveRecord::Base - # has_many :authorships - # has_many :books, :through => :authorships - # end - # - # class Authorship < ActiveRecord::Base - # belongs_to :author - # belongs_to :book - # end - # - # @author = Author.find :first - # @author.authorships.collect { |a| a.book } # selects all books that the author's authorships belong to. - # @author.books # selects all books by using the Authorship join model - # - # You can also go through a +has_many+ association on the join model: - # - # class Firm < ActiveRecord::Base - # has_many :clients - # has_many :invoices, :through => :clients - # end - # - # class Client < ActiveRecord::Base - # belongs_to :firm - # has_many :invoices - # end - # - # class Invoice < ActiveRecord::Base - # belongs_to :client - # end - # - # @firm = Firm.find :first - # @firm.clients.collect { |c| c.invoices }.flatten # select all invoices for all clients of the firm - # @firm.invoices # selects all invoices by going through the Client join model. - # - # Similarly you can go through a +has_one+ association on the join model: - # - # class Group < ActiveRecord::Base - # has_many :users - # has_many :avatars, :through => :users - # end - # - # class User < ActiveRecord::Base - # belongs_to :group - # has_one :avatar - # end - # - # class Avatar < ActiveRecord::Base - # belongs_to :user - # end - # - # @group = Group.first - # @group.users.collect { |u| u.avatar }.flatten # select all avatars for all users in the group - # @group.avatars # selects all avatars by going through the User join model. - # - # An important caveat with going through +has_one+ or +has_many+ associations on the join model is that these associations are - # *read-only*. For example, the following would not work following the previous example: - # - # @group.avatars << Avatar.new # this would work if User belonged_to Avatar rather than the other way around. - # @group.avatars.delete(@group.avatars.last) # so would this - # - # === Polymorphic Associations - # - # Polymorphic associations on models are not restricted on what types of models they can be associated with. Rather, they - # specify an interface that a +has_many+ association must adhere to. - # - # class Asset < ActiveRecord::Base - # belongs_to :attachable, :polymorphic => true - # end - # - # class Post < ActiveRecord::Base - # has_many :assets, :as => :attachable # The :as option specifies the polymorphic interface to use. - # end - # - # @asset.attachable = @post - # - # This works by using a type column in addition to a foreign key to specify the associated record. In the Asset example, you'd need - # an +attachable_id+ integer column and an +attachable_type+ string column. - # - # Using polymorphic associations in combination with single table inheritance (STI) is a little tricky. In order - # for the associations to work as expected, ensure that you store the base model for the STI models in the - # type column of the polymorphic association. To continue with the asset example above, suppose there are guest posts - # and member posts that use the posts table for STI. In this case, there must be a +type+ column in the posts table. - # - # class Asset < ActiveRecord::Base - # belongs_to :attachable, :polymorphic => true - # - # def attachable_type=(sType) - # super(sType.to_s.classify.constantize.base_class.to_s) - # end - # end - # - # class Post < ActiveRecord::Base - # # because we store "Post" in attachable_type now :dependent => :destroy will work - # has_many :assets, :as => :attachable, :dependent => :destroy - # end - # - # class GuestPost < Post - # end - # - # class MemberPost < Post - # end - # - # == Caching - # - # All of the methods are built on a simple caching principle that will keep the result of the last query around unless specifically - # instructed not to. The cache is even shared across methods to make it even cheaper to use the macro-added methods without - # worrying too much about performance at the first go. Example: - # - # project.milestones # fetches milestones from the database - # project.milestones.size # uses the milestone cache - # project.milestones.empty? # uses the milestone cache - # project.milestones(true).size # fetches milestones from the database - # project.milestones # uses the milestone cache - # - # == Eager loading of associations - # - # Eager loading is a way to find objects of a certain class and a number of named associations. This is - # one of the easiest ways of to prevent the dreaded 1+N problem in which fetching 100 posts that each need to display their author - # triggers 101 database queries. Through the use of eager loading, the 101 queries can be reduced to 2. Example: - # - # class Post < ActiveRecord::Base - # belongs_to :author - # has_many :comments - # end - # - # Consider the following loop using the class above: - # - # for post in Post.all - # puts "Post: " + post.title - # puts "Written by: " + post.author.name - # puts "Last comment on: " + post.comments.first.created_on - # end - # - # To iterate over these one hundred posts, we'll generate 201 database queries. Let's first just optimize it for retrieving the author: - # - # for post in Post.find(:all, :include => :author) - # - # This references the name of the +belongs_to+ association that also used the <tt>:author</tt> symbol. After loading the posts, find - # will collect the +author_id+ from each one and load all the referenced authors with one query. Doing so will cut down the number of queries from 201 to 102. - # - # We can improve upon the situation further by referencing both associations in the finder with: - # - # for post in Post.find(:all, :include => [ :author, :comments ]) - # - # This will load all comments with a single query. This reduces the total number of queries to 3. More generally the number of queries - # will be 1 plus the number of associations named (except if some of the associations are polymorphic +belongs_to+ - see below). - # - # To include a deep hierarchy of associations, use a hash: - # - # for post in Post.find(:all, :include => [ :author, { :comments => { :author => :gravatar } } ]) - # - # That'll grab not only all the comments but all their authors and gravatar pictures. You can mix and match - # symbols, arrays and hashes in any combination to describe the associations you want to load. - # - # All of this power shouldn't fool you into thinking that you can pull out huge amounts of data with no performance penalty just because you've reduced - # the number of queries. The database still needs to send all the data to Active Record and it still needs to be processed. So it's no - # catch-all for performance problems, but it's a great way to cut down on the number of queries in a situation as the one described above. - # - # Since only one table is loaded at a time, conditions or orders cannot reference tables other than the main one. If this is the case - # Active Record falls back to the previously used LEFT OUTER JOIN based strategy. For example - # - # Post.find(:all, :include => [ :author, :comments ], :conditions => ['comments.approved = ?', true]) - # - # will result in a single SQL query with joins along the lines of: <tt>LEFT OUTER JOIN comments ON comments.post_id = posts.id</tt> and - # <tt>LEFT OUTER JOIN authors ON authors.id = posts.author_id</tt>. Note that using conditions like this can have unintended consequences. - # In the above example posts with no approved comments are not returned at all, because the conditions apply to the SQL statement as a whole - # and not just to the association. You must disambiguate column references for this fallback to happen, for example - # <tt>:order => "author.name DESC"</tt> will work but <tt>:order => "name DESC"</tt> will not. - # - # If you do want eagerload only some members of an association it is usually more natural to <tt>:include</tt> an association - # which has conditions defined on it: - # - # class Post < ActiveRecord::Base - # has_many :approved_comments, :class_name => 'Comment', :conditions => ['approved = ?', true] - # end - # - # Post.find(:all, :include => :approved_comments) - # - # will load posts and eager load the +approved_comments+ association, which contains only those comments that have been approved. - # - # If you eager load an association with a specified <tt>:limit</tt> option, it will be ignored, returning all the associated objects: - # - # class Picture < ActiveRecord::Base - # has_many :most_recent_comments, :class_name => 'Comment', :order => 'id DESC', :limit => 10 - # end - # - # Picture.find(:first, :include => :most_recent_comments).most_recent_comments # => returns all associated comments. - # - # When eager loaded, conditions are interpolated in the context of the model class, not the model instance. Conditions are lazily interpolated - # before the actual model exists. - # - # Eager loading is supported with polymorphic associations. - # - # class Address < ActiveRecord::Base - # belongs_to :addressable, :polymorphic => true - # end - # - # A call that tries to eager load the addressable model - # - # Address.find(:all, :include => :addressable) - # - # will execute one query to load the addresses and load the addressables with one query per addressable type. - # For example if all the addressables are either of class Person or Company then a total of 3 queries will be executed. The list of - # addressable types to load is determined on the back of the addresses loaded. This is not supported if Active Record has to fallback - # to the previous implementation of eager loading and will raise ActiveRecord::EagerLoadPolymorphicError. The reason is that the parent - # model's type is a column value so its corresponding table name cannot be put in the +FROM+/+JOIN+ clauses of that query. - # - # == Table Aliasing - # - # Active Record uses table aliasing in the case that a table is referenced multiple times in a join. If a table is referenced only once, - # the standard table name is used. The second time, the table is aliased as <tt>#{reflection_name}_#{parent_table_name}</tt>. Indexes are appended - # for any more successive uses of the table name. - # - # Post.find :all, :joins => :comments - # # => SELECT ... FROM posts INNER JOIN comments ON ... - # Post.find :all, :joins => :special_comments # STI - # # => SELECT ... FROM posts INNER JOIN comments ON ... AND comments.type = 'SpecialComment' - # Post.find :all, :joins => [:comments, :special_comments] # special_comments is the reflection name, posts is the parent table name - # # => SELECT ... FROM posts INNER JOIN comments ON ... INNER JOIN comments special_comments_posts - # - # Acts as tree example: - # - # TreeMixin.find :all, :joins => :children - # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # TreeMixin.find :all, :joins => {:children => :parent} - # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # INNER JOIN parents_mixins ... - # TreeMixin.find :all, :joins => {:children => {:parent => :children}} - # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # INNER JOIN parents_mixins ... - # INNER JOIN mixins childrens_mixins_2 - # - # Has and Belongs to Many join tables use the same idea, but add a <tt>_join</tt> suffix: - # - # Post.find :all, :joins => :categories - # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # Post.find :all, :joins => {:categories => :posts} - # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories - # Post.find :all, :joins => {:categories => {:posts => :categories}} - # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories - # INNER JOIN categories_posts categories_posts_join INNER JOIN categories categories_posts_2 - # - # If you wish to specify your own custom joins using a <tt>:joins</tt> option, those table names will take precedence over the eager associations: - # - # Post.find :all, :joins => :comments, :joins => "inner join comments ..." - # # => SELECT ... FROM posts INNER JOIN comments_posts ON ... INNER JOIN comments ... - # Post.find :all, :joins => [:comments, :special_comments], :joins => "inner join comments ..." - # # => SELECT ... FROM posts INNER JOIN comments comments_posts ON ... - # INNER JOIN comments special_comments_posts ... - # INNER JOIN comments ... - # - # Table aliases are automatically truncated according to the maximum length of table identifiers according to the specific database. - # - # == Modules - # - # By default, associations will look for objects within the current module scope. Consider: - # - # module MyApplication - # module Business - # class Firm < ActiveRecord::Base - # has_many :clients - # end - # - # class Client < ActiveRecord::Base; end - # end - # end - # - # When <tt>Firm#clients</tt> is called, it will in turn call <tt>MyApplication::Business::Client.find_all_by_firm_id(firm.id)</tt>. - # If you want to associate with a class in another module scope, this can be done by specifying the complete class name. - # Example: - # - # module MyApplication - # module Business - # class Firm < ActiveRecord::Base; end - # end - # - # module Billing - # class Account < ActiveRecord::Base - # belongs_to :firm, :class_name => "MyApplication::Business::Firm" - # end - # end - # end - # - # == Type safety with <tt>ActiveRecord::AssociationTypeMismatch</tt> - # - # If you attempt to assign an object to an association that doesn't match the inferred or specified <tt>:class_name</tt>, you'll - # get an <tt>ActiveRecord::AssociationTypeMismatch</tt>. - # - # == Options - # - # All of the association macros can be specialized through options. This makes cases more complex than the simple and guessable ones - # possible. - module ClassMethods - # Specifies a one-to-many association. The following methods for retrieval and query of - # collections of associated objects will be added: - # - # [collection(force_reload = false)] - # Returns an array of all the associated objects. - # An empty array is returned if none are found. - # [collection<<(object, ...)] - # Adds one or more objects to the collection by setting their foreign keys to the collection's primary key. - # [collection.delete(object, ...)] - # Removes one or more objects from the collection by setting their foreign keys to +NULL+. - # Objects will be in addition destroyed if they're associated with <tt>:dependent => :destroy</tt>, - # and deleted if they're associated with <tt>:dependent => :delete_all</tt>. - # [collection=objects] - # Replaces the collections content by deleting and adding objects as appropriate. - # [collection_singular_ids] - # Returns an array of the associated objects' ids - # [collection_singular_ids=ids] - # Replace the collection with the objects identified by the primary keys in +ids+ - # [collection.clear] - # Removes every object from the collection. This destroys the associated objects if they - # are associated with <tt>:dependent => :destroy</tt>, deletes them directly from the - # database if <tt>:dependent => :delete_all</tt>, otherwise sets their foreign keys to +NULL+. - # [collection.empty?] - # Returns +true+ if there are no associated objects. - # [collection.size] - # Returns the number of associated objects. - # [collection.find(...)] - # Finds an associated object according to the same rules as ActiveRecord::Base.find. - # [collection.exists?(...)] - # Checks whether an associated object with the given conditions exists. - # Uses the same rules as ActiveRecord::Base.exists?. - # [collection.build(attributes = {}, ...)] - # Returns one or more new objects of the collection type that have been instantiated - # with +attributes+ and linked to this object through a foreign key, but have not yet - # been saved. <b>Note:</b> This only works if an associated object already exists, not if - # it's +nil+! - # [collection.create(attributes = {})] - # Returns a new object of the collection type that has been instantiated - # with +attributes+, linked to this object through a foreign key, and that has already - # been saved (if it passed the validation). <b>Note:</b> This only works if an associated - # object already exists, not if it's +nil+! - # - # (*Note*: +collection+ is replaced with the symbol passed as the first argument, so - # <tt>has_many :clients</tt> would add among others <tt>clients.empty?</tt>.) - # - # === Example - # - # Example: A Firm class declares <tt>has_many :clients</tt>, which will add: - # * <tt>Firm#clients</tt> (similar to <tt>Clients.find :all, :conditions => ["firm_id = ?", id]</tt>) - # * <tt>Firm#clients<<</tt> - # * <tt>Firm#clients.delete</tt> - # * <tt>Firm#clients=</tt> - # * <tt>Firm#client_ids</tt> - # * <tt>Firm#client_ids=</tt> - # * <tt>Firm#clients.clear</tt> - # * <tt>Firm#clients.empty?</tt> (similar to <tt>firm.clients.size == 0</tt>) - # * <tt>Firm#clients.size</tt> (similar to <tt>Client.count "firm_id = #{id}"</tt>) - # * <tt>Firm#clients.find</tt> (similar to <tt>Client.find(id, :conditions => "firm_id = #{id}")</tt>) - # * <tt>Firm#clients.exists?(:name => 'ACME')</tt> (similar to <tt>Client.exists?(:name => 'ACME', :firm_id => firm.id)</tt>) - # * <tt>Firm#clients.build</tt> (similar to <tt>Client.new("firm_id" => id)</tt>) - # * <tt>Firm#clients.create</tt> (similar to <tt>c = Client.new("firm_id" => id); c.save; c</tt>) - # The declaration can also include an options hash to specialize the behavior of the association. - # - # === Supported options - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_many :products</tt> will by default be linked to the Product class, but - # if the real class name is SpecialProduct, you'll have to specify it with this option. - # [:conditions] - # Specify the conditions that the associated objects must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>price > 5 AND name LIKE 'B%'</tt>. Record creations from the association are scoped if a hash - # is used. <tt>has_many :posts, :conditions => {:published => true}</tt> will create published posts with <tt>@blog.posts.create</tt> - # or <tt>@blog.posts.build</tt>. - # [:order] - # Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment, - # such as <tt>last_name, first_name DESC</tt>. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_many+ association will use "person_id" - # as the default <tt>:foreign_key</tt>. - # [:primary_key] - # Specify the method that returns the primary key used for the association. By default this is +id+. - # [:dependent] - # If set to <tt>:destroy</tt> all the associated objects are destroyed - # alongside this object by calling their +destroy+ method. If set to <tt>:delete_all</tt> all associated - # objects are deleted *without* calling their +destroy+ method. If set to <tt>:nullify</tt> all associated - # objects' foreign keys are set to +NULL+ *without* calling their +save+ callbacks. *Warning:* This option is ignored when also using - # the <tt>:through</tt> option. - # [:finder_sql] - # Specify a complete SQL statement to fetch the association. This is a good way to go for complex - # associations that depend on multiple tables. Note: When this option is used, +find_in_collection+ is _not_ added. - # [:counter_sql] - # Specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is - # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by replacing <tt>SELECT ... FROM</tt> with <tt>SELECT COUNT(*) FROM</tt>. - # [:extend] - # Specify a named module for extending the proxy. See "Association extensions". - # [:include] - # Specify second-order associations that should be eager loaded when the collection is loaded. - # [:group] - # An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause. - # [:having] - # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause. - # [:limit] - # An integer determining the limit on the number of rows that should be returned. - # [:offset] - # An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if you, for example, want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:as] - # Specifies a polymorphic interface (See <tt>belongs_to</tt>). - # [:through] - # Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt> and <tt>:foreign_key</tt> - # are ignored, as the association uses the source reflection. You can only use a <tt>:through</tt> query through a <tt>belongs_to</tt> - # <tt>has_one</tt> or <tt>has_many</tt> association on the join model. - # [:source] - # Specifies the source association name used by <tt>has_many :through</tt> queries. Only use it if the name cannot be - # inferred from the association. <tt>has_many :subscribers, :through => :subscriptions</tt> will look for either <tt>:subscribers</tt> or - # <tt>:subscriber</tt> on Subscription, unless a <tt>:source</tt> is given. - # [:source_type] - # Specifies type of the source association used by <tt>has_many :through</tt> queries where the source - # association is a polymorphic +belongs_to+. - # [:uniq] - # If true, duplicates will be omitted from the collection. Useful in conjunction with <tt>:through</tt>. - # [:readonly] - # If true, all the associated objects are readonly through the association. - # [:validate] - # If false, don't validate the associated objects when saving the parent object. true by default. - # [:autosave] - # If true, always save any loaded members and destroy members marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # has_many :comments, :order => "posted_on" - # has_many :comments, :include => :author - # has_many :people, :class_name => "Person", :conditions => "deleted = 0", :order => "name" - # has_many :tracks, :order => "position", :dependent => :destroy - # has_many :comments, :dependent => :nullify - # has_many :tags, :as => :taggable - # has_many :reports, :readonly => true - # has_many :subscribers, :through => :subscriptions, :source => :user - # has_many :subscribers, :class_name => "Person", :finder_sql => - # 'SELECT DISTINCT people.* ' + - # 'FROM people p, post_subscriptions ps ' + - # 'WHERE ps.post_id = #{id} AND ps.person_id = p.id ' + - # 'ORDER BY p.first_name' - def has_many(association_id, options = {}, &extension) - reflection = create_has_many_reflection(association_id, options, &extension) - configure_dependency_for_has_many(reflection) - add_association_callbacks(reflection.name, reflection.options) - - if options[:through] - collection_accessor_methods(reflection, HasManyThroughAssociation) - else - collection_accessor_methods(reflection, HasManyAssociation) - end - end - - # Specifies a one-to-one association with another class. This method should only be used - # if the other class contains the foreign key. If the current class contains the foreign key, - # then you should use +belongs_to+ instead. See also ActiveRecord::Associations::ClassMethods's overview - # on when to use has_one and when to use belongs_to. - # - # The following methods for retrieval and query of a single associated object will be added: - # - # [association(force_reload = false)] - # Returns the associated object. +nil+ is returned if none is found. - # [association=(associate)] - # Assigns the associate object, extracts the primary key, sets it as the foreign key, - # and saves the associate object. - # [build_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+ and linked to this object through a foreign key, but has not - # yet been saved. <b>Note:</b> This ONLY works if an association already exists. - # It will NOT work if the association is +nil+. - # [create_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+, linked to this object through a foreign key, and that - # has already been saved (if it passed the validation). - # - # (+association+ is replaced with the symbol passed as the first argument, so - # <tt>has_one :manager</tt> would add among others <tt>manager.nil?</tt>.) - # - # === Example - # - # An Account class declares <tt>has_one :beneficiary</tt>, which will add: - # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.find(:first, :conditions => "account_id = #{id}")</tt>) - # * <tt>Account#beneficiary=(beneficiary)</tt> (similar to <tt>beneficiary.account_id = account.id; beneficiary.save</tt>) - # * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new("account_id" => id)</tt>) - # * <tt>Account#create_beneficiary</tt> (similar to <tt>b = Beneficiary.new("account_id" => id); b.save; b</tt>) - # - # === Options - # - # The declaration can also include an options hash to specialize the behavior of the association. - # - # Options are: - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_one :manager</tt> will by default be linked to the Manager class, but - # if the real class name is Person, you'll have to specify it with this option. - # [:conditions] - # Specify the conditions that the associated object must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>rank = 5</tt>. Record creation from the association is scoped if a hash - # is used. <tt>has_one :account, :conditions => {:enabled => true}</tt> will create an enabled account with <tt>@company.create_account</tt> - # or <tt>@company.build_account</tt>. - # [:order] - # Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment, - # such as <tt>last_name, first_name DESC</tt>. - # [:dependent] - # If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to - # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method. If set to <tt>:nullify</tt>, the associated - # object's foreign key is set to +NULL+. Also, association is assigned. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association will use "person_id" - # as the default <tt>:foreign_key</tt>. - # [:primary_key] - # Specify the method that returns the primary key used for the association. By default this is +id+. - # [:include] - # Specify second-order associations that should be eager loaded when this object is loaded. - # [:as] - # Specifies a polymorphic interface (See <tt>belongs_to</tt>). - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example, you want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:through] - # Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt> and <tt>:foreign_key</tt> - # are ignored, as the association uses the source reflection. You can only use a <tt>:through</tt> query through a - # <tt>has_one</tt> or <tt>belongs_to</tt> association on the join model. - # [:source] - # Specifies the source association name used by <tt>has_one :through</tt> queries. Only use it if the name cannot be - # inferred from the association. <tt>has_one :favorite, :through => :favorites</tt> will look for a - # <tt>:favorite</tt> on Favorite, unless a <tt>:source</tt> is given. - # [:source_type] - # Specifies type of the source association used by <tt>has_one :through</tt> queries where the source - # association is a polymorphic +belongs_to+. - # [:readonly] - # If true, the associated object is readonly through the association. - # [:validate] - # If false, don't validate the associated object when saving the parent object. +false+ by default. - # [:autosave] - # If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # has_one :credit_card, :dependent => :destroy # destroys the associated credit card - # has_one :credit_card, :dependent => :nullify # updates the associated records foreign key value to NULL rather than destroying it - # has_one :last_comment, :class_name => "Comment", :order => "posted_on" - # has_one :project_manager, :class_name => "Person", :conditions => "role = 'project_manager'" - # has_one :attachment, :as => :attachable - # has_one :boss, :readonly => :true - # has_one :club, :through => :membership - # has_one :primary_address, :through => :addressables, :conditions => ["addressable.primary = ?", true], :source => :addressable - def has_one(association_id, options = {}) - if options[:through] - reflection = create_has_one_through_reflection(association_id, options) - association_accessor_methods(reflection, ActiveRecord::Associations::HasOneThroughAssociation) - else - reflection = create_has_one_reflection(association_id, options) - association_accessor_methods(reflection, HasOneAssociation) - association_constructor_method(:build, reflection, HasOneAssociation) - association_constructor_method(:create, reflection, HasOneAssociation) - configure_dependency_for_has_one(reflection) - end - end - - # Specifies a one-to-one association with another class. This method should only be used - # if this class contains the foreign key. If the other class contains the foreign key, - # then you should use +has_one+ instead. See also ActiveRecord::Associations::ClassMethods's overview - # on when to use +has_one+ and when to use +belongs_to+. - # - # Methods will be added for retrieval and query for a single associated object, for which - # this object holds an id: - # - # [association(force_reload = false)] - # Returns the associated object. +nil+ is returned if none is found. - # [association=(associate)] - # Assigns the associate object, extracts the primary key, and sets it as the foreign key. - # [build_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+ and linked to this object through a foreign key, but has not yet been saved. - # [create_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+, linked to this object through a foreign key, and that - # has already been saved (if it passed the validation). - # - # (+association+ is replaced with the symbol passed as the first argument, so - # <tt>belongs_to :author</tt> would add among others <tt>author.nil?</tt>.) - # - # === Example - # - # A Post class declares <tt>belongs_to :author</tt>, which will add: - # * <tt>Post#author</tt> (similar to <tt>Author.find(author_id)</tt>) - # * <tt>Post#author=(author)</tt> (similar to <tt>post.author_id = author.id</tt>) - # * <tt>Post#author?</tt> (similar to <tt>post.author == some_author</tt>) - # * <tt>Post#build_author</tt> (similar to <tt>post.author = Author.new</tt>) - # * <tt>Post#create_author</tt> (similar to <tt>post.author = Author.new; post.author.save; post.author</tt>) - # The declaration can also include an options hash to specialize the behavior of the association. - # - # === Options - # - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_one :author</tt> will by default be linked to the Author class, but - # if the real class name is Person, you'll have to specify it with this option. - # [:conditions] - # Specify the conditions that the associated object must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>authorized = 1</tt>. - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example, you want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :person</tt> association will use - # "person_id" as the default <tt>:foreign_key</tt>. Similarly, <tt>belongs_to :favorite_person, :class_name => "Person"</tt> - # will use a foreign key of "favorite_person_id". - # [:primary_key] - # Specify the method that returns the primary key of associated object used for the association. By default this is id. - # [:dependent] - # If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to - # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method. This option should not be specified when - # <tt>belongs_to</tt> is used in conjunction with a <tt>has_many</tt> relationship on another class because of the potential to leave - # orphaned records behind. - # [:counter_cache] - # Caches the number of belonging objects on the associate class through the use of +increment_counter+ - # and +decrement_counter+. The counter cache is incremented when an object of this class is created and decremented when it's - # destroyed. This requires that a column named <tt>#{table_name}_count</tt> (such as +comments_count+ for a belonging Comment class) - # is used on the associate class (such as a Post class). You can also specify a custom counter cache column by providing - # a column name instead of a +true+/+false+ value to this option (e.g., <tt>:counter_cache => :my_custom_counter</tt>.) - # Note: Specifying a counter cache will add it to that model's list of readonly attributes using +attr_readonly+. - # [:include] - # Specify second-order associations that should be eager loaded when this object is loaded. - # [:polymorphic] - # Specify this association is a polymorphic association by passing +true+. - # Note: If you've enabled the counter cache, then you may want to add the counter cache attribute - # to the +attr_readonly+ list in the associated classes (e.g. <tt>class Post; attr_readonly :comments_count; end</tt>). - # [:readonly] - # If true, the associated object is readonly through the association. - # [:validate] - # If false, don't validate the associated objects when saving the parent object. +false+ by default. - # [:autosave] - # If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default. - # [:touch] - # If true, the associated object will be touched (the updated_at/on attributes set to now) when this record is either saved or - # destroyed. If you specify a symbol, that attribute will be updated with the current time instead of the updated_at/on attribute. - # - # Option examples: - # belongs_to :firm, :foreign_key => "client_of" - # belongs_to :person, :primary_key => "name", :foreign_key => "person_name" - # belongs_to :author, :class_name => "Person", :foreign_key => "author_id" - # belongs_to :valid_coupon, :class_name => "Coupon", :foreign_key => "coupon_id", - # :conditions => 'discounts > #{payments_count}' - # belongs_to :attachable, :polymorphic => true - # belongs_to :project, :readonly => true - # belongs_to :post, :counter_cache => true - # belongs_to :company, :touch => true - # belongs_to :company, :touch => :employees_last_updated_at - def belongs_to(association_id, options = {}) - reflection = create_belongs_to_reflection(association_id, options) - - if reflection.options[:polymorphic] - association_accessor_methods(reflection, BelongsToPolymorphicAssociation) - else - association_accessor_methods(reflection, BelongsToAssociation) - association_constructor_method(:build, reflection, BelongsToAssociation) - association_constructor_method(:create, reflection, BelongsToAssociation) - end - - add_counter_cache_callbacks(reflection) if options[:counter_cache] - add_touch_callbacks(reflection, options[:touch]) if options[:touch] - - configure_dependency_for_belongs_to(reflection) - end - - # Specifies a many-to-many relationship with another class. This associates two classes via an - # intermediate join table. Unless the join table is explicitly specified as an option, it is - # guessed using the lexical order of the class names. So a join between Developer and Project - # will give the default join table name of "developers_projects" because "D" outranks "P". Note that this precedence - # is calculated using the <tt><</tt> operator for String. This means that if the strings are of different lengths, - # and the strings are equal when compared up to the shortest length, then the longer string is considered of higher - # lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers" - # to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes", - # but it in fact generates a join table name of "paper_boxes_papers". Be aware of this caveat, and use the - # custom <tt>:join_table</tt> option if you need to. - # - # The join table should not have a primary key or a model associated with it. You must manually generate the - # join table with a migration such as this: - # - # class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration - # def self.up - # create_table :developers_projects, :id => false do |t| - # t.integer :developer_id - # t.integer :project_id - # end - # end - # - # def self.down - # drop_table :developers_projects - # end - # end - # - # Deprecated: Any additional fields added to the join table will be placed as attributes when pulling records out through - # +has_and_belongs_to_many+ associations. Records returned from join tables with additional attributes will be marked as - # readonly (because we can't save changes to the additional attributes). It's strongly recommended that you upgrade any - # associations with attributes to a real join model (see introduction). - # - # Adds the following methods for retrieval and query: - # - # [collection(force_reload = false)] - # Returns an array of all the associated objects. - # An empty array is returned if none are found. - # [collection<<(object, ...)] - # Adds one or more objects to the collection by creating associations in the join table - # (<tt>collection.push</tt> and <tt>collection.concat</tt> are aliases to this method). - # [collection.delete(object, ...)] - # Removes one or more objects from the collection by removing their associations from the join table. - # This does not destroy the objects. - # [collection=objects] - # Replaces the collection's content by deleting and adding objects as appropriate. - # [collection_singular_ids] - # Returns an array of the associated objects' ids. - # [collection_singular_ids=ids] - # Replace the collection by the objects identified by the primary keys in +ids+. - # [collection.clear] - # Removes every object from the collection. This does not destroy the objects. - # [collection.empty?] - # Returns +true+ if there are no associated objects. - # [collection.size] - # Returns the number of associated objects. - # [collection.find(id)] - # Finds an associated object responding to the +id+ and that - # meets the condition that it has to be associated with this object. - # Uses the same rules as ActiveRecord::Base.find. - # [collection.exists?(...)] - # Checks whether an associated object with the given conditions exists. - # Uses the same rules as ActiveRecord::Base.exists?. - # [collection.build(attributes = {})] - # Returns a new object of the collection type that has been instantiated - # with +attributes+ and linked to this object through the join table, but has not yet been saved. - # [collection.create(attributes = {})] - # Returns a new object of the collection type that has been instantiated - # with +attributes+, linked to this object through the join table, and that has already been saved (if it passed the validation). - # - # (+collection+ is replaced with the symbol passed as the first argument, so - # <tt>has_and_belongs_to_many :categories</tt> would add among others <tt>categories.empty?</tt>.) - # - # === Example - # - # A Developer class declares <tt>has_and_belongs_to_many :projects</tt>, which will add: - # * <tt>Developer#projects</tt> - # * <tt>Developer#projects<<</tt> - # * <tt>Developer#projects.delete</tt> - # * <tt>Developer#projects=</tt> - # * <tt>Developer#project_ids</tt> - # * <tt>Developer#project_ids=</tt> - # * <tt>Developer#projects.clear</tt> - # * <tt>Developer#projects.empty?</tt> - # * <tt>Developer#projects.size</tt> - # * <tt>Developer#projects.find(id)</tt> - # * <tt>Developer#clients.exists?(...)</tt> - # * <tt>Developer#projects.build</tt> (similar to <tt>Project.new("project_id" => id)</tt>) - # * <tt>Developer#projects.create</tt> (similar to <tt>c = Project.new("project_id" => id); c.save; c</tt>) - # The declaration may include an options hash to specialize the behavior of the association. - # - # === Options - # - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_and_belongs_to_many :projects</tt> will by default be linked to the - # Project class, but if the real class name is SuperProject, you'll have to specify it with this option. - # [:join_table] - # Specify the name of the join table if the default based on lexical order isn't what you want. - # <b>WARNING:</b> If you're overwriting the table name of either class, the +table_name+ method - # MUST be declared underneath any +has_and_belongs_to_many+ declaration in order to work. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_and_belongs_to_many+ association - # to Project will use "person_id" as the default <tt>:foreign_key</tt>. - # [:association_foreign_key] - # Specify the foreign key used for the association on the receiving side of the association. - # By default this is guessed to be the name of the associated class in lower-case and "_id" suffixed. - # So if a Person class makes a +has_and_belongs_to_many+ association to Project, - # the association will use "project_id" as the default <tt>:association_foreign_key</tt>. - # [:conditions] - # Specify the conditions that the associated object must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>authorized = 1</tt>. Record creations from the association are scoped if a hash is used. - # <tt>has_many :posts, :conditions => {:published => true}</tt> will create published posts with <tt>@blog.posts.create</tt> - # or <tt>@blog.posts.build</tt>. - # [:order] - # Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment, - # such as <tt>last_name, first_name DESC</tt> - # [:uniq] - # If true, duplicate associated objects will be ignored by accessors and query methods. - # [:finder_sql] - # Overwrite the default generated SQL statement used to fetch the association with a manual statement - # [:counter_sql] - # Specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is - # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by replacing <tt>SELECT ... FROM</tt> with <tt>SELECT COUNT(*) FROM</tt>. - # [:delete_sql] - # Overwrite the default generated SQL statement used to remove links between the associated - # classes with a manual statement. - # [:insert_sql] - # Overwrite the default generated SQL statement used to add links between the associated classes - # with a manual statement. - # [:extend] - # Anonymous module for extending the proxy, see "Association extensions". - # [:include] - # Specify second-order associations that should be eager loaded when the collection is loaded. - # [:group] - # An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause. - # [:having] - # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause. - # [:limit] - # An integer determining the limit on the number of rows that should be returned. - # [:offset] - # An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example, you want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:readonly] - # If true, all the associated objects are readonly through the association. - # [:validate] - # If false, don't validate the associated objects when saving the parent object. +true+ by default. - # [:autosave] - # If true, always save any loaded members and destroy members marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # has_and_belongs_to_many :projects - # has_and_belongs_to_many :projects, :include => [ :milestones, :manager ] - # has_and_belongs_to_many :nations, :class_name => "Country" - # has_and_belongs_to_many :categories, :join_table => "prods_cats" - # has_and_belongs_to_many :categories, :readonly => true - # has_and_belongs_to_many :active_projects, :join_table => 'developers_projects', :delete_sql => - # 'DELETE FROM developers_projects WHERE active=1 AND developer_id = #{id} AND project_id = #{record.id}' - def has_and_belongs_to_many(association_id, options = {}, &extension) - reflection = create_has_and_belongs_to_many_reflection(association_id, options, &extension) - collection_accessor_methods(reflection, HasAndBelongsToManyAssociation) - - # Don't use a before_destroy callback since users' before_destroy - # callbacks will be executed after the association is wiped out. - old_method = "destroy_without_habtm_shim_for_#{reflection.name}" - class_eval <<-end_eval unless method_defined?(old_method) - alias_method :#{old_method}, :destroy_without_callbacks # alias_method :destroy_without_habtm_shim_for_posts, :destroy_without_callbacks - def destroy_without_callbacks # def destroy_without_callbacks - #{reflection.name}.clear # posts.clear - #{old_method} # destroy_without_habtm_shim_for_posts - end # end - end_eval - - add_association_callbacks(reflection.name, options) - end - - private - # Generates a join table name from two provided table names. - # The names in the join table namesme end up in lexicographic order. - # - # join_table_name("members", "clubs") # => "clubs_members" - # join_table_name("members", "special_clubs") # => "members_special_clubs" - def join_table_name(first_table_name, second_table_name) - if first_table_name < second_table_name - join_table = "#{first_table_name}_#{second_table_name}" - else - join_table = "#{second_table_name}_#{first_table_name}" - end - - table_name_prefix + join_table + table_name_suffix - end - - def association_accessor_methods(reflection, association_proxy_class) - define_method(reflection.name) do |*params| - force_reload = params.first unless params.empty? - association = association_instance_get(reflection.name) - - if association.nil? || force_reload - association = association_proxy_class.new(self, reflection) - retval = force_reload ? reflection.klass.uncached { association.reload } : association.reload - if retval.nil? and association_proxy_class == BelongsToAssociation - association_instance_set(reflection.name, nil) - return nil - end - association_instance_set(reflection.name, association) - end - - association.target.nil? ? nil : association - end - - define_method("loaded_#{reflection.name}?") do - association = association_instance_get(reflection.name) - association && association.loaded? - end - - define_method("#{reflection.name}=") do |new_value| - association = association_instance_get(reflection.name) - - if association.nil? || association.target != new_value - association = association_proxy_class.new(self, reflection) - end - - if association_proxy_class == HasOneThroughAssociation - association.create_through_record(new_value) - if new_record? - association_instance_set(reflection.name, new_value.nil? ? nil : association) - else - self.send(reflection.name, new_value) - end - else - association.replace(new_value) - association_instance_set(reflection.name, new_value.nil? ? nil : association) - end - end - - define_method("set_#{reflection.name}_target") do |target| - return if target.nil? and association_proxy_class == BelongsToAssociation - association = association_proxy_class.new(self, reflection) - association.target = target - association_instance_set(reflection.name, association) - end - end - - def collection_reader_method(reflection, association_proxy_class) - define_method(reflection.name) do |*params| - force_reload = params.first unless params.empty? - association = association_instance_get(reflection.name) - - unless association - association = association_proxy_class.new(self, reflection) - association_instance_set(reflection.name, association) - end - - reflection.klass.uncached { association.reload } if force_reload - - association - end - - define_method("#{reflection.name.to_s.singularize}_ids") do - if send(reflection.name).loaded? || reflection.options[:finder_sql] - send(reflection.name).map(&:id) - else - send(reflection.name).all(:select => "#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").map(&:id) - end - end - end - - def collection_accessor_methods(reflection, association_proxy_class, writer = true) - collection_reader_method(reflection, association_proxy_class) - - if writer - define_method("#{reflection.name}=") do |new_value| - # Loads proxy class instance (defined in collection_reader_method) if not already loaded - association = send(reflection.name) - association.replace(new_value) - association - end - - define_method("#{reflection.name.to_s.singularize}_ids=") do |new_value| - ids = (new_value || []).reject { |nid| nid.blank? }.map(&:to_i) - send("#{reflection.name}=", reflection.klass.find(ids).index_by(&:id).values_at(*ids)) - end - end - end - - def association_constructor_method(constructor, reflection, association_proxy_class) - define_method("#{constructor}_#{reflection.name}") do |*params| - attributees = params.first unless params.empty? - replace_existing = params[1].nil? ? true : params[1] - association = association_instance_get(reflection.name) - - unless association - association = association_proxy_class.new(self, reflection) - association_instance_set(reflection.name, association) - end - - if association_proxy_class == HasOneAssociation - association.send(constructor, attributees, replace_existing) - else - association.send(constructor, attributees) - end - end - end - - def add_counter_cache_callbacks(reflection) - cache_column = reflection.counter_cache_column - - method_name = "belongs_to_counter_cache_after_create_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.class.increment_counter(cache_column, association.id) unless association.nil? - end - after_create(method_name) - - method_name = "belongs_to_counter_cache_before_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.class.decrement_counter(cache_column, association.id) unless association.nil? - end - before_destroy(method_name) - - module_eval( - "#{reflection.class_name}.send(:attr_readonly,\"#{cache_column}\".intern) if defined?(#{reflection.class_name}) && #{reflection.class_name}.respond_to?(:attr_readonly)" - ) - end - - def add_touch_callbacks(reflection, touch_attribute) - method_name = "belongs_to_touch_after_save_or_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - - if touch_attribute == true - association.touch unless association.nil? - else - association.touch(touch_attribute) unless association.nil? - end - end - after_save(method_name) - after_destroy(method_name) - end - - def find_with_associations(options = {}) - catch :invalid_query do - join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins]) - rows = select_all_rows(options, join_dependency) - return join_dependency.instantiate(rows) - end - [] - end - - # Creates before_destroy callback methods that nullify, delete or destroy - # has_many associated objects, according to the defined :dependent rule. - # - # See HasManyAssociation#delete_records. Dependent associations - # delete children, otherwise foreign key is set to NULL. - # - # The +extra_conditions+ parameter, which is not used within the main - # Active Record codebase, is meant to allow plugins to define extra - # finder conditions. - def configure_dependency_for_has_many(reflection, extra_conditions = nil) - if reflection.options.include?(:dependent) - case reflection.options[:dependent] - when :destroy - method_name = "has_many_dependent_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - send(reflection.name).each do |o| - # No point in executing the counter update since we're going to destroy the parent anyway - counter_method = ('belongs_to_counter_cache_before_destroy_for_' + self.class.name.downcase).to_sym - if(o.respond_to? counter_method) then - class << o - self - end.send(:define_method, counter_method, Proc.new {}) - end - o.destroy - end - end - before_destroy method_name - when :delete_all - before_destroy do |record| - record.class.send(:delete_all_has_many_dependencies, - record, - reflection.name, - reflection.klass, - reflection.dependent_conditions(record, record.class, extra_conditions)) - end - when :nullify - before_destroy do |record| - record.class.send(:nullify_has_many_dependencies, - record, - reflection.name, - reflection.klass, - reflection.primary_key_name, - reflection.dependent_conditions(record, record.class, extra_conditions)) - end - else - raise ArgumentError, "The :dependent option expects either :destroy, :delete_all, or :nullify (#{reflection.options[:dependent].inspect})" - end - end - end - - # Creates before_destroy callback methods that nullify, delete or destroy - # has_one associated objects, according to the defined :dependent rule. - def configure_dependency_for_has_one(reflection) - if reflection.options.include?(:dependent) - case reflection.options[:dependent] - when :destroy - method_name = "has_one_dependent_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.destroy unless association.nil? - end - before_destroy method_name - when :delete - method_name = "has_one_dependent_delete_for_#{reflection.name}".to_sym - define_method(method_name) do - # Retrieve the associated object and delete it. The retrieval - # is necessary because there may be multiple associated objects - # with foreign keys pointing to this object, and we only want - # to delete the correct one, not all of them. - association = send(reflection.name) - association.delete unless association.nil? - end - before_destroy method_name - when :nullify - method_name = "has_one_dependent_nullify_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.update_attribute(reflection.primary_key_name, nil) unless association.nil? - end - before_destroy method_name - else - raise ArgumentError, "The :dependent option expects either :destroy, :delete or :nullify (#{reflection.options[:dependent].inspect})" - end - end - end - - def configure_dependency_for_belongs_to(reflection) - if reflection.options.include?(:dependent) - case reflection.options[:dependent] - when :destroy - method_name = "belongs_to_dependent_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.destroy unless association.nil? - end - after_destroy method_name - when :delete - method_name = "belongs_to_dependent_delete_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.delete unless association.nil? - end - after_destroy method_name - else - raise ArgumentError, "The :dependent option expects either :destroy or :delete (#{reflection.options[:dependent].inspect})" - end - end - end - - def delete_all_has_many_dependencies(record, reflection_name, association_class, dependent_conditions) - association_class.delete_all(dependent_conditions) - end - - def nullify_has_many_dependencies(record, reflection_name, association_class, primary_key_name, dependent_conditions) - association_class.update_all("#{primary_key_name} = NULL", dependent_conditions) - end - - mattr_accessor :valid_keys_for_has_many_association - @@valid_keys_for_has_many_association = [ - :class_name, :table_name, :foreign_key, :primary_key, - :dependent, - :select, :conditions, :include, :order, :group, :having, :limit, :offset, - :as, :through, :source, :source_type, - :uniq, - :finder_sql, :counter_sql, - :before_add, :after_add, :before_remove, :after_remove, - :extend, :readonly, - :validate, :inverse_of - ] - - def create_has_many_reflection(association_id, options, &extension) - options.assert_valid_keys(valid_keys_for_has_many_association) - options[:extend] = create_extension_modules(association_id, extension, options[:extend]) - - create_reflection(:has_many, association_id, options, self) - end - - mattr_accessor :valid_keys_for_has_one_association - @@valid_keys_for_has_one_association = [ - :class_name, :foreign_key, :remote, :select, :conditions, :order, - :include, :dependent, :counter_cache, :extend, :as, :readonly, - :validate, :primary_key, :inverse_of - ] - - def create_has_one_reflection(association_id, options) - options.assert_valid_keys(valid_keys_for_has_one_association) - create_reflection(:has_one, association_id, options, self) - end - - def create_has_one_through_reflection(association_id, options) - options.assert_valid_keys( - :class_name, :foreign_key, :remote, :select, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :through, :source, :source_type, :validate - ) - create_reflection(:has_one, association_id, options, self) - end - - mattr_accessor :valid_keys_for_belongs_to_association - @@valid_keys_for_belongs_to_association = [ - :class_name, :primary_key, :foreign_key, :foreign_type, :remote, :select, :conditions, - :include, :dependent, :counter_cache, :extend, :polymorphic, :readonly, - :validate, :touch, :inverse_of - ] - - def create_belongs_to_reflection(association_id, options) - options.assert_valid_keys(valid_keys_for_belongs_to_association) - reflection = create_reflection(:belongs_to, association_id, options, self) - - if options[:polymorphic] - reflection.options[:foreign_type] ||= reflection.class_name.underscore + "_type" - end - - reflection - end - - mattr_accessor :valid_keys_for_has_and_belongs_to_many_association - @@valid_keys_for_has_and_belongs_to_many_association = [ - :class_name, :table_name, :join_table, :foreign_key, :association_foreign_key, - :select, :conditions, :include, :order, :group, :having, :limit, :offset, - :uniq, - :finder_sql, :counter_sql, :delete_sql, :insert_sql, - :before_add, :after_add, :before_remove, :after_remove, - :extend, :readonly, - :validate - ] - - def create_has_and_belongs_to_many_reflection(association_id, options, &extension) - options.assert_valid_keys(valid_keys_for_has_and_belongs_to_many_association) - - options[:extend] = create_extension_modules(association_id, extension, options[:extend]) - - reflection = create_reflection(:has_and_belongs_to_many, association_id, options, self) - - if reflection.association_foreign_key == reflection.primary_key_name - raise HasAndBelongsToManyAssociationForeignKeyNeeded.new(reflection) - end - - reflection.options[:join_table] ||= join_table_name(undecorated_table_name(self.to_s), undecorated_table_name(reflection.class_name)) - - reflection - end - - def reflect_on_included_associations(associations) - [ associations ].flatten.collect { |association| reflect_on_association(association.to_s.intern) } - end - - def guard_against_unlimitable_reflections(reflections, options) - if (options[:offset] || options[:limit]) && !using_limitable_reflections?(reflections) - raise( - ConfigurationError, - "You can not use offset and limit together with has_many or has_and_belongs_to_many associations" - ) - end - end - - def select_all_rows(options, join_dependency) - connection.select_all( - construct_finder_sql_with_included_associations(options, join_dependency), - "#{name} Load Including Associations" - ) - end - - def construct_finder_sql_with_included_associations(options, join_dependency) - scope = scope(:find) - sql = "SELECT #{column_aliases(join_dependency)} FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} " - sql << join_dependency.join_associations.collect{|join| join.association_join }.join - - add_joins!(sql, options[:joins], scope) - add_conditions!(sql, options[:conditions], scope) - add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - - add_group!(sql, options[:group], options[:having], scope) - add_order!(sql, options[:order], scope) - add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections) - add_lock!(sql, options, scope) - - return sanitize_sql(sql) - end - - def add_limited_ids_condition!(sql, options, join_dependency) - unless (id_list = select_limited_ids_list(options, join_dependency)).empty? - sql << "#{condition_word(sql)} #{connection.quote_table_name table_name}.#{primary_key} IN (#{id_list}) " - else - throw :invalid_query - end - end - - def select_limited_ids_list(options, join_dependency) - pk = columns_hash[primary_key] - - connection.select_all( - construct_finder_sql_for_association_limiting(options, join_dependency), - "#{name} Load IDs For Limited Eager Loading" - ).collect { |row| connection.quote(row[primary_key], pk) }.join(", ") - end - - def construct_finder_sql_for_association_limiting(options, join_dependency) - scope = scope(:find) - - # Only join tables referenced in order or conditions since this is particularly slow on the pre-query. - tables_from_conditions = conditions_tables(options) - tables_from_order = order_tables(options) - all_tables = tables_from_conditions + tables_from_order - distinct_join_associations = all_tables.uniq.map{|table| - join_dependency.joins_for_table_name(table) - }.flatten.compact.uniq - - order = options[:order] - if scoped_order = (scope && scope[:order]) - order = order ? "#{order}, #{scoped_order}" : scoped_order - end - - is_distinct = !options[:joins].blank? || include_eager_conditions?(options, tables_from_conditions) || include_eager_order?(options, tables_from_order) - sql = "SELECT " - if is_distinct - sql << connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", order) - else - sql << primary_key - end - sql << " FROM #{connection.quote_table_name table_name} " - - if is_distinct - sql << distinct_join_associations.collect { |assoc| assoc.association_join }.join - add_joins!(sql, options[:joins], scope) - end - - add_conditions!(sql, options[:conditions], scope) - add_group!(sql, options[:group], options[:having], scope) - - if order && is_distinct - connection.add_order_by_for_association_limiting!(sql, :order => order) - else - add_order!(sql, options[:order], scope) - end - - add_limit!(sql, options, scope) - - return sanitize_sql(sql) - end - - def tables_in_string(string) - return [] if string.blank? - string.scan(/([\.a-zA-Z_]+).?\./).flatten - end - - def tables_in_hash(hash) - return [] if hash.blank? - tables = hash.map do |key, value| - if value.is_a?(Hash) - key.to_s - else - tables_in_string(key) if key.is_a?(String) - end - end - tables.flatten.compact - end - - def conditions_tables(options) - # look in both sets of conditions - conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond| - case cond - when nil then all - when Array then all << tables_in_string(cond.first) - when Hash then all << tables_in_hash(cond) - else all << tables_in_string(cond) - end - end - conditions.flatten - end - - def order_tables(options) - order = [options[:order], scope(:find, :order) ].join(", ") - return [] unless order && order.is_a?(String) - tables_in_string(order) - end - - def selects_tables(options) - select = options[:select] - return [] unless select && select.is_a?(String) - tables_in_string(select) - end - - def joined_tables(options) - scope = scope(:find) - joins = options[:joins] - merged_joins = scope && scope[:joins] && joins ? merge_joins(scope[:joins], joins) : (joins || scope && scope[:joins]) - [table_name] + case merged_joins - when Symbol, Hash, Array - if array_of_strings?(merged_joins) - tables_in_string(merged_joins.join(' ')) - else - join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, merged_joins, nil) - join_dependency.join_associations.collect {|join_association| [join_association.aliased_join_table_name, join_association.aliased_table_name]}.flatten.compact - end - else - tables_in_string(merged_joins) - end - end - - # Checks if the conditions reference a table other than the current model table - def include_eager_conditions?(options, tables = nil, joined_tables = nil) - ((tables || conditions_tables(options)) - (joined_tables || joined_tables(options))).any? - end - - # Checks if the query order references a table other than the current model's table. - def include_eager_order?(options, tables = nil, joined_tables = nil) - ((tables || order_tables(options)) - (joined_tables || joined_tables(options))).any? - end - - def include_eager_select?(options, joined_tables = nil) - (selects_tables(options) - (joined_tables || joined_tables(options))).any? - end - - def references_eager_loaded_tables?(options) - joined_tables = joined_tables(options) - include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables) || include_eager_select?(options, joined_tables) - end - - def using_limitable_reflections?(reflections) - reflections.none?(&:collection?) - end - - def column_aliases(join_dependency) - join_dependency.joins.collect{|join| join.column_names_with_alias.collect{|column_name, aliased_name| - "#{connection.quote_table_name join.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}"}}.flatten.join(", ") - end - - def add_association_callbacks(association_name, options) - callbacks = %w(before_add after_add before_remove after_remove) - callbacks.each do |callback_name| - full_callback_name = "#{callback_name}_for_#{association_name}" - defined_callbacks = options[callback_name.to_sym] - if options.has_key?(callback_name.to_sym) - class_inheritable_reader full_callback_name.to_sym - write_inheritable_attribute(full_callback_name.to_sym, [defined_callbacks].flatten) - else - write_inheritable_attribute(full_callback_name.to_sym, []) - end - end - end - - def condition_word(sql) - sql =~ /where/i ? " AND " : "WHERE " - end - - def create_extension_modules(association_id, block_extension, extensions) - if block_extension - extension_module_name = "#{self.to_s.demodulize}#{association_id.to_s.camelize}AssociationExtension" - - silence_warnings do - self.parent.const_set(extension_module_name, Module.new(&block_extension)) - end - Array(extensions).push("#{self.parent}::#{extension_module_name}".constantize) - else - Array(extensions) - end - end - - class JoinDependency # :nodoc: - attr_reader :joins, :reflections, :table_aliases - - def initialize(base, associations, joins) - @joins = [JoinBase.new(base, joins)] - @associations = associations - @reflections = [] - @base_records_hash = {} - @base_records_in_order = [] - @table_aliases = Hash.new { |aliases, table| aliases[table] = 0 } - @table_aliases[base.table_name] = 1 - build(associations) - end - - def join_associations - @joins[1..-1].to_a - end - - def join_base - @joins[0] - end - - def instantiate(rows) - rows.each_with_index do |row, i| - primary_id = join_base.record_id(row) - unless @base_records_hash[primary_id] - @base_records_in_order << (@base_records_hash[primary_id] = join_base.instantiate(row)) - end - construct(@base_records_hash[primary_id], @associations, join_associations.dup, row) - end - remove_duplicate_results!(join_base.active_record, @base_records_in_order, @associations) - return @base_records_in_order - end - - def remove_duplicate_results!(base, records, associations) - case associations - when Symbol, String - reflection = base.reflections[associations] - if reflection && reflection.collection? - records.each { |record| record.send(reflection.name).target.uniq! } - end - when Array - associations.each do |association| - remove_duplicate_results!(base, records, association) - end - when Hash - associations.keys.each do |name| - reflection = base.reflections[name] - - parent_records = records.map do |record| - descendant = record.send(reflection.name) - next unless descendant - descendant.target.uniq! if reflection.collection? - descendant - end.flatten.compact - - remove_duplicate_results!(reflection.klass, parent_records, associations[name]) unless parent_records.empty? - end - end - end - - def join_for_table_name(table_name) - join = (@joins.select{|j|j.aliased_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first) rescue nil - return join unless join.nil? - @joins.select{|j|j.is_a?(JoinAssociation) && j.aliased_join_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first rescue nil - end - - def joins_for_table_name(table_name) - join = join_for_table_name(table_name) - result = nil - if join && join.is_a?(JoinAssociation) - result = [join] - if join.parent && join.parent.is_a?(JoinAssociation) - result = joins_for_table_name(join.parent.aliased_table_name) + - result - end - end - result - end - - protected - def build(associations, parent = nil) - parent ||= @joins.last - case associations - when Symbol, String - reflection = parent.reflections[associations.to_s.intern] or - raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?" - @reflections << reflection - @joins << build_join_association(reflection, parent) - when Array - associations.each do |association| - build(association, parent) - end - when Hash - associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| - build(name, parent) - build(associations[name]) - end - else - raise ConfigurationError, associations.inspect - end - end - - # overridden in InnerJoinDependency subclass - def build_join_association(reflection, parent) - JoinAssociation.new(reflection, self, parent) - end - - def construct(parent, associations, joins, row) - case associations - when Symbol, String - join = joins.detect{|j| j.reflection.name.to_s == associations.to_s && j.parent_table_name == parent.class.table_name } - raise(ConfigurationError, "No such association") if join.nil? - - joins.delete(join) - construct_association(parent, join, row) - when Array - associations.each do |association| - construct(parent, association, joins, row) - end - when Hash - associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| - join = joins.detect{|j| j.reflection.name.to_s == name.to_s && j.parent_table_name == parent.class.table_name } - raise(ConfigurationError, "No such association") if join.nil? - - association = construct_association(parent, join, row) - joins.delete(join) - construct(association, associations[name], joins, row) if association - end - else - raise ConfigurationError, associations.inspect - end - end - - def construct_association(record, join, row) - case join.reflection.macro - when :has_many, :has_and_belongs_to_many - collection = record.send(join.reflection.name) - collection.loaded - - return nil if record.id.to_s != join.parent.record_id(row).to_s or row[join.aliased_primary_key].nil? - association = join.instantiate(row) - collection.target.push(association) - collection.__send__(:set_inverse_instance, association, record) - when :has_one - return if record.id.to_s != join.parent.record_id(row).to_s - return if record.instance_variable_defined?("@#{join.reflection.name}") - association = join.instantiate(row) unless row[join.aliased_primary_key].nil? - set_target_and_inverse(join, association, record) - when :belongs_to - return if record.id.to_s != join.parent.record_id(row).to_s or row[join.aliased_primary_key].nil? - association = join.instantiate(row) - set_target_and_inverse(join, association, record) - else - raise ConfigurationError, "unknown macro: #{join.reflection.macro}" - end - return association - end - - def set_target_and_inverse(join, association, record) - association_proxy = record.send("set_#{join.reflection.name}_target", association) - association_proxy.__send__(:set_inverse_instance, association, record) - end - - class JoinBase # :nodoc: - attr_reader :active_record, :table_joins - delegate :table_name, :column_names, :primary_key, :reflections, :sanitize_sql, :to => :active_record - - def initialize(active_record, joins = nil) - @active_record = active_record - @cached_record = {} - @table_joins = joins - end - - def aliased_prefix - "t0" - end - - def aliased_primary_key - "#{aliased_prefix}_r0" - end - - def aliased_table_name - active_record.table_name - end - - def column_names_with_alias - unless defined?(@column_names_with_alias) - @column_names_with_alias = [] - - ([primary_key] + (column_names - [primary_key])).each_with_index do |column_name, i| - @column_names_with_alias << [column_name, "#{aliased_prefix}_r#{i}"] - end - end - - @column_names_with_alias - end - - def extract_record(row) - column_names_with_alias.inject({}){|record, (cn, an)| record[cn] = row[an]; record} - end - - def record_id(row) - row[aliased_primary_key] - end - - def instantiate(row) - @cached_record[record_id(row)] ||= active_record.send(:instantiate, extract_record(row)) - end - end - - class JoinAssociation < JoinBase # :nodoc: - attr_reader :reflection, :parent, :aliased_table_name, :aliased_prefix, :aliased_join_table_name, :parent_table_name - delegate :options, :klass, :through_reflection, :source_reflection, :to => :reflection - - def initialize(reflection, join_dependency, parent = nil) - reflection.check_validity! - if reflection.options[:polymorphic] - raise EagerLoadPolymorphicError.new(reflection) - end - - super(reflection.klass) - @join_dependency = join_dependency - @parent = parent - @reflection = reflection - @aliased_prefix = "t#{ join_dependency.joins.size }" - @parent_table_name = parent.active_record.table_name - @aliased_table_name = aliased_table_name_for(table_name) - - if reflection.macro == :has_and_belongs_to_many - @aliased_join_table_name = aliased_table_name_for(reflection.options[:join_table], "_join") - end - - if [:has_many, :has_one].include?(reflection.macro) && reflection.options[:through] - @aliased_join_table_name = aliased_table_name_for(reflection.through_reflection.klass.table_name, "_join") - end - end - - def association_join - connection = reflection.active_record.connection - join = case reflection.macro - when :has_and_belongs_to_many - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_alias_for(options[:join_table], aliased_join_table_name), - connection.quote_table_name(aliased_join_table_name), - options[:foreign_key] || reflection.active_record.to_s.foreign_key, - connection.quote_table_name(parent.aliased_table_name), - reflection.active_record.primary_key] + - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - klass.primary_key, - connection.quote_table_name(aliased_join_table_name), - options[:association_foreign_key] || klass.to_s.foreign_key - ] - when :has_many, :has_one - case - when reflection.options[:through] - through_conditions = through_reflection.options[:conditions] ? "AND #{interpolate_sql(sanitize_sql(through_reflection.options[:conditions]))}" : '' - - jt_foreign_key = jt_as_extra = jt_source_extra = jt_sti_extra = nil - first_key = second_key = as_extra = nil - - if through_reflection.options[:as] # has_many :through against a polymorphic join - jt_foreign_key = through_reflection.options[:as].to_s + '_id' - jt_as_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(through_reflection.options[:as].to_s + '_type'), - klass.quote_value(parent.active_record.base_class.name) - ] - else - jt_foreign_key = through_reflection.primary_key_name - end - - case source_reflection.macro - when :has_many - if source_reflection.options[:as] - first_key = "#{source_reflection.options[:as]}_id" - second_key = options[:foreign_key] || primary_key - as_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_table_name), - connection.quote_column_name("#{source_reflection.options[:as]}_type"), - klass.quote_value(source_reflection.active_record.base_class.name) - ] - else - first_key = through_reflection.klass.base_class.to_s.foreign_key - second_key = options[:foreign_key] || primary_key - end - - unless through_reflection.klass.descends_from_active_record? - jt_sti_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(through_reflection.active_record.inheritance_column), - through_reflection.klass.quote_value(through_reflection.klass.sti_name)] - end - when :belongs_to - first_key = primary_key - if reflection.options[:source_type] - second_key = source_reflection.association_foreign_key - jt_source_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(reflection.source_reflection.options[:foreign_type]), - klass.quote_value(reflection.options[:source_type]) - ] - else - second_key = source_reflection.primary_key_name - end - end - - " #{join_type} %s ON (%s.%s = %s.%s%s%s%s) " % [ - table_alias_for(through_reflection.klass.table_name, aliased_join_table_name), - connection.quote_table_name(parent.aliased_table_name), - connection.quote_column_name(parent.primary_key), - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(jt_foreign_key), - jt_as_extra, jt_source_extra, jt_sti_extra - ] + - " #{join_type} %s ON (%s.%s = %s.%s%s) " % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - connection.quote_column_name(first_key), - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(second_key), - as_extra - ] - - when reflection.options[:as] && [:has_many, :has_one].include?(reflection.macro) - " #{join_type} %s ON %s.%s = %s.%s AND %s.%s = %s" % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - "#{reflection.options[:as]}_id", - connection.quote_table_name(parent.aliased_table_name), - parent.primary_key, - connection.quote_table_name(aliased_table_name), - "#{reflection.options[:as]}_type", - klass.quote_value(parent.active_record.base_class.name) - ] - else - foreign_key = options[:foreign_key] || reflection.active_record.name.foreign_key - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_name_and_alias, - aliased_table_name, - foreign_key, - parent.aliased_table_name, - reflection.options[:primary_key] || parent.primary_key - ] - end - when :belongs_to - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - reflection.options[:primary_key] || reflection.klass.primary_key, - connection.quote_table_name(parent.aliased_table_name), - options[:foreign_key] || reflection.primary_key_name - ] - else - "" - end || '' - join << %(AND %s) % [ - klass.send(:type_condition, aliased_table_name)] unless klass.descends_from_active_record? - - [through_reflection, reflection].each do |ref| - join << "AND #{interpolate_sql(sanitize_sql(ref.options[:conditions], aliased_table_name))} " if ref && ref.options[:conditions] - end - - join - end - - protected - - def aliased_table_name_for(name, suffix = nil) - if !parent.table_joins.blank? && parent.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{active_record.connection.quote_table_name name.downcase}\son} - @join_dependency.table_aliases[name] += 1 - end - - unless @join_dependency.table_aliases[name].zero? - # if the table name has been used, then use an alias - name = active_record.connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}" - table_index = @join_dependency.table_aliases[name] - @join_dependency.table_aliases[name] += 1 - name = name[0..active_record.connection.table_alias_length-3] + "_#{table_index+1}" if table_index > 0 - else - @join_dependency.table_aliases[name] += 1 - end - - name - end - - def pluralize(table_name) - ActiveRecord::Base.pluralize_table_names ? table_name.to_s.pluralize : table_name - end - - def table_alias_for(table_name, table_alias) - "#{reflection.active_record.connection.quote_table_name(table_name)} #{table_alias if table_name != table_alias}".strip - end - - def table_name_and_alias - table_alias_for table_name, @aliased_table_name - end - - def interpolate_sql(sql) - instance_eval("%@#{sql.gsub('@', '\@')}@") - end - - private - def join_type - "LEFT OUTER JOIN" - end - end - end - - class InnerJoinDependency < JoinDependency # :nodoc: - protected - def build_join_association(reflection, parent) - InnerJoinAssociation.new(reflection, self, parent) - end - - class InnerJoinAssociation < JoinAssociation - private - def join_type - "INNER JOIN" - end - end - end - - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb b/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb deleted file mode 100644 index c04110a9..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +++ /dev/null @@ -1,533 +0,0 @@ -require 'set' - -module ActiveRecord - module Associations - # AssociationCollection is an abstract class that provides common stuff to - # ease the implementation of association proxies that represent - # collections. See the class hierarchy in AssociationProxy. - # - # You need to be careful with assumptions regarding the target: The proxy - # does not fetch records from the database until it needs them, but new - # ones created with +build+ are added to the target. So, the target may be - # non-empty and still lack children waiting to be read from the database. - # If you look directly to the database you cannot assume that's the entire - # collection because new records may have beed added to the target, etc. - # - # If you need to work on all current children, new and existing records, - # +load_target+ and the +loaded+ flag are your friends. - class AssociationCollection < AssociationProxy #:nodoc: - def initialize(owner, reflection) - super - construct_sql - end - - def find(*args) - options = args.extract_options! - - # If using a custom finder_sql, scan the entire collection. - if @reflection.options[:finder_sql] - expects_array = args.first.kind_of?(Array) - ids = args.flatten.compact.uniq.map { |arg| arg.to_i } - - if ids.size == 1 - id = ids.first - record = load_target.detect { |r| id == r.id } - expects_array ? [ record ] : record - else - load_target.select { |r| ids.include?(r.id) } - end - else - conditions = "#{@finder_sql}" - if sanitized_conditions = sanitize_sql(options[:conditions]) - conditions << " AND (#{sanitized_conditions})" - end - - options[:conditions] = conditions - - if options[:order] && @reflection.options[:order] - options[:order] = "#{options[:order]}, #{@reflection.options[:order]}" - elsif @reflection.options[:order] - options[:order] = @reflection.options[:order] - end - - # Build options specific to association - construct_find_options!(options) - - merge_options_from_reflection!(options) - - # Pass through args exactly as we received them. - args << options - @reflection.klass.find(*args) - end - end - - # Fetches the first one using SQL if possible. - def first(*args) - if fetch_first_or_last_using_find?(args) - find(:first, *args) - else - load_target unless loaded? - @target.first(*args) - end - end - - # Fetches the last one using SQL if possible. - def last(*args) - if fetch_first_or_last_using_find?(args) - find(:last, *args) - else - load_target unless loaded? - @target.last(*args) - end - end - - def to_ary - load_target - if @target.is_a?(Array) - @target.to_ary - else - Array(@target) - end - end - - def reset - reset_target! - @loaded = false - end - - def build(attributes = {}, &block) - if attributes.is_a?(Array) - attributes.collect { |attr| build(attr, &block) } - else - build_record(attributes) do |record| - block.call(record) if block_given? - set_belongs_to_association_for(record) - end - end - end - - # Add +records+ to this association. Returns +self+ so method calls may be chained. - # Since << flattens its argument list and inserts each record, +push+ and +concat+ behave identically. - def <<(*records) - result = true - load_target if @owner.new_record? - - transaction do - flatten_deeper(records).each do |record| - raise_on_type_mismatch(record) - add_record_to_target_with_callbacks(record) do |r| - result &&= insert_record(record) unless @owner.new_record? - end - end - end - - result && self - end - - alias_method :push, :<< - alias_method :concat, :<< - - # Starts a transaction in the association class's database connection. - # - # class Author < ActiveRecord::Base - # has_many :books - # end - # - # Author.find(:first).books.transaction do - # # same effect as calling Book.transaction - # end - def transaction(*args) - @reflection.klass.transaction(*args) do - yield - end - end - - # Remove all records from this association - # - # See delete for more info. - def delete_all - load_target - delete(@target) - reset_target! - end - - # Calculate sum using SQL, not Enumerable - def sum(*args) - if block_given? - calculate(:sum, *args) { |*block_args| yield(*block_args) } - else - calculate(:sum, *args) - end - end - - # Count all records using SQL. If the +:counter_sql+ option is set for the association, it will - # be used for the query. If no +:counter_sql+ was supplied, but +:finder_sql+ was set, the - # descendant's +construct_sql+ method will have set :counter_sql automatically. - # Otherwise, construct options and pass them with scope to the target class's +count+. - def count(*args) - if @reflection.options[:counter_sql] - @reflection.klass.count_by_sql(@counter_sql) - else - column_name, options = @reflection.klass.send(:construct_count_options_from_args, *args) - if @reflection.options[:uniq] - # This is needed because 'SELECT count(DISTINCT *)..' is not valid SQL. - column_name = "#{@reflection.quoted_table_name}.#{@reflection.klass.primary_key}" if column_name == :all - options.merge!(:distinct => true) - end - - value = @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.count(column_name, options) } - - limit = @reflection.options[:limit] - offset = @reflection.options[:offset] - - if limit || offset - [ [value - offset.to_i, 0].max, limit.to_i ].min - else - value - end - end - end - - # Removes +records+ from this association calling +before_remove+ and - # +after_remove+ callbacks. - # - # This method is abstract in the sense that +delete_records+ has to be - # provided by descendants. Note this method does not imply the records - # are actually removed from the database, that depends precisely on - # +delete_records+. They are in any case removed from the collection. - def delete(*records) - remove_records(records) do |records, old_records| - delete_records(old_records) if old_records.any? - records.each { |record| @target.delete(record) } - end - end - - # Destroy +records+ and remove them from this association calling - # +before_remove+ and +after_remove+ callbacks. - # - # Note that this method will _always_ remove records from the database - # ignoring the +:dependent+ option. - def destroy(*records) - records = find(records) if records.any? {|record| record.kind_of?(Fixnum) || record.kind_of?(String)} - remove_records(records) do |records, old_records| - old_records.each { |record| record.destroy } - end - - load_target - end - - # Removes all records from this association. Returns +self+ so method calls may be chained. - def clear - return self if length.zero? # forces load_target if it hasn't happened already - - if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy - destroy_all - else - delete_all - end - - self - end - - # Destory all the records from this association. - # - # See destroy for more info. - def destroy_all - load_target - destroy(@target).tap do - reset_target! - end - end - - def create(attrs = {}) - if attrs.is_a?(Array) - attrs.collect { |attr| create(attr) } - else - create_record(attrs) do |record| - yield(record) if block_given? - record.save - end - end - end - - def create!(attrs = {}) - create_record(attrs) do |record| - yield(record) if block_given? - record.save! - end - end - - # Returns the size of the collection by executing a SELECT COUNT(*) - # query if the collection hasn't been loaded, and calling - # <tt>collection.size</tt> if it has. - # - # If the collection has been already loaded +size+ and +length+ are - # equivalent. If not and you are going to need the records anyway - # +length+ will take one less query. Otherwise +size+ is more efficient. - # - # This method is abstract in the sense that it relies on - # +count_records+, which is a method descendants have to provide. - def size - if @owner.new_record? || (loaded? && !@reflection.options[:uniq]) - @target.size - elsif !loaded? && @reflection.options[:group] - load_target.size - elsif !loaded? && !@reflection.options[:uniq] && @target.is_a?(Array) - unsaved_records = @target.select { |r| r.new_record? } - unsaved_records.size + count_records - else - count_records - end - end - - # Returns the size of the collection calling +size+ on the target. - # - # If the collection has been already loaded +length+ and +size+ are - # equivalent. If not and you are going to need the records anyway this - # method will take one less query. Otherwise +size+ is more efficient. - def length - load_target.size - end - - # Equivalent to <tt>collection.size.zero?</tt>. If the collection has - # not been already loaded and you are going to fetch the records anyway - # it is better to check <tt>collection.length.zero?</tt>. - def empty? - size.zero? - end - - def any? - if block_given? - method_missing(:any?) { |*block_args| yield(*block_args) } - else - !empty? - end - end - - def uniq(collection = self) - seen = Set.new - collection.inject([]) do |kept, record| - unless seen.include?(record.id) - kept << record - seen << record.id - end - kept - end - end - - # Replace this collection with +other_array+ - # This will perform a diff and delete/add only records that have changed. - def replace(other_array) - other_array.each { |val| raise_on_type_mismatch(val) } - - load_target - other = other_array.size < 100 ? other_array : other_array.to_set - current = @target.size < 100 ? @target : @target.to_set - - transaction do - delete(@target.select { |v| !other.include?(v) }) - concat(other_array.select { |v| !current.include?(v) }) - end - end - - def include?(record) - return false unless record.is_a?(@reflection.klass) - return include_in_memory?(record) if record.new_record? - load_target if @reflection.options[:finder_sql] && !loaded? - return @target.include?(record) if loaded? - exists?(record) - end - - def proxy_respond_to?(method, include_private = false) - super || @reflection.klass.respond_to?(method, include_private) - end - - protected - def construct_find_options!(options) - end - - def load_target - if !@owner.new_record? || foreign_key_present - begin - if !loaded? - if @target.is_a?(Array) && @target.any? - @target = find_target.map do |f| - i = @target.index(f) - t = @target.delete_at(i) if i - if t && t.changed? - t - else - f.mark_for_destruction if t && t.marked_for_destruction? - f - end - end + @target.find_all {|t| t.new_record?} - else - @target = find_target - end - end - rescue ActiveRecord::RecordNotFound - reset - end - end - - loaded if target - target - end - - def method_missing(method, *args, &block) - case method.to_s - when 'find_or_create' - return find(:first, :conditions => args.first) || create(args.first) - when /^find_or_create_by_(.*)$/ - rest = $1 - find_args = pull_finder_args_from(DynamicFinderMatch.match(method).attribute_names, *args) - return send("find_by_#{rest}", *find_args) || - method_missing("create_by_#{rest}", *args, &block) - when /^create_by_(.*)$/ - return create($1.split('_and_').zip(args).inject({}) { |h,kv| k,v=kv ; h[k] = v ; h }, &block) - end - - if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) - if block_given? - super { |*block_args| yield(*block_args) } - else - super - end - elsif @reflection.klass.scopes.include?(method) - @reflection.klass.scopes[method].call(self, *args) - else - with_scope(construct_scope) do - if block_given? - @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) } - else - @reflection.klass.send(method, *args) - end - end - end - end - - # overloaded in derived Association classes to provide useful scoping depending on association type. - def construct_scope - {} - end - - def reset_target! - @target = Array.new - end - - def find_target - records = - if @reflection.options[:finder_sql] - @reflection.klass.find_by_sql(@finder_sql) - else - find(:all) - end - - records = @reflection.options[:uniq] ? uniq(records) : records - records.each do |record| - set_inverse_instance(record, @owner) - end - records - end - - def add_record_to_target_with_callbacks(record) - callback(:before_add, record) - yield(record) if block_given? - @target ||= [] unless loaded? - @target << record unless @reflection.options[:uniq] && @target.include?(record) - callback(:after_add, record) - set_inverse_instance(record, @owner) - record - end - - private - # Separate the "finder" args from the "create" args given to a - # find_or_create_by_ call. Returns an array with the - # parameter values in the same order as the keys in the - # "names" array. This code was based on code in base.rb's - # method_missing method. - def pull_finder_args_from(names, *args) - attributes = names.collect { |name| name.intern } - attribute_hash = {} - args.each_with_index do |arg, i| - if arg.is_a?(Hash) - attribute_hash.merge! arg - else - attribute_hash[attributes[i]] = arg - end - end - attribute_hash = attribute_hash.with_indifferent_access - attributes.collect { |attr| attribute_hash[attr] } - end - - def create_record(attrs) - attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash) - ensure_owner_is_not_new - record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) do - @reflection.build_association(attrs) - end - if block_given? - add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) } - else - add_record_to_target_with_callbacks(record) - end - end - - def build_record(attrs) - attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash) - record = @reflection.build_association(attrs) - if block_given? - add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) } - else - add_record_to_target_with_callbacks(record) - end - end - - def remove_records(*records) - records = flatten_deeper(records) - records.each { |record| raise_on_type_mismatch(record) } - - transaction do - records.each { |record| callback(:before_remove, record) } - old_records = records.reject { |r| r.new_record? } - yield(records, old_records) - records.each { |record| callback(:after_remove, record) } - end - end - - def callback(method, record) - callbacks_for(method).each do |callback| - ActiveSupport::Callbacks::Callback.new(method, callback, record).call(@owner, record) - end - end - - def callbacks_for(callback_name) - full_callback_name = "#{callback_name}_for_#{@reflection.name}" - @owner.class.read_inheritable_attribute(full_callback_name.to_sym) || [] - end - - def ensure_owner_is_not_new - if @owner.new_record? - raise ActiveRecord::RecordNotSaved, "You cannot call create unless the parent is saved" - end - end - - def fetch_first_or_last_using_find?(args) - args.first.kind_of?(Hash) || !(loaded? || @owner.new_record? || @reflection.options[:finder_sql] || - @target.any? { |record| record.new_record? } || args.first.kind_of?(Integer)) - end - - def include_in_memory?(record) - if @reflection.is_a?(ActiveRecord::Reflection::ThroughReflection) - @owner.send(proxy_reflection.through_reflection.name.to_sym).each do |source| - source_reflection_target = source.send(proxy_reflection.source_reflection.name) - return true if source_reflection_target.respond_to?(:include?) ? source_reflection_target.include?(record) : source_reflection_target == record - end - false - else - @target.include?(record) - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb b/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb deleted file mode 100644 index f925eb23..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +++ /dev/null @@ -1,288 +0,0 @@ -module ActiveRecord - module Associations - # This is the root class of all association proxies: - # - # AssociationProxy - # BelongsToAssociation - # HasOneAssociation - # BelongsToPolymorphicAssociation - # AssociationCollection - # HasAndBelongsToManyAssociation - # HasManyAssociation - # HasManyThroughAssociation - # HasOneThroughAssociation - # - # Association proxies in Active Record are middlemen between the object that - # holds the association, known as the <tt>@owner</tt>, and the actual associated - # object, known as the <tt>@target</tt>. The kind of association any proxy is - # about is available in <tt>@reflection</tt>. That's an instance of the class - # ActiveRecord::Reflection::AssociationReflection. - # - # For example, given - # - # class Blog < ActiveRecord::Base - # has_many :posts - # end - # - # blog = Blog.find(:first) - # - # the association proxy in <tt>blog.posts</tt> has the object in +blog+ as - # <tt>@owner</tt>, the collection of its posts as <tt>@target</tt>, and - # the <tt>@reflection</tt> object represents a <tt>:has_many</tt> macro. - # - # This class has most of the basic instance methods removed, and delegates - # unknown methods to <tt>@target</tt> via <tt>method_missing</tt>. As a - # corner case, it even removes the +class+ method and that's why you get - # - # blog.posts.class # => Array - # - # though the object behind <tt>blog.posts</tt> is not an Array, but an - # ActiveRecord::Associations::HasManyAssociation. - # - # The <tt>@target</tt> object is not \loaded until needed. For example, - # - # blog.posts.count - # - # is computed directly through SQL and does not trigger by itself the - # instantiation of the actual post records. - class AssociationProxy #:nodoc: - alias_method :proxy_respond_to?, :respond_to? - alias_method :proxy_extend, :extend - delegate :to_param, :to => :proxy_target - instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^object_id$)/ } - - def initialize(owner, reflection) - @owner, @reflection = owner, reflection - reflection.check_validity! - Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) } - reset - end - - # Returns the owner of the proxy. - def proxy_owner - @owner - end - - # Returns the reflection object that represents the association handled - # by the proxy. - def proxy_reflection - @reflection - end - - # Returns the \target of the proxy, same as +target+. - def proxy_target - @target - end - - # Does the proxy or its \target respond to +symbol+? - def respond_to?(*args) - proxy_respond_to?(*args) || (load_target && @target.respond_to?(*args)) - end - - # Forwards <tt>===</tt> explicitly to the \target because the instance method - # removal above doesn't catch it. Loads the \target if needed. - def ===(other) - load_target - other === @target - end - - # Returns the name of the table of the related class: - # - # post.comments.aliased_table_name # => "comments" - # - def aliased_table_name - @reflection.klass.table_name - end - - # Returns the SQL string that corresponds to the <tt>:conditions</tt> - # option of the macro, if given, or +nil+ otherwise. - def conditions - @conditions ||= interpolate_sql(@reflection.sanitized_conditions) if @reflection.sanitized_conditions - end - alias :sql_conditions :conditions - - # Resets the \loaded flag to +false+ and sets the \target to +nil+. - def reset - @loaded = false - @target = nil - end - - # Reloads the \target and returns +self+ on success. - def reload - reset - load_target - self unless @target.nil? - end - - # Has the \target been already \loaded? - def loaded? - @loaded - end - - # Asserts the \target has been loaded setting the \loaded flag to +true+. - def loaded - @loaded = true - end - - # Returns the target of this proxy, same as +proxy_target+. - def target - @target - end - - # Sets the target of this proxy to <tt>\target</tt>, and the \loaded flag to +true+. - def target=(target) - @target = target - loaded - end - - # Forwards the call to the target. Loads the \target if needed. - def inspect - load_target - @target.inspect - end - - def send(method, *args) - if proxy_respond_to?(method) - super - else - load_target - @target.send(method, *args) - end - end - - protected - # Does the association have a <tt>:dependent</tt> option? - def dependent? - @reflection.options[:dependent] - end - - # Returns a string with the IDs of +records+ joined with a comma, quoted - # if needed. The result is ready to be inserted into a SQL IN clause. - # - # quoted_record_ids(records) # => "23,56,58,67" - # - def quoted_record_ids(records) - records.map { |record| record.quoted_id }.join(',') - end - - def interpolate_sql(sql, record = nil) - @owner.send(:interpolate_sql, sql, record) - end - - # Forwards the call to the reflection class. - def sanitize_sql(sql, table_name = @reflection.klass.quoted_table_name) - @reflection.klass.send(:sanitize_sql, sql, table_name) - end - - # Assigns the ID of the owner to the corresponding foreign key in +record+. - # If the association is polymorphic the type of the owner is also set. - def set_belongs_to_association_for(record) - if @reflection.options[:as] - record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record? - record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s - else - unless @owner.new_record? - primary_key = @reflection.options[:primary_key] || :id - record[@reflection.primary_key_name] = @owner.send(primary_key) - end - end - end - - # Merges into +options+ the ones coming from the reflection. - def merge_options_from_reflection!(options) - options.reverse_merge!( - :group => @reflection.options[:group], - :having => @reflection.options[:having], - :limit => @reflection.options[:limit], - :offset => @reflection.options[:offset], - :joins => @reflection.options[:joins], - :include => @reflection.options[:include], - :select => @reflection.options[:select], - :readonly => @reflection.options[:readonly] - ) - end - - # Forwards +with_scope+ to the reflection. - def with_scope(*args, &block) - @reflection.klass.send :with_scope, *args, &block - end - - private - # Forwards any missing method call to the \target. - def method_missing(method, *args, &block) - if load_target - if @target.respond_to?(method) - @target.send(method, *args, &block) - else - super - end - end - end - - # Loads the \target if needed and returns it. - # - # This method is abstract in the sense that it relies on +find_target+, - # which is expected to be provided by descendants. - # - # If the \target is already \loaded it is just returned. Thus, you can call - # +load_target+ unconditionally to get the \target. - # - # ActiveRecord::RecordNotFound is rescued within the method, and it is - # not reraised. The proxy is \reset and +nil+ is the return value. - def load_target - return nil unless defined?(@loaded) - - if !loaded? and (!@owner.new_record? || foreign_key_present) - @target = find_target - end - - @loaded = true - @target - rescue ActiveRecord::RecordNotFound - reset - end - - # Can be overwritten by associations that might have the foreign key - # available for an association without having the object itself (and - # still being a new record). Currently, only +belongs_to+ presents - # this scenario (both vanilla and polymorphic). - def foreign_key_present - false - end - - # Raises ActiveRecord::AssociationTypeMismatch unless +record+ is of - # the kind of the class of the associated objects. Meant to be used as - # a sanity check when you are about to assign an associated record. - def raise_on_type_mismatch(record) - unless record.is_a?(@reflection.klass) || record.is_a?(@reflection.class_name.constantize) - message = "#{@reflection.class_name}(##{@reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})" - raise ActiveRecord::AssociationTypeMismatch, message - end - end - - # Array#flatten has problems with recursive arrays. Going one level - # deeper solves the majority of the problems. - def flatten_deeper(array) - array.collect { |element| (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element }.flatten - end - - # Returns the ID of the owner, quoted if needed. - def owner_quoted_id - @owner.quoted_id - end - - def set_inverse_instance(record, instance) - return if record.nil? || !we_can_set_the_inverse_on_this?(record) - inverse_relationship = @reflection.inverse_of - unless inverse_relationship.nil? - record.send(:"set_#{inverse_relationship.name}_target", instance) - end - end - - # Override in subclasses - def we_can_set_the_inverse_on_this?(record) - false - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb b/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb deleted file mode 100644 index 3f8b9d2c..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +++ /dev/null @@ -1,86 +0,0 @@ -module ActiveRecord - module Associations - class BelongsToAssociation < AssociationProxy #:nodoc: - def create(attributes = {}) - replace(@reflection.create_association(attributes)) - end - - def build(attributes = {}) - replace(@reflection.build_association(attributes)) - end - - def replace(record) - counter_cache_name = @reflection.counter_cache_column - - if record.nil? - if counter_cache_name && !@owner.new_record? - @reflection.klass.decrement_counter(counter_cache_name, previous_record_id) if @owner[@reflection.primary_key_name] - end - - @target = @owner[@reflection.primary_key_name] = nil - else - raise_on_type_mismatch(record) - - if counter_cache_name && !@owner.new_record? - @reflection.klass.increment_counter(counter_cache_name, record.id) - @reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name] - end - - @target = (AssociationProxy === record ? record.target : record) - @owner[@reflection.primary_key_name] = record_id(record) unless record.new_record? - @updated = true - end - - set_inverse_instance(record, @owner) - - loaded - record - end - - def updated? - @updated - end - - private - def find_target - find_method = if @reflection.options[:primary_key] - "find_by_#{@reflection.options[:primary_key]}" - else - "find" - end - the_target = @reflection.klass.send(find_method, - @owner[@reflection.primary_key_name], - :select => @reflection.options[:select], - :conditions => conditions, - :include => @reflection.options[:include], - :readonly => @reflection.options[:readonly] - ) if @owner[@reflection.primary_key_name] - set_inverse_instance(the_target, @owner) - the_target - end - - def foreign_key_present - !@owner[@reflection.primary_key_name].nil? - end - - def record_id(record) - record.send(@reflection.options[:primary_key] || :id) - end - - def previous_record_id - @previous_record_id ||= if @reflection.options[:primary_key] - previous_record = @owner.send(@reflection.name) - previous_record.nil? ? nil : previous_record.id - else - @owner[@reflection.primary_key_name] - end - end - - # NOTE - for now, we're only supporting inverse setting from belongs_to back onto - # has_one associations. - def we_can_set_the_inverse_on_this?(record) - @reflection.has_inverse? && @reflection.inverse_of.macro == :has_one - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb b/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb deleted file mode 100644 index f6edd638..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +++ /dev/null @@ -1,77 +0,0 @@ -module ActiveRecord - module Associations - class BelongsToPolymorphicAssociation < AssociationProxy #:nodoc: - def replace(record) - if record.nil? - @target = @owner[@reflection.primary_key_name] = @owner[@reflection.options[:foreign_type]] = nil - else - @target = (AssociationProxy === record ? record.target : record) - - @owner[@reflection.primary_key_name] = record_id(record) - @owner[@reflection.options[:foreign_type]] = record.class.base_class.name.to_s - - @updated = true - end - - set_inverse_instance(record, @owner) - loaded - record - end - - def updated? - @updated - end - - private - - # NOTE - for now, we're only supporting inverse setting from belongs_to back onto - # has_one associations. - def we_can_set_the_inverse_on_this?(record) - if @reflection.has_inverse? - inverse_association = @reflection.polymorphic_inverse_of(record.class) - inverse_association && inverse_association.macro == :has_one - else - false - end - end - - def set_inverse_instance(record, instance) - return if record.nil? || !we_can_set_the_inverse_on_this?(record) - inverse_relationship = @reflection.polymorphic_inverse_of(record.class) - unless inverse_relationship.nil? - record.send(:"set_#{inverse_relationship.name}_target", instance) - end - end - - def find_target - return nil if association_class.nil? - - target = - if @reflection.options[:conditions] - association_class.find( - @owner[@reflection.primary_key_name], - :select => @reflection.options[:select], - :conditions => conditions, - :include => @reflection.options[:include] - ) - else - association_class.find(@owner[@reflection.primary_key_name], :select => @reflection.options[:select], :include => @reflection.options[:include]) - end - set_inverse_instance(target, @owner) - target - end - - def foreign_key_present - !@owner[@reflection.primary_key_name].nil? - end - - def record_id(record) - record.send(@reflection.options[:primary_key] || :id) - end - - def association_class - @owner[@reflection.options[:foreign_type]] ? @owner[@reflection.options[:foreign_type]].constantize : nil - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb deleted file mode 100644 index 83a4a8b9..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ /dev/null @@ -1,143 +0,0 @@ -module ActiveRecord - module Associations - class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc: - def initialize(owner, reflection) - super - @primary_key_list = {} - end - - def create(attributes = {}) - create_record(attributes) { |record| insert_record(record) } - end - - def create!(attributes = {}) - create_record(attributes) { |record| insert_record(record, true) } - end - - def columns - @reflection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns") - end - - def reset_column_information - @reflection.reset_column_information - end - - def has_primary_key? - return @has_primary_key unless @has_primary_key.nil? - @has_primary_key = (@owner.connection.supports_primary_key? && - @owner.connection.primary_key(@reflection.options[:join_table])) - end - - protected - def construct_find_options!(options) - options[:joins] = @join_sql - options[:readonly] = finding_with_ambiguous_select?(options[:select] || @reflection.options[:select]) - options[:select] ||= (@reflection.options[:select] || '*') - end - - def count_records - load_target.size - end - - def insert_record(record, force = true, validate = true) - if has_primary_key? - raise ActiveRecord::ConfigurationError, - "Primary key is not allowed in a has_and_belongs_to_many join table (#{@reflection.options[:join_table]})." - end - - if record.new_record? - if force - record.save! - else - return false unless record.save(validate) - end - end - - if @reflection.options[:insert_sql] - @owner.connection.insert(interpolate_sql(@reflection.options[:insert_sql], record)) - else - attributes = columns.inject({}) do |attrs, column| - case column.name.to_s - when @reflection.primary_key_name.to_s - attrs[column.name] = owner_quoted_id - when @reflection.association_foreign_key.to_s - attrs[column.name] = record.quoted_id - else - if record.has_attribute?(column.name) - value = @owner.send(:quote_value, record[column.name], column) - attrs[column.name] = value unless value.nil? - end - end - attrs - end - - sql = - "INSERT INTO #{@owner.connection.quote_table_name @reflection.options[:join_table]} (#{@owner.send(:quoted_column_names, attributes).join(', ')}) " + - "VALUES (#{attributes.values.join(', ')})" - - @owner.connection.insert(sql) - end - - return true - end - - def delete_records(records) - if sql = @reflection.options[:delete_sql] - records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) } - else - ids = quoted_record_ids(records) - sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})" - @owner.connection.delete(sql) - end - end - - def construct_sql - if @reflection.options[:finder_sql] - @finder_sql = interpolate_sql(@reflection.options[:finder_sql]) - else - @finder_sql = "#{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.primary_key_name} = #{owner_quoted_id} " - @finder_sql << " AND (#{conditions})" if conditions - end - - @join_sql = "INNER JOIN #{@owner.connection.quote_table_name @reflection.options[:join_table]} ON #{@reflection.quoted_table_name}.#{@reflection.klass.primary_key} = #{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.association_foreign_key}" - - if @reflection.options[:counter_sql] - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - elsif @reflection.options[:finder_sql] - # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */ - @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" } - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - else - @counter_sql = @finder_sql - end - end - - def construct_scope - { :find => { :conditions => @finder_sql, - :joins => @join_sql, - :readonly => false, - :order => @reflection.options[:order], - :include => @reflection.options[:include], - :limit => @reflection.options[:limit] } } - end - - # Join tables with additional columns on top of the two foreign keys must be considered ambiguous unless a select - # clause has been explicitly defined. Otherwise you can get broken records back, if, for example, the join column also has - # an id column. This will then overwrite the id column of the records coming back. - def finding_with_ambiguous_select?(select_clause) - !select_clause && columns.size != 2 - end - - private - def create_record(attributes, &block) - # Can't use Base.create because the foreign key may be a protected attribute. - ensure_owner_is_not_new - if attributes.is_a?(Array) - attributes.collect { |attr| create(attr) } - else - build_record(attributes, &block) - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb deleted file mode 100644 index 4e113be1..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +++ /dev/null @@ -1,127 +0,0 @@ -module ActiveRecord - module Associations - # This is the proxy that handles a has many association. - # - # If the association has a <tt>:through</tt> option further specialization - # is provided by its child HasManyThroughAssociation. - class HasManyAssociation < AssociationCollection #:nodoc: - protected - def owner_quoted_id - if @reflection.options[:primary_key] - quote_value(@owner.send(@reflection.options[:primary_key])) - else - @owner.quoted_id - end - end - - # Returns the number of records in this collection. - # - # If the association has a counter cache it gets that value. Otherwise - # it will attempt to do a count via SQL, bounded to <tt>:limit</tt> if - # there's one. Some configuration options like :group make it impossible - # to do a SQL count, in those cases the array count will be used. - # - # That does not depend on whether the collection has already been loaded - # or not. The +size+ method is the one that takes the loaded flag into - # account and delegates to +count_records+ if needed. - # - # If the collection is empty the target is set to an empty array and - # the loaded flag is set to true as well. - def count_records - count = if has_cached_counter? - @owner.send(:read_attribute, cached_counter_attribute_name) - elsif @reflection.options[:counter_sql] - @reflection.klass.count_by_sql(@counter_sql) - else - @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]) - end - - # If there's nothing in the database and @target has no new records - # we are certain the current target is an empty array. This is a - # documented side-effect of the method that may avoid an extra SELECT. - @target ||= [] and loaded if count == 0 - - if @reflection.options[:limit] - count = [ @reflection.options[:limit], count ].min - end - - return count - end - - def has_cached_counter? - @owner.attribute_present?(cached_counter_attribute_name) - end - - def cached_counter_attribute_name - "#{@reflection.name}_count" - end - - def insert_record(record, force = false, validate = true) - set_belongs_to_association_for(record) - force ? record.save! : record.save(validate) - end - - # Deletes the records according to the <tt>:dependent</tt> option. - def delete_records(records) - case @reflection.options[:dependent] - when :destroy - records.each { |r| r.destroy } - when :delete_all - @reflection.klass.delete(records.map { |record| record.id }) - else - ids = quoted_record_ids(records) - @reflection.klass.update_all( - "#{@reflection.primary_key_name} = NULL", - "#{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})" - ) - @owner.class.update_counters(@owner.id, cached_counter_attribute_name => -records.size) if has_cached_counter? - end - end - - def target_obsolete? - false - end - - def construct_sql - case - when @reflection.options[:finder_sql] - @finder_sql = interpolate_sql(@reflection.options[:finder_sql]) - - when @reflection.options[:as] - @finder_sql = - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" - @finder_sql << " AND (#{conditions})" if conditions - - else - @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" - @finder_sql << " AND (#{conditions})" if conditions - end - - if @reflection.options[:counter_sql] - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - elsif @reflection.options[:finder_sql] - # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */ - @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" } - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - else - @counter_sql = @finder_sql - end - end - - def construct_scope - create_scoping = {} - set_belongs_to_association_for(create_scoping) - { - :find => { :conditions => @finder_sql, :readonly => false, :order => @reflection.options[:order], :limit => @reflection.options[:limit], :include => @reflection.options[:include]}, - :create => create_scoping - } - end - - def we_can_set_the_inverse_on_this?(record) - inverse = @reflection.inverse_of - return !inverse.nil? - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb deleted file mode 100644 index aa4c185f..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +++ /dev/null @@ -1,266 +0,0 @@ -module ActiveRecord - module Associations - class HasManyThroughAssociation < HasManyAssociation #:nodoc: - alias_method :new, :build - - def create!(attrs = nil) - transaction do - self << (object = attrs ? @reflection.klass.send(:with_scope, :create => attrs) { @reflection.create_association! } : @reflection.create_association!) - object - end - end - - def create(attrs = nil) - transaction do - object = if attrs - @reflection.klass.send(:with_scope, :create => attrs) { - @reflection.create_association - } - else - @reflection.create_association - end - raise_on_type_mismatch(object) - add_record_to_target_with_callbacks(object) do |r| - insert_record(object, false) - end - object - end - end - - # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and - # calling collection.size if it has. If it's more likely than not that the collection does have a size larger than zero, - # and you need to fetch that collection afterwards, it'll take one fewer SELECT query if you use #length. - def size - return @owner.send(:read_attribute, cached_counter_attribute_name) if has_cached_counter? - return @target.size if loaded? - return count - end - - protected - def target_reflection_has_associated_record? - if @reflection.through_reflection.macro == :belongs_to && @owner[@reflection.through_reflection.primary_key_name].blank? - false - else - true - end - end - - def construct_find_options!(options) - options[:select] = construct_select(options[:select]) - options[:from] ||= construct_from - options[:joins] = construct_joins(options[:joins]) - options[:include] = @reflection.source_reflection.options[:include] if options[:include].nil? && @reflection.source_reflection.options[:include] - end - - def insert_record(record, force = true, validate = true) - if record.new_record? - if force - record.save! - else - return false unless record.save(validate) - end - end - through_reflection = @reflection.through_reflection - klass = through_reflection.klass - @owner.send(@reflection.through_reflection.name).proxy_target << klass.send(:with_scope, :create => construct_join_attributes(record)) { through_reflection.create_association! } - end - - # TODO - add dependent option support - def delete_records(records) - klass = @reflection.through_reflection.klass - records.each do |associate| - klass.delete_all(construct_join_attributes(associate)) - end - end - - def find_target - return [] unless target_reflection_has_associated_record? - @reflection.klass.find(:all, - :select => construct_select, - :conditions => construct_conditions, - :from => construct_from, - :joins => construct_joins, - :order => @reflection.options[:order], - :limit => @reflection.options[:limit], - :group => @reflection.options[:group], - :readonly => @reflection.options[:readonly], - :include => @reflection.options[:include] || @reflection.source_reflection.options[:include] - ) - end - - # Construct attributes for associate pointing to owner. - def construct_owner_attributes(reflection) - if as = reflection.options[:as] - { "#{as}_id" => @owner.id, - "#{as}_type" => @owner.class.base_class.name.to_s } - else - { reflection.primary_key_name => @owner.id } - end - end - - # Construct attributes for :through pointing to owner and associate. - def construct_join_attributes(associate) - # TODO: revist this to allow it for deletion, supposing dependent option is supported - raise ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(@owner, @reflection) if [:has_one, :has_many].include?(@reflection.source_reflection.macro) - join_attributes = construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.primary_key_name => associate.id) - if @reflection.options[:source_type] - join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class.base_class.name.to_s) - end - join_attributes - end - - # Associate attributes pointing to owner, quoted. - def construct_quoted_owner_attributes(reflection) - if as = reflection.options[:as] - { "#{as}_id" => owner_quoted_id, - "#{as}_type" => reflection.klass.quote_value( - @owner.class.base_class.name.to_s, - reflection.klass.columns_hash["#{as}_type"]) } - elsif reflection.macro == :belongs_to - { reflection.klass.primary_key => @owner[reflection.primary_key_name] } - else - { reflection.primary_key_name => owner_quoted_id } - end - end - - # Build SQL conditions from attributes, qualified by table name. - def construct_conditions - table_name = @reflection.through_reflection.quoted_table_name - conditions = construct_quoted_owner_attributes(@reflection.through_reflection).map do |attr, value| - "#{table_name}.#{attr} = #{value}" - end - conditions << sql_conditions if sql_conditions - "(" + conditions.join(') AND (') + ")" - end - - def construct_from - @reflection.quoted_table_name - end - - def construct_select(custom_select = nil) - distinct = "DISTINCT " if @reflection.options[:uniq] - selected = custom_select || @reflection.options[:select] || "#{distinct}#{@reflection.quoted_table_name}.*" - end - - def construct_joins(custom_joins = nil) - polymorphic_join = nil - if @reflection.source_reflection.macro == :belongs_to - reflection_primary_key = @reflection.klass.primary_key - source_primary_key = @reflection.source_reflection.primary_key_name - if @reflection.options[:source_type] - polymorphic_join = "AND %s.%s = %s" % [ - @reflection.through_reflection.quoted_table_name, "#{@reflection.source_reflection.options[:foreign_type]}", - @owner.class.quote_value(@reflection.options[:source_type]) - ] - end - else - reflection_primary_key = @reflection.source_reflection.primary_key_name - source_primary_key = @reflection.through_reflection.klass.primary_key - if @reflection.source_reflection.options[:as] - polymorphic_join = "AND %s.%s = %s" % [ - @reflection.quoted_table_name, "#{@reflection.source_reflection.options[:as]}_type", - @owner.class.quote_value(@reflection.through_reflection.klass.name) - ] - end - end - - "INNER JOIN %s ON %s.%s = %s.%s %s #{@reflection.options[:joins]} #{custom_joins}" % [ - @reflection.through_reflection.quoted_table_name, - @reflection.quoted_table_name, reflection_primary_key, - @reflection.through_reflection.quoted_table_name, source_primary_key, - polymorphic_join - ] - end - - def construct_scope - { :create => construct_owner_attributes(@reflection), - :find => { :from => construct_from, - :conditions => construct_conditions, - :joins => construct_joins, - :include => @reflection.options[:include], - :select => construct_select, - :order => @reflection.options[:order], - :limit => @reflection.options[:limit], - :readonly => @reflection.options[:readonly], - } } - end - - def construct_sql - case - when @reflection.options[:finder_sql] - @finder_sql = interpolate_sql(@reflection.options[:finder_sql]) - - @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" - @finder_sql << " AND (#{conditions})" if conditions - else - @finder_sql = construct_conditions - end - - if @reflection.options[:counter_sql] - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - elsif @reflection.options[:finder_sql] - # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */ - @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" } - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - else - @counter_sql = @finder_sql - end - end - - def conditions - @conditions = build_conditions unless defined?(@conditions) - @conditions - end - - def build_conditions - association_conditions = @reflection.options[:conditions] - through_conditions = build_through_conditions - source_conditions = @reflection.source_reflection.options[:conditions] - uses_sti = !@reflection.through_reflection.klass.descends_from_active_record? - - if association_conditions || through_conditions || source_conditions || uses_sti - all = [] - - [association_conditions, source_conditions].each do |conditions| - all << interpolate_sql(sanitize_sql(conditions)) if conditions - end - - all << through_conditions if through_conditions - all << build_sti_condition if uses_sti - - all.map { |sql| "(#{sql})" } * ' AND ' - end - end - - def build_through_conditions - conditions = @reflection.through_reflection.options[:conditions] - if conditions.is_a?(Hash) - interpolate_sql(sanitize_sql(conditions)).gsub( - @reflection.quoted_table_name, - @reflection.through_reflection.quoted_table_name) - elsif conditions - interpolate_sql(sanitize_sql(conditions)) - end - end - - def build_sti_condition - @reflection.through_reflection.klass.send(:type_condition) - end - - alias_method :sql_conditions, :conditions - - def has_cached_counter? - @owner.attribute_present?(cached_counter_attribute_name) - end - - def cached_counter_attribute_name - "#{@reflection.name}_count" - end - - # NOTE - not sure that we can actually cope with inverses here - def we_can_set_the_inverse_on_this?(record) - false - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb deleted file mode 100644 index b504e052..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb +++ /dev/null @@ -1,142 +0,0 @@ -module ActiveRecord - module Associations - class HasOneAssociation < BelongsToAssociation #:nodoc: - def initialize(owner, reflection) - super - construct_sql - end - - def create(attrs = {}, replace_existing = true) - new_record(replace_existing) do |reflection| - attrs = merge_with_conditions(attrs) - reflection.create_association(attrs) - end - end - - def create!(attrs = {}, replace_existing = true) - new_record(replace_existing) do |reflection| - attrs = merge_with_conditions(attrs) - reflection.create_association!(attrs) - end - end - - def build(attrs = {}, replace_existing = true) - new_record(replace_existing) do |reflection| - attrs = merge_with_conditions(attrs) - reflection.build_association(attrs) - end - end - - def replace(obj, dont_save = false) - load_target - - unless @target.nil? || @target == obj - if dependent? && !dont_save - case @reflection.options[:dependent] - when :delete - @target.delete unless @target.new_record? - @owner.clear_association_cache - when :destroy - @target.destroy unless @target.new_record? - @owner.clear_association_cache - when :nullify - @target[@reflection.primary_key_name] = nil - @target.save unless @owner.new_record? || @target.new_record? - end - else - @target[@reflection.primary_key_name] = nil - @target.save unless @owner.new_record? || @target.new_record? - end - end - - if obj.nil? - @target = nil - else - raise_on_type_mismatch(obj) - set_belongs_to_association_for(obj) - @target = (AssociationProxy === obj ? obj.target : obj) - end - - set_inverse_instance(obj, @owner) - @loaded = true - - unless @owner.new_record? or obj.nil? or dont_save - return (obj.save ? self : false) - else - return (obj.nil? ? nil : self) - end - end - - protected - def owner_quoted_id - if @reflection.options[:primary_key] - @owner.class.quote_value(@owner.send(@reflection.options[:primary_key])) - else - @owner.quoted_id - end - end - - private - def find_target - the_target = @reflection.klass.find(:first, - :conditions => @finder_sql, - :select => @reflection.options[:select], - :order => @reflection.options[:order], - :include => @reflection.options[:include], - :readonly => @reflection.options[:readonly] - ) - set_inverse_instance(the_target, @owner) - the_target - end - - def construct_sql - case - when @reflection.options[:as] - @finder_sql = - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" - else - @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" - end - @finder_sql << " AND (#{conditions})" if conditions - end - - def construct_scope - create_scoping = {} - set_belongs_to_association_for(create_scoping) - { :create => create_scoping } - end - - def new_record(replace_existing) - # Make sure we load the target first, if we plan on replacing the existing - # instance. Otherwise, if the target has not previously been loaded - # elsewhere, the instance we create will get orphaned. - load_target if replace_existing - record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) do - yield @reflection - end - - if replace_existing - replace(record, true) - else - record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? - self.target = record - set_inverse_instance(record, @owner) - end - - record - end - - def merge_with_conditions(attrs={}) - attrs ||= {} - attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash) - attrs - end - - def we_can_set_the_inverse_on_this?(record) - inverse = @reflection.inverse_of - return !inverse.nil? - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb deleted file mode 100644 index d8bcf76a..00000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +++ /dev/null @@ -1,37 +0,0 @@ -module ActiveRecord - module Associations - class HasOneThroughAssociation < HasManyThroughAssociation - - def create_through_record(new_value) #nodoc: - klass = @reflection.through_reflection.klass - - current_object = @owner.send(@reflection.through_reflection.name) - - if current_object - new_value ? current_object.update_attributes(construct_join_attributes(new_value)) : current_object.destroy - elsif new_value - if @owner.new_record? - self.target = new_value - through_association = @owner.send(:association_instance_get, @reflection.through_reflection.name) - through_association.build(construct_join_attributes(new_value)) - else - @owner.send(@reflection.through_reflection.name, klass.create(construct_join_attributes(new_value))) - end - end - end - - private - def find(*args) - super(args.merge(:limit => 1)) - end - - def find_target - super.first - end - - def reset_target! - @target = nil - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/attribute_methods.rb b/vendor/rails/activerecord/lib/active_record/attribute_methods.rb deleted file mode 100644 index 22630b3e..00000000 --- a/vendor/rails/activerecord/lib/active_record/attribute_methods.rb +++ /dev/null @@ -1,388 +0,0 @@ -module ActiveRecord - module AttributeMethods #:nodoc: - DEFAULT_SUFFIXES = %w(= ? _before_type_cast) - ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [:datetime, :timestamp, :time, :date] - - def self.included(base) - base.extend ClassMethods - base.attribute_method_suffix(*DEFAULT_SUFFIXES) - base.cattr_accessor :attribute_types_cached_by_default, :instance_writer => false - base.attribute_types_cached_by_default = ATTRIBUTE_TYPES_CACHED_BY_DEFAULT - base.cattr_accessor :time_zone_aware_attributes, :instance_writer => false - base.time_zone_aware_attributes = false - base.class_inheritable_accessor :skip_time_zone_conversion_for_attributes, :instance_writer => false - base.skip_time_zone_conversion_for_attributes = [] - end - - # Declare and check for suffixed attribute methods. - module ClassMethods - # Declares a method available for all attributes with the given suffix. - # Uses +method_missing+ and <tt>respond_to?</tt> to rewrite the method - # - # #{attr}#{suffix}(*args, &block) - # - # to - # - # attribute#{suffix}(#{attr}, *args, &block) - # - # An <tt>attribute#{suffix}</tt> instance method must exist and accept at least - # the +attr+ argument. - # - # For example: - # - # class Person < ActiveRecord::Base - # attribute_method_suffix '_changed?' - # - # private - # def attribute_changed?(attr) - # ... - # end - # end - # - # person = Person.find(1) - # person.name_changed? # => false - # person.name = 'Hubert' - # person.name_changed? # => true - def attribute_method_suffix(*suffixes) - attribute_method_suffixes.concat suffixes - rebuild_attribute_method_regexp - end - - # Returns MatchData if method_name is an attribute method. - def match_attribute_method?(method_name) - rebuild_attribute_method_regexp unless defined?(@@attribute_method_regexp) && @@attribute_method_regexp - @@attribute_method_regexp.match(method_name) - end - - - # Contains the names of the generated attribute methods. - def generated_methods #:nodoc: - @generated_methods ||= Set.new - end - - def generated_methods? - !generated_methods.empty? - end - - # Generates all the attribute related methods for columns in the database - # accessors, mutators and query methods. - def define_attribute_methods - return if generated_methods? - columns_hash.each do |name, column| - unless instance_method_already_implemented?(name) - if self.serialized_attributes[name] - define_read_method_for_serialized_attribute(name) - elsif create_time_zone_conversion_attribute?(name, column) - define_read_method_for_time_zone_conversion(name) - else - define_read_method(name.to_sym, name, column) - end - end - - unless instance_method_already_implemented?("#{name}=") - if create_time_zone_conversion_attribute?(name, column) - define_write_method_for_time_zone_conversion(name) - else - define_write_method(name.to_sym) - end - end - - unless instance_method_already_implemented?("#{name}?") - define_question_method(name) - end - end - end - - # Checks whether the method is defined in the model or any of its subclasses - # that also derive from Active Record. Raises DangerousAttributeError if the - # method is defined by Active Record though. - def instance_method_already_implemented?(method_name) - method_name = method_name.to_s - return true if method_name =~ /^id(=$|\?$|$)/ - @_defined_class_methods ||= ancestors.first(ancestors.index(ActiveRecord::Base)).sum([]) { |m| m.public_instance_methods(false) | m.private_instance_methods(false) | m.protected_instance_methods(false) }.map(&:to_s).to_set - @@_defined_activerecord_methods ||= (ActiveRecord::Base.public_instance_methods(false) | ActiveRecord::Base.private_instance_methods(false) | ActiveRecord::Base.protected_instance_methods(false)).map(&:to_s).to_set - raise DangerousAttributeError, "#{method_name} is defined by ActiveRecord" if @@_defined_activerecord_methods.include?(method_name) - @_defined_class_methods.include?(method_name) - end - - alias :define_read_methods :define_attribute_methods - - # +cache_attributes+ allows you to declare which converted attribute values should - # be cached. Usually caching only pays off for attributes with expensive conversion - # methods, like time related columns (e.g. +created_at+, +updated_at+). - def cache_attributes(*attribute_names) - attribute_names.each {|attr| cached_attributes << attr.to_s} - end - - # Returns the attributes which are cached. By default time related columns - # with datatype <tt>:datetime, :timestamp, :time, :date</tt> are cached. - def cached_attributes - @cached_attributes ||= - columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map(&:name).to_set - end - - # Returns +true+ if the provided attribute is being cached. - def cache_attribute?(attr_name) - cached_attributes.include?(attr_name) - end - - private - # Suffixes a, ?, c become regexp /(a|\?|c)$/ - def rebuild_attribute_method_regexp - suffixes = attribute_method_suffixes.map { |s| Regexp.escape(s) } - @@attribute_method_regexp = /(#{suffixes.join('|')})$/.freeze - end - - # Default to =, ?, _before_type_cast - def attribute_method_suffixes - @@attribute_method_suffixes ||= [] - end - - def create_time_zone_conversion_attribute?(name, column) - time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(name.to_sym) && [:datetime, :timestamp].include?(column.type) - end - - # Define an attribute reader method. Cope with nil column. - def define_read_method(symbol, attr_name, column) - cast_code = column.type_cast_code('v') if column - access_code = cast_code ? "(v=@attributes['#{attr_name}']) && #{cast_code}" : "@attributes['#{attr_name}']" - - unless attr_name.to_s == self.primary_key.to_s - access_code = access_code.insert(0, "missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); ") - end - - if cache_attribute?(attr_name) - access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})" - end - evaluate_attribute_method attr_name, "def #{symbol}; #{access_code}; end" - end - - # Define read method for serialized attribute. - def define_read_method_for_serialized_attribute(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}; unserialize_attribute('#{attr_name}'); end" - end - - # Defined for all +datetime+ and +timestamp+ attributes when +time_zone_aware_attributes+ are enabled. - # This enhanced read method automatically converts the UTC time stored in the database to the time zone stored in Time.zone. - def define_read_method_for_time_zone_conversion(attr_name) - method_body = <<-EOV - def #{attr_name}(reload = false) - cached = @attributes_cache['#{attr_name}'] - return cached if cached && !reload - time = read_attribute('#{attr_name}') - @attributes_cache['#{attr_name}'] = time.acts_like?(:time) ? time.in_time_zone : time - end - EOV - evaluate_attribute_method attr_name, method_body - end - - # Defines a predicate method <tt>attr_name?</tt>. - def define_question_method(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}?; query_attribute('#{attr_name}'); end", "#{attr_name}?" - end - - def define_write_method(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}=(new_value);write_attribute('#{attr_name}', new_value);end", "#{attr_name}=" - end - - # Defined for all +datetime+ and +timestamp+ attributes when +time_zone_aware_attributes+ are enabled. - # This enhanced write method will automatically convert the time passed to it to the zone stored in Time.zone. - def define_write_method_for_time_zone_conversion(attr_name) - method_body = <<-EOV - def #{attr_name}=(time) - unless time.acts_like?(:time) - time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time - end - time = time.in_time_zone rescue nil if time - write_attribute(:#{attr_name}, time) - end - EOV - evaluate_attribute_method attr_name, method_body, "#{attr_name}=" - end - - # Evaluate the definition for an attribute related method - def evaluate_attribute_method(attr_name, method_definition, method_name=attr_name) - - unless method_name.to_s == primary_key.to_s - generated_methods << method_name - end - - begin - class_eval(method_definition, __FILE__) - rescue SyntaxError => err - generated_methods.delete(attr_name) - if logger - logger.warn "Exception occurred during reader method compilation." - logger.warn "Maybe #{attr_name} is not a valid Ruby identifier?" - logger.warn err.message - end - end - end - end # ClassMethods - - - # Allows access to the object attributes, which are held in the <tt>@attributes</tt> hash, as though they - # were first-class methods. So a Person class with a name attribute can use Person#name and - # Person#name= and never directly use the attributes hash -- except for multiple assigns with - # ActiveRecord#attributes=. A Milestone class can also ask Milestone#completed? to test that - # the completed attribute is not +nil+ or 0. - # - # It's also possible to instantiate related objects, so a Client class belonging to the clients - # table with a +master_id+ foreign key can instantiate master through Client#master. - def method_missing(method_id, *args, &block) - method_name = method_id.to_s - - if self.class.private_method_defined?(method_name) - raise NoMethodError.new("Attempt to call private method", method_name, args) - end - - # If we haven't generated any methods yet, generate them, then - # see if we've created the method we're looking for. - if !self.class.generated_methods? - self.class.define_attribute_methods - if self.class.generated_methods.include?(method_name) - return self.send(method_id, *args, &block) - end - end - - if self.class.primary_key.to_s == method_name - id - elsif md = self.class.match_attribute_method?(method_name) - attribute_name, method_type = md.pre_match, md.to_s - if @attributes.include?(attribute_name) - __send__("attribute#{method_type}", attribute_name, *args, &block) - else - super - end - elsif @attributes.include?(method_name) - read_attribute(method_name) - else - super - end - end - - # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example, - # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). - def read_attribute(attr_name) - attr_name = attr_name.to_s - if !(value = @attributes[attr_name]).nil? - if column = column_for_attribute(attr_name) - if unserializable_attribute?(attr_name, column) - unserialize_attribute(attr_name) - else - column.type_cast(value) - end - else - value - end - else - nil - end - end - - def read_attribute_before_type_cast(attr_name) - @attributes[attr_name] - end - - # Returns true if the attribute is of a text column and marked for serialization. - def unserializable_attribute?(attr_name, column) - column.text? && self.class.serialized_attributes[attr_name] - end - - # Returns the unserialized object of the attribute. - def unserialize_attribute(attr_name) - unserialized_object = object_from_yaml(@attributes[attr_name]) - - if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) || unserialized_object.nil? - @attributes.frozen? ? unserialized_object : @attributes[attr_name] = unserialized_object - else - raise SerializationTypeMismatch, - "#{attr_name} was supposed to be a #{self.class.serialized_attributes[attr_name]}, but was a #{unserialized_object.class.to_s}" - end - end - - - # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings for fixnum and float - # columns are turned into +nil+. - def write_attribute(attr_name, value) - attr_name = attr_name.to_s - @attributes_cache.delete(attr_name) - if (column = column_for_attribute(attr_name)) && column.number? - @attributes[attr_name] = convert_number_column_value(value) - else - @attributes[attr_name] = value - end - end - - - def query_attribute(attr_name) - unless value = read_attribute(attr_name) - false - else - column = self.class.columns_hash[attr_name] - if column.nil? - if Numeric === value || value !~ /[^0-9]/ - !value.to_i.zero? - else - return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value) - !value.blank? - end - elsif column.number? - !value.zero? - else - !value.blank? - end - end - end - - # A Person object with a name attribute can ask <tt>person.respond_to?(:name)</tt>, - # <tt>person.respond_to?(:name=)</tt>, and <tt>person.respond_to?(:name?)</tt> - # which will all return +true+. - alias :respond_to_without_attributes? :respond_to? - def respond_to?(method, include_private_methods = false) - method_name = method.to_s - if super - return true - elsif !include_private_methods && super(method, true) - # If we're here than we haven't found among non-private methods - # but found among all methods. Which means that given method is private. - return false - elsif !self.class.generated_methods? - self.class.define_attribute_methods - if self.class.generated_methods.include?(method_name) - return true - end - end - - if @attributes.nil? - return super - elsif @attributes.include?(method_name) - return true - elsif md = self.class.match_attribute_method?(method_name) - return true if @attributes.include?(md.pre_match) - end - super - end - - private - - def missing_attribute(attr_name, stack) - raise ActiveRecord::MissingAttributeError, "missing attribute: #{attr_name}", stack - end - - # Handle *? for method_missing. - def attribute?(attribute_name) - query_attribute(attribute_name) - end - - # Handle *= for method_missing. - def attribute=(attribute_name, value) - write_attribute(attribute_name, value) - end - - # Handle *_before_type_cast for method_missing. - def attribute_before_type_cast(attribute_name) - read_attribute_before_type_cast(attribute_name) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/autosave_association.rb b/vendor/rails/activerecord/lib/active_record/autosave_association.rb deleted file mode 100644 index 045e16b0..00000000 --- a/vendor/rails/activerecord/lib/active_record/autosave_association.rb +++ /dev/null @@ -1,395 +0,0 @@ -module ActiveRecord - # AutosaveAssociation is a module that takes care of automatically saving - # your associations when the parent is saved. In addition to saving, it - # also destroys any associations that were marked for destruction. - # (See mark_for_destruction and marked_for_destruction?) - # - # Saving of the parent, its associations, and the destruction of marked - # associations, all happen inside 1 transaction. This should never leave the - # database in an inconsistent state after, for instance, mass assigning - # attributes and saving them. - # - # If validations for any of the associations fail, their error messages will - # be applied to the parent. - # - # Note that it also means that associations marked for destruction won't - # be destroyed directly. They will however still be marked for destruction. - # - # === One-to-one Example - # - # Consider a Post model with one Author: - # - # class Post - # has_one :author, :autosave => true - # end - # - # Saving changes to the parent and its associated model can now be performed - # automatically _and_ atomically: - # - # post = Post.find(1) - # post.title # => "The current global position of migrating ducks" - # post.author.name # => "alloy" - # - # post.title = "On the migration of ducks" - # post.author.name = "Eloy Duran" - # - # post.save - # post.reload - # post.title # => "On the migration of ducks" - # post.author.name # => "Eloy Duran" - # - # Destroying an associated model, as part of the parent's save action, is as - # simple as marking it for destruction: - # - # post.author.mark_for_destruction - # post.author.marked_for_destruction? # => true - # - # Note that the model is _not_ yet removed from the database: - # id = post.author.id - # Author.find_by_id(id).nil? # => false - # - # post.save - # post.reload.author # => nil - # - # Now it _is_ removed from the database: - # Author.find_by_id(id).nil? # => true - # - # === One-to-many Example - # - # Consider a Post model with many Comments: - # - # class Post - # has_many :comments, :autosave => true - # end - # - # Saving changes to the parent and its associated model can now be performed - # automatically _and_ atomically: - # - # post = Post.find(1) - # post.title # => "The current global position of migrating ducks" - # post.comments.first.body # => "Wow, awesome info thanks!" - # post.comments.last.body # => "Actually, your article should be named differently." - # - # post.title = "On the migration of ducks" - # post.comments.last.body = "Actually, your article should be named differently. [UPDATED]: You are right, thanks." - # - # post.save - # post.reload - # post.title # => "On the migration of ducks" - # post.comments.last.body # => "Actually, your article should be named differently. [UPDATED]: You are right, thanks." - # - # Destroying one of the associated models members, as part of the parent's - # save action, is as simple as marking it for destruction: - # - # post.comments.last.mark_for_destruction - # post.comments.last.marked_for_destruction? # => true - # post.comments.length # => 2 - # - # Note that the model is _not_ yet removed from the database: - # id = post.comments.last.id - # Comment.find_by_id(id).nil? # => false - # - # post.save - # post.reload.comments.length # => 1 - # - # Now it _is_ removed from the database: - # Comment.find_by_id(id).nil? # => true - # - # === Validation - # - # Validation is performed on the parent as usual, but also on all autosave - # enabled associations. If any of the associations fail validation, its - # error messages will be applied on the parents errors object and validation - # of the parent will fail. - # - # Consider a Post model with Author which validates the presence of its name - # attribute: - # - # class Post - # has_one :author, :autosave => true - # end - # - # class Author - # validates_presence_of :name - # end - # - # post = Post.find(1) - # post.author.name = '' - # post.save # => false - # post.errors # => #<ActiveRecord::Errors:0x174498c @errors={"author_name"=>["can't be blank"]}, @base=#<Post ...>> - # - # No validations will be performed on the associated models when validations - # are skipped for the parent: - # - # post = Post.find(1) - # post.author.name = '' - # post.save(false) # => true - module AutosaveAssociation - ASSOCIATION_TYPES = %w{ has_one belongs_to has_many has_and_belongs_to_many } - - def self.included(base) - base.class_eval do - base.extend(ClassMethods) - alias_method_chain :reload, :autosave_associations - - ASSOCIATION_TYPES.each do |type| - base.send("valid_keys_for_#{type}_association") << :autosave - end - end - end - - module ClassMethods - private - - # def belongs_to(name, options = {}) - # super - # add_autosave_association_callbacks(reflect_on_association(name)) - # end - ASSOCIATION_TYPES.each do |type| - module_eval <<-CODE, __FILE__, __LINE__ + 1 - def #{type}(name, options = {}) - super - add_autosave_association_callbacks(reflect_on_association(name)) - end - CODE - end - - # Adds a validate and save callback for the association as specified by - # the +reflection+. - # - # For performance reasons, we don't check whether to validate at runtime, - # but instead only define the method and callback when needed. However, - # this can change, for instance, when using nested attributes, which is - # called _after_ the association has been defined. Since we don't want - # the callbacks to get defined multiple times, there are guards that - # check if the save or validation methods have already been defined - # before actually defining them. - def add_autosave_association_callbacks(reflection) - save_method = :"autosave_associated_records_for_#{reflection.name}" - validation_method = :"validate_associated_records_for_#{reflection.name}" - collection = reflection.collection? - - unless method_defined?(save_method) - if collection - before_save :before_save_collection_association - - define_method(save_method) { save_collection_association(reflection) } - # Doesn't use after_save as that would save associations added in after_create/after_update twice - after_create save_method - after_update save_method - else - if reflection.macro == :has_one - define_method(save_method) { save_has_one_association(reflection) } - after_save save_method - else - define_method(save_method) { save_belongs_to_association(reflection) } - before_save save_method - end - end - end - - if reflection.validate? && !method_defined?(validation_method) - method = (collection ? :validate_collection_association : :validate_single_association) - define_method(validation_method) { send(method, reflection) } - validate validation_method - end - end - end - - # Reloads the attributes of the object as usual and removes a mark for destruction. - def reload_with_autosave_associations(options = nil) - @marked_for_destruction = false - reload_without_autosave_associations(options) - end - - # Marks this record to be destroyed as part of the parents save transaction. - # This does _not_ actually destroy the record yet, rather it will be destroyed when <tt>parent.save</tt> is called. - # - # Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model. - def mark_for_destruction - @marked_for_destruction = true - end - - # Returns whether or not this record will be destroyed as part of the parents save transaction. - # - # Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model. - def marked_for_destruction? - @marked_for_destruction - end - - # Returns whether or not this record has been changed in any way (including whether - # any of its nested autosave associations are likewise changed) - def changed_for_autosave? - new_record? || changed? || marked_for_destruction? || nested_records_changed_for_autosave? - end - - private - - # Returns the record for an association collection that should be validated - # or saved. If +autosave+ is +false+ only new records will be returned, - # unless the parent is/was a new record itself. - def associated_records_to_validate_or_save(association, new_record, autosave) - if new_record - association - elsif autosave - association.target.select { |record| record.changed_for_autosave? } - else - association.target.select { |record| record.new_record? } - end - end - - # go through nested autosave associations that are loaded in memory (without loading - # any new ones), and return true if is changed for autosave - def nested_records_changed_for_autosave? - self.class.reflect_on_all_autosave_associations.each do |reflection| - if association = association_instance_get(reflection.name) - if [:belongs_to, :has_one].include?(reflection.macro) - return true if association.target && association.target.changed_for_autosave? - else - association.target.each {|record| return true if record.changed_for_autosave? } - end - end - end - false - end - - # Validate the association if <tt>:validate</tt> or <tt>:autosave</tt> is - # turned on for the association specified by +reflection+. - def validate_single_association(reflection) - if (association = association_instance_get(reflection.name)) && !association.target.nil? - association_valid?(reflection, association) - end - end - - # Validate the associated records if <tt>:validate</tt> or - # <tt>:autosave</tt> is turned on for the association specified by - # +reflection+. - def validate_collection_association(reflection) - if association = association_instance_get(reflection.name) - if records = associated_records_to_validate_or_save(association, new_record?, reflection.options[:autosave]) - records.each { |record| association_valid?(reflection, record) } - end - end - end - - # Returns whether or not the association is valid and applies any errors to - # the parent, <tt>self</tt>, if it wasn't. Skips any <tt>:autosave</tt> - # enabled records if they're marked_for_destruction? or destroyed. - def association_valid?(reflection, association) - return true if association.destroyed? || association.marked_for_destruction? - - unless valid = association.valid? - if reflection.options[:autosave] - association.errors.each_error do |attribute, error| - attribute = "#{reflection.name}.#{attribute}" - errors.add(attribute, error.dup) unless errors.on(attribute) - end - else - errors.add(reflection.name) - end - end - valid - end - - # Is used as a before_save callback to check while saving a collection - # association whether or not the parent was a new record before saving. - def before_save_collection_association - @new_record_before_save = new_record? - true - end - - # Saves any new associated records, or all loaded autosave associations if - # <tt>:autosave</tt> is enabled on the association. - # - # In addition, it destroys all children that were marked for destruction - # with mark_for_destruction. - # - # This all happens inside a transaction, _if_ the Transactions module is included into - # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. - def save_collection_association(reflection) - if association = association_instance_get(reflection.name) - autosave = reflection.options[:autosave] - - if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave) - records.each do |record| - next if record.destroyed? - - if autosave && record.marked_for_destruction? - association.destroy(record) - elsif autosave != false && (@new_record_before_save || record.new_record?) - if autosave - saved = association.send(:insert_record, record, false, false) - else - association.send(:insert_record, record) - end - elsif autosave - saved = record.save(false) - end - - raise ActiveRecord::Rollback if saved == false - end - end - - # reconstruct the SQL queries now that we know the owner's id - association.send(:construct_sql) if association.respond_to?(:construct_sql) - end - end - - # Saves the associated record if it's new or <tt>:autosave</tt> is enabled - # on the association. - # - # In addition, it will destroy the association if it was marked for - # destruction with mark_for_destruction. - # - # This all happens inside a transaction, _if_ the Transactions module is included into - # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. - def save_has_one_association(reflection) - if (association = association_instance_get(reflection.name)) && !association.target.nil? && !association.destroyed? - autosave = reflection.options[:autosave] - - if autosave && association.marked_for_destruction? - association.destroy - else - key = reflection.options[:primary_key] ? send(reflection.options[:primary_key]) : id - if autosave != false && (new_record? || association.new_record? || association[reflection.primary_key_name] != key || autosave) - association[reflection.primary_key_name] = key - saved = association.save(!autosave) - raise ActiveRecord::Rollback if !saved && autosave - saved - end - end - end - end - - # Saves the associated record if it's new or <tt>:autosave</tt> is enabled - # on the association. - # - # In addition, it will destroy the association if it was marked for - # destruction with mark_for_destruction. - # - # This all happens inside a transaction, _if_ the Transactions module is included into - # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. - def save_belongs_to_association(reflection) - if (association = association_instance_get(reflection.name)) && !association.destroyed? - autosave = reflection.options[:autosave] - - if autosave && association.marked_for_destruction? - association.destroy - elsif autosave != false - saved = association.save(!autosave) if association.new_record? || autosave - - if association.updated? - association_id = association.send(reflection.options[:primary_key] || :id) - self[reflection.primary_key_name] = association_id - # TODO: Removing this code doesn't seem to matter… - if reflection.options[:polymorphic] - self[reflection.options[:foreign_type]] = association.class.base_class.name.to_s - end - end - - saved if autosave - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/base.rb b/vendor/rails/activerecord/lib/active_record/base.rb deleted file mode 100755 index 461007fd..00000000 --- a/vendor/rails/activerecord/lib/active_record/base.rb +++ /dev/null @@ -1,3218 +0,0 @@ -require 'yaml' -require 'set' -require 'active_support/core_ext/class/attribute' - -module ActiveRecord #:nodoc: - # Generic Active Record exception class. - class ActiveRecordError < StandardError - end - - # Raised when the single-table inheritance mechanism fails to locate the subclass - # (for example due to improper usage of column that +inheritance_column+ points to). - class SubclassNotFound < ActiveRecordError #:nodoc: - end - - # Raised when an object assigned to an association has an incorrect type. - # - # class Ticket < ActiveRecord::Base - # has_many :patches - # end - # - # class Patch < ActiveRecord::Base - # belongs_to :ticket - # end - # - # # Comments are not patches, this assignment raises AssociationTypeMismatch. - # @ticket.patches << Comment.new(:content => "Please attach tests to your patch.") - class AssociationTypeMismatch < ActiveRecordError - end - - # Raised when unserialized object's type mismatches one specified for serializable field. - class SerializationTypeMismatch < ActiveRecordError - end - - # Raised when adapter not specified on connection (or configuration file <tt>config/database.yml</tt> misses adapter field). - class AdapterNotSpecified < ActiveRecordError - end - - # Raised when Active Record cannot find database adapter specified in <tt>config/database.yml</tt> or programmatically. - class AdapterNotFound < ActiveRecordError - end - - # Raised when connection to the database could not been established (for example when <tt>connection=</tt> is given a nil object). - class ConnectionNotEstablished < ActiveRecordError - end - - # Raised when Active Record cannot find record by given id or set of ids. - class RecordNotFound < ActiveRecordError - end - - # Raised by ActiveRecord::Base.save! and ActiveRecord::Base.create! methods when record cannot be - # saved because record is invalid. - class RecordNotSaved < ActiveRecordError - end - - # Raised when SQL statement cannot be executed by the database (for example, it's often the case for MySQL when Ruby driver used is too old). - class StatementInvalid < ActiveRecordError - end - - # Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example, when using +find+ method) - # does not match number of expected variables. - # - # For example, in - # - # Location.find :all, :conditions => ["lat = ? AND lng = ?", 53.7362] - # - # two placeholders are given but only one variable to fill them. - class PreparedStatementInvalid < ActiveRecordError - end - - # Raised on attempt to save stale record. Record is stale when it's being saved in another query after - # instantiation, for example, when two users edit the same wiki page and one starts editing and saves - # the page before the other. - # - # Read more about optimistic locking in ActiveRecord::Locking module RDoc. - class StaleObjectError < ActiveRecordError - end - - # Raised when association is being configured improperly or - # user tries to use offset and limit together with has_many or has_and_belongs_to_many associations. - class ConfigurationError < ActiveRecordError - end - - # Raised on attempt to update record that is instantiated as read only. - class ReadOnlyRecord < ActiveRecordError - end - - # ActiveRecord::Transactions::ClassMethods.transaction uses this exception - # to distinguish a deliberate rollback from other exceptional situations. - # Normally, raising an exception will cause the +transaction+ method to rollback - # the database transaction *and* pass on the exception. But if you raise an - # ActiveRecord::Rollback exception, then the database transaction will be rolled back, - # without passing on the exception. - # - # For example, you could do this in your controller to rollback a transaction: - # - # class BooksController < ActionController::Base - # def create - # Book.transaction do - # book = Book.new(params[:book]) - # book.save! - # if today_is_friday? - # # The system must fail on Friday so that our support department - # # won't be out of job. We silently rollback this transaction - # # without telling the user. - # raise ActiveRecord::Rollback, "Call tech support!" - # end - # end - # # ActiveRecord::Rollback is the only exception that won't be passed on - # # by ActiveRecord::Base.transaction, so this line will still be reached - # # even on Friday. - # redirect_to root_url - # end - # end - class Rollback < ActiveRecordError - end - - # Raised when attribute has a name reserved by Active Record (when attribute has name of one of Active Record instance methods). - class DangerousAttributeError < ActiveRecordError - end - - # Raised when you've tried to access a column which wasn't loaded by your finder. - # Typically this is because <tt>:select</tt> has been specified. - class MissingAttributeError < NoMethodError - end - - # Raised when unknown attributes are supplied via mass assignment. - class UnknownAttributeError < NoMethodError - end - - # Raised when an error occurred while doing a mass assignment to an attribute through the - # <tt>attributes=</tt> method. The exception has an +attribute+ property that is the name of the - # offending attribute. - class AttributeAssignmentError < ActiveRecordError - attr_reader :exception, :attribute - def initialize(message, exception, attribute) - @exception = exception - @attribute = attribute - @message = message - end - end - - # Raised when there are multiple errors while doing a mass assignment through the +attributes+ - # method. The exception has an +errors+ property that contains an array of AttributeAssignmentError - # objects, each corresponding to the error while assigning to an attribute. - class MultiparameterAssignmentErrors < ActiveRecordError - attr_reader :errors - def initialize(errors) - @errors = errors - end - end - - # Active Record objects don't specify their attributes directly, but rather infer them from the table definition with - # which they're linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change - # is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain - # database table will happen automatically in most common cases, but can be overwritten for the uncommon ones. - # - # See the mapping rules in table_name and the full example in link:files/README.html for more insight. - # - # == Creation - # - # Active Records accept constructor parameters either in a hash or as a block. The hash method is especially useful when - # you're receiving the data from somewhere else, like an HTTP request. It works like this: - # - # user = User.new(:name => "David", :occupation => "Code Artist") - # user.name # => "David" - # - # You can also use block initialization: - # - # user = User.new do |u| - # u.name = "David" - # u.occupation = "Code Artist" - # end - # - # And of course you can just create a bare object and specify the attributes after the fact: - # - # user = User.new - # user.name = "David" - # user.occupation = "Code Artist" - # - # == Conditions - # - # Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement. - # The array form is to be used when the condition input is tainted and requires sanitization. The string form can - # be used for statements that don't involve tainted data. The hash form works much like the array form, except - # only equality and range is possible. Examples: - # - # class User < ActiveRecord::Base - # def self.authenticate_unsafely(user_name, password) - # find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'") - # end - # - # def self.authenticate_safely(user_name, password) - # find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ]) - # end - # - # def self.authenticate_safely_simply(user_name, password) - # find(:first, :conditions => { :user_name => user_name, :password => password }) - # end - # end - # - # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query and is thus susceptible to SQL-injection - # attacks if the <tt>user_name</tt> and +password+ parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and - # <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+ before inserting them in the query, - # which will ensure that an attacker can't escape the query and fake the login (or worse). - # - # When using multiple parameters in the conditions, it can easily become hard to read exactly what the fourth or fifth - # question mark is supposed to represent. In those cases, you can resort to named bind variables instead. That's done by replacing - # the question marks with symbols and supplying a hash with values for the matching symbol keys: - # - # Company.find(:first, :conditions => [ - # "id = :id AND name = :name AND division = :division AND created_at > :accounting_date", - # { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' } - # ]) - # - # Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND - # operator. For instance: - # - # Student.find(:all, :conditions => { :first_name => "Harvey", :status => 1 }) - # Student.find(:all, :conditions => params[:student]) - # - # A range may be used in the hash to use the SQL BETWEEN operator: - # - # Student.find(:all, :conditions => { :grade => 9..12 }) - # - # An array may be used in the hash to use the SQL IN operator: - # - # Student.find(:all, :conditions => { :grade => [9,11,12] }) - # - # == Overwriting default accessors - # - # All column values are automatically available through basic accessors on the Active Record object, but sometimes you - # want to specialize this behavior. This can be done by overwriting the default accessors (using the same - # name as the attribute) and calling <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually change things. - # Example: - # - # class Song < ActiveRecord::Base - # # Uses an integer of seconds to hold the length of the song - # - # def length=(minutes) - # write_attribute(:length, minutes.to_i * 60) - # end - # - # def length - # read_attribute(:length) / 60 - # end - # end - # - # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt> instead of <tt>write_attribute(:attribute, value)</tt> and - # <tt>read_attribute(:attribute)</tt> as a shorter form. - # - # == Attribute query methods - # - # In addition to the basic accessors, query methods are also automatically available on the Active Record object. - # Query methods allow you to test whether an attribute value is present. - # - # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call - # to determine whether the user has a name: - # - # user = User.new(:name => "David") - # user.name? # => true - # - # anonymous = User.new(:name => "") - # anonymous.name? # => false - # - # == Accessing attributes before they have been typecasted - # - # Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first. - # That can be done by using the <tt><attribute>_before_type_cast</tt> accessors that all attributes have. For example, if your Account model - # has a <tt>balance</tt> attribute, you can call <tt>account.balance_before_type_cast</tt> or <tt>account.id_before_type_cast</tt>. - # - # This is especially useful in validation situations where the user might supply a string for an integer field and you want to display - # the original string back in an error message. Accessing the attribute normally would typecast the string to 0, which isn't what you - # want. - # - # == Dynamic attribute-based finders - # - # Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects by simple queries without turning to SQL. They work by - # appending the name of an attribute to <tt>find_by_</tt>, <tt>find_last_by_</tt>, or <tt>find_all_by_</tt>, so you get finders like <tt>Person.find_by_user_name</tt>, - # <tt>Person.find_all_by_last_name</tt>, and <tt>Payment.find_by_transaction_id</tt>. So instead of writing - # <tt>Person.find(:first, :conditions => ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>. - # And instead of writing <tt>Person.find(:all, :conditions => ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>. - # - # It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like - # <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing - # <tt>Person.find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt>, you just do - # <tt>Person.find_by_user_name_and_password(user_name, password)</tt>. - # - # It's even possible to use all the additional parameters to find. For example, the full interface for <tt>Payment.find_all_by_amount</tt> - # is actually <tt>Payment.find_all_by_amount(amount, options)</tt>. And the full interface to <tt>Person.find_by_user_name</tt> is - # actually <tt>Person.find_by_user_name(user_name, options)</tt>. So you could call <tt>Payment.find_all_by_amount(50, :order => "created_on")</tt>. - # Also you may call <tt>Payment.find_last_by_amount(amount, options)</tt> returning the last record matching that amount and options. - # - # The same dynamic finder style can be used to create the object if it doesn't already exist. This dynamic finder is called with - # <tt>find_or_create_by_</tt> and will return the object if it already exists and otherwise creates it, then returns it. Protected attributes won't be set unless they are given in a block. For example: - # - # # No 'Summer' tag exists - # Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") - # - # # Now the 'Summer' tag does exist - # Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer") - # - # # Now 'Bob' exist and is an 'admin' - # User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true } - # - # Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without saving it first. Protected attributes won't be set unless they are given in a block. For example: - # - # # No 'Winter' tag exists - # winter = Tag.find_or_initialize_by_name("Winter") - # winter.new_record? # true - # - # To find by a subset of the attributes to be used for instantiating a new object, pass a hash instead of - # a list of parameters. For example: - # - # Tag.find_or_create_by_name(:name => "rails", :creator => current_user) - # - # That will either find an existing tag named "rails", or create a new one while setting the user that created it. - # - # == Saving arrays, hashes, and other non-mappable objects in text columns - # - # Active Record can serialize any object in text columns using YAML. To do so, you must specify this with a call to the class method +serialize+. - # This makes it possible to store arrays, hashes, and other non-mappable objects without doing any additional work. Example: - # - # class User < ActiveRecord::Base - # serialize :preferences - # end - # - # user = User.create(:preferences => { "background" => "black", "display" => large }) - # User.find(user.id).preferences # => { "background" => "black", "display" => large } - # - # You can also specify a class option as the second parameter that'll raise an exception if a serialized object is retrieved as a - # descendant of a class not in the hierarchy. Example: - # - # class User < ActiveRecord::Base - # serialize :preferences, Hash - # end - # - # user = User.create(:preferences => %w( one two three )) - # User.find(user.id).preferences # raises SerializationTypeMismatch - # - # == Single table inheritance - # - # Active Record allows inheritance by storing the name of the class in a column that by default is named "type" (can be changed - # by overwriting <tt>Base.inheritance_column</tt>). This means that an inheritance looking like this: - # - # class Company < ActiveRecord::Base; end - # class Firm < Company; end - # class Client < Company; end - # class PriorityClient < Client; end - # - # When you do <tt>Firm.create(:name => "37signals")</tt>, this record will be saved in the companies table with type = "Firm". You can then - # fetch this row again using <tt>Company.find(:first, "name = '37signals'")</tt> and it will return a Firm object. - # - # If you don't have a type column defined in your table, single-table inheritance won't be triggered. In that case, it'll work just - # like normal subclasses with no special magic for differentiating between them or reloading the right type with find. - # - # Note, all the attributes for all the cases are kept in the same table. Read more: - # http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html - # - # == Connection to multiple databases in different models - # - # Connections are usually created through ActiveRecord::Base.establish_connection and retrieved by ActiveRecord::Base.connection. - # All classes inheriting from ActiveRecord::Base will use this connection. But you can also set a class-specific connection. - # For example, if Course is an ActiveRecord::Base, but resides in a different database, you can just say <tt>Course.establish_connection</tt> - # and Course and all of its subclasses will use this connection instead. - # - # This feature is implemented by keeping a connection pool in ActiveRecord::Base that is a Hash indexed by the class. If a connection is - # requested, the retrieve_connection method will go up the class-hierarchy until a connection is found in the connection pool. - # - # == Exceptions - # - # * ActiveRecordError - Generic error class and superclass of all other errors raised by Active Record. - # * AdapterNotSpecified - The configuration hash used in <tt>establish_connection</tt> didn't include an - # <tt>:adapter</tt> key. - # * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a non-existent adapter - # (or a bad spelling of an existing one). - # * AssociationTypeMismatch - The object assigned to the association wasn't of the type specified in the association definition. - # * SerializationTypeMismatch - The serialized object wasn't of the class specified as the second parameter. - # * ConnectionNotEstablished+ - No connection has been established. Use <tt>establish_connection</tt> before querying. - # * RecordNotFound - No record responded to the +find+ method. Either the row with the given ID doesn't exist - # or the row didn't meet the additional restrictions. Some +find+ calls do not raise this exception to signal - # nothing was found, please check its documentation for further details. - # * StatementInvalid - The database server rejected the SQL statement. The precise error is added in the message. - # * MultiparameterAssignmentErrors - Collection of errors that occurred during a mass assignment using the - # <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of AttributeAssignmentError - # objects that should be inspected to determine which attributes triggered the errors. - # * AttributeAssignmentError - An error occurred while doing a mass assignment through the <tt>attributes=</tt> method. - # You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error. - # - # *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level). - # So it's possible to assign a logger to the class through <tt>Base.logger=</tt> which will then be used by all - # instances in the current object space. - class Base - ## - # :singleton-method: - # Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed - # on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+. - cattr_accessor :logger, :instance_writer => false - - def self.inherited(child) #:nodoc: - @@subclasses[self] ||= [] - @@subclasses[self] << child - super - end - - def self.reset_subclasses #:nodoc: - nonreloadables = [] - subclasses.each do |klass| - unless ActiveSupport::Dependencies.autoloaded? klass - nonreloadables << klass - next - end - klass.instance_variables.each { |var| klass.send(:remove_instance_variable, var) } - klass.instance_methods(false).each { |m| klass.send :undef_method, m } - end - @@subclasses = {} - nonreloadables.each { |klass| (@@subclasses[klass.superclass] ||= []) << klass } - end - - @@subclasses = {} - - ## - # :singleton-method: - # Contains the database configuration - as is typically stored in config/database.yml - - # as a Hash. - # - # For example, the following database.yml... - # - # development: - # adapter: sqlite3 - # database: db/development.sqlite3 - # - # production: - # adapter: sqlite3 - # database: db/production.sqlite3 - # - # ...would result in ActiveRecord::Base.configurations to look like this: - # - # { - # 'development' => { - # 'adapter' => 'sqlite3', - # 'database' => 'db/development.sqlite3' - # }, - # 'production' => { - # 'adapter' => 'sqlite3', - # 'database' => 'db/production.sqlite3' - # } - # } - cattr_accessor :configurations, :instance_writer => false - @@configurations = {} - - ## - # :singleton-method: - # Accessor for the prefix type that will be prepended to every primary key column name. The options are :table_name and - # :table_name_with_underscore. If the first is specified, the Product class will look for "productid" instead of "id" as - # the primary column. If the latter is specified, the Product class will look for "product_id" instead of "id". Remember - # that this is a global setting for all Active Records. - cattr_accessor :primary_key_prefix_type, :instance_writer => false - @@primary_key_prefix_type = nil - - ## - # :singleton-method: - # Accessor for the name of the prefix string to prepend to every table name. So if set to "basecamp_", all - # table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace - # for tables in a shared database. By default, the prefix is the empty string. - # - # If you are organising your models within modules you can add a prefix to the models within a namespace by defining - # a singleton method in the parent module called table_name_prefix which returns your chosen prefix. - cattr_accessor :table_name_prefix, :instance_writer => false - @@table_name_prefix = "" - - ## - # :singleton-method: - # Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp", - # "people_basecamp"). By default, the suffix is the empty string. - cattr_accessor :table_name_suffix, :instance_writer => false - @@table_name_suffix = "" - - ## - # :singleton-method: - # Indicates whether table names should be the pluralized versions of the corresponding class names. - # If true, the default table name for a Product class will be +products+. If false, it would just be +product+. - # See table_name for the full rules on table/class naming. This is true, by default. - cattr_accessor :pluralize_table_names, :instance_writer => false - @@pluralize_table_names = true - - ## - # :singleton-method: - # Determines whether to use ANSI codes to colorize the logging statements committed by the connection adapter. These colors - # make it much easier to overview things during debugging (when used through a reader like +tail+ and on a black background), but - # may complicate matters if you use software like syslog. This is true, by default. - cattr_accessor :colorize_logging, :instance_writer => false - @@colorize_logging = true - - ## - # :singleton-method: - # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database. - # This is set to :local by default. - cattr_accessor :default_timezone, :instance_writer => false - @@default_timezone = :local - - ## - # :singleton-method: - # Specifies the format to use when dumping the database schema with Rails' - # Rakefile. If :sql, the schema is dumped as (potentially database- - # specific) SQL statements. If :ruby, the schema is dumped as an - # ActiveRecord::Schema file which can be loaded into any database that - # supports migrations. Use :ruby if you want to have different database - # adapters for, e.g., your development and test environments. - cattr_accessor :schema_format , :instance_writer => false - @@schema_format = :ruby - - ## - # :singleton-method: - # Specify whether or not to use timestamps for migration numbers - cattr_accessor :timestamped_migrations , :instance_writer => false - @@timestamped_migrations = true - - # Determine whether to store the full constant name including namespace when using STI - class_attribute :store_full_sti_class - self.store_full_sti_class = false - - # Stores the default scope for the class - class_inheritable_accessor :default_scoping, :instance_writer => false - self.default_scoping = [] - - class << self # Class methods - # Find operates with four different retrieval approaches: - # - # * Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). - # If no record can be found for all of the listed ids, then RecordNotFound will be raised. - # * Find first - This will return the first record matched by the options used. These options can either be specific - # conditions or merely an order. If no record can be matched, +nil+ is returned. Use - # <tt>Model.find(:first, *args)</tt> or its shortcut <tt>Model.first(*args)</tt>. - # * Find last - This will return the last record matched by the options used. These options can either be specific - # conditions or merely an order. If no record can be matched, +nil+ is returned. Use - # <tt>Model.find(:last, *args)</tt> or its shortcut <tt>Model.last(*args)</tt>. - # * Find all - This will return all the records matched by the options used. - # If no records are found, an empty array is returned. Use - # <tt>Model.find(:all, *args)</tt> or its shortcut <tt>Model.all(*args)</tt>. - # - # All approaches accept an options hash as their last parameter. - # - # ==== Parameters - # - # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1", <tt>[ "user_name = ?", username ]</tt>, or <tt>["user_name = :user_name", { :user_name => user_name }]</tt>. See conditions in the intro. - # * <tt>:order</tt> - An SQL fragment like "created_at DESC, name". - # * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause. - # * <tt>:having</tt> - Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause. - # * <tt>:limit</tt> - An integer determining the limit on the number of rows that should be returned. - # * <tt>:offset</tt> - An integer determining the offset from where the rows should be fetched. So at 5, it would skip rows 0 through 4. - # * <tt>:joins</tt> - Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed), - # named associations in the same form used for the <tt>:include</tt> option, which will perform an <tt>INNER JOIN</tt> on the associated table(s), - # or an array containing a mixture of both strings and named associations. - # If the value is a string, then the records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # Pass <tt>:readonly => false</tt> to override. - # * <tt>:include</tt> - Names associations that should be loaded alongside. The symbols named refer - # to already defined associations. See eager loading under Associations. - # * <tt>:select</tt> - By default, this is "*" as in "SELECT * FROM", but can be changed if you, for example, want to do a join but not - # include the joined columns. Takes a string with the SELECT SQL fragment (e.g. "id, name"). - # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an alternate table name (or even the name - # of a database view). - # * <tt>:readonly</tt> - Mark the returned records read-only so they cannot be saved or updated. - # * <tt>:lock</tt> - An SQL fragment like "FOR UPDATE" or "LOCK IN SHARE MODE". - # <tt>:lock => true</tt> gives connection's default exclusive lock, usually "FOR UPDATE". - # - # ==== Examples - # - # # find by id - # Person.find(1) # returns the object for ID = 1 - # Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6) - # Person.find([7, 17]) # returns an array for objects with IDs in (7, 17) - # Person.find([1]) # returns an array for the object with ID = 1 - # Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC") - # - # Note that returned records may not be in the same order as the ids you - # provide since database rows are unordered. Give an explicit <tt>:order</tt> - # to ensure the results are sorted. - # - # ==== Examples - # - # # find first - # Person.find(:first) # returns the first object fetched by SELECT * FROM people - # Person.find(:first, :conditions => [ "user_name = ?", user_name]) - # Person.find(:first, :conditions => [ "user_name = :u", { :u => user_name }]) - # Person.find(:first, :order => "created_on DESC", :offset => 5) - # - # # find last - # Person.find(:last) # returns the last object fetched by SELECT * FROM people - # Person.find(:last, :conditions => [ "user_name = ?", user_name]) - # Person.find(:last, :order => "created_on DESC", :offset => 5) - # - # # find all - # Person.find(:all) # returns an array of objects for all the rows fetched by SELECT * FROM people - # Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50) - # Person.find(:all, :conditions => { :friends => ["Bob", "Steve", "Fred"] } - # Person.find(:all, :offset => 10, :limit => 10) - # Person.find(:all, :include => [ :account, :friends ]) - # Person.find(:all, :group => "category") - # - # Example for find with a lock: Imagine two concurrent transactions: - # each will read <tt>person.visits == 2</tt>, add 1 to it, and save, resulting - # in two saves of <tt>person.visits = 3</tt>. By locking the row, the second - # transaction has to wait until the first is finished; we get the - # expected <tt>person.visits == 4</tt>. - # - # Person.transaction do - # person = Person.find(1, :lock => true) - # person.visits += 1 - # person.save! - # end - def find(*args) - options = args.extract_options! - validate_find_options(options) - set_readonly_option!(options) - - case args.first - when :first then find_initial(options) - when :last then find_last(options) - when :all then find_every(options) - else find_from_ids(args, options) - end - end - - # A convenience wrapper for <tt>find(:first, *args)</tt>. You can pass in all the - # same arguments to this method as you can to <tt>find(:first)</tt>. - def first(*args) - find(:first, *args) - end - - # A convenience wrapper for <tt>find(:last, *args)</tt>. You can pass in all the - # same arguments to this method as you can to <tt>find(:last)</tt>. - def last(*args) - find(:last, *args) - end - - # This is an alias for find(:all). You can pass in all the same arguments to this method as you can - # to find(:all) - def all(*args) - find(:all, *args) - end - - # Executes a custom SQL query against your database and returns all the results. The results will - # be returned as an array with columns requested encapsulated as attributes of the model you call - # this method from. If you call <tt>Product.find_by_sql</tt> then the results will be returned in - # a Product object with the attributes you specified in the SQL query. - # - # If you call a complicated SQL query which spans multiple tables the columns specified by the - # SELECT will be attributes of the model, whether or not they are columns of the corresponding - # table. - # - # The +sql+ parameter is a full SQL query as a string. It will be called as is, there will be - # no database agnostic conversions performed. This should be a last resort because using, for example, - # MySQL specific terms will lock you to using that particular database engine or require you to - # change your call if you switch engines. - # - # ==== Examples - # # A simple SQL query spanning multiple tables - # Post.find_by_sql "SELECT p.title, c.author FROM posts p, comments c WHERE p.id = c.post_id" - # > [#<Post:0x36bff9c @attributes={"title"=>"Ruby Meetup", "first_name"=>"Quentin"}>, ...] - # - # # You can use the same string replacement techniques as you can with ActiveRecord#find - # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date] - # > [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...] - def find_by_sql(sql) - connection.select_all(sanitize_sql(sql), "#{name} Load").collect! { |record| instantiate(record) } - end - - # Returns true if a record exists in the table that matches the +id+ or - # conditions given, or false otherwise. The argument can take five forms: - # - # * Integer - Finds the record with this primary key. - # * String - Finds the record with a primary key corresponding to this - # string (such as <tt>'5'</tt>). - # * Array - Finds the record that matches these +find+-style conditions - # (such as <tt>['color = ?', 'red']</tt>). - # * Hash - Finds the record that matches these +find+-style conditions - # (such as <tt>{:color => 'red'}</tt>). - # * No args - Returns false if the table is empty, true otherwise. - # - # For more information about specifying conditions as a Hash or Array, - # see the Conditions section in the introduction to ActiveRecord::Base. - # - # Note: You can't pass in a condition as a string (like <tt>name = - # 'Jamie'</tt>), since it would be sanitized and then queried against - # the primary key column, like <tt>id = 'name = \'Jamie\''</tt>. - # - # ==== Examples - # Person.exists?(5) - # Person.exists?('5') - # Person.exists?(:name => "David") - # Person.exists?(['name LIKE ?', "%#{query}%"]) - # Person.exists? - def exists?(id_or_conditions = {}) - find_initial( - :select => "#{quoted_table_name}.#{primary_key}", - :conditions => expand_id_conditions(id_or_conditions)) ? true : false - end - - # Creates an object (or multiple objects) and saves it to the database, if validations pass. - # The resulting object is returned whether the object was saved successfully to the database or not. - # - # The +attributes+ parameter can be either be a Hash or an Array of Hashes. These Hashes describe the - # attributes on the objects that are to be created. - # - # ==== Examples - # # Create a single new object - # User.create(:first_name => 'Jamie') - # - # # Create an Array of new objects - # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) - # - # # Create a single object and pass it into a block to set other attributes. - # User.create(:first_name => 'Jamie') do |u| - # u.is_admin = false - # end - # - # # Creating an Array of new objects using a block, where the block is executed for each object: - # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u| - # u.is_admin = false - # end - def create(attributes = nil, &block) - if attributes.is_a?(Array) - attributes.collect { |attr| create(attr, &block) } - else - object = new(attributes) - yield(object) if block_given? - object.save - object - end - end - - # Updates an object (or multiple objects) and saves it to the database, if validations pass. - # The resulting object is returned whether the object was saved successfully to the database or not. - # - # ==== Parameters - # - # * +id+ - This should be the id or an array of ids to be updated. - # * +attributes+ - This should be a hash of attributes to be set on the object, or an array of hashes. - # - # ==== Examples - # - # # Updating one record: - # Person.update(15, :user_name => 'Samuel', :group => 'expert') - # - # # Updating multiple records: - # people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } } - # Person.update(people.keys, people.values) - def update(id, attributes) - if id.is_a?(Array) - idx = -1 - id.collect { |one_id| idx += 1; update(one_id, attributes[idx]) } - else - object = find(id) - object.update_attributes(attributes) - object - end - end - - # Deletes the row with a primary key matching the +id+ argument, using a - # SQL +DELETE+ statement, and returns the number of rows deleted. Active - # Record objects are not instantiated, so the object's callbacks are not - # executed, including any <tt>:dependent</tt> association options or - # Observer methods. - # - # You can delete multiple rows at once by passing an Array of <tt>id</tt>s. - # - # Note: Although it is often much faster than the alternative, - # <tt>#destroy</tt>, skipping callbacks might bypass business logic in - # your application that ensures referential integrity or performs other - # essential jobs. - # - # ==== Examples - # - # # Delete a single row - # Todo.delete(1) - # - # # Delete multiple rows - # Todo.delete([2,3,4]) - def delete(id) - delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ]) - end - - # Destroy an object (or multiple objects) that has the given id, the object is instantiated first, - # therefore all callbacks and filters are fired off before the object is deleted. This method is - # less efficient than ActiveRecord#delete but allows cleanup methods and other actions to be run. - # - # This essentially finds the object (or multiple objects) with the given id, creates a new object - # from the attributes, and then calls destroy on it. - # - # ==== Parameters - # - # * +id+ - Can be either an Integer or an Array of Integers. - # - # ==== Examples - # - # # Destroy a single object - # Todo.destroy(1) - # - # # Destroy multiple objects - # todos = [1,2,3] - # Todo.destroy(todos) - def destroy(id) - if id.is_a?(Array) - id.map { |one_id| destroy(one_id) } - else - find(id).destroy - end - end - - # Updates all records with details given if they match a set of conditions supplied, limits and order can - # also be supplied. This method constructs a single SQL UPDATE statement and sends it straight to the - # database. It does not instantiate the involved models and it does not trigger Active Record callbacks. - # - # ==== Parameters - # - # * +updates+ - A string of column and value pairs that will be set on any records that match conditions. This creates the SET clause of the generated SQL. - # * +conditions+ - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro for more info. - # * +options+ - Additional options are <tt>:limit</tt> and <tt>:order</tt>, see the examples for usage. - # - # ==== Examples - # - # # Update all billing objects with the 3 different attributes given - # Billing.update_all( "category = 'authorized', approved = 1, author = 'David'" ) - # - # # Update records that match our conditions - # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'" ) - # - # # Update records that match our conditions but limit it to 5 ordered by date - # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'", - # :order => 'created_at', :limit => 5 ) - def update_all(updates, conditions = nil, options = {}) - sql = "UPDATE #{quoted_table_name} SET #{sanitize_sql_for_assignment(updates)} " - - scope = scope(:find) - - select_sql = "" - add_conditions!(select_sql, conditions, scope) - - if options.has_key?(:limit) || (scope && scope[:limit]) - # Only take order from scope if limit is also provided by scope, this - # is useful for updating a has_many association with a limit. - add_order!(select_sql, options[:order], scope) - - add_limit!(select_sql, options, scope) - sql.concat(connection.limited_update_conditions(select_sql, quoted_table_name, connection.quote_column_name(primary_key))) - else - add_order!(select_sql, options[:order], nil) - sql.concat(select_sql) - end - - connection.update(sql, "#{name} Update") - end - - # Destroys the records matching +conditions+ by instantiating each - # record and calling its +destroy+ method. Each object's callbacks are - # executed (including <tt>:dependent</tt> association options and - # +before_destroy+/+after_destroy+ Observer methods). Returns the - # collection of objects that were destroyed; each will be frozen, to - # reflect that no changes should be made (since they can't be - # persisted). - # - # Note: Instantiation, callback execution, and deletion of each - # record can be time consuming when you're removing many records at - # once. It generates at least one SQL +DELETE+ query per record (or - # possibly more, to enforce your callbacks). If you want to delete many - # rows quickly, without concern for their associations or callbacks, use - # +delete_all+ instead. - # - # ==== Parameters - # - # * +conditions+ - A string, array, or hash that specifies which records - # to destroy. If omitted, all records are destroyed. See the - # Conditions section in the introduction to ActiveRecord::Base for - # more information. - # - # ==== Examples - # - # Person.destroy_all("last_login < '2004-04-04'") - # Person.destroy_all(:status => "inactive") - def destroy_all(conditions = nil) - find(:all, :conditions => conditions).each { |object| object.destroy } - end - - # Deletes the records matching +conditions+ without instantiating the records first, and hence not - # calling the +destroy+ method nor invoking callbacks. This is a single SQL DELETE statement that - # goes straight to the database, much more efficient than +destroy_all+. Be careful with relations - # though, in particular <tt>:dependent</tt> rules defined on associations are not honored. Returns - # the number of rows affected. - # - # ==== Parameters - # - # * +conditions+ - Conditions are specified the same way as with +find+ method. - # - # ==== Example - # - # Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')") - # Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else']) - # - # Both calls delete the affected posts all at once with a single DELETE statement. If you need to destroy dependent - # associations or call your <tt>before_*</tt> or +after_destroy+ callbacks, use the +destroy_all+ method instead. - def delete_all(conditions = nil) - sql = "DELETE FROM #{quoted_table_name} " - add_conditions!(sql, conditions, scope(:find)) - connection.delete(sql, "#{name} Delete all") - end - - # Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part. - # The use of this method should be restricted to complicated SQL queries that can't be executed - # using the ActiveRecord::Calculations class methods. Look into those before using this. - # - # ==== Parameters - # - # * +sql+ - An SQL statement which should return a count query from the database, see the example below. - # - # ==== Examples - # - # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id" - def count_by_sql(sql) - sql = sanitize_conditions(sql) - connection.select_value(sql, "#{name} Count").to_i - end - - # Resets one or more counter caches to their correct value using an SQL - # count query. This is useful when adding new counter caches, or if the - # counter has been corrupted or modified directly by SQL. - # - # ==== Parameters - # - # * +id+ - The id of the object you wish to reset a counter on. - # * +counters+ - One or more counter names to reset - # - # ==== Examples - # - # # For Post with id #1 records reset the comments_count - # Post.reset_counters(1, :comments) - def reset_counters(id, *counters) - object = find(id) - counters.each do |association| - child_class = reflect_on_association(association.to_sym).klass - belongs_name = self.name.demodulize.underscore.to_sym - counter_name = child_class.reflect_on_association(belongs_name).counter_cache_column - value = object.send(association).count - - connection.update(<<-CMD, "#{name} UPDATE") - UPDATE #{quoted_table_name} - SET #{connection.quote_column_name(counter_name)} = #{value} - WHERE #{connection.quote_column_name(primary_key)} = #{quote_value(object.id)} - CMD - end - return true - end - - # A generic "counter updater" implementation, intended primarily to be - # used by increment_counter and decrement_counter, but which may also - # be useful on its own. It simply does a direct SQL update for the record - # with the given ID, altering the given hash of counters by the amount - # given by the corresponding value: - # - # ==== Parameters - # - # * +id+ - The id of the object you wish to update a counter on or an Array of ids. - # * +counters+ - An Array of Hashes containing the names of the fields - # to update as keys and the amount to update the field by as values. - # - # ==== Examples - # - # # For the Post with id of 5, decrement the comment_count by 1, and - # # increment the action_count by 1 - # Post.update_counters 5, :comment_count => -1, :action_count => 1 - # # Executes the following SQL: - # # UPDATE posts - # # SET comment_count = comment_count - 1, - # # action_count = action_count + 1 - # # WHERE id = 5 - # - # # For the Posts with id of 10 and 15, increment the comment_count by 1 - # Post.update_counters [10, 15], :comment_count => 1 - # # Executes the following SQL: - # # UPDATE posts - # # SET comment_count = comment_count + 1, - # # WHERE id IN (10, 15) - def update_counters(id, counters) - updates = counters.map do |counter_name, value| - operator = value < 0 ? '-' : '+' - quoted_column = connection.quote_column_name(counter_name) - "#{quoted_column} = COALESCE(#{quoted_column}, 0) #{operator} #{value.abs}" - end - - update_all(updates.join(', '), primary_key => id ) - end - - # Increment a number field by one, usually representing a count. - # - # This is used for caching aggregate values, so that they don't need to be computed every time. - # For example, a DiscussionBoard may cache post_count and comment_count otherwise every time the board is - # shown it would have to run an SQL query to find how many posts and comments there are. - # - # ==== Parameters - # - # * +counter_name+ - The name of the field that should be incremented. - # * +id+ - The id of the object that should be incremented. - # - # ==== Examples - # - # # Increment the post_count column for the record with an id of 5 - # DiscussionBoard.increment_counter(:post_count, 5) - def increment_counter(counter_name, id) - update_counters(id, counter_name => 1) - end - - # Decrement a number field by one, usually representing a count. - # - # This works the same as increment_counter but reduces the column value by 1 instead of increasing it. - # - # ==== Parameters - # - # * +counter_name+ - The name of the field that should be decremented. - # * +id+ - The id of the object that should be decremented. - # - # ==== Examples - # - # # Decrement the post_count column for the record with an id of 5 - # DiscussionBoard.decrement_counter(:post_count, 5) - def decrement_counter(counter_name, id) - update_counters(id, counter_name => -1) - end - - # Attributes named in this macro are protected from mass-assignment, - # such as <tt>new(attributes)</tt>, - # <tt>update_attributes(attributes)</tt>, or - # <tt>attributes=(attributes)</tt>. - # - # Mass-assignment to these attributes will simply be ignored, to assign - # to them you can use direct writer methods. This is meant to protect - # sensitive attributes from being overwritten by malicious users - # tampering with URLs or forms. - # - # class Customer < ActiveRecord::Base - # attr_protected :credit_rating - # end - # - # customer = Customer.new("name" => David, "credit_rating" => "Excellent") - # customer.credit_rating # => nil - # customer.attributes = { "description" => "Jolly fellow", "credit_rating" => "Superb" } - # customer.credit_rating # => nil - # - # customer.credit_rating = "Average" - # customer.credit_rating # => "Average" - # - # To start from an all-closed default and enable attributes as needed, - # have a look at +attr_accessible+. - def attr_protected(*attributes) - write_inheritable_attribute(:attr_protected, Set.new(attributes.map(&:to_s)) + (protected_attributes || [])) - end - - # Returns an array of all the attributes that have been protected from mass-assignment. - def protected_attributes # :nodoc: - read_inheritable_attribute(:attr_protected) - end - - # Specifies a white list of model attributes that can be set via - # mass-assignment, such as <tt>new(attributes)</tt>, - # <tt>update_attributes(attributes)</tt>, or - # <tt>attributes=(attributes)</tt> - # - # This is the opposite of the +attr_protected+ macro: Mass-assignment - # will only set attributes in this list, to assign to the rest of - # attributes you can use direct writer methods. This is meant to protect - # sensitive attributes from being overwritten by malicious users - # tampering with URLs or forms. If you'd rather start from an all-open - # default and restrict attributes as needed, have a look at - # +attr_protected+. - # - # class Customer < ActiveRecord::Base - # attr_accessible :name, :nickname - # end - # - # customer = Customer.new(:name => "David", :nickname => "Dave", :credit_rating => "Excellent") - # customer.credit_rating # => nil - # customer.attributes = { :name => "Jolly fellow", :credit_rating => "Superb" } - # customer.credit_rating # => nil - # - # customer.credit_rating = "Average" - # customer.credit_rating # => "Average" - def attr_accessible(*attributes) - write_inheritable_attribute(:attr_accessible, Set.new(attributes.map(&:to_s)) + (accessible_attributes || [])) - end - - # Returns an array of all the attributes that have been made accessible to mass-assignment. - def accessible_attributes # :nodoc: - read_inheritable_attribute(:attr_accessible) - end - - # Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards. - def attr_readonly(*attributes) - write_inheritable_attribute(:attr_readonly, Set.new(attributes.map(&:to_s)) + (readonly_attributes || [])) - end - - # Returns an array of all the attributes that have been specified as readonly. - def readonly_attributes - read_inheritable_attribute(:attr_readonly) - end - - # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, - # then specify the name of that attribute using this method and it will be handled automatically. - # The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that - # class on retrieval or SerializationTypeMismatch will be raised. - # - # ==== Parameters - # - # * +attr_name+ - The field name that should be serialized. - # * +class_name+ - Optional, class name that the object type should be equal to. - # - # ==== Example - # # Serialize a preferences attribute - # class User - # serialize :preferences - # end - def serialize(attr_name, class_name = Object) - serialized_attributes[attr_name.to_s] = class_name - end - - # Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values. - def serialized_attributes - read_inheritable_attribute(:attr_serialized) or write_inheritable_attribute(:attr_serialized, {}) - end - - # Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending - # directly from ActiveRecord::Base. So if the hierarchy looks like: Reply < Message < ActiveRecord::Base, then Message is used - # to guess the table name even when called on Reply. The rules used to do the guess are handled by the Inflector class - # in Active Support, which knows almost all common English inflections. You can add new inflections in config/initializers/inflections.rb. - # - # Nested classes are given table names prefixed by the singular form of - # the parent's table name. Enclosing modules are not considered. - # - # ==== Examples - # - # class Invoice < ActiveRecord::Base; end; - # file class table_name - # invoice.rb Invoice invoices - # - # class Invoice < ActiveRecord::Base; class Lineitem < ActiveRecord::Base; end; end; - # file class table_name - # invoice.rb Invoice::Lineitem invoice_lineitems - # - # module Invoice; class Lineitem < ActiveRecord::Base; end; end; - # file class table_name - # invoice/lineitem.rb Invoice::Lineitem lineitems - # - # Additionally, the class-level +table_name_prefix+ is prepended and the - # +table_name_suffix+ is appended. So if you have "myapp_" as a prefix, - # the table name guess for an Invoice class becomes "myapp_invoices". - # Invoice::Lineitem becomes "myapp_invoice_lineitems". - # - # You can also overwrite this class method to allow for unguessable - # links, such as a Mouse class with a link to a "mice" table. Example: - # - # class Mouse < ActiveRecord::Base - # set_table_name "mice" - # end - def table_name - reset_table_name - end - - def reset_table_name #:nodoc: - base = base_class - - name = - # STI subclasses always use their superclass' table. - unless self == base - base.table_name - else - # Nested classes are prefixed with singular parent table name. - if parent < ActiveRecord::Base && !parent.abstract_class? - contained = parent.table_name - contained = contained.singularize if parent.pluralize_table_names - contained << '_' - end - name = "#{full_table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}" - end - - set_table_name(name) - name - end - - # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the - # primary_key_prefix_type setting, though. - def primary_key - reset_primary_key - end - - def reset_primary_key #:nodoc: - key = get_primary_key(base_class.name) - set_primary_key(key) - key - end - - def get_primary_key(base_name) #:nodoc: - key = 'id' - case primary_key_prefix_type - when :table_name - key = base_name.to_s.foreign_key(false) - when :table_name_with_underscore - key = base_name.to_s.foreign_key - end - key - end - - def full_table_name_prefix #:nodoc: - (parents.detect{ |p| p.respond_to?(:table_name_prefix) } || self).table_name_prefix - end - - # Defines the column name for use with single table inheritance - # -- can be set in subclasses like so: self.inheritance_column = "type_id" - def inheritance_column - @inheritance_column ||= "type".freeze - end - - # Lazy-set the sequence name to the connection's default. This method - # is only ever called once since set_sequence_name overrides it. - def sequence_name #:nodoc: - reset_sequence_name - end - - def reset_sequence_name #:nodoc: - default = connection.default_sequence_name(table_name, primary_key) - set_sequence_name(default) - default - end - - # Sets the table name to use to the given value, or (if the value - # is nil or false) to the value returned by the given block. - # - # class Project < ActiveRecord::Base - # set_table_name "project" - # end - def set_table_name(value = nil, &block) - define_attr_method :table_name, value, &block - end - alias :table_name= :set_table_name - - # Sets the name of the primary key column to use to the given value, - # or (if the value is nil or false) to the value returned by the given - # block. - # - # class Project < ActiveRecord::Base - # set_primary_key "sysid" - # end - def set_primary_key(value = nil, &block) - define_attr_method :primary_key, value, &block - end - alias :primary_key= :set_primary_key - - # Sets the name of the inheritance column to use to the given value, - # or (if the value # is nil or false) to the value returned by the - # given block. - # - # class Project < ActiveRecord::Base - # set_inheritance_column do - # original_inheritance_column + "_id" - # end - # end - def set_inheritance_column(value = nil, &block) - define_attr_method :inheritance_column, value, &block - end - alias :inheritance_column= :set_inheritance_column - - # Sets the name of the sequence to use when generating ids to the given - # value, or (if the value is nil or false) to the value returned by the - # given block. This is required for Oracle and is useful for any - # database which relies on sequences for primary key generation. - # - # If a sequence name is not explicitly set when using Oracle or Firebird, - # it will default to the commonly used pattern of: #{table_name}_seq - # - # If a sequence name is not explicitly set when using PostgreSQL, it - # will discover the sequence corresponding to your primary key for you. - # - # class Project < ActiveRecord::Base - # set_sequence_name "projectseq" # default would have been "project_seq" - # end - def set_sequence_name(value = nil, &block) - define_attr_method :sequence_name, value, &block - end - alias :sequence_name= :set_sequence_name - - # Turns the +table_name+ back into a class name following the reverse rules of +table_name+. - def class_name(table_name = table_name) # :nodoc: - ActiveSupport::Deprecation.warn("ActiveRecord::Base#class_name is deprecated and will be removed in Rails 3.", caller) - - # remove any prefix and/or suffix from the table name - class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize - class_name = class_name.singularize if pluralize_table_names - class_name - end - - # Indicates whether the table associated with this class exists - def table_exists? - connection.table_exists?(table_name) - end - - # Returns an array of column objects for the table associated with this class. - def columns - unless defined?(@columns) && @columns - @columns = connection.columns(table_name, "#{name} Columns") - @columns.each { |column| column.primary = column.name == primary_key } - end - @columns - end - - # Returns a hash of column objects for the table associated with this class. - def columns_hash - @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash } - end - - # Returns an array of column names as strings. - def column_names - @column_names ||= columns.map { |column| column.name } - end - - # Returns an array of column objects where the primary id, all columns ending in "_id" or "_count", - # and columns used for single table inheritance have been removed. - def content_columns - @content_columns ||= columns.reject { |c| c.primary || c.name =~ /(_id|_count)$/ || c.name == inheritance_column } - end - - # Returns a hash of all the methods added to query each of the columns in the table with the name of the method as the key - # and true as the value. This makes it possible to do O(1) lookups in respond_to? to check if a given method for attribute - # is available. - def column_methods_hash #:nodoc: - @dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr| - attr_name = attr.to_s - methods[attr.to_sym] = attr_name - methods["#{attr}=".to_sym] = attr_name - methods["#{attr}?".to_sym] = attr_name - methods["#{attr}_before_type_cast".to_sym] = attr_name - methods - end - end - - # Resets all the cached information about columns, which will cause them - # to be reloaded on the next request. - # - # The most common usage pattern for this method is probably in a migration, - # when just after creating a table you want to populate it with some default - # values, eg: - # - # class CreateJobLevels < ActiveRecord::Migration - # def self.up - # create_table :job_levels do |t| - # t.integer :id - # t.string :name - # - # t.timestamps - # end - # - # JobLevel.reset_column_information - # %w{assistant executive manager director}.each do |type| - # JobLevel.create(:name => type) - # end - # end - # - # def self.down - # drop_table :job_levels - # end - # end - def reset_column_information - generated_methods.each { |name| undef_method(name) } - @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = @inheritance_column = nil - end - - def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc: - subclasses.each { |klass| klass.reset_inheritable_attributes; klass.reset_column_information } - end - - def self_and_descendants_from_active_record#nodoc: - klass = self - classes = [klass] - while klass != klass.base_class - classes << klass = klass.superclass - end - classes - rescue - # OPTIMIZE this rescue is to fix this test: ./test/cases/reflection_test.rb:56:in `test_human_name_for_column' - # Appearantly the method base_class causes some trouble. - # It now works for sure. - [self] - end - - # Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example: - # Person.human_attribute_name("first_name") # => "First name" - # This used to be depricated in favor of humanize, but is now preferred, because it automatically uses the I18n - # module now. - # Specify +options+ with additional translating options. - def human_attribute_name(attribute_key_name, options = {}) - defaults = self_and_descendants_from_active_record.map do |klass| - :"#{klass.name.underscore}.#{attribute_key_name}" - end - defaults << options[:default] if options[:default] - defaults.flatten! - defaults << attribute_key_name.to_s.humanize - options[:count] ||= 1 - I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes])) - end - - # Transform the modelname into a more humane format, using I18n. - # Defaults to the basic humanize method. - # Default scope of the translation is activerecord.models - # Specify +options+ with additional translating options. - def human_name(options = {}) - defaults = self_and_descendants_from_active_record.map do |klass| - :"#{klass.name.underscore}" - end - defaults << self.name.humanize - I18n.translate(defaults.shift, {:scope => [:activerecord, :models], :count => 1, :default => defaults}.merge(options)) - end - - # True if this isn't a concrete subclass needing a STI type condition. - def descends_from_active_record? - if superclass.abstract_class? - superclass.descends_from_active_record? - else - superclass == Base || !columns_hash.include?(inheritance_column) - end - end - - def finder_needs_type_condition? #:nodoc: - # This is like this because benchmarking justifies the strange :false stuff - :true == (@finder_needs_type_condition ||= descends_from_active_record? ? :false : :true) - end - - # Returns a string like 'Post id:integer, title:string, body:text' - def inspect - if self == Base - super - elsif abstract_class? - "#{super}(abstract)" - elsif table_exists? - attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', ' - "#{super}(#{attr_list})" - else - "#{super}(Table doesn't exist)" - end - end - - def quote_value(value, column = nil) #:nodoc: - connection.quote(value,column) - end - - # Used to sanitize objects before they're used in an SQL SELECT statement. Delegates to <tt>connection.quote</tt>. - def sanitize(object) #:nodoc: - connection.quote(object) - end - - # Log and benchmark multiple statements in a single block. Example: - # - # Project.benchmark("Creating project") do - # project = Project.create("name" => "stuff") - # project.create_manager("name" => "David") - # project.milestones << Milestone.find(:all) - # end - # - # The benchmark is only recorded if the current level of the logger is less than or equal to the <tt>log_level</tt>, - # which makes it easy to include benchmarking statements in production software that will remain inexpensive because - # the benchmark will only be conducted if the log level is low enough. - # - # The logging of the multiple statements is turned off unless <tt>use_silence</tt> is set to false. - def benchmark(title, log_level = Logger::DEBUG, use_silence = true) - if logger && logger.level <= log_level - result = nil - ms = Benchmark.ms { result = use_silence ? silence { yield } : yield } - logger.add(log_level, '%s (%.1fms)' % [title, ms]) - result - else - yield - end - end - - # Silences the logger for the duration of the block. - def silence - old_logger_level, logger.level = logger.level, Logger::ERROR if logger - yield - ensure - logger.level = old_logger_level if logger - end - - # Overwrite the default class equality method to provide support for association proxies. - def ===(object) - object.is_a?(self) - end - - # Returns the base AR subclass that this class descends from. If A - # extends AR::Base, A.base_class will return A. If B descends from A - # through some arbitrarily deep hierarchy, B.base_class will return A. - def base_class - class_of_active_record_descendant(self) - end - - # Set this to true if this is an abstract class (see <tt>abstract_class?</tt>). - attr_accessor :abstract_class - - # Returns whether this class is a base AR class. If A is a base class and - # B descends from A, then B.base_class will return B. - def abstract_class? - defined?(@abstract_class) && @abstract_class == true - end - - def respond_to?(method_id, include_private = false) - if match = DynamicFinderMatch.match(method_id) - return true if all_attributes_exists?(match.attribute_names) - elsif match = DynamicScopeMatch.match(method_id) - return true if all_attributes_exists?(match.attribute_names) - end - - super - end - - def sti_name - store_full_sti_class ? name : name.demodulize - end - - # Merges conditions so that the result is a valid +condition+ - def merge_conditions(*conditions) - segments = [] - - conditions.each do |condition| - unless condition.blank? - sql = sanitize_sql(condition) - segments << sql unless sql.blank? - end - end - - "(#{segments.join(') AND (')})" unless segments.empty? - end - - private - def find_initial(options) - options.update(:limit => 1) - find_every(options).first - end - - def find_last(options) - order = options[:order] - - if order - order = reverse_sql_order(order) - elsif !scoped?(:find, :order) - order = "#{table_name}.#{primary_key} DESC" - end - - if scoped?(:find, :order) - scope = scope(:find) - original_scoped_order = scope[:order] - scope[:order] = reverse_sql_order(original_scoped_order) - end - - begin - find_initial(options.merge({ :order => order })) - ensure - scope[:order] = original_scoped_order if original_scoped_order - end - end - - def reverse_sql_order(order_query) - reversed_query = order_query.to_s.split(/,/).each { |s| - if s.match(/\s(asc|ASC)$/) - s.gsub!(/\s(asc|ASC)$/, ' DESC') - elsif s.match(/\s(desc|DESC)$/) - s.gsub!(/\s(desc|DESC)$/, ' ASC') - elsif !s.match(/\s(asc|ASC|desc|DESC)$/) - s.concat(' DESC') - end - }.join(',') - end - - def find_every(options) - include_associations = merge_includes(scope(:find, :include), options[:include]) - - if include_associations.any? && references_eager_loaded_tables?(options) - records = find_with_associations(options) - else - records = find_by_sql(construct_finder_sql(options)) - if include_associations.any? - preload_associations(records, include_associations) - end - end - - records.each { |record| record.readonly! } if options[:readonly] - - records - end - - def find_from_ids(ids, options) - expects_array = ids.first.kind_of?(Array) - return ids.first if expects_array && ids.first.empty? - - ids = ids.flatten.compact.uniq - - case ids.size - when 0 - raise RecordNotFound, "Couldn't find #{name} without an ID" - when 1 - result = find_one(ids.first, options) - expects_array ? [ result ] : result - else - find_some(ids, options) - end - end - - def find_one(id, options) - conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions] - options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} = #{quote_value(id,columns_hash[primary_key])}#{conditions}" - - # Use find_every(options).first since the primary key condition - # already ensures we have a single record. Using find_initial adds - # a superfluous :limit => 1. - if result = find_every(options).first - result - else - raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}" - end - end - - def find_some(ids, options) - conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions] - ids_list = ids.map { |id| quote_value(id,columns_hash[primary_key]) }.join(',') - options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} IN (#{ids_list})#{conditions}" - - result = find_every(options) - - # Determine expected size from limit and offset, not just ids.size. - expected_size = - if options[:limit] && ids.size > options[:limit] - options[:limit] - else - ids.size - end - - # 11 ids with limit 3, offset 9 should give 2 results. - if options[:offset] && (ids.size - options[:offset] < expected_size) - expected_size = ids.size - options[:offset] - end - - if result.size == expected_size - result - else - raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})" - end - end - - # Finder methods must instantiate through this method to work with the - # single-table inheritance model that makes it possible to create - # objects of different types from the same table. - def instantiate(record) - object = - if subclass_name = record[inheritance_column] - # No type given. - if subclass_name.empty? - allocate - - else - # Ignore type if no column is present since it was probably - # pulled in from a sloppy join. - unless columns_hash.include?(inheritance_column) - allocate - - else - begin - compute_type(subclass_name).allocate - rescue NameError - raise SubclassNotFound, - "The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " + - "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " + - "Please rename this column if you didn't intend it to be used for storing the inheritance class " + - "or overwrite #{self.to_s}.inheritance_column to use another column for that information." - end - end - end - else - allocate - end - - object.instance_variable_set("@attributes", record) - object.instance_variable_set("@attributes_cache", Hash.new) - - if object.respond_to_without_attributes?(:after_find) - object.send(:callback, :after_find) - end - - if object.respond_to_without_attributes?(:after_initialize) - object.send(:callback, :after_initialize) - end - - object - end - - # Nest the type name in the same module as this class. - # Bar is "MyApp::Business::Bar" relative to MyApp::Business::Foo - def type_name_with_module(type_name) - if store_full_sti_class - type_name - else - (/^::/ =~ type_name) ? type_name : "#{parent.name}::#{type_name}" - end - end - - def default_select(qualified) - if qualified - quoted_table_name + '.*' - else - '*' - end - end - - def construct_finder_sql(options) - scope = scope(:find) - sql = "SELECT #{options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))} " - sql << "FROM #{options[:from] || (scope && scope[:from]) || quoted_table_name} " - - add_joins!(sql, options[:joins], scope) - add_conditions!(sql, options[:conditions], scope) - - add_group!(sql, options[:group], options[:having], scope) - add_order!(sql, options[:order], scope) - add_limit!(sql, options, scope) - add_lock!(sql, options, scope) - - sql - end - - # Merges includes so that the result is a valid +include+ - def merge_includes(first, second) - (safe_to_array(first) + safe_to_array(second)).uniq - end - - def merge_joins(*joins) - if joins.any?{|j| j.is_a?(String) || array_of_strings?(j) } - joins = joins.collect do |join| - join = [join] if join.is_a?(String) - unless array_of_strings?(join) - join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, join, nil) - join = join_dependency.join_associations.collect { |assoc| assoc.association_join } - end - join - end - joins.flatten.map{|j| j.strip}.uniq - else - joins.collect{|j| safe_to_array(j)}.flatten.uniq - end - end - - # Object#to_a is deprecated, though it does have the desired behavior - def safe_to_array(o) - case o - when NilClass - [] - when Array - o - else - [o] - end - end - - def array_of_strings?(o) - o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)} - end - - def add_order!(sql, order, scope = :auto) - scope = scope(:find) if :auto == scope - scoped_order = scope[:order] if scope - if order - sql << " ORDER BY #{order}" - if scoped_order && scoped_order != order - sql << ", #{scoped_order}" - end - else - sql << " ORDER BY #{scoped_order}" if scoped_order - end - end - - def add_group!(sql, group, having, scope = :auto) - if group - sql << " GROUP BY #{group}" - sql << " HAVING #{sanitize_sql_for_conditions(having)}" if having - else - scope = scope(:find) if :auto == scope - if scope && (scoped_group = scope[:group]) - sql << " GROUP BY #{scoped_group}" - sql << " HAVING #{sanitize_sql_for_conditions(scope[:having])}" if scope[:having] - end - end - end - - # The optional scope argument is for the current <tt>:find</tt> scope. - def add_limit!(sql, options, scope = :auto) - scope = scope(:find) if :auto == scope - - if scope - options[:limit] ||= scope[:limit] - options[:offset] ||= scope[:offset] - end - - connection.add_limit_offset!(sql, options) - end - - # The optional scope argument is for the current <tt>:find</tt> scope. - # The <tt>:lock</tt> option has precedence over a scoped <tt>:lock</tt>. - def add_lock!(sql, options, scope = :auto) - scope = scope(:find) if :auto == scope - options = options.reverse_merge(:lock => scope[:lock]) if scope - connection.add_lock!(sql, options) - end - - # The optional scope argument is for the current <tt>:find</tt> scope. - def add_joins!(sql, joins, scope = :auto) - scope = scope(:find) if :auto == scope - merged_joins = scope && scope[:joins] && joins ? merge_joins(scope[:joins], joins) : (joins || scope && scope[:joins]) - case merged_joins - when Symbol, Hash, Array - if array_of_strings?(merged_joins) - sql << merged_joins.join(' ') + " " - else - join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, merged_joins, nil) - sql << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} " - end - when String - sql << " #{merged_joins} " - end - end - - # Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed. - # The optional scope argument is for the current <tt>:find</tt> scope. - def add_conditions!(sql, conditions, scope = :auto) - scope = scope(:find) if :auto == scope - conditions = [conditions] - conditions << scope[:conditions] if scope - conditions << type_condition if finder_needs_type_condition? - merged_conditions = merge_conditions(*conditions) - sql << "WHERE #{merged_conditions} " unless merged_conditions.blank? - end - - def type_condition(table_alias=nil) - quoted_table_alias = self.connection.quote_table_name(table_alias || table_name) - quoted_inheritance_column = connection.quote_column_name(inheritance_column) - type_condition = subclasses.inject("#{quoted_table_alias}.#{quoted_inheritance_column} = '#{sti_name}' ") do |condition, subclass| - condition << "OR #{quoted_table_alias}.#{quoted_inheritance_column} = '#{subclass.sti_name}' " - end - - " (#{type_condition}) " - end - - # Guesses the table name, but does not decorate it with prefix and suffix information. - def undecorated_table_name(class_name = base_class.name) - table_name = class_name.to_s.demodulize.underscore - table_name = table_name.pluralize if pluralize_table_names - table_name - end - - # Enables dynamic finders like <tt>find_by_user_name(user_name)</tt> and <tt>find_by_user_name_and_password(user_name, password)</tt> - # that are turned into <tt>find(:first, :conditions => ["user_name = ?", user_name])</tt> and - # <tt>find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt> respectively. Also works for - # <tt>find(:all)</tt> by using <tt>find_all_by_amount(50)</tt> that is turned into <tt>find(:all, :conditions => ["amount = ?", 50])</tt>. - # - # It's even possible to use all the additional parameters to +find+. For example, the full interface for +find_all_by_amount+ - # is actually <tt>find_all_by_amount(amount, options)</tt>. - # - # Also enables dynamic scopes like scoped_by_user_name(user_name) and scoped_by_user_name_and_password(user_name, password) that - # are turned into scoped(:conditions => ["user_name = ?", user_name]) and scoped(:conditions => ["user_name = ? AND password = ?", user_name, password]) - # respectively. - # - # Each dynamic finder, scope or initializer/creator is also defined in the class after it is first invoked, so that future - # attempts to use it do not run through method_missing. - def method_missing(method_id, *arguments, &block) - if match = DynamicFinderMatch.match(method_id) - attribute_names = match.attribute_names - super unless all_attributes_exists?(attribute_names) - if match.finder? - finder = match.finder - bang = match.bang? - # def self.find_by_login_and_activated(*args) - # options = args.extract_options! - # attributes = construct_attributes_from_arguments( - # [:login,:activated], - # args - # ) - # finder_options = { :conditions => attributes } - # validate_find_options(options) - # set_readonly_option!(options) - # - # if options[:conditions] - # with_scope(:find => finder_options) do - # find(:first, options) - # end - # else - # find(:first, options.merge(finder_options)) - # end - # end - self.class_eval <<-EOS, __FILE__, __LINE__ + 1 - def self.#{method_id}(*args) - options = args.extract_options! - attributes = construct_attributes_from_arguments( - [:#{attribute_names.join(',:')}], - args - ) - finder_options = { :conditions => attributes } - validate_find_options(options) - set_readonly_option!(options) - - #{'result = ' if bang}if options[:conditions] - with_scope(:find => finder_options) do - find(:#{finder}, options) - end - else - find(:#{finder}, options.merge(finder_options)) - end - #{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect {|pair| "#{pair.first} = #{pair.second}"}.join(\', \')}")' if bang} - end - EOS - send(method_id, *arguments) - elsif match.instantiator? - instantiator = match.instantiator - # def self.find_or_create_by_user_id(*args) - # guard_protected_attributes = false - # - # if args[0].is_a?(Hash) - # guard_protected_attributes = true - # attributes = args[0].with_indifferent_access - # find_attributes = attributes.slice(*[:user_id]) - # else - # find_attributes = attributes = construct_attributes_from_arguments([:user_id], args) - # end - # - # options = { :conditions => find_attributes } - # set_readonly_option!(options) - # - # record = find(:first, options) - # - # if record.nil? - # record = self.new { |r| r.send(:attributes=, attributes, guard_protected_attributes) } - # yield(record) if block_given? - # record.save - # record - # else - # record - # end - # end - self.class_eval <<-EOS, __FILE__, __LINE__ + 1 - def self.#{method_id}(*args) - attributes = [:#{attribute_names.join(',:')}] - protected_attributes_for_create, unprotected_attributes_for_create = {}, {} - args.each_with_index do |arg, i| - if arg.is_a?(Hash) - protected_attributes_for_create = args[i].with_indifferent_access - else - unprotected_attributes_for_create[attributes[i]] = args[i] - end - end - - find_attributes = (protected_attributes_for_create.merge(unprotected_attributes_for_create)).slice(*attributes) - - options = { :conditions => find_attributes } - set_readonly_option!(options) - - record = find(:first, options) - - if record.nil? - record = self.new do |r| - r.send(:attributes=, protected_attributes_for_create, true) unless protected_attributes_for_create.empty? - r.send(:attributes=, unprotected_attributes_for_create, false) unless unprotected_attributes_for_create.empty? - end - #{'yield(record) if block_given?'} - #{'record.save' if instantiator == :create} - record - else - record - end - end - EOS - send(method_id, *arguments, &block) - end - elsif match = DynamicScopeMatch.match(method_id) - attribute_names = match.attribute_names - super unless all_attributes_exists?(attribute_names) - if match.scope? - self.class_eval <<-EOS, __FILE__, __LINE__ + 1 - def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args) - options = args.extract_options! # options = args.extract_options! - attributes = construct_attributes_from_arguments( # attributes = construct_attributes_from_arguments( - [:#{attribute_names.join(',:')}], args # [:user_name, :password], args - ) # ) - # - scoped(:conditions => attributes) # scoped(:conditions => attributes) - end # end - EOS - send(method_id, *arguments) - end - else - super - end - end - - def construct_attributes_from_arguments(attribute_names, arguments) - attributes = {} - attribute_names.each_with_index { |name, idx| attributes[name] = arguments[idx] } - attributes - end - - # Similar in purpose to +expand_hash_conditions_for_aggregates+. - def expand_attribute_names_for_aggregates(attribute_names) - expanded_attribute_names = [] - attribute_names.each do |attribute_name| - unless (aggregation = reflect_on_aggregation(attribute_name.to_sym)).nil? - aggregate_mapping(aggregation).each do |field_attr, aggregate_attr| - expanded_attribute_names << field_attr - end - else - expanded_attribute_names << attribute_name - end - end - expanded_attribute_names - end - - def all_attributes_exists?(attribute_names) - attribute_names = expand_attribute_names_for_aggregates(attribute_names) - attribute_names.all? { |name| column_methods_hash.include?(name.to_sym) } - end - - def attribute_condition(quoted_column_name, argument) - case argument - when nil then "#{quoted_column_name} IS ?" - when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope then "#{quoted_column_name} IN (?)" - when Range then if argument.exclude_end? - "#{quoted_column_name} >= ? AND #{quoted_column_name} < ?" - else - "#{quoted_column_name} BETWEEN ? AND ?" - end - else "#{quoted_column_name} = ?" - end - end - - # Interpret Array and Hash as conditions and anything else as an id. - def expand_id_conditions(id_or_conditions) - case id_or_conditions - when Array, Hash then id_or_conditions - else sanitize_sql(primary_key => id_or_conditions) - end - end - - # Defines an "attribute" method (like +inheritance_column+ or - # +table_name+). A new (class) method will be created with the - # given name. If a value is specified, the new method will - # return that value (as a string). Otherwise, the given block - # will be used to compute the value of the method. - # - # The original method will be aliased, with the new name being - # prefixed with "original_". This allows the new method to - # access the original value. - # - # Example: - # - # class A < ActiveRecord::Base - # define_attr_method :primary_key, "sysid" - # define_attr_method( :inheritance_column ) do - # original_inheritance_column + "_id" - # end - # end - def define_attr_method(name, value=nil, &block) - sing = class << self; self; end - sing.send :alias_method, "original_#{name}", name - if block_given? - sing.send :define_method, name, &block - else - # use eval instead of a block to work around a memory leak in dev - # mode in fcgi - sing.class_eval "def #{name}; #{value.to_s.inspect}; end" - end - end - - protected - # Scope parameters to method calls within the block. Takes a hash of method_name => parameters hash. - # method_name may be <tt>:find</tt> or <tt>:create</tt>. <tt>:find</tt> parameters may include the <tt>:conditions</tt>, <tt>:joins</tt>, - # <tt>:include</tt>, <tt>:offset</tt>, <tt>:limit</tt>, and <tt>:readonly</tt> options. <tt>:create</tt> parameters are an attributes hash. - # - # class Article < ActiveRecord::Base - # def self.create_with_scope - # with_scope(:find => { :conditions => "blog_id = 1" }, :create => { :blog_id => 1 }) do - # find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1 - # a = create(1) - # a.blog_id # => 1 - # end - # end - # end - # - # In nested scopings, all previous parameters are overwritten by the innermost rule, with the exception of - # <tt>:conditions</tt>, <tt>:include</tt>, and <tt>:joins</tt> options in <tt>:find</tt>, which are merged. - # - # <tt>:joins</tt> options are uniqued so multiple scopes can join in the same table without table aliasing - # problems. If you need to join multiple tables, but still want one of the tables to be uniqued, use the - # array of strings format for your joins. - # - # class Article < ActiveRecord::Base - # def self.find_with_scope - # with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }, :create => { :blog_id => 1 }) do - # with_scope(:find => { :limit => 10 }) - # find(:all) # => SELECT * from articles WHERE blog_id = 1 LIMIT 10 - # end - # with_scope(:find => { :conditions => "author_id = 3" }) - # find(:all) # => SELECT * from articles WHERE blog_id = 1 AND author_id = 3 LIMIT 1 - # end - # end - # end - # end - # - # You can ignore any previous scopings by using the <tt>with_exclusive_scope</tt> method. - # - # class Article < ActiveRecord::Base - # def self.find_with_exclusive_scope - # with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }) do - # with_exclusive_scope(:find => { :limit => 10 }) - # find(:all) # => SELECT * from articles LIMIT 10 - # end - # end - # end - # end - # - # *Note*: the +:find+ scope also has effect on update and deletion methods, - # like +update_all+ and +delete_all+. - def with_scope(method_scoping = {}, action = :merge, &block) - method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping) - - # Dup first and second level of hash (method and params). - method_scoping = method_scoping.inject({}) do |hash, (method, params)| - hash[method] = (params == true) ? params : params.dup - hash - end - - method_scoping.assert_valid_keys([ :find, :create ]) - - if f = method_scoping[:find] - f.assert_valid_keys(VALID_FIND_OPTIONS) - set_readonly_option! f - end - - # Merge scopings - if [:merge, :reverse_merge].include?(action) && current_scoped_methods - method_scoping = current_scoped_methods.inject(method_scoping) do |hash, (method, params)| - case hash[method] - when Hash - if method == :find - (hash[method].keys + params.keys).uniq.each do |key| - merge = hash[method][key] && params[key] # merge if both scopes have the same key - if key == :conditions && merge - if params[key].is_a?(Hash) && hash[method][key].is_a?(Hash) - hash[method][key] = merge_conditions(hash[method][key].deep_merge(params[key])) - else - hash[method][key] = merge_conditions(params[key], hash[method][key]) - end - elsif key == :include && merge - hash[method][key] = merge_includes(hash[method][key], params[key]).uniq - elsif key == :joins && merge - hash[method][key] = merge_joins(params[key], hash[method][key]) - else - hash[method][key] = hash[method][key] || params[key] - end - end - else - if action == :reverse_merge - hash[method] = hash[method].merge(params) - else - hash[method] = params.merge(hash[method]) - end - end - else - hash[method] = params - end - hash - end - end - - self.scoped_methods << method_scoping - begin - yield - ensure - self.scoped_methods.pop - end - end - - # Works like with_scope, but discards any nested properties. - def with_exclusive_scope(method_scoping = {}, &block) - with_scope(method_scoping, :overwrite, &block) - end - - def subclasses #:nodoc: - @@subclasses[self] ||= [] - @@subclasses[self] + extra = @@subclasses[self].inject([]) {|list, subclass| list + subclass.subclasses } - end - - # Sets the default options for the model. The format of the - # <tt>options</tt> argument is the same as in find. - # - # class Person < ActiveRecord::Base - # default_scope :order => 'last_name, first_name' - # end - def default_scope(options = {}) - self.default_scoping << { :find => options, :create => options[:conditions].is_a?(Hash) ? options[:conditions] : {} } - end - - # Test whether the given method and optional key are scoped. - def scoped?(method, key = nil) #:nodoc: - if current_scoped_methods && (scope = current_scoped_methods[method]) - !key || !scope[key].nil? - end - end - - # Retrieve the scope for the given method and optional key. - def scope(method, key = nil) #:nodoc: - if current_scoped_methods && (scope = current_scoped_methods[method]) - key ? scope[key] : scope - end - end - - def scoped_methods #:nodoc: - Thread.current[:"#{self}_scoped_methods"] ||= self.default_scoping.dup - end - - def current_scoped_methods #:nodoc: - scoped_methods.last - end - - # Returns the class type of the record using the current module as a prefix. So descendants of - # MyApp::Business::Account would appear as MyApp::Business::AccountSubclass. - def compute_type(type_name) - modularized_name = type_name_with_module(type_name) - silence_warnings do - begin - class_eval(modularized_name, __FILE__) - rescue NameError - class_eval(type_name, __FILE__) - end - end - end - - # Returns the class descending directly from ActiveRecord::Base or an - # abstract class, if any, in the inheritance hierarchy. - def class_of_active_record_descendant(klass) - if klass.superclass == Base || klass.superclass.abstract_class? - klass - elsif klass.superclass.nil? - raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord" - else - class_of_active_record_descendant(klass.superclass) - end - end - - # Returns the name of the class descending directly from Active Record in the inheritance hierarchy. - def class_name_of_active_record_descendant(klass) #:nodoc: - klass.base_class.name - end - - # Accepts an array, hash, or string of SQL conditions and sanitizes - # them into a valid SQL fragment for a WHERE clause. - # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'" - # { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'" - # "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'" - def sanitize_sql_for_conditions(condition, table_name = quoted_table_name) - return nil if condition.blank? - - case condition - when Array; sanitize_sql_array(condition) - when Hash; sanitize_sql_hash_for_conditions(condition, table_name) - else condition - end - end - alias_method :sanitize_sql, :sanitize_sql_for_conditions - - # Accepts an array, hash, or string of SQL conditions and sanitizes - # them into a valid SQL fragment for a SET clause. - # { :name => nil, :group_id => 4 } returns "name = NULL , group_id='4'" - def sanitize_sql_for_assignment(assignments) - case assignments - when Array; sanitize_sql_array(assignments) - when Hash; sanitize_sql_hash_for_assignment(assignments) - else assignments - end - end - - def aggregate_mapping(reflection) - mapping = reflection.options[:mapping] || [reflection.name, reflection.name] - mapping.first.is_a?(Array) ? mapping : [mapping] - end - - # Accepts a hash of SQL conditions and replaces those attributes - # that correspond to a +composed_of+ relationship with their expanded - # aggregate attribute values. - # Given: - # class Person < ActiveRecord::Base - # composed_of :address, :class_name => "Address", - # :mapping => [%w(address_street street), %w(address_city city)] - # end - # Then: - # { :address => Address.new("813 abc st.", "chicago") } - # # => { :address_street => "813 abc st.", :address_city => "chicago" } - def expand_hash_conditions_for_aggregates(attrs) - expanded_attrs = {} - attrs.each do |attr, value| - unless (aggregation = reflect_on_aggregation(attr.to_sym)).nil? - mapping = aggregate_mapping(aggregation) - mapping.each do |field_attr, aggregate_attr| - if mapping.size == 1 && !value.respond_to?(aggregate_attr) - expanded_attrs[field_attr] = value - else - expanded_attrs[field_attr] = value.send(aggregate_attr) - end - end - else - expanded_attrs[attr] = value - end - end - expanded_attrs - end - - # Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause. - # { :name => "foo'bar", :group_id => 4 } - # # => "name='foo''bar' and group_id= 4" - # { :status => nil, :group_id => [1,2,3] } - # # => "status IS NULL and group_id IN (1,2,3)" - # { :age => 13..18 } - # # => "age BETWEEN 13 AND 18" - # { 'other_records.id' => 7 } - # # => "`other_records`.`id` = 7" - # { :other_records => { :id => 7 } } - # # => "`other_records`.`id` = 7" - # And for value objects on a composed_of relationship: - # { :address => Address.new("123 abc st.", "chicago") } - # # => "address_street='123 abc st.' and address_city='chicago'" - def sanitize_sql_hash_for_conditions(attrs, default_table_name = quoted_table_name) - attrs = expand_hash_conditions_for_aggregates(attrs) - - conditions = attrs.map do |attr, value| - table_name = default_table_name - - unless value.is_a?(Hash) - attr = attr.to_s - - # Extract table name from qualified attribute names. - if attr.include?('.') - attr_table_name, attr = attr.split('.', 2) - attr_table_name = connection.quote_table_name(attr_table_name) - else - attr_table_name = table_name - end - - attribute_condition("#{attr_table_name}.#{connection.quote_column_name(attr)}", value) - else - sanitize_sql_hash_for_conditions(value, connection.quote_table_name(attr.to_s)) - end - end.join(' AND ') - - replace_bind_variables(conditions, expand_range_bind_variables(attrs.values)) - end - alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions - - # Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause. - # { :status => nil, :group_id => 1 } - # # => "status = NULL , group_id = 1" - def sanitize_sql_hash_for_assignment(attrs) - attrs.map do |attr, value| - "#{connection.quote_column_name(attr)} = #{quote_bound_value(value)}" - end.join(', ') - end - - # Accepts an array of conditions. The array has each value - # sanitized and interpolated into the SQL statement. - # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'" - def sanitize_sql_array(ary) - statement, *values = ary - if values.first.is_a?(Hash) and statement =~ /:\w+/ - replace_named_bind_variables(statement, values.first) - elsif statement.include?('?') - replace_bind_variables(statement, values) - else - statement % values.collect { |value| connection.quote_string(value.to_s) } - end - end - - alias_method :sanitize_conditions, :sanitize_sql - - def replace_bind_variables(statement, values) #:nodoc: - raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size) - bound = values.dup - statement.gsub('?') { quote_bound_value(bound.shift) } - end - - def replace_named_bind_variables(statement, bind_vars) #:nodoc: - statement.gsub(/(:?):([a-zA-Z]\w*)/) do - if $1 == ':' # skip postgresql casts - $& # return the whole match - elsif bind_vars.include?(match = $2.to_sym) - quote_bound_value(bind_vars[match]) - else - raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}" - end - end - end - - def expand_range_bind_variables(bind_vars) #:nodoc: - expanded = [] - - bind_vars.each do |var| - next if var.is_a?(Hash) - - if var.is_a?(Range) - expanded << var.first - expanded << var.last - else - expanded << var - end - end - - expanded - end - - def quote_bound_value(value) #:nodoc: - if value.respond_to?(:map) && !value.acts_like?(:string) - if value.respond_to?(:empty?) && value.empty? - connection.quote(nil) - else - value.map { |v| connection.quote(v) }.join(',') - end - else - connection.quote(value) - end - end - - def raise_if_bind_arity_mismatch(statement, expected, provided) #:nodoc: - unless expected == provided - raise PreparedStatementInvalid, "wrong number of bind variables (#{provided} for #{expected}) in: #{statement}" - end - end - - VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset, - :order, :select, :readonly, :group, :having, :from, :lock ] - - def validate_find_options(options) #:nodoc: - options.assert_valid_keys(VALID_FIND_OPTIONS) - end - - def set_readonly_option!(options) #:nodoc: - # Inherit :readonly from finder scope if set. Otherwise, - # if :joins is not blank then :readonly defaults to true. - unless options.has_key?(:readonly) - if scoped_readonly = scope(:find, :readonly) - options[:readonly] = scoped_readonly - elsif !options[:joins].blank? && !options[:select] - options[:readonly] = true - end - end - end - - def encode_quoted_value(value) #:nodoc: - quoted_value = connection.quote(value) - quoted_value = "'#{quoted_value[1..-2].gsub(/\'/, "\\\\'")}'" if quoted_value.include?("\\\'") # (for ruby mode) " - quoted_value - end - end - - public - # New objects can be instantiated as either empty (pass no construction parameter) or pre-set with - # attributes but not yet saved (pass a hash with key names matching the associated table column names). - # In both instances, valid attribute keys are determined by the column names of the associated table -- - # hence you can't have attributes that aren't part of the table columns. - def initialize(attributes = nil) - @attributes = attributes_from_column_definition - @attributes_cache = {} - @new_record = true - ensure_proper_type - self.attributes = attributes unless attributes.nil? - assign_attributes(self.class.send(:scope, :create)) if self.class.send(:scoped?, :create) - result = yield self if block_given? - callback(:after_initialize) if respond_to_without_attributes?(:after_initialize) - result - end - - # A model instance's primary key is always available as model.id - # whether you name it the default 'id' or set it to something else. - def id - attr_name = self.class.primary_key - column = column_for_attribute(attr_name) - - self.class.send(:define_read_method, :id, attr_name, column) - # now that the method exists, call it - self.send attr_name.to_sym - - end - - # Returns a String, which Action Pack uses for constructing an URL to this - # object. The default implementation returns this record's id as a String, - # or nil if this record's unsaved. - # - # For example, suppose that you have a User model, and that you have a - # <tt>map.resources :users</tt> route. Normally, +user_path+ will - # construct a path with the user object's 'id' in it: - # - # user = User.find_by_name('Phusion') - # user_path(user) # => "/users/1" - # - # You can override +to_param+ in your model to make +user_path+ construct - # a path using the user's name instead of the user's id: - # - # class User < ActiveRecord::Base - # def to_param # overridden - # name - # end - # end - # - # user = User.find_by_name('Phusion') - # user_path(user) # => "/users/Phusion" - def to_param - # We can't use alias_method here, because method 'id' optimizes itself on the fly. - (id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes - end - - # Returns a cache key that can be used to identify this record. - # - # ==== Examples - # - # Product.new.cache_key # => "products/new" - # Product.find(5).cache_key # => "products/5" (updated_at not available) - # Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available) - def cache_key - case - when new_record? - "#{self.class.model_name.cache_key}/new" - when timestamp = self[:updated_at] - "#{self.class.model_name.cache_key}/#{id}-#{timestamp.to_s(:number)}" - else - "#{self.class.model_name.cache_key}/#{id}" - end - end - - def id_before_type_cast #:nodoc: - read_attribute_before_type_cast(self.class.primary_key) - end - - def quoted_id #:nodoc: - quote_value(id, column_for_attribute(self.class.primary_key)) - end - - # Sets the primary ID. - def id=(value) - write_attribute(self.class.primary_key, value) - end - - # Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet; otherwise, returns false. - def new_record? - @new_record || false - end - - # :call-seq: - # save(perform_validation = true) - # - # Saves the model. - # - # If the model is new a record gets created in the database, otherwise - # the existing record gets updated. - # - # If +perform_validation+ is true validations run. If any of them fail - # the action is cancelled and +save+ returns +false+. If the flag is - # false validations are bypassed altogether. See - # ActiveRecord::Validations for more information. - # - # There's a series of callbacks associated with +save+. If any of the - # <tt>before_*</tt> callbacks return +false+ the action is cancelled and - # +save+ returns +false+. See ActiveRecord::Callbacks for further - # details. - def save - create_or_update - end - - # Saves the model. - # - # If the model is new a record gets created in the database, otherwise - # the existing record gets updated. - # - # With <tt>save!</tt> validations always run. If any of them fail - # ActiveRecord::RecordInvalid gets raised. See ActiveRecord::Validations - # for more information. - # - # There's a series of callbacks associated with <tt>save!</tt>. If any of - # the <tt>before_*</tt> callbacks return +false+ the action is cancelled - # and <tt>save!</tt> raises ActiveRecord::RecordNotSaved. See - # ActiveRecord::Callbacks for further details. - def save! - create_or_update || raise(RecordNotSaved) - end - - # Deletes the record in the database and freezes this instance to - # reflect that no changes should be made (since they can't be - # persisted). Returns the frozen instance. - # - # The row is simply removed with a SQL +DELETE+ statement on the - # record's primary key, and no callbacks are executed. - # - # To enforce the object's +before_destroy+ and +after_destroy+ - # callbacks, Observer methods, or any <tt>:dependent</tt> association - # options, use <tt>#destroy</tt>. - def delete - self.class.delete(id) unless new_record? - @destroyed = true - freeze - end - - # Deletes the record in the database and freezes this instance to reflect that no changes should - # be made (since they can't be persisted). - def destroy - unless new_record? - connection.delete( - "DELETE FROM #{self.class.quoted_table_name} " + - "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}", - "#{self.class.name} Destroy" - ) - end - - @destroyed = true - freeze - end - - # Returns a clone of the record that hasn't been assigned an id yet and - # is treated as a new record. Note that this is a "shallow" clone: - # it copies the object's attributes only, not its associations. - # The extent of a "deep" clone is application-specific and is therefore - # left to the application to implement according to its need. - def clone - attrs = clone_attributes(:read_attribute_before_type_cast) - attrs.delete(self.class.primary_key) - record = self.class.new - record.send :instance_variable_set, '@attributes', attrs - record - end - - # Returns an instance of the specified +klass+ with the attributes of the current record. This is mostly useful in relation to - # single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record - # identification in Action Pack to allow, say, <tt>Client < Company</tt> to do something like render <tt>:partial => @client.becomes(Company)</tt> - # to render that instance using the companies/company partial instead of clients/client. - # - # Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either - # instance will affect the other. - def becomes(klass) - klass.new.tap do |became| - became.instance_variable_set("@attributes", @attributes) - became.instance_variable_set("@attributes_cache", @attributes_cache) - became.instance_variable_set("@new_record", new_record?) - end - end - - # Updates a single attribute and saves the record without going through the normal validation procedure. - # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method - # in Base is replaced with this when the validations module is mixed in, which it is by default. - def update_attribute(name, value) - send(name.to_s + '=', value) - save(false) - end - - # Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will - # fail and false will be returned. - def update_attributes(attributes) - with_transaction_returning_status(:update_attributes_inside_transaction, attributes) - end - - def update_attributes_inside_transaction(attributes) #:nodoc: - self.attributes = attributes - save - end - - # Updates an object just like Base.update_attributes but calls save! instead of save so an exception is raised if the record is invalid. - def update_attributes!(attributes) - with_transaction_returning_status(:update_attributes_inside_transaction!, attributes) - end - - def update_attributes_inside_transaction!(attributes) #:nodoc: - self.attributes = attributes - save! - end - - # Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1). - # The increment is performed directly on the underlying attribute, no setter is invoked. - # Only makes sense for number-based attributes. Returns +self+. - def increment(attribute, by = 1) - self[attribute] ||= 0 - self[attribute] += by - self - end - - # Wrapper around +increment+ that saves the record. This method differs from - # its non-bang version in that it passes through the attribute setter. - # Saving is not subjected to validation checks. Returns +true+ if the - # record could be saved. - def increment!(attribute, by = 1) - increment(attribute, by).update_attribute(attribute, self[attribute]) - end - - # Initializes +attribute+ to zero if +nil+ and subtracts the value passed as +by+ (default is 1). - # The decrement is performed directly on the underlying attribute, no setter is invoked. - # Only makes sense for number-based attributes. Returns +self+. - def decrement(attribute, by = 1) - self[attribute] ||= 0 - self[attribute] -= by - self - end - - # Wrapper around +decrement+ that saves the record. This method differs from - # its non-bang version in that it passes through the attribute setter. - # Saving is not subjected to validation checks. Returns +true+ if the - # record could be saved. - def decrement!(attribute, by = 1) - decrement(attribute, by).update_attribute(attribute, self[attribute]) - end - - # Assigns to +attribute+ the boolean opposite of <tt>attribute?</tt>. So - # if the predicate returns +true+ the attribute will become +false+. This - # method toggles directly the underlying value without calling any setter. - # Returns +self+. - def toggle(attribute) - self[attribute] = !send("#{attribute}?") - self - end - - # Wrapper around +toggle+ that saves the record. This method differs from - # its non-bang version in that it passes through the attribute setter. - # Saving is not subjected to validation checks. Returns +true+ if the - # record could be saved. - def toggle!(attribute) - toggle(attribute).update_attribute(attribute, self[attribute]) - end - - # Reloads the attributes of this object from the database. - # The optional options argument is passed to find when reloading so you - # may do e.g. record.reload(:lock => true) to reload the same record with - # an exclusive row lock. - def reload(options = nil) - clear_aggregation_cache - clear_association_cache - @attributes.update(self.class.send(:with_exclusive_scope) { self.class.find(self.id, options) }.instance_variable_get('@attributes')) - @attributes_cache = {} - self - end - - # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example, - # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). - # (Alias for the protected read_attribute method). - def [](attr_name) - read_attribute(attr_name) - end - - # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. - # (Alias for the protected write_attribute method). - def []=(attr_name, value) - write_attribute(attr_name, value) - end - - # Allows you to set all the attributes at once by passing in a hash with keys - # matching the attribute names (which again matches the column names). - # - # If +guard_protected_attributes+ is true (the default), then sensitive - # attributes can be protected from this form of mass-assignment by using - # the +attr_protected+ macro. Or you can alternatively specify which - # attributes *can* be accessed with the +attr_accessible+ macro. Then all the - # attributes not included in that won't be allowed to be mass-assigned. - # - # class User < ActiveRecord::Base - # attr_protected :is_admin - # end - # - # user = User.new - # user.attributes = { :username => 'Phusion', :is_admin => true } - # user.username # => "Phusion" - # user.is_admin? # => false - # - # user.send(:attributes=, { :username => 'Phusion', :is_admin => true }, false) - # user.is_admin? # => true - def attributes=(new_attributes, guard_protected_attributes = true) - return if new_attributes.nil? - attributes = new_attributes.dup - attributes.stringify_keys! - - attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes - assign_attributes(attributes) if attributes and attributes.any? - end - - # Returns a hash of all the attributes with their names as keys and the values of the attributes as values. - def attributes - attrs = {} - attribute_names.each { |name| attrs[name] = read_attribute(name) } - attrs - end - - # Returns a hash of attributes before typecasting and deserialization. - def attributes_before_type_cast - self.attribute_names.inject({}) do |attrs, name| - attrs[name] = read_attribute_before_type_cast(name) - attrs - end - end - - # Returns an <tt>#inspect</tt>-like string for the value of the - # attribute +attr_name+. String attributes are elided after 50 - # characters, and Date and Time attributes are returned in the - # <tt>:db</tt> format. Other attributes return the value of - # <tt>#inspect</tt> without modification. - # - # person = Person.create!(:name => "David Heinemeier Hansson " * 3) - # - # person.attribute_for_inspect(:name) - # # => '"David Heinemeier Hansson David Heinemeier Hansson D..."' - # - # person.attribute_for_inspect(:created_at) - # # => '"2009-01-12 04:48:57"' - def attribute_for_inspect(attr_name) - value = read_attribute(attr_name) - - if value.is_a?(String) && value.length > 50 - "#{value[0..50]}...".inspect - elsif value.is_a?(Date) || value.is_a?(Time) - %("#{value.to_s(:db)}") - else - value.inspect - end - end - - # Returns true if the specified +attribute+ has been set by the user or by a database load and is neither - # nil nor empty? (the latter only applies to objects that respond to empty?, most notably Strings). - def attribute_present?(attribute) - value = read_attribute(attribute) - !value.blank? - end - - # Returns true if the given attribute is in the attributes hash - def has_attribute?(attr_name) - @attributes.has_key?(attr_name.to_s) - end - - # Returns an array of names for the attributes available on this object sorted alphabetically. - def attribute_names - @attributes.keys.sort - end - - # Returns the column object for the named attribute. - def column_for_attribute(name) - self.class.columns_hash[name.to_s] - end - - # Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id. - def ==(comparison_object) - comparison_object.equal?(self) || - (comparison_object.instance_of?(self.class) && - comparison_object.id == id && - !comparison_object.new_record?) - end - - # Delegates to == - def eql?(comparison_object) - self == (comparison_object) - end - - # Delegates to id in order to allow two records of the same type and id to work with something like: - # [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ] - def hash - id.hash - end - - # Freeze the attributes hash such that associations are still accessible, even on destroyed records. - def freeze - @attributes.freeze; self - end - - # Returns +true+ if the attributes hash has been frozen. - def frozen? - @attributes.frozen? - end - - # Returns +true+ if the record has been destroyed. - def destroyed? - @destroyed - end - - # Returns +true+ if the record is read only. Records loaded through joins with piggy-back - # attributes will be marked as read only since they cannot be saved. - def readonly? - defined?(@readonly) && @readonly == true - end - - # Marks this record as read only. - def readonly! - @readonly = true - end - - # Returns the contents of the record as a nicely formatted string. - def inspect - attributes_as_nice_string = self.class.column_names.collect { |name| - if has_attribute?(name) || new_record? - "#{name}: #{attribute_for_inspect(name)}" - end - }.compact.join(", ") - "#<#{self.class} #{attributes_as_nice_string}>" - end - - private - # Assigns attributes, dealing nicely with both multi and single paramater attributes - # Assumes attributes is a hash - - def assign_attributes(attributes={}) - multiparameter_attributes = [] - - attributes.each do |k, v| - if k.to_s.include?("(") - multiparameter_attributes << [ k, v ] - else - respond_to?(:"#{k}=") ? send(:"#{k}=", v) : raise(UnknownAttributeError, "unknown attribute: #{k}") - end - end - - assign_multiparameter_attributes(multiparameter_attributes) unless multiparameter_attributes.empty? - end - - def create_or_update - raise ReadOnlyRecord if readonly? - result = new_record? ? create : update - result != false - end - - # Updates the associated record with values matching those of the instance attributes. - # Returns the number of affected rows. - def update(attribute_names = @attributes.keys) - quoted_attributes = attributes_with_quotes(false, false, attribute_names) - return 0 if quoted_attributes.empty? - connection.update( - "UPDATE #{self.class.quoted_table_name} " + - "SET #{quoted_comma_pair_list(connection, quoted_attributes)} " + - "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}", - "#{self.class.name} Update" - ) - end - - # Creates a record with values matching those of the instance attributes - # and returns its id. - def create - if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name) - self.id = connection.next_sequence_value(self.class.sequence_name) - end - - quoted_attributes = attributes_with_quotes - - statement = if quoted_attributes.empty? - connection.empty_insert_statement(self.class.table_name) - else - "INSERT INTO #{self.class.quoted_table_name} " + - "(#{quoted_column_names.join(', ')}) " + - "VALUES(#{quoted_attributes.values.join(', ')})" - end - - self.id = connection.insert(statement, "#{self.class.name} Create", - self.class.primary_key, self.id, self.class.sequence_name) - - @new_record = false - id - end - - # Sets the attribute used for single table inheritance to this class name if this is not the ActiveRecord::Base descendant. - # Considering the hierarchy Reply < Message < ActiveRecord::Base, this makes it possible to do Reply.new without having to - # set <tt>Reply[Reply.inheritance_column] = "Reply"</tt> yourself. No such attribute would be set for objects of the - # Message class in that example. - def ensure_proper_type - unless self.class.descends_from_active_record? - write_attribute(self.class.inheritance_column, self.class.sti_name) - end - end - - def convert_number_column_value(value) - if value == false - 0 - elsif value == true - 1 - elsif value.is_a?(String) && value.blank? - nil - else - value - end - end - - def remove_attributes_protected_from_mass_assignment(attributes) - safe_attributes = - if self.class.accessible_attributes.nil? && self.class.protected_attributes.nil? - attributes.reject { |key, value| attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) } - elsif self.class.protected_attributes.nil? - attributes.reject { |key, value| !self.class.accessible_attributes.include?(key.gsub(/\(.+/, "")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) } - elsif self.class.accessible_attributes.nil? - attributes.reject { |key, value| self.class.protected_attributes.include?(key.gsub(/\(.+/,"")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) } - else - raise "Declare either attr_protected or attr_accessible for #{self.class}, but not both." - end - - removed_attributes = attributes.keys - safe_attributes.keys - - if removed_attributes.any? - log_protected_attribute_removal(removed_attributes) - end - - safe_attributes - end - - # Removes attributes which have been marked as readonly. - def remove_readonly_attributes(attributes) - unless self.class.readonly_attributes.nil? - attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"")) } - else - attributes - end - end - - def log_protected_attribute_removal(*attributes) - logger.debug "WARNING: Can't mass-assign these protected attributes: #{attributes.join(', ')}" - end - - # The primary key and inheritance column can never be set by mass-assignment for security reasons. - def attributes_protected_by_default - default = [ self.class.primary_key, self.class.inheritance_column ] - default << 'id' unless self.class.primary_key.eql? 'id' - default - end - - # Returns a copy of the attributes hash where all the values have been safely quoted for use in - # an SQL statement. - def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) - quoted = {} - connection = self.class.connection - attribute_names.each do |name| - if (column = column_for_attribute(name)) && (include_primary_key || !column.primary) - value = read_attribute(name) - - # We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML. - if value && self.class.serialized_attributes.has_key?(name) && (value.acts_like?(:date) || value.acts_like?(:time)) - value = value.to_yaml - end - - quoted[name] = connection.quote(value, column) - end - end - include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) - end - - # Quote strings appropriately for SQL statements. - def quote_value(value, column = nil) - self.class.connection.quote(value, column) - end - - # Interpolate custom SQL string in instance context. - # Optional record argument is meant for custom insert_sql. - def interpolate_sql(sql, record = nil) - instance_eval("%@#{sql.gsub('@', '\@')}@") - end - - # Initializes the attributes array with keys matching the columns from the linked table and - # the values matching the corresponding default value of that column, so - # that a new instance, or one populated from a passed-in Hash, still has all the attributes - # that instances loaded from the database would. - def attributes_from_column_definition - self.class.columns.inject({}) do |attributes, column| - attributes[column.name] = column.default unless column.name == self.class.primary_key - attributes - end - end - - # Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done - # by calling new on the column type or aggregation type (through composed_of) object with these parameters. - # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate - # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the - # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float, - # s for String, and a for Array. If all the values for a given attribute are empty, the attribute will be set to nil. - def assign_multiparameter_attributes(pairs) - execute_callstack_for_multiparameter_attributes( - extract_callstack_for_multiparameter_attributes(pairs) - ) - end - - def instantiate_time_object(name, values) - if self.class.send(:create_time_zone_conversion_attribute?, name, column_for_attribute(name)) - Time.zone.local(*values) - else - Time.time_with_datetime_fallback(@@default_timezone, *values) - end - end - - def execute_callstack_for_multiparameter_attributes(callstack) - errors = [] - callstack.each do |name, values_with_empty_parameters| - begin - klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass - # in order to allow a date to be set without a year, we must keep the empty values. - # Otherwise, we wouldn't be able to distinguish it from a date with an empty day. - values = values_with_empty_parameters.reject(&:nil?) - - if values.empty? - send(name + "=", nil) - else - - value = if Time == klass - instantiate_time_object(name, values) - elsif Date == klass - begin - values = values_with_empty_parameters.collect do |v| v.nil? ? 1 : v end - Date.new(*values) - rescue ArgumentError => ex # if Date.new raises an exception on an invalid date - instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates - end - else - klass.new(*values) - end - - send(name + "=", value) - end - rescue => ex - errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name) - end - end - unless errors.empty? - raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes" - end - end - - def extract_callstack_for_multiparameter_attributes(pairs) - attributes = { } - - for pair in pairs - multiparameter_name, value = pair - attribute_name = multiparameter_name.split("(").first - attributes[attribute_name] = [] unless attributes.include?(attribute_name) - - parameter_value = value.empty? ? nil : type_cast_attribute_value(multiparameter_name, value) - attributes[attribute_name] << [ find_parameter_position(multiparameter_name), parameter_value ] - end - - attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } } - end - - def type_cast_attribute_value(multiparameter_name, value) - multiparameter_name =~ /\([0-9]*([if])\)/ ? value.send("to_" + $1) : value - end - - def find_parameter_position(multiparameter_name) - multiparameter_name.scan(/\(([0-9]*).*\)/).first.first - end - - # Returns a comma-separated pair list, like "key1 = val1, key2 = val2". - def comma_pair_list(hash) - hash.map { |k,v| "#{k} = #{v}" }.join(", ") - end - - def quoted_column_names(attributes = attributes_with_quotes) - connection = self.class.connection - attributes.keys.collect do |column_name| - connection.quote_column_name(column_name) - end - end - - def self.quoted_table_name - self.connection.quote_table_name(self.table_name) - end - - def quote_columns(quoter, hash) - hash.inject({}) do |quoted, (name, value)| - quoted[quoter.quote_column_name(name)] = value - quoted - end - end - - def quoted_comma_pair_list(quoter, hash) - comma_pair_list(quote_columns(quoter, hash)) - end - - def object_from_yaml(string) - return string unless string.is_a?(String) && string =~ /^---/ - YAML::load(string) rescue string - end - - def clone_attributes(reader_method = :read_attribute, attributes = {}) - self.attribute_names.inject(attributes) do |attrs, name| - attrs[name] = clone_attribute_value(reader_method, name) - attrs - end - end - - def clone_attribute_value(reader_method, attribute_name) - value = send(reader_method, attribute_name) - value.duplicable? ? value.clone : value - rescue TypeError, NoMethodError - value - end - end - - Base.class_eval do - extend QueryCache::ClassMethods - include Validations - include Locking::Optimistic, Locking::Pessimistic - include AttributeMethods - include Dirty - include Callbacks, Observing, Timestamp - include Associations, AssociationPreload, NamedScope - - # AutosaveAssociation needs to be included before Transactions, because we want - # #save_with_autosave_associations to be wrapped inside a transaction. - include AutosaveAssociation, NestedAttributes - - include Aggregations, Transactions, Reflection, Batches, Calculations, Serialization - end -end - -# TODO: Remove this and make it work with LAZY flag -require 'active_record/connection_adapters/abstract_adapter' diff --git a/vendor/rails/activerecord/lib/active_record/batches.rb b/vendor/rails/activerecord/lib/active_record/batches.rb deleted file mode 100644 index acbbd98c..00000000 --- a/vendor/rails/activerecord/lib/active_record/batches.rb +++ /dev/null @@ -1,85 +0,0 @@ -module ActiveRecord - module Batches # :nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # When processing large numbers of records, it's often a good idea to do - # so in batches to prevent memory ballooning. - module ClassMethods - # Yields each record that was found by the find +options+. The find is - # performed by find_in_batches with a batch size of 1000 (or as - # specified by the <tt>:batch_size</tt> option). - # - # Example: - # - # Person.find_each(:conditions => "age > 21") do |person| - # person.party_all_night! - # end - # - # Note: This method is only intended to use for batch processing of - # large amounts of records that wouldn't fit in memory all at once. If - # you just need to loop over less than 1000 records, it's probably - # better just to use the regular find methods. - def find_each(options = {}) - find_in_batches(options) do |records| - records.each { |record| yield record } - end - - self - end - - # Yields each batch of records that was found by the find +options+ as - # an array. The size of each batch is set by the <tt>:batch_size</tt> - # option; the default is 1000. - # - # You can control the starting point for the batch processing by - # supplying the <tt>:start</tt> option. This is especially useful if you - # want multiple workers dealing with the same processing queue. You can - # make worker 1 handle all the records between id 0 and 10,000 and - # worker 2 handle from 10,000 and beyond (by setting the <tt>:start</tt> - # option on that worker). - # - # It's not possible to set the order. That is automatically set to - # ascending on the primary key ("id ASC") to make the batch ordering - # work. This also mean that this method only works with integer-based - # primary keys. You can't set the limit either, that's used to control - # the the batch sizes. - # - # Example: - # - # Person.find_in_batches(:conditions => "age > 21") do |group| - # sleep(50) # Make sure it doesn't get too crowded in there! - # group.each { |person| person.party_all_night! } - # end - def find_in_batches(options = {}) - raise "You can't specify an order, it's forced to be #{batch_order}" if options[:order] - raise "You can't specify a limit, it's forced to be the batch_size" if options[:limit] - - start = options.delete(:start).to_i - batch_size = options.delete(:batch_size) || 1000 - - proxy = scoped(options.merge(:order => batch_order, :limit => batch_size)) - records = proxy.find(:all, :conditions => [ "#{table_name}.#{primary_key} >= ?", start ]) - - while records.any? - yield records - - break if records.size < batch_size - - last_value = records.last.id - - raise "You must include the primary key if you define a select" unless last_value.present? - - records = proxy.find(:all, :conditions => [ "#{table_name}.#{primary_key} > ?", last_value ]) - end - end - - - private - def batch_order - "#{table_name}.#{primary_key} ASC" - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/lib/active_record/calculations.rb b/vendor/rails/activerecord/lib/active_record/calculations.rb deleted file mode 100644 index f6249e52..00000000 --- a/vendor/rails/activerecord/lib/active_record/calculations.rb +++ /dev/null @@ -1,321 +0,0 @@ -module ActiveRecord - module Calculations #:nodoc: - CALCULATIONS_OPTIONS = [:conditions, :joins, :order, :select, :group, :having, :distinct, :limit, :offset, :include, :from] - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - # Count operates using three different approaches. - # - # * Count all: By not passing any parameters to count, it will return a count of all the rows for the model. - # * Count using column: By passing a column name to count, it will return a count of all the rows for the model with supplied column present - # * Count using options will find the row count matched by the options used. - # - # The third approach, count using options, accepts an option hash as the only parameter. The options are: - # - # * <tt>:conditions</tt>: An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro to ActiveRecord::Base. - # * <tt>:joins</tt>: Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed) - # or named associations in the same form used for the <tt>:include</tt> option, which will perform an INNER JOIN on the associated table(s). - # If the value is a string, then the records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # Pass <tt>:readonly => false</tt> to override. - # * <tt>:include</tt>: Named associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer - # to already defined associations. When using named associations, count returns the number of DISTINCT items for the model you're counting. - # See eager loading under Associations. - # * <tt>:order</tt>: An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations). - # * <tt>:group</tt>: An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause. - # * <tt>:select</tt>: By default, this is * as in SELECT * FROM, but can be changed if you, for example, want to do a join but not - # include the joined columns. - # * <tt>:distinct</tt>: Set this to true to make this a distinct calculation, such as SELECT COUNT(DISTINCT posts.id) ... - # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an alternate table name (or even the name - # of a database view). - # - # Examples for counting all: - # Person.count # returns the total count of all people - # - # Examples for counting by column: - # Person.count(:age) # returns the total count of all people whose age is present in database - # - # Examples for count with options: - # Person.count(:conditions => "age > 26") - # Person.count(:conditions => "age > 26 AND job.salary > 60000", :include => :job) # because of the named association, it finds the DISTINCT count using LEFT OUTER JOIN. - # Person.count(:conditions => "age > 26 AND job.salary > 60000", :joins => "LEFT JOIN jobs on jobs.person_id = person.id") # finds the number of rows matching the conditions and joins. - # Person.count('id', :conditions => "age > 26") # Performs a COUNT(id) - # Person.count(:all, :conditions => "age > 26") # Performs a COUNT(*) (:all is an alias for '*') - # - # Note: <tt>Person.count(:all)</tt> will not work because it will use <tt>:all</tt> as the condition. Use Person.count instead. - def count(*args) - calculate(:count, *construct_count_options_from_args(*args)) - end - - # Calculates the average value on a given column. The value is returned as - # a float, or +nil+ if there's no row. See +calculate+ for examples with - # options. - # - # Person.average('age') # => 35.8 - def average(column_name, options = {}) - calculate(:avg, column_name, options) - end - - # Calculates the minimum value on a given column. The value is returned - # with the same data type of the column, or +nil+ if there's no row. See - # +calculate+ for examples with options. - # - # Person.minimum('age') # => 7 - def minimum(column_name, options = {}) - calculate(:min, column_name, options) - end - - # Calculates the maximum value on a given column. The value is returned - # with the same data type of the column, or +nil+ if there's no row. See - # +calculate+ for examples with options. - # - # Person.maximum('age') # => 93 - def maximum(column_name, options = {}) - calculate(:max, column_name, options) - end - - # Calculates the sum of values on a given column. The value is returned - # with the same data type of the column, 0 if there's no row. See - # +calculate+ for examples with options. - # - # Person.sum('age') # => 4562 - def sum(column_name, options = {}) - calculate(:sum, column_name, options) - end - - # This calculates aggregate values in the given column. Methods for count, sum, average, minimum, and maximum have been added as shortcuts. - # Options such as <tt>:conditions</tt>, <tt>:order</tt>, <tt>:group</tt>, <tt>:having</tt>, and <tt>:joins</tt> can be passed to customize the query. - # - # There are two basic forms of output: - # * Single aggregate value: The single value is type cast to Fixnum for COUNT, Float for AVG, and the given column's type for everything else. - # * Grouped values: This returns an ordered hash of the values and groups them by the <tt>:group</tt> option. It takes either a column name, or the name - # of a belongs_to association. - # - # values = Person.maximum(:age, :group => 'last_name') - # puts values["Drake"] - # => 43 - # - # drake = Family.find_by_last_name('Drake') - # values = Person.maximum(:age, :group => :family) # Person belongs_to :family - # puts values[drake] - # => 43 - # - # values.each do |family, max_age| - # ... - # end - # - # Options: - # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro to ActiveRecord::Base. - # * <tt>:include</tt>: Eager loading, see Associations for details. Since calculations don't load anything, the purpose of this is to access fields on joined tables in your conditions, order, or group clauses. - # * <tt>:joins</tt> - An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id". (Rarely needed). - # The records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # * <tt>:order</tt> - An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations). - # * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause. - # * <tt>:select</tt> - By default, this is * as in SELECT * FROM, but can be changed if you for example want to do a join, but not - # include the joined columns. - # * <tt>:distinct</tt> - Set this to true to make this a distinct calculation, such as SELECT COUNT(DISTINCT posts.id) ... - # - # Examples: - # Person.calculate(:count, :all) # The same as Person.count - # Person.average(:age) # SELECT AVG(age) FROM people... - # Person.minimum(:age, :conditions => ['last_name != ?', 'Drake']) # Selects the minimum age for everyone with a last name other than 'Drake' - # Person.minimum(:age, :having => 'min(age) > 17', :group => :last_name) # Selects the minimum age for any family without any minors - # Person.sum("2 * age") - def calculate(operation, column_name, options = {}) - validate_calculation_options(operation, options) - column_name = options[:select] if options[:select] - column_name = '*' if column_name == :all - column = column_for column_name - catch :invalid_query do - if options[:group] - return execute_grouped_calculation(operation, column_name, column, options) - else - return execute_simple_calculation(operation, column_name, column, options) - end - end - 0 - end - - protected - def construct_count_options_from_args(*args) - options = {} - column_name = :all - - # We need to handle - # count() - # count(:column_name=:all) - # count(options={}) - # count(column_name=:all, options={}) - case args.size - when 1 - args[0].is_a?(Hash) ? options = args[0] : column_name = args[0] - when 2 - column_name, options = args - else - raise ArgumentError, "Unexpected parameters passed to count(): #{args.inspect}" - end if args.size > 0 - - [column_name, options] - end - - def construct_calculation_sql(operation, column_name, options) #:nodoc: - operation = operation.to_s.downcase - options = options.symbolize_keys - - scope = scope(:find) - merged_includes = merge_includes(scope ? scope[:include] : [], options[:include]) - aggregate_alias = column_alias_for(operation, column_name) - column_name = "#{connection.quote_table_name(table_name)}.#{column_name}" if column_names.include?(column_name.to_s) - - if operation == 'count' - if merged_includes.any? - options[:distinct] = true - column_name = options[:select] || [connection.quote_table_name(table_name), primary_key] * '.' - end - - if options[:distinct] - use_workaround = !connection.supports_count_distinct? - end - end - - if options[:distinct] && column_name.to_s !~ /\s*DISTINCT\s+/i - distinct = 'DISTINCT ' - end - sql = "SELECT #{operation}(#{distinct}#{column_name}) AS #{aggregate_alias}" - - # A (slower) workaround if we're using a backend, like sqlite, that doesn't support COUNT DISTINCT. - sql = "SELECT COUNT(*) AS #{aggregate_alias}" if use_workaround - - options[:group_fields].each_index{|i| sql << ", #{options[:group_fields][i]} AS #{options[:group_aliases][i]}" } if options[:group] - if options[:from] - sql << " FROM #{options[:from]} " - elsif scope && scope[:from] && !use_workaround - sql << " FROM #{scope[:from]} " - else - sql << " FROM (SELECT #{distinct}#{column_name}" if use_workaround - sql << " FROM #{connection.quote_table_name(table_name)} " - end - - joins = "" - add_joins!(joins, options[:joins], scope) - - if merged_includes.any? - join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, merged_includes, joins) - sql << join_dependency.join_associations.collect{|join| join.association_join }.join - end - - sql << joins unless joins.blank? - - add_conditions!(sql, options[:conditions], scope) - add_limited_ids_condition!(sql, options, join_dependency) if join_dependency && !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - - if options[:group] - group_key = connection.adapter_name == 'FrontBase' ? :group_aliases : :group_fields - sql << " GROUP BY #{options[group_key].join(',')} " - end - - if options[:group] && options[:having] - having = sanitize_sql_for_conditions(options[:having]) - - # FrontBase requires identifiers in the HAVING clause and chokes on function calls - if connection.adapter_name == 'FrontBase' - having.downcase! - having.gsub!(/#{operation}\s*\(\s*#{column_name}\s*\)/, aggregate_alias) - end - - sql << " HAVING #{having} " - end - - sql << " ORDER BY #{options[:order]} " if options[:order] - add_limit!(sql, options, scope) - sql << ") #{aggregate_alias}_subquery" if use_workaround - sql - end - - def execute_simple_calculation(operation, column_name, column, options) #:nodoc: - value = connection.select_value(construct_calculation_sql(operation, column_name, options)) - type_cast_calculated_value(value, column, operation) - end - - def execute_grouped_calculation(operation, column_name, column, options) #:nodoc: - group_attr = options[:group] - association = reflect_on_association(group_attr.to_s.to_sym) - associated = association && association.macro == :belongs_to # only count belongs_to associations - group_fields = Array(associated ? association.primary_key_name : group_attr) - group_aliases = [] - group_columns = {} - - group_fields.each do |field| - group_aliases << column_alias_for(field) - group_columns[column_alias_for(field)] = column_for(field) - end - - sql = construct_calculation_sql(operation, column_name, options.merge(:group_fields => group_fields, :group_aliases => group_aliases)) - calculated_data = connection.select_all(sql) - aggregate_alias = column_alias_for(operation, column_name) - - if association - key_ids = calculated_data.collect { |row| row[group_aliases.first] } - key_records = association.klass.base_class.find(key_ids) - key_records = key_records.inject({}) { |hsh, r| hsh.merge(r.id => r) } - end - - calculated_data.inject(ActiveSupport::OrderedHash.new) do |all, row| - key = group_aliases.map{|group_alias| type_cast_calculated_value(row[group_alias], group_columns[group_alias])} - key = key.first if key.size == 1 - key = key_records[key] if associated - value = row[aggregate_alias] - all[key] = type_cast_calculated_value(value, column, operation) - all - end - end - - private - def validate_calculation_options(operation, options = {}) - options.assert_valid_keys(CALCULATIONS_OPTIONS) - end - - # Converts the given keys to the value that the database adapter returns as - # a usable column name: - # - # column_alias_for("users.id") # => "users_id" - # column_alias_for("sum(id)") # => "sum_id" - # column_alias_for("count(distinct users.id)") # => "count_distinct_users_id" - # column_alias_for("count(*)") # => "count_all" - # column_alias_for("count", "id") # => "count_id" - def column_alias_for(*keys) - table_name = keys.join(' ') - table_name.downcase! - table_name.gsub!(/\*/, 'all') - table_name.gsub!(/\W+/, ' ') - table_name.strip! - table_name.gsub!(/ +/, '_') - - connection.table_alias_for(table_name) - end - - def column_for(field) - field_name = field.to_s.split('.').last - columns.detect { |c| c.name.to_s == field_name } - end - - def type_cast_calculated_value(value, column, operation = nil) - if value.is_a?(String) || value.nil? - case operation.to_s.downcase - when 'count' then value.to_i - when 'sum' then type_cast_using_column(value || '0', column) - when 'avg' then value.try(:to_d) - else type_cast_using_column(value, column) - end - else - value - end - end - - def type_cast_using_column(value, column) - column ? column.type_cast(value) : value - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/callbacks.rb b/vendor/rails/activerecord/lib/active_record/callbacks.rb deleted file mode 100644 index e375037b..00000000 --- a/vendor/rails/activerecord/lib/active_record/callbacks.rb +++ /dev/null @@ -1,360 +0,0 @@ -require 'observer' - -module ActiveRecord - # Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic - # before or after an alteration of the object state. This can be used to make sure that associated and - # dependent objects are deleted when +destroy+ is called (by overwriting +before_destroy+) or to massage attributes - # before they're validated (by overwriting +before_validation+). As an example of the callbacks initiated, consider - # the <tt>Base#save</tt> call for a new record: - # - # * (-) <tt>save</tt> - # * (-) <tt>valid</tt> - # * (1) <tt>before_validation</tt> - # * (2) <tt>before_validation_on_create</tt> - # * (-) <tt>validate</tt> - # * (-) <tt>validate_on_create</tt> - # * (3) <tt>after_validation</tt> - # * (4) <tt>after_validation_on_create</tt> - # * (5) <tt>before_save</tt> - # * (6) <tt>before_create</tt> - # * (-) <tt>create</tt> - # * (7) <tt>after_create</tt> - # * (8) <tt>after_save</tt> - # - # That's a total of eight callbacks, which gives you immense power to react and prepare for each state in the - # Active Record lifecycle. The sequence for calling <tt>Base#save</tt> an existing record is similar, except that each - # <tt>_on_create</tt> callback is replaced by the corresponding <tt>_on_update</tt> callback. - # - # Examples: - # class CreditCard < ActiveRecord::Base - # # Strip everything but digits, so the user can specify "555 234 34" or - # # "5552-3434" or both will mean "55523434" - # def before_validation_on_create - # self.number = number.gsub(/[^0-9]/, "") if attribute_present?("number") - # end - # end - # - # class Subscription < ActiveRecord::Base - # before_create :record_signup - # - # private - # def record_signup - # self.signed_up_on = Date.today - # end - # end - # - # class Firm < ActiveRecord::Base - # # Destroys the associated clients and people when the firm is destroyed - # before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" } - # before_destroy { |record| Client.destroy_all "client_of = #{record.id}" } - # end - # - # == Inheritable callback queues - # - # Besides the overwritable callback methods, it's also possible to register callbacks through the use of the callback macros. - # Their main advantage is that the macros add behavior into a callback queue that is kept intact down through an inheritance - # hierarchy. Example: - # - # class Topic < ActiveRecord::Base - # before_destroy :destroy_author - # end - # - # class Reply < Topic - # before_destroy :destroy_readers - # end - # - # Now, when <tt>Topic#destroy</tt> is run only +destroy_author+ is called. When <tt>Reply#destroy</tt> is run, both +destroy_author+ and - # +destroy_readers+ are called. Contrast this to the situation where we've implemented the save behavior through overwriteable - # methods: - # - # class Topic < ActiveRecord::Base - # def before_destroy() destroy_author end - # end - # - # class Reply < Topic - # def before_destroy() destroy_readers end - # end - # - # In that case, <tt>Reply#destroy</tt> would only run +destroy_readers+ and _not_ +destroy_author+. So, use the callback macros when - # you want to ensure that a certain callback is called for the entire hierarchy, and use the regular overwriteable methods - # when you want to leave it up to each descendant to decide whether they want to call +super+ and trigger the inherited callbacks. - # - # *IMPORTANT:* In order for inheritance to work for the callback queues, you must specify the callbacks before specifying the - # associations. Otherwise, you might trigger the loading of a child before the parent has registered the callbacks and they won't - # be inherited. - # - # == Types of callbacks - # - # There are four types of callbacks accepted by the callback macros: Method references (symbol), callback objects, - # inline methods (using a proc), and inline eval methods (using a string). Method references and callback objects are the - # recommended approaches, inline methods using a proc are sometimes appropriate (such as for creating mix-ins), and inline - # eval methods are deprecated. - # - # The method reference callbacks work by specifying a protected or private method available in the object, like this: - # - # class Topic < ActiveRecord::Base - # before_destroy :delete_parents - # - # private - # def delete_parents - # self.class.delete_all "parent_id = #{id}" - # end - # end - # - # The callback objects have methods named after the callback called with the record as the only parameter, such as: - # - # class BankAccount < ActiveRecord::Base - # before_save EncryptionWrapper.new - # after_save EncryptionWrapper.new - # after_initialize EncryptionWrapper.new - # end - # - # class EncryptionWrapper - # def before_save(record) - # record.credit_card_number = encrypt(record.credit_card_number) - # end - # - # def after_save(record) - # record.credit_card_number = decrypt(record.credit_card_number) - # end - # - # alias_method :after_find, :after_save - # - # private - # def encrypt(value) - # # Secrecy is committed - # end - # - # def decrypt(value) - # # Secrecy is unveiled - # end - # end - # - # So you specify the object you want messaged on a given callback. When that callback is triggered, the object has - # a method by the name of the callback messaged. You can make these callbacks more flexible by passing in other - # initialization data such as the name of the attribute to work with: - # - # class BankAccount < ActiveRecord::Base - # before_save EncryptionWrapper.new("credit_card_number") - # after_save EncryptionWrapper.new("credit_card_number") - # after_initialize EncryptionWrapper.new("credit_card_number") - # end - # - # class EncryptionWrapper - # def initialize(attribute) - # @attribute = attribute - # end - # - # def before_save(record) - # record.send("#{@attribute}=", encrypt(record.send("#{@attribute}"))) - # end - # - # def after_save(record) - # record.send("#{@attribute}=", decrypt(record.send("#{@attribute}"))) - # end - # - # alias_method :after_find, :after_save - # - # private - # def encrypt(value) - # # Secrecy is committed - # end - # - # def decrypt(value) - # # Secrecy is unveiled - # end - # end - # - # The callback macros usually accept a symbol for the method they're supposed to run, but you can also pass a "method string", - # which will then be evaluated within the binding of the callback. Example: - # - # class Topic < ActiveRecord::Base - # before_destroy 'self.class.delete_all "parent_id = #{id}"' - # end - # - # Notice that single quotes (') are used so the <tt>#{id}</tt> part isn't evaluated until the callback is triggered. Also note that these - # inline callbacks can be stacked just like the regular ones: - # - # class Topic < ActiveRecord::Base - # before_destroy 'self.class.delete_all "parent_id = #{id}"', - # 'puts "Evaluated after parents are destroyed"' - # end - # - # == The +after_find+ and +after_initialize+ exceptions - # - # Because +after_find+ and +after_initialize+ are called for each object found and instantiated by a finder, such as <tt>Base.find(:all)</tt>, we've had - # to implement a simple performance constraint (50% more speed on a simple test case). Unlike all the other callbacks, +after_find+ and - # +after_initialize+ will only be run if an explicit implementation is defined (<tt>def after_find</tt>). In that case, all of the - # callback types will be called. - # - # == <tt>before_validation*</tt> returning statements - # - # If the returning value of a +before_validation+ callback can be evaluated to +false+, the process will be aborted and <tt>Base#save</tt> will return +false+. - # If Base#save! is called it will raise a ActiveRecord::RecordInvalid exception. - # Nothing will be appended to the errors object. - # - # == Canceling callbacks - # - # If a <tt>before_*</tt> callback returns +false+, all the later callbacks and the associated action are cancelled. If an <tt>after_*</tt> callback returns - # +false+, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks - # defined as methods on the model, which are called last. - # - # == Transactions - # - # The entire callback chain of a +save+, <tt>save!</tt>, or +destroy+ call runs - # within a transaction. That includes <tt>after_*</tt> hooks. If everything - # goes fine a COMMIT is executed once the chain has been completed. - # - # If a <tt>before_*</tt> callback cancels the action a ROLLBACK is issued. You - # can also trigger a ROLLBACK raising an exception in any of the callbacks, - # including <tt>after_*</tt> hooks. Note, however, that in that case the client - # needs to be aware of it because an ordinary +save+ will raise such exception - # instead of quietly returning +false+. - module Callbacks - CALLBACKS = %w( - after_find after_initialize before_save after_save before_create after_create before_update after_update before_validation - after_validation before_validation_on_create after_validation_on_create before_validation_on_update - after_validation_on_update before_destroy after_destroy - ) - - def self.included(base) #:nodoc: - base.extend Observable - - [:create_or_update, :valid?, :create, :update, :destroy].each do |method| - base.send :alias_method_chain, method, :callbacks - end - - base.send :include, ActiveSupport::Callbacks - base.define_callbacks *CALLBACKS - end - - # Is called when the object was instantiated by one of the finders, like <tt>Base.find</tt>. - #def after_find() end - - # Is called after the object has been instantiated by a call to <tt>Base.new</tt>. - #def after_initialize() end - - # Is called _before_ <tt>Base.save</tt> (regardless of whether it's a +create+ or +update+ save). - def before_save() end - - # Is called _after_ <tt>Base.save</tt> (regardless of whether it's a +create+ or +update+ save). - # Note that this callback is still wrapped in the transaction around +save+. For example, if you - # invoke an external indexer at this point it won't see the changes in the database. - # - # class Contact < ActiveRecord::Base - # after_save { logger.info( 'New contact saved!' ) } - # end - def after_save() end - def create_or_update_with_callbacks #:nodoc: - return false if callback(:before_save) == false - if result = create_or_update_without_callbacks - callback(:after_save) - end - result - end - private :create_or_update_with_callbacks - - # Is called _before_ <tt>Base.save</tt> on new objects that haven't been saved yet (no record exists). - def before_create() end - - # Is called _after_ <tt>Base.save</tt> on new objects that haven't been saved yet (no record exists). - # Note that this callback is still wrapped in the transaction around +save+. For example, if you - # invoke an external indexer at this point it won't see the changes in the database. - def after_create() end - def create_with_callbacks #:nodoc: - return false if callback(:before_create) == false - result = create_without_callbacks - callback(:after_create) - result - end - private :create_with_callbacks - - # Is called _before_ <tt>Base.save</tt> on existing objects that have a record. - def before_update() end - - # Is called _after_ <tt>Base.save</tt> on existing objects that have a record. - # Note that this callback is still wrapped in the transaction around +save+. For example, if you - # invoke an external indexer at this point it won't see the changes in the database. - def after_update() end - - def update_with_callbacks(*args) #:nodoc: - return false if callback(:before_update) == false - result = update_without_callbacks(*args) - callback(:after_update) - result - end - private :update_with_callbacks - - # Is called _before_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call). - def before_validation() end - - # Is called _after_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call). - def after_validation() end - - # Is called _before_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on new objects - # that haven't been saved yet (no record exists). - def before_validation_on_create() end - - # Is called _after_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on new objects - # that haven't been saved yet (no record exists). - def after_validation_on_create() end - - # Is called _before_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on - # existing objects that have a record. - def before_validation_on_update() end - - # Is called _after_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on - # existing objects that have a record. - def after_validation_on_update() end - - def valid_with_callbacks? #:nodoc: - return false if callback(:before_validation) == false - if new_record? then result = callback(:before_validation_on_create) else result = callback(:before_validation_on_update) end - return false if false == result - - result = valid_without_callbacks? - - callback(:after_validation) - if new_record? then callback(:after_validation_on_create) else callback(:after_validation_on_update) end - - return result - end - - # Is called _before_ <tt>Base.destroy</tt>. - # - # Note: If you need to _destroy_ or _nullify_ associated records first, - # use the <tt>:dependent</tt> option on your associations. - def before_destroy() end - - # Is called _after_ <tt>Base.destroy</tt> (and all the attributes have been frozen). - # - # class Contact < ActiveRecord::Base - # after_destroy { |record| logger.info( "Contact #{record.id} was destroyed." ) } - # end - def after_destroy() end - def destroy_with_callbacks #:nodoc: - return false if callback(:before_destroy) == false - result = destroy_without_callbacks - callback(:after_destroy) - result - end - - private - def callback(method) - result = run_callbacks(method) { |result, object| false == result } - - if result != false && respond_to_without_attributes?(method) - result = send(method) - end - - notify(method) - - return result - end - - def notify(method) #:nodoc: - self.class.changed - self.class.notify_observers(method, self) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb deleted file mode 100644 index aac84cc5..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ /dev/null @@ -1,371 +0,0 @@ -require 'monitor' -require 'set' - -module ActiveRecord - # Raised when a connection could not be obtained within the connection - # acquisition timeout period. - class ConnectionTimeoutError < ConnectionNotEstablished - end - - module ConnectionAdapters - # Connection pool base class for managing ActiveRecord database - # connections. - # - # == Introduction - # - # A connection pool synchronizes thread access to a limited number of - # database connections. The basic idea is that each thread checks out a - # database connection from the pool, uses that connection, and checks the - # connection back in. ConnectionPool is completely thread-safe, and will - # ensure that a connection cannot be used by two threads at the same time, - # as long as ConnectionPool's contract is correctly followed. It will also - # handle cases in which there are more threads than connections: if all - # connections have been checked out, and a thread tries to checkout a - # connection anyway, then ConnectionPool will wait until some other thread - # has checked in a connection. - # - # == Obtaining (checking out) a connection - # - # Connections can be obtained and used from a connection pool in several - # ways: - # - # 1. Simply use ActiveRecord::Base.connection as with ActiveRecord 2.1 and - # earlier (pre-connection-pooling). Eventually, when you're done with - # the connection(s) and wish it to be returned to the pool, you call - # ActiveRecord::Base.clear_active_connections!. This will be the - # default behavior for ActiveRecord when used in conjunction with - # ActionPack's request handling cycle. - # 2. Manually check out a connection from the pool with - # ActiveRecord::Base.connection_pool.checkout. You are responsible for - # returning this connection to the pool when finished by calling - # ActiveRecord::Base.connection_pool.checkin(connection). - # 3. Use ActiveRecord::Base.connection_pool.with_connection(&block), which - # obtains a connection, yields it as the sole argument to the block, - # and returns it to the pool after the block completes. - # - # Connections in the pool are actually AbstractAdapter objects (or objects - # compatible with AbstractAdapter's interface). - # - # == Options - # - # There are two connection-pooling-related options that you can add to - # your database connection configuration: - # - # * +pool+: number indicating size of connection pool (default 5) - # * +wait_timeout+: number of seconds to block and wait for a connection - # before giving up and raising a timeout error (default 5 seconds). - class ConnectionPool - attr_reader :spec - - # Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification - # object which describes database connection information (e.g. adapter, - # host name, username, password, etc), as well as the maximum size for - # this ConnectionPool. - # - # The default ConnectionPool maximum size is 5. - def initialize(spec) - @spec = spec - - # The cache of reserved connections mapped to threads - @reserved_connections = {} - - # The mutex used to synchronize pool access - @connection_mutex = Monitor.new - @queue = @connection_mutex.new_cond - - # default 5 second timeout unless on ruby 1.9 - @timeout = - if RUBY_VERSION < '1.9' - spec.config[:wait_timeout] || 5 - end - - # default max pool size to 5 - @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5 - - @connections = [] - @checked_out = [] - end - - # Retrieve the connection associated with the current thread, or call - # #checkout to obtain one if necessary. - # - # #connection can be called any number of times; the connection is - # held in a hash keyed by the thread id. - def connection - if conn = @reserved_connections[current_connection_id] - conn - else - @reserved_connections[current_connection_id] = checkout - end - end - - # Signal that the thread is finished with the current connection. - # #release_connection releases the connection-thread association - # and returns the connection to the pool. - def release_connection - conn = @reserved_connections.delete(current_connection_id) - checkin conn if conn - end - - # Reserve a connection, and yield it to a block. Ensure the connection is - # checked back in when finished. - def with_connection - conn = checkout - yield conn - ensure - checkin conn - end - - # Returns true if a connection has already been opened. - def connected? - !@connections.empty? - end - - # Disconnects all connections in the pool, and clears the pool. - def disconnect! - @reserved_connections.each do |name,conn| - checkin conn - end - @reserved_connections = {} - @connections.each do |conn| - conn.disconnect! - end - @connections = [] - end - - # Clears the cache which maps classes - def clear_reloadable_connections! - @reserved_connections.each do |name, conn| - checkin conn - end - @reserved_connections = {} - @connections.each do |conn| - conn.disconnect! if conn.requires_reloading? - end - @connections = [] - end - - # Verify active connections and remove and disconnect connections - # associated with stale threads. - def verify_active_connections! #:nodoc: - clear_stale_cached_connections! - @connections.each do |connection| - connection.verify! - end - end - - # Return any checked-out connections back to the pool by threads that - # are no longer alive. - def clear_stale_cached_connections! - remove_stale_cached_threads!(@reserved_connections) do |name, conn| - checkin conn - end - end - - # Check-out a database connection from the pool, indicating that you want - # to use it. You should call #checkin when you no longer need this. - # - # This is done by either returning an existing connection, or by creating - # a new connection. If the maximum number of connections for this pool has - # already been reached, but the pool is empty (i.e. they're all being used), - # then this method will wait until a thread has checked in a connection. - # The wait time is bounded however: if no connection can be checked out - # within the timeout specified for this pool, then a ConnectionTimeoutError - # exception will be raised. - # - # Returns: an AbstractAdapter object. - # - # Raises: - # - ConnectionTimeoutError: no connection can be obtained from the pool - # within the timeout period. - def checkout - # Checkout an available connection - @connection_mutex.synchronize do - loop do - conn = if @checked_out.size < @connections.size - checkout_existing_connection - elsif @connections.size < @size - checkout_new_connection - end - return conn if conn - # No connections available; wait for one - if @queue.wait(@timeout) - next - else - # try looting dead threads - clear_stale_cached_connections! - if @size == @checked_out.size - raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it." - end - end - end - end - end - - # Check-in a database connection back into the pool, indicating that you - # no longer need this connection. - # - # +conn+: an AbstractAdapter object, which was obtained by earlier by - # calling +checkout+ on this pool. - def checkin(conn) - @connection_mutex.synchronize do - conn.run_callbacks :checkin - @checked_out.delete conn - @queue.signal - end - end - - synchronize :clear_reloadable_connections!, :verify_active_connections!, - :connected?, :disconnect!, :with => :@connection_mutex - - private - def new_connection - ActiveRecord::Base.send(spec.adapter_method, spec.config) - end - - def current_connection_id #:nodoc: - Thread.current.object_id - end - - # Remove stale threads from the cache. - def remove_stale_cached_threads!(cache, &block) - keys = Set.new(cache.keys) - - Thread.list.each do |thread| - keys.delete(thread.object_id) if thread.alive? - end - keys.each do |key| - next unless cache.has_key?(key) - block.call(key, cache[key]) - cache.delete(key) - end - end - - def checkout_new_connection - c = new_connection - @connections << c - checkout_and_verify(c) - end - - def checkout_existing_connection - c = (@connections - @checked_out).first - checkout_and_verify(c) - end - - def checkout_and_verify(c) - c.verify! - c.run_callbacks :checkout - @checked_out << c - c - end - end - - # ConnectionHandler is a collection of ConnectionPool objects. It is used - # for keeping separate connection pools for ActiveRecord models that connect - # to different databases. - # - # For example, suppose that you have 5 models, with the following hierarchy: - # - # | - # +-- Book - # | | - # | +-- ScaryBook - # | +-- GoodBook - # +-- Author - # +-- BankAccount - # - # Suppose that Book is to connect to a separate database (i.e. one other - # than the default database). Then Book, ScaryBook and GoodBook will all use - # the same connection pool. Likewise, Author and BankAccount will use the - # same connection pool. However, the connection pool used by Author/BankAccount - # is not the same as the one used by Book/ScaryBook/GoodBook. - # - # Normally there is only a single ConnectionHandler instance, accessible via - # ActiveRecord::Base.connection_handler. ActiveRecord models use this to - # determine that connection pool that they should use. - class ConnectionHandler - def initialize(pools = {}) - @connection_pools = pools - end - - def connection_pools - @connection_pools ||= {} - end - - def establish_connection(name, spec) - @connection_pools[name] = ConnectionAdapters::ConnectionPool.new(spec) - end - - # Returns any connections in use by the current thread back to the pool, - # and also returns connections to the pool cached by threads that are no - # longer alive. - def clear_active_connections! - @connection_pools.each_value {|pool| pool.release_connection } - end - - # Clears the cache which maps classes - def clear_reloadable_connections! - @connection_pools.each_value {|pool| pool.clear_reloadable_connections! } - end - - def clear_all_connections! - @connection_pools.each_value {|pool| pool.disconnect! } - end - - # Verify active connections. - def verify_active_connections! #:nodoc: - @connection_pools.each_value {|pool| pool.verify_active_connections! } - end - - # Locate the connection of the nearest super class. This can be an - # active or defined connection: if it is the latter, it will be - # opened and set as the active connection for the class it was defined - # for (not necessarily the current class). - def retrieve_connection(klass) #:nodoc: - pool = retrieve_connection_pool(klass) - (pool && pool.connection) or raise ConnectionNotEstablished - end - - # Returns true if a connection that's accessible to this class has - # already been opened. - def connected?(klass) - conn = retrieve_connection_pool(klass) - conn ? conn.connected? : false - end - - # Remove the connection for this class. This will close the active - # connection and the defined connection (if they exist). The result - # can be used as an argument for establish_connection, for easily - # re-establishing the connection. - def remove_connection(klass) - pool = @connection_pools[klass.name] - @connection_pools.delete_if { |key, value| value == pool } - pool.disconnect! if pool - pool.spec.config if pool - end - - def retrieve_connection_pool(klass) - pool = @connection_pools[klass.name] - return pool if pool - return nil if ActiveRecord::Base == klass - retrieve_connection_pool klass.superclass - end - end - - class ConnectionManagement - def initialize(app) - @app = app - end - - def call(env) - @app.call(env) - ensure - # Don't return connection (and peform implicit rollback) if - # this request is a part of integration test - unless env.key?("rack.test") - ActiveRecord::Base.clear_active_connections! - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb deleted file mode 100644 index 535498f1..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ /dev/null @@ -1,139 +0,0 @@ -module ActiveRecord - class Base - class ConnectionSpecification #:nodoc: - attr_reader :config, :adapter_method - def initialize (config, adapter_method) - @config, @adapter_method = config, adapter_method - end - end - - ## - # :singleton-method: - # The connection handler - class_attribute :connection_handler - self.connection_handler = ConnectionAdapters::ConnectionHandler.new - - # Returns the connection currently associated with the class. This can - # also be used to "borrow" the connection to do database work that isn't - # easily done without going straight to SQL. - def connection - self.class.connection - end - - # Establishes the connection to the database. Accepts a hash as input where - # the <tt>:adapter</tt> key must be specified with the name of a database adapter (in lower-case) - # example for regular databases (MySQL, Postgresql, etc): - # - # ActiveRecord::Base.establish_connection( - # :adapter => "mysql", - # :host => "localhost", - # :username => "myuser", - # :password => "mypass", - # :database => "somedatabase" - # ) - # - # Example for SQLite database: - # - # ActiveRecord::Base.establish_connection( - # :adapter => "sqlite", - # :database => "path/to/dbfile" - # ) - # - # Also accepts keys as strings (for parsing from YAML for example): - # - # ActiveRecord::Base.establish_connection( - # "adapter" => "sqlite", - # "database" => "path/to/dbfile" - # ) - # - # The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError - # may be returned on an error. - def self.establish_connection(spec = nil) - case spec - when nil - raise AdapterNotSpecified unless defined? RAILS_ENV - establish_connection(RAILS_ENV) - when ConnectionSpecification - self.connection_handler.establish_connection(name, spec) - when Symbol, String - if configuration = configurations[spec.to_s] - establish_connection(configuration) - else - raise AdapterNotSpecified, "#{spec} database is not configured" - end - else - spec = spec.symbolize_keys - unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end - - begin - require 'rubygems' - gem "activerecord-#{spec[:adapter]}-adapter" - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" - rescue LoadError - begin - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" - rescue LoadError - raise "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{$!})" - end - end - - adapter_method = "#{spec[:adapter]}_connection" - if !respond_to?(adapter_method) - raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" - end - - remove_connection - establish_connection(ConnectionSpecification.new(spec, adapter_method)) - end - end - - class << self - # Deprecated and no longer has any effect. - def allow_concurrency - ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency has been deprecated and no longer has any effect. Please remove all references to allow_concurrency.") - end - - # Deprecated and no longer has any effect. - def allow_concurrency=(flag) - ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency= has been deprecated and no longer has any effect. Please remove all references to allow_concurrency=.") - end - - # Deprecated and no longer has any effect. - def verification_timeout - ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout has been deprecated and no longer has any effect. Please remove all references to verification_timeout.") - end - - # Deprecated and no longer has any effect. - def verification_timeout=(flag) - ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout= has been deprecated and no longer has any effect. Please remove all references to verification_timeout=.") - end - - # Returns the connection currently associated with the class. This can - # also be used to "borrow" the connection to do database work unrelated - # to any of the specific Active Records. - def connection - retrieve_connection - end - - def connection_pool - connection_handler.retrieve_connection_pool(self) - end - - def retrieve_connection - connection_handler.retrieve_connection(self) - end - - # Returns true if +ActiveRecord+ is connected. - def connected? - connection_handler.connected?(self) - end - - def remove_connection(klass = self) - connection_handler.remove_connection(klass) - end - - delegate :clear_active_connections!, :clear_reloadable_connections!, - :clear_all_connections!,:verify_active_connections!, :to => :connection_handler - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_limits.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_limits.rb deleted file mode 100644 index 4118ea7b..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_limits.rb +++ /dev/null @@ -1,57 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module DatabaseLimits - - # the maximum length of a table alias - def table_alias_length - 255 - end - - # the maximum length of a column name - def column_name_length - 64 - end - - # the maximum length of a table name - def table_name_length - 64 - end - - # the maximum length of an index name - def index_name_length - 64 - end - - # the maximum number of columns per table - def columns_per_table - 1024 - end - - # the maximum number of indexes per table - def indexes_per_table - 16 - end - - # the maximum number of columns in a multicolumn index - def columns_per_multicolumn_index - 16 - end - - # the maximum number of elements in an IN (x,y,z) clause - def in_clause_length - 65535 - end - - # the maximum length of a SQL query - def sql_query_length - 1048575 - end - - # maximum number of joins in a single query - def joins_per_query - 256 - end - - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb deleted file mode 100644 index 08601da0..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ /dev/null @@ -1,289 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module DatabaseStatements - # Returns an array of record hashes with the column names as keys and - # column values as values. - def select_all(sql, name = nil) - select(sql, name) - end - - # Returns a record hash with the column names as keys and column values - # as values. - def select_one(sql, name = nil) - result = select_all(sql, name) - result.first if result - end - - # Returns a single value from a record - def select_value(sql, name = nil) - if result = select_one(sql, name) - result.values.first - end - end - - # Returns an array of the values of the first column in a select: - # select_values("SELECT id FROM companies LIMIT 3") => [1,2,3] - def select_values(sql, name = nil) - result = select_rows(sql, name) - result.map { |v| v[0] } - end - - # Returns an array of arrays containing the field values. - # Order is the same as that returned by +columns+. - def select_rows(sql, name = nil) - end - undef_method :select_rows - - # Executes the SQL statement in the context of this connection. - def execute(sql, name = nil, skip_logging = false) - end - undef_method :execute - - # Returns the last auto-generated ID from the affected table. - def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - insert_sql(sql, name, pk, id_value, sequence_name) - end - - # Executes the update statement and returns the number of rows affected. - def update(sql, name = nil) - update_sql(sql, name) - end - - # Executes the delete statement and returns the number of rows affected. - def delete(sql, name = nil) - delete_sql(sql, name) - end - - # Checks whether there is currently no transaction active. This is done - # by querying the database driver, and does not use the transaction - # house-keeping information recorded by #increment_open_transactions and - # friends. - # - # Returns true if there is no transaction active, false if there is a - # transaction active, and nil if this information is unknown. - # - # Not all adapters supports transaction state introspection. Currently, - # only the PostgreSQL adapter supports this. - def outside_transaction? - nil - end - - # Runs the given block in a database transaction, and returns the result - # of the block. - # - # == Nested transactions support - # - # Most databases don't support true nested transactions. At the time of - # writing, the only database that supports true nested transactions that - # we're aware of, is MS-SQL. - # - # In order to get around this problem, #transaction will emulate the effect - # of nested transactions, by using savepoints: - # http://dev.mysql.com/doc/refman/5.0/en/savepoints.html - # Savepoints are supported by MySQL and PostgreSQL, but not SQLite3. - # - # It is safe to call this method if a database transaction is already open, - # i.e. if #transaction is called within another #transaction block. In case - # of a nested call, #transaction will behave as follows: - # - # - The block will be run without doing anything. All database statements - # that happen within the block are effectively appended to the already - # open database transaction. - # - However, if +:requires_new+ is set, the block will be wrapped in a - # database savepoint acting as a sub-transaction. - # - # === Caveats - # - # MySQL doesn't support DDL transactions. If you perform a DDL operation, - # then any created savepoints will be automatically released. For example, - # if you've created a savepoint, then you execute a CREATE TABLE statement, - # then the savepoint that was created will be automatically released. - # - # This means that, on MySQL, you shouldn't execute DDL operations inside - # a #transaction call that you know might create a savepoint. Otherwise, - # #transaction will raise exceptions when it tries to release the - # already-automatically-released savepoints: - # - # Model.connection.transaction do # BEGIN - # Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1 - # Model.connection.create_table(...) - # # active_record_1 now automatically released - # end # RELEASE SAVEPOINT active_record_1 <--- BOOM! database error! - # end - def transaction(options = {}) - options.assert_valid_keys :requires_new, :joinable - - last_transaction_joinable = @transaction_joinable - if options.has_key?(:joinable) - @transaction_joinable = options[:joinable] - else - @transaction_joinable = true - end - requires_new = options[:requires_new] || !last_transaction_joinable - - transaction_open = false - begin - if block_given? - if requires_new || open_transactions == 0 - if open_transactions == 0 - begin_db_transaction - elsif requires_new - create_savepoint - end - increment_open_transactions - transaction_open = true - end - yield - end - rescue Exception => database_transaction_rollback - if transaction_open && !outside_transaction? - transaction_open = false - decrement_open_transactions - if open_transactions == 0 - rollback_db_transaction - else - rollback_to_savepoint - end - end - raise unless database_transaction_rollback.is_a?(ActiveRecord::Rollback) - end - ensure - @transaction_joinable = last_transaction_joinable - - if outside_transaction? - @open_transactions = 0 - elsif transaction_open - decrement_open_transactions - begin - if open_transactions == 0 - commit_db_transaction - else - release_savepoint - end - rescue Exception => database_transaction_rollback - if open_transactions == 0 - rollback_db_transaction - else - rollback_to_savepoint - end - raise - end - end - end - - # Begins the transaction (and turns off auto-committing). - def begin_db_transaction() end - - # Commits the transaction (and turns on auto-committing). - def commit_db_transaction() end - - # Rolls back the transaction (and turns on auto-committing). Must be - # done if the transaction block raises an exception or returns false. - def rollback_db_transaction() end - - # Alias for <tt>add_limit_offset!</tt>. - def add_limit!(sql, options) - add_limit_offset!(sql, options) if options - end - - # Appends +LIMIT+ and +OFFSET+ options to an SQL statement, or some SQL - # fragment that has the same semantics as LIMIT and OFFSET. - # - # +options+ must be a Hash which contains a +:limit+ option (required) - # and an +:offset+ option (optional). - # - # This method *modifies* the +sql+ parameter. - # - # ===== Examples - # add_limit_offset!('SELECT * FROM suppliers', {:limit => 10, :offset => 50}) - # generates - # SELECT * FROM suppliers LIMIT 10 OFFSET 50 - def add_limit_offset!(sql, options) - if limit = options[:limit] - sql << " LIMIT #{sanitize_limit(limit)}" - if offset = options[:offset] - sql << " OFFSET #{offset.to_i}" - end - end - sql - end - - # Appends a locking clause to an SQL statement. - # This method *modifies* the +sql+ parameter. - # # SELECT * FROM suppliers FOR UPDATE - # add_lock! 'SELECT * FROM suppliers', :lock => true - # add_lock! 'SELECT * FROM suppliers', :lock => ' FOR UPDATE' - def add_lock!(sql, options) - case lock = options[:lock] - when true; sql << ' FOR UPDATE' - when String; sql << " #{lock}" - end - end - - def default_sequence_name(table, column) - nil - end - - # Set the sequence to the max value of the table's column. - def reset_sequence!(table, column, sequence = nil) - # Do nothing by default. Implement for PostgreSQL, Oracle, ... - end - - # Inserts the given fixture into the table. Overridden in adapters that require - # something beyond a simple insert (eg. Oracle). - def insert_fixture(fixture, table_name) - execute "INSERT INTO #{quote_table_name(table_name)} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert' - end - - def empty_insert_statement(table_name) - "INSERT INTO #{quote_table_name(table_name)} VALUES(DEFAULT)" - end - - def case_sensitive_equality_operator - "=" - end - - def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key) - "WHERE #{quoted_primary_key} IN (SELECT #{quoted_primary_key} FROM #{quoted_table_name} #{where_sql})" - end - - protected - # Returns an array of record hashes with the column names as keys and - # column values as values. - def select(sql, name = nil) - end - undef_method :select - - # Returns the last auto-generated ID from the affected table. - def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - execute(sql, name) - id_value - end - - # Executes the update statement and returns the number of rows affected. - def update_sql(sql, name = nil) - execute(sql, name) - end - - # Executes the delete statement and returns the number of rows affected. - def delete_sql(sql, name = nil) - update_sql(sql, name) - end - - # Sanitizes the given LIMIT parameter in order to prevent SQL injection. - # - # +limit+ may be anything that can evaluate to a string via #to_s. It - # should look like an integer, or a comma-delimited list of integers. - # - # Returns the sanitized limit parameter, either as an integer, or as a - # string which contains a comma-delimited list of integers. - def sanitize_limit(limit) - if limit.to_s =~ /,/ - limit.to_s.split(',').map{ |i| i.to_i }.join(',') - else - limit.to_i - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb deleted file mode 100644 index 166c17b5..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +++ /dev/null @@ -1,94 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module QueryCache - class << self - def included(base) - base.class_eval do - alias_method_chain :columns, :query_cache - alias_method_chain :select_all, :query_cache - end - - dirties_query_cache base, :insert, :update, :delete - end - - def dirties_query_cache(base, *method_names) - method_names.each do |method_name| - base.class_eval <<-end_code, __FILE__, __LINE__ + 1 - def #{method_name}_with_query_dirty(*args) # def update_with_query_dirty(*args) - clear_query_cache if @query_cache_enabled # clear_query_cache if @query_cache_enabled - #{method_name}_without_query_dirty(*args) # update_without_query_dirty(*args) - end # end - # - alias_method_chain :#{method_name}, :query_dirty # alias_method_chain :update, :query_dirty - end_code - end - end - end - - attr_reader :query_cache, :query_cache_enabled - - # Enable the query cache within the block. - def cache - old, @query_cache_enabled = @query_cache_enabled, true - @query_cache ||= {} - yield - ensure - clear_query_cache - @query_cache_enabled = old - end - - # Disable the query cache within the block. - def uncached - old, @query_cache_enabled = @query_cache_enabled, false - yield - ensure - @query_cache_enabled = old - end - - # Clears the query cache. - # - # One reason you may wish to call this method explicitly is between queries - # that ask the database to randomize results. Otherwise the cache would see - # the same SQL query and repeatedly return the same result each time, silently - # undermining the randomness you were expecting. - def clear_query_cache - @query_cache.clear if @query_cache - end - - def select_all_with_query_cache(*args) - if @query_cache_enabled - cache_sql(args.first) { select_all_without_query_cache(*args) } - else - select_all_without_query_cache(*args) - end - end - - def columns_with_query_cache(*args) - if @query_cache_enabled - @query_cache["SHOW FIELDS FROM #{args.first}"] ||= columns_without_query_cache(*args) - else - columns_without_query_cache(*args) - end - end - - private - def cache_sql(sql) - result = - if @query_cache.has_key?(sql) - log_info(sql, "CACHE", 0.0) - @query_cache[sql] - else - @query_cache[sql] = yield - end - - if Array === result - result.collect { |row| row.dup } - else - result.duplicable? ? result.dup : result - end - rescue TypeError - result - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb deleted file mode 100644 index 50a1f700..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ /dev/null @@ -1,65 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module Quoting - # Quotes the column value to help prevent - # {SQL injection attacks}[http://en.wikipedia.org/wiki/SQL_injection]. - def quote(value, column = nil) - # records are quoted as their primary key - return value.quoted_id if value.respond_to?(:quoted_id) - - case value - when String, ActiveSupport::Multibyte::Chars - value = value.to_s - if column && column.type == :binary && column.class.respond_to?(:string_to_binary) - "'#{quote_string(column.class.string_to_binary(value))}'" # ' (for ruby-mode) - elsif column && [:integer, :float].include?(column.type) - value = column.type == :integer ? value.to_i : value.to_f - value.to_s - else - "'#{quote_string(value)}'" # ' (for ruby-mode) - end - when NilClass then "NULL" - when TrueClass then (column && column.type == :integer ? '1' : quoted_true) - when FalseClass then (column && column.type == :integer ? '0' : quoted_false) - when Float, Fixnum, Bignum then value.to_s - # BigDecimals need to be output in a non-normalized form and quoted. - when BigDecimal then value.to_s('F') - else - if value.acts_like?(:date) || value.acts_like?(:time) - "'#{quoted_date(value)}'" - else - "'#{quote_string(value.to_yaml)}'" - end - end - end - - # Quotes a string, escaping any ' (single quote) and \ (backslash) - # characters. - def quote_string(s) - s.gsub(/\\/, '\&\&').gsub(/'/, "''") # ' (for ruby-mode) - end - - # Quotes the column name. Defaults to no quoting. - def quote_column_name(column_name) - column_name - end - - # Quotes the table name. Defaults to column name quoting. - def quote_table_name(table_name) - quote_column_name(table_name) - end - - def quoted_true - "'t'" - end - - def quoted_false - "'f'" - end - - def quoted_date(value) - value.to_s(:db) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb deleted file mode 100644 index 399a2721..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ /dev/null @@ -1,722 +0,0 @@ -require 'date' -require 'set' -require 'bigdecimal' -require 'bigdecimal/util' - -module ActiveRecord - module ConnectionAdapters #:nodoc: - # An abstract definition of a column in a table. - class Column - TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set - FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set - - module Format - ISO_DATE = /\A(\d{4})-(\d\d)-(\d\d)\z/ - ISO_DATETIME = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/ - end - - attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale - attr_accessor :primary - - # Instantiates a new column in the table. - # - # +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int(11)</tt>. - # +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>. - # +sql_type+ is only used to extract the column's length, if necessary. For example +60+ in <tt>company_name varchar(60)</tt>. - # +null+ determines if this column allows +NULL+ values. - def initialize(name, default, sql_type = nil, null = true) - @name, @sql_type, @null = name, sql_type, null - @limit, @precision, @scale = extract_limit(sql_type), extract_precision(sql_type), extract_scale(sql_type) - @type = simplified_type(sql_type) - @default = extract_default(default) - - @primary = nil - end - - # Returns +true+ if the column is either of type string or text. - def text? - type == :string || type == :text - end - - # Returns +true+ if the column is either of type integer, float or decimal. - def number? - type == :integer || type == :float || type == :decimal - end - - def has_default? - !default.nil? - end - - # Returns the Ruby class that corresponds to the abstract data type. - def klass - case type - when :integer then Fixnum - when :float then Float - when :decimal then BigDecimal - when :datetime then Time - when :date then Date - when :timestamp then Time - when :time then Time - when :text, :string then String - when :binary then String - when :boolean then Object - end - end - - # Casts value (which is a String) to an appropriate instance. - def type_cast(value) - return nil if value.nil? - case type - when :string then value - when :text then value - when :integer then value.to_i rescue value ? 1 : 0 - when :float then value.to_f - when :decimal then self.class.value_to_decimal(value) - when :datetime then self.class.string_to_time(value) - when :timestamp then self.class.string_to_time(value) - when :time then self.class.string_to_dummy_time(value) - when :date then self.class.string_to_date(value) - when :binary then self.class.binary_to_string(value) - when :boolean then self.class.value_to_boolean(value) - else value - end - end - - def type_cast_code(var_name) - case type - when :string then nil - when :text then nil - when :integer then "(#{var_name}.to_i rescue #{var_name} ? 1 : 0)" - when :float then "#{var_name}.to_f" - when :decimal then "#{self.class.name}.value_to_decimal(#{var_name})" - when :datetime then "#{self.class.name}.string_to_time(#{var_name})" - when :timestamp then "#{self.class.name}.string_to_time(#{var_name})" - when :time then "#{self.class.name}.string_to_dummy_time(#{var_name})" - when :date then "#{self.class.name}.string_to_date(#{var_name})" - when :binary then "#{self.class.name}.binary_to_string(#{var_name})" - when :boolean then "#{self.class.name}.value_to_boolean(#{var_name})" - else nil - end - end - - # Returns the human name of the column name. - # - # ===== Examples - # Column.new('sales_stage', ...).human_name # => 'Sales stage' - def human_name - Base.human_attribute_name(@name) - end - - def extract_default(default) - type_cast(default) - end - - class << self - # Used to convert from Strings to BLOBs - def string_to_binary(value) - value - end - - # Used to convert from BLOBs to Strings - def binary_to_string(value) - value - end - - def string_to_date(string) - return string unless string.is_a?(String) - return nil if string.empty? - - fast_string_to_date(string) || fallback_string_to_date(string) - end - - def string_to_time(string) - return string unless string.is_a?(String) - return nil if string.empty? - - fast_string_to_time(string) || fallback_string_to_time(string) - end - - def string_to_dummy_time(string) - return string unless string.is_a?(String) - return nil if string.empty? - - string_to_time "2000-01-01 #{string}" - end - - # convert something to a boolean - def value_to_boolean(value) - if value.is_a?(String) && value.blank? - nil - else - TRUE_VALUES.include?(value) - end - end - - # convert something to a BigDecimal - def value_to_decimal(value) - # Using .class is faster than .is_a? and - # subclasses of BigDecimal will be handled - # in the else clause - if value.class == BigDecimal - value - elsif value.respond_to?(:to_d) - value.to_d - else - value.to_s.to_d - end - end - - protected - # '0.123456' -> 123456 - # '1.123456' -> 123456 - def microseconds(time) - ((time[:sec_fraction].to_f % 1) * 1_000_000).to_i - end - - def new_date(year, mon, mday) - if year && year != 0 - Date.new(year, mon, mday) rescue nil - end - end - - def new_time(year, mon, mday, hour, min, sec, microsec) - # Treat 0000-00-00 00:00:00 as nil. - return nil if year.nil? || year == 0 - - Time.time_with_datetime_fallback(Base.default_timezone, year, mon, mday, hour, min, sec, microsec) rescue nil - end - - def fast_string_to_date(string) - if string =~ Format::ISO_DATE - new_date $1.to_i, $2.to_i, $3.to_i - end - end - - # Doesn't handle time zones. - def fast_string_to_time(string) - if string =~ Format::ISO_DATETIME - microsec = ($7.to_f * 1_000_000).to_i - new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec - end - end - - def fallback_string_to_date(string) - new_date(*::Date._parse(string, false).values_at(:year, :mon, :mday)) - end - - def fallback_string_to_time(string) - time_hash = Date._parse(string) - time_hash[:sec_fraction] = microseconds(time_hash) - - new_time(*time_hash.values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction)) - end - end - - private - def extract_limit(sql_type) - $1.to_i if sql_type =~ /\((.*)\)/ - end - - def extract_precision(sql_type) - $2.to_i if sql_type =~ /^(numeric|decimal|number)\((\d+)(,\d+)?\)/i - end - - def extract_scale(sql_type) - case sql_type - when /^(numeric|decimal|number)\((\d+)\)/i then 0 - when /^(numeric|decimal|number)\((\d+)(,(\d+))\)/i then $4.to_i - end - end - - def simplified_type(field_type) - case field_type - when /int/i - :integer - when /float|double/i - :float - when /decimal|numeric|number/i - extract_scale(field_type) == 0 ? :integer : :decimal - when /datetime/i - :datetime - when /timestamp/i - :timestamp - when /time/i - :time - when /date/i - :date - when /clob/i, /text/i - :text - when /blob/i, /binary/i - :binary - when /char/i, /string/i - :string - when /boolean/i - :boolean - end - end - end - - class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths) #:nodoc: - end - - # Abstract representation of a column definition. Instances of this type - # are typically created by methods in TableDefinition, and added to the - # +columns+ attribute of said TableDefinition object, in order to be used - # for generating a number of table creation or table changing SQL statements. - class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc: - - def sql_type - base.type_to_sql(type.to_sym, limit, precision, scale) rescue type - end - - def to_sql - column_sql = "#{base.quote_column_name(name)} #{sql_type}" - column_options = {} - column_options[:null] = null unless null.nil? - column_options[:default] = default unless default.nil? - add_column_options!(column_sql, column_options) unless type.to_sym == :primary_key - column_sql - end - - private - - def add_column_options!(sql, options) - base.add_column_options!(sql, options.merge(:column => self)) - end - end - - # Represents the schema of an SQL table in an abstract way. This class - # provides methods for manipulating the schema representation. - # - # Inside migration files, the +t+ object in +create_table+ and - # +change_table+ is actually of this type: - # - # class SomeMigration < ActiveRecord::Migration - # def self.up - # create_table :foo do |t| - # puts t.class # => "ActiveRecord::ConnectionAdapters::TableDefinition" - # end - # end - # - # def self.down - # ... - # end - # end - # - # The table definitions - # The Columns are stored as a ColumnDefinition in the +columns+ attribute. - class TableDefinition - # An array of ColumnDefinition objects, representing the column changes - # that have been defined. - attr_accessor :columns - - def initialize(base) - @columns = [] - @base = base - end - - #Handles non supported datatypes - e.g. XML - def method_missing(symbol, *args) - if symbol.to_s == 'xml' - xml_column_fallback(args) - end - end - - def xml_column_fallback(*args) - case @base.adapter_name.downcase - when 'sqlite', 'mysql' - options = args.extract_options! - column(args[0], :text, options) - end - end - # Appends a primary key definition to the table definition. - # Can be called multiple times, but this is probably not a good idea. - def primary_key(name) - column(name, :primary_key) - end - - # Returns a ColumnDefinition for the column with name +name+. - def [](name) - @columns.find {|column| column.name.to_s == name.to_s} - end - - # Instantiates a new column for the table. - # The +type+ parameter is normally one of the migrations native types, - # which is one of the following: - # <tt>:primary_key</tt>, <tt>:string</tt>, <tt>:text</tt>, - # <tt>:integer</tt>, <tt>:float</tt>, <tt>:decimal</tt>, - # <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>, - # <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. - # - # You may use a type not in this list as long as it is supported by your - # database (for example, "polygon" in MySQL), but this will not be database - # agnostic and should usually be avoided. - # - # Available options are (none of these exists by default): - # * <tt>:limit</tt> - - # Requests a maximum column length. This is number of characters for <tt>:string</tt> and <tt>:text</tt> columns and number of bytes for :binary and :integer columns. - # * <tt>:default</tt> - - # The column's default value. Use nil for NULL. - # * <tt>:null</tt> - - # Allows or disallows +NULL+ values in the column. This option could - # have been named <tt>:null_allowed</tt>. - # * <tt>:precision</tt> - - # Specifies the precision for a <tt>:decimal</tt> column. - # * <tt>:scale</tt> - - # Specifies the scale for a <tt>:decimal</tt> column. - # - # For clarity's sake: the precision is the number of significant digits, - # while the scale is the number of digits that can be stored following - # the decimal point. For example, the number 123.45 has a precision of 5 - # and a scale of 2. A decimal with a precision of 5 and a scale of 2 can - # range from -999.99 to 999.99. - # - # Please be aware of different RDBMS implementations behavior with - # <tt>:decimal</tt> columns: - # * The SQL standard says the default scale should be 0, <tt>:scale</tt> <= - # <tt>:precision</tt>, and makes no comments about the requirements of - # <tt>:precision</tt>. - # * MySQL: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..30]. - # Default is (10,0). - # * PostgreSQL: <tt>:precision</tt> [1..infinity], - # <tt>:scale</tt> [0..infinity]. No default. - # * SQLite2: Any <tt>:precision</tt> and <tt>:scale</tt> may be used. - # Internal storage as strings. No default. - # * SQLite3: No restrictions on <tt>:precision</tt> and <tt>:scale</tt>, - # but the maximum supported <tt>:precision</tt> is 16. No default. - # * Oracle: <tt>:precision</tt> [1..38], <tt>:scale</tt> [-84..127]. - # Default is (38,0). - # * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62]. - # Default unknown. - # * Firebird: <tt>:precision</tt> [1..18], <tt>:scale</tt> [0..18]. - # Default (9,0). Internal types NUMERIC and DECIMAL have different - # storage rules, decimal being better. - # * FrontBase?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38]. - # Default (38,0). WARNING Max <tt>:precision</tt>/<tt>:scale</tt> for - # NUMERIC is 19, and DECIMAL is 38. - # * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38]. - # Default (38,0). - # * Sybase: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38]. - # Default (38,0). - # * OpenBase?: Documentation unclear. Claims storage in <tt>double</tt>. - # - # This method returns <tt>self</tt>. - # - # == Examples - # # Assuming td is an instance of TableDefinition - # td.column(:granted, :boolean) - # # granted BOOLEAN - # - # td.column(:picture, :binary, :limit => 2.megabytes) - # # => picture BLOB(2097152) - # - # td.column(:sales_stage, :string, :limit => 20, :default => 'new', :null => false) - # # => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL - # - # td.column(:bill_gates_money, :decimal, :precision => 15, :scale => 2) - # # => bill_gates_money DECIMAL(15,2) - # - # td.column(:sensor_reading, :decimal, :precision => 30, :scale => 20) - # # => sensor_reading DECIMAL(30,20) - # - # # While <tt>:scale</tt> defaults to zero on most databases, it - # # probably wouldn't hurt to include it. - # td.column(:huge_integer, :decimal, :precision => 30) - # # => huge_integer DECIMAL(30) - # - # # Defines a column with a database-specific type. - # td.column(:foo, 'polygon') - # # => foo polygon - # - # == Short-hand examples - # - # Instead of calling +column+ directly, you can also work with the short-hand definitions for the default types. - # They use the type as the method name instead of as a parameter and allow for multiple columns to be defined - # in a single statement. - # - # What can be written like this with the regular calls to column: - # - # create_table "products", :force => true do |t| - # t.column "shop_id", :integer - # t.column "creator_id", :integer - # t.column "name", :string, :default => "Untitled" - # t.column "value", :string, :default => "Untitled" - # t.column "created_at", :datetime - # t.column "updated_at", :datetime - # end - # - # Can also be written as follows using the short-hand: - # - # create_table :products do |t| - # t.integer :shop_id, :creator_id - # t.string :name, :value, :default => "Untitled" - # t.timestamps - # end - # - # There's a short-hand method for each of the type values declared at the top. And then there's - # TableDefinition#timestamps that'll add created_at and +updated_at+ as datetimes. - # - # TableDefinition#references will add an appropriately-named _id column, plus a corresponding _type - # column if the <tt>:polymorphic</tt> option is supplied. If <tt>:polymorphic</tt> is a hash of options, these will be - # used when creating the <tt>_type</tt> column. So what can be written like this: - # - # create_table :taggings do |t| - # t.integer :tag_id, :tagger_id, :taggable_id - # t.string :tagger_type - # t.string :taggable_type, :default => 'Photo' - # end - # - # Can also be written as follows using references: - # - # create_table :taggings do |t| - # t.references :tag - # t.references :tagger, :polymorphic => true - # t.references :taggable, :polymorphic => { :default => 'Photo' } - # end - def column(name, type, options = {}) - column = self[name] || ColumnDefinition.new(@base, name, type) - if options[:limit] - column.limit = options[:limit] - elsif native[type.to_sym].is_a?(Hash) - column.limit = native[type.to_sym][:limit] - end - column.precision = options[:precision] - column.scale = options[:scale] - column.default = options[:default] - column.null = options[:null] - @columns << column unless @columns.include? column - self - end - - %w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| - class_eval <<-EOV - def #{column_type}(*args) # def string(*args) - options = args.extract_options! # options = args.extract_options! - column_names = args # column_names = args - # - column_names.each { |name| column(name, '#{column_type}', options) } # column_names.each { |name| column(name, 'string', options) } - end # end - EOV - end - - # Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and - # <tt>:updated_at</tt> to the table. - def timestamps(*args) - options = args.extract_options! - column(:created_at, :datetime, options) - column(:updated_at, :datetime, options) - end - - def references(*args) - options = args.extract_options! - polymorphic = options.delete(:polymorphic) - args.each do |col| - column("#{col}_id", :integer, options) - column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil? - end - end - alias :belongs_to :references - - # Returns a String whose contents are the column definitions - # concatenated together. This string can then be prepended and appended to - # to generate the final SQL to create the table. - def to_sql - @columns.map(&:to_sql) * ', ' - end - - private - def native - @base.native_database_types - end - end - - # Represents a SQL table in an abstract way for updating a table. - # Also see TableDefinition and SchemaStatements#create_table - # - # Available transformations are: - # - # change_table :table do |t| - # t.column - # t.index - # t.timestamps - # t.change - # t.change_default - # t.rename - # t.references - # t.belongs_to - # t.string - # t.text - # t.integer - # t.float - # t.decimal - # t.datetime - # t.timestamp - # t.time - # t.date - # t.binary - # t.boolean - # t.remove - # t.remove_references - # t.remove_belongs_to - # t.remove_index - # t.remove_timestamps - # end - # - class Table - def initialize(table_name, base) - @table_name = table_name - @base = base - end - - # Adds a new column to the named table. - # See TableDefinition#column for details of the options you can use. - # ===== Example - # ====== Creating a simple column - # t.column(:name, :string) - def column(column_name, type, options = {}) - @base.add_column(@table_name, column_name, type, options) - end - - # Adds a new index to the table. +column_name+ can be a single Symbol, or - # an Array of Symbols. See SchemaStatements#add_index - # - # ===== Examples - # ====== Creating a simple index - # t.index(:name) - # ====== Creating a unique index - # t.index([:branch_id, :party_id], :unique => true) - # ====== Creating a named index - # t.index([:branch_id, :party_id], :unique => true, :name => 'by_branch_party') - def index(column_name, options = {}) - @base.add_index(@table_name, column_name, options) - end - - # Adds timestamps (created_at and updated_at) columns to the table. See SchemaStatements#add_timestamps - # ===== Example - # t.timestamps - def timestamps - @base.add_timestamps(@table_name) - end - - # Changes the column's definition according to the new options. - # See TableDefinition#column for details of the options you can use. - # ===== Examples - # t.change(:name, :string, :limit => 80) - # t.change(:description, :text) - def change(column_name, type, options = {}) - @base.change_column(@table_name, column_name, type, options) - end - - # Sets a new default value for a column. See SchemaStatements#change_column_default - # ===== Examples - # t.change_default(:qualification, 'new') - # t.change_default(:authorized, 1) - def change_default(column_name, default) - @base.change_column_default(@table_name, column_name, default) - end - - # Removes the column(s) from the table definition. - # ===== Examples - # t.remove(:qualification) - # t.remove(:qualification, :experience) - def remove(*column_names) - @base.remove_column(@table_name, column_names) - end - - # Removes the given index from the table. - # - # ===== Examples - # ====== Remove the suppliers_name_index in the suppliers table - # t.remove_index :name - # ====== Remove the index named accounts_branch_id_index in the accounts table - # t.remove_index :column => :branch_id - # ====== Remove the index named accounts_branch_id_party_id_index in the accounts table - # t.remove_index :column => [:branch_id, :party_id] - # ====== Remove the index named by_branch_party in the accounts table - # t.remove_index :name => :by_branch_party - def remove_index(options = {}) - @base.remove_index(@table_name, options) - end - - # Removes the timestamp columns (created_at and updated_at) from the table. - # ===== Example - # t.remove_timestamps - def remove_timestamps - @base.remove_timestamps(@table_name) - end - - # Renames a column. - # ===== Example - # t.rename(:description, :name) - def rename(column_name, new_column_name) - @base.rename_column(@table_name, column_name, new_column_name) - end - - # Adds a reference. Optionally adds a +type+ column. - # <tt>references</tt> and <tt>belongs_to</tt> are acceptable. - # ===== Examples - # t.references(:goat) - # t.references(:goat, :polymorphic => true) - # t.belongs_to(:goat) - def references(*args) - options = args.extract_options! - polymorphic = options.delete(:polymorphic) - args.each do |col| - @base.add_column(@table_name, "#{col}_id", :integer, options) - @base.add_column(@table_name, "#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil? - end - end - alias :belongs_to :references - - # Removes a reference. Optionally removes a +type+ column. - # <tt>remove_references</tt> and <tt>remove_belongs_to</tt> are acceptable. - # ===== Examples - # t.remove_references(:goat) - # t.remove_references(:goat, :polymorphic => true) - # t.remove_belongs_to(:goat) - def remove_references(*args) - options = args.extract_options! - polymorphic = options.delete(:polymorphic) - args.each do |col| - @base.remove_column(@table_name, "#{col}_id") - @base.remove_column(@table_name, "#{col}_type") unless polymorphic.nil? - end - end - alias :remove_belongs_to :remove_references - - # Adds a column or columns of a specified type - # ===== Examples - # t.string(:goat) - # t.string(:goat, :sheep) - %w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| - class_eval <<-EOV - def #{column_type}(*args) # def string(*args) - options = args.extract_options! # options = args.extract_options! - column_names = args # column_names = args - # - column_names.each do |name| # column_names.each do |name| - column = ColumnDefinition.new(@base, name, '#{column_type}') # column = ColumnDefinition.new(@base, name, 'string') - if options[:limit] # if options[:limit] - column.limit = options[:limit] # column.limit = options[:limit] - elsif native['#{column_type}'.to_sym].is_a?(Hash) # elsif native['string'.to_sym].is_a?(Hash) - column.limit = native['#{column_type}'.to_sym][:limit] # column.limit = native['string'.to_sym][:limit] - end # end - column.precision = options[:precision] # column.precision = options[:precision] - column.scale = options[:scale] # column.scale = options[:scale] - column.default = options[:default] # column.default = options[:default] - column.null = options[:null] # column.null = options[:null] - @base.add_column(@table_name, name, column.sql_type, options) # @base.add_column(@table_name, name, column.sql_type, options) - end # end - end # end - EOV - end - - private - def native - @base.native_database_types - end - end - - end -end - diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb deleted file mode 100644 index 12826b19..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ /dev/null @@ -1,490 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module SchemaStatements - # Returns a Hash of mappings from the abstract data types to the native - # database types. See TableDefinition#column for details on the recognized - # abstract data types. - def native_database_types - {} - end - - # Truncates a table alias according to the limits of the current adapter. - def table_alias_for(table_name) - table_name[0..table_alias_length-1].gsub(/\./, '_') - end - - # def tables(name = nil) end - - def table_exists?(table_name) - tables.include?(table_name.to_s) - end - - # Returns an array of indexes for the given table. - # def indexes(table_name, name = nil) end - - # Returns an array of Column objects for the table specified by +table_name+. - # See the concrete implementation for details on the expected parameter values. - def columns(table_name, name = nil) end - - # Creates a new table with the name +table_name+. +table_name+ may either - # be a String or a Symbol. - # - # There are two ways to work with +create_table+. You can use the block - # form or the regular form, like this: - # - # === Block form - # # create_table() passes a TableDefinition object to the block. - # # This form will not only create the table, but also columns for the - # # table. - # create_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 - # # Other fields here - # end - # - # === Regular form - # # Creates a table called 'suppliers' with no columns. - # create_table(:suppliers) - # # Add a column to 'suppliers'. - # add_column(:suppliers, :name, :string, {:limit => 60}) - # - # The +options+ hash can include the following keys: - # [<tt>:id</tt>] - # Whether to automatically add a primary key column. Defaults to true. - # Join tables for +has_and_belongs_to_many+ should set <tt>:id => false</tt>. - # [<tt>:primary_key</tt>] - # The name of the primary key, if one is to be added automatically. - # Defaults to +id+. - # [<tt>:options</tt>] - # Any extra options you want appended to the table definition. - # [<tt>:temporary</tt>] - # Make a temporary table. - # [<tt>:force</tt>] - # Set to true to drop the table before creating it. - # Defaults to false. - # - # ===== Examples - # ====== Add a backend specific option to the generated SQL (MySQL) - # create_table(:suppliers, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8') - # generates: - # CREATE TABLE suppliers ( - # id int(11) DEFAULT NULL auto_increment PRIMARY KEY - # ) ENGINE=InnoDB DEFAULT CHARSET=utf8 - # - # ====== Rename the primary key column - # create_table(:objects, :primary_key => 'guid') do |t| - # t.column :name, :string, :limit => 80 - # end - # generates: - # CREATE TABLE objects ( - # guid int(11) DEFAULT NULL auto_increment PRIMARY KEY, - # name varchar(80) - # ) - # - # ====== Do not add a primary key column - # create_table(:categories_suppliers, :id => false) do |t| - # t.column :category_id, :integer - # t.column :supplier_id, :integer - # end - # generates: - # CREATE TABLE categories_suppliers ( - # category_id int, - # supplier_id int - # ) - # - # See also TableDefinition#column for details on how to create columns. - def create_table(table_name, options = {}) - table_definition = TableDefinition.new(self) - table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false - - yield table_definition if block_given? - - if options[:force] && table_exists?(table_name) - drop_table(table_name, options) - end - - create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE " - create_sql << "#{quote_table_name(table_name)} (" - create_sql << table_definition.to_sql - create_sql << ") #{options[:options]}" - execute create_sql - end - - # A block for changing columns in +table+. - # - # === Example - # # change_table() yields a Table instance - # change_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 - # # Other column alterations here - # end - # - # ===== Examples - # ====== Add a column - # change_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 - # end - # - # ====== Add 2 integer columns - # change_table(:suppliers) do |t| - # t.integer :width, :height, :null => false, :default => 0 - # end - # - # ====== Add created_at/updated_at columns - # change_table(:suppliers) do |t| - # t.timestamps - # end - # - # ====== Add a foreign key column - # change_table(:suppliers) do |t| - # t.references :company - # end - # - # Creates a <tt>company_id(integer)</tt> column - # - # ====== Add a polymorphic foreign key column - # change_table(:suppliers) do |t| - # t.belongs_to :company, :polymorphic => true - # end - # - # Creates <tt>company_type(varchar)</tt> and <tt>company_id(integer)</tt> columns - # - # ====== Remove a column - # change_table(:suppliers) do |t| - # t.remove :company - # end - # - # ====== Remove several columns - # change_table(:suppliers) do |t| - # t.remove :company_id - # t.remove :width, :height - # end - # - # ====== Remove an index - # change_table(:suppliers) do |t| - # t.remove_index :company_id - # end - # - # See also Table for details on - # all of the various column transformation - def change_table(table_name) - yield Table.new(table_name, self) - end - - # Renames a table. - # ===== Example - # rename_table('octopuses', 'octopi') - def rename_table(table_name, new_name) - raise NotImplementedError, "rename_table is not implemented" - end - - # Drops a table from the database. - def drop_table(table_name, options = {}) - execute "DROP TABLE #{quote_table_name(table_name)}" - end - - # Adds a new column to the named table. - # See TableDefinition#column for details of the options you can use. - def add_column(table_name, column_name, type, options = {}) - add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - add_column_options!(add_column_sql, options) - execute(add_column_sql) - end - - # Removes the column(s) from the table definition. - # ===== Examples - # remove_column(:suppliers, :qualification) - # remove_columns(:suppliers, :qualification, :experience) - def remove_column(table_name, *column_names) - raise ArgumentError.new("You must specify at least one column name. Example: remove_column(:people, :first_name)") if column_names.empty? - column_names.flatten.each do |column_name| - execute "ALTER TABLE #{quote_table_name(table_name)} DROP #{quote_column_name(column_name)}" - end - end - alias :remove_columns :remove_column - - # Changes the column's definition according to the new options. - # See TableDefinition#column for details of the options you can use. - # ===== Examples - # change_column(:suppliers, :name, :string, :limit => 80) - # change_column(:accounts, :description, :text) - def change_column(table_name, column_name, type, options = {}) - raise NotImplementedError, "change_column is not implemented" - end - - # Sets a new default value for a column. If you want to set the default - # value to +NULL+, you are out of luck. You need to - # DatabaseStatements#execute the appropriate SQL statement yourself. - # ===== Examples - # change_column_default(:suppliers, :qualification, 'new') - # change_column_default(:accounts, :authorized, 1) - def change_column_default(table_name, column_name, default) - raise NotImplementedError, "change_column_default is not implemented" - end - - # Renames a column. - # ===== Example - # rename_column(:suppliers, :description, :name) - def rename_column(table_name, column_name, new_column_name) - raise NotImplementedError, "rename_column is not implemented" - end - - # Adds a new index to the table. +column_name+ can be a single Symbol, or - # an Array of Symbols. - # - # The index will be named after the table and the first column name, - # unless you pass <tt>:name</tt> as an option. - # - # When creating an index on multiple columns, the first column is used as a name - # for the index. For example, when you specify an index on two columns - # [<tt>:first</tt>, <tt>:last</tt>], the DBMS creates an index for both columns as well as an - # index for the first column <tt>:first</tt>. Using just the first name for this index - # makes sense, because you will never have to create a singular index with this - # name. - # - # ===== Examples - # - # ====== Creating a simple index - # add_index(:suppliers, :name) - # generates - # CREATE INDEX suppliers_name_index ON suppliers(name) - # - # ====== Creating a unique index - # add_index(:accounts, [:branch_id, :party_id], :unique => true) - # generates - # CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id) - # - # ====== Creating a named index - # add_index(:accounts, [:branch_id, :party_id], :unique => true, :name => 'by_branch_party') - # generates - # CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id) - # - # ====== Creating an index with specific key length - # add_index(:accounts, :name, :name => 'by_name', :length => 10) - # generates - # CREATE INDEX by_name ON accounts(name(10)) - # - # add_index(:accounts, [:name, :surname], :name => 'by_name_surname', :length => {:name => 10, :surname => 15}) - # generates - # CREATE INDEX by_name_surname ON accounts(name(10), surname(15)) - # - # Note: SQLite doesn't support index length - def add_index(table_name, column_name, options = {}) - column_names = Array(column_name) - index_name = index_name(table_name, :column => column_names) - - if Hash === options # legacy support, since this param was a string - index_type = options[:unique] ? "UNIQUE" : "" - index_name = options[:name].to_s if options[:name] - else - index_type = options - end - - if index_name.length > index_name_length - @logger.warn("Index name '#{index_name}' on table '#{table_name}' is too long; the limit is #{index_name_length} characters. Skipping.") - return - end - if index_exists?(table_name, index_name, false) - @logger.warn("Index name '#{index_name}' on table '#{table_name}' already exists. Skipping.") - return - end - quoted_column_names = quoted_columns_for_index(column_names, options).join(", ") - - execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names})" - end - - # Remove the given index from the table. - # - # Remove the suppliers_name_index in the suppliers table. - # remove_index :suppliers, :name - # Remove the index named accounts_branch_id_index in the accounts table. - # remove_index :accounts, :column => :branch_id - # Remove the index named accounts_branch_id_party_id_index in the accounts table. - # remove_index :accounts, :column => [:branch_id, :party_id] - # Remove the index named by_branch_party in the accounts table. - # remove_index :accounts, :name => :by_branch_party - def remove_index(table_name, options = {}) - index_name = index_name(table_name, options) - unless index_exists?(table_name, index_name, true) - @logger.warn("Index name '#{index_name}' on table '#{table_name}' does not exist. Skipping.") - return - end - remove_index!(table_name, index_name) - end - - def remove_index!(table_name, index_name) #:nodoc: - execute "DROP INDEX #{quote_column_name(index_name)} ON #{table_name}" - end - - # Rename an index. - # - # Rename the index_people_on_last_name index to index_users_on_last_name - # rename_index :people, 'index_people_on_last_name', 'index_users_on_last_name' - def rename_index(table_name, old_name, new_name) - # this is a naive implementation; some DBs may support this more efficiently (Postgres, for instance) - old_index_def = indexes(table_name).detect { |i| i.name == old_name } - return unless old_index_def - remove_index(table_name, :name => old_name) - add_index(table_name, old_index_def.columns, :name => new_name, :unique => old_index_def.unique) - end - - def index_name(table_name, options) #:nodoc: - if Hash === options # legacy support - if options[:column] - "index_#{table_name}_on_#{Array(options[:column]) * '_and_'}" - elsif options[:name] - options[:name] - else - raise ArgumentError, "You must specify the index name" - end - else - index_name(table_name, :column => options) - end - end - - # Verify the existence of an index. - # - # The default argument is returned if the underlying implementation does not define the indexes method, - # as there's no way to determine the correct answer in that case. - def index_exists?(table_name, index_name, default) - return default unless respond_to?(:indexes) - index_name = index_name.to_s - indexes(table_name).detect { |i| i.name == index_name } - end - - # Returns a string of <tt>CREATE TABLE</tt> SQL statement(s) for recreating the - # entire structure of the database. - def structure_dump - end - - def dump_schema_information #:nodoc: - sm_table = ActiveRecord::Migrator.schema_migrations_table_name - migrated = select_values("SELECT version FROM #{sm_table}") - migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n\n") - end - - # Should not be called normally, but this operation is non-destructive. - # The migrations module handles this automatically. - def initialize_schema_migrations_table - sm_table = ActiveRecord::Migrator.schema_migrations_table_name - - unless tables.detect { |t| t == sm_table } - create_table(sm_table, :id => false) do |schema_migrations_table| - schema_migrations_table.column :version, :string, :null => false - end - add_index sm_table, :version, :unique => true, - :name => "#{Base.table_name_prefix}unique_schema_migrations#{Base.table_name_suffix}" - - # Backwards-compatibility: if we find schema_info, assume we've - # migrated up to that point: - si_table = Base.table_name_prefix + 'schema_info' + Base.table_name_suffix - - if tables.detect { |t| t == si_table } - - old_version = select_value("SELECT version FROM #{quote_table_name(si_table)}").to_i - assume_migrated_upto_version(old_version) - drop_table(si_table) - end - end - end - - def assume_migrated_upto_version(version, migrations_path = ActiveRecord::Migrator.migrations_path) - version = version.to_i - sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name) - - migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i) - versions = Dir["#{migrations_path}/[0-9]*_*.rb"].map do |filename| - filename.split('/').last.split('_').first.to_i - end - - unless migrated.include?(version) - execute "INSERT INTO #{sm_table} (version) VALUES ('#{version}')" - end - - inserted = Set.new - (versions - migrated).each do |v| - if inserted.include?(v) - raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict." - elsif v < version - execute "INSERT INTO #{sm_table} (version) VALUES ('#{v}')" - inserted << v - end - end - end - - def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: - if native = native_database_types[type] - column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup - - if type == :decimal # ignore limit, use precision and scale - scale ||= native[:scale] - - if precision ||= native[:precision] - if scale - column_type_sql << "(#{precision},#{scale})" - else - column_type_sql << "(#{precision})" - end - elsif scale - raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified" - end - - elsif (type != :primary_key) && (limit ||= native.is_a?(Hash) && native[:limit]) - column_type_sql << "(#{limit})" - end - - column_type_sql - else - type - end - end - - def add_column_options!(sql, options) #:nodoc: - sql << " DEFAULT #{quote(options[:default], options[:column])}" if options_include_default?(options) - # must explicitly check for :null to allow change_column to work on migrations - if options[:null] == false - sql << " NOT NULL" - end - end - - # SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause. - # Both PostgreSQL and Oracle overrides this for custom DISTINCT syntax. - # - # distinct("posts.id", "posts.created_at desc") - def distinct(columns, order_by) - "DISTINCT #{columns}" - end - - # ORDER BY clause for the passed order option. - # PostgreSQL overrides this due to its stricter standards compliance. - def add_order_by_for_association_limiting!(sql, options) - sql << " ORDER BY #{options[:order]}" - end - - # Adds timestamps (created_at and updated_at) columns to the named table. - # ===== Examples - # add_timestamps(:suppliers) - def add_timestamps(table_name) - add_column table_name, :created_at, :datetime - add_column table_name, :updated_at, :datetime - end - - # Removes the timestamp columns (created_at and updated_at) from the table definition. - # ===== Examples - # remove_timestamps(:suppliers) - def remove_timestamps(table_name) - remove_column table_name, :updated_at - remove_column table_name, :created_at - end - - protected - # Overridden by the mysql adapter for supporting index lengths - def quoted_columns_for_index(column_names, options = {}) - column_names.map {|name| quote_column_name(name) } - end - - def options_include_default?(options) - options.include?(:default) && !(options[:null] == false && options[:default].nil?) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb deleted file mode 100755 index b8a6a71e..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ /dev/null @@ -1,249 +0,0 @@ -require 'benchmark' -require 'date' -require 'bigdecimal' -require 'bigdecimal/util' - -# TODO: Autoload these files -require 'active_record/connection_adapters/abstract/schema_definitions' -require 'active_record/connection_adapters/abstract/schema_statements' -require 'active_record/connection_adapters/abstract/database_statements' -require 'active_record/connection_adapters/abstract/quoting' -require 'active_record/connection_adapters/abstract/connection_pool' -require 'active_record/connection_adapters/abstract/connection_specification' -require 'active_record/connection_adapters/abstract/query_cache' -require 'active_record/connection_adapters/abstract/database_limits' - -module ActiveRecord - module ConnectionAdapters # :nodoc: - # ActiveRecord supports multiple database systems. AbstractAdapter and - # related classes form the abstraction layer which makes this possible. - # An AbstractAdapter represents a connection to a database, and provides an - # abstract interface for database-specific functionality such as establishing - # a connection, escaping values, building the right SQL fragments for ':offset' - # and ':limit' options, etc. - # - # All the concrete database adapters follow the interface laid down in this class. - # ActiveRecord::Base.connection returns an AbstractAdapter object, which - # you can use. - # - # Most of the methods in the adapter are useful during migrations. Most - # notably, the instance methods provided by SchemaStatement are very useful. - class AbstractAdapter - include Quoting, DatabaseStatements, SchemaStatements - include DatabaseLimits - include QueryCache - include ActiveSupport::Callbacks - define_callbacks :checkout, :checkin - - @@row_even = true - - def initialize(connection, logger = nil) #:nodoc: - @connection, @logger = connection, logger - @runtime = 0 - @last_verification = 0 - @query_cache_enabled = false - end - - # Returns the human-readable name of the adapter. Use mixed case - one - # can always use downcase if needed. - def adapter_name - 'Abstract' - end - - # Does this adapter support migrations? Backend specific, as the - # abstract adapter always returns +false+. - def supports_migrations? - false - end - - # Can this adapter determine the primary key for tables not attached - # to an ActiveRecord class, such as join tables? Backend specific, as - # the abstract adapter always returns +false+. - def supports_primary_key? - false - end - - # Does this adapter support using DISTINCT within COUNT? This is +true+ - # for all adapters except sqlite. - def supports_count_distinct? - true - end - - # Does this adapter support DDL rollbacks in transactions? That is, would - # CREATE TABLE or ALTER TABLE get rolled back by a transaction? PostgreSQL, - # SQL Server, and others support this. MySQL and others do not. - def supports_ddl_transactions? - false - end - - # Does this adapter support savepoints? PostgreSQL and MySQL do, SQLite - # does not. - def supports_savepoints? - false - end - - # Should primary key values be selected from their corresponding - # sequence before the insert statement? If true, next_sequence_value - # is called before each insert to set the record's primary key. - # This is false for all adapters but Firebird. - def prefetch_primary_key?(table_name = nil) - false - end - - def reset_runtime #:nodoc: - rt, @runtime = @runtime, 0 - rt - end - - # QUOTING ================================================== - - # Override to return the quoted table name. Defaults to column quoting. - def quote_table_name(name) - quote_column_name(name) - end - - # REFERENTIAL INTEGRITY ==================================== - - # Override to turn off referential integrity while executing <tt>&block</tt>. - def disable_referential_integrity(&block) - yield - end - - # CONNECTION MANAGEMENT ==================================== - - # Checks whether the connection to the database is still active. This includes - # checking whether the database is actually capable of responding, i.e. whether - # the connection isn't stale. - def active? - @active != false - end - - # Disconnects from the database if already connected, and establishes a - # new connection with the database. - def reconnect! - @active = true - end - - # Disconnects from the database if already connected. Otherwise, this - # method does nothing. - def disconnect! - @active = false - end - - # Reset the state of this connection, directing the DBMS to clear - # transactions and other connection-related server-side state. Usually a - # database-dependent operation. - # - # The default implementation does nothing; the implementation should be - # overridden by concrete adapters. - def reset! - # this should be overridden by concrete adapters - end - - # Returns true if its safe to reload the connection between requests for development mode. - def requires_reloading? - true - end - - # Checks whether the connection to the database is still active (i.e. not stale). - # This is done under the hood by calling <tt>active?</tt>. If the connection - # is no longer active, then this method will reconnect to the database. - def verify!(*ignored) - reconnect! unless active? - end - - # Provides access to the underlying database driver for this adapter. For - # example, this method returns a Mysql object in case of MysqlAdapter, - # and a PGconn object in case of PostgreSQLAdapter. - # - # This is useful for when you need to call a proprietary method such as - # PostgreSQL's lo_* methods. - def raw_connection - @connection - end - - def open_transactions - @open_transactions ||= 0 - end - - def increment_open_transactions - @open_transactions ||= 0 - @open_transactions += 1 - end - - def decrement_open_transactions - @open_transactions -= 1 - end - - def transaction_joinable=(joinable) - @transaction_joinable = joinable - end - - def create_savepoint - end - - def rollback_to_savepoint - end - - def release_savepoint - end - - def current_savepoint_name - "active_record_#{open_transactions}" - end - - def log_info(sql, name, ms) - if @logger && @logger.debug? - name = '%s (%.1fms)' % [name || 'SQL', ms] - @logger.debug(format_log_entry(name, sql.squeeze(' '))) - end - end - - protected - def log(sql, name) - if block_given? - result = nil - ms = Benchmark.ms { result = yield } - @runtime += ms - log_info(sql, name, ms) - result - else - log_info(sql, name, 0) - nil - end - rescue SystemExit, SignalException, NoMemoryError => e - # Don't re-wrap these exceptions. They are probably not being caused by invalid - # sql, but rather some external stimulus beyond the responsibilty of this code. - # Additionaly, wrapping these exceptions with StatementInvalid would lead to - # meaningful loss of data, such as losing SystemExit#status. - raise e - rescue Exception => e - # Log message and raise exception. - # Set last_verification to 0, so that connection gets verified - # upon reentering the request loop - @last_verification = 0 - message = "#{e.class.name}: #{e.message}: #{sql}" - log_info(message, name, 0) - raise ActiveRecord::StatementInvalid, message - end - - def format_log_entry(message, dump = nil) - if ActiveRecord::Base.colorize_logging - if @@row_even - @@row_even = false - message_color, dump_color = "4;36;1", "0;1" - else - @@row_even = true - message_color, dump_color = "4;35;1", "0" - end - - log_entry = " \e[#{message_color}m#{message}\e[0m " - log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump - log_entry - else - "%s %s" % [message, dump] - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb deleted file mode 100644 index c50022bd..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ /dev/null @@ -1,662 +0,0 @@ -require 'active_record/connection_adapters/abstract_adapter' -require 'set' - -module MysqlCompat #:nodoc: - # add all_hashes method to standard mysql-c bindings or pure ruby version - def self.define_all_hashes_method! - raise 'Mysql not loaded' unless defined?(::Mysql) - - target = defined?(Mysql::Result) ? Mysql::Result : MysqlRes - return if target.instance_methods.include?('all_hashes') || - target.instance_methods.include?(:all_hashes) - - # Ruby driver has a version string and returns null values in each_hash - # C driver >= 2.7 returns null values in each_hash - if Mysql.const_defined?(:VERSION) && (Mysql::VERSION.is_a?(String) || Mysql::VERSION >= 20700) - target.class_eval <<-'end_eval' - def all_hashes # def all_hashes - rows = [] # rows = [] - each_hash { |row| rows << row } # each_hash { |row| rows << row } - rows # rows - end # end - end_eval - - # adapters before 2.7 don't have a version constant - # and don't return null values in each_hash - else - target.class_eval <<-'end_eval' - def all_hashes # def all_hashes - rows = [] # rows = [] - all_fields = fetch_fields.inject({}) { |fields, f| # all_fields = fetch_fields.inject({}) { |fields, f| - fields[f.name] = nil; fields # fields[f.name] = nil; fields - } # } - each_hash { |row| rows << all_fields.dup.update(row) } # each_hash { |row| rows << all_fields.dup.update(row) } - rows # rows - end # end - end_eval - end - - unless target.instance_methods.include?('all_hashes') || - target.instance_methods.include?(:all_hashes) - raise "Failed to defined #{target.name}#all_hashes method. Mysql::VERSION = #{Mysql::VERSION.inspect}" - end - end -end - -module ActiveRecord - class Base - # Establishes a connection to the database that's used by all Active Record objects. - def self.mysql_connection(config) # :nodoc: - config = config.symbolize_keys - host = config[:host] - port = config[:port] - socket = config[:socket] - username = config[:username] ? config[:username].to_s : 'root' - password = config[:password].to_s - database = config[:database] - - # Require the MySQL driver and define Mysql::Result.all_hashes - unless defined? Mysql - begin - require_library_or_gem('mysql') - rescue LoadError - $stderr.puts '!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.' - raise - end - end - - MysqlCompat.define_all_hashes_method! - - mysql = Mysql.init - mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslca] || config[:sslkey] - - default_flags = Mysql.const_defined?(:CLIENT_MULTI_RESULTS) ? Mysql::CLIENT_MULTI_RESULTS : 0 - options = [host, username, password, database, port, socket, default_flags] - ConnectionAdapters::MysqlAdapter.new(mysql, logger, options, config) - end - end - - module ConnectionAdapters - class MysqlColumn < Column #:nodoc: - def extract_default(default) - if sql_type =~ /blob/i || type == :text - if default.blank? - return null ? nil : '' - else - raise ArgumentError, "#{type} columns cannot have a default value: #{default.inspect}" - end - elsif missing_default_forged_as_empty_string?(default) - nil - else - super - end - end - - def has_default? - return false if sql_type =~ /blob/i || type == :text #mysql forbids defaults on blob and text columns - super - end - - private - def simplified_type(field_type) - return :boolean if MysqlAdapter.emulate_booleans && field_type.downcase.index("tinyint(1)") - return :string if field_type =~ /enum/i - super - end - - def extract_limit(sql_type) - case sql_type - when /blob|text/i - case sql_type - when /tiny/i - 255 - when /medium/i - 16777215 - when /long/i - 2147483647 # mysql only allows 2^31-1, not 2^32-1, somewhat inconsistently with the tiny/medium/normal cases - else - super # we could return 65535 here, but we leave it undecorated by default - end - when /^bigint/i; 8 - when /^int/i; 4 - when /^mediumint/i; 3 - when /^smallint/i; 2 - when /^tinyint/i; 1 - else - super - end - end - - # MySQL misreports NOT NULL column default when none is given. - # We can't detect this for columns which may have a legitimate '' - # default (string) but we can for others (integer, datetime, boolean, - # and the rest). - # - # Test whether the column has default '', is not null, and is not - # a type allowing default ''. - def missing_default_forged_as_empty_string?(default) - type != :string && !null && default == '' - end - end - - # The MySQL adapter will work with both Ruby/MySQL, which is a Ruby-based MySQL adapter that comes bundled with Active Record, and with - # the faster C-based MySQL/Ruby adapter (available both as a gem and from http://www.tmtm.org/en/mysql/ruby/). - # - # Options: - # - # * <tt>:host</tt> - Defaults to "localhost". - # * <tt>:port</tt> - Defaults to 3306. - # * <tt>:socket</tt> - Defaults to "/tmp/mysql.sock". - # * <tt>:username</tt> - Defaults to "root" - # * <tt>:password</tt> - Defaults to nothing. - # * <tt>:database</tt> - The name of the database. No default, must be provided. - # * <tt>:encoding</tt> - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection. - # * <tt>:reconnect</tt> - Defaults to false (See MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html). - # * <tt>:sslca</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslkey</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslcert</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslcapath</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslcipher</tt> - Necessary to use MySQL with an SSL connection. - # - class MysqlAdapter < AbstractAdapter - - ## - # :singleton-method: - # By default, the MysqlAdapter will consider all columns of type <tt>tinyint(1)</tt> - # as boolean. If you wish to disable this emulation (which was the default - # behavior in versions 0.13.1 and earlier) you can add the following line - # to your environment.rb file: - # - # ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans = false - cattr_accessor :emulate_booleans - self.emulate_booleans = true - - ADAPTER_NAME = 'MySQL'.freeze - - LOST_CONNECTION_ERROR_MESSAGES = [ - "Server shutdown in progress", - "Broken pipe", - "Lost connection to MySQL server during query", - "MySQL server has gone away" ] - - QUOTED_TRUE, QUOTED_FALSE = '1'.freeze, '0'.freeze - - NATIVE_DATABASE_TYPES = { - :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY".freeze, - :string => { :name => "varchar", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "int", :limit => 4 }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "datetime" }, - :timestamp => { :name => "datetime" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "blob" }, - :boolean => { :name => "tinyint", :limit => 1 } - } - - def initialize(connection, logger, connection_options, config) - super(connection, logger) - @connection_options, @config = connection_options, config - @quoted_column_names, @quoted_table_names = {}, {} - connect - end - - def adapter_name #:nodoc: - ADAPTER_NAME - end - - def supports_migrations? #:nodoc: - true - end - - def supports_primary_key? #:nodoc: - true - end - - def supports_savepoints? #:nodoc: - true - end - - def native_database_types #:nodoc: - NATIVE_DATABASE_TYPES - end - - - # QUOTING ================================================== - - def quote(value, column = nil) - if value.kind_of?(String) && column && column.type == :binary && column.class.respond_to?(:string_to_binary) - s = column.class.string_to_binary(value).unpack("H*")[0] - "x'#{s}'" - elsif value.kind_of?(BigDecimal) - value.to_s("F") - else - super - end - end - - def quote_column_name(name) #:nodoc: - @quoted_column_names[name] ||= "`#{name.to_s.gsub('`', '``')}`" - end - - def quote_table_name(name) #:nodoc: - @quoted_table_names[name] ||= quote_column_name(name).gsub('.', '`.`') - end - - def quote_string(string) #:nodoc: - @connection.quote(string) - end - - def quoted_true - QUOTED_TRUE - end - - def quoted_false - QUOTED_FALSE - end - - # REFERENTIAL INTEGRITY ==================================== - - def disable_referential_integrity(&block) #:nodoc: - old = select_value("SELECT @@FOREIGN_KEY_CHECKS") - - begin - update("SET FOREIGN_KEY_CHECKS = 0") - yield - ensure - update("SET FOREIGN_KEY_CHECKS = #{old}") - end - end - - # CONNECTION MANAGEMENT ==================================== - - def active? - if @connection.respond_to?(:stat) - @connection.stat - else - @connection.query 'select 1' - end - - # mysql-ruby doesn't raise an exception when stat fails. - if @connection.respond_to?(:errno) - @connection.errno.zero? - else - true - end - rescue Mysql::Error - false - end - - def reconnect! - disconnect! - connect - end - - def disconnect! - @connection.close rescue nil - end - - def reset! - if @connection.respond_to?(:change_user) - # See http://bugs.mysql.com/bug.php?id=33540 -- the workaround way to - # reset the connection is to change the user to the same user. - @connection.change_user(@config[:username], @config[:password], @config[:database]) - configure_connection - end - end - - # DATABASE STATEMENTS ====================================== - - def select_rows(sql, name = nil) - @connection.query_with_result = true - result = execute(sql, name) - rows = [] - result.each { |row| rows << row } - result.free - @connection.more_results && @connection.next_result # invoking stored procedures with CLIENT_MULTI_RESULTS requires this to tidy up else connection will be dropped - rows - end - - # Executes a SQL query and returns a MySQL::Result object. Note that you have to free the Result object after you're done using it. - def execute(sql, name = nil) #:nodoc: - log(sql, name) { @connection.query(sql) } - rescue ActiveRecord::StatementInvalid => exception - if exception.message.split(":").first =~ /Packets out of order/ - raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings." - else - raise - end - end - - def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: - super sql, name - id_value || @connection.insert_id - end - - def update_sql(sql, name = nil) #:nodoc: - super - @connection.affected_rows - end - - def begin_db_transaction #:nodoc: - execute "BEGIN" - rescue Exception - # Transactions aren't supported - end - - def commit_db_transaction #:nodoc: - execute "COMMIT" - rescue Exception - # Transactions aren't supported - end - - def rollback_db_transaction #:nodoc: - execute "ROLLBACK" - rescue Exception - # Transactions aren't supported - end - - def create_savepoint - execute("SAVEPOINT #{current_savepoint_name}") - end - - def rollback_to_savepoint - execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}") - end - - def release_savepoint - execute("RELEASE SAVEPOINT #{current_savepoint_name}") - end - - def add_limit_offset!(sql, options) #:nodoc: - if limit = options[:limit] - limit = sanitize_limit(limit) - unless offset = options[:offset] - sql << " LIMIT #{limit}" - else - sql << " LIMIT #{offset.to_i}, #{limit}" - end - end - end - - - # SCHEMA STATEMENTS ======================================== - - def structure_dump #:nodoc: - if supports_views? - sql = "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'" - else - sql = "SHOW TABLES" - end - - select_all(sql).inject("") do |structure, table| - table.delete('Table_type') - structure += select_one("SHOW CREATE TABLE #{quote_table_name(table.to_a.first.last)}")["Create Table"] + ";\n\n" - end - end - - def recreate_database(name, options = {}) #:nodoc: - drop_database(name) - create_database(name, options) - end - - # Create a new MySQL database with optional <tt>:charset</tt> and <tt>:collation</tt>. - # Charset defaults to utf8. - # - # Example: - # create_database 'charset_test', :charset => 'latin1', :collation => 'latin1_bin' - # create_database 'matt_development' - # create_database 'matt_development', :charset => :big5 - def create_database(name, options = {}) - if options[:collation] - execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`" - else - execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}`" - end - end - - def drop_database(name) #:nodoc: - execute "DROP DATABASE IF EXISTS `#{name}`" - end - - def current_database - select_value 'SELECT DATABASE() as db' - end - - # Returns the database character set. - def charset - show_variable 'character_set_database' - end - - # Returns the database collation strategy. - def collation - show_variable 'collation_database' - end - - def tables(name = nil) #:nodoc: - tables = [] - result = execute("SHOW TABLES", name) - result.each { |field| tables << field[0] } - result.free - tables - end - - def drop_table(table_name, options = {}) - super(table_name, options) - end - - def indexes(table_name, name = nil)#:nodoc: - indexes = [] - current_index = nil - result = execute("SHOW KEYS FROM #{quote_table_name(table_name)}", name) - result.each do |row| - if current_index != row[2] - next if row[2] == "PRIMARY" # skip the primary key - current_index = row[2] - indexes << IndexDefinition.new(row[0], row[2], row[1] == "0", [], []) - end - - indexes.last.columns << row[4] - indexes.last.lengths << row[7] - end - result.free - indexes - end - - def columns(table_name, name = nil)#:nodoc: - sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}" - columns = [] - result = execute(sql, name) - result.each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") } - result.free - columns - end - - def create_table(table_name, options = {}) #:nodoc: - super(table_name, options.reverse_merge(:options => "ENGINE=InnoDB")) - end - - def rename_table(table_name, new_name) - execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}" - end - - def add_column(table_name, column_name, type, options = {}) - add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - add_column_options!(add_column_sql, options) - add_column_position!(add_column_sql, options) - execute(add_column_sql) - end - - def change_column_default(table_name, column_name, default) #:nodoc: - column = column_for(table_name, column_name) - change_column table_name, column_name, column.sql_type, :default => default - end - - def change_column_null(table_name, column_name, null, default = nil) - column = column_for(table_name, column_name) - - unless null || default.nil? - execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") - end - - change_column table_name, column_name, column.sql_type, :null => null - end - - def change_column(table_name, column_name, type, options = {}) #:nodoc: - column = column_for(table_name, column_name) - - unless options_include_default?(options) - options[:default] = column.default - end - - unless options.has_key?(:null) - options[:null] = column.null - end - - change_column_sql = "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - add_column_options!(change_column_sql, options) - add_column_position!(change_column_sql, options) - execute(change_column_sql) - end - - def rename_column(table_name, column_name, new_column_name) #:nodoc: - options = {} - if column = columns(table_name).find { |c| c.name == column_name.to_s } - options[:default] = column.default - options[:null] = column.null - else - raise ActiveRecordError, "No such column: #{table_name}.#{column_name}" - end - current_type = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'")["Type"] - rename_column_sql = "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(new_column_name)} #{current_type}" - add_column_options!(rename_column_sql, options) - execute(rename_column_sql) - end - - # Maps logical Rails types to MySQL-specific data types. - def type_to_sql(type, limit = nil, precision = nil, scale = nil) - return super unless type.to_s == 'integer' - - case limit - when 1; 'tinyint' - when 2; 'smallint' - when 3; 'mediumint' - when nil, 4, 11; 'int(11)' # compatibility with MySQL default - when 5..8; 'bigint' - else raise(ActiveRecordError, "No integer type has byte size #{limit}") - end - end - - def add_column_position!(sql, options) - if options[:first] - sql << " FIRST" - elsif options[:after] - sql << " AFTER #{quote_column_name(options[:after])}" - end - end - - # SHOW VARIABLES LIKE 'name' - def show_variable(name) - variables = select_all("SHOW VARIABLES LIKE '#{name}'") - variables.first['Value'] unless variables.empty? - end - - # Returns a table's primary key and belonging sequence. - def pk_and_sequence_for(table) #:nodoc: - keys = [] - result = execute("describe #{quote_table_name(table)}") - result.each_hash do |h| - keys << h["Field"]if h["Key"] == "PRI" - end - result.free - keys.length == 1 ? [keys.first, nil] : nil - end - - # Returns just a table's primary key - def primary_key(table) - pk_and_sequence = pk_and_sequence_for(table) - pk_and_sequence && pk_and_sequence.first - end - - def case_sensitive_equality_operator - "= BINARY" - end - - def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key) - where_sql - end - - protected - def quoted_columns_for_index(column_names, options = {}) - length = options[:length] if options.is_a?(Hash) - - quoted_column_names = case length - when Hash - column_names.map {|name| length[name] ? "#{quote_column_name(name)}(#{length[name]})" : quote_column_name(name) } - when Fixnum - column_names.map {|name| "#{quote_column_name(name)}(#{length})"} - else - column_names.map {|name| quote_column_name(name) } - end - end - - private - def connect - encoding = @config[:encoding] - if encoding - @connection.options(Mysql::SET_CHARSET_NAME, encoding) rescue nil - end - - if @config[:sslca] || @config[:sslkey] - @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) - end - - @connection.options(Mysql::OPT_CONNECT_TIMEOUT, @config[:connect_timeout]) if @config[:connect_timeout] - @connection.options(Mysql::OPT_READ_TIMEOUT, @config[:read_timeout]) if @config[:read_timeout] - @connection.options(Mysql::OPT_WRITE_TIMEOUT, @config[:write_timeout]) if @config[:write_timeout] - - @connection.real_connect(*@connection_options) - - # reconnect must be set after real_connect is called, because real_connect sets it to false internally - @connection.reconnect = !!@config[:reconnect] if @connection.respond_to?(:reconnect=) - - configure_connection - end - - def configure_connection - encoding = @config[:encoding] - execute("SET NAMES '#{encoding}'") if encoding - - # By default, MySQL 'where id is null' selects the last inserted id. - # Turn this off. http://dev.rubyonrails.org/ticket/6778 - execute("SET SQL_AUTO_IS_NULL=0") - end - - def select(sql, name = nil) - @connection.query_with_result = true - result = execute(sql, name) - rows = result.all_hashes - result.free - @connection.more_results && @connection.next_result # invoking stored procedures with CLIENT_MULTI_RESULTS requires this to tidy up else connection will be dropped - rows - end - - def supports_views? - version[0] >= 5 - end - - def version - @version ||= @connection.server_info.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i } - end - - def column_for(table_name, column_name) - unless column = columns(table_name).find { |c| c.name == column_name.to_s } - raise "No such column: #{table_name}.#{column_name}" - end - column - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb deleted file mode 100644 index a3483189..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ /dev/null @@ -1,1078 +0,0 @@ -require 'active_record/connection_adapters/abstract_adapter' - -begin - require_library_or_gem 'pg' -rescue LoadError => e - begin - require_library_or_gem 'postgres' - class PGresult - alias_method :nfields, :num_fields unless self.method_defined?(:nfields) - alias_method :ntuples, :num_tuples unless self.method_defined?(:ntuples) - alias_method :ftype, :type unless self.method_defined?(:ftype) - alias_method :cmd_tuples, :cmdtuples unless self.method_defined?(:cmd_tuples) - end - rescue LoadError - raise e - end -end - -module ActiveRecord - class Base - # Establishes a connection to the database that's used by all Active Record objects - def self.postgresql_connection(config) # :nodoc: - config = config.symbolize_keys - host = config[:host] - port = config[:port] || 5432 - username = config[:username].to_s if config[:username] - password = config[:password].to_s if config[:password] - - if config.has_key?(:database) - database = config[:database] - else - raise ArgumentError, "No database specified. Missing argument: database." - end - - # The postgres drivers don't allow the creation of an unconnected PGconn object, - # so just pass a nil connection object for the time being. - ConnectionAdapters::PostgreSQLAdapter.new(nil, logger, [host, port, nil, nil, database, username, password], config) - end - end - - module ConnectionAdapters - class TableDefinition - def xml(*args) - options = args.extract_options! - column(args[0], 'xml', options) - end - end - # PostgreSQL-specific extensions to column definitions in a table. - class PostgreSQLColumn < Column #:nodoc: - # Instantiates a new PostgreSQL column definition in a table. - def initialize(name, default, sql_type = nil, null = true) - super(name, self.class.extract_value_from_default(default), sql_type, null) - end - - private - def extract_limit(sql_type) - case sql_type - when /^bigint/i; 8 - when /^smallint/i; 2 - else super - end - end - - # Extracts the scale from PostgreSQL-specific data types. - def extract_scale(sql_type) - # Money type has a fixed scale of 2. - sql_type =~ /^money/ ? 2 : super - end - - # Extracts the precision from PostgreSQL-specific data types. - def extract_precision(sql_type) - # Actual code is defined dynamically in PostgreSQLAdapter.connect - # depending on the server specifics - super - end - - # Maps PostgreSQL-specific data types to logical Rails types. - def simplified_type(field_type) - case field_type - # Numeric and monetary types - when /^(?:real|double precision)$/ - :float - # Monetary types - when /^money$/ - :decimal - # Character types - when /^(?:character varying|bpchar)(?:\(\d+\))?$/ - :string - # Binary data types - when /^bytea$/ - :binary - # Date/time types - when /^timestamp with(?:out)? time zone$/ - :datetime - when /^interval$/ - :string - # Geometric types - when /^(?:point|line|lseg|box|"?path"?|polygon|circle)$/ - :string - # Network address types - when /^(?:cidr|inet|macaddr)$/ - :string - # Bit strings - when /^bit(?: varying)?(?:\(\d+\))?$/ - :string - # XML type - when /^xml$/ - :xml - # Arrays - when /^\D+\[\]$/ - :string - # Object identifier types - when /^oid$/ - :integer - # Pass through all types that are not specific to PostgreSQL. - else - super - end - end - - # Extracts the value from a PostgreSQL column default definition. - def self.extract_value_from_default(default) - case default - # Numeric types - when /\A\(?(-?\d+(\.\d*)?\)?)\z/ - $1 - # Character types - when /\A'(.*)'::(?:character varying|bpchar|text)\z/m - $1 - # Character types (8.1 formatting) - when /\AE'(.*)'::(?:character varying|bpchar|text)\z/m - $1.gsub(/\\(\d\d\d)/) { $1.oct.chr } - # Binary data types - when /\A'(.*)'::bytea\z/m - $1 - # Date/time types - when /\A'(.+)'::(?:time(?:stamp)? with(?:out)? time zone|date)\z/ - $1 - when /\A'(.*)'::interval\z/ - $1 - # Boolean type - when 'true' - true - when 'false' - false - # Geometric types - when /\A'(.*)'::(?:point|line|lseg|box|"?path"?|polygon|circle)\z/ - $1 - # Network address types - when /\A'(.*)'::(?:cidr|inet|macaddr)\z/ - $1 - # Bit string types - when /\AB'(.*)'::"?bit(?: varying)?"?\z/ - $1 - # XML type - when /\A'(.*)'::xml\z/m - $1 - # Arrays - when /\A'(.*)'::"?\D+"?\[\]\z/ - $1 - # Object identifier types - when /\A-?\d+\z/ - $1 - else - # Anything else is blank, some user type, or some function - # and we can't know the value of that, so return nil. - nil - end - end - end - end - - module ConnectionAdapters - # The PostgreSQL adapter works both with the native C (http://ruby.scripting.ca/postgres/) and the pure - # Ruby (available both as gem and from http://rubyforge.org/frs/?group_id=234&release_id=1944) drivers. - # - # Options: - # - # * <tt>:host</tt> - Defaults to "localhost". - # * <tt>:port</tt> - Defaults to 5432. - # * <tt>:username</tt> - Defaults to nothing. - # * <tt>:password</tt> - Defaults to nothing. - # * <tt>:database</tt> - The name of the database. No default, must be provided. - # * <tt>:schema_search_path</tt> - An optional schema search path for the connection given as a string of comma-separated schema names. This is backward-compatible with the <tt>:schema_order</tt> option. - # * <tt>:encoding</tt> - An optional client encoding that is used in a <tt>SET client_encoding TO <encoding></tt> call on the connection. - # * <tt>:min_messages</tt> - An optional client min messages that is used in a <tt>SET client_min_messages TO <min_messages></tt> call on the connection. - # * <tt>:allow_concurrency</tt> - If true, use async query methods so Ruby threads don't deadlock; otherwise, use blocking query methods. - class PostgreSQLAdapter < AbstractAdapter - ADAPTER_NAME = 'PostgreSQL'.freeze - - NATIVE_DATABASE_TYPES = { - :primary_key => "serial primary key".freeze, - :string => { :name => "character varying", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "integer" }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "timestamp" }, - :timestamp => { :name => "timestamp" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "bytea" }, - :boolean => { :name => "boolean" }, - :xml => { :name => "xml" } - } - - # Returns 'PostgreSQL' as adapter name for identification purposes. - def adapter_name - ADAPTER_NAME - end - - # Initializes and connects a PostgreSQL adapter. - def initialize(connection, logger, connection_parameters, config) - super(connection, logger) - @connection_parameters, @config = connection_parameters, config - - connect - end - - # Is this connection alive and ready for queries? - def active? - if @connection.respond_to?(:status) - @connection.status == PGconn::CONNECTION_OK - else - # We're asking the driver, not ActiveRecord, so use @connection.query instead of #query - @connection.query 'SELECT 1' - true - end - # postgres-pr raises a NoMethodError when querying if no connection is available. - rescue PGError, NoMethodError - false - end - - # Close then reopen the connection. - def reconnect! - if @connection.respond_to?(:reset) - @connection.reset - configure_connection - else - disconnect! - connect - end - end - - # Close the connection. - def disconnect! - @connection.close rescue nil - end - - def native_database_types #:nodoc: - NATIVE_DATABASE_TYPES - end - - # Does PostgreSQL support migrations? - def supports_migrations? - true - end - - # Does PostgreSQL support finding primary key on non-ActiveRecord tables? - def supports_primary_key? #:nodoc: - true - end - - # Enable standard-conforming strings if available. - def set_standard_conforming_strings - old, self.client_min_messages = client_min_messages, 'panic' - execute('SET standard_conforming_strings = on') rescue nil - ensure - self.client_min_messages = old - end - - def supports_insert_with_returning? - postgresql_version >= 80200 - end - - def supports_ddl_transactions? - true - end - - def supports_savepoints? - true - end - - # Returns the configured supported identifier length supported by PostgreSQL, - # or report the default of 63 on PostgreSQL 7.x. - def table_alias_length - @table_alias_length ||= (postgresql_version >= 80000 ? query('SHOW max_identifier_length')[0][0].to_i : 63) - end - - # QUOTING ================================================== - - # Escapes binary strings for bytea input to the database. - def escape_bytea(original_value) - if @connection.respond_to?(:escape_bytea) - self.class.instance_eval do - define_method(:escape_bytea) do |value| - @connection.escape_bytea(value) if value - end - end - elsif PGconn.respond_to?(:escape_bytea) - self.class.instance_eval do - define_method(:escape_bytea) do |value| - PGconn.escape_bytea(value) if value - end - end - else - self.class.instance_eval do - define_method(:escape_bytea) do |value| - if value - result = '' - value.each_byte { |c| result << sprintf('\\\\%03o', c) } - result - end - end - end - end - escape_bytea(original_value) - end - - # Unescapes bytea output from a database to the binary string it represents. - # NOTE: This is NOT an inverse of escape_bytea! This is only to be used - # on escaped binary output from database drive. - def unescape_bytea(original_value) - # In each case, check if the value actually is escaped PostgreSQL bytea output - # or an unescaped Active Record attribute that was just written. - if @connection.respond_to?(:unescape_bytea) - self.class.instance_eval do - define_method(:unescape_bytea) do |value| - @connection.unescape_bytea(value) if value - end - end - elsif PGconn.respond_to?(:unescape_bytea) - self.class.instance_eval do - define_method(:unescape_bytea) do |value| - PGconn.unescape_bytea(value) if value - end - end - else - raise 'Your PostgreSQL connection does not support unescape_bytea. Try upgrading to pg 0.9.0 or later.' - end - unescape_bytea(original_value) - end - - # Quotes PostgreSQL-specific data types for SQL input. - def quote(value, column = nil) #:nodoc: - if value.kind_of?(String) && column && column.type == :binary - "'#{escape_bytea(value)}'" - elsif value.kind_of?(String) && column && column.sql_type == 'xml' - "xml '#{quote_string(value)}'" - elsif value.kind_of?(Numeric) && column && column.sql_type == 'money' - # Not truly string input, so doesn't require (or allow) escape string syntax. - "'#{value.to_s}'" - elsif value.kind_of?(String) && column && column.sql_type =~ /^bit/ - case value - when /^[01]*$/ - "B'#{value}'" # Bit-string notation - when /^[0-9A-F]*$/i - "X'#{value}'" # Hexadecimal notation - end - else - super - end - end - - # Quotes strings for use in SQL input in the postgres driver for better performance. - def quote_string(original_value) #:nodoc: - if @connection.respond_to?(:escape) - self.class.instance_eval do - define_method(:quote_string) do |s| - @connection.escape(s) - end - end - elsif PGconn.respond_to?(:escape) - self.class.instance_eval do - define_method(:quote_string) do |s| - PGconn.escape(s) - end - end - else - # There are some incorrectly compiled postgres drivers out there - # that don't define PGconn.escape. - self.class.instance_eval do - remove_method(:quote_string) - end - end - quote_string(original_value) - end - - # Checks the following cases: - # - # - table_name - # - "table.name" - # - schema_name.table_name - # - schema_name."table.name" - # - "schema.name".table_name - # - "schema.name"."table.name" - def quote_table_name(name) - schema, name_part = extract_pg_identifier_from_name(name.to_s) - - unless name_part - quote_column_name(schema) - else - table_name, name_part = extract_pg_identifier_from_name(name_part) - "#{quote_column_name(schema)}.#{quote_column_name(table_name)}" - end - end - - # Quotes column names for use in SQL queries. - def quote_column_name(name) #:nodoc: - PGconn.quote_ident(name.to_s) - end - - # Quote date/time values for use in SQL input. Includes microseconds - # if the value is a Time responding to usec. - def quoted_date(value) #:nodoc: - if value.acts_like?(:time) && value.respond_to?(:usec) - "#{super}.#{sprintf("%06d", value.usec)}" - else - super - end - end - - # REFERENTIAL INTEGRITY ==================================== - - def supports_disable_referential_integrity?() #:nodoc: - version = query("SHOW server_version")[0][0].split('.') - (version[0].to_i >= 8 && version[1].to_i >= 1) ? true : false - rescue - return false - end - - def disable_referential_integrity(&block) #:nodoc: - if supports_disable_referential_integrity?() then - execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";")) - end - yield - ensure - if supports_disable_referential_integrity?() then - execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";")) - end - end - - # DATABASE STATEMENTS ====================================== - - # Executes a SELECT query and returns an array of rows. Each row is an - # array of field values. - def select_rows(sql, name = nil) - select_raw(sql, name).last - end - - # Executes an INSERT query and returns the new record's ID - def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - # Extract the table from the insert sql. Yuck. - table = sql.split(" ", 4)[2].gsub('"', '') - - # Try an insert with 'returning id' if available (PG >= 8.2) - if supports_insert_with_returning? - pk, sequence_name = *pk_and_sequence_for(table) unless pk - if pk - id = select_value("#{sql} RETURNING #{quote_column_name(pk)}") - clear_query_cache - return id - end - end - - # Otherwise, insert then grab last_insert_id. - if insert_id = super - insert_id - else - # If neither pk nor sequence name is given, look them up. - unless pk || sequence_name - pk, sequence_name = *pk_and_sequence_for(table) - end - - # If a pk is given, fallback to default sequence name. - # Don't fetch last insert id for a table without a pk. - if pk && sequence_name ||= default_sequence_name(table, pk) - last_insert_id(table, sequence_name) - end - end - end - - # create a 2D array representing the result set - def result_as_array(res) #:nodoc: - # check if we have any binary column and if they need escaping - unescape_col = [] - for j in 0...res.nfields do - # unescape string passed BYTEA field (OID == 17) - unescape_col << ( res.ftype(j)==17 ) - end - - ary = [] - for i in 0...res.ntuples do - ary << [] - for j in 0...res.nfields do - data = res.getvalue(i,j) - data = unescape_bytea(data) if unescape_col[j] and data.is_a?(String) - ary[i] << data - end - end - return ary - end - - - # Queries the database and returns the results in an Array-like object - def query(sql, name = nil) #:nodoc: - log(sql, name) do - if @async - res = @connection.async_exec(sql) - else - res = @connection.exec(sql) - end - return result_as_array(res) - end - end - - # Executes an SQL statement, returning a PGresult object on success - # or raising a PGError exception otherwise. - def execute(sql, name = nil) - log(sql, name) do - if @async - @connection.async_exec(sql) - else - @connection.exec(sql) - end - end - end - - # Executes an UPDATE query and returns the number of affected tuples. - def update_sql(sql, name = nil) - super.cmd_tuples - end - - # Begins a transaction. - def begin_db_transaction - execute "BEGIN" - end - - # Commits a transaction. - def commit_db_transaction - execute "COMMIT" - end - - # Aborts a transaction. - def rollback_db_transaction - execute "ROLLBACK" - end - - if defined?(PGconn::PQTRANS_IDLE) - # The ruby-pg driver supports inspecting the transaction status, - # while the ruby-postgres driver does not. - def outside_transaction? - @connection.transaction_status == PGconn::PQTRANS_IDLE - end - end - - def create_savepoint - execute("SAVEPOINT #{current_savepoint_name}") - end - - def rollback_to_savepoint - execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}") - end - - def release_savepoint - execute("RELEASE SAVEPOINT #{current_savepoint_name}") - end - - # SCHEMA STATEMENTS ======================================== - - def recreate_database(name) #:nodoc: - drop_database(name) - create_database(name) - end - - # Create a new PostgreSQL database. Options include <tt>:owner</tt>, <tt>:template</tt>, - # <tt>:encoding</tt>, <tt>:tablespace</tt>, and <tt>:connection_limit</tt> (note that MySQL uses - # <tt>:charset</tt> while PostgreSQL uses <tt>:encoding</tt>). - # - # Example: - # create_database config[:database], config - # create_database 'foo_development', :encoding => 'unicode' - def create_database(name, options = {}) - options = options.reverse_merge(:encoding => "utf8") - - option_string = options.symbolize_keys.sum do |key, value| - case key - when :owner - " OWNER = \"#{value}\"" - when :template - " TEMPLATE = \"#{value}\"" - when :encoding - " ENCODING = '#{value}'" - when :tablespace - " TABLESPACE = \"#{value}\"" - when :connection_limit - " CONNECTION LIMIT = #{value}" - else - "" - end - end - - execute "CREATE DATABASE #{quote_table_name(name)}#{option_string}" - end - - # Drops a PostgreSQL database - # - # Example: - # drop_database 'matt_development' - def drop_database(name) #:nodoc: - if postgresql_version >= 80200 - execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}" - else - begin - execute "DROP DATABASE #{quote_table_name(name)}" - rescue ActiveRecord::StatementInvalid - @logger.warn "#{name} database doesn't exist." if @logger - end - end - end - - - # Returns the list of all tables in the schema search path or a specified schema. - def tables(name = nil) - schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',') - query(<<-SQL, name).map { |row| row[0] } - SELECT tablename - FROM pg_tables - WHERE schemaname IN (#{schemas}) - SQL - end - - # Returns the list of all indexes for a table. - def indexes(table_name, name = nil) - schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',') - result = query(<<-SQL, name) - SELECT distinct i.relname, d.indisunique, d.indkey, t.oid - FROM pg_class t, pg_class i, pg_index d - WHERE i.relkind = 'i' - AND d.indexrelid = i.oid - AND d.indisprimary = 'f' - AND t.oid = d.indrelid - AND t.relname = '#{table_name}' - AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (#{schemas}) ) - ORDER BY i.relname - SQL - - - indexes = [] - - indexes = result.map do |row| - index_name = row[0] - unique = row[1] == 't' - indkey = row[2].split(" ") - oid = row[3] - - columns = query(<<-SQL, "Columns for index #{row[0]} on #{table_name}").inject({}) {|attlist, r| attlist[r[1]] = r[0]; attlist} - SELECT a.attname, a.attnum - FROM pg_attribute a - WHERE a.attrelid = #{oid} - AND a.attnum IN (#{indkey.join(",")}) - SQL - - column_names = indkey.map {|attnum| columns[attnum] } - IndexDefinition.new(table_name, index_name, unique, column_names) - - end - - indexes - end - - # Returns the list of all column definitions for a table. - def columns(table_name, name = nil) - # Limit, precision, and scale are all handled by the superclass. - column_definitions(table_name).collect do |name, type, default, notnull| - PostgreSQLColumn.new(name, default, type, notnull == 'f') - end - end - - # Returns the current database name. - def current_database - query('select current_database()')[0][0] - end - - # Returns the current database encoding format. - def encoding - query(<<-end_sql)[0][0] - SELECT pg_encoding_to_char(pg_database.encoding) FROM pg_database - WHERE pg_database.datname LIKE '#{current_database}' - end_sql - end - - # Sets the schema search path to a string of comma-separated schema names. - # Names beginning with $ have to be quoted (e.g. $user => '$user'). - # See: http://www.postgresql.org/docs/current/static/ddl-schemas.html - # - # This should be not be called manually but set in database.yml. - def schema_search_path=(schema_csv) - if schema_csv - execute "SET search_path TO #{schema_csv}" - @schema_search_path = schema_csv - end - end - - # Returns the active schema search path. - def schema_search_path - @schema_search_path ||= query('SHOW search_path')[0][0] - end - - # Returns the current client message level. - def client_min_messages - query('SHOW client_min_messages')[0][0] - end - - # Set the client message level. - def client_min_messages=(level) - execute("SET client_min_messages TO '#{level}'") - end - - # Returns the sequence name for a table's primary key or some other specified key. - def default_sequence_name(table_name, pk = nil) #:nodoc: - default_pk, default_seq = pk_and_sequence_for(table_name) - default_seq || "#{table_name}_#{pk || default_pk || 'id'}_seq" - end - - # Resets the sequence of a table's primary key to the maximum value. - def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc: - unless pk and sequence - default_pk, default_sequence = pk_and_sequence_for(table) - pk ||= default_pk - sequence ||= default_sequence - end - if pk - if sequence - quoted_sequence = quote_column_name(sequence) - - select_value <<-end_sql, 'Reset sequence' - SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false) - end_sql - else - @logger.warn "#{table} has primary key #{pk} with no default sequence" if @logger - end - end - end - - # Returns a table's primary key and belonging sequence. - def pk_and_sequence_for(table) #:nodoc: - # First try looking for a sequence with a dependency on the - # given table's primary key. - result = query(<<-end_sql, 'PK and serial sequence')[0] - SELECT attr.attname, seq.relname - FROM pg_class seq, - pg_attribute attr, - pg_depend dep, - pg_namespace name, - pg_constraint cons - WHERE seq.oid = dep.objid - AND seq.relkind = 'S' - AND attr.attrelid = dep.refobjid - AND attr.attnum = dep.refobjsubid - AND attr.attrelid = cons.conrelid - AND attr.attnum = cons.conkey[1] - AND cons.contype = 'p' - AND dep.refobjid = '#{quote_table_name(table)}'::regclass - end_sql - - if result.nil? or result.empty? - # If that fails, try parsing the primary key's default value. - # Support the 7.x and 8.0 nextval('foo'::text) as well as - # the 8.1+ nextval('foo'::regclass). - result = query(<<-end_sql, 'PK and custom sequence')[0] - SELECT attr.attname, - CASE - WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN - substr(split_part(def.adsrc, '''', 2), - strpos(split_part(def.adsrc, '''', 2), '.')+1) - ELSE split_part(def.adsrc, '''', 2) - END - FROM pg_class t - JOIN pg_attribute attr ON (t.oid = attrelid) - JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum) - JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1]) - WHERE t.oid = '#{quote_table_name(table)}'::regclass - AND cons.contype = 'p' - AND def.adsrc ~* 'nextval' - end_sql - end - - # [primary_key, sequence] - [result.first, result.last] - rescue - nil - end - - # Returns just a table's primary key - def primary_key(table) - pk_and_sequence = pk_and_sequence_for(table) - pk_and_sequence && pk_and_sequence.first - end - - # Renames a table. - def rename_table(name, new_name) - execute "ALTER TABLE #{quote_table_name(name)} RENAME TO #{quote_table_name(new_name)}" - end - - # Adds a new column to the named table. - # See TableDefinition#column for details of the options you can use. - def add_column(table_name, column_name, type, options = {}) - default = options[:default] - notnull = options[:null] == false - - # Add the column. - execute("ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}") - - change_column_default(table_name, column_name, default) if options_include_default?(options) - change_column_null(table_name, column_name, false, default) if notnull - end - - # Changes the column of a table. - def change_column(table_name, column_name, type, options = {}) - quoted_table_name = quote_table_name(table_name) - - begin - execute "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - rescue ActiveRecord::StatementInvalid => e - raise e if postgresql_version > 80000 - # This is PostgreSQL 7.x, so we have to use a more arcane way of doing it. - begin - begin_db_transaction - tmp_column_name = "#{column_name}_ar_tmp" - add_column(table_name, tmp_column_name, type, options) - execute "UPDATE #{quoted_table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})" - remove_column(table_name, column_name) - rename_column(table_name, tmp_column_name, column_name) - commit_db_transaction - rescue - rollback_db_transaction - end - end - - change_column_default(table_name, column_name, options[:default]) if options_include_default?(options) - change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null) - end - - # Changes the default value of a table column. - def change_column_default(table_name, column_name, default) - execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} SET DEFAULT #{quote(default)}" - end - - def change_column_null(table_name, column_name, null, default = nil) - unless null || default.nil? - execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") - end - execute("ALTER TABLE #{quote_table_name(table_name)} ALTER #{quote_column_name(column_name)} #{null ? 'DROP' : 'SET'} NOT NULL") - end - - # Renames a column in a table. - def rename_column(table_name, column_name, new_column_name) - execute "ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}" - end - - def remove_index!(table_name, index_name) #:nodoc: - execute "DROP INDEX #{quote_table_name(index_name)}" - end - - def index_name_length - 63 - end - - # Maps logical Rails types to PostgreSQL-specific data types. - def type_to_sql(type, limit = nil, precision = nil, scale = nil) - return super unless type.to_s == 'integer' - - case limit - when 1..2; 'smallint' - when 3..4, nil; 'integer' - when 5..8; 'bigint' - else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.") - end - end - - # Returns a SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause. - # - # PostgreSQL requires the ORDER BY columns in the select list for distinct queries, and - # requires that the ORDER BY include the distinct column. - # - # distinct("posts.id", "posts.created_at desc") - def distinct(columns, order_by) #:nodoc: - return "DISTINCT #{columns}" if order_by.blank? - - # Construct a clean list of column names from the ORDER BY clause, removing - # any ASC/DESC modifiers - order_columns = order_by.split(',').collect { |s| s.split.first } - order_columns.delete_if &:blank? - order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| "#{s} AS alias_#{i}" } - - # Return a DISTINCT ON() clause that's distinct on the columns we want but includes - # all the required columns for the ORDER BY to work properly. - sql = "DISTINCT ON (#{columns}) #{columns}, " - sql << order_columns * ', ' - end - - # Returns an ORDER BY clause for the passed order option. - # - # PostgreSQL does not allow arbitrary ordering when using DISTINCT ON, so we work around this - # by wrapping the +sql+ string as a sub-select and ordering in that query. - def add_order_by_for_association_limiting!(sql, options) #:nodoc: - return sql if options[:order].blank? - - order = options[:order].split(',').collect { |s| s.strip }.reject(&:blank?) - order.map! { |s| 'DESC' if s =~ /\bdesc$/i } - order = order.zip((0...order.size).to_a).map { |s,i| "id_list.alias_#{i} #{s}" }.join(', ') - - sql.replace "SELECT * FROM (#{sql}) AS id_list ORDER BY #{order}" - end - - protected - # Returns the version of the connected PostgreSQL version. - def postgresql_version - @postgresql_version ||= - if @connection.respond_to?(:server_version) - @connection.server_version - else - # Mimic PGconn.server_version behavior - begin - query('SELECT version()')[0][0] =~ /PostgreSQL (\d+)\.(\d+)\.(\d+)/ - ($1.to_i * 10000) + ($2.to_i * 100) + $3.to_i - rescue - 0 - end - end - end - - private - # The internal PostgreSQL identifier of the money data type. - MONEY_COLUMN_TYPE_OID = 790 #:nodoc: - - # Connects to a PostgreSQL server and sets up the adapter depending on the - # connected server's characteristics. - def connect - @connection = PGconn.connect(*@connection_parameters) - PGconn.translate_results = false if PGconn.respond_to?(:translate_results=) - - # Ignore async_exec and async_query when using postgres-pr. - @async = @config[:allow_concurrency] && @connection.respond_to?(:async_exec) - - # Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of - # PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision - # should know about this but can't detect it there, so deal with it here. - money_precision = (postgresql_version >= 80300) ? 19 : 10 - PostgreSQLColumn.module_eval(<<-end_eval) - def extract_precision(sql_type) # def extract_precision(sql_type) - if sql_type =~ /^money$/ # if sql_type =~ /^money$/ - #{money_precision} # 19 - else # else - super # super - end # end - end # end - end_eval - - configure_connection - end - - # Configures the encoding, verbosity, and schema search path of the connection. - # This is called by #connect and should not be called manually. - def configure_connection - if @config[:encoding] - if @connection.respond_to?(:set_client_encoding) - @connection.set_client_encoding(@config[:encoding]) - else - execute("SET client_encoding TO '#{@config[:encoding]}'") - end - end - self.client_min_messages = @config[:min_messages] if @config[:min_messages] - self.schema_search_path = @config[:schema_search_path] || @config[:schema_order] - - # Use standard-conforming strings if available so we don't have to do the E'...' dance. - set_standard_conforming_strings - end - - # Returns the current ID of a table's sequence. - def last_insert_id(table, sequence_name) #:nodoc: - Integer(select_value("SELECT currval('#{sequence_name}')")) - end - - # Executes a SELECT query and returns the results, performing any data type - # conversions that are required to be performed here instead of in PostgreSQLColumn. - def select(sql, name = nil) - fields, rows = select_raw(sql, name) - result = [] - for row in rows - row_hash = {} - fields.each_with_index do |f, i| - row_hash[f] = row[i] - end - result << row_hash - end - result - end - - def select_raw(sql, name = nil) - res = execute(sql, name) - results = result_as_array(res) - fields = [] - rows = [] - if res.ntuples > 0 - fields = res.fields - results.each do |row| - hashed_row = {} - row.each_index do |cell_index| - # If this is a money type column and there are any currency symbols, - # then strip them off. Indeed it would be prettier to do this in - # PostgreSQLColumn.string_to_decimal but would break form input - # fields that call value_before_type_cast. - if res.ftype(cell_index) == MONEY_COLUMN_TYPE_OID - # Because money output is formatted according to the locale, there are two - # cases to consider (note the decimal separators): - # (1) $12,345,678.12 - # (2) $12.345.678,12 - case column = row[cell_index] - when /^-?\D+[\d,]+\.\d{2}$/ # (1) - row[cell_index] = column.gsub(/[^-\d\.]/, '') - when /^-?\D+[\d\.]+,\d{2}$/ # (2) - row[cell_index] = column.gsub(/[^-\d,]/, '').sub(/,/, '.') - end - end - - hashed_row[fields[cell_index]] = column - end - rows << row - end - end - res.clear - return fields, rows - end - - # Returns the list of a table's column names, data types, and default values. - # - # The underlying query is roughly: - # SELECT column.name, column.type, default.value - # FROM column LEFT JOIN default - # ON column.table_id = default.table_id - # AND column.num = default.column_num - # WHERE column.table_id = get_table_id('table_name') - # AND column.num > 0 - # AND NOT column.is_dropped - # ORDER BY column.num - # - # If the table name is not prefixed with a schema, the database will - # take the first match from the schema search path. - # - # Query implementation notes: - # - format_type includes the column size constraint, e.g. varchar(50) - # - ::regclass is a function that gives the id for a table name - def column_definitions(table_name) #:nodoc: - query <<-end_sql - SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull - FROM pg_attribute a LEFT JOIN pg_attrdef d - ON a.attrelid = d.adrelid AND a.attnum = d.adnum - WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass - AND a.attnum > 0 AND NOT a.attisdropped - ORDER BY a.attnum - end_sql - end - - def extract_pg_identifier_from_name(name) - match_data = name[0,1] == '"' ? name.match(/\"([^\"]+)\"/) : name.match(/([^\.]+)/) - - if match_data - rest = name[match_data[0].length..-1] - rest = rest[1..-1] if rest[0,1] == "." - [match_data[1], (rest.length > 0 ? rest : nil)] - end - end - end - end -end - diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb deleted file mode 100644 index c6086a2f..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'active_record/connection_adapters/sqlite_adapter' - -module ActiveRecord - class Base - # sqlite3 adapter reuses sqlite_connection. - def self.sqlite3_connection(config) # :nodoc: - parse_sqlite_config!(config) - - unless self.class.const_defined?(:SQLite3) - require_library_or_gem(config[:adapter]) - end - - db = SQLite3::Database.new( - config[:database], - :results_as_hash => true, - :type_translation => false - ) - - db.busy_timeout(config[:timeout]) unless config[:timeout].nil? - - ConnectionAdapters::SQLite3Adapter.new(db, logger, config) - end - end - - module ConnectionAdapters #:nodoc: - class SQLite3Adapter < SQLiteAdapter # :nodoc: - def table_structure(table_name) - @connection.table_info(quote_table_name(table_name)).tap do |structure| - raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb deleted file mode 100644 index 242f3f7e..00000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ /dev/null @@ -1,454 +0,0 @@ -# encoding: binary -require 'active_record/connection_adapters/abstract_adapter' - -module ActiveRecord - class Base - class << self - # Establishes a connection to the database that's used by all Active Record objects - def sqlite_connection(config) # :nodoc: - parse_sqlite_config!(config) - - unless self.class.const_defined?(:SQLite) - require_library_or_gem(config[:adapter]) - - db = SQLite::Database.new(config[:database], 0) - db.show_datatypes = "ON" if !defined? SQLite::Version - db.results_as_hash = true if defined? SQLite::Version - db.type_translation = false - - message = "Support for SQLite2Adapter and DeprecatedSQLiteAdapter has been removed from Rails 3. " - message << "You should migrate to SQLite 3+ or use the plugin from git://github.com/rails/sqlite2_adapter.git with Rails 3." - ActiveSupport::Deprecation.warn(message) - - # "Downgrade" deprecated sqlite API - if SQLite.const_defined?(:Version) - ConnectionAdapters::SQLite2Adapter.new(db, logger, config) - else - ConnectionAdapters::DeprecatedSQLiteAdapter.new(db, logger, config) - end - end - end - - private - def parse_sqlite_config!(config) - if config.include?(:dbfile) - ActiveSupport::Deprecation.warn "Please update config/database.yml to use 'database' instead of 'dbfile'" - end - - config[:database] ||= config[:dbfile] - # Require database. - unless config[:database] - raise ArgumentError, "No database file specified. Missing argument: database" - end - - # Allow database path relative to RAILS_ROOT, but only if - # the database path is not the special path that tells - # Sqlite to build a database only in memory. - if Object.const_defined?(:RAILS_ROOT) && ':memory:' != config[:database] - config[:database] = File.expand_path(config[:database], RAILS_ROOT) - end - end - end - end - - module ConnectionAdapters #:nodoc: - class SQLiteColumn < Column #:nodoc: - class << self - def string_to_binary(value) - value = value.dup.force_encoding(Encoding::BINARY) if value.respond_to?(:force_encoding) - value.gsub(/\0|\%/n) do |b| - case b - when "\0" then "%00" - when "%" then "%25" - end - end - end - - def binary_to_string(value) - value = value.dup.force_encoding(Encoding::BINARY) if value.respond_to?(:force_encoding) - value.gsub(/%00|%25/n) do |b| - case b - when "%00" then "\0" - when "%25" then "%" - end - end - end - end - end - - # The SQLite adapter works with both the 2.x and 3.x series of SQLite with the sqlite-ruby drivers (available both as gems and - # from http://rubyforge.org/projects/sqlite-ruby/). - # - # Options: - # - # * <tt>:database</tt> - Path to the database file. - class SQLiteAdapter < AbstractAdapter - class Version - include Comparable - - def initialize(version_string) - @version = version_string.split('.').map(&:to_i) - end - - def <=>(version_string) - @version <=> version_string.split('.').map(&:to_i) - end - end - - def initialize(connection, logger, config) - super(connection, logger) - @config = config - end - - def adapter_name #:nodoc: - 'SQLite' - end - - def supports_ddl_transactions? - sqlite_version >= '2.0.0' - end - - def supports_migrations? #:nodoc: - true - end - - def supports_primary_key? #:nodoc: - true - end - - def requires_reloading? - true - end - - def supports_add_column? - sqlite_version >= '3.1.6' - end - - def disconnect! - super - @connection.close rescue nil - end - - def supports_count_distinct? #:nodoc: - sqlite_version >= '3.2.6' - end - - def supports_autoincrement? #:nodoc: - sqlite_version >= '3.1.0' - end - - def native_database_types #:nodoc: - { - :primary_key => default_primary_key_type, - :string => { :name => "varchar", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "integer" }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "datetime" }, - :timestamp => { :name => "datetime" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "blob" }, - :boolean => { :name => "boolean" } - } - end - - - # QUOTING ================================================== - - def quote_string(s) #:nodoc: - @connection.class.quote(s) - end - - def quote_column_name(name) #:nodoc: - %Q("#{name.to_s.gsub('"', '""')}") - end - - - # DATABASE STATEMENTS ====================================== - - def execute(sql, name = nil) #:nodoc: - catch_schema_changes { log(sql, name) { @connection.execute(sql) } } - end - - def update_sql(sql, name = nil) #:nodoc: - super - @connection.changes - end - - def delete_sql(sql, name = nil) #:nodoc: - sql += " WHERE 1=1" unless sql =~ /WHERE/i - super sql, name - end - - def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: - super || @connection.last_insert_row_id - end - - def select_rows(sql, name = nil) - execute(sql, name).map do |row| - (0...(row.size / 2)).map { |i| row[i] } - end - end - - def begin_db_transaction #:nodoc: - catch_schema_changes { @connection.transaction } - end - - def commit_db_transaction #:nodoc: - catch_schema_changes { @connection.commit } - end - - def rollback_db_transaction #:nodoc: - catch_schema_changes { @connection.rollback } - end - - # SELECT ... FOR UPDATE is redundant since the table is locked. - def add_lock!(sql, options) #:nodoc: - sql - end - - - # SCHEMA STATEMENTS ======================================== - - def tables(name = nil) #:nodoc: - sql = <<-SQL - SELECT name - FROM sqlite_master - WHERE type = 'table' AND NOT name = 'sqlite_sequence' - SQL - - execute(sql, name).map do |row| - row['name'] - end - end - - def columns(table_name, name = nil) #:nodoc: - table_structure(table_name).map do |field| - SQLiteColumn.new(field['name'], field['dflt_value'], field['type'], field['notnull'].to_i == 0) - end - end - - def indexes(table_name, name = nil) #:nodoc: - execute("PRAGMA index_list(#{quote_table_name(table_name)})", name).map do |row| - index = IndexDefinition.new(table_name, row['name']) - index.unique = row['unique'].to_i != 0 - index.columns = execute("PRAGMA index_info('#{index.name}')").map { |col| col['name'] } - index - end - end - - def primary_key(table_name) #:nodoc: - column = table_structure(table_name).find {|field| field['pk'].to_i == 1} - column ? column['name'] : nil - end - - def remove_index!(table_name, index_name) #:nodoc: - execute "DROP INDEX #{quote_column_name(index_name)}" - end - - def rename_table(name, new_name) - execute "ALTER TABLE #{name} RENAME TO #{new_name}" - end - - # See: http://www.sqlite.org/lang_altertable.html - # SQLite has an additional restriction on the ALTER TABLE statement - def valid_alter_table_options( type, options) - type.to_sym != :primary_key - end - - def add_column(table_name, column_name, type, options = {}) #:nodoc: - if supports_add_column? && valid_alter_table_options( type, options ) - super(table_name, column_name, type, options) - else - alter_table(table_name) do |definition| - definition.column(column_name, type, options) - end - end - end - - def remove_column(table_name, *column_names) #:nodoc: - raise ArgumentError.new("You must specify at least one column name. Example: remove_column(:people, :first_name)") if column_names.empty? - column_names.flatten.each do |column_name| - alter_table(table_name) do |definition| - definition.columns.delete(definition[column_name]) - end - end - end - alias :remove_columns :remove_column - - def change_column_default(table_name, column_name, default) #:nodoc: - alter_table(table_name) do |definition| - definition[column_name].default = default - end - end - - def change_column_null(table_name, column_name, null, default = nil) - unless null || default.nil? - execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") - end - alter_table(table_name) do |definition| - definition[column_name].null = null - end - end - - def change_column(table_name, column_name, type, options = {}) #:nodoc: - alter_table(table_name) do |definition| - include_default = options_include_default?(options) - definition[column_name].instance_eval do - self.type = type - self.limit = options[:limit] if options.include?(:limit) - self.default = options[:default] if include_default - self.null = options[:null] if options.include?(:null) - end - end - end - - def rename_column(table_name, column_name, new_column_name) #:nodoc: - unless columns(table_name).detect{|c| c.name == column_name.to_s } - raise ActiveRecord::ActiveRecordError, "Missing column #{table_name}.#{column_name}" - end - alter_table(table_name, :rename => {column_name.to_s => new_column_name.to_s}) - end - - def empty_insert_statement(table_name) - "INSERT INTO #{table_name} VALUES(NULL)" - end - - protected - def select(sql, name = nil) #:nodoc: - execute(sql, name).map do |row| - record = {} - row.each_key do |key| - if key.is_a?(String) - record[key.sub(/^"?\w+"?\./, '')] = row[key] - end - end - record - end - end - - def table_structure(table_name) - execute("PRAGMA table_info(#{quote_table_name(table_name)})").tap do |structure| - raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? - end - end - - def alter_table(table_name, options = {}) #:nodoc: - altered_table_name = "altered_#{table_name}" - caller = lambda {|definition| yield definition if block_given?} - - transaction do - move_table(table_name, altered_table_name, - options.merge(:temporary => true)) - move_table(altered_table_name, table_name, &caller) - end - end - - def move_table(from, to, options = {}, &block) #:nodoc: - copy_table(from, to, options, &block) - drop_table(from) - end - - def copy_table(from, to, options = {}) #:nodoc: - options = options.merge(:id => (!columns(from).detect{|c| c.name == 'id'}.nil? && 'id' == primary_key(from).to_s)) - create_table(to, options) do |definition| - @definition = definition - columns(from).each do |column| - column_name = options[:rename] ? - (options[:rename][column.name] || - options[:rename][column.name.to_sym] || - column.name) : column.name - - @definition.column(column_name, column.type, - :limit => column.limit, :default => column.default, - :null => column.null) - end - @definition.primary_key(primary_key(from)) if primary_key(from) - yield @definition if block_given? - end - - copy_table_indexes(from, to, options[:rename] || {}) - copy_table_contents(from, to, - @definition.columns.map {|column| column.name}, - options[:rename] || {}) - end - - def copy_table_indexes(from, to, rename = {}) #:nodoc: - indexes(from).each do |index| - name = index.name - if to == "altered_#{from}" - name = "temp_#{name}" - elsif from == "altered_#{to}" - name = name[5..-1] - end - - to_column_names = columns(to).map(&:name) - columns = index.columns.map {|c| rename[c] || c }.select do |column| - to_column_names.include?(column) - end - - unless columns.empty? - # index name can't be the same - opts = { :name => name.gsub(/_(#{from})_/, "_#{to}_") } - opts[:unique] = true if index.unique - add_index(to, columns, opts) - end - end - end - - def copy_table_contents(from, to, columns, rename = {}) #:nodoc: - column_mappings = Hash[*columns.map {|name| [name, name]}.flatten] - rename.inject(column_mappings) {|map, a| map[a.last] = a.first; map} - from_columns = columns(from).collect {|col| col.name} - columns = columns.find_all{|col| from_columns.include?(column_mappings[col])} - quoted_columns = columns.map { |col| quote_column_name(col) } * ',' - - quoted_to = quote_table_name(to) - @connection.execute "SELECT * FROM #{quote_table_name(from)}" do |row| - sql = "INSERT INTO #{quoted_to} (#{quoted_columns}) VALUES (" - sql << columns.map {|col| quote row[column_mappings[col]]} * ', ' - sql << ')' - @connection.execute sql - end - end - - def catch_schema_changes - return yield - rescue ActiveRecord::StatementInvalid => exception - if exception.message =~ /database schema has changed/ - reconnect! - retry - else - raise - end - end - - def sqlite_version - @sqlite_version ||= SQLiteAdapter::Version.new(select_value('select sqlite_version(*)')) - end - - def default_primary_key_type - if supports_autoincrement? - 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze - else - 'INTEGER PRIMARY KEY NOT NULL'.freeze - end - end - end - - class SQLite2Adapter < SQLiteAdapter # :nodoc: - def rename_table(name, new_name) - move_table(name, new_name) - end - end - - class DeprecatedSQLiteAdapter < SQLite2Adapter # :nodoc: - def insert(sql, name = nil, pk = nil, id_value = nil) - execute(sql, name = nil) - id_value || @connection.last_insert_rowid - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/dirty.rb b/vendor/rails/activerecord/lib/active_record/dirty.rb deleted file mode 100644 index 1db8fef6..00000000 --- a/vendor/rails/activerecord/lib/active_record/dirty.rb +++ /dev/null @@ -1,183 +0,0 @@ -module ActiveRecord - # Track unsaved attribute changes. - # - # A newly instantiated object is unchanged: - # person = Person.find_by_name('uncle bob') - # person.changed? # => false - # - # Change the name: - # person.name = 'Bob' - # person.changed? # => true - # person.name_changed? # => true - # person.name_was # => 'uncle bob' - # person.name_change # => ['uncle bob', 'Bob'] - # person.name = 'Bill' - # person.name_change # => ['uncle bob', 'Bill'] - # - # Save the changes: - # person.save - # person.changed? # => false - # person.name_changed? # => false - # - # Assigning the same value leaves the attribute unchanged: - # person.name = 'Bill' - # person.name_changed? # => false - # person.name_change # => nil - # - # Which attributes have changed? - # person.name = 'bob' - # person.changed # => ['name'] - # person.changes # => { 'name' => ['Bill', 'bob'] } - # - # Before modifying an attribute in-place: - # person.name_will_change! - # person.name << 'by' - # person.name_change # => ['uncle bob', 'uncle bobby'] - module Dirty - DIRTY_SUFFIXES = ['_changed?', '_change', '_will_change!', '_was'] - - def self.included(base) - base.attribute_method_suffix *DIRTY_SUFFIXES - base.alias_method_chain :write_attribute, :dirty - base.alias_method_chain :save, :dirty - base.alias_method_chain :save!, :dirty - base.alias_method_chain :update, :dirty - base.alias_method_chain :reload, :dirty - - base.class_attribute :partial_updates - base.partial_updates = true - - base.send(:extend, ClassMethods) - end - - # Do any attributes have unsaved changes? - # person.changed? # => false - # person.name = 'bob' - # person.changed? # => true - def changed? - !changed_attributes.empty? - end - - # List of attributes with unsaved changes. - # person.changed # => [] - # person.name = 'bob' - # person.changed # => ['name'] - def changed - changed_attributes.keys - end - - # Map of changed attrs => [original value, new value]. - # person.changes # => {} - # person.name = 'bob' - # person.changes # => { 'name' => ['bill', 'bob'] } - def changes - changed.inject({}) { |h, attr| h[attr] = attribute_change(attr); h } - end - - # Attempts to +save+ the record and clears changed attributes if successful. - def save_with_dirty(*args) #:nodoc: - if status = save_without_dirty(*args) - changed_attributes.clear - end - status - end - - # Attempts to <tt>save!</tt> the record and clears changed attributes if successful. - def save_with_dirty!(*args) #:nodoc: - status = save_without_dirty!(*args) - changed_attributes.clear - status - end - - # <tt>reload</tt> the record and clears changed attributes. - def reload_with_dirty(*args) #:nodoc: - record = reload_without_dirty(*args) - changed_attributes.clear - record - end - - private - # Map of change <tt>attr => original value</tt>. - def changed_attributes - @changed_attributes ||= {} - end - - # Handle <tt>*_changed?</tt> for +method_missing+. - def attribute_changed?(attr) - changed_attributes.include?(attr) - end - - # Handle <tt>*_change</tt> for +method_missing+. - def attribute_change(attr) - [changed_attributes[attr], __send__(attr)] if attribute_changed?(attr) - end - - # Handle <tt>*_was</tt> for +method_missing+. - def attribute_was(attr) - attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr) - end - - # Handle <tt>*_will_change!</tt> for +method_missing+. - def attribute_will_change!(attr) - changed_attributes[attr] = clone_attribute_value(:read_attribute, attr) - end - - # Wrap write_attribute to remember original attribute value. - def write_attribute_with_dirty(attr, value) - attr = attr.to_s - - # The attribute already has an unsaved change. - if changed_attributes.include?(attr) - old = changed_attributes[attr] - changed_attributes.delete(attr) unless field_changed?(attr, old, value) - else - old = clone_attribute_value(:read_attribute, attr) - changed_attributes[attr] = old if field_changed?(attr, old, value) - end - - # Carry on. - write_attribute_without_dirty(attr, value) - end - - def update_with_dirty - if partial_updates? - # Serialized attributes should always be written in case they've been - # changed in place. - update_without_dirty(changed | (attributes.keys & self.class.serialized_attributes.keys)) - else - update_without_dirty - end - end - - def field_changed?(attr, old, value) - if column = column_for_attribute(attr) - if column.number? && column.null && (old.nil? || old == 0) && value.blank? - # For nullable numeric columns, NULL gets stored in database for blank (i.e. '') values. - # Hence we don't record it as a change if the value changes from nil to ''. - # If an old value of 0 is set to '' we want this to get changed to nil as otherwise it'll - # be typecast back to 0 (''.to_i => 0) - value = nil - else - value = column.type_cast(value) - end - end - - old != value - end - - module ClassMethods - def self.extended(base) - base.singleton_class.alias_method_chain(:alias_attribute, :dirty) - end - - def alias_attribute_with_dirty(new_name, old_name) - alias_attribute_without_dirty(new_name, old_name) - DIRTY_SUFFIXES.each do |suffix| - module_eval <<-STR, __FILE__, __LINE__ + 1 - def #{new_name}#{suffix}; self.#{old_name}#{suffix}; end # def subject_changed?; self.title_changed?; end - STR - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb b/vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb deleted file mode 100644 index 8f9f05ce..00000000 --- a/vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb +++ /dev/null @@ -1,41 +0,0 @@ -module ActiveRecord - class DynamicFinderMatch - def self.match(method) - df_match = self.new(method) - df_match.finder ? df_match : nil - end - - def initialize(method) - @finder = :first - case method.to_s - when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/ - @finder = :last if $1 == 'last_by' - @finder = :all if $1 == 'all_by' - names = $2 - when /^find_by_([_a-zA-Z]\w*)\!$/ - @bang = true - names = $1 - when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/ - @instantiator = $1 == 'initialize' ? :new : :create - names = $2 - else - @finder = nil - end - @attribute_names = names && names.split('_and_') - end - - attr_reader :finder, :attribute_names, :instantiator - - def finder? - !@finder.nil? && @instantiator.nil? - end - - def instantiator? - @finder == :first && !@instantiator.nil? - end - - def bang? - @bang - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb b/vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb deleted file mode 100644 index f796ba66..00000000 --- a/vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb +++ /dev/null @@ -1,25 +0,0 @@ -module ActiveRecord - class DynamicScopeMatch - def self.match(method) - ds_match = self.new(method) - ds_match.scope ? ds_match : nil - end - - def initialize(method) - @scope = true - case method.to_s - when /^scoped_by_([_a-zA-Z]\w*)$/ - names = $1 - else - @scope = nil - end - @attribute_names = names && names.split('_and_') - end - - attr_reader :scope, :attribute_names - - def scope? - !@scope.nil? - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/fixtures.rb b/vendor/rails/activerecord/lib/active_record/fixtures.rb deleted file mode 100644 index ef8325f5..00000000 --- a/vendor/rails/activerecord/lib/active_record/fixtures.rb +++ /dev/null @@ -1,997 +0,0 @@ -require 'erb' -require 'yaml' -require 'csv' -require 'zlib' -require 'active_support/dependencies' -require 'active_support/test_case' - -if RUBY_VERSION < '1.9' - module YAML #:nodoc: - class Omap #:nodoc: - def keys; map { |k, v| k } end - def values; map { |k, v| v } end - end - end -end - -if defined? ActiveRecord - class FixtureClassNotFound < ActiveRecord::ActiveRecordError #:nodoc: - end -else - class FixtureClassNotFound < StandardError #:nodoc: - end -end - -# Fixtures are a way of organizing data that you want to test against; in short, sample data. -# -# = Fixture formats -# -# Fixtures come in 3 flavors: -# -# 1. YAML fixtures -# 2. CSV fixtures -# 3. Single-file fixtures -# -# == YAML fixtures -# -# This type of fixture is in YAML format and the preferred default. YAML is a file format which describes data structures -# in a non-verbose, human-readable format. It ships with Ruby 1.8.1+. -# -# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed in the directory appointed -# by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just -# put your files in <tt><your-rails-app>/test/fixtures/</tt>). The fixture file ends with the <tt>.yml</tt> file extension (Rails example: -# <tt><your-rails-app>/test/fixtures/web_sites.yml</tt>). The format of a YAML fixture file looks like this: -# -# rubyonrails: -# id: 1 -# name: Ruby on Rails -# url: http://www.rubyonrails.org -# -# google: -# id: 2 -# name: Google -# url: http://www.google.com -# -# This YAML fixture file includes two fixtures. Each YAML fixture (ie. record) is given a name and is followed by an -# indented list of key/value pairs in the "key: value" format. Records are separated by a blank line for your viewing -# pleasure. -# -# Note that YAML fixtures are unordered. If you want ordered fixtures, use the omap YAML type. See http://yaml.org/type/omap.html -# for the specification. You will need ordered fixtures when you have foreign key constraints on keys in the same table. -# This is commonly needed for tree structures. Example: -# -# --- !omap -# - parent: -# id: 1 -# parent_id: NULL -# title: Parent -# - child: -# id: 2 -# parent_id: 1 -# title: Child -# -# == CSV fixtures -# -# Fixtures can also be kept in the Comma Separated Value (CSV) format. Akin to YAML fixtures, CSV fixtures are stored -# in a single file, but instead end with the <tt>.csv</tt> file extension -# (Rails example: <tt><your-rails-app>/test/fixtures/web_sites.csv</tt>). -# -# The format of this type of fixture file is much more compact than the others, but also a little harder to read by us -# humans. The first line of the CSV file is a comma-separated list of field names. The rest of the file is then comprised -# of the actual data (1 per line). Here's an example: -# -# id, name, url -# 1, Ruby On Rails, http://www.rubyonrails.org -# 2, Google, http://www.google.com -# -# Should you have a piece of data with a comma character in it, you can place double quotes around that value. If you -# need to use a double quote character, you must escape it with another double quote. -# -# Another unique attribute of the CSV fixture is that it has *no* fixture name like the other two formats. Instead, the -# fixture names are automatically generated by deriving the class name of the fixture file and adding an incrementing -# number to the end. In our example, the 1st fixture would be called "web_site_1" and the 2nd one would be called -# "web_site_2". -# -# Most databases and spreadsheets support exporting to CSV format, so this is a great format for you to choose if you -# have existing data somewhere already. -# -# == Single-file fixtures -# -# This type of fixture was the original format for Active Record that has since been deprecated in favor of the YAML and CSV formats. -# Fixtures for this format are created by placing text files in a sub-directory (with the name of the model) to the directory -# appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just -# put your files in <tt><your-rails-app>/test/fixtures/<your-model-name>/</tt> -- -# like <tt><your-rails-app>/test/fixtures/web_sites/</tt> for the WebSite model). -# -# Each text file placed in this directory represents a "record". Usually these types of fixtures are named without -# extensions, but if you are on a Windows machine, you might consider adding <tt>.txt</tt> as the extension. Here's what the -# above example might look like: -# -# web_sites/google -# web_sites/yahoo.txt -# web_sites/ruby-on-rails -# -# The file format of a standard fixture is simple. Each line is a property (or column in db speak) and has the syntax -# of "name => value". Here's an example of the ruby-on-rails fixture above: -# -# id => 1 -# name => Ruby on Rails -# url => http://www.rubyonrails.org -# -# = Using fixtures in testcases -# -# Since fixtures are a testing construct, we use them in our unit and functional tests. There are two ways to use the -# fixtures, but first let's take a look at a sample unit test: -# -# require 'test_helper' -# -# class WebSiteTest < ActiveSupport::TestCase -# test "web_site_count" do -# assert_equal 2, WebSite.count -# end -# end -# -# By default, the <tt>test_helper module</tt> will load all of your fixtures into your test database, so this test will succeed. -# The testing environment will automatically load the all fixtures into the database before each test. -# To ensure consistent data, the environment deletes the fixtures before running the load. -# -# In addition to being available in the database, the fixture's data may also be accessed by -# using a special dynamic method, which has the same name as the model, and accepts the -# name of the fixture to instantiate: -# -# test "find" do -# assert_equal "Ruby on Rails", web_sites(:rubyonrails).name -# end -# -# Alternatively, you may enable auto-instantiation of the fixture data. For instance, take the following tests: -# -# test "find_alt_method_1" do -# assert_equal "Ruby on Rails", @web_sites['rubyonrails']['name'] -# end -# -# test "find_alt_method_2" do -# assert_equal "Ruby on Rails", @rubyonrails.news -# end -# -# In order to use these methods to access fixtured data within your testcases, you must specify one of the -# following in your <tt>ActiveSupport::TestCase</tt>-derived class: -# -# - to fully enable instantiated fixtures (enable alternate methods #1 and #2 above) -# self.use_instantiated_fixtures = true -# -# - create only the hash for the fixtures, do not 'find' each instance (enable alternate method #1 only) -# self.use_instantiated_fixtures = :no_instances -# -# Using either of these alternate methods incurs a performance hit, as the fixtured data must be fully -# traversed in the database to create the fixture hash and/or instance variables. This is expensive for -# large sets of fixtured data. -# -# = Dynamic fixtures with ERb -# -# Some times you don't care about the content of the fixtures as much as you care about the volume. In these cases, you can -# mix ERb in with your YAML or CSV fixtures to create a bunch of fixtures for load testing, like: -# -# <% for i in 1..1000 %> -# fix_<%= i %>: -# id: <%= i %> -# name: guy_<%= 1 %> -# <% end %> -# -# This will create 1000 very simple YAML fixtures. -# -# Using ERb, you can also inject dynamic values into your fixtures with inserts like <tt><%= Date.today.strftime("%Y-%m-%d") %></tt>. -# This is however a feature to be used with some caution. The point of fixtures are that they're stable units of predictable -# sample data. If you feel that you need to inject dynamic values, then perhaps you should reexamine whether your application -# is properly testable. Hence, dynamic values in fixtures are to be considered a code smell. -# -# = Transactional fixtures -# -# TestCases can use begin+rollback to isolate their changes to the database instead of having to delete+insert for every test case. -# -# class FooTest < ActiveSupport::TestCase -# self.use_transactional_fixtures = true -# -# test "godzilla" do -# assert !Foo.find(:all).empty? -# Foo.destroy_all -# assert Foo.find(:all).empty? -# end -# -# test "godzilla aftermath" do -# assert !Foo.find(:all).empty? -# end -# end -# -# If you preload your test database with all fixture data (probably in the Rakefile task) and use transactional fixtures, -# then you may omit all fixtures declarations in your test cases since all the data's already there and every case rolls back its changes. -# -# In order to use instantiated fixtures with preloaded data, set +self.pre_loaded_fixtures+ to true. This will provide -# access to fixture data for every table that has been loaded through fixtures (depending on the value of +use_instantiated_fixtures+) -# -# When *not* to use transactional fixtures: -# -# 1. You're testing whether a transaction works correctly. Nested transactions don't commit until all parent transactions commit, -# particularly, the fixtures transaction which is begun in setup and rolled back in teardown. Thus, you won't be able to verify -# the results of your transaction until Active Record supports nested transactions or savepoints (in progress). -# 2. Your database does not support transactions. Every Active Record database supports transactions except MySQL MyISAM. -# Use InnoDB, MaxDB, or NDB instead. -# -# = Advanced YAML Fixtures -# -# YAML fixtures that don't specify an ID get some extra features: -# -# * Stable, autogenerated IDs -# * Label references for associations (belongs_to, has_one, has_many) -# * HABTM associations as inline lists -# * Autofilled timestamp columns -# * Fixture label interpolation -# * Support for YAML defaults -# -# == Stable, autogenerated IDs -# -# Here, have a monkey fixture: -# -# george: -# id: 1 -# name: George the Monkey -# -# reginald: -# id: 2 -# name: Reginald the Pirate -# -# Each of these fixtures has two unique identifiers: one for the database -# and one for the humans. Why don't we generate the primary key instead? -# Hashing each fixture's label yields a consistent ID: -# -# george: # generated id: 503576764 -# name: George the Monkey -# -# reginald: # generated id: 324201669 -# name: Reginald the Pirate -# -# Active Record looks at the fixture's model class, discovers the correct -# primary key, and generates it right before inserting the fixture -# into the database. -# -# The generated ID for a given label is constant, so we can discover -# any fixture's ID without loading anything, as long as we know the label. -# -# == Label references for associations (belongs_to, has_one, has_many) -# -# Specifying foreign keys in fixtures can be very fragile, not to -# mention difficult to read. Since Active Record can figure out the ID of -# any fixture from its label, you can specify FK's by label instead of ID. -# -# === belongs_to -# -# Let's break out some more monkeys and pirates. -# -# ### in pirates.yml -# -# reginald: -# id: 1 -# name: Reginald the Pirate -# monkey_id: 1 -# -# ### in monkeys.yml -# -# george: -# id: 1 -# name: George the Monkey -# pirate_id: 1 -# -# Add a few more monkeys and pirates and break this into multiple files, -# and it gets pretty hard to keep track of what's going on. Let's -# use labels instead of IDs: -# -# ### in pirates.yml -# -# reginald: -# name: Reginald the Pirate -# monkey: george -# -# ### in monkeys.yml -# -# george: -# name: George the Monkey -# pirate: reginald -# -# Pow! All is made clear. Active Record reflects on the fixture's model class, -# finds all the +belongs_to+ associations, and allows you to specify -# a target *label* for the *association* (monkey: george) rather than -# a target *id* for the *FK* (<tt>monkey_id: 1</tt>). -# -# ==== Polymorphic belongs_to -# -# Supporting polymorphic relationships is a little bit more complicated, since -# Active Record needs to know what type your association is pointing at. Something -# like this should look familiar: -# -# ### in fruit.rb -# -# belongs_to :eater, :polymorphic => true -# -# ### in fruits.yml -# -# apple: -# id: 1 -# name: apple -# eater_id: 1 -# eater_type: Monkey -# -# Can we do better? You bet! -# -# apple: -# eater: george (Monkey) -# -# Just provide the polymorphic target type and Active Record will take care of the rest. -# -# === has_and_belongs_to_many -# -# Time to give our monkey some fruit. -# -# ### in monkeys.yml -# -# george: -# id: 1 -# name: George the Monkey -# pirate_id: 1 -# -# ### in fruits.yml -# -# apple: -# id: 1 -# name: apple -# -# orange: -# id: 2 -# name: orange -# -# grape: -# id: 3 -# name: grape -# -# ### in fruits_monkeys.yml -# -# apple_george: -# fruit_id: 1 -# monkey_id: 1 -# -# orange_george: -# fruit_id: 2 -# monkey_id: 1 -# -# grape_george: -# fruit_id: 3 -# monkey_id: 1 -# -# Let's make the HABTM fixture go away. -# -# ### in monkeys.yml -# -# george: -# name: George the Monkey -# pirate: reginald -# fruits: apple, orange, grape -# -# ### in fruits.yml -# -# apple: -# name: apple -# -# orange: -# name: orange -# -# grape: -# name: grape -# -# Zap! No more fruits_monkeys.yml file. We've specified the list of fruits -# on George's fixture, but we could've just as easily specified a list -# of monkeys on each fruit. As with +belongs_to+, Active Record reflects on -# the fixture's model class and discovers the +has_and_belongs_to_many+ -# associations. -# -# == Autofilled timestamp columns -# -# If your table/model specifies any of Active Record's -# standard timestamp columns (+created_at+, +created_on+, +updated_at+, +updated_on+), -# they will automatically be set to <tt>Time.now</tt>. -# -# If you've set specific values, they'll be left alone. -# -# == Fixture label interpolation -# -# The label of the current fixture is always available as a column value: -# -# geeksomnia: -# name: Geeksomnia's Account -# subdomain: $LABEL -# -# Also, sometimes (like when porting older join table fixtures) you'll need -# to be able to get ahold of the identifier for a given label. ERB -# to the rescue: -# -# george_reginald: -# monkey_id: <%= Fixtures.identify(:reginald) %> -# pirate_id: <%= Fixtures.identify(:george) %> -# -# == Support for YAML defaults -# -# You probably already know how to use YAML to set and reuse defaults in -# your <tt>database.yml</tt> file. You can use the same technique in your fixtures: -# -# DEFAULTS: &DEFAULTS -# created_on: <%= 3.weeks.ago.to_s(:db) %> -# -# first: -# name: Smurf -# <<: *DEFAULTS -# -# second: -# name: Fraggle -# <<: *DEFAULTS -# -# Any fixture labeled "DEFAULTS" is safely ignored. - -class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash) - MAX_ID = 2 ** 30 - 1 - DEFAULT_FILTER_RE = /\.ya?ml$/ - - @@all_cached_fixtures = {} - - def self.reset_cache(connection = nil) - connection ||= ActiveRecord::Base.connection - @@all_cached_fixtures[connection.object_id] = {} - end - - def self.cache_for_connection(connection) - @@all_cached_fixtures[connection.object_id] ||= {} - @@all_cached_fixtures[connection.object_id] - end - - def self.fixture_is_cached?(connection, table_name) - cache_for_connection(connection)[table_name] - end - - def self.cached_fixtures(connection, keys_to_fetch = nil) - if keys_to_fetch - fixtures = cache_for_connection(connection).values_at(*keys_to_fetch) - else - fixtures = cache_for_connection(connection).values - end - fixtures.size > 1 ? fixtures : fixtures.first - end - - def self.cache_fixtures(connection, fixtures_map) - cache_for_connection(connection).update(fixtures_map) - end - - def self.instantiate_fixtures(object, table_name, fixtures, load_instances = true) - object.instance_variable_set "@#{table_name.to_s.gsub('.','_')}", fixtures - if load_instances - ActiveRecord::Base.silence do - fixtures.each do |name, fixture| - begin - object.instance_variable_set "@#{name}", fixture.find - rescue FixtureClassNotFound - nil - end - end - end - end - end - - def self.instantiate_all_loaded_fixtures(object, load_instances = true) - all_loaded_fixtures.each do |table_name, fixtures| - Fixtures.instantiate_fixtures(object, table_name, fixtures, load_instances) - end - end - - cattr_accessor :all_loaded_fixtures - self.all_loaded_fixtures = {} - - def self.create_fixtures(fixtures_directory, table_names, class_names = {}) - table_names = [table_names].flatten.map { |n| n.to_s } - connection = block_given? ? yield : ActiveRecord::Base.connection - - table_names_to_fetch = table_names.reject { |table_name| fixture_is_cached?(connection, table_name) } - - unless table_names_to_fetch.empty? - ActiveRecord::Base.silence do - connection.disable_referential_integrity do - fixtures_map = {} - - fixtures = table_names_to_fetch.map do |table_name| - fixtures_map[table_name] = Fixtures.new(connection, File.split(table_name.to_s).last, class_names[table_name.to_sym], File.join(fixtures_directory, table_name.to_s)) - end - - all_loaded_fixtures.update(fixtures_map) - - connection.transaction(:requires_new => true) do - fixtures.reverse.each { |fixture| fixture.delete_existing_fixtures } - fixtures.each { |fixture| fixture.insert_fixtures } - - # Cap primary key sequences to max(pk). - if connection.respond_to?(:reset_pk_sequence!) - table_names.each do |table_name| - connection.reset_pk_sequence!(table_name) - end - end - end - - cache_fixtures(connection, fixtures_map) - end - end - end - cached_fixtures(connection, table_names) - end - - # Returns a consistent, platform-independent identifier for +label+. - # Identifiers are positive integers less than 2^32. - def self.identify(label) - Zlib.crc32(label.to_s) % MAX_ID - end - - attr_reader :table_name, :name - - def initialize(connection, table_name, class_name, fixture_path, file_filter = DEFAULT_FILTER_RE) - @connection, @table_name, @fixture_path, @file_filter = connection, table_name, fixture_path, file_filter - @name = table_name # preserve fixture base name - @class_name = class_name || - (ActiveRecord::Base.pluralize_table_names ? @table_name.singularize.camelize : @table_name.camelize) - @table_name = "#{ActiveRecord::Base.table_name_prefix}#{@table_name}#{ActiveRecord::Base.table_name_suffix}" - @table_name = class_name.table_name if class_name.respond_to?(:table_name) - @connection = class_name.connection if class_name.respond_to?(:connection) - read_fixture_files - end - - def delete_existing_fixtures - @connection.delete "DELETE FROM #{@connection.quote_table_name(table_name)}", 'Fixture Delete' - end - - def insert_fixtures - now = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now - now = now.to_s(:db) - - # allow a standard key to be used for doing defaults in YAML - if is_a?(Hash) - delete('DEFAULTS') - else - delete(assoc('DEFAULTS')) - end - - # track any join tables we need to insert later - habtm_fixtures = Hash.new do |h, habtm| - h[habtm] = HabtmFixtures.new(@connection, habtm.options[:join_table], nil, nil) - end - - each do |label, fixture| - row = fixture.to_hash - - if model_class && model_class < ActiveRecord::Base - # fill in timestamp columns if they aren't specified and the model is set to record_timestamps - if model_class.record_timestamps - timestamp_column_names.each do |name| - row[name] = now unless row.key?(name) - end - end - - # interpolate the fixture label - row.each do |key, value| - row[key] = label if value == "$LABEL" - end - - # generate a primary key if necessary - if has_primary_key_column? && !row.include?(primary_key_name) - row[primary_key_name] = Fixtures.identify(label) - end - - # If STI is used, find the correct subclass for association reflection - reflection_class = - if row.include?(inheritance_column_name) - row[inheritance_column_name].constantize rescue model_class - else - model_class - end - - reflection_class.reflect_on_all_associations.each do |association| - case association.macro - when :belongs_to - # Do not replace association name with association foreign key if they are named the same - fk_name = (association.options[:foreign_key] || "#{association.name}_id").to_s - - if association.name.to_s != fk_name && value = row.delete(association.name.to_s) - if association.options[:polymorphic] - if value.sub!(/\s*\(([^\)]*)\)\s*$/, "") - target_type = $1 - target_type_name = (association.options[:foreign_type] || "#{association.name}_type").to_s - - # support polymorphic belongs_to as "label (Type)" - row[target_type_name] = target_type - end - end - - row[fk_name] = Fixtures.identify(value) - end - when :has_and_belongs_to_many - if (targets = row.delete(association.name.to_s)) - targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/) - join_fixtures = habtm_fixtures[association] - - targets.each do |target| - join_fixtures["#{label}_#{target}"] = Fixture.new( - { association.primary_key_name => row[primary_key_name], - association.association_foreign_key => Fixtures.identify(target) }, - nil, @connection) - end - end - end - end - end - - @connection.insert_fixture(fixture, @table_name) - end - - # insert any HABTM join tables we discovered - habtm_fixtures.values.each do |fixture| - fixture.delete_existing_fixtures - fixture.insert_fixtures - end - end - - private - class HabtmFixtures < ::Fixtures #:nodoc: - def read_fixture_files; end - end - - def model_class - unless defined?(@model_class) - @model_class = - if @class_name.nil? || @class_name.is_a?(Class) - @class_name - else - @class_name.constantize rescue nil - end - end - - @model_class - end - - def primary_key_name - @primary_key_name ||= model_class && model_class.primary_key - end - - def has_primary_key_column? - @has_primary_key_column ||= model_class && primary_key_name && - model_class.columns.find { |c| c.name == primary_key_name } - end - - def timestamp_column_names - @timestamp_column_names ||= %w(created_at created_on updated_at updated_on).select do |name| - column_names.include?(name) - end - end - - def inheritance_column_name - @inheritance_column_name ||= model_class && model_class.inheritance_column - end - - def column_names - @column_names ||= @connection.columns(@table_name).collect(&:name) - end - - def read_fixture_files - if File.file?(yaml_file_path) - read_yaml_fixture_files - elsif File.file?(csv_file_path) - read_csv_fixture_files - end - end - - def read_yaml_fixture_files - yaml_string = "" - Dir["#{@fixture_path}/**/*.yml"].select { |f| test(?f, f) }.each do |subfixture_path| - yaml_string << IO.read(subfixture_path) - end - yaml_string << IO.read(yaml_file_path) - - if yaml = parse_yaml_string(yaml_string) - # If the file is an ordered map, extract its children. - yaml_value = - if yaml.respond_to?(:type_id) && yaml.respond_to?(:value) - yaml.value - else - [yaml] - end - - yaml_value.each do |fixture| - raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{fixture}" unless fixture.respond_to?(:each) - fixture.each do |name, data| - unless data - raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{name} (nil)" - end - - self[name] = Fixture.new(data, model_class, @connection) - end - end - end - end - - def read_csv_fixture_files - reader = CSV.parse(erb_render(IO.read(csv_file_path))) - header = reader.shift - i = 0 - reader.each do |row| - data = {} - row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip } - self["#{@class_name.to_s.underscore}_#{i+=1}"] = Fixture.new(data, model_class, @connection) - end - end - - def yaml_file_path - "#{@fixture_path}.yml" - end - - def csv_file_path - @fixture_path + ".csv" - end - - def yaml_fixtures_key(path) - File.basename(@fixture_path).split(".").first - end - - def parse_yaml_string(fixture_content) - YAML::load(erb_render(fixture_content)) - rescue => error - raise Fixture::FormatError, "a YAML error occurred parsing #{yaml_file_path}. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html\nThe exact error was:\n #{error.class}: #{error}" - end - - def erb_render(fixture_content) - ERB.new(fixture_content).result - end -end - -class Fixture #:nodoc: - include Enumerable - - class FixtureError < StandardError #:nodoc: - end - - class FormatError < FixtureError #:nodoc: - end - - attr_reader :model_class - - def initialize(fixture, model_class, connection = ActiveRecord::Base.connection) - @connection = connection - @fixture = fixture - @model_class = model_class.is_a?(Class) ? model_class : model_class.constantize rescue nil - end - - def class_name - @model_class.name if @model_class - end - - def each - @fixture.each { |item| yield item } - end - - def [](key) - @fixture[key] - end - - def to_hash - @fixture - end - - def key_list - columns = @fixture.keys.collect{ |column_name| @connection.quote_column_name(column_name) } - columns.join(", ") - end - - def value_list - list = @fixture.inject([]) do |fixtures, (key, value)| - col = model_class.columns_hash[key] if model_class.respond_to?(:ancestors) && model_class.ancestors.include?(ActiveRecord::Base) - fixtures << @connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r") - end - list * ', ' - end - - def find - if model_class - model_class.find(self[model_class.primary_key]) - else - raise FixtureClassNotFound, "No class attached to find." - end - end -end - -module ActiveRecord - module TestFixtures - def self.included(base) - base.class_eval do - setup :setup_fixtures - teardown :teardown_fixtures - - superclass_delegating_accessor :fixture_path - superclass_delegating_accessor :fixture_table_names - superclass_delegating_accessor :fixture_class_names - superclass_delegating_accessor :use_transactional_fixtures - superclass_delegating_accessor :use_instantiated_fixtures # true, false, or :no_instances - superclass_delegating_accessor :pre_loaded_fixtures - - self.fixture_table_names = [] - self.use_transactional_fixtures = false - self.use_instantiated_fixtures = true - self.pre_loaded_fixtures = false - - self.fixture_class_names = {} - end - - base.extend ClassMethods - end - - module ClassMethods - def set_fixture_class(class_names = {}) - self.fixture_class_names = self.fixture_class_names.merge(class_names) - end - - def fixtures(*table_names) - if table_names.first == :all - table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"] - table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') } - else - table_names = table_names.flatten.map { |n| n.to_s } - end - - self.fixture_table_names |= table_names - require_fixture_classes(table_names) - setup_fixture_accessors(table_names) - end - - def try_to_load_dependency(file_name) - require_dependency file_name - rescue LoadError => e - # Let's hope the developer has included it himself - - # Let's warn in case this is a subdependency, otherwise - # subdependency error messages are totally cryptic - if ActiveRecord::Base.logger - ActiveRecord::Base.logger.warn("Unable to load #{file_name}, underlying cause #{e.message} \n\n #{e.backtrace.join("\n")}") - end - end - - def require_fixture_classes(table_names = nil) - (table_names || fixture_table_names).each do |table_name| - file_name = table_name.to_s - file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names - try_to_load_dependency(file_name) - end - end - - def setup_fixture_accessors(table_names = nil) - table_names = [table_names] if table_names && !table_names.respond_to?(:each) - (table_names || fixture_table_names).each do |table_name| - table_name = table_name.to_s.tr('.', '_') - - define_method(table_name) do |*fixtures| - force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload - - @fixture_cache[table_name] ||= {} - - instances = fixtures.map do |fixture| - @fixture_cache[table_name].delete(fixture) if force_reload - - if @loaded_fixtures[table_name][fixture.to_s] - @fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find - else - raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'" - end - end - - instances.size == 1 ? instances.first : instances - end - private table_name - end - end - - def uses_transaction(*methods) - @uses_transaction = [] unless defined?(@uses_transaction) - @uses_transaction.concat methods.map(&:to_s) - end - - def uses_transaction?(method) - @uses_transaction = [] unless defined?(@uses_transaction) - @uses_transaction.include?(method.to_s) - end - end - - def run_in_transaction? - use_transactional_fixtures && - !self.class.uses_transaction?(method_name) - end - - def setup_fixtures - return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? - - if pre_loaded_fixtures && !use_transactional_fixtures - raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures' - end - - @fixture_cache = {} - @@already_loaded_fixtures ||= {} - - # Load fixtures once and begin transaction. - if run_in_transaction? - if @@already_loaded_fixtures[self.class] - @loaded_fixtures = @@already_loaded_fixtures[self.class] - else - load_fixtures - @@already_loaded_fixtures[self.class] = @loaded_fixtures - end - ActiveRecord::Base.connection.increment_open_transactions - ActiveRecord::Base.connection.transaction_joinable = false - ActiveRecord::Base.connection.begin_db_transaction - # Load fixtures for every test. - else - Fixtures.reset_cache - @@already_loaded_fixtures[self.class] = nil - load_fixtures - end - - # Instantiate fixtures for every test if requested. - instantiate_fixtures if use_instantiated_fixtures - end - - def teardown_fixtures - return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? - - unless run_in_transaction? - Fixtures.reset_cache - end - - # Rollback changes if a transaction is active. - if run_in_transaction? && ActiveRecord::Base.connection.open_transactions != 0 - ActiveRecord::Base.connection.rollback_db_transaction - ActiveRecord::Base.connection.decrement_open_transactions - end - ActiveRecord::Base.clear_active_connections! - end - - private - def load_fixtures - @loaded_fixtures = {} - fixtures = Fixtures.create_fixtures(fixture_path, fixture_table_names, fixture_class_names) - unless fixtures.nil? - if fixtures.instance_of?(Fixtures) - @loaded_fixtures[fixtures.name] = fixtures - else - fixtures.each { |f| @loaded_fixtures[f.name] = f } - end - end - end - - # for pre_loaded_fixtures, only require the classes once. huge speed improvement - @@required_fixture_classes = false - - def instantiate_fixtures - if pre_loaded_fixtures - raise RuntimeError, 'Load fixtures before instantiating them.' if Fixtures.all_loaded_fixtures.empty? - unless @@required_fixture_classes - self.class.require_fixture_classes Fixtures.all_loaded_fixtures.keys - @@required_fixture_classes = true - end - Fixtures.instantiate_all_loaded_fixtures(self, load_instances?) - else - raise RuntimeError, 'Load fixtures before instantiating them.' if @loaded_fixtures.nil? - @loaded_fixtures.each do |table_name, fixtures| - Fixtures.instantiate_fixtures(self, table_name, fixtures, load_instances?) - end - end - end - - def load_instances? - use_instantiated_fixtures != :no_instances - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/locale/en.yml b/vendor/rails/activerecord/lib/active_record/locale/en.yml deleted file mode 100644 index 6dab5e20..00000000 --- a/vendor/rails/activerecord/lib/active_record/locale/en.yml +++ /dev/null @@ -1,58 +0,0 @@ -en: - activerecord: - errors: - # The values :model, :attribute and :value are always available for interpolation - # The value :count is available when applicable. Can be used for pluralization. - messages: - inclusion: "is not included in the list" - exclusion: "is reserved" - invalid: "is invalid" - confirmation: "doesn't match confirmation" - accepted: "must be accepted" - empty: "can't be empty" - blank: "can't be blank" - too_long: "is too long (maximum is %{count} characters)" - too_short: "is too short (minimum is %{count} characters)" - wrong_length: "is the wrong length (should be %{count} characters)" - taken: "has already been taken" - not_a_number: "is not a number" - greater_than: "must be greater than %{count}" - greater_than_or_equal_to: "must be greater than or equal to %{count}" - equal_to: "must be equal to %{count}" - less_than: "must be less than %{count}" - less_than_or_equal_to: "must be less than or equal to %{count}" - odd: "must be odd" - even: "must be even" - record_invalid: "Validation failed: %{errors}" - # Append your own errors here or at the model/attributes scope. - - full_messages: - format: "%{attribute} %{message}" - - # You can define own errors for models or model attributes. - # The values :model, :attribute and :value are always available for interpolation. - # - # For example, - # models: - # user: - # blank: "This is a custom blank message for %{model}: %{attribute}" - # attributes: - # login: - # blank: "This is a custom blank message for User login" - # Will define custom blank validation message for User model and - # custom blank validation message for login attribute of User model. - #models: - - # Translate model names. Used in Model.human_name(). - #models: - # For example, - # user: "Dude" - # will translate User model name to "Dude" - - # Translate model attribute names. Used in Model.human_attribute_name(attribute). - #attributes: - # For example, - # user: - # login: "Handle" - # will translate User attribute "login" as "Handle" - diff --git a/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb b/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb deleted file mode 100644 index 147aa86c..00000000 --- a/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb +++ /dev/null @@ -1,182 +0,0 @@ -module ActiveRecord - module Locking - # == What is Optimistic Locking - # - # Optimistic locking allows multiple users to access the same record for edits, and assumes a minimum of - # conflicts with the data. It does this by checking whether another process has made changes to a record since - # it was opened, an ActiveRecord::StaleObjectError is thrown if that has occurred and the update is ignored. - # - # Check out ActiveRecord::Locking::Pessimistic for an alternative. - # - # == Usage - # - # Active Records support optimistic locking if the field <tt>lock_version</tt> is present. Each update to the - # record increments the lock_version column and the locking facilities ensure that records instantiated twice - # will let the last one saved raise a StaleObjectError if the first was also updated. Example: - # - # p1 = Person.find(1) - # p2 = Person.find(1) - # - # p1.first_name = "Michael" - # p1.save - # - # p2.first_name = "should fail" - # p2.save # Raises a ActiveRecord::StaleObjectError - # - # Optimistic locking will also check for stale data when objects are destroyed. Example: - # - # p1 = Person.find(1) - # p2 = Person.find(1) - # - # p1.first_name = "Michael" - # p1.save - # - # p2.destroy # Raises a ActiveRecord::StaleObjectError - # - # You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging, - # or otherwise apply the business logic needed to resolve the conflict. - # - # You must ensure that your database schema defaults the lock_version column to 0. - # - # This behavior can be turned off by setting <tt>ActiveRecord::Base.lock_optimistically = false</tt>. - # To override the name of the lock_version column, invoke the <tt>set_locking_column</tt> method. - # This method uses the same syntax as <tt>set_table_name</tt> - module Optimistic - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.cattr_accessor :lock_optimistically, :instance_writer => false - base.lock_optimistically = true - - base.alias_method_chain :update, :lock - base.alias_method_chain :destroy, :lock - base.alias_method_chain :attributes_from_column_definition, :lock - - class << base - alias_method :locking_column=, :set_locking_column - end - end - - def locking_enabled? #:nodoc: - self.class.locking_enabled? - end - - private - def attributes_from_column_definition_with_lock - result = attributes_from_column_definition_without_lock - - # If the locking column has no default value set, - # start the lock version at zero. Note we can't use - # locking_enabled? at this point as @attributes may - # not have been initialized yet - - if lock_optimistically && result.include?(self.class.locking_column) - result[self.class.locking_column] ||= 0 - end - - return result - end - - def update_with_lock(attribute_names = @attributes.keys) #:nodoc: - return update_without_lock(attribute_names) unless locking_enabled? - return 0 if attribute_names.empty? - - lock_col = self.class.locking_column - previous_value = send(lock_col).to_i - send(lock_col + '=', previous_value + 1) - - attribute_names += [lock_col] - attribute_names.uniq! - - begin - affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with optimistic locking") - UPDATE #{self.class.quoted_table_name} - SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false, false, attribute_names))} - WHERE #{self.class.primary_key} = #{quote_value(id)} - AND #{self.class.quoted_locking_column} = #{quote_value(previous_value)} - end_sql - - unless affected_rows == 1 - raise ActiveRecord::StaleObjectError, "Attempted to update a stale object: #{self.class.name}" - end - - affected_rows - - # If something went wrong, revert the version. - rescue Exception - send(lock_col + '=', previous_value) - raise - end - end - - def destroy_with_lock #:nodoc: - return destroy_without_lock unless locking_enabled? - - unless new_record? - lock_col = self.class.locking_column - previous_value = send(lock_col).to_i - - affected_rows = connection.delete( - "DELETE FROM #{self.class.quoted_table_name} " + - "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id} " + - "AND #{self.class.quoted_locking_column} = #{quote_value(previous_value)}", - "#{self.class.name} Destroy" - ) - - unless affected_rows == 1 - raise ActiveRecord::StaleObjectError, "Attempted to delete a stale object: #{self.class.name}" - end - end - - @destroyed = true - freeze - end - - module ClassMethods - DEFAULT_LOCKING_COLUMN = 'lock_version' - - def self.extended(base) - class <<base - alias_method_chain :update_counters, :lock - end - end - - # Is optimistic locking enabled for this table? Returns true if the - # +lock_optimistically+ flag is set to true (which it is, by default) - # and the table includes the +locking_column+ column (defaults to - # +lock_version+). - def locking_enabled? - lock_optimistically && columns_hash[locking_column] - end - - # Set the column to use for optimistic locking. Defaults to +lock_version+. - def set_locking_column(value = nil, &block) - define_attr_method :locking_column, value, &block - value - end - - # The version column used for optimistic locking. Defaults to +lock_version+. - def locking_column - reset_locking_column - end - - # Quote the column name used for optimistic locking. - def quoted_locking_column - connection.quote_column_name(locking_column) - end - - # Reset the column used for optimistic locking back to the +lock_version+ default. - def reset_locking_column - set_locking_column DEFAULT_LOCKING_COLUMN - end - - # Make sure the lock version column gets updated when counters are - # updated. - def update_counters_with_lock(id, counters) - counters = counters.merge(locking_column => 1) if locking_enabled? - update_counters_without_lock(id, counters) - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb b/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb deleted file mode 100644 index fcc9ebb4..00000000 --- a/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb +++ /dev/null @@ -1,55 +0,0 @@ -module ActiveRecord - module Locking - # Locking::Pessimistic provides support for row-level locking using - # SELECT ... FOR UPDATE and other lock types. - # - # Pass <tt>:lock => true</tt> to ActiveRecord::Base.find to obtain an exclusive - # lock on the selected rows: - # # select * from accounts where id=1 for update - # Account.find(1, :lock => true) - # - # Pass <tt>:lock => 'some locking clause'</tt> to give a database-specific locking clause - # of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT'. - # - # Example: - # Account.transaction do - # # select * from accounts where name = 'shugo' limit 1 for update - # shugo = Account.find(:first, :conditions => "name = 'shugo'", :lock => true) - # yuko = Account.find(:first, :conditions => "name = 'yuko'", :lock => true) - # shugo.balance -= 100 - # shugo.save! - # yuko.balance += 100 - # yuko.save! - # end - # - # You can also use ActiveRecord::Base#lock! method to lock one record by id. - # This may be better if you don't need to lock every row. Example: - # Account.transaction do - # # select * from accounts where ... - # accounts = Account.find(:all, :conditions => ...) - # account1 = accounts.detect { |account| ... } - # account2 = accounts.detect { |account| ... } - # # select * from accounts where id=? for update - # account1.lock! - # account2.lock! - # account1.balance -= 100 - # account1.save! - # account2.balance += 100 - # account2.save! - # end - # - # Database-specific information on row locking: - # MySQL: http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html - # PostgreSQL: http://www.postgresql.org/docs/8.1/interactive/sql-select.html#SQL-FOR-UPDATE-SHARE - module Pessimistic - # Obtain a row lock on this record. Reloads the record to obtain the requested - # lock. Pass an SQL locking clause to append the end of the SELECT statement - # or pass true for "FOR UPDATE" (the default, an exclusive row lock). Returns - # the locked record. - def lock!(lock = true) - reload(:lock => lock) unless new_record? - self - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/migration.rb b/vendor/rails/activerecord/lib/active_record/migration.rb deleted file mode 100644 index 5d709c0d..00000000 --- a/vendor/rails/activerecord/lib/active_record/migration.rb +++ /dev/null @@ -1,571 +0,0 @@ -module ActiveRecord - class IrreversibleMigration < ActiveRecordError#:nodoc: - end - - class DuplicateMigrationVersionError < ActiveRecordError#:nodoc: - def initialize(version) - super("Multiple migrations have the version number #{version}") - end - end - - class DuplicateMigrationNameError < ActiveRecordError#:nodoc: - def initialize(name) - super("Multiple migrations have the name #{name}") - end - end - - class UnknownMigrationVersionError < ActiveRecordError #:nodoc: - def initialize(version) - super("No migration with version number #{version}") - end - end - - class IllegalMigrationNameError < ActiveRecordError#:nodoc: - def initialize(name) - super("Illegal name for migration file: #{name}\n\t(only lower case letters, numbers, and '_' allowed)") - end - end - - # Migrations can manage the evolution of a schema used by several physical databases. It's a solution - # to the common problem of adding a field to make a new feature work in your local database, but being unsure of how to - # push that change to other developers and to the production server. With migrations, you can describe the transformations - # in self-contained classes that can be checked into version control systems and executed against another database that - # might be one, two, or five versions behind. - # - # Example of a simple migration: - # - # class AddSsl < ActiveRecord::Migration - # def self.up - # add_column :accounts, :ssl_enabled, :boolean, :default => 1 - # end - # - # def self.down - # remove_column :accounts, :ssl_enabled - # end - # end - # - # This migration will add a boolean flag to the accounts table and remove it if you're backing out of the migration. - # It shows how all migrations have two class methods +up+ and +down+ that describes the transformations required to implement - # or remove the migration. These methods can consist of both the migration specific methods like add_column and remove_column, - # but may also contain regular Ruby code for generating data needed for the transformations. - # - # Example of a more complex migration that also needs to initialize data: - # - # class AddSystemSettings < ActiveRecord::Migration - # def self.up - # create_table :system_settings do |t| - # t.string :name - # t.string :label - # t.text :value - # t.string :type - # t.integer :position - # end - # - # SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1 - # end - # - # def self.down - # drop_table :system_settings - # end - # end - # - # This migration first adds the system_settings table, then creates the very first row in it using the Active Record model - # that relies on the table. It also uses the more advanced create_table syntax where you can specify a complete table schema - # in one block call. - # - # == Available transformations - # - # * <tt>create_table(name, options)</tt> Creates a table called +name+ and makes the table object available to a block - # that can then add columns to it, following the same format as add_column. See example above. The options hash is for - # fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create table definition. - # * <tt>drop_table(name)</tt>: Drops the table called +name+. - # * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+ to +new_name+. - # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column to the table called +table_name+ - # named +column_name+ specified to be one of the following types: - # <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>, <tt>:decimal</tt>, <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>, - # <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. A default value can be specified by passing an - # +options+ hash like <tt>{ :default => 11 }</tt>. Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g. <tt>{ :limit => 50, :null => false }</tt>) - # -- see ActiveRecord::ConnectionAdapters::TableDefinition#column for details. - # * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames a column but keeps the type and content. - # * <tt>change_column(table_name, column_name, type, options)</tt>: Changes the column to a different type using the same - # parameters as add_column. - # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named +column_name+ from the table called +table_name+. - # * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index with the name of the column. Other options include - # <tt>:name</tt> and <tt>:unique</tt> (e.g. <tt>{ :name => "users_name_index", :unique => true }</tt>). - # * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified by +index_name+. - # - # == Irreversible transformations - # - # Some transformations are destructive in a manner that cannot be reversed. Migrations of that kind should raise - # an <tt>ActiveRecord::IrreversibleMigration</tt> exception in their +down+ method. - # - # == Running migrations from within Rails - # - # The Rails package has several tools to help create and apply migrations. - # - # To generate a new migration, you can use - # script/generate migration MyNewMigration - # - # where MyNewMigration is the name of your migration. The generator will - # create an empty migration file <tt>nnn_my_new_migration.rb</tt> in the <tt>db/migrate/</tt> - # directory where <tt>nnn</tt> is the next largest migration number. - # - # You may then edit the <tt>self.up</tt> and <tt>self.down</tt> methods of - # MyNewMigration. - # - # There is a special syntactic shortcut to generate migrations that add fields to a table. - # script/generate migration add_fieldname_to_tablename fieldname:string - # - # This will generate the file <tt>nnn_add_fieldname_to_tablename</tt>, which will look like this: - # class AddFieldnameToTablename < ActiveRecord::Migration - # def self.up - # add_column :tablenames, :fieldname, :string - # end - # - # def self.down - # remove_column :tablenames, :fieldname - # end - # end - # - # To run migrations against the currently configured database, use - # <tt>rake db:migrate</tt>. This will update the database by running all of the - # pending migrations, creating the <tt>schema_migrations</tt> table - # (see "About the schema_migrations table" section below) if missing. It will also - # invoke the db:schema:dump task, which will update your db/schema.rb file - # to match the structure of your database. - # - # To roll the database back to a previous migration version, use - # <tt>rake db:migrate VERSION=X</tt> where <tt>X</tt> is the version to which - # you wish to downgrade. If any of the migrations throw an - # <tt>ActiveRecord::IrreversibleMigration</tt> exception, that step will fail and you'll - # have some manual work to do. - # - # == Database support - # - # Migrations are currently supported in MySQL, PostgreSQL, SQLite, - # SQL Server, Sybase, and Oracle (all supported databases except DB2). - # - # == More examples - # - # Not all migrations change the schema. Some just fix the data: - # - # class RemoveEmptyTags < ActiveRecord::Migration - # def self.up - # Tag.find(:all).each { |tag| tag.destroy if tag.pages.empty? } - # end - # - # def self.down - # # not much we can do to restore deleted data - # raise ActiveRecord::IrreversibleMigration, "Can't recover the deleted tags" - # end - # end - # - # Others remove columns when they migrate up instead of down: - # - # class RemoveUnnecessaryItemAttributes < ActiveRecord::Migration - # def self.up - # remove_column :items, :incomplete_items_count - # remove_column :items, :completed_items_count - # end - # - # def self.down - # add_column :items, :incomplete_items_count - # add_column :items, :completed_items_count - # end - # end - # - # And sometimes you need to do something in SQL not abstracted directly by migrations: - # - # class MakeJoinUnique < ActiveRecord::Migration - # def self.up - # execute "ALTER TABLE `pages_linked_pages` ADD UNIQUE `page_id_linked_page_id` (`page_id`,`linked_page_id`)" - # end - # - # def self.down - # execute "ALTER TABLE `pages_linked_pages` DROP INDEX `page_id_linked_page_id`" - # end - # end - # - # == Using a model after changing its table - # - # Sometimes you'll want to add a column in a migration and populate it immediately after. In that case, you'll need - # to make a call to Base#reset_column_information in order to ensure that the model has the latest column data from - # after the new column was added. Example: - # - # class AddPeopleSalary < ActiveRecord::Migration - # def self.up - # add_column :people, :salary, :integer - # Person.reset_column_information - # Person.find(:all).each do |p| - # p.update_attribute :salary, SalaryCalculator.compute(p) - # end - # end - # end - # - # == Controlling verbosity - # - # By default, migrations will describe the actions they are taking, writing - # them to the console as they happen, along with benchmarks describing how - # long each step took. - # - # You can quiet them down by setting ActiveRecord::Migration.verbose = false. - # - # You can also insert your own messages and benchmarks by using the +say_with_time+ - # method: - # - # def self.up - # ... - # say_with_time "Updating salaries..." do - # Person.find(:all).each do |p| - # p.update_attribute :salary, SalaryCalculator.compute(p) - # end - # end - # ... - # end - # - # The phrase "Updating salaries..." would then be printed, along with the - # benchmark for the block when the block completes. - # - # == About the schema_migrations table - # - # Rails versions 2.0 and prior used to create a table called - # <tt>schema_info</tt> when using migrations. This table contained the - # version of the schema as of the last applied migration. - # - # Starting with Rails 2.1, the <tt>schema_info</tt> table is - # (automatically) replaced by the <tt>schema_migrations</tt> table, which - # contains the version numbers of all the migrations applied. - # - # As a result, it is now possible to add migration files that are numbered - # lower than the current schema version: when migrating up, those - # never-applied "interleaved" migrations will be automatically applied, and - # when migrating down, never-applied "interleaved" migrations will be skipped. - # - # == Timestamped Migrations - # - # By default, Rails generates migrations that look like: - # - # 20080717013526_your_migration_name.rb - # - # The prefix is a generation timestamp (in UTC). - # - # If you'd prefer to use numeric prefixes, you can turn timestamped migrations - # off by setting: - # - # config.active_record.timestamped_migrations = false - # - # In environment.rb. - # - class Migration - @@verbose = true - cattr_accessor :verbose - - class << self - def up_with_benchmarks #:nodoc: - migrate(:up) - end - - def down_with_benchmarks #:nodoc: - migrate(:down) - end - - # Execute this migration in the named direction - def migrate(direction) - return unless respond_to?(direction) - - case direction - when :up then announce "migrating" - when :down then announce "reverting" - end - - result = nil - time = Benchmark.measure { result = send("#{direction}_without_benchmarks") } - - case direction - when :up then announce "migrated (%.4fs)" % time.real; write - when :down then announce "reverted (%.4fs)" % time.real; write - end - - result - end - - # Because the method added may do an alias_method, it can be invoked - # recursively. We use @ignore_new_methods as a guard to indicate whether - # it is safe for the call to proceed. - def singleton_method_added(sym) #:nodoc: - return if defined?(@ignore_new_methods) && @ignore_new_methods - - begin - @ignore_new_methods = true - - case sym - when :up, :down - klass = (class << self; self; end) - klass.send(:alias_method_chain, sym, "benchmarks") - end - ensure - @ignore_new_methods = false - end - end - - def write(text="") - puts(text) if verbose - end - - def announce(message) - text = "#{@version} #{name}: #{message}" - length = [0, 75 - text.length].max - write "== %s %s" % [text, "=" * length] - end - - def say(message, subitem=false) - write "#{subitem ? " ->" : "--"} #{message}" - end - - def say_with_time(message) - say(message) - result = nil - time = Benchmark.measure { result = yield } - say "%.4fs" % time.real, :subitem - say("#{result} rows", :subitem) if result.is_a?(Integer) - result - end - - def suppress_messages - save, self.verbose = verbose, false - yield - ensure - self.verbose = save - end - - def connection - ActiveRecord::Base.connection - end - - def method_missing(method, *arguments, &block) - arg_list = arguments.map(&:inspect) * ', ' - - say_with_time "#{method}(#{arg_list})" do - unless arguments.empty? || method == :execute - arguments[0] = Migrator.proper_table_name(arguments.first) - end - connection.send(method, *arguments, &block) - end - end - end - end - - # MigrationProxy is used to defer loading of the actual migration classes - # until they are needed - class MigrationProxy - - attr_accessor :name, :version, :filename - - delegate :migrate, :announce, :write, :to=>:migration - - private - - def migration - @migration ||= load_migration - end - - def load_migration - load(filename) - name.constantize - end - - end - - class Migrator#:nodoc: - class << self - def migrate(migrations_path, target_version = nil) - case - when target_version.nil? then up(migrations_path, target_version) - when current_version == 0 && target_version == 0 then # noop - when current_version > target_version then down(migrations_path, target_version) - else up(migrations_path, target_version) - end - end - - def rollback(migrations_path, steps=1) - migrator = self.new(:down, migrations_path) - start_index = migrator.migrations.index(migrator.current_migration) - - return unless start_index - - finish = migrator.migrations[start_index + steps] - down(migrations_path, finish ? finish.version : 0) - end - - def up(migrations_path, target_version = nil) - self.new(:up, migrations_path, target_version).migrate - end - - def down(migrations_path, target_version = nil) - self.new(:down, migrations_path, target_version).migrate - end - - def run(direction, migrations_path, target_version) - self.new(direction, migrations_path, target_version).run - end - - def migrations_path - 'db/migrate' - end - - def schema_migrations_table_name - Base.table_name_prefix + 'schema_migrations' + Base.table_name_suffix - end - - def get_all_versions - Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).sort - end - - def current_version - sm_table = schema_migrations_table_name - if Base.connection.table_exists?(sm_table) - get_all_versions.max || 0 - else - 0 - end - end - - def proper_table_name(name) - # Use the Active Record objects own table_name, or pre/suffix from ActiveRecord::Base if name is a symbol/string - name.table_name rescue "#{ActiveRecord::Base.table_name_prefix}#{name}#{ActiveRecord::Base.table_name_suffix}" - end - end - - def initialize(direction, migrations_path, target_version = nil) - raise StandardError.new("This database does not yet support migrations") unless Base.connection.supports_migrations? - Base.connection.initialize_schema_migrations_table - @direction, @migrations_path, @target_version = direction, migrations_path, target_version - end - - def current_version - migrated.last || 0 - end - - def current_migration - migrations.detect { |m| m.version == current_version } - end - - def run - target = migrations.detect { |m| m.version == @target_version } - raise UnknownMigrationVersionError.new(@target_version) if target.nil? - unless (up? && migrated.include?(target.version.to_i)) || (down? && !migrated.include?(target.version.to_i)) - target.migrate(@direction) - record_version_state_after_migrating(target.version) - end - end - - def migrate - current = migrations.detect { |m| m.version == current_version } - target = migrations.detect { |m| m.version == @target_version } - - if target.nil? && !@target_version.nil? && @target_version > 0 - raise UnknownMigrationVersionError.new(@target_version) - end - - start = up? ? 0 : (migrations.index(current) || 0) - finish = migrations.index(target) || migrations.size - 1 - runnable = migrations[start..finish] - - # skip the last migration if we're headed down, but not ALL the way down - runnable.pop if down? && !target.nil? - - runnable.each do |migration| - Base.logger.info "Migrating to #{migration.name} (#{migration.version})" - - # On our way up, we skip migrating the ones we've already migrated - next if up? && migrated.include?(migration.version.to_i) - - # On our way down, we skip reverting the ones we've never migrated - if down? && !migrated.include?(migration.version.to_i) - migration.announce 'never migrated, skipping'; migration.write - next - end - - begin - ddl_transaction do - migration.migrate(@direction) - record_version_state_after_migrating(migration.version) - end - rescue => e - canceled_msg = Base.connection.supports_ddl_transactions? ? "this and " : "" - raise StandardError, "An error has occurred, #{canceled_msg}all later migrations canceled:\n\n#{e}", e.backtrace - end - end - end - - def migrations - @migrations ||= begin - files = Dir["#{@migrations_path}/[0-9]*_*.rb"] - - migrations = files.inject([]) do |klasses, file| - version, name = file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first - - raise IllegalMigrationNameError.new(file) unless version - version = version.to_i - - if klasses.detect { |m| m.version == version } - raise DuplicateMigrationVersionError.new(version) - end - - if klasses.detect { |m| m.name == name.camelize } - raise DuplicateMigrationNameError.new(name.camelize) - end - - klasses << (MigrationProxy.new).tap do |migration| - migration.name = name.camelize - migration.version = version - migration.filename = file - end - end - - migrations = migrations.sort_by(&:version) - down? ? migrations.reverse : migrations - end - end - - def pending_migrations - already_migrated = migrated - migrations.reject { |m| already_migrated.include?(m.version.to_i) } - end - - def migrated - @migrated_versions ||= self.class.get_all_versions - end - - private - def record_version_state_after_migrating(version) - sm_table = self.class.schema_migrations_table_name - - @migrated_versions ||= [] - if down? - @migrated_versions.delete(version.to_i) - Base.connection.update("DELETE FROM #{sm_table} WHERE version = '#{version}'") - else - @migrated_versions.push(version.to_i).sort! - Base.connection.insert("INSERT INTO #{sm_table} (version) VALUES ('#{version}')") - end - end - - def up? - @direction == :up - end - - def down? - @direction == :down - end - - # Wrap the migration in a transaction only if supported by the adapter. - def ddl_transaction(&block) - if Base.connection.supports_ddl_transactions? - Base.transaction { block.call } - else - block.call - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/named_scope.rb b/vendor/rails/activerecord/lib/active_record/named_scope.rb deleted file mode 100644 index 5e49de6a..00000000 --- a/vendor/rails/activerecord/lib/active_record/named_scope.rb +++ /dev/null @@ -1,197 +0,0 @@ -module ActiveRecord - module NamedScope - # All subclasses of ActiveRecord::Base have one named scope: - # * <tt>scoped</tt> - which allows for the creation of anonymous \scopes, on the fly: <tt>Shirt.scoped(:conditions => {:color => 'red'}).scoped(:include => :washing_instructions)</tt> - # - # These anonymous \scopes tend to be useful when procedurally generating complex queries, where passing - # intermediate values (scopes) around as first-class objects is convenient. - # - # You can define a scope that applies to all finders using ActiveRecord::Base.default_scope. - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def scopes - read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {}) - end - - def scoped(scope, &block) - Scope.new(self, scope, &block) - end - - # Adds a class method for retrieving and querying objects. A scope represents a narrowing of a database query, - # such as <tt>:conditions => {:color => :red}, :select => 'shirts.*', :include => :washing_instructions</tt>. - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} - # named_scope :dry_clean_only, :joins => :washing_instructions, :conditions => ['washing_instructions.dry_clean_only = ?', true] - # end - # - # The above calls to <tt>named_scope</tt> define class methods Shirt.red and Shirt.dry_clean_only. Shirt.red, - # in effect, represents the query <tt>Shirt.find(:all, :conditions => {:color => 'red'})</tt>. - # - # Unlike <tt>Shirt.find(...)</tt>, however, the object returned by Shirt.red is not an Array; it resembles the association object - # constructed by a <tt>has_many</tt> declaration. For instance, you can invoke <tt>Shirt.red.find(:first)</tt>, <tt>Shirt.red.count</tt>, - # <tt>Shirt.red.find(:all, :conditions => {:size => 'small'})</tt>. Also, just - # as with the association objects, named \scopes act like an Array, implementing Enumerable; <tt>Shirt.red.each(&block)</tt>, - # <tt>Shirt.red.first</tt>, and <tt>Shirt.red.inject(memo, &block)</tt> all behave as if Shirt.red really was an Array. - # - # These named \scopes are composable. For instance, <tt>Shirt.red.dry_clean_only</tt> will produce all shirts that are both red and dry clean only. - # Nested finds and calculations also work with these compositions: <tt>Shirt.red.dry_clean_only.count</tt> returns the number of garments - # for which these criteria obtain. Similarly with <tt>Shirt.red.dry_clean_only.average(:thread_count)</tt>. - # - # All \scopes are available as class methods on the ActiveRecord::Base descendant upon which the \scopes were defined. But they are also available to - # <tt>has_many</tt> associations. If, - # - # class Person < ActiveRecord::Base - # has_many :shirts - # end - # - # then <tt>elton.shirts.red.dry_clean_only</tt> will return all of Elton's red, dry clean - # only shirts. - # - # Named \scopes can also be procedural: - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # In this example, <tt>Shirt.colored('puce')</tt> finds all puce shirts. - # - # Named \scopes can also have extensions, just as with <tt>has_many</tt> declarations: - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} do - # def dom_id - # 'red_shirts' - # end - # end - # end - # - # - # For testing complex named \scopes, you can examine the scoping options using the - # <tt>proxy_options</tt> method on the proxy itself. - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # expected_options = { :conditions => { :colored => 'red' } } - # assert_equal expected_options, Shirt.colored('red').proxy_options - def named_scope(name, options = {}, &block) - name = name.to_sym - - scopes[name] = lambda do |parent_scope, *args| - Scope.new(parent_scope, case options - when Hash - options - when Proc - if self.model_name != parent_scope.model_name - options.bind(parent_scope).call(*args) - else - options.call(*args) - end - end, &block) - end - - singleton_class.send :define_method, name do |*args| - scopes[name].call(self, *args) - end - end - end - - class Scope - attr_reader :proxy_scope, :proxy_options, :current_scoped_methods_when_defined - NON_DELEGATE_METHODS = %w(nil? send object_id class extend find size count sum average maximum minimum paginate first last empty? any? respond_to?).to_set - [].methods.each do |m| - unless m =~ /^__/ || NON_DELEGATE_METHODS.include?(m.to_s) - delegate m, :to => :proxy_found - end - end - - delegate :scopes, :with_scope, :scoped_methods, :to => :proxy_scope - - def initialize(proxy_scope, options, &block) - options ||= {} - [options[:extend]].flatten.each { |extension| extend extension } if options[:extend] - extend Module.new(&block) if block_given? - unless (Scope === proxy_scope || ActiveRecord::Associations::AssociationCollection === proxy_scope) - @current_scoped_methods_when_defined = proxy_scope.send(:current_scoped_methods) - end - @proxy_scope, @proxy_options = proxy_scope, options.except(:extend) - end - - def reload - load_found; self - end - - def first(*args) - if args.first.kind_of?(Integer) || (@found && !args.first.kind_of?(Hash)) - proxy_found.first(*args) - else - find(:first, *args) - end - end - - def last(*args) - if args.first.kind_of?(Integer) || (@found && !args.first.kind_of?(Hash)) - proxy_found.last(*args) - else - find(:last, *args) - end - end - - def size - @found ? @found.length : count - end - - def empty? - @found ? @found.empty? : count.zero? - end - - def respond_to?(method, include_private = false) - super || @proxy_scope.respond_to?(method, include_private) - end - - def any? - if block_given? - proxy_found.any? { |*block_args| yield(*block_args) } - else - !empty? - end - end - - protected - def proxy_found - @found || load_found - end - - private - def method_missing(method, *args, &block) - if scopes.include?(method) - scopes[method].call(self, *args) - else - with_scope({:find => proxy_options, :create => proxy_options[:conditions].is_a?(Hash) ? proxy_options[:conditions] : {}}, :reverse_merge) do - method = :new if method == :build - if current_scoped_methods_when_defined && !scoped_methods.include?(current_scoped_methods_when_defined) - with_scope current_scoped_methods_when_defined do - proxy_scope.send(method, *args, &block) - end - else - proxy_scope.send(method, *args, &block) - end - end - end - end - - def load_found - @found = find(:all) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/nested_attributes.rb b/vendor/rails/activerecord/lib/active_record/nested_attributes.rb deleted file mode 100644 index 65434fb0..00000000 --- a/vendor/rails/activerecord/lib/active_record/nested_attributes.rb +++ /dev/null @@ -1,404 +0,0 @@ -module ActiveRecord - module NestedAttributes #:nodoc: - class TooManyRecords < ActiveRecordError - end - - def self.included(base) - base.extend(ClassMethods) - base.class_inheritable_accessor :nested_attributes_options, :instance_writer => false - base.nested_attributes_options = {} - end - - # == Nested Attributes - # - # Nested attributes allow you to save attributes on associated records - # through the parent. By default nested attribute updating is turned off, - # you can enable it using the accepts_nested_attributes_for class method. - # When you enable nested attributes an attribute writer is defined on - # the model. - # - # The attribute writer is named after the association, which means that - # in the following example, two new methods are added to your model: - # <tt>author_attributes=(attributes)</tt> and - # <tt>pages_attributes=(attributes)</tt>. - # - # class Book < ActiveRecord::Base - # has_one :author - # has_many :pages - # - # accepts_nested_attributes_for :author, :pages - # end - # - # Note that the <tt>:autosave</tt> option is automatically enabled on every - # association that accepts_nested_attributes_for is used for. - # - # === One-to-one - # - # Consider a Member model that has one Avatar: - # - # class Member < ActiveRecord::Base - # has_one :avatar - # accepts_nested_attributes_for :avatar - # end - # - # Enabling nested attributes on a one-to-one association allows you to - # create the member and avatar in one go: - # - # params = { :member => { :name => 'Jack', :avatar_attributes => { :icon => 'smiling' } } } - # member = Member.create(params) - # member.avatar.id # => 2 - # member.avatar.icon # => 'smiling' - # - # It also allows you to update the avatar through the member: - # - # params = { :member' => { :avatar_attributes => { :id => '2', :icon => 'sad' } } } - # member.update_attributes params['member'] - # member.avatar.icon # => 'sad' - # - # By default you will only be able to set and update attributes on the - # associated model. If you want to destroy the associated model through the - # attributes hash, you have to enable it first using the - # <tt>:allow_destroy</tt> option. - # - # class Member < ActiveRecord::Base - # has_one :avatar - # accepts_nested_attributes_for :avatar, :allow_destroy => true - # end - # - # Now, when you add the <tt>_destroy</tt> key to the attributes hash, with a - # value that evaluates to +true+, you will destroy the associated model: - # - # member.avatar_attributes = { :id => '2', :_destroy => '1' } - # member.avatar.marked_for_destruction? # => true - # member.save - # member.avatar #=> nil - # - # Note that the model will _not_ be destroyed until the parent is saved. - # - # === One-to-many - # - # Consider a member that has a number of posts: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts - # end - # - # You can now set or update attributes on an associated post model through - # the attribute hash. - # - # For each hash that does _not_ have an <tt>id</tt> key a new record will - # be instantiated, unless the hash also contains a <tt>_destroy</tt> key - # that evaluates to +true+. - # - # params = { :member => { - # :name => 'joe', :posts_attributes => [ - # { :title => 'Kari, the awesome Ruby documentation browser!' }, - # { :title => 'The egalitarian assumption of the modern citizen' }, - # { :title => '', :_destroy => '1' } # this will be ignored - # ] - # }} - # - # member = Member.create(params['member']) - # member.posts.length # => 2 - # member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!' - # member.posts.second.title # => 'The egalitarian assumption of the modern citizen' - # - # You may also set a :reject_if proc to silently ignore any new record - # hashes if they fail to pass your criteria. For example, the previous - # example could be rewritten as: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts, :reject_if => proc { |attributes| attributes['title'].blank? } - # end - # - # params = { :member => { - # :name => 'joe', :posts_attributes => [ - # { :title => 'Kari, the awesome Ruby documentation browser!' }, - # { :title => 'The egalitarian assumption of the modern citizen' }, - # { :title => '' } # this will be ignored because of the :reject_if proc - # ] - # }} - # - # member = Member.create(params['member']) - # member.posts.length # => 2 - # member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!' - # member.posts.second.title # => 'The egalitarian assumption of the modern citizen' - # - # Alternatively, :reject_if also accepts a symbol for using methods: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts, :reject_if => :new_record? - # end - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts, :reject_if => :reject_posts - # - # def reject_posts(attributed) - # attributed['title].blank? - # end - # end - # - # If the hash contains an <tt>id</tt> key that matches an already - # associated record, the matching record will be modified: - # - # member.attributes = { - # :name => 'Joe', - # :posts_attributes => [ - # { :id => 1, :title => '[UPDATED] An, as of yet, undisclosed awesome Ruby documentation browser!' }, - # { :id => 2, :title => '[UPDATED] other post' } - # ] - # } - # - # member.posts.first.title # => '[UPDATED] An, as of yet, undisclosed awesome Ruby documentation browser!' - # member.posts.second.title # => '[UPDATED] other post' - # - # By default the associated records are protected from being destroyed. If - # you want to destroy any of the associated records through the attributes - # hash, you have to enable it first using the <tt>:allow_destroy</tt> - # option. This will allow you to also use the <tt>_destroy</tt> key to - # destroy existing records: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts, :allow_destroy => true - # end - # - # params = { :member => { - # :posts_attributes => [{ :id => '2', :_destroy => '1' }] - # }} - # - # member.attributes = params['member'] - # member.posts.detect { |p| p.id == 2 }.marked_for_destruction? # => true - # member.posts.length #=> 2 - # member.save - # member.posts.length # => 1 - # - # === Saving - # - # All changes to models, including the destruction of those marked for - # destruction, are saved and destroyed automatically and atomically when - # the parent model is saved. This happens inside the transaction initiated - # by the parents save method. See ActiveRecord::AutosaveAssociation. - module ClassMethods - REJECT_ALL_BLANK_PROC = proc { |attributes| attributes.all? { |_, value| value.blank? } } - - # Defines an attributes writer for the specified association(s). If you - # are using <tt>attr_protected</tt> or <tt>attr_accessible</tt>, then you - # will need to add the attribute writer to the allowed list. - # - # Supported options: - # [:allow_destroy] - # If true, destroys any members from the attributes hash with a - # <tt>_destroy</tt> key and a value that evaluates to +true+ - # (eg. 1, '1', true, or 'true'). This option is off by default. - # [:reject_if] - # Allows you to specify a Proc or a Symbol pointing to a method - # that checks whether a record should be built for a certain attribute - # hash. The hash is passed to the supplied Proc or the method - # and it should return either +true+ or +false+. When no :reject_if - # is specified, a record will be built for all attribute hashes that - # do not have a <tt>_destroy</tt> value that evaluates to true. - # Passing <tt>:all_blank</tt> instead of a Proc will create a proc - # that will reject a record where all the attributes are blank. - # [:limit] - # Allows you to specify the maximum number of the associated records that - # can be processes with the nested attributes. If the size of the - # nested attributes array exceeds the specified limit, NestedAttributes::TooManyRecords - # exception is raised. If omitted, any number associations can be processed. - # Note that the :limit option is only applicable to one-to-many associations. - # [:update_only] - # Allows you to specify that an existing record may only be updated. - # A new record may only be created when there is no existing record. - # This option only works for one-to-one associations and is ignored for - # collection associations. This option is off by default. - # - # Examples: - # # creates avatar_attributes= - # accepts_nested_attributes_for :avatar, :reject_if => proc { |attributes| attributes['name'].blank? } - # # creates avatar_attributes= - # accepts_nested_attributes_for :avatar, :reject_if => :all_blank - # # creates avatar_attributes= and posts_attributes= - # accepts_nested_attributes_for :avatar, :posts, :allow_destroy => true - def accepts_nested_attributes_for(*attr_names) - options = { :allow_destroy => false, :update_only => false } - options.update(attr_names.extract_options!) - options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only) - options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank - - attr_names.each do |association_name| - if reflection = reflect_on_association(association_name) - reflection.options[:autosave] = true - add_autosave_association_callbacks(reflection) - nested_attributes_options[association_name.to_sym] = options - type = (reflection.collection? ? :collection : :one_to_one) - - # def pirate_attributes=(attributes) - # assign_nested_attributes_for_one_to_one_association(:pirate, attributes) - # end - class_eval <<-EOS, __FILE__, __LINE__ + 1 - def #{association_name}_attributes=(attributes) - assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes) - end - EOS - else - raise ArgumentError, "No association found for name `#{association_name}'. Has it been defined yet?" - end - end - end - end - - # Returns ActiveRecord::AutosaveAssociation::marked_for_destruction? It's - # used in conjunction with fields_for to build a form element for the - # destruction of this association. - # - # See ActionView::Helpers::FormHelper::fields_for for more info. - def _destroy - marked_for_destruction? - end - - private - - # Attribute hash keys that should not be assigned as normal attributes. - # These hash keys are nested attributes implementation details. - UNASSIGNABLE_KEYS = %w( id _destroy ) - - # Assigns the given attributes to the association. - # - # If update_only is false and the given attributes include an <tt>:id</tt> - # that matches the existing record’s id, then the existing record will be - # modified. If update_only is true, a new record is only created when no - # object exists. Otherwise a new record will be built. - # - # If the given attributes include a matching <tt>:id</tt> attribute, or - # update_only is true, and a <tt>:_destroy</tt> key set to a truthy value, - # then the existing record will be marked for destruction. - def assign_nested_attributes_for_one_to_one_association(association_name, attributes) - options = nested_attributes_options[association_name] - attributes = attributes.with_indifferent_access - check_existing_record = (options[:update_only] || !attributes['id'].blank?) - - if check_existing_record && (record = send(association_name)) && - (options[:update_only] || record.id.to_s == attributes['id'].to_s) - assign_to_or_mark_for_destruction(record, attributes, options[:allow_destroy]) - - elsif attributes['id'] - raise_nested_attributes_record_not_found(association_name, attributes['id']) - - elsif !reject_new_record?(association_name, attributes) - method = "build_#{association_name}" - if respond_to?(method) - send(method, attributes.except(*UNASSIGNABLE_KEYS)) - else - raise ArgumentError, "Cannot build association #{association_name}. Are you trying to build a polymorphic one-to-one association?" - end - end - end - - # Assigns the given attributes to the collection association. - # - # Hashes with an <tt>:id</tt> value matching an existing associated record - # will update that record. Hashes without an <tt>:id</tt> value will build - # a new record for the association. Hashes with a matching <tt>:id</tt> - # value and a <tt>:_destroy</tt> key set to a truthy value will mark the - # matched record for destruction. - # - # For example: - # - # assign_nested_attributes_for_collection_association(:people, { - # '1' => { :id => '1', :name => 'Peter' }, - # '2' => { :name => 'John' }, - # '3' => { :id => '2', :_destroy => true } - # }) - # - # Will update the name of the Person with ID 1, build a new associated - # person with the name `John', and mark the associatied Person with ID 2 - # for destruction. - # - # Also accepts an Array of attribute hashes: - # - # assign_nested_attributes_for_collection_association(:people, [ - # { :id => '1', :name => 'Peter' }, - # { :name => 'John' }, - # { :id => '2', :_destroy => true } - # ]) - def assign_nested_attributes_for_collection_association(association_name, attributes_collection) - options = nested_attributes_options[association_name] - - unless attributes_collection.is_a?(Hash) || attributes_collection.is_a?(Array) - raise ArgumentError, "Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})" - end - - if options[:limit] && attributes_collection.size > options[:limit] - raise TooManyRecords, "Maximum #{options[:limit]} records are allowed. Got #{attributes_collection.size} records instead." - end - - if attributes_collection.is_a? Hash - attributes_collection = attributes_collection.sort_by { |index, _| index.to_i }.map { |_, attributes| attributes } - end - - association = send(association_name) - - existing_records = if association.loaded? - association.to_a - else - attribute_ids = attributes_collection.map {|a| a['id'] || a[:id] }.compact - attribute_ids.present? ? association.all(:conditions => {association.primary_key => attribute_ids}) : [] - end - - attributes_collection.each do |attributes| - attributes = attributes.with_indifferent_access - - if attributes['id'].blank? - unless reject_new_record?(association_name, attributes) - association.build(attributes.except(*UNASSIGNABLE_KEYS)) - end - elsif existing_record = existing_records.detect { |record| record.id.to_s == attributes['id'].to_s } - association.send(:add_record_to_target_with_callbacks, existing_record) unless association.loaded? - assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy]) - else - raise_nested_attributes_record_not_found(association_name, attributes['id']) - end - end - end - - # Updates a record with the +attributes+ or marks it for destruction if - # +allow_destroy+ is +true+ and has_destroy_flag? returns +true+. - def assign_to_or_mark_for_destruction(record, attributes, allow_destroy) - if has_destroy_flag?(attributes) && allow_destroy - record.mark_for_destruction - else - record.attributes = attributes.except(*UNASSIGNABLE_KEYS) - end - end - - # Determines if a hash contains a truthy _destroy key. - def has_destroy_flag?(hash) - ConnectionAdapters::Column.value_to_boolean(hash['_destroy']) - end - - # Determines if a new record should be build by checking for - # has_destroy_flag? or if a <tt>:reject_if</tt> proc exists for this - # association and evaluates to +true+. - def reject_new_record?(association_name, attributes) - has_destroy_flag?(attributes) || call_reject_if(association_name, attributes) - end - - def call_reject_if(association_name, attributes) - case callback = nested_attributes_options[association_name][:reject_if] - when Symbol - method(callback).arity == 0 ? send(callback) : send(callback, attributes) - when Proc - callback.call(attributes) - end - end - - def raise_nested_attributes_record_not_found(association_name, record_id) - reflection = self.class.reflect_on_association(association_name) - raise RecordNotFound, "Couldn't find #{reflection.klass.name} with ID=#{record_id} for #{self.class.name} with ID=#{id}" - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/observer.rb b/vendor/rails/activerecord/lib/active_record/observer.rb deleted file mode 100644 index b35e407c..00000000 --- a/vendor/rails/activerecord/lib/active_record/observer.rb +++ /dev/null @@ -1,197 +0,0 @@ -require 'singleton' -require 'set' - -module ActiveRecord - module Observing # :nodoc: - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - # Activates the observers assigned. Examples: - # - # # Calls PersonObserver.instance - # ActiveRecord::Base.observers = :person_observer - # - # # Calls Cacher.instance and GarbageCollector.instance - # ActiveRecord::Base.observers = :cacher, :garbage_collector - # - # # Same as above, just using explicit class references - # ActiveRecord::Base.observers = Cacher, GarbageCollector - # - # Note: Setting this does not instantiate the observers yet. +instantiate_observers+ is - # called during startup, and before each development request. - def observers=(*observers) - @observers = observers.flatten - end - - # Gets the current observers. - def observers - @observers ||= [] - end - - # Instantiate the global Active Record observers. - def instantiate_observers - return if @observers.blank? - @observers.each do |observer| - if observer.respond_to?(:to_sym) # Symbol or String - observer.to_s.camelize.constantize.instance - elsif observer.respond_to?(:instance) - observer.instance - else - raise ArgumentError, "#{observer} must be a lowercase, underscored class name (or an instance of the class itself) responding to the instance method. Example: Person.observers = :big_brother # calls BigBrother.instance" - end - end - end - - protected - # Notify observers when the observed class is subclassed. - def inherited(subclass) - super - changed - notify_observers :observed_class_inherited, subclass - end - end - end - - # Observer classes respond to lifecycle callbacks to implement trigger-like - # behavior outside the original class. This is a great way to reduce the - # clutter that normally comes when the model class is burdened with - # functionality that doesn't pertain to the core responsibility of the - # class. Example: - # - # class CommentObserver < ActiveRecord::Observer - # def after_save(comment) - # Notifications.deliver_comment("admin@do.com", "New comment was posted", comment) - # end - # end - # - # This Observer sends an email when a Comment#save is finished. - # - # class ContactObserver < ActiveRecord::Observer - # def after_create(contact) - # contact.logger.info('New contact added!') - # end - # - # def after_destroy(contact) - # contact.logger.warn("Contact with an id of #{contact.id} was destroyed!") - # end - # end - # - # This Observer uses logger to log when specific callbacks are triggered. - # - # == Observing a class that can't be inferred - # - # Observers will by default be mapped to the class with which they share a name. So CommentObserver will - # be tied to observing Comment, ProductManagerObserver to ProductManager, and so on. If you want to name your observer - # differently than the class you're interested in observing, you can use the Observer.observe class method which takes - # either the concrete class (Product) or a symbol for that class (:product): - # - # class AuditObserver < ActiveRecord::Observer - # observe :account - # - # def after_update(account) - # AuditTrail.new(account, "UPDATED") - # end - # end - # - # If the audit observer needs to watch more than one kind of object, this can be specified with multiple arguments: - # - # class AuditObserver < ActiveRecord::Observer - # observe :account, :balance - # - # def after_update(record) - # AuditTrail.new(record, "UPDATED") - # end - # end - # - # The AuditObserver will now act on both updates to Account and Balance by treating them both as records. - # - # == Available callback methods - # - # The observer can implement callback methods for each of the methods described in the Callbacks module. - # - # == Storing Observers in Rails - # - # If you're using Active Record within Rails, observer classes are usually stored in app/models with the - # naming convention of app/models/audit_observer.rb. - # - # == Configuration - # - # In order to activate an observer, list it in the <tt>config.active_record.observers</tt> configuration setting in your - # <tt>config/environment.rb</tt> file. - # - # config.active_record.observers = :comment_observer, :signup_observer - # - # Observers will not be invoked unless you define these in your application configuration. - # - # == Loading - # - # Observers register themselves in the model class they observe, since it is the class that - # notifies them of events when they occur. As a side-effect, when an observer is loaded its - # corresponding model class is loaded. - # - # Up to (and including) Rails 2.0.2 observers were instantiated between plugins and - # application initializers. Now observers are loaded after application initializers, - # so observed models can make use of extensions. - # - # If by any chance you are using observed models in the initialization you can still - # load their observers by calling <tt>ModelObserver.instance</tt> before. Observers are - # singletons and that call instantiates and registers them. - # - class Observer - include Singleton - - class << self - # Attaches the observer to the supplied model classes. - def observe(*models) - models.flatten! - models.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model } - define_method(:observed_classes) { Set.new(models) } - end - - # The class observed by default is inferred from the observer's class name: - # assert_equal Person, PersonObserver.observed_class - def observed_class - if observed_class_name = name[/(.*)Observer/, 1] - observed_class_name.constantize - else - nil - end - end - end - - # Start observing the declared classes and their subclasses. - def initialize - Set.new(observed_classes + observed_subclasses).each { |klass| add_observer! klass } - end - - # Send observed_method(object) if the method exists. - def update(observed_method, object) #:nodoc: - send(observed_method, object) if respond_to?(observed_method) - end - - # Special method sent by the observed class when it is inherited. - # Passes the new subclass. - def observed_class_inherited(subclass) #:nodoc: - self.class.observe(observed_classes + [subclass]) - add_observer!(subclass) - end - - protected - def observed_classes - Set.new([self.class.observed_class].compact.flatten) - end - - def observed_subclasses - observed_classes.sum([]) { |klass| klass.send(:subclasses) } - end - - def add_observer!(klass) - klass.add_observer(self) - if respond_to?(:after_find) && !klass.method_defined?(:after_find) - klass.class_eval 'def after_find() end' - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/query_cache.rb b/vendor/rails/activerecord/lib/active_record/query_cache.rb deleted file mode 100644 index eb92bc25..00000000 --- a/vendor/rails/activerecord/lib/active_record/query_cache.rb +++ /dev/null @@ -1,33 +0,0 @@ -module ActiveRecord - class QueryCache - module ClassMethods - # Enable the query cache within the block if Active Record is configured. - def cache(&block) - if ActiveRecord::Base.configurations.blank? - yield - else - connection.cache(&block) - end - end - - # Disable the query cache within the block if Active Record is configured. - def uncached(&block) - if ActiveRecord::Base.configurations.blank? - yield - else - connection.uncached(&block) - end - end - end - - def initialize(app) - @app = app - end - - def call(env) - ActiveRecord::Base.cache do - @app.call(env) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/reflection.rb b/vendor/rails/activerecord/lib/active_record/reflection.rb deleted file mode 100644 index 13bcb8b1..00000000 --- a/vendor/rails/activerecord/lib/active_record/reflection.rb +++ /dev/null @@ -1,385 +0,0 @@ -module ActiveRecord - module Reflection # :nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # Reflection allows you to interrogate Active Record classes and objects about their associations and aggregations. - # This information can, for example, be used in a form builder that took an Active Record object and created input - # fields for all of the attributes depending on their type and displayed the associations to other objects. - # - # You can find the interface for the AggregateReflection and AssociationReflection classes in the abstract MacroReflection class. - module ClassMethods - def create_reflection(macro, name, options, active_record) - case macro - when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many - klass = options[:through] ? ThroughReflection : AssociationReflection - reflection = klass.new(macro, name, options, active_record) - when :composed_of - reflection = AggregateReflection.new(macro, name, options, active_record) - end - write_inheritable_hash :reflections, name => reflection - reflection - end - - # Returns a hash containing all AssociationReflection objects for the current class - # Example: - # - # Invoice.reflections - # Account.reflections - # - def reflections - read_inheritable_attribute(:reflections) || write_inheritable_attribute(:reflections, {}) - end - - # Returns an array of AggregateReflection objects for all the aggregations in the class. - def reflect_on_all_aggregations - reflections.values.select { |reflection| reflection.is_a?(AggregateReflection) } - end - - # Returns the AggregateReflection object for the named +aggregation+ (use the symbol). Example: - # - # Account.reflect_on_aggregation(:balance) # returns the balance AggregateReflection - # - def reflect_on_aggregation(aggregation) - reflections[aggregation].is_a?(AggregateReflection) ? reflections[aggregation] : nil - end - - # Returns an array of AssociationReflection objects for all the associations in the class. If you only want to reflect on a - # certain association type, pass in the symbol (<tt>:has_many</tt>, <tt>:has_one</tt>, <tt>:belongs_to</tt>) for that as the first parameter. - # Example: - # - # Account.reflect_on_all_associations # returns an array of all associations - # Account.reflect_on_all_associations(:has_many) # returns an array of all has_many associations - # - def reflect_on_all_associations(macro = nil) - association_reflections = reflections.values.select { |reflection| reflection.is_a?(AssociationReflection) } - macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections - end - - # Returns the AssociationReflection object for the named +association+ (use the symbol). Example: - # - # Account.reflect_on_association(:owner) # returns the owner AssociationReflection - # Invoice.reflect_on_association(:line_items).macro # returns :has_many - # - def reflect_on_association(association) - reflections[association].is_a?(AssociationReflection) ? reflections[association] : nil - end - - # Returns an array of AssociationReflection objects for all associations which have <tt>:autosave</tt> enabled. - def reflect_on_all_autosave_associations - reflections.values.select { |reflection| reflection.options[:autosave] } - end - end - - - # Abstract base class for AggregateReflection and AssociationReflection that describes the interface available for both of - # those classes. Objects of AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods. - class MacroReflection - attr_reader :active_record - - def initialize(macro, name, options, active_record) - @macro, @name, @options, @active_record = macro, name, options, active_record - end - - # Returns the name of the macro. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> will return - # <tt>:balance</tt> or for <tt>has_many :clients</tt> it will return <tt>:clients</tt>. - def name - @name - end - - # Returns the macro type. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>:composed_of</tt> - # or for <tt>has_many :clients</tt> will return <tt>:has_many</tt>. - def macro - @macro - end - - # Returns the hash of options used for the macro. For example, it would return <tt>{ :class_name => "Money" }</tt> for - # <tt>composed_of :balance, :class_name => 'Money'</tt> or +{}+ for <tt>has_many :clients</tt>. - def options - @options - end - - # Returns the class for the macro. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns the Money - # class and <tt>has_many :clients</tt> returns the Client class. - def klass - @klass ||= class_name.constantize - end - - # Returns the class name for the macro. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt> - # and <tt>has_many :clients</tt> returns <tt>'Client'</tt>. - def class_name - @class_name ||= options[:class_name] || derive_class_name - end - - # Returns +true+ if +self+ and +other_aggregation+ have the same +name+ attribute, +active_record+ attribute, - # and +other_aggregation+ has an options hash assigned to it. - def ==(other_aggregation) - other_aggregation.kind_of?(self.class) && name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record - end - - def sanitized_conditions #:nodoc: - @sanitized_conditions ||= klass.send(:sanitize_sql, options[:conditions]) if options[:conditions] - end - - # Returns +true+ if +self+ is a +belongs_to+ reflection. - def belongs_to? - macro == :belongs_to - end - - private - def derive_class_name - name.to_s.camelize - end - end - - - # Holds all the meta-data about an aggregation as it was specified in the Active Record class. - class AggregateReflection < MacroReflection #:nodoc: - end - - # Holds all the meta-data about an association as it was specified in the Active Record class. - class AssociationReflection < MacroReflection #:nodoc: - # Returns the target association's class: - # - # class Author < ActiveRecord::Base - # has_many :books - # end - # - # Author.reflect_on_association(:books).klass - # # => Book - # - # <b>Note:</b> do not call +klass.new+ or +klass.create+ to instantiate - # a new association object. Use +build_association+ or +create_association+ - # instead. This allows plugins to hook into association object creation. - def klass - @klass ||= active_record.send(:compute_type, class_name) - end - - # Returns a new, unsaved instance of the associated class. +options+ will - # be passed to the class's constructor. - def build_association(*options) - klass.new(*options) - end - - # Creates a new instance of the associated class, and immediates saves it - # with ActiveRecord::Base#save. +options+ will be passed to the class's - # creation method. Returns the newly created object. - def create_association(*options) - klass.create(*options) - end - - # Creates a new instance of the associated class, and immediates saves it - # with ActiveRecord::Base#save!. +options+ will be passed to the class's - # creation method. If the created record doesn't pass validations, then an - # exception will be raised. - # - # Returns the newly created object. - def create_association!(*options) - klass.create!(*options) - end - - def table_name - @table_name ||= klass.table_name - end - - def quoted_table_name - @quoted_table_name ||= klass.quoted_table_name - end - - def primary_key_name - @primary_key_name ||= options[:foreign_key] || derive_primary_key_name - end - - def association_foreign_key - @association_foreign_key ||= @options[:association_foreign_key] || class_name.foreign_key - end - - def counter_cache_column - if options[:counter_cache] == true - "#{active_record.name.demodulize.underscore.pluralize}_count" - elsif options[:counter_cache] - options[:counter_cache] - end - end - - def columns(tbl_name, log_msg) - @columns ||= klass.connection.columns(tbl_name, log_msg) - end - - def reset_column_information - @columns = nil - end - - def check_validity! - check_validity_of_inverse! - end - - def check_validity_of_inverse! - unless options[:polymorphic] - if has_inverse? && inverse_of.nil? - raise InverseOfAssociationNotFoundError.new(self) - end - end - end - - def through_reflection - false - end - - def through_reflection_primary_key_name - end - - def source_reflection - nil - end - - def has_inverse? - !@options[:inverse_of].nil? - end - - def inverse_of - if has_inverse? - @inverse_of ||= klass.reflect_on_association(options[:inverse_of]) - end - end - - def polymorphic_inverse_of(associated_class) - if has_inverse? - if inverse_relationship = associated_class.reflect_on_association(options[:inverse_of]) - inverse_relationship - else - raise InverseOfAssociationNotFoundError.new(self, associated_class) - end - end - end - - # Returns whether or not this association reflection is for a collection - # association. Returns +true+ if the +macro+ is one of +has_many+ or - # +has_and_belongs_to_many+, +false+ otherwise. - def collection? - if @collection.nil? - @collection = [:has_many, :has_and_belongs_to_many].include?(macro) - end - @collection - end - - # Returns whether or not the association should be validated as part of - # the parent's validation. - # - # Unless you explicitely disable validation with - # <tt>:validate => false</tt>, it will take place when: - # - # * you explicitely enable validation; <tt>:validate => true</tt> - # * you use autosave; <tt>:autosave => true</tt> - # * the association is a +has_many+ association - def validate? - !options[:validate].nil? ? options[:validate] : (options[:autosave] == true || macro == :has_many) - end - - def dependent_conditions(record, base_class, extra_conditions) - dependent_conditions = [] - dependent_conditions << "#{primary_key_name} = #{record.send(name).send(:owner_quoted_id)}" - dependent_conditions << "#{options[:as]}_type = '#{base_class.name}'" if options[:as] - dependent_conditions << klass.send(:sanitize_sql, options[:conditions]) if options[:conditions] - dependent_conditions = dependent_conditions.collect {|where| "(#{where})" }.join(" AND ") - dependent_conditions << extra_conditions if extra_conditions - dependent_conditions = dependent_conditions.gsub('@', '\@') - dependent_conditions - end - - private - def derive_class_name - class_name = name.to_s.camelize - class_name = class_name.singularize if collection? - class_name - end - - def derive_primary_key_name - if belongs_to? - "#{name}_id" - elsif options[:as] - "#{options[:as]}_id" - else - active_record.name.foreign_key - end - end - end - - # Holds all the meta-data about a :through association as it was specified in the Active Record class. - class ThroughReflection < AssociationReflection #:nodoc: - # Gets the source of the through reflection. It checks both a singularized and pluralized form for <tt>:belongs_to</tt> or <tt>:has_many</tt>. - # (The <tt>:tags</tt> association on Tagging below.) - # - # class Post < ActiveRecord::Base - # has_many :taggings - # has_many :tags, :through => :taggings - # end - # - def source_reflection - @source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first - end - - # Returns the AssociationReflection object specified in the <tt>:through</tt> option - # of a HasManyThrough or HasOneThrough association. Example: - # - # class Post < ActiveRecord::Base - # has_many :taggings - # has_many :tags, :through => :taggings - # end - # - # tags_reflection = Post.reflect_on_association(:tags) - # taggings_reflection = tags_reflection.through_reflection - # - def through_reflection - @through_reflection ||= active_record.reflect_on_association(options[:through]) - end - - # Gets an array of possible <tt>:through</tt> source reflection names: - # - # [:singularized, :pluralized] - # - def source_reflection_names - @source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym } - end - - def check_validity! - if through_reflection.nil? - raise HasManyThroughAssociationNotFoundError.new(active_record.name, self) - end - - if source_reflection.nil? - raise HasManyThroughSourceAssociationNotFoundError.new(self) - end - - if options[:source_type] && source_reflection.options[:polymorphic].nil? - raise HasManyThroughAssociationPointlessSourceTypeError.new(active_record.name, self, source_reflection) - end - - if source_reflection.options[:polymorphic] && options[:source_type].nil? - raise HasManyThroughAssociationPolymorphicError.new(active_record.name, self, source_reflection) - end - - unless [:belongs_to, :has_many, :has_one].include?(source_reflection.macro) && source_reflection.options[:through].nil? - raise HasManyThroughSourceAssociationMacroError.new(self) - end - - check_validity_of_inverse! - end - - def through_reflection_primary_key - through_reflection.belongs_to? ? through_reflection.klass.primary_key : through_reflection.primary_key_name - end - - def through_reflection_primary_key_name - through_reflection.primary_key_name if through_reflection.belongs_to? - end - - private - def derive_class_name - # get the class_name of the belongs_to association of the through reflection - options[:source_type] || source_reflection.class_name - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/schema.rb b/vendor/rails/activerecord/lib/active_record/schema.rb deleted file mode 100644 index a996a0eb..00000000 --- a/vendor/rails/activerecord/lib/active_record/schema.rb +++ /dev/null @@ -1,55 +0,0 @@ -module ActiveRecord - # Allows programmers to programmatically define a schema in a portable - # DSL. This means you can define tables, indexes, etc. without using SQL - # directly, so your applications can more easily support multiple - # databases. - # - # Usage: - # - # ActiveRecord::Schema.define do - # create_table :authors do |t| - # t.string :name, :null => false - # end - # - # add_index :authors, :name, :unique - # - # create_table :posts do |t| - # t.integer :author_id, :null => false - # t.string :subject - # t.text :body - # t.boolean :private, :default => false - # end - # - # add_index :posts, :author_id - # end - # - # ActiveRecord::Schema is only supported by database adapters that also - # support migrations, the two features being very similar. - class Schema < Migration - private_class_method :new - - def self.migrations_path - ActiveRecord::Migrator.migrations_path - end - - # Eval the given block. All methods available to the current connection - # adapter are available within the block, so you can easily use the - # database definition DSL to build up your schema (+create_table+, - # +add_index+, etc.). - # - # The +info+ hash is optional, and if given is used to define metadata - # about the current schema (currently, only the schema's version): - # - # ActiveRecord::Schema.define(:version => 20380119000001) do - # ... - # end - def self.define(info={}, &block) - instance_eval(&block) - - unless info[:version].blank? - initialize_schema_migrations_table - assume_migrated_upto_version(info[:version], migrations_path) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/schema_dumper.rb b/vendor/rails/activerecord/lib/active_record/schema_dumper.rb deleted file mode 100644 index 1a21f86c..00000000 --- a/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'stringio' -require 'bigdecimal' - -module ActiveRecord - # This class is used to dump the database schema for some connection to some - # output format (i.e., ActiveRecord::Schema). - class SchemaDumper #:nodoc: - private_class_method :new - - ## - # :singleton-method: - # A list of tables which should not be dumped to the schema. - # Acceptable values are strings as well as regexp. - # This setting is only used if ActiveRecord::Base.schema_format == :ruby - cattr_accessor :ignore_tables - @@ignore_tables = [] - - def self.dump(connection=ActiveRecord::Base.connection, stream=STDOUT) - new(connection).dump(stream) - stream - end - - def dump(stream) - header(stream) - tables(stream) - trailer(stream) - stream - end - - private - - def initialize(connection) - @connection = connection - @types = @connection.native_database_types - @version = Migrator::current_version rescue nil - end - - def header(stream) - define_params = @version ? ":version => #{@version}" : "" - - stream.puts <<HEADER -# This file is auto-generated from the current state of the database. Instead of editing this file, -# please use the migrations feature of Active Record to incrementally modify your database, and -# then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your database schema. If you need -# to create the application database on another system, you should be using db:schema:load, not running -# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(#{define_params}) do - -HEADER - end - - def trailer(stream) - stream.puts "end" - end - - def tables(stream) - @connection.tables.sort.each do |tbl| - next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| - case ignored - when String; tbl == ignored - when Regexp; tbl =~ ignored - else - raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' - end - end - table(tbl, stream) - end - end - - def table(table, stream) - columns = @connection.columns(table) - begin - tbl = StringIO.new - - # first dump primary key column - if @connection.respond_to?(:pk_and_sequence_for) - pk, pk_seq = @connection.pk_and_sequence_for(table) - elsif @connection.respond_to?(:primary_key) - pk = @connection.primary_key(table) - end - - tbl.print " create_table #{table.inspect}" - if columns.detect { |c| c.name == pk } - if pk != 'id' - tbl.print %Q(, :primary_key => "#{pk}") - end - else - tbl.print ", :id => false" - end - tbl.print ", :force => true" - tbl.puts " do |t|" - - # then dump all non-primary key columns - column_specs = columns.map do |column| - raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil? - next if column.name == pk - spec = {} - spec[:name] = column.name.inspect - spec[:type] = column.type.to_s - spec[:limit] = column.limit.inspect if column.limit != @types[column.type][:limit] && column.type != :decimal - spec[:precision] = column.precision.inspect if !column.precision.nil? - spec[:scale] = column.scale.inspect if !column.scale.nil? - spec[:null] = 'false' if !column.null - spec[:default] = default_string(column.default) if column.has_default? - (spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.inspect} => ")} - spec - end.compact - - # find all migration keys used in this table - keys = [:name, :limit, :precision, :scale, :default, :null] & column_specs.map(&:keys).flatten - - # figure out the lengths for each column based on above keys - lengths = keys.map{ |key| column_specs.map{ |spec| spec[key] ? spec[key].length + 2 : 0 }.max } - - # the string we're going to sprintf our values against, with standardized column widths - format_string = lengths.map{ |len| "%-#{len}s" } - - # find the max length for the 'type' column, which is special - type_length = column_specs.map{ |column| column[:type].length }.max - - # add column type definition to our format string - format_string.unshift " t.%-#{type_length}s " - - format_string *= '' - - column_specs.each do |colspec| - values = keys.zip(lengths).map{ |key, len| colspec.key?(key) ? colspec[key] + ", " : " " * len } - values.unshift colspec[:type] - tbl.print((format_string % values).gsub(/,\s*$/, '')) - tbl.puts - end - - tbl.puts " end" - tbl.puts - - indexes(table, tbl) - - tbl.rewind - stream.print tbl.read - rescue => e - stream.puts "# Could not dump table #{table.inspect} because of following #{e.class}" - stream.puts "# #{e.message}" - stream.puts - end - - stream - end - - def default_string(value) - case value - when BigDecimal - value.to_s - when Date, DateTime, Time - "'" + value.to_s(:db) + "'" - else - value.inspect - end - end - - def indexes(table, stream) - if (indexes = @connection.indexes(table)).any? - add_index_statements = indexes.map do |index| - statment_parts = [ ('add_index ' + index.table.inspect) ] - statment_parts << index.columns.inspect - statment_parts << (':name => ' + index.name.inspect) - statment_parts << ':unique => true' if index.unique - - index_lengths = index.lengths.compact if index.lengths.is_a?(Array) - statment_parts << (':length => ' + Hash[*index.columns.zip(index.lengths).flatten].inspect) if index_lengths.present? - - ' ' + statment_parts.join(', ') - end - - stream.puts add_index_statements.sort.join("\n") - stream.puts - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/serialization.rb b/vendor/rails/activerecord/lib/active_record/serialization.rb deleted file mode 100644 index 4e2081ec..00000000 --- a/vendor/rails/activerecord/lib/active_record/serialization.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'active_support/json' - -module ActiveRecord #:nodoc: - module Serialization - class Serializer #:nodoc: - attr_reader :options - - def initialize(record, options = nil) - @record = record - @options = options ? options.dup : {} - end - - # To replicate the behavior in ActiveRecord#attributes, - # <tt>:except</tt> takes precedence over <tt>:only</tt>. If <tt>:only</tt> is not set - # for a N level model but is set for the N+1 level models, - # then because <tt>:except</tt> is set to a default value, the second - # level model can have both <tt>:except</tt> and <tt>:only</tt> set. So if - # <tt>:only</tt> is set, always delete <tt>:except</tt>. - def serializable_attribute_names - attribute_names = @record.attribute_names - - if options[:only] - options.delete(:except) - attribute_names = attribute_names & Array(options[:only]).collect { |n| n.to_s } - else - options[:except] = Array(options[:except]) | Array(@record.class.inheritance_column) - attribute_names = attribute_names - options[:except].collect { |n| n.to_s } - end - - attribute_names - end - - def serializable_method_names - Array(options[:methods]).inject([]) do |method_attributes, name| - method_attributes << name if @record.respond_to?(name.to_s) - method_attributes - end - end - - def serializable_names - serializable_attribute_names + serializable_method_names - end - - # Add associations specified via the <tt>:includes</tt> option. - # Expects a block that takes as arguments: - # +association+ - name of the association - # +records+ - the association record(s) to be serialized - # +opts+ - options for the association records - def add_includes(&block) - if include_associations = options.delete(:include) - base_only_or_except = { :except => options[:except], - :only => options[:only] } - - include_has_options = include_associations.is_a?(Hash) - associations = include_has_options ? include_associations.keys : Array(include_associations) - - for association in associations - records = case @record.class.reflect_on_association(association).macro - when :has_many, :has_and_belongs_to_many - @record.send(association).to_a - when :has_one, :belongs_to - @record.send(association) - end - - unless records.nil? - association_options = include_has_options ? include_associations[association] : base_only_or_except - opts = options.merge(association_options) - yield(association, records, opts) - end - end - - options[:include] = include_associations - end - end - - def serializable_record - {}.tap do |serializable_record| - serializable_names.each { |name| serializable_record[name] = @record.send(name) } - add_includes do |association, records, opts| - if records.is_a?(Enumerable) - serializable_record[association] = records.collect { |r| self.class.new(r, opts).serializable_record } - else - serializable_record[association] = self.class.new(records, opts).serializable_record - end - end - end - end - - def serialize - # overwrite to implement - end - - def to_s(&block) - serialize(&block) - end - end - end -end - -require 'active_record/serializers/xml_serializer' -require 'active_record/serializers/json_serializer' diff --git a/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb b/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb deleted file mode 100644 index 5d493816..00000000 --- a/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'active_support/json' -require 'active_support/core_ext/module/model_naming' - -module ActiveRecord #:nodoc: - module Serialization - def self.included(base) - base.cattr_accessor :include_root_in_json, :instance_writer => false - end - - # Returns a JSON string representing the model. Some configuration is - # available through +options+. - # - # The option <tt>ActiveRecord::Base.include_root_in_json</tt> controls the - # top-level behavior of to_json. In a new Rails application, it is set to - # <tt>true</tt> in initializers/new_rails_defaults.rb. When it is <tt>true</tt>, - # to_json will emit a single root node named after the object's type. For example: - # - # konata = User.find(1) - # ActiveRecord::Base.include_root_in_json = true - # konata.to_json - # # => { "user": {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true} } - # - # ActiveRecord::Base.include_root_in_json = false - # konata.to_json - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true} - # - # The remainder of the examples in this section assume include_root_in_json is set to - # <tt>false</tt>. - # - # Without any +options+, the returned JSON string will include all - # the model's attributes. For example: - # - # konata = User.find(1) - # konata.to_json - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true} - # - # The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the attributes - # included, and work similar to the +attributes+ method. For example: - # - # konata.to_json(:only => [ :id, :name ]) - # # => {"id": 1, "name": "Konata Izumi"} - # - # konata.to_json(:except => [ :id, :created_at, :age ]) - # # => {"name": "Konata Izumi", "awesome": true} - # - # To include any methods on the model, use <tt>:methods</tt>. - # - # konata.to_json(:methods => :permalink) - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true, - # "permalink": "1-konata-izumi"} - # - # To include associations, use <tt>:include</tt>. - # - # konata.to_json(:include => :posts) - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true, - # "posts": [{"id": 1, "author_id": 1, "title": "Welcome to the weblog"}, - # {"id": 2, author_id: 1, "title": "So I was thinking"}]} - # - # 2nd level and higher order associations work as well: - # - # konata.to_json(:include => { :posts => { - # :include => { :comments => { - # :only => :body } }, - # :only => :title } }) - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true, - # "posts": [{"comments": [{"body": "1st post!"}, {"body": "Second!"}], - # "title": "Welcome to the weblog"}, - # {"comments": [{"body": "Don't think too hard"}], - # "title": "So I was thinking"}]} - def to_json(options = {}) - super - end - - def as_json(options = nil) #:nodoc: - hash = Serializer.new(self, options).serializable_record - hash = { options[:root] || self.class.model_name.element => hash } if include_root_in_json - hash - end - - def from_json(json) - self.attributes = ActiveSupport::JSON.decode(json) - self - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb b/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb deleted file mode 100644 index 9bf11930..00000000 --- a/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +++ /dev/null @@ -1,357 +0,0 @@ -module ActiveRecord #:nodoc: - module Serialization - # Builds an XML document to represent the model. Some configuration is - # available through +options+. However more complicated cases should - # override ActiveRecord::Base#to_xml. - # - # By default the generated XML document will include the processing - # instruction and all the object's attributes. For example: - # - # <?xml version="1.0" encoding="UTF-8"?> - # <topic> - # <title>The First Topic</title> - # <author-name>David</author-name> - # <id type="integer">1</id> - # <approved type="boolean">false</approved> - # <replies-count type="integer">0</replies-count> - # <bonus-time type="datetime">2000-01-01T08:28:00+12:00</bonus-time> - # <written-on type="datetime">2003-07-16T09:28:00+1200</written-on> - # <content>Have a nice day</content> - # <author-email-address>david@loudthinking.com</author-email-address> - # <parent-id></parent-id> - # <last-read type="date">2004-04-15</last-read> - # </topic> - # - # This behavior can be controlled with <tt>:only</tt>, <tt>:except</tt>, - # <tt>:skip_instruct</tt>, <tt>:skip_types</tt>, <tt>:dasherize</tt> and <tt>:camelize</tt> . - # The <tt>:only</tt> and <tt>:except</tt> options are the same as for the - # +attributes+ method. The default is to dasherize all column names, but you - # can disable this setting <tt>:dasherize</tt> to +false+. Setting <tt>:camelize</tt> - # to +true+ will camelize all column names - this also overrides <tt>:dasherize</tt>. - # To not have the column type included in the XML output set <tt>:skip_types</tt> to +true+. - # - # For instance: - # - # topic.to_xml(:skip_instruct => true, :except => [ :id, :bonus_time, :written_on, :replies_count ]) - # - # <topic> - # <title>The First Topic</title> - # <author-name>David</author-name> - # <approved type="boolean">false</approved> - # <content>Have a nice day</content> - # <author-email-address>david@loudthinking.com</author-email-address> - # <parent-id></parent-id> - # <last-read type="date">2004-04-15</last-read> - # </topic> - # - # To include first level associations use <tt>:include</tt>: - # - # firm.to_xml :include => [ :account, :clients ] - # - # <?xml version="1.0" encoding="UTF-8"?> - # <firm> - # <id type="integer">1</id> - # <rating type="integer">1</rating> - # <name>37signals</name> - # <clients type="array"> - # <client> - # <rating type="integer">1</rating> - # <name>Summit</name> - # </client> - # <client> - # <rating type="integer">1</rating> - # <name>Microsoft</name> - # </client> - # </clients> - # <account> - # <id type="integer">1</id> - # <credit-limit type="integer">50</credit-limit> - # </account> - # </firm> - # - # To include deeper levels of associations pass a hash like this: - # - # firm.to_xml :include => {:account => {}, :clients => {:include => :address}} - # <?xml version="1.0" encoding="UTF-8"?> - # <firm> - # <id type="integer">1</id> - # <rating type="integer">1</rating> - # <name>37signals</name> - # <clients type="array"> - # <client> - # <rating type="integer">1</rating> - # <name>Summit</name> - # <address> - # ... - # </address> - # </client> - # <client> - # <rating type="integer">1</rating> - # <name>Microsoft</name> - # <address> - # ... - # </address> - # </client> - # </clients> - # <account> - # <id type="integer">1</id> - # <credit-limit type="integer">50</credit-limit> - # </account> - # </firm> - # - # To include any methods on the model being called use <tt>:methods</tt>: - # - # firm.to_xml :methods => [ :calculated_earnings, :real_earnings ] - # - # <firm> - # # ... normal attributes as shown above ... - # <calculated-earnings>100000000000000000</calculated-earnings> - # <real-earnings>5</real-earnings> - # </firm> - # - # To call any additional Procs use <tt>:procs</tt>. The Procs are passed a - # modified version of the options hash that was given to +to_xml+: - # - # proc = Proc.new { |options| options[:builder].tag!('abc', 'def') } - # firm.to_xml :procs => [ proc ] - # - # <firm> - # # ... normal attributes as shown above ... - # <abc>def</abc> - # </firm> - # - # Alternatively, you can yield the builder object as part of the +to_xml+ call: - # - # firm.to_xml do |xml| - # xml.creator do - # xml.first_name "David" - # xml.last_name "Heinemeier Hansson" - # end - # end - # - # <firm> - # # ... normal attributes as shown above ... - # <creator> - # <first_name>David</first_name> - # <last_name>Heinemeier Hansson</last_name> - # </creator> - # </firm> - # - # As noted above, you may override +to_xml+ in your ActiveRecord::Base - # subclasses to have complete control about what's generated. The general - # form of doing this is: - # - # class IHaveMyOwnXML < ActiveRecord::Base - # def to_xml(options = {}) - # options[:indent] ||= 2 - # xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - # xml.instruct! unless options[:skip_instruct] - # xml.level_one do - # xml.tag!(:second_level, 'content') - # end - # end - # end - def to_xml(options = {}, &block) - serializer = XmlSerializer.new(self, options) - block_given? ? serializer.to_s(&block) : serializer.to_s - end - - def from_xml(xml) - self.attributes = Hash.from_xml(xml).values.first - self - end - end - - class XmlSerializer < ActiveRecord::Serialization::Serializer #:nodoc: - def builder - @builder ||= begin - options[:indent] ||= 2 - builder = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - - unless options[:skip_instruct] - builder.instruct! - options[:skip_instruct] = true - end - - builder - end - end - - def root - root = (options[:root] || @record.class.model_name.singular).to_s - reformat_name(root) - end - - def dasherize? - !options.has_key?(:dasherize) || options[:dasherize] - end - - def camelize? - options.has_key?(:camelize) && options[:camelize] - end - - def reformat_name(name) - name = name.camelize if camelize? - dasherize? ? name.dasherize : name - end - - def serializable_attributes - serializable_attribute_names.collect { |name| Attribute.new(name, @record) } - end - - def serializable_method_attributes - Array(options[:methods]).inject([]) do |method_attributes, name| - method_attributes << MethodAttribute.new(name.to_s, @record) if @record.respond_to?(name.to_s) - method_attributes - end - end - - def add_attributes - (serializable_attributes + serializable_method_attributes).each do |attribute| - add_tag(attribute) - end - end - - def add_procs - if procs = options.delete(:procs) - [ *procs ].each do |proc| - proc.call(options) - end - end - end - - def add_tag(attribute) - builder.tag!( - reformat_name(attribute.name), - attribute.value.to_s, - attribute.decorations(!options[:skip_types]) - ) - end - - def add_associations(association, records, opts) - if records.is_a?(Enumerable) - tag = reformat_name(association.to_s) - type = options[:skip_types] ? {} : {:type => "array"} - - if records.empty? - builder.tag!(tag, type) - else - builder.tag!(tag, type) do - association_name = association.to_s.singularize - records.each do |record| - if options[:skip_types] - record_type = {} - else - record_class = (record.class.to_s.underscore == association_name) ? nil : record.class.name - record_type = {:type => record_class} - end - - record.to_xml opts.merge(:root => association_name).merge(record_type) - end - end - end - else - if record = @record.send(association) - record.to_xml(opts.merge(:root => association)) - end - end - end - - def serialize - args = [root] - if options[:namespace] - args << {:xmlns=>options[:namespace]} - end - - if options[:type] - args << {:type=>options[:type]} - end - - builder.tag!(*args) do - add_attributes - procs = options.delete(:procs) - add_includes { |association, records, opts| add_associations(association, records, opts) } - options[:procs] = procs - add_procs - yield builder if block_given? - end - end - - class Attribute #:nodoc: - attr_reader :name, :value, :type - - def initialize(name, record) - @name, @record = name, record - - @type = compute_type - @value = compute_value - end - - # There is a significant speed improvement if the value - # does not need to be escaped, as <tt>tag!</tt> escapes all values - # to ensure that valid XML is generated. For known binary - # values, it is at least an order of magnitude faster to - # Base64 encode binary values and directly put them in the - # output XML than to pass the original value or the Base64 - # encoded value to the <tt>tag!</tt> method. It definitely makes - # no sense to Base64 encode the value and then give it to - # <tt>tag!</tt>, since that just adds additional overhead. - def needs_encoding? - ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type) - end - - def decorations(include_types = true) - decorations = {} - - if type == :binary - decorations[:encoding] = 'base64' - end - - if include_types && type != :string - decorations[:type] = type - end - - if value.nil? - decorations[:nil] = true - end - - decorations - end - - protected - def compute_type - type = if @record.class.serialized_attributes.has_key?(name) - :yaml - else - @record.class.columns_hash[name].try(:type) - end - - case type - when :text - :string - when :time - :datetime - else - type - end - end - - def compute_value - value = @record.send(name) - - if formatter = Hash::XML_FORMATTING[type.to_s] - value ? formatter.call(value) : nil - else - value - end - end - end - - class MethodAttribute < Attribute #:nodoc: - protected - def compute_type - Hash::XML_TYPE_NAMES[@record.send(name).class.name] || :string - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/session_store.rb b/vendor/rails/activerecord/lib/active_record/session_store.rb deleted file mode 100644 index d6d0c6e1..00000000 --- a/vendor/rails/activerecord/lib/active_record/session_store.rb +++ /dev/null @@ -1,334 +0,0 @@ -module ActiveRecord - # A session store backed by an Active Record class. A default class is - # provided, but any object duck-typing to an Active Record Session class - # with text +session_id+ and +data+ attributes is sufficient. - # - # The default assumes a +sessions+ tables with columns: - # +id+ (numeric primary key), - # +session_id+ (text, or longtext if your session data exceeds 65K), and - # +data+ (text or longtext; careful if your session data exceeds 65KB). - # The +session_id+ column should always be indexed for speedy lookups. - # Session data is marshaled to the +data+ column in Base64 format. - # If the data you write is larger than the column's size limit, - # ActionController::SessionOverflowError will be raised. - # - # You may configure the table name, primary key, and data column. - # For example, at the end of <tt>config/environment.rb</tt>: - # ActiveRecord::SessionStore::Session.table_name = 'legacy_session_table' - # ActiveRecord::SessionStore::Session.primary_key = 'session_id' - # ActiveRecord::SessionStore::Session.data_column_name = 'legacy_session_data' - # Note that setting the primary key to the +session_id+ frees you from - # having a separate +id+ column if you don't want it. However, you must - # set <tt>session.model.id = session.session_id</tt> by hand! A before filter - # on ApplicationController is a good place. - # - # Since the default class is a simple Active Record, you get timestamps - # for free if you add +created_at+ and +updated_at+ datetime columns to - # the +sessions+ table, making periodic session expiration a snap. - # - # You may provide your own session class implementation, whether a - # feature-packed Active Record or a bare-metal high-performance SQL - # store, by setting - # ActiveRecord::SessionStore.session_class = MySessionClass - # You must implement these methods: - # self.find_by_session_id(session_id) - # initialize(hash_of_session_id_and_data) - # attr_reader :session_id - # attr_accessor :data - # save - # destroy - # - # The example SqlBypass class is a generic SQL session store. You may - # use it as a basis for high-performance database-specific stores. - class SessionStore < ActionController::Session::AbstractStore - # The default Active Record class. - class Session < ActiveRecord::Base - ## - # :singleton-method: - # Customizable data column name. Defaults to 'data'. - cattr_accessor :data_column_name - self.data_column_name = 'data' - - before_save :marshal_data! - before_save :raise_on_session_data_overflow! - - class << self - def data_column_size_limit - @data_column_size_limit ||= columns_hash[@@data_column_name].limit - end - - # Hook to set up sessid compatibility. - def find_by_session_id(session_id) - setup_sessid_compatibility! - find_by_session_id(session_id) - end - - def marshal(data) - ActiveSupport::Base64.encode64(Marshal.dump(data)) if data - end - - def unmarshal(data) - Marshal.load(ActiveSupport::Base64.decode64(data)) if data - end - - def create_table! - connection.execute <<-end_sql - CREATE TABLE #{table_name} ( - id INTEGER PRIMARY KEY, - #{connection.quote_column_name('session_id')} TEXT UNIQUE, - #{connection.quote_column_name(@@data_column_name)} TEXT(255) - ) - end_sql - end - - def drop_table! - connection.execute "DROP TABLE #{table_name}" - end - - private - # Compatibility with tables using sessid instead of session_id. - def setup_sessid_compatibility! - # Reset column info since it may be stale. - reset_column_information - if columns_hash['sessid'] - def self.find_by_session_id(*args) - find_by_sessid(*args) - end - - define_method(:session_id) { sessid } - define_method(:session_id=) { |session_id| self.sessid = session_id } - else - def self.find_by_session_id(session_id) - find :first, :conditions => {:session_id=>session_id} - end - end - end - end - - # Lazy-unmarshal session state. - def data - @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) || {} - end - - attr_writer :data - - # Has the session been loaded yet? - def loaded? - !!@data - end - - private - def marshal_data! - return false if !loaded? - write_attribute(@@data_column_name, self.class.marshal(self.data)) - end - - # Ensures that the data about to be stored in the database is not - # larger than the data storage column. Raises - # ActionController::SessionOverflowError. - def raise_on_session_data_overflow! - return false if !loaded? - limit = self.class.data_column_size_limit - if loaded? and limit and read_attribute(@@data_column_name).size > limit - raise ActionController::SessionOverflowError - end - end - end - - # A barebones session store which duck-types with the default session - # store but bypasses Active Record and issues SQL directly. This is - # an example session model class meant as a basis for your own classes. - # - # The database connection, table name, and session id and data columns - # are configurable class attributes. Marshaling and unmarshaling - # are implemented as class methods that you may override. By default, - # marshaling data is - # - # ActiveSupport::Base64.encode64(Marshal.dump(data)) - # - # and unmarshaling data is - # - # Marshal.load(ActiveSupport::Base64.decode64(data)) - # - # This marshaling behavior is intended to store the widest range of - # binary session data in a +text+ column. For higher performance, - # store in a +blob+ column instead and forgo the Base64 encoding. - class SqlBypass - ## - # :singleton-method: - # Use the ActiveRecord::Base.connection by default. - cattr_accessor :connection - - ## - # :singleton-method: - # The table name defaults to 'sessions'. - cattr_accessor :table_name - @@table_name = 'sessions' - - ## - # :singleton-method: - # The session id field defaults to 'session_id'. - cattr_accessor :session_id_column - @@session_id_column = 'session_id' - - ## - # :singleton-method: - # The data field defaults to 'data'. - cattr_accessor :data_column - @@data_column = 'data' - - class << self - def connection - @@connection ||= ActiveRecord::Base.connection - end - - # Look up a session by id and unmarshal its data if found. - def find_by_session_id(session_id) - if record = connection.select_one("SELECT * FROM #{@@table_name} WHERE #{@@session_id_column}=#{connection.quote(session_id)}") - new(:session_id => session_id, :marshaled_data => record['data']) - end - end - - def marshal(data) - ActiveSupport::Base64.encode64(Marshal.dump(data)) if data - end - - def unmarshal(data) - Marshal.load(ActiveSupport::Base64.decode64(data)) if data - end - - def create_table! - @@connection.execute <<-end_sql - CREATE TABLE #{table_name} ( - id INTEGER PRIMARY KEY, - #{@@connection.quote_column_name(session_id_column)} TEXT UNIQUE, - #{@@connection.quote_column_name(data_column)} TEXT - ) - end_sql - end - - def drop_table! - @@connection.execute "DROP TABLE #{table_name}" - end - end - - attr_reader :session_id - attr_writer :data - - # Look for normal and marshaled data, self.find_by_session_id's way of - # telling us to postpone unmarshaling until the data is requested. - # We need to handle a normal data attribute in case of a new record. - def initialize(attributes) - @session_id, @data, @marshaled_data = attributes[:session_id], attributes[:data], attributes[:marshaled_data] - @new_record = @marshaled_data.nil? - end - - def new_record? - @new_record - end - - # Lazy-unmarshal session state. - def data - unless @data - if @marshaled_data - @data, @marshaled_data = self.class.unmarshal(@marshaled_data) || {}, nil - else - @data = {} - end - end - @data - end - - def loaded? - !!@data - end - - def save - return false if !loaded? - marshaled_data = self.class.marshal(data) - - if @new_record - @new_record = false - @@connection.update <<-end_sql, 'Create session' - INSERT INTO #{@@table_name} ( - #{@@connection.quote_column_name(@@session_id_column)}, - #{@@connection.quote_column_name(@@data_column)} ) - VALUES ( - #{@@connection.quote(session_id)}, - #{@@connection.quote(marshaled_data)} ) - end_sql - else - @@connection.update <<-end_sql, 'Update session' - UPDATE #{@@table_name} - SET #{@@connection.quote_column_name(@@data_column)}=#{@@connection.quote(marshaled_data)} - WHERE #{@@connection.quote_column_name(@@session_id_column)}=#{@@connection.quote(session_id)} - end_sql - end - end - - def destroy - unless @new_record - @@connection.delete <<-end_sql, 'Destroy session' - DELETE FROM #{@@table_name} - WHERE #{@@connection.quote_column_name(@@session_id_column)}=#{@@connection.quote(session_id)} - end_sql - end - end - end - - # The class used for session storage. Defaults to - # ActiveRecord::SessionStore::Session - cattr_accessor :session_class - self.session_class = Session - - SESSION_RECORD_KEY = 'rack.session.record'.freeze - - private - def get_session(env, sid) - Base.silence do - sid ||= generate_sid - session = find_session(sid) - env[SESSION_RECORD_KEY] = session - [sid, session.data] - end - end - - def set_session(env, sid, session_data) - Base.silence do - record = get_session_model(env, sid) - record.data = session_data - return false unless record.save - - session_data = record.data - if session_data && session_data.respond_to?(:each_value) - session_data.each_value do |obj| - obj.clear_association_cache if obj.respond_to?(:clear_association_cache) - end - end - end - - return true - end - - def destroy(env) - if sid = current_session_id(env) - Base.silence do - get_session_model(env, sid).destroy - end - end - end - - def get_session_model(env, sid) - if env[ENV_SESSION_OPTIONS_KEY][:id].nil? - env[SESSION_RECORD_KEY] = find_session(sid) - else - env[SESSION_RECORD_KEY] ||= find_session(sid) - end - end - - def find_session(id) - @@session_class.find_by_session_id(id) || - @@session_class.new(:session_id => id, :data => {}) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/test_case.rb b/vendor/rails/activerecord/lib/active_record/test_case.rb deleted file mode 100644 index 8c6abaac..00000000 --- a/vendor/rails/activerecord/lib/active_record/test_case.rb +++ /dev/null @@ -1,66 +0,0 @@ -require "active_support/test_case" - -module ActiveRecord - class TestCase < ActiveSupport::TestCase #:nodoc: - def assert_date_from_db(expected, actual, message = nil) - # SybaseAdapter doesn't have a separate column type just for dates, - # so the time is in the string and incorrectly formatted - if current_adapter?(:SybaseAdapter) - assert_equal expected.to_s, actual.to_date.to_s, message - else - assert_equal expected.to_s, actual.to_s, message - end - end - - def assert_sql(*patterns_to_match) - $queries_executed = [] - yield - ensure - failed_patterns = [] - patterns_to_match.each do |pattern| - failed_patterns << pattern unless $queries_executed.any?{ |sql| pattern === sql } - end - assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found." - end - - def assert_queries(num = 1) - $queries_executed = [] - yield - ensure - %w{ BEGIN COMMIT }.each { |x| $queries_executed.delete(x) } - assert_equal num, $queries_executed.size, "#{$queries_executed.size} instead of #{num} queries were executed.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}" - end - - def assert_no_queries(&block) - assert_queries(0, &block) - end - - def self.use_concurrent_connections - setup :connection_allow_concurrency_setup - teardown :connection_allow_concurrency_teardown - end - - def connection_allow_concurrency_setup - @connection = ActiveRecord::Base.remove_connection - ActiveRecord::Base.establish_connection(@connection.merge({:allow_concurrency => true})) - end - - def connection_allow_concurrency_teardown - ActiveRecord::Base.clear_all_connections! - ActiveRecord::Base.establish_connection(@connection) - end - - def with_kcode(kcode) - if RUBY_VERSION < '1.9' - orig_kcode, $KCODE = $KCODE, kcode - begin - yield - ensure - $KCODE = orig_kcode - end - else - yield - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/timestamp.rb b/vendor/rails/activerecord/lib/active_record/timestamp.rb deleted file mode 100644 index d9e1ef35..00000000 --- a/vendor/rails/activerecord/lib/active_record/timestamp.rb +++ /dev/null @@ -1,71 +0,0 @@ -module ActiveRecord - # Active Record automatically timestamps create and update operations if the table has fields - # named created_at/created_on or updated_at/updated_on. - # - # Timestamping can be turned off by setting - # <tt>ActiveRecord::Base.record_timestamps = false</tt> - # - # Timestamps are in the local timezone by default but you can use UTC by setting - # <tt>ActiveRecord::Base.default_timezone = :utc</tt> - module Timestamp - def self.included(base) #:nodoc: - base.alias_method_chain :create, :timestamps - base.alias_method_chain :update, :timestamps - - base.class_inheritable_accessor :record_timestamps, :instance_writer => false - base.record_timestamps = true - end - - # Saves the record with the updated_at/on attributes set to the current time. - # If the save fails because of validation errors, an ActiveRecord::RecordInvalid exception is raised. - # If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes. - # - # Examples: - # - # product.touch # updates updated_at - # product.touch(:designed_at) # updates the designed_at attribute - def touch(attribute = nil) - current_time = current_time_from_proper_timezone - - if attribute - write_attribute(attribute, current_time) - else - write_attribute('updated_at', current_time) if respond_to?(:updated_at) - write_attribute('updated_on', current_time) if respond_to?(:updated_on) - end - - save! - end - - - private - def create_with_timestamps #:nodoc: - if record_timestamps - current_time = current_time_from_proper_timezone - - write_attribute('created_at', current_time) if respond_to?(:created_at) && created_at.nil? - write_attribute('created_on', current_time) if respond_to?(:created_on) && created_on.nil? - - write_attribute('updated_at', current_time) if respond_to?(:updated_at) && updated_at.nil? - write_attribute('updated_on', current_time) if respond_to?(:updated_on) && updated_on.nil? - end - - create_without_timestamps - end - - def update_with_timestamps(*args) #:nodoc: - if record_timestamps && (!partial_updates? || changed?) - current_time = current_time_from_proper_timezone - - write_attribute('updated_at', current_time) if respond_to?(:updated_at) - write_attribute('updated_on', current_time) if respond_to?(:updated_on) - end - - update_without_timestamps(*args) - end - - def current_time_from_proper_timezone - self.class.default_timezone == :utc ? Time.now.utc : Time.now - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/lib/active_record/transactions.rb b/vendor/rails/activerecord/lib/active_record/transactions.rb deleted file mode 100644 index 0b6e52c7..00000000 --- a/vendor/rails/activerecord/lib/active_record/transactions.rb +++ /dev/null @@ -1,235 +0,0 @@ -require 'thread' - -module ActiveRecord - # See ActiveRecord::Transactions::ClassMethods for documentation. - module Transactions - class TransactionError < ActiveRecordError # :nodoc: - end - - def self.included(base) - base.extend(ClassMethods) - - base.class_eval do - [:destroy, :save, :save!].each do |method| - alias_method_chain method, :transactions - end - end - end - - # Transactions are protective blocks where SQL statements are only permanent - # if they can all succeed as one atomic action. The classic example is a - # transfer between two accounts where you can only have a deposit if the - # withdrawal succeeded and vice versa. Transactions enforce the integrity of - # the database and guard the data against program errors or database - # break-downs. So basically you should use transaction blocks whenever you - # have a number of statements that must be executed together or not at all. - # Example: - # - # ActiveRecord::Base.transaction do - # david.withdrawal(100) - # mary.deposit(100) - # end - # - # This example will only take money from David and give to Mary if neither - # +withdrawal+ nor +deposit+ raises an exception. Exceptions will force a - # ROLLBACK that returns the database to the state before the transaction was - # begun. Be aware, though, that the objects will _not_ have their instance - # data returned to their pre-transactional state. - # - # == Different Active Record classes in a single transaction - # - # Though the transaction class method is called on some Active Record class, - # the objects within the transaction block need not all be instances of - # that class. This is because transactions are per-database connection, not - # per-model. - # - # In this example a <tt>Balance</tt> record is transactionally saved even - # though <tt>transaction</tt> is called on the <tt>Account</tt> class: - # - # Account.transaction do - # balance.save! - # account.save! - # end - # - # Note that the +transaction+ method is also available as a model instance - # method. For example, you can also do this: - # - # balance.transaction do - # balance.save! - # account.save! - # end - # - # == Transactions are not distributed across database connections - # - # A transaction acts on a single database connection. If you have - # multiple class-specific databases, the transaction will not protect - # interaction among them. One workaround is to begin a transaction - # on each class whose models you alter: - # - # Student.transaction do - # Course.transaction do - # course.enroll(student) - # student.units += course.units - # end - # end - # - # This is a poor solution, but full distributed transactions are beyond - # the scope of Active Record. - # - # == Save and destroy are automatically wrapped in a transaction - # - # Both Base#save and Base#destroy come wrapped in a transaction that ensures - # that whatever you do in validations or callbacks will happen under the - # protected cover of a transaction. So you can use validations to check for - # values that the transaction depends on or you can raise exceptions in the - # callbacks to rollback, including <tt>after_*</tt> callbacks. - # - # == Exception handling and rolling back - # - # Also have in mind that exceptions thrown within a transaction block will - # be propagated (after triggering the ROLLBACK), so you should be ready to - # catch those in your application code. - # - # One exception is the ActiveRecord::Rollback exception, which will trigger - # a ROLLBACK when raised, but not be re-raised by the transaction block. - # - # *Warning*: one should not catch ActiveRecord::StatementInvalid exceptions - # inside a transaction block. StatementInvalid exceptions indicate that an - # error occurred at the database level, for example when a unique constraint - # is violated. On some database systems, such as PostgreSQL, database errors - # inside a transaction causes the entire transaction to become unusable - # until it's restarted from the beginning. Here is an example which - # demonstrates the problem: - # - # # Suppose that we have a Number model with a unique column called 'i'. - # Number.transaction do - # Number.create(:i => 0) - # begin - # # This will raise a unique constraint error... - # Number.create(:i => 0) - # rescue ActiveRecord::StatementInvalid - # # ...which we ignore. - # end - # - # # On PostgreSQL, the transaction is now unusable. The following - # # statement will cause a PostgreSQL error, even though the unique - # # constraint is no longer violated: - # Number.create(:i => 1) - # # => "PGError: ERROR: current transaction is aborted, commands - # # ignored until end of transaction block" - # end - # - # One should restart the entire transaction if a StatementError occurred. - # - # == Nested transactions - # - # #transaction calls can be nested. By default, this makes all database - # statements in the nested transaction block become part of the parent - # transaction. For example: - # - # User.transaction do - # User.create(:username => 'Kotori') - # User.transaction do - # User.create(:username => 'Nemu') - # raise ActiveRecord::Rollback - # end - # end - # - # User.find(:all) # => empty - # - # It is also possible to requires a sub-transaction by passing - # <tt>:requires_new => true</tt>. If anything goes wrong, the - # database rolls back to the beginning of the sub-transaction - # without rolling back the parent transaction. For example: - # - # User.transaction do - # User.create(:username => 'Kotori') - # User.transaction(:requires_new => true) do - # User.create(:username => 'Nemu') - # raise ActiveRecord::Rollback - # end - # end - # - # User.find(:all) # => Returns only Kotori - # - # Most databases don't support true nested transactions. At the time of - # writing, the only database that we're aware of that supports true nested - # transactions, is MS-SQL. Because of this, Active Record emulates nested - # transactions by using savepoints. See - # http://dev.mysql.com/doc/refman/5.0/en/savepoints.html - # for more information about savepoints. - # - # === Caveats - # - # If you're on MySQL, then do not use DDL operations in nested transactions - # blocks that are emulated with savepoints. That is, do not execute statements - # like 'CREATE TABLE' inside such blocks. This is because MySQL automatically - # releases all savepoints upon executing a DDL operation. When #transaction - # is finished and tries to release the savepoint it created earlier, a - # database error will occur because the savepoint has already been - # automatically released. The following example demonstrates the problem: - # - # Model.connection.transaction do # BEGIN - # Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1 - # Model.connection.create_table(...) # active_record_1 now automatically released - # end # RELEASE savepoint active_record_1 - # # ^^^^ BOOM! database error! - # end - module ClassMethods - # See ActiveRecord::Transactions::ClassMethods for detailed documentation. - def transaction(options = {}, &block) - # See the ConnectionAdapters::DatabaseStatements#transaction API docs. - connection.transaction(options, &block) - end - end - - # See ActiveRecord::Transactions::ClassMethods for detailed documentation. - def transaction(&block) - self.class.transaction(&block) - end - - def destroy_with_transactions #:nodoc: - with_transaction_returning_status(:destroy_without_transactions) - end - - def save_with_transactions(perform_validation = true) #:nodoc: - rollback_active_record_state! { with_transaction_returning_status(:save_without_transactions, perform_validation) } - end - - def save_with_transactions! #:nodoc: - rollback_active_record_state! { self.class.transaction { save_without_transactions! } } - end - - # Reset id and @new_record if the transaction rolls back. - def rollback_active_record_state! - id_present = has_attribute?(self.class.primary_key) - previous_id = id - previous_new_record = new_record? - yield - rescue Exception - @new_record = previous_new_record - if id_present - self.id = previous_id - else - @attributes.delete(self.class.primary_key) - @attributes_cache.delete(self.class.primary_key) - end - raise - end - - # Executes +method+ within a transaction and captures its return value as a - # status flag. If the status is true the transaction is committed, otherwise - # a ROLLBACK is issued. In any case the status flag is returned. - # - # This method is available within the context of an ActiveRecord::Base - # instance. - def with_transaction_returning_status(method, *args) - status = nil - self.class.transaction do - status = send(method, *args) - raise ActiveRecord::Rollback unless status - end - status - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/validations.rb b/vendor/rails/activerecord/lib/active_record/validations.rb deleted file mode 100644 index 643f1e0c..00000000 --- a/vendor/rails/activerecord/lib/active_record/validations.rb +++ /dev/null @@ -1,1146 +0,0 @@ -module ActiveRecord - # Raised by <tt>save!</tt> and <tt>create!</tt> when the record is invalid. Use the - # +record+ method to retrieve the record which did not validate. - # begin - # complex_operation_that_calls_save!_internally - # rescue ActiveRecord::RecordInvalid => invalid - # puts invalid.record.errors - # end - class RecordInvalid < ActiveRecordError - attr_reader :record - def initialize(record) - @record = record - errors = @record.errors.full_messages.join(I18n.t('support.array.words_connector', :default => ', ')) - super(I18n.t('activerecord.errors.messages.record_invalid', :errors => errors)) - end - end - - class Error - attr_accessor :base, :attribute, :type, :message, :options - - def initialize(base, attribute, type = nil, options = {}) - self.base = base - self.attribute = attribute - self.type = type || :invalid - self.options = options - self.message = options.delete(:message) || self.type - end - - def message - # When type is a string, it means that we do not have to do a lookup, because - # the user already sent the "final" message. - type.is_a?(String) ? type : generate_message(default_options) - end - - def full_message - attribute.to_s == 'base' ? message : generate_full_message(default_options) - end - - alias :to_s :message - - def value - @base.respond_to?(attribute) ? @base.send(attribute) : nil - end - - protected - - # Translates an error message in it's default scope (<tt>activerecord.errrors.messages</tt>). - # Error messages are first looked up in <tt>models.MODEL.attributes.ATTRIBUTE.MESSAGE</tt>, if it's not there, - # it's looked up in <tt>models.MODEL.MESSAGE</tt> and if that is not there it returns the translation of the - # default message (e.g. <tt>activerecord.errors.messages.MESSAGE</tt>). The translated model name, - # translated attribute name and the value are available for interpolation. - # - # When using inheritence in your models, it will check all the inherited models too, but only if the model itself - # hasn't been found. Say you have <tt>class Admin < User; end</tt> and you wanted the translation for the <tt>:blank</tt> - # error +message+ for the <tt>title</tt> +attribute+, it looks for these translations: - # - # <ol> - # <li><tt>activerecord.errors.models.admin.attributes.title.blank</tt></li> - # <li><tt>activerecord.errors.models.admin.blank</tt></li> - # <li><tt>activerecord.errors.models.user.attributes.title.blank</tt></li> - # <li><tt>activerecord.errors.models.user.blank</tt></li> - # <li><tt>activerecord.errors.messages.blank</tt></li> - # <li>any default you provided through the +options+ hash (in the activerecord.errors scope)</li> - # </ol> - def generate_message(options = {}) - keys = @base.class.self_and_descendants_from_active_record.map do |klass| - [ :"models.#{klass.name.underscore}.attributes.#{attribute}.#{@message}", - :"models.#{klass.name.underscore}.#{@message}" ] - end.flatten - - keys << options.delete(:default) - keys << :"messages.#{@message}" - keys << @message if @message.is_a?(String) - keys << @type unless @type == @message - keys.compact! - - options.merge!(:default => keys) - I18n.translate(keys.shift, options) - end - - # Wraps an error message into a full_message format. - # - # The default full_message format for any locale is <tt>"%{attribute} %{message}"</tt>. - # One can specify locale specific default full_message format by storing it as a - # translation for the key <tt>:"activerecord.errors.full_messages.format"</tt>. - # - # Additionally one can specify a validation specific error message format by - # storing a translation for <tt>:"activerecord.errors.full_messages.[message_key]"</tt>. - # E.g. the full_message format for any validation that uses :blank as a message - # key (such as validates_presence_of) can be stored to <tt>:"activerecord.errors.full_messages.blank".</tt> - # - # Because the message key used by a validation can be overwritten on the - # <tt>validates_*</tt> class macro level one can customize the full_message format for - # any particular validation: - # - # # app/models/article.rb - # class Article < ActiveRecord::Base - # validates_presence_of :title, :message => :"title.blank" - # end - # - # # config/locales/en.yml - # en: - # activerecord: - # errors: - # full_messages: - # title: - # blank: This title is screwed! - def generate_full_message(options = {}) - keys = [ - :"full_messages.#{@message}", - :'full_messages.format', - '%{attribute} %{message}' - ] - - options.merge!(:default => keys, :message => self.message) - I18n.translate(keys.shift, options) - end - - # Return user options with default options. - # - def default_options - options.reverse_merge :scope => [:activerecord, :errors], - :model => @base.class.human_name, - :attribute => @base.class.human_attribute_name(attribute.to_s), - :value => value - end - end - - # Active Record validation is reported to and from this object, which is used by Base#save to - # determine whether the object is in a valid state to be saved. See usage example in Validations. - class Errors - include Enumerable - - class << self - def default_error_messages - ActiveSupport::Deprecation.warn("ActiveRecord::Errors.default_error_messages has been deprecated. Please use I18n.translate('activerecord.errors.messages').") - I18n.translate 'activerecord.errors.messages' - end - end - - def initialize(base) # :nodoc: - @base = base - clear - end - - # Adds an error to the base object instead of any particular attribute. This is used - # to report errors that don't tie to any specific attribute, but rather to the object - # as a whole. These error messages don't get prepended with any field name when iterating - # with +each_full+, so they should be complete sentences. - def add_to_base(msg) - add(:base, msg) - end - - # Adds an error message (+messsage+) to the +attribute+, which will be returned on a call to <tt>on(attribute)</tt> - # for the same attribute and ensure that this error object returns false when asked if <tt>empty?</tt>. More than one - # error can be added to the same +attribute+ in which case an array will be returned on a call to <tt>on(attribute)</tt>. - # If no +messsage+ is supplied, :invalid is assumed. - # If +message+ is a Symbol, it will be translated, using the appropriate scope (see translate_error). - # - def add(attribute, message = nil, options = {}) - options[:message] = options.delete(:default) if options[:default].is_a?(Symbol) - error, message = message, nil if message.is_a?(Error) - - @errors[attribute.to_s] ||= [] - @errors[attribute.to_s] << (error || Error.new(@base, attribute, message, options)) - end - - # Will add an error message to each of the attributes in +attributes+ that is empty. - def add_on_empty(attributes, custom_message = nil) - for attr in [attributes].flatten - value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s] - is_empty = value.respond_to?(:empty?) ? value.empty? : false - add(attr, :empty, :default => custom_message) unless !value.nil? && !is_empty - end - end - - # Will add an error message to each of the attributes in +attributes+ that is blank (using Object#blank?). - def add_on_blank(attributes, custom_message = nil) - for attr in [attributes].flatten - value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s] - add(attr, :blank, :default => custom_message) if value.blank? - end - end - - # Returns true if the specified +attribute+ has errors associated with it. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.invalid?(:name) # => true - # company.errors.invalid?(:address) # => false - def invalid?(attribute) - !@errors[attribute.to_s].nil? - end - - # Returns +nil+, if no errors are associated with the specified +attribute+. - # Returns the error message, if one error is associated with the specified +attribute+. - # Returns an array of error messages, if more than one error is associated with the specified +attribute+. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.on(:name) # => ["is too short (minimum is 5 characters)", "can't be blank"] - # company.errors.on(:email) # => "can't be blank" - # company.errors.on(:address) # => nil - def on(attribute) - attribute = attribute.to_s - return nil unless @errors.has_key?(attribute) - errors = @errors[attribute].map(&:to_s) - errors.size == 1 ? errors.first : errors - end - - alias :[] :on - - # Returns errors assigned to the base object through +add_to_base+ according to the normal rules of <tt>on(attribute)</tt>. - def on_base - on(:base) - end - - # Yields each attribute and associated message per error added. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.each{|attr,msg| puts "#{attr} - #{msg}" } - # # => name - is too short (minimum is 5 characters) - # # name - can't be blank - # # address - can't be blank - def each - @errors.each_key { |attr| @errors[attr].each { |error| yield attr, error.message } } - end - - # Yields each attribute and associated error per error added. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.each_error{|attr,err| puts "#{attr} - #{err.type}" } - # # => name - :too_short - # # name - :blank - # # address - :blank - def each_error - @errors.each_key { |attr| @errors[attr].each { |error| yield attr, error } } - end - - # Yields each full error message added. So <tt>Person.errors.add("first_name", "can't be empty")</tt> will be returned - # through iteration as "First name can't be empty". - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.each_full{|msg| puts msg } - # # => Name is too short (minimum is 5 characters) - # # Name can't be blank - # # Address can't be blank - def each_full - full_messages.each { |msg| yield msg } - end - - # Returns all the full error messages in an array. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.full_messages # => - # ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Address can't be blank"] - def full_messages(options = {}) - @errors.values.inject([]) do |full_messages, errors| - full_messages + errors.map { |error| error.full_message } - end - end - - # Returns true if no errors have been added. - def empty? - @errors.empty? - end - - # Removes all errors that have been added. - def clear - @errors = ActiveSupport::OrderedHash.new - end - - # Returns the total number of errors added. Two errors added to the same attribute will be counted as such. - def size - @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size } - end - - alias_method :count, :size - alias_method :length, :size - - # Returns an XML representation of this error object. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.to_xml - # # => <?xml version="1.0" encoding="UTF-8"?> - # # <errors> - # # <error>Name is too short (minimum is 5 characters)</error> - # # <error>Name can't be blank</error> - # # <error>Address can't be blank</error> - # # </errors> - def to_xml(options={}) - options[:root] ||= "errors" - options[:indent] ||= 2 - options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - - options[:builder].instruct! unless options.delete(:skip_instruct) - options[:builder].errors do |e| - full_messages.each { |msg| e.error(msg) } - end - end - - def generate_message(attribute, message = :invalid, options = {}) - Error.new(@base, attribute, message, options).to_s - end - end - - - # Please do have a look at ActiveRecord::Validations::ClassMethods for a higher level of validations. - # - # Active Records implement validation by overwriting Base#validate (or the variations, +validate_on_create+ and - # +validate_on_update+). Each of these methods can inspect the state of the object, which usually means ensuring - # that a number of attributes have a certain value (such as not empty, within a given range, matching a certain regular expression). - # - # Example: - # - # class Person < ActiveRecord::Base - # protected - # def validate - # errors.add_on_empty %w( first_name last_name ) - # errors.add("phone_number", "has invalid format") unless phone_number =~ /[0-9]*/ - # end - # - # def validate_on_create # is only run the first time a new object is saved - # unless valid_discount?(membership_discount) - # errors.add("membership_discount", "has expired") - # end - # end - # - # def validate_on_update - # errors.add_to_base("No changes have occurred") if unchanged_attributes? - # end - # end - # - # person = Person.new("first_name" => "David", "phone_number" => "what?") - # person.save # => false (and doesn't do the save) - # person.errors.empty? # => false - # person.errors.count # => 2 - # person.errors.on "last_name" # => "can't be empty" - # person.errors.on "phone_number" # => "has invalid format" - # person.errors.each_full { |msg| puts msg } - # # => "Last name can't be empty\n" + - # # "Phone number has invalid format" - # - # person.attributes = { "last_name" => "Heinemeier", "phone_number" => "555-555" } - # person.save # => true (and person is now saved in the database) - # - # An Errors object is automatically created for every Active Record. - module Validations - VALIDATIONS = %w( validate validate_on_create validate_on_update ) - - def self.included(base) # :nodoc: - base.extend ClassMethods - base.class_eval do - alias_method_chain :save, :validation - alias_method_chain :save!, :validation - end - - base.send :include, ActiveSupport::Callbacks - base.define_callbacks *VALIDATIONS - end - - # Active Record classes can implement validations in several ways. The highest level, easiest to read, - # and recommended approach is to use the declarative <tt>validates_..._of</tt> class methods (and - # +validates_associated+) documented below. These are sufficient for most model validations. - # - # Slightly lower level is +validates_each+. It provides some of the same options as the purely declarative - # validation methods, but like all the lower-level approaches it requires manually adding to the errors collection - # when the record is invalid. - # - # At a yet lower level, a model can use the class methods +validate+, +validate_on_create+ and +validate_on_update+ - # to add validation methods or blocks. These are ActiveSupport::Callbacks and follow the same rules of inheritance - # and chaining. - # - # The lowest level style is to define the instance methods +validate+, +validate_on_create+ and +validate_on_update+ - # as documented in ActiveRecord::Validations. - # - # == +validate+, +validate_on_create+ and +validate_on_update+ Class Methods - # - # Calls to these methods add a validation method or block to the class. Again, this approach is recommended - # only when the higher-level methods documented below (<tt>validates_..._of</tt> and +validates_associated+) are - # insufficient to handle the required validation. - # - # This can be done with a symbol pointing to a method: - # - # class Comment < ActiveRecord::Base - # validate :must_be_friends - # - # def must_be_friends - # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee) - # end - # end - # - # Or with a block which is passed the current record to be validated: - # - # class Comment < ActiveRecord::Base - # validate do |comment| - # comment.must_be_friends - # end - # - # def must_be_friends - # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee) - # end - # end - # - # This usage applies to +validate_on_create+ and +validate_on_update+ as well. - module ClassMethods - DEFAULT_VALIDATION_OPTIONS = { - :on => :save, - :allow_nil => false, - :allow_blank => false, - :message => nil - }.freeze - - ALL_RANGE_OPTIONS = [ :is, :within, :in, :minimum, :maximum ].freeze - ALL_NUMERICALITY_CHECKS = { :greater_than => '>', :greater_than_or_equal_to => '>=', - :equal_to => '==', :less_than => '<', :less_than_or_equal_to => '<=', - :odd => 'odd?', :even => 'even?' }.freeze - - # Validates each attribute against a block. - # - # class Person < ActiveRecord::Base - # validates_each :first_name, :last_name do |record, attr, value| - # record.errors.add attr, 'starts with z.' if value[0] == ?z - # end - # end - # - # Options: - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+. - # * <tt>:allow_blank</tt> - Skip validation if attribute is blank. - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_each(*attrs) - options = attrs.extract_options!.symbolize_keys - attrs = attrs.flatten - - # Declare the validation. - send(validation_method(options[:on] || :save), options) do |record| - attrs.each do |attr| - value = record.send(attr) - next if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank]) - yield record, attr, value - end - end - end - - # Encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example: - # - # Model: - # class Person < ActiveRecord::Base - # validates_confirmation_of :user_name, :password - # validates_confirmation_of :email_address, :message => "should match confirmation" - # end - # - # View: - # <%= password_field "person", "password" %> - # <%= password_field "person", "password_confirmation" %> - # - # The added +password_confirmation+ attribute is virtual; it exists only as an in-memory attribute for validating the password. - # To achieve this, the validation adds accessors to the model for the confirmation attribute. NOTE: This check is performed - # only if +password_confirmation+ is not +nil+, and by default only on save. To require confirmation, make sure to add a presence - # check for the confirmation attribute: - # - # validates_presence_of :password_confirmation, :if => :password_changed? - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "doesn't match confirmation"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_confirmation_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - attr_accessor(*(attr_names.map { |n| "#{n}_confirmation" })) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation") - record.errors.add(attr_name, :confirmation, :default => configuration[:message]) - end - end - end - - # Encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example: - # - # class Person < ActiveRecord::Base - # validates_acceptance_of :terms_of_service - # validates_acceptance_of :eula, :message => "must be abided" - # end - # - # If the database column does not exist, the +terms_of_service+ attribute is entirely virtual. This check is - # performed only if +terms_of_service+ is not +nil+ and by default on save. - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "must be accepted"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is true). - # * <tt>:accept</tt> - Specifies value that is considered accepted. The default value is a string "1", which - # makes it easy to relate to an HTML checkbox. This should be set to +true+ if you are validating a database - # column, since the attribute is typecast from "1" to +true+ before validation. - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_acceptance_of(*attr_names) - configuration = { :on => :save, :allow_nil => true, :accept => "1" } - configuration.update(attr_names.extract_options!) - - db_cols = begin - column_names - rescue Exception # To ignore both statement and connection errors - [] - end - names = attr_names.reject { |name| db_cols.include?(name.to_s) } - attr_accessor(*names) - - validates_each(attr_names,configuration) do |record, attr_name, value| - unless value == configuration[:accept] - record.errors.add(attr_name, :accepted, :default => configuration[:message]) - end - end - end - - # Validates that the specified attributes are not blank (as defined by Object#blank?). Happens by default on save. Example: - # - # class Person < ActiveRecord::Base - # validates_presence_of :first_name - # end - # - # The first_name attribute must be in the object and it cannot be blank. - # - # If you want to validate the presence of a boolean field (where the real values are true and false), - # you will want to use <tt>validates_inclusion_of :field_name, :in => [true, false]</tt>. - # - # This is due to the way Object#blank? handles boolean values: <tt>false.blank? # => true</tt>. - # - # Configuration options: - # * <tt>message</tt> - A custom error message (default is: "can't be blank"). - # * <tt>on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, - # <tt>:update</tt>). - # * <tt>if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). - # The method, proc or string should return or evaluate to a true or false value. - # * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). - # The method, proc or string should return or evaluate to a true or false value. - # - def validates_presence_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - # can't use validates_each here, because it cannot cope with nonexistent attributes, - # while errors.add_on_empty can - send(validation_method(configuration[:on]), configuration) do |record| - record.errors.add_on_blank(attr_names, configuration[:message]) - end - end - - # Validates that the specified attribute matches the length restrictions supplied. Only one option can be used at a time: - # - # class Person < ActiveRecord::Base - # validates_length_of :first_name, :maximum=>30 - # validates_length_of :last_name, :maximum=>30, :message=>"less than %{count} if you don't mind" - # validates_length_of :fax, :in => 7..32, :allow_nil => true - # validates_length_of :phone, :in => 7..32, :allow_blank => true - # validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name" - # validates_length_of :fav_bra_size, :minimum => 1, :too_short => "please enter at least %{count} character" - # validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with %{count} characters... don't play me." - # validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %{count} words."), :tokenizer => lambda {|str| str.scan(/\w+/) } - # end - # - # Configuration options: - # * <tt>:minimum</tt> - The minimum size of the attribute. - # * <tt>:maximum</tt> - The maximum size of the attribute. - # * <tt>:is</tt> - The exact size of the attribute. - # * <tt>:within</tt> - A range specifying the minimum and maximum size of the attribute. - # * <tt>:in</tt> - A synonym(or alias) for <tt>:within</tt>. - # * <tt>:allow_nil</tt> - Attribute may be +nil+; skip validation. - # * <tt>:allow_blank</tt> - Attribute may be blank; skip validation. - # * <tt>:too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is %{count} characters)"). - # * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is %{count} characters)"). - # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be %{count} characters)"). - # * <tt>:message</tt> - The error message to use for a <tt>:minimum</tt>, <tt>:maximum</tt>, or <tt>:is</tt> violation. An alias of the appropriate <tt>too_long</tt>/<tt>too_short</tt>/<tt>wrong_length</tt> message. - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:tokenizer</tt> - Specifies how to split up the attribute string. (e.g. <tt>:tokenizer => lambda {|str| str.scan(/\w+/)}</tt> to - # count words as in above example.) - # Defaults to <tt>lambda{ |value| value.split(//) }</tt> which counts individual characters. - def validates_length_of(*attrs) - # Merge given options with defaults. - options = { - :tokenizer => lambda {|value| value.split(//)} - }.merge(DEFAULT_VALIDATION_OPTIONS) - options.update(attrs.extract_options!.symbolize_keys) - - # Ensure that one and only one range option is specified. - range_options = ALL_RANGE_OPTIONS & options.keys - case range_options.size - when 0 - raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.' - when 1 - # Valid number of options; do nothing. - else - raise ArgumentError, 'Too many range options specified. Choose only one.' - end - - # Get range option and value. - option = range_options.first - option_value = options[range_options.first] - key = {:is => :wrong_length, :minimum => :too_short, :maximum => :too_long}[option] - custom_message = options[:message] || options[key] - - case option - when :within, :in - raise ArgumentError, ":#{option} must be a Range" unless option_value.is_a?(Range) - - validates_each(attrs, options) do |record, attr, value| - value = options[:tokenizer].call(value) if value.kind_of?(String) - if value.nil? or value.size < option_value.begin - record.errors.add(attr, :too_short, :default => custom_message || options[:too_short], :count => option_value.begin) - elsif value.size > option_value.end - record.errors.add(attr, :too_long, :default => custom_message || options[:too_long], :count => option_value.end) - end - end - when :is, :minimum, :maximum - raise ArgumentError, ":#{option} must be a nonnegative Integer" unless option_value.is_a?(Integer) and option_value >= 0 - - # Declare different validations per option. - validity_checks = { :is => "==", :minimum => ">=", :maximum => "<=" } - - validates_each(attrs, options) do |record, attr, value| - value = options[:tokenizer].call(value) if value.kind_of?(String) - unless !value.nil? and value.size.method(validity_checks[option])[option_value] - record.errors.add(attr, key, :default => custom_message, :count => option_value) - end - end - end - end - - alias_method :validates_size_of, :validates_length_of - - - # Validates whether the value of the specified attributes are unique across the system. Useful for making sure that only one user - # can be named "davidhh". - # - # class Person < ActiveRecord::Base - # validates_uniqueness_of :user_name, :scope => :account_id - # end - # - # It can also validate whether the value of the specified attributes are unique based on multiple scope parameters. For example, - # making sure that a teacher can only be on the schedule once per semester for a particular class. - # - # class TeacherSchedule < ActiveRecord::Base - # validates_uniqueness_of :teacher_id, :scope => [:semester_id, :class_id] - # end - # - # When the record is created, a check is performed to make sure that no record exists in the database with the given value for the specified - # attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. - # - # Configuration options: - # * <tt>:message</tt> - Specifies a custom error message (default is: "has already been taken"). - # * <tt>:scope</tt> - One or more columns by which to limit the scope of the uniqueness constraint. - # * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by non-text columns (+true+ by default). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # - # === Concurrency and integrity - # - # Using this validation method in conjunction with ActiveRecord::Base#save - # does not guarantee the absence of duplicate record insertions, because - # uniqueness checks on the application level are inherently prone to race - # conditions. For example, suppose that two users try to post a Comment at - # the same time, and a Comment's title must be unique. At the database-level, - # the actions performed by these users could be interleaved in the following manner: - # - # User 1 | User 2 - # ------------------------------------+-------------------------------------- - # # User 1 checks whether there's | - # # already a comment with the title | - # # 'My Post'. This is not the case. | - # SELECT * FROM comments | - # WHERE title = 'My Post' | - # | - # | # User 2 does the same thing and also - # | # infers that his title is unique. - # | SELECT * FROM comments - # | WHERE title = 'My Post' - # | - # # User 1 inserts his comment. | - # INSERT INTO comments | - # (title, content) VALUES | - # ('My Post', 'hi!') | - # | - # | # User 2 does the same thing. - # | INSERT INTO comments - # | (title, content) VALUES - # | ('My Post', 'hello!') - # | - # | # ^^^^^^ - # | # Boom! We now have a duplicate - # | # title! - # - # This could even happen if you use transactions with the 'serializable' - # isolation level. There are several ways to get around this problem: - # - By locking the database table before validating, and unlocking it after - # saving. However, table locking is very expensive, and thus not - # recommended. - # - By locking a lock file before validating, and unlocking it after saving. - # This does not work if you've scaled your Rails application across - # multiple web servers (because they cannot share lock files, or cannot - # do that efficiently), and thus not recommended. - # - Creating a unique index on the field, by using - # ActiveRecord::ConnectionAdapters::SchemaStatements#add_index. In the - # rare case that a race condition occurs, the database will guarantee - # the field's uniqueness. - # - # When the database catches such a duplicate insertion, - # ActiveRecord::Base#save will raise an ActiveRecord::StatementInvalid - # exception. You can either choose to let this error propagate (which - # will result in the default Rails exception page being shown), or you - # can catch it and restart the transaction (e.g. by telling the user - # that the title already exists, and asking him to re-enter the title). - # This technique is also known as optimistic concurrency control: - # http://en.wikipedia.org/wiki/Optimistic_concurrency_control - # - # Active Record currently provides no way to distinguish unique - # index constraint errors from other types of database errors, so you - # will have to parse the (database-specific) exception message to detect - # such a case. - def validates_uniqueness_of(*attr_names) - configuration = { :case_sensitive => true } - configuration.update(attr_names.extract_options!) - - validates_each(attr_names,configuration) do |record, attr_name, value| - # The check for an existing value should be run from a class that - # isn't abstract. This means working down from the current class - # (self), to the first non-abstract class. Since classes don't know - # their subclasses, we have to build the hierarchy between self and - # the record's class. - class_hierarchy = [record.class] - while class_hierarchy.first != self - class_hierarchy.insert(0, class_hierarchy.first.superclass) - end - - # Now we can work our way down the tree to the first non-abstract - # class (which has a database table to query from). - finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? } - - column = finder_class.columns_hash[attr_name.to_s] - - if value.nil? - comparison_operator = "IS ?" - elsif column.text? - comparison_operator = "#{connection.case_sensitive_equality_operator} ?" - value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s - else - comparison_operator = "= ?" - end - - sql_attribute = "#{record.class.quoted_table_name}.#{connection.quote_column_name(attr_name)}" - - if value.nil? || (configuration[:case_sensitive] || !column.text?) - condition_sql = "#{sql_attribute} #{comparison_operator}" - condition_params = [value] - else - condition_sql = "LOWER(#{sql_attribute}) #{comparison_operator}" - condition_params = [value.mb_chars.downcase] - end - - if scope = configuration[:scope] - Array(scope).map do |scope_item| - scope_value = record.send(scope_item) - condition_sql << " AND " << attribute_condition("#{record.class.quoted_table_name}.#{connection.quote_column_name(scope_item)}", scope_value) - condition_params << scope_value - end - end - - unless record.new_record? - condition_sql << " AND #{record.class.quoted_table_name}.#{record.class.primary_key} <> ?" - condition_params << record.send(:id) - end - - finder_class.with_exclusive_scope do - if finder_class.exists?([condition_sql, *condition_params]) - record.errors.add(attr_name, :taken, :default => configuration[:message], :value => value) - end - end - end - end - - - # Validates whether the value of the specified attribute is of the correct form by matching it against the regular expression - # provided. - # - # class Person < ActiveRecord::Base - # validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create - # end - # - # Note: use <tt>\A</tt> and <tt>\Z</tt> to match the start and end of the string, <tt>^</tt> and <tt>$</tt> match the start/end of a line. - # - # A regular expression must be provided or else an exception will be raised. - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "is invalid"). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:with</tt> - The regular expression used to validate the format with (note: must be supplied!). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_format_of(*attr_names) - configuration = { :on => :save, :with => nil } - configuration.update(attr_names.extract_options!) - - raise(ArgumentError, "A regular expression must be supplied as the :with option of the configuration hash") unless configuration[:with].is_a?(Regexp) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless value.to_s =~ configuration[:with] - record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value) - end - end - end - - # Validates whether the value of the specified attribute is available in a particular enumerable object. - # - # class Person < ActiveRecord::Base - # validates_inclusion_of :gender, :in => %w( m f ) - # validates_inclusion_of :age, :in => 0..99 - # validates_inclusion_of :format, :in => %w( jpg gif png ), :message => "extension %{value} is not included in the list" - # end - # - # Configuration options: - # * <tt>:in</tt> - An enumerable object of available items. - # * <tt>:message</tt> - Specifies a custom error message (default is: "is not included in the list"). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_inclusion_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - enum = configuration[:in] || configuration[:within] - - raise(ArgumentError, "An object with the method include? is required must be supplied as the :in option of the configuration hash") unless enum.respond_to?(:include?) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless enum.include?(value) - record.errors.add(attr_name, :inclusion, :default => configuration[:message], :value => value) - end - end - end - - # Validates that the value of the specified attribute is not in a particular enumerable object. - # - # class Person < ActiveRecord::Base - # validates_exclusion_of :username, :in => %w( admin superuser ), :message => "You don't belong here" - # validates_exclusion_of :age, :in => 30..60, :message => "This site is only for under 30 and over 60" - # validates_exclusion_of :format, :in => %w( mov avi ), :message => "extension %{value} is not allowed" - # end - # - # Configuration options: - # * <tt>:in</tt> - An enumerable object of items that the value shouldn't be part of. - # * <tt>:message</tt> - Specifies a custom error message (default is: "is reserved"). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_exclusion_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - enum = configuration[:in] || configuration[:within] - - raise(ArgumentError, "An object with the method include? is required must be supplied as the :in option of the configuration hash") unless enum.respond_to?(:include?) - - validates_each(attr_names, configuration) do |record, attr_name, value| - if enum.include?(value) - record.errors.add(attr_name, :exclusion, :default => configuration[:message], :value => value) - end - end - end - - # Validates whether the associated object or objects are all valid themselves. Works with any kind of association. - # - # class Book < ActiveRecord::Base - # has_many :pages - # belongs_to :library - # - # validates_associated :pages, :library - # end - # - # Warning: If, after the above definition, you then wrote: - # - # class Page < ActiveRecord::Base - # belongs_to :book - # - # validates_associated :book - # end - # - # this would specify a circular dependency and cause infinite recursion. - # - # NOTE: This validation will not fail if the association hasn't been assigned. If you want to ensure that the association - # is both present and guaranteed to be valid, you also need to use +validates_presence_of+. - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "is invalid") - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_associated(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless (value.is_a?(Array) ? value : [value]).collect { |r| r.nil? || r.valid? }.all? - record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value) - end - end - end - - # Validates whether the value of the specified attribute is numeric by trying to convert it to - # a float with Kernel.Float (if <tt>only_integer</tt> is false) or applying it to the regular expression - # <tt>/\A[\+\-]?\d+\Z/</tt> (if <tt>only_integer</tt> is set to true). - # - # class Person < ActiveRecord::Base - # validates_numericality_of :value, :on => :create - # end - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "is not a number"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:only_integer</tt> - Specifies whether the value has to be an integer, e.g. an integral value (default is +false+). - # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is +false+). Notice that for fixnum and float columns empty strings are converted to +nil+. - # * <tt>:greater_than</tt> - Specifies the value must be greater than the supplied value. - # * <tt>:greater_than_or_equal_to</tt> - Specifies the value must be greater than or equal the supplied value. - # * <tt>:equal_to</tt> - Specifies the value must be equal to the supplied value. - # * <tt>:less_than</tt> - Specifies the value must be less than the supplied value. - # * <tt>:less_than_or_equal_to</tt> - Specifies the value must be less than or equal the supplied value. - # * <tt>:odd</tt> - Specifies the value must be an odd number. - # * <tt>:even</tt> - Specifies the value must be an even number. - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_numericality_of(*attr_names) - configuration = { :on => :save, :only_integer => false, :allow_nil => false } - configuration.update(attr_names.extract_options!) - - - numericality_options = ALL_NUMERICALITY_CHECKS.keys & configuration.keys - - (numericality_options - [ :odd, :even ]).each do |option| - raise ArgumentError, ":#{option} must be a number" unless configuration[option].is_a?(Numeric) - end - - validates_each(attr_names,configuration) do |record, attr_name, value| - raw_value = record.send("#{attr_name}_before_type_cast") || value - - next if configuration[:allow_nil] and raw_value.nil? - - if configuration[:only_integer] - unless raw_value.to_s =~ /\A[+-]?\d+\Z/ - record.errors.add(attr_name, :not_a_number, :value => raw_value, :default => configuration[:message]) - next - end - raw_value = raw_value.to_i - else - begin - raw_value = Kernel.Float(raw_value) - rescue ArgumentError, TypeError - record.errors.add(attr_name, :not_a_number, :value => raw_value, :default => configuration[:message]) - next - end - end - - numericality_options.each do |option| - case option - when :odd, :even - unless raw_value.to_i.method(ALL_NUMERICALITY_CHECKS[option])[] - record.errors.add(attr_name, option, :value => raw_value, :default => configuration[:message]) - end - else - record.errors.add(attr_name, option, :default => configuration[:message], :value => raw_value, :count => configuration[option]) unless raw_value.method(ALL_NUMERICALITY_CHECKS[option])[configuration[option]] - end - end - end - end - - # Creates an object just like Base.create but calls save! instead of save - # so an exception is raised if the record is invalid. - def create!(attributes = nil, &block) - if attributes.is_a?(Array) - attributes.collect { |attr| create!(attr, &block) } - else - object = new(attributes) - yield(object) if block_given? - object.save! - object - end - end - - private - def validation_method(on) - case on - when :save then :validate - when :create then :validate_on_create - when :update then :validate_on_update - end - end - end - - # The validation process on save can be skipped by passing false. The regular Base#save method is - # replaced with this when the validations module is mixed in, which it is by default. - def save_with_validation(perform_validation = true) - if perform_validation && valid? || !perform_validation - save_without_validation - else - false - end - end - - # Attempts to save the record just like Base#save but will raise a RecordInvalid exception instead of returning false - # if the record is not valid. - def save_with_validation! - if valid? - save_without_validation! - else - raise RecordInvalid.new(self) - end - end - - # Runs +validate+ and +validate_on_create+ or +validate_on_update+ and returns true if no errors were added otherwise false. - def valid? - errors.clear - - run_callbacks(:validate) - validate - - if new_record? - run_callbacks(:validate_on_create) - validate_on_create - else - run_callbacks(:validate_on_update) - validate_on_update - end - - errors.empty? - end - - # Performs the opposite of <tt>valid?</tt>. Returns true if errors were added, false otherwise. - def invalid? - !valid? - end - - # Returns the Errors object that holds all information about attribute error messages. - def errors - @errors ||= Errors.new(self) - end - - protected - # Overwrite this method for validation checks on all saves and use <tt>Errors.add(field, msg)</tt> for invalid attributes. - def validate - end - - # Overwrite this method for validation checks used only on creation. - def validate_on_create - end - - # Overwrite this method for validation checks used only on updates. - def validate_on_update - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/version.rb b/vendor/rails/activerecord/lib/active_record/version.rb deleted file mode 100644 index d0291047..00000000 --- a/vendor/rails/activerecord/lib/active_record/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveRecord - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 14 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/activerecord/lib/activerecord.rb b/vendor/rails/activerecord/lib/activerecord.rb deleted file mode 100644 index bb6a0db2..00000000 --- a/vendor/rails/activerecord/lib/activerecord.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'active_record' -ActiveSupport::Deprecation.warn 'require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.' diff --git a/vendor/rails/activerecord/test/assets/example.log b/vendor/rails/activerecord/test/assets/example.log deleted file mode 100644 index f084369d..00000000 --- a/vendor/rails/activerecord/test/assets/example.log +++ /dev/null @@ -1 +0,0 @@ -# Logfile created on Wed Oct 31 16:05:13 +0000 2007 by logger.rb/1.5.2.9 diff --git a/vendor/rails/activerecord/test/assets/flowers.jpg b/vendor/rails/activerecord/test/assets/flowers.jpg deleted file mode 100644 index fe9df546..00000000 Binary files a/vendor/rails/activerecord/test/assets/flowers.jpg and /dev/null differ diff --git a/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb b/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb deleted file mode 100644 index 3911afac..00000000 --- a/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -# The filename begins with "aaa" to ensure this is the first test. -require "cases/helper" - -class AAACreateTablesTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def test_load_schema - eval(File.read(SCHEMA_ROOT + "/schema.rb")) - if File.exists?(adapter_specific_schema_file) - eval(File.read(adapter_specific_schema_file)) - end - assert true - end - - def test_drop_and_create_courses_table - eval(File.read(SCHEMA_ROOT + "/schema2.rb")) - assert true - end - - private - def adapter_specific_schema_file - SCHEMA_ROOT + '/' + ActiveRecord::Base.connection.adapter_name.downcase + '_specific_schema.rb' - end -end diff --git a/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb b/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb deleted file mode 100644 index 3526f49a..00000000 --- a/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb +++ /dev/null @@ -1,122 +0,0 @@ -require "cases/helper" - -class ActiveSchemaTest < ActiveRecord::TestCase - def setup - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - alias_method :execute_without_stub, :execute - def execute(sql, name = nil) return sql end - end - end - - def teardown - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - remove_method :execute - alias_method :execute, :execute_without_stub - end - end - - def test_add_index - # add_index calls index_exists? which can't work since execute is stubbed - ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:define_method, :index_exists?) do |*| - false - end - expected = "CREATE INDEX `index_people_on_last_name` ON `people` (`last_name`)" - assert_equal expected, add_index(:people, :last_name, :length => nil) - - expected = "CREATE INDEX `index_people_on_last_name` ON `people` (`last_name`(10))" - assert_equal expected, add_index(:people, :last_name, :length => 10) - - expected = "CREATE INDEX `index_people_on_last_name_and_first_name` ON `people` (`last_name`(15), `first_name`(15))" - assert_equal expected, add_index(:people, [:last_name, :first_name], :length => 15) - - expected = "CREATE INDEX `index_people_on_last_name_and_first_name` ON `people` (`last_name`(15), `first_name`)" - assert_equal expected, add_index(:people, [:last_name, :first_name], :length => {:last_name => 15}) - - expected = "CREATE INDEX `index_people_on_last_name_and_first_name` ON `people` (`last_name`(15), `first_name`(10))" - assert_equal expected, add_index(:people, [:last_name, :first_name], :length => {:last_name => 15, :first_name => 10}) - ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:remove_method, :index_exists?) - end - - def test_drop_table - assert_equal "DROP TABLE `people`", drop_table(:people) - end - - if current_adapter?(:MysqlAdapter) - def test_create_mysql_database_with_encoding - assert_equal "CREATE DATABASE `matt` DEFAULT CHARACTER SET `utf8`", create_database(:matt) - assert_equal "CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1`", create_database(:aimonetti, {:charset => 'latin1'}) - assert_equal "CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci`", create_database(:matt_aimonetti, {:charset => :big5, :collation => :big5_chinese_ci}) - end - - def test_recreate_mysql_database_with_encoding - create_database(:luca, {:charset => 'latin1'}) - assert_equal "CREATE DATABASE `luca` DEFAULT CHARACTER SET `latin1`", recreate_database(:luca, {:charset => 'latin1'}) - end - end - - def test_add_column - assert_equal "ALTER TABLE `people` ADD `last_name` varchar(255)", add_column(:people, :last_name, :string) - end - - def test_add_column_with_limit - assert_equal "ALTER TABLE `people` ADD `key` varchar(32)", add_column(:people, :key, :string, :limit => 32) - end - - def test_drop_table_with_specific_database - assert_equal "DROP TABLE `otherdb`.`people`", drop_table('otherdb.people') - end - - def test_add_timestamps - with_real_execute do - begin - ActiveRecord::Base.connection.create_table :delete_me do |t| - end - ActiveRecord::Base.connection.add_timestamps :delete_me - assert column_present?('delete_me', 'updated_at', 'datetime') - assert column_present?('delete_me', 'created_at', 'datetime') - ensure - ActiveRecord::Base.connection.drop_table :delete_me rescue nil - end - end - end - - def test_remove_timestamps - with_real_execute do - begin - ActiveRecord::Base.connection.create_table :delete_me do |t| - t.timestamps - end - ActiveRecord::Base.connection.remove_timestamps :delete_me - assert !column_present?('delete_me', 'updated_at', 'datetime') - assert !column_present?('delete_me', 'created_at', 'datetime') - ensure - ActiveRecord::Base.connection.drop_table :delete_me rescue nil - end - end - end - - private - def with_real_execute - #we need to actually modify some data, so we make execute point to the original method - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - alias_method :execute_with_stub, :execute - alias_method :execute, :execute_without_stub - end - yield - ensure - #before finishing, we restore the alias to the mock-up method - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - alias_method :execute, :execute_with_stub - end - end - - - def method_missing(method_symbol, *arguments) - ActiveRecord::Base.connection.send(method_symbol, *arguments) - end - - def column_present?(table_name, column_name, type) - results = ActiveRecord::Base.connection.select_all("SHOW FIELDS FROM #{table_name} LIKE '#{column_name}'") - results.first && results.first['Type'] == type - end -end diff --git a/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb b/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb deleted file mode 100644 index af80f724..00000000 --- a/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'cases/helper' - -class PostgresqlActiveSchemaTest < Test::Unit::TestCase - def setup - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do - alias_method :real_execute, :execute - def execute(sql, name = nil) sql end - end - end - - def teardown - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:alias_method, :execute, :real_execute) - end - - def test_create_database_with_encoding - assert_equal %(CREATE DATABASE "matt" ENCODING = 'utf8'), create_database(:matt) - assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'latin1'), create_database(:aimonetti, :encoding => :latin1) - end - - private - def method_missing(method_symbol, *arguments) - ActiveRecord::Base.connection.send(method_symbol, *arguments) - end -end diff --git a/vendor/rails/activerecord/test/cases/adapter_test.rb b/vendor/rails/activerecord/test/cases/adapter_test.rb deleted file mode 100644 index b7fa6dfd..00000000 --- a/vendor/rails/activerecord/test/cases/adapter_test.rb +++ /dev/null @@ -1,144 +0,0 @@ -require "cases/helper" - -class AdapterTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.connection - end - - def test_tables - tables = @connection.tables - assert tables.include?("accounts") - assert tables.include?("authors") - assert tables.include?("tasks") - assert tables.include?("topics") - end - - def test_table_exists? - assert @connection.table_exists?("accounts") - assert !@connection.table_exists?("nonexistingtable") - end - - def test_indexes - idx_name = "accounts_idx" - - if @connection.respond_to?(:indexes) - indexes = @connection.indexes("accounts") - assert indexes.empty? - - @connection.add_index :accounts, :firm_id, :name => idx_name - indexes = @connection.indexes("accounts") - assert_equal "accounts", indexes.first.table - # OpenBase does not have the concept of a named index - # Indexes are merely properties of columns. - assert_equal idx_name, indexes.first.name unless current_adapter?(:OpenBaseAdapter) - assert !indexes.first.unique - assert_equal ["firm_id"], indexes.first.columns - else - warn "#{@connection.class} does not respond to #indexes" - end - - ensure - @connection.remove_index(:accounts, :name => idx_name) rescue nil - end - - def test_current_database - if @connection.respond_to?(:current_database) - assert_equal ENV['ARUNIT_DB_NAME'] || "activerecord_unittest", @connection.current_database - end - end - - if current_adapter?(:MysqlAdapter) - def test_charset - assert_not_nil @connection.charset - assert_not_equal 'character_set_database', @connection.charset - assert_equal @connection.show_variable('character_set_database'), @connection.charset - end - - def test_collation - assert_not_nil @connection.collation - assert_not_equal 'collation_database', @connection.collation - assert_equal @connection.show_variable('collation_database'), @connection.collation - end - - def test_show_nonexistent_variable_returns_nil - assert_nil @connection.show_variable('foo_bar_baz') - end - - def test_not_specifying_database_name_for_cross_database_selects - begin - assert_nothing_raised do - ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['arunit'].except(:database)) - ActiveRecord::Base.connection.execute "SELECT activerecord_unittest.pirates.*, activerecord_unittest2.courses.* FROM activerecord_unittest.pirates, activerecord_unittest2.courses" - end - ensure - ActiveRecord::Base.establish_connection 'arunit' - end - end - end - - if current_adapter?(:PostgreSQLAdapter) - def test_encoding - assert_not_nil @connection.encoding - end - end - - def test_table_alias - def @connection.test_table_alias_length() 10; end - class << @connection - alias_method :old_table_alias_length, :table_alias_length - alias_method :table_alias_length, :test_table_alias_length - end - - assert_equal 'posts', @connection.table_alias_for('posts') - assert_equal 'posts_comm', @connection.table_alias_for('posts_comments') - assert_equal 'dbo_posts', @connection.table_alias_for('dbo.posts') - - class << @connection - remove_method :table_alias_length - alias_method :table_alias_length, :old_table_alias_length - end - end - - # test resetting sequences in odd tables in postgreSQL - if ActiveRecord::Base.connection.respond_to?(:reset_pk_sequence!) - require 'models/movie' - require 'models/subscriber' - - def test_reset_empty_table_with_custom_pk - Movie.delete_all - Movie.connection.reset_pk_sequence! 'movies' - assert_equal 1, Movie.create(:name => 'fight club').id - end - - if ActiveRecord::Base.connection.adapter_name != "FrontBase" - def test_reset_table_with_non_integer_pk - Subscriber.delete_all - Subscriber.connection.reset_pk_sequence! 'subscribers' - sub = Subscriber.new(:name => 'robert drake') - sub.id = 'bob drake' - assert_nothing_raised { sub.save! } - end - end - end - - def test_add_limit_offset_should_sanitize_sql_injection_for_limit_without_comas - sql_inject = "1 select * from schema" - assert_equal " LIMIT 1", @connection.add_limit_offset!("", :limit=>sql_inject) - if current_adapter?(:MysqlAdapter) - assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) - else - assert_equal " LIMIT 1 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) - end - end - - def test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas - sql_inject = "1, 7 procedure help()" - if current_adapter?(:MysqlAdapter) - assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject) - assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=> '1 ; DROP TABLE USERS', :offset=>7) - else - assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject) - assert_equal " LIMIT 1,7 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/aggregations_test.rb b/vendor/rails/activerecord/test/cases/aggregations_test.rb deleted file mode 100644 index 4e0e1c7f..00000000 --- a/vendor/rails/activerecord/test/cases/aggregations_test.rb +++ /dev/null @@ -1,167 +0,0 @@ -require "cases/helper" -require 'models/customer' - -class AggregationsTest < ActiveRecord::TestCase - fixtures :customers - - def test_find_single_value_object - assert_equal 50, customers(:david).balance.amount - assert_kind_of Money, customers(:david).balance - assert_equal 300, customers(:david).balance.exchange_to("DKK").amount - end - - def test_find_multiple_value_object - assert_equal customers(:david).address_street, customers(:david).address.street - assert( - customers(:david).address.close_to?(Address.new("Different Street", customers(:david).address_city, customers(:david).address_country)) - ) - end - - def test_change_single_value_object - customers(:david).balance = Money.new(100) - customers(:david).save - assert_equal 100, customers(:david).reload.balance.amount - end - - def test_immutable_value_objects - customers(:david).balance = Money.new(100) - assert_raise(ActiveSupport::FrozenObjectError) { customers(:david).balance.instance_eval { @amount = 20 } } - end - - def test_inferred_mapping - assert_equal "35.544623640962634", customers(:david).gps_location.latitude - assert_equal "-105.9309951055148", customers(:david).gps_location.longitude - - customers(:david).gps_location = GpsLocation.new("39x-110") - - assert_equal "39", customers(:david).gps_location.latitude - assert_equal "-110", customers(:david).gps_location.longitude - - customers(:david).save - - customers(:david).reload - - assert_equal "39", customers(:david).gps_location.latitude - assert_equal "-110", customers(:david).gps_location.longitude - end - - def test_reloaded_instance_refreshes_aggregations - assert_equal "35.544623640962634", customers(:david).gps_location.latitude - assert_equal "-105.9309951055148", customers(:david).gps_location.longitude - - Customer.update_all("gps_location = '24x113'") - customers(:david).reload - assert_equal '24x113', customers(:david)['gps_location'] - - assert_equal GpsLocation.new('24x113'), customers(:david).gps_location - end - - def test_gps_equality - assert GpsLocation.new('39x110') == GpsLocation.new('39x110') - end - - def test_gps_inequality - assert GpsLocation.new('39x110') != GpsLocation.new('39x111') - end - - def test_allow_nil_gps_is_nil - assert_equal nil, customers(:zaphod).gps_location - end - - def test_allow_nil_gps_set_to_nil - customers(:david).gps_location = nil - customers(:david).save - customers(:david).reload - assert_equal nil, customers(:david).gps_location - end - - def test_allow_nil_set_address_attributes_to_nil - customers(:zaphod).address = nil - assert_equal nil, customers(:zaphod).attributes[:address_street] - assert_equal nil, customers(:zaphod).attributes[:address_city] - assert_equal nil, customers(:zaphod).attributes[:address_country] - end - - def test_allow_nil_address_set_to_nil - customers(:zaphod).address = nil - customers(:zaphod).save - customers(:zaphod).reload - assert_equal nil, customers(:zaphod).address - end - - def test_nil_raises_error_when_allow_nil_is_false - assert_raise(NoMethodError) { customers(:david).balance = nil } - end - - def test_allow_nil_address_loaded_when_only_some_attributes_are_nil - customers(:zaphod).address_street = nil - customers(:zaphod).save - customers(:zaphod).reload - assert_kind_of Address, customers(:zaphod).address - assert customers(:zaphod).address.street.nil? - end - - def test_nil_assignment_results_in_nil - customers(:david).gps_location = GpsLocation.new('39x111') - assert_not_equal nil, customers(:david).gps_location - customers(:david).gps_location = nil - assert_equal nil, customers(:david).gps_location - end - - def test_custom_constructor - assert_equal 'Barney GUMBLE', customers(:barney).fullname.to_s - assert_kind_of Fullname, customers(:barney).fullname - end - - def test_custom_converter - customers(:barney).fullname = 'Barnoit Gumbleau' - assert_equal 'Barnoit GUMBLEAU', customers(:barney).fullname.to_s - assert_kind_of Fullname, customers(:barney).fullname - end -end - -class DeprecatedAggregationsTest < ActiveRecord::TestCase - class Person < ActiveRecord::Base; end - - def test_conversion_block_is_deprecated - assert_deprecated 'conversion block has been deprecated' do - Person.composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount)) { |balance| balance.to_money } - end - end - - def test_conversion_block_used_when_converter_option_is_nil - assert_deprecated 'conversion block has been deprecated' do - Person.composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount)) { |balance| balance.to_money } - end - assert_raise(NoMethodError) { Person.new.balance = 5 } - end - - def test_converter_option_overrides_conversion_block - assert_deprecated 'conversion block has been deprecated' do - Person.composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| Money.new(balance) }) { |balance| balance.to_money } - end - - person = Person.new - assert_nothing_raised { person.balance = 5 } - assert_equal 5, person.balance.amount - assert_kind_of Money, person.balance - end -end - -class OverridingAggregationsTest < ActiveRecord::TestCase - class Name; end - class DifferentName; end - - class Person < ActiveRecord::Base - composed_of :composed_of, :mapping => %w(person_first_name first_name) - end - - class DifferentPerson < Person - composed_of :composed_of, :class_name => 'DifferentName', :mapping => %w(different_person_first_name first_name) - end - - def test_composed_of_aggregation_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal Person.reflect_on_aggregation(:composed_of), - DifferentPerson.reflect_on_aggregation(:composed_of) - end -end diff --git a/vendor/rails/activerecord/test/cases/ar_schema_test.rb b/vendor/rails/activerecord/test/cases/ar_schema_test.rb deleted file mode 100644 index 4c1589d9..00000000 --- a/vendor/rails/activerecord/test/cases/ar_schema_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "cases/helper" - -if ActiveRecord::Base.connection.supports_migrations? - - class ActiveRecordSchemaTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @connection = ActiveRecord::Base.connection - end - - def teardown - @connection.drop_table :fruits rescue nil - end - - def test_schema_define - ActiveRecord::Schema.define(:version => 7) do - create_table :fruits do |t| - t.column :color, :string - t.column :fruit_size, :string # NOTE: "size" is reserved in Oracle - t.column :texture, :string - t.column :flavor, :string - end - end - - assert_nothing_raised { @connection.select_all "SELECT * FROM fruits" } - assert_nothing_raised { @connection.select_all "SELECT * FROM schema_migrations" } - assert_equal 7, ActiveRecord::Migrator::current_version - end - end - -end diff --git a/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb deleted file mode 100644 index ab0edee3..00000000 --- a/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ /dev/null @@ -1,438 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/computer' -require 'models/customer' -require 'models/order' -require 'models/post' -require 'models/author' -require 'models/tag' -require 'models/tagging' -require 'models/comment' -require 'models/sponsor' -require 'models/member' -require 'models/essay' - -class BelongsToAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :developers, :projects, :topics, - :developers_projects, :computers, :authors, :posts, :tags, :taggings, :comments - - def test_belongs_to - Client.find(3).firm.name - assert_equal companies(:first_firm).name, Client.find(3).firm.name - assert !Client.find(3).firm.nil?, "Microsoft should have a firm" - end - - def test_belongs_to_with_primary_key - client = Client.create(:name => "Primary key client", :firm_name => companies(:first_firm).name) - assert_equal companies(:first_firm).name, client.firm_with_primary_key.name - end - - def test_belongs_to_with_primary_key_joins_on_correct_column - sql = Client.send(:construct_finder_sql, :joins => :firm_with_primary_key) - assert sql !~ /\.id/ - assert sql =~ /\.name/ - end - - def test_proxy_assignment - account = Account.find(1) - assert_nothing_raised { account.firm = account.firm } - end - - def test_triple_equality - assert Client.find(3).firm === Firm - assert Firm === Client.find(3).firm - end - - def test_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { Account.find(1).firm = 1 } - assert_raise(ActiveRecord::AssociationTypeMismatch) { Account.find(1).firm = Project.find(1) } - end - - def test_natural_assignment - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - citibank.firm = apple - assert_equal apple.id, citibank.firm_id - end - - def test_natural_assignment_with_primary_key - apple = Firm.create("name" => "Apple") - citibank = Client.create("name" => "Primary key client") - citibank.firm_with_primary_key = apple - assert_equal apple.name, citibank.firm_name - end - - def test_eager_loading_with_primary_key - apple = Firm.create("name" => "Apple") - citibank = Client.create("name" => "Citibank", :firm_name => "Apple") - citibank_result = Client.find(:first, :conditions => {:name => "Citibank"}, :include => :firm_with_primary_key) - assert_not_nil citibank_result.instance_variable_get("@firm_with_primary_key") - end - - def test_no_unexpected_aliasing - first_firm = companies(:first_firm) - another_firm = companies(:another_firm) - - citibank = Account.create("credit_limit" => 10) - citibank.firm = first_firm - original_proxy = citibank.firm - citibank.firm = another_firm - - assert_equal first_firm.object_id, original_proxy.target.object_id - assert_equal another_firm.object_id, citibank.firm.target.object_id - end - - def test_creating_the_belonging_object - citibank = Account.create("credit_limit" => 10) - apple = citibank.create_firm("name" => "Apple") - assert_equal apple, citibank.firm - citibank.save - citibank.reload - assert_equal apple, citibank.firm - end - - def test_creating_the_belonging_object_with_primary_key - client = Client.create(:name => "Primary key client") - apple = client.create_firm_with_primary_key("name" => "Apple") - assert_equal apple, client.firm_with_primary_key - client.save - client.reload - assert_equal apple, client.firm_with_primary_key - end - - def test_building_the_belonging_object - citibank = Account.create("credit_limit" => 10) - apple = citibank.build_firm("name" => "Apple") - citibank.save - assert_equal apple.id, citibank.firm_id - end - - def test_building_the_belonging_object_with_primary_key - client = Client.create(:name => "Primary key client") - apple = client.build_firm_with_primary_key("name" => "Apple") - client.save - assert_equal apple.name, client.firm_name - end - - def test_natural_assignment_to_nil - client = Client.find(3) - client.firm = nil - client.save - assert_nil client.firm(true) - assert_nil client.client_of - end - - def test_natural_assignment_to_nil_with_primary_key - client = Client.create(:name => "Primary key client", :firm_name => companies(:first_firm).name) - client.firm_with_primary_key = nil - client.save - assert_nil client.firm_with_primary_key(true) - assert_nil client.client_of - end - - def test_with_different_class_name - assert_equal Company.find(1).name, Company.find(3).firm_with_other_name.name - assert_not_nil Company.find(3).firm_with_other_name, "Microsoft should have a firm" - end - - def test_with_condition - assert_equal Company.find(1).name, Company.find(3).firm_with_condition.name - assert_not_nil Company.find(3).firm_with_condition, "Microsoft should have a firm" - end - - def test_with_select - assert_equal Company.find(2).firm_with_select.attributes.size, 1 - assert_equal Company.find(2, :include => :firm_with_select ).firm_with_select.attributes.size, 1 - end - - def test_belongs_to_counter - debate = Topic.create("title" => "debate") - assert_equal 0, debate.send(:read_attribute, "replies_count"), "No replies yet" - - trash = debate.replies.create("title" => "blah!", "content" => "world around!") - assert_equal 1, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply created" - - trash.destroy - assert_equal 0, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply deleted" - end - - def test_belongs_to_with_primary_key_counter - debate = Topic.create("title" => "debate") - assert_equal 0, debate.send(:read_attribute, "replies_count"), "No replies yet" - - trash = debate.replies_with_primary_key.create("title" => "blah!", "content" => "world around!") - assert_equal 1, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply created" - - trash.destroy - assert_equal 0, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply deleted" - end - - def test_belongs_to_counter_with_assigning_nil - p = Post.find(1) - c = Comment.find(1) - - assert_equal p.id, c.post_id - assert_equal 2, Post.find(p.id).comments.size - - c.post = nil - - assert_equal 1, Post.find(p.id).comments.size - end - - def test_belongs_to_with_primary_key_counter_with_assigning_nil - debate = Topic.create("title" => "debate") - reply = Reply.create("title" => "blah!", "content" => "world around!", "parent_title" => "debate") - - assert_equal debate.title, reply.parent_title - assert_equal 1, Topic.find(debate.id).send(:read_attribute, "replies_count") - - reply.topic_with_primary_key = nil - - assert_equal 0, Topic.find(debate.id).send(:read_attribute, "replies_count") - end - - def test_belongs_to_counter_with_reassigning - t1 = Topic.create("title" => "t1") - t2 = Topic.create("title" => "t2") - r1 = Reply.new("title" => "r1", "content" => "r1") - r1.topic = t1 - - assert r1.save - assert_equal 1, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - - r1.topic = Topic.find(t2.id) - - assert r1.save - assert_equal 0, Topic.find(t1.id).replies.size - assert_equal 1, Topic.find(t2.id).replies.size - - r1.topic = nil - - assert_equal 0, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - - r1.topic = t1 - - assert_equal 1, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - - r1.destroy - - assert_equal 0, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - end - - def test_belongs_to_reassign_with_namespaced_models_and_counters - t1 = Web::Topic.create("title" => "t1") - t2 = Web::Topic.create("title" => "t2") - r1 = Web::Reply.new("title" => "r1", "content" => "r1") - r1.topic = t1 - - assert r1.save - assert_equal 1, Web::Topic.find(t1.id).replies.size - assert_equal 0, Web::Topic.find(t2.id).replies.size - - r1.topic = Web::Topic.find(t2.id) - - assert r1.save - assert_equal 0, Web::Topic.find(t1.id).replies.size - assert_equal 1, Web::Topic.find(t2.id).replies.size - end - - def test_belongs_to_counter_after_save - topic = Topic.create!(:title => "monday night") - topic.replies.create!(:title => "re: monday night", :content => "football") - assert_equal 1, Topic.find(topic.id)[:replies_count] - - topic.save! - assert_equal 1, Topic.find(topic.id)[:replies_count] - end - - def test_belongs_to_counter_after_update_attributes - topic = Topic.create!(:title => "37s") - topic.replies.create!(:title => "re: 37s", :content => "rails") - assert_equal 1, Topic.find(topic.id)[:replies_count] - - topic.update_attributes(:title => "37signals") - assert_equal 1, Topic.find(topic.id)[:replies_count] - end - - def test_assignment_before_child_saved - final_cut = Client.new("name" => "Final Cut") - firm = Firm.find(1) - final_cut.firm = firm - assert final_cut.new_record? - assert final_cut.save - assert !final_cut.new_record? - assert !firm.new_record? - assert_equal firm, final_cut.firm - assert_equal firm, final_cut.firm(true) - end - - def test_assignment_before_child_saved_with_primary_key - final_cut = Client.new("name" => "Final Cut") - firm = Firm.find(1) - final_cut.firm_with_primary_key = firm - assert final_cut.new_record? - assert final_cut.save - assert !final_cut.new_record? - assert !firm.new_record? - assert_equal firm, final_cut.firm_with_primary_key - assert_equal firm, final_cut.firm_with_primary_key(true) - end - - def test_new_record_with_foreign_key_but_no_object - c = Client.new("firm_id" => 1) - assert_equal Firm.find(:first), c.firm_with_basic_id - end - - def test_forgetting_the_load_when_foreign_key_enters_late - c = Client.new - assert_nil c.firm_with_basic_id - - c.firm_id = 1 - assert_equal Firm.find(:first), c.firm_with_basic_id - end - - def test_field_name_same_as_foreign_key - computer = Computer.find(1) - assert_not_nil computer.developer, ":foreign key == attribute didn't lock up" # ' - end - - def test_counter_cache - topic = Topic.create :title => "Zoom-zoom-zoom" - assert_equal 0, topic[:replies_count] - - reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") - reply.topic = topic - - assert_equal 1, topic.reload[:replies_count] - assert_equal 1, topic.replies.size - - topic[:replies_count] = 15 - assert_equal 15, topic.replies.size - end - - def test_custom_counter_cache - reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") - assert_equal 0, reply[:replies_count] - - silly = SillyReply.create(:title => "gaga", :content => "boo-boo") - silly.reply = reply - - assert_equal 1, reply.reload[:replies_count] - assert_equal 1, reply.replies.size - - reply[:replies_count] = 17 - assert_equal 17, reply.replies.size - end - - def test_association_assignment_sticks - post = Post.find(:first) - - author1, author2 = Author.find(:all, :limit => 2) - assert_not_nil author1 - assert_not_nil author2 - - # make sure the association is loaded - post.author - - # set the association by id, directly - post.author_id = author2.id - - # save and reload - post.save! - post.reload - - # the author id of the post should be the id we set - assert_equal post.author_id, author2.id - end - - def test_cant_save_readonly_association - assert_raise(ActiveRecord::ReadOnlyRecord) { companies(:first_client).readonly_firm.save! } - assert companies(:first_client).readonly_firm.readonly? - end - - def test_polymorphic_assignment_foreign_type_field_updating - # should update when assigning a saved record - sponsor = Sponsor.new - member = Member.create - sponsor.sponsorable = member - assert_equal "Member", sponsor.sponsorable_type - - # should update when assigning a new record - sponsor = Sponsor.new - member = Member.new - sponsor.sponsorable = member - assert_equal "Member", sponsor.sponsorable_type - end - - def test_polymorphic_assignment_with_primary_key_foreign_type_field_updating - # should update when assigning a saved record - essay = Essay.new - writer = Author.create(:name => "David") - essay.writer = writer - assert_equal "Author", essay.writer_type - - # should update when assigning a new record - essay = Essay.new - writer = Author.new - essay.writer = writer - assert_equal "Author", essay.writer_type - end - - def test_polymorphic_assignment_updates_foreign_id_field_for_new_and_saved_records - sponsor = Sponsor.new - saved_member = Member.create - new_member = Member.new - - sponsor.sponsorable = saved_member - assert_equal saved_member.id, sponsor.sponsorable_id - - sponsor.sponsorable = new_member - assert_equal nil, sponsor.sponsorable_id - end - - def test_polymorphic_assignment_with_primary_key_updates_foreign_id_field_for_new_and_saved_records - essay = Essay.new - saved_writer = Author.create(:name => "David") - new_writer = Author.new - - essay.writer = saved_writer - assert_equal saved_writer.name, essay.writer_id - - essay.writer = new_writer - assert_equal nil, essay.writer_id - end - - def test_belongs_to_proxy_should_not_respond_to_private_methods - assert_raise(NoMethodError) { companies(:first_firm).private_method } - assert_raise(NoMethodError) { companies(:second_client).firm.private_method } - end - - def test_belongs_to_proxy_should_respond_to_private_methods_via_send - companies(:first_firm).send(:private_method) - companies(:second_client).firm.send(:private_method) - end - - def test_save_of_record_with_loaded_belongs_to - @account = companies(:first_firm).account - - assert_nothing_raised do - Account.find(@account.id).save! - Account.find(@account.id, :include => :firm).save! - end - - @account.firm.delete - - assert_nothing_raised do - Account.find(@account.id).save! - Account.find(@account.id, :include => :firm).save! - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb b/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb deleted file mode 100644 index 91b1af12..00000000 --- a/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb +++ /dev/null @@ -1,161 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/project' -require 'models/developer' - -class AssociationCallbacksTest < ActiveRecord::TestCase - fixtures :posts, :authors, :projects, :developers - - def setup - @david = authors(:david) - @thinking = posts(:thinking) - @authorless = posts(:authorless) - assert @david.post_log.empty? - end - - def test_adding_macro_callbacks - @david.posts_with_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}"], @david.post_log - @david.posts_with_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}", "before_adding#{@thinking.id}", - "after_adding#{@thinking.id}"], @david.post_log - end - - def test_adding_with_proc_callbacks - @david.posts_with_proc_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}"], @david.post_log - @david.posts_with_proc_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}", "before_adding#{@thinking.id}", - "after_adding#{@thinking.id}"], @david.post_log - end - - def test_removing_with_macro_callbacks - first_post, second_post = @david.posts_with_callbacks[0, 2] - @david.posts_with_callbacks.delete(first_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}"], @david.post_log - @david.posts_with_callbacks.delete(second_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}", "before_removing#{second_post.id}", - "after_removing#{second_post.id}"], @david.post_log - end - - def test_removing_with_proc_callbacks - first_post, second_post = @david.posts_with_callbacks[0, 2] - @david.posts_with_proc_callbacks.delete(first_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}"], @david.post_log - @david.posts_with_proc_callbacks.delete(second_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}", "before_removing#{second_post.id}", - "after_removing#{second_post.id}"], @david.post_log - end - - def test_multiple_callbacks - @david.posts_with_multiple_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "before_adding_proc#{@thinking.id}", "after_adding#{@thinking.id}", - "after_adding_proc#{@thinking.id}"], @david.post_log - @david.posts_with_multiple_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "before_adding_proc#{@thinking.id}", "after_adding#{@thinking.id}", - "after_adding_proc#{@thinking.id}", "before_adding#{@thinking.id}", "before_adding_proc#{@thinking.id}", - "after_adding#{@thinking.id}", "after_adding_proc#{@thinking.id}"], @david.post_log - end - - def test_has_many_callbacks_with_create - morten = Author.create :name => "Morten" - post = morten.posts_with_proc_callbacks.create! :title => "Hello", :body => "How are you doing?" - assert_equal ["before_adding<new>", "after_adding#{post.id}"], morten.post_log - end - - def test_has_many_callbacks_with_create! - morten = Author.create! :name => "Morten" - post = morten.posts_with_proc_callbacks.create :title => "Hello", :body => "How are you doing?" - assert_equal ["before_adding<new>", "after_adding#{post.id}"], morten.post_log - end - - def test_has_many_callbacks_for_save_on_parent - jack = Author.new :name => "Jack" - post = jack.posts_with_callbacks.build :title => "Call me back!", :body => "Before you wake up and after you sleep" - - callback_log = ["before_adding<new>", "after_adding#{jack.posts_with_callbacks.first.id}"] - assert_equal callback_log, jack.post_log - assert jack.save - assert_equal 1, jack.posts_with_callbacks.count - assert_equal callback_log, jack.post_log - end - - def test_has_and_belongs_to_many_add_callback - david = developers(:david) - ar = projects(:active_record) - assert ar.developers_log.empty? - ar.developers_with_callbacks << david - assert_equal ["before_adding#{david.id}", "after_adding#{david.id}"], ar.developers_log - ar.developers_with_callbacks << david - assert_equal ["before_adding#{david.id}", "after_adding#{david.id}", "before_adding#{david.id}", - "after_adding#{david.id}"], ar.developers_log - end - - def test_has_and_belongs_to_many_after_add_called_after_save - ar = projects(:active_record) - assert ar.developers_log.empty? - alice = Developer.new(:name => 'alice') - ar.developers_with_callbacks << alice - assert_equal"after_adding#{alice.id}", ar.developers_log.last - - bob = ar.developers_with_callbacks.create(:name => 'bob') - assert_equal "after_adding#{bob.id}", ar.developers_log.last - - ar.developers_with_callbacks.build(:name => 'charlie') - assert_equal "after_adding<new>", ar.developers_log.last - end - - - def test_has_and_belongs_to_many_remove_callback - david = developers(:david) - jamis = developers(:jamis) - activerecord = projects(:active_record) - assert activerecord.developers_log.empty? - activerecord.developers_with_callbacks.delete(david) - assert_equal ["before_removing#{david.id}", "after_removing#{david.id}"], activerecord.developers_log - - activerecord.developers_with_callbacks.delete(jamis) - assert_equal ["before_removing#{david.id}", "after_removing#{david.id}", "before_removing#{jamis.id}", - "after_removing#{jamis.id}"], activerecord.developers_log - end - - def test_has_and_belongs_to_many_remove_callback_on_clear - activerecord = projects(:active_record) - assert activerecord.developers_log.empty? - if activerecord.developers_with_callbacks.size == 0 - activerecord.developers << developers(:david) - activerecord.developers << developers(:jamis) - activerecord.reload - assert activerecord.developers_with_callbacks.size == 2 - end - log_array = activerecord.developers_with_callbacks.collect {|d| ["before_removing#{d.id}","after_removing#{d.id}"]}.flatten.sort - assert activerecord.developers_with_callbacks.clear - assert_equal log_array, activerecord.developers_log.sort - end - - def test_has_many_and_belongs_to_many_callbacks_for_save_on_parent - project = Project.new :name => "Callbacks" - project.developers_with_callbacks.build :name => "Jack", :salary => 95000 - - callback_log = ["before_adding<new>", "after_adding<new>"] - assert_equal callback_log, project.developers_log - assert project.save - assert_equal 1, project.developers_with_callbacks.size - assert_equal callback_log, project.developers_log - end - - def test_dont_add_if_before_callback_raises_exception - assert !@david.unchangable_posts.include?(@authorless) - begin - @david.unchangable_posts << @authorless - rescue Exception => e - end - assert @david.post_log.empty? - assert !@david.unchangable_posts.include?(@authorless) - @david.reload - assert !@david.unchangable_posts.include?(@authorless) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb deleted file mode 100644 index 45e74ea0..00000000 --- a/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +++ /dev/null @@ -1,131 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/categorization' -require 'models/company' -require 'models/topic' -require 'models/reply' - -class CascadedEagerLoadingTest < ActiveRecord::TestCase - fixtures :authors, :mixins, :companies, :posts, :topics, :accounts, :comments, :categorizations - - def test_eager_association_loading_with_cascaded_two_levels - authors = Author.find(:all, :include=>{:posts=>:comments}, :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal 1, authors[1].posts.size - assert_equal 9, authors[0].posts.collect{|post| post.comments.size }.inject(0){|sum,i| sum+i} - end - - def test_eager_association_loading_with_cascaded_two_levels_and_one_level - authors = Author.find(:all, :include=>[{:posts=>:comments}, :categorizations], :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal 1, authors[1].posts.size - assert_equal 9, authors[0].posts.collect{|post| post.comments.size }.inject(0){|sum,i| sum+i} - assert_equal 1, authors[0].categorizations.size - assert_equal 2, authors[1].categorizations.size - end - - def test_eager_association_loading_with_cascaded_two_levels_with_two_has_many_associations - authors = Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}, :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal 1, authors[1].posts.size - assert_equal 9, authors[0].posts.collect{|post| post.comments.size }.inject(0){|sum,i| sum+i} - end - - def test_eager_association_loading_with_cascaded_two_levels_and_self_table_reference - authors = Author.find(:all, :include=>{:posts=>[:comments, :author]}, :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal authors(:david).name, authors[0].name - assert_equal [authors(:david).name], authors[0].posts.collect{|post| post.author.name}.uniq - end - - def test_eager_association_loading_with_cascaded_two_levels_with_condition - authors = Author.find(:all, :include=>{:posts=>:comments}, :conditions=>"authors.id=1", :order=>"authors.id") - assert_equal 1, authors.size - assert_equal 5, authors[0].posts.size - end - - def test_eager_association_loading_with_cascaded_three_levels_by_ping_pong - firms = Firm.find(:all, :include=>{:account=>{:firm=>:account}}, :order=>"companies.id") - assert_equal 2, firms.size - assert_equal firms.first.account, firms.first.account.firm.account - assert_equal companies(:first_firm).account, assert_no_queries { firms.first.account.firm.account } - assert_equal companies(:first_firm).account.firm.account, assert_no_queries { firms.first.account.firm.account } - end - - def test_eager_association_loading_with_has_many_sti - topics = Topic.find(:all, :include => :replies, :order => 'topics.id') - first, second, = topics(:first).replies.size, topics(:second).replies.size - assert_no_queries do - assert_equal first, topics[0].replies.size - assert_equal second, topics[1].replies.size - end - end - - def test_eager_association_loading_with_has_many_sti_and_subclasses - silly = SillyReply.new(:title => "gaga", :content => "boo-boo", :parent_id => 1) - silly.parent_id = 1 - assert silly.save - - topics = Topic.find(:all, :include => :replies, :order => 'topics.id, replies_topics.id') - assert_no_queries do - assert_equal 2, topics[0].replies.size - assert_equal 0, topics[1].replies.size - end - end - - def test_eager_association_loading_with_belongs_to_sti - replies = Reply.find(:all, :include => :topic, :order => 'topics.id') - assert replies.include?(topics(:second)) - assert !replies.include?(topics(:first)) - assert_equal topics(:first), assert_no_queries { replies.first.topic } - end - - def test_eager_association_loading_with_multiple_stis_and_order - author = Author.find(:first, :include => { :posts => [ :special_comments , :very_special_comment ] }, :order => 'authors.name, comments.body, very_special_comments_posts.body', :conditions => 'posts.id = 4') - assert_equal authors(:david), author - assert_no_queries do - author.posts.first.special_comments - author.posts.first.very_special_comment - end - end - - def test_eager_association_loading_of_stis_with_multiple_references - authors = Author.find(:all, :include => { :posts => { :special_comments => { :post => [ :special_comments, :very_special_comment ] } } }, :order => 'comments.body, very_special_comments_posts.body', :conditions => 'posts.id = 4') - assert_equal [authors(:david)], authors - assert_no_queries do - authors.first.posts.first.special_comments.first.post.special_comments - authors.first.posts.first.special_comments.first.post.very_special_comment - end - end - - def test_eager_association_loading_where_first_level_returns_nil - authors = Author.find(:all, :include => {:post_about_thinking => :comments}, :order => 'authors.id DESC') - assert_equal [authors(:mary), authors(:david)], authors - assert_no_queries do - authors[1].post_about_thinking.comments.first - end - end -end - -require 'models/vertex' -require 'models/edge' -class CascadedEagerLoadingTest < ActiveRecord::TestCase - fixtures :edges, :vertices - - def test_eager_association_loading_with_recursive_cascading_four_levels_has_many_through - source = Vertex.find(:first, :include=>{:sinks=>{:sinks=>{:sinks=>:sinks}}}, :order => 'vertices.id') - assert_equal vertices(:vertex_4), assert_no_queries { source.sinks.first.sinks.first.sinks.first } - end - - def test_eager_association_loading_with_recursive_cascading_four_levels_has_and_belongs_to_many - sink = Vertex.find(:first, :include=>{:sources=>{:sources=>{:sources=>:sources}}}, :order => 'vertices.id DESC') - assert_equal vertices(:vertex_1), assert_no_queries { sink.sources.first.sources.first.sources.first.sources.first } - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb deleted file mode 100644 index 7c470616..00000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'cases/helper' -require 'models/post' -require 'models/tagging' - -module Namespaced - class Post < ActiveRecord::Base - set_table_name 'posts' - has_one :tagging, :as => :taggable, :class_name => 'Tagging' - end -end - -class EagerLoadIncludeFullStiClassNamesTest < ActiveRecord::TestCase - - def setup - generate_test_objects - end - - def generate_test_objects - post = Namespaced::Post.create( :title => 'Great stuff', :body => 'This is not', :author_id => 1 ) - tagging = Tagging.create( :taggable => post ) - end - - def test_class_names - old = ActiveRecord::Base.store_full_sti_class - - ActiveRecord::Base.store_full_sti_class = false - post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging ) - assert_nil post.tagging - - ActiveRecord::Base.store_full_sti_class = true - post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging ) - assert_equal 'Tagging', post.tagging.class.name - ensure - ActiveRecord::Base.store_full_sti_class = old - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb deleted file mode 100644 index 420011d6..00000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'cases/helper' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/category' -require 'models/categorization' -require 'active_support/core_ext/array/random_access' - -module Remembered - def self.included(base) - base.extend ClassMethods - base.class_eval do - after_create :remember - protected - def remember; self.class.remembered << self; end - end - end - - module ClassMethods - def remembered; @@remembered ||= []; end - def sample; @@remembered.sample; end - end -end - -class ShapeExpression < ActiveRecord::Base - belongs_to :shape, :polymorphic => true - belongs_to :paint, :polymorphic => true -end - -class Circle < ActiveRecord::Base - has_many :shape_expressions, :as => :shape - include Remembered -end -class Square < ActiveRecord::Base - has_many :shape_expressions, :as => :shape - include Remembered -end -class Triangle < ActiveRecord::Base - has_many :shape_expressions, :as => :shape - include Remembered -end -class PaintColor < ActiveRecord::Base - has_many :shape_expressions, :as => :paint - belongs_to :non_poly, :foreign_key => "non_poly_one_id", :class_name => "NonPolyOne" - include Remembered -end -class PaintTexture < ActiveRecord::Base - has_many :shape_expressions, :as => :paint - belongs_to :non_poly, :foreign_key => "non_poly_two_id", :class_name => "NonPolyTwo" - include Remembered -end -class NonPolyOne < ActiveRecord::Base - has_many :paint_colors - include Remembered -end -class NonPolyTwo < ActiveRecord::Base - has_many :paint_textures - include Remembered -end - - - -class EagerLoadPolyAssocsTest < ActiveRecord::TestCase - NUM_SIMPLE_OBJS = 50 - NUM_SHAPE_EXPRESSIONS = 100 - - def setup - generate_test_object_graphs - end - - def teardown - [Circle, Square, Triangle, PaintColor, PaintTexture, - ShapeExpression, NonPolyOne, NonPolyTwo].each do |c| - c.delete_all - end - - end - - - def generate_test_object_graphs - 1.upto(NUM_SIMPLE_OBJS) do - [Circle, Square, Triangle, NonPolyOne, NonPolyTwo].map(&:create!) - end - 1.upto(NUM_SIMPLE_OBJS) do - PaintColor.create!(:non_poly_one_id => NonPolyOne.sample.id) - PaintTexture.create!(:non_poly_two_id => NonPolyTwo.sample.id) - end - 1.upto(NUM_SHAPE_EXPRESSIONS) do - shape_type = [Circle, Square, Triangle].sample - paint_type = [PaintColor, PaintTexture].sample - ShapeExpression.create!(:shape_type => shape_type.to_s, :shape_id => shape_type.sample.id, - :paint_type => paint_type.to_s, :paint_id => paint_type.sample.id) - end - end - - def test_include_query - res = 0 - res = ShapeExpression.find :all, :include => [ :shape, { :paint => :non_poly } ] - assert_equal NUM_SHAPE_EXPRESSIONS, res.size - assert_queries(0) do - res.each do |se| - assert_not_nil se.paint.non_poly, "this is the association that was loading incorrectly before the change" - assert_not_nil se.shape, "just making sure other associations still work" - end - end - end -end - -class EagerLoadNestedIncludeWithMissingDataTest < ActiveRecord::TestCase - def setup - @davey_mcdave = Author.create(:name => 'Davey McDave') - @first_post = @davey_mcdave.posts.create(:title => 'Davey Speaks', :body => 'Expressive wordage') - @first_comment = @first_post.comments.create(:body => 'Inflamatory doublespeak') - @first_categorization = @davey_mcdave.categorizations.create(:category => Category.first, :post => @first_post) - end - - def teardown - @davey_mcdave.destroy - @first_post.destroy - @first_comment.destroy - @first_categorization.destroy - end - - def test_missing_data_in_a_nested_include_should_not_cause_errors_when_constructing_objects - assert_nothing_raised do - # @davey_mcdave doesn't have any author_favorites - includes = {:posts => :comments, :categorizations => :category, :author_favorites => :favorite_author } - Author.all :include => includes, :conditions => {:authors => {:name => @davey_mcdave.name}}, :order => 'categories.name' - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_load_nested_polymorphic_include.rb b/vendor/rails/activerecord/test/cases/associations/eager_load_nested_polymorphic_include.rb deleted file mode 100644 index 3b8efe99..00000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_load_nested_polymorphic_include.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'cases/helper' -require 'models/tee' -require 'models/tie' -require 'models/polymorphic_design' -require 'models/polymorphic_price' - -class EagerLoadNestedPolymorphicIncludeTest < ActiveRecord::TestCase - fixtures :tees, :ties, :polymorphic_designs, :polymorphic_prices - - def test_eager_load_polymorphic_has_one_nested_under_polymorphic_belongs_to - designs = PolymorphicDesign.scoped(:include => {:designable => :polymorphic_price}) - - associated_price_ids = designs.map{|design| design.designable.polymorphic_price.id} - expected_price_ids = [1, 2, 3, 4] - - assert expected_price_ids.all?{|expected_id| associated_price_ids.include?(expected_id)}, - "Expected associated prices to be #{expected_price_ids.inspect} but they were #{associated_price_ids.sort.inspect}" - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb deleted file mode 100644 index 07d0b246..00000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb +++ /dev/null @@ -1,145 +0,0 @@ -require "cases/helper" - -class Virus < ActiveRecord::Base - belongs_to :octopus -end -class Octopus < ActiveRecord::Base - has_one :virus -end -class Pass < ActiveRecord::Base - belongs_to :bus -end -class Bus < ActiveRecord::Base - has_many :passes -end -class Mess < ActiveRecord::Base - has_and_belongs_to_many :crises -end -class Crisis < ActiveRecord::Base - has_and_belongs_to_many :messes - has_many :analyses, :dependent => :destroy - has_many :successes, :through => :analyses - has_many :dresses, :dependent => :destroy - has_many :compresses, :through => :dresses -end -class Analysis < ActiveRecord::Base - belongs_to :crisis - belongs_to :success -end -class Success < ActiveRecord::Base - has_many :analyses, :dependent => :destroy - has_many :crises, :through => :analyses -end -class Dress < ActiveRecord::Base - belongs_to :crisis - has_many :compresses -end -class Compress < ActiveRecord::Base - belongs_to :dress -end - - -class EagerSingularizationTest < ActiveRecord::TestCase - - def setup - if ActiveRecord::Base.connection.supports_migrations? - ActiveRecord::Base.connection.create_table :viri do |t| - t.column :octopus_id, :integer - t.column :species, :string - end - ActiveRecord::Base.connection.create_table :octopi do |t| - t.column :species, :string - end - ActiveRecord::Base.connection.create_table :passes do |t| - t.column :bus_id, :integer - t.column :rides, :integer - end - ActiveRecord::Base.connection.create_table :buses do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :crises_messes, :id => false do |t| - t.column :crisis_id, :integer - t.column :mess_id, :integer - end - ActiveRecord::Base.connection.create_table :messes do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :crises do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :successes do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :analyses do |t| - t.column :crisis_id, :integer - t.column :success_id, :integer - end - ActiveRecord::Base.connection.create_table :dresses do |t| - t.column :crisis_id, :integer - end - ActiveRecord::Base.connection.create_table :compresses do |t| - t.column :dress_id, :integer - end - @have_tables = true - else - @have_tables = false - end - end - - def teardown - ActiveRecord::Base.connection.drop_table :viri - ActiveRecord::Base.connection.drop_table :octopi - ActiveRecord::Base.connection.drop_table :passes - ActiveRecord::Base.connection.drop_table :buses - ActiveRecord::Base.connection.drop_table :crises_messes - ActiveRecord::Base.connection.drop_table :messes - ActiveRecord::Base.connection.drop_table :crises - ActiveRecord::Base.connection.drop_table :successes - ActiveRecord::Base.connection.drop_table :analyses - ActiveRecord::Base.connection.drop_table :dresses - ActiveRecord::Base.connection.drop_table :compresses - end - - def test_eager_no_extra_singularization_belongs_to - return unless @have_tables - assert_nothing_raised do - Virus.find(:all, :include => :octopus) - end - end - - def test_eager_no_extra_singularization_has_one - return unless @have_tables - assert_nothing_raised do - Octopus.find(:all, :include => :virus) - end - end - - def test_eager_no_extra_singularization_has_many - return unless @have_tables - assert_nothing_raised do - Bus.find(:all, :include => :passes) - end - end - - def test_eager_no_extra_singularization_has_and_belongs_to_many - return unless @have_tables - assert_nothing_raised do - Crisis.find(:all, :include => :messes) - Mess.find(:all, :include => :crises) - end - end - - def test_eager_no_extra_singularization_has_many_through_belongs_to - return unless @have_tables - assert_nothing_raised do - Crisis.find(:all, :include => :successes) - end - end - - def test_eager_no_extra_singularization_has_many_through_has_many - return unless @have_tables - assert_nothing_raised do - Crisis.find(:all, :include => :compresses) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_test.rb deleted file mode 100644 index b7117193..00000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_test.rb +++ /dev/null @@ -1,852 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/tagging' -require 'models/tag' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/company' -require 'models/person' -require 'models/reader' -require 'models/owner' -require 'models/pet' -require 'models/reference' -require 'models/job' -require 'models/subscriber' -require 'models/subscription' -require 'models/book' -require 'models/developer' -require 'models/project' - -class EagerAssociationTest < ActiveRecord::TestCase - fixtures :posts, :comments, :authors, :author_addresses, :categories, :categories_posts, - :companies, :accounts, :tags, :taggings, :people, :readers, - :owners, :pets, :author_favorites, :jobs, :references, :subscribers, :subscriptions, :books, - :developers, :projects, :developers_projects - - def test_loading_with_one_association - posts = Post.find(:all, :include => :comments) - post = posts.find { |p| p.id == 1 } - assert_equal 2, post.comments.size - assert post.comments.include?(comments(:greetings)) - - post = Post.find(:first, :include => :comments, :conditions => "posts.title = 'Welcome to the weblog'") - assert_equal 2, post.comments.size - assert post.comments.include?(comments(:greetings)) - - posts = Post.find(:all, :include => :last_comment) - post = posts.find { |p| p.id == 1 } - assert_equal Post.find(1).last_comment, post.last_comment - end - - def test_loading_with_one_association_with_non_preload - posts = Post.find(:all, :include => :last_comment, :order => 'comments.id DESC') - post = posts.find { |p| p.id == 1 } - assert_equal Post.find(1).last_comment, post.last_comment - end - - def test_loading_conditions_with_or - posts = authors(:david).posts.find(:all, :include => :comments, :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE} = 'SpecialComment'") - assert_nil posts.detect { |p| p.author_id != authors(:david).id }, - "expected to find only david's posts" - end - - def test_with_ordering - list = Post.find(:all, :include => :comments, :order => "posts.id DESC") - [:eager_other, :sti_habtm, :sti_post_and_comments, :sti_comments, - :authorless, :thinking, :welcome - ].each_with_index do |post, index| - assert_equal posts(post), list[index] - end - end - - def test_with_two_tables_in_from_without_getting_double_quoted - posts = Post.find(:all, - :select => "posts.*", - :from => "authors, posts", - :include => :comments, - :conditions => "posts.author_id = authors.id", - :order => "posts.id" - ) - - assert_equal 2, posts.first.comments.size - end - - def test_loading_with_multiple_associations - posts = Post.find(:all, :include => [ :comments, :author, :categories ], :order => "posts.id") - assert_equal 2, posts.first.comments.size - assert_equal 2, posts.first.categories.size - assert posts.first.comments.include?(comments(:greetings)) - end - - def test_duplicate_middle_objects - comments = Comment.find :all, :conditions => 'post_id = 1', :include => [:post => :author] - assert_no_queries do - comments.each {|comment| comment.post.author.name} - end - end - - def test_including_duplicate_objects_from_belongs_to - popular_post = Post.create!(:title => 'foo', :body => "I like cars!") - comment = popular_post.comments.create!(:body => "lol") - popular_post.readers.create!(:person => people(:michael)) - popular_post.readers.create!(:person => people(:david)) - - readers = Reader.find(:all, :conditions => ["post_id = ?", popular_post.id], - :include => {:post => :comments}) - readers.each do |reader| - assert_equal [comment], reader.post.comments - end - end - - def test_including_duplicate_objects_from_has_many - car_post = Post.create!(:title => 'foo', :body => "I like cars!") - car_post.categories << categories(:general) - car_post.categories << categories(:technology) - - comment = car_post.comments.create!(:body => "hmm") - categories = Category.find(:all, :conditions => ["posts.id=?", car_post.id], - :include => {:posts => :comments}) - categories.each do |category| - assert_equal [comment], category.posts[0].comments - end - end - - def test_finding_with_includes_on_has_many_association_with_same_include_includes_only_once - author_id = authors(:david).id - author = assert_queries(3) { Author.find(author_id, :include => {:posts_with_comments => :comments}) } # find the author, then find the posts, then find the comments - author.posts_with_comments.each do |post_with_comments| - assert_equal post_with_comments.comments.length, post_with_comments.comments.count - assert_equal nil, post_with_comments.comments.uniq! - end - end - - def test_finding_with_includes_on_has_one_assocation_with_same_include_includes_only_once - author = authors(:david) - post = author.post_about_thinking_with_last_comment - last_comment = post.last_comment - author = assert_queries(3) { Author.find(author.id, :include => {:post_about_thinking_with_last_comment => :last_comment})} # find the author, then find the posts, then find the comments - assert_no_queries do - assert_equal post, author.post_about_thinking_with_last_comment - assert_equal last_comment, author.post_about_thinking_with_last_comment.last_comment - end - end - - def test_finding_with_includes_on_belongs_to_association_with_same_include_includes_only_once - post = posts(:welcome) - author = post.author - author_address = author.author_address - post = assert_queries(3) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author, then find the address - assert_no_queries do - assert_equal author, post.author_with_address - assert_equal author_address, post.author_with_address.author_address - end - end - - def test_finding_with_includes_on_null_belongs_to_association_with_same_include_includes_only_once - post = posts(:welcome) - post.update_attributes!(:author => nil) - post = assert_queries(1) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author which is null so no query for the author or address - assert_no_queries do - assert_equal nil, post.author_with_address - end - end - - def test_loading_from_an_association - posts = authors(:david).posts.find(:all, :include => :comments, :order => "posts.id") - assert_equal 2, posts.first.comments.size - end - - def test_loading_from_an_association_that_has_a_hash_of_conditions - assert_nothing_raised do - Author.find(:all, :include => :hello_posts_with_hash_conditions) - end - assert !Author.find(authors(:david).id, :include => :hello_posts_with_hash_conditions).hello_posts.empty? - end - - def test_loading_with_no_associations - assert_nil Post.find(posts(:authorless).id, :include => :author).author - end - - def test_nested_loading_with_no_associations - assert_nothing_raised do - Post.find(posts(:authorless).id, :include => {:author => :author_addresss}) - end - end - - def test_eager_association_loading_with_belongs_to_and_foreign_keys - pets = Pet.find(:all, :include => :owner) - assert_equal 3, pets.length - end - - def test_eager_association_loading_with_belongs_to - comments = Comment.find(:all, :include => :post) - assert_equal 10, comments.length - titles = comments.map { |c| c.post.title } - assert titles.include?(posts(:welcome).title) - assert titles.include?(posts(:sti_post_and_comments).title) - end - - def test_eager_association_loading_with_belongs_to_and_limit - comments = Comment.find(:all, :include => :post, :limit => 5, :order => 'comments.id') - assert_equal 5, comments.length - assert_equal [1,2,3,5,6], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_conditions - comments = Comment.find(:all, :include => :post, :conditions => 'post_id = 4', :limit => 3, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [5,6,7], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset - comments = Comment.find(:all, :include => :post, :limit => 3, :offset => 2, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [3,5,6], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions - comments = Comment.find(:all, :include => :post, :conditions => 'post_id = 4', :limit => 3, :offset => 1, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [6,7,8], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array - comments = Comment.find(:all, :include => :post, :conditions => ['post_id = ?',4], :limit => 3, :offset => 1, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [6,7,8], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_conditions_string_with_unquoted_table_name - assert_nothing_raised do - Comment.find(:all, :include => :post, :conditions => ['posts.id = ?',4]) - end - end - - def test_eager_association_loading_with_belongs_to_and_conditions_hash - comments = [] - assert_nothing_raised do - comments = Comment.find(:all, :include => :post, :conditions => {:posts => {:id => 4}}, :limit => 3, :order => 'comments.id') - end - assert_equal 3, comments.length - assert_equal [5,6,7], comments.collect { |c| c.id } - assert_no_queries do - comments.first.post - end - end - - def test_eager_association_loading_with_belongs_to_and_conditions_string_with_quoted_table_name - quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id') - assert_nothing_raised do - Comment.find(:all, :include => :post, :conditions => ["#{quoted_posts_id} = ?",4]) - end - end - - def test_eager_association_loading_with_belongs_to_and_order_string_with_unquoted_table_name - assert_nothing_raised do - Comment.find(:all, :include => :post, :order => 'posts.id') - end - end - - def test_eager_association_loading_with_belongs_to_and_order_string_with_quoted_table_name - quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id') - assert_nothing_raised do - Comment.find(:all, :include => :post, :order => quoted_posts_id) - end - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_multiple_associations - posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1, :order => 'posts.id') - assert_equal 1, posts.length - assert_equal [1], posts.collect { |p| p.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_multiple_associations - posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1, :offset => 1, :order => 'posts.id') - assert_equal 1, posts.length - assert_equal [2], posts.collect { |p| p.id } - end - - def test_eager_association_loading_with_belongs_to_inferred_foreign_key_from_association_name - author_favorite = AuthorFavorite.find(:first, :include => :favorite_author) - assert_equal authors(:mary), assert_no_queries { author_favorite.favorite_author } - end - - def test_eager_load_belongs_to_quotes_table_and_column_names - job = Job.find jobs(:unicyclist).id, :include => :ideal_reference - references(:michael_unicyclist) - assert_no_queries{ assert_equal references(:michael_unicyclist), job.ideal_reference} - end - - def test_eager_load_has_one_quotes_table_and_column_names - michael = Person.find(people(:michael), :include => :favourite_reference) - references(:michael_unicyclist) - assert_no_queries{ assert_equal references(:michael_unicyclist), michael.favourite_reference} - end - - def test_eager_load_has_many_quotes_table_and_column_names - michael = Person.find(people(:michael), :include => :references) - references(:michael_magician,:michael_unicyclist) - assert_no_queries{ assert_equal references(:michael_magician,:michael_unicyclist), michael.references.sort_by(&:id) } - end - - def test_eager_load_has_many_through_quotes_table_and_column_names - michael = Person.find(people(:michael), :include => :jobs) - jobs(:magician, :unicyclist) - assert_no_queries{ assert_equal jobs(:unicyclist, :magician), michael.jobs.sort_by(&:id) } - end - - def test_eager_load_has_many_with_string_keys - subscriptions = subscriptions(:webster_awdr, :webster_rfr) - subscriber =Subscriber.find(subscribers(:second).id, :include => :subscriptions) - assert_equal subscriptions, subscriber.subscriptions.sort_by(&:id) - end - - def test_eager_load_has_many_through_with_string_keys - books = books(:awdr, :rfr) - subscriber = Subscriber.find(subscribers(:second).id, :include => :books) - assert_equal books, subscriber.books.sort_by(&:id) - end - - def test_eager_load_belongs_to_with_string_keys - subscriber = subscribers(:second) - subscription = Subscription.find(subscriptions(:webster_awdr).id, :include => :subscriber) - assert_equal subscriber, subscription.subscriber - end - - def test_eager_association_loading_with_explicit_join - posts = Post.find(:all, :include => :comments, :joins => "INNER JOIN authors ON posts.author_id = authors.id AND authors.name = 'Mary'", :limit => 1, :order => 'author_id') - assert_equal 1, posts.length - end - - def test_eager_with_has_many_through - posts_with_comments = people(:michael).posts.find(:all, :include => :comments, :order => 'posts.id') - posts_with_author = people(:michael).posts.find(:all, :include => :author, :order => 'posts.id') - posts_with_comments_and_author = people(:michael).posts.find(:all, :include => [ :comments, :author ], :order => 'posts.id') - assert_equal 2, posts_with_comments.inject(0) { |sum, post| sum += post.comments.size } - assert_equal authors(:david), assert_no_queries { posts_with_author.first.author } - assert_equal authors(:david), assert_no_queries { posts_with_comments_and_author.first.author } - end - - def test_eager_with_has_many_through_a_belongs_to_association - author = authors(:mary) - post = Post.create!(:author => author, :title => "TITLE", :body => "BODY") - author.author_favorites.create(:favorite_author_id => 1) - author.author_favorites.create(:favorite_author_id => 2) - posts_with_author_favorites = author.posts.find(:all, :include => :author_favorites) - assert_no_queries { posts_with_author_favorites.first.author_favorites.first.author_id } - end - - def test_eager_with_has_many_through_an_sti_join_model - author = Author.find(:first, :include => :special_post_comments, :order => 'authors.id') - assert_equal [comments(:does_it_hurt)], assert_no_queries { author.special_post_comments } - end - - def test_eager_with_has_many_through_an_sti_join_model_with_conditions_on_both - author = Author.find(:first, :include => :special_nonexistant_post_comments, :order => 'authors.id') - assert_equal [], author.special_nonexistant_post_comments - end - - def test_eager_with_has_many_through_join_model_with_conditions - assert_equal Author.find(:first, :include => :hello_post_comments, - :order => 'authors.id').hello_post_comments.sort_by(&:id), - Author.find(:first, :order => 'authors.id').hello_post_comments.sort_by(&:id) - end - - def test_eager_with_has_many_through_join_model_with_conditions_on_top_level - assert_equal comments(:more_greetings), Author.find(authors(:david).id, :include => :comments_with_order_and_conditions).comments_with_order_and_conditions.first - end - - def test_eager_with_has_many_through_with_conditions_join_model_with_include - post_tags = Post.find(posts(:welcome).id).misc_tags - eager_post_tags = Post.find(1, :include => :misc_tags).misc_tags - assert_equal post_tags, eager_post_tags - end - - def test_eager_with_has_many_through_association_with_order - author_comments = Author.find(authors(:david).id).comments_desc - eager_author_comments = Author.find(authors(:david).id, :include => :comments_desc).comments_desc - assert_equal eager_author_comments, author_comments - end - - def test_eager_with_has_many_through_join_model_with_include - author_comments = Author.find(authors(:david).id, :include => :comments_with_include).comments_with_include.to_a - assert_no_queries do - author_comments.first.post.title - end - end - - def test_eager_with_has_many_and_limit - posts = Post.find(:all, :order => 'posts.id asc', :include => [ :author, :comments ], :limit => 2) - assert_equal 2, posts.size - assert_equal 3, posts.inject(0) { |sum, post| sum += post.comments.size } - end - - def test_eager_with_has_many_and_limit_and_conditions - if current_adapter?(:OpenBaseAdapter) - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "FETCHBLOB(posts.body) = 'hello'", :order => "posts.id") - else - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.body = 'hello'", :order => "posts.id") - end - assert_equal 2, posts.size - assert_equal [4,5], posts.collect { |p| p.id } - end - - def test_eager_with_has_many_and_limit_and_conditions_array - if current_adapter?(:OpenBaseAdapter) - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "FETCHBLOB(posts.body) = ?", 'hello' ], :order => "posts.id") - else - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "posts.body = ?", 'hello' ], :order => "posts.id") - end - assert_equal 2, posts.size - assert_equal [4,5], posts.collect { |p| p.id } - end - - def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal 2, posts.size - - count = Post.count(:include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal count, posts.size - end - - def test_eager_with_has_many_and_limit_and_high_offset - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal 0, posts.size - end - - def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_array_conditions - assert_queries(1) do - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, - :conditions => [ "authors.name = ? and comments.body = ?", 'David', 'go crazy' ]) - assert_equal 0, posts.size - end - end - - def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_hash_conditions - assert_queries(1) do - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, - :conditions => { 'authors.name' => 'David', 'comments.body' => 'go crazy' }) - assert_equal 0, posts.size - end - end - - def test_count_eager_with_has_many_and_limit_and_high_offset - posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal 0, posts - end - - def test_eager_with_has_many_and_limit_with_no_results - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.title = 'magic forest'") - assert_equal 0, posts.size - end - - def test_eager_count_performed_on_a_has_many_association_with_multi_table_conditional - author = authors(:david) - author_posts_without_comments = author.posts.select { |post| post.comments.blank? } - assert_equal author_posts_without_comments.size, author.posts.count(:all, :include => :comments, :conditions => 'comments.id is null') - end - - def test_eager_count_performed_on_a_has_many_through_association_with_multi_table_conditional - person = people(:michael) - person_posts_without_comments = person.posts.select { |post| post.comments.blank? } - assert_equal person_posts_without_comments.size, person.posts_with_no_comments.count - end - - def test_eager_with_has_and_belongs_to_many_and_limit - posts = Post.find(:all, :include => :categories, :order => "posts.id", :limit => 3) - assert_equal 3, posts.size - assert_equal 2, posts[0].categories.size - assert_equal 1, posts[1].categories.size - assert_equal 0, posts[2].categories.size - assert posts[0].categories.include?(categories(:technology)) - assert posts[1].categories.include?(categories(:general)) - end - - def test_eager_with_has_many_and_limit_and_conditions_on_the_eagers - posts = authors(:david).posts.find(:all, - :include => :comments, - :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'", - :limit => 2 - ) - assert_equal 2, posts.size - - count = Post.count( - :include => [ :comments, :author ], - :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')", - :limit => 2 - ) - assert_equal count, posts.size - end - - def test_eager_with_has_many_and_limit_and_scoped_conditions_on_the_eagers - posts = nil - Post.with_scope(:find => { - :include => :comments, - :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'" - }) do - posts = authors(:david).posts.find(:all, :limit => 2) - assert_equal 2, posts.size - end - - Post.with_scope(:find => { - :include => [ :comments, :author ], - :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')" - }) do - count = Post.count(:limit => 2) - assert_equal count, posts.size - end - end - - def test_eager_with_has_many_and_limit_and_scoped_and_explicit_conditions_on_the_eagers - Post.with_scope(:find => { :conditions => "1=1" }) do - posts = authors(:david).posts.find(:all, - :include => :comments, - :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'", - :limit => 2 - ) - assert_equal 2, posts.size - - count = Post.count( - :include => [ :comments, :author ], - :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')", - :limit => 2 - ) - assert_equal count, posts.size - end - end - - def test_eager_with_scoped_order_using_association_limiting_without_explicit_scope - posts_with_explicit_order = Post.find(:all, :conditions => 'comments.id is not null', :include => :comments, :order => 'posts.id DESC', :limit => 2) - posts_with_scoped_order = Post.with_scope(:find => {:order => 'posts.id DESC'}) do - Post.find(:all, :conditions => 'comments.id is not null', :include => :comments, :limit => 2) - end - assert_equal posts_with_explicit_order, posts_with_scoped_order - end - - def test_eager_association_loading_with_habtm - posts = Post.find(:all, :include => :categories, :order => "posts.id") - assert_equal 2, posts[0].categories.size - assert_equal 1, posts[1].categories.size - assert_equal 0, posts[2].categories.size - assert posts[0].categories.include?(categories(:technology)) - assert posts[1].categories.include?(categories(:general)) - end - - def test_eager_with_inheritance - posts = SpecialPost.find(:all, :include => [ :comments ]) - end - - def test_eager_has_one_with_association_inheritance - post = Post.find(4, :include => [ :very_special_comment ]) - assert_equal "VerySpecialComment", post.very_special_comment.class.to_s - end - - def test_eager_has_many_with_association_inheritance - post = Post.find(4, :include => [ :special_comments ]) - post.special_comments.each do |special_comment| - assert_equal "SpecialComment", special_comment.class.to_s - end - end - - def test_eager_habtm_with_association_inheritance - post = Post.find(6, :include => [ :special_categories ]) - assert_equal 1, post.special_categories.size - post.special_categories.each do |special_category| - assert_equal "SpecialCategory", special_category.class.to_s - end - end - - def test_eager_with_has_one_dependent_does_not_destroy_dependent - assert_not_nil companies(:first_firm).account - f = Firm.find(:first, :include => :account, - :conditions => ["companies.name = ?", "37signals"]) - assert_not_nil f.account - assert_equal companies(:first_firm, :reload).account, f.account - end - - def test_eager_with_multi_table_conditional_properly_counts_the_records_when_using_size - author = authors(:david) - posts_with_no_comments = author.posts.select { |post| post.comments.blank? } - assert_equal posts_with_no_comments.size, author.posts_with_no_comments.size - assert_equal posts_with_no_comments, author.posts_with_no_comments - end - - def test_eager_with_invalid_association_reference - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { - post = Post.find(6, :include=> :monkeys ) - } - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { - post = Post.find(6, :include=>[ :monkeys ]) - } - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { - post = Post.find(6, :include=>[ 'monkeys' ]) - } - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys, :elephants") { - post = Post.find(6, :include=>[ :monkeys, :elephants ]) - } - end - - def find_all_ordered(className, include=nil) - className.find(:all, :order=>"#{className.table_name}.#{className.primary_key}", :include=>include) - end - - def test_limited_eager_with_order - assert_equal posts(:thinking, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title)', :limit => 2, :offset => 1) - assert_equal posts(:sti_post_and_comments, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC', :limit => 2, :offset => 1) - end - - def test_limited_eager_with_multiple_order_columns - assert_equal posts(:thinking, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title), posts.id', :limit => 2, :offset => 1) - assert_equal posts(:sti_post_and_comments, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC, posts.id', :limit => 2, :offset => 1) - end - - def test_preload_with_interpolation - assert_equal [comments(:greetings)], Post.find(posts(:welcome).id, :include => :comments_with_interpolated_conditions).comments_with_interpolated_conditions - end - - def test_polymorphic_type_condition - post = Post.find(posts(:thinking).id, :include => :taggings) - assert post.taggings.include?(taggings(:thinking_general)) - post = SpecialPost.find(posts(:thinking).id, :include => :taggings) - assert post.taggings.include?(taggings(:thinking_general)) - end - - def test_eager_with_multiple_associations_with_same_table_has_many_and_habtm - # Eager includes of has many and habtm associations aren't necessarily sorted in the same way - def assert_equal_after_sort(item1, item2, item3 = nil) - assert_equal(item1.sort{|a,b| a.id <=> b.id}, item2.sort{|a,b| a.id <=> b.id}) - assert_equal(item3.sort{|a,b| a.id <=> b.id}, item2.sort{|a,b| a.id <=> b.id}) if item3 - end - # Test regular association, association with conditions, association with - # STI, and association with conditions assured not to be true - post_types = [:posts, :other_posts, :special_posts] - # test both has_many and has_and_belongs_to_many - [Author, Category].each do |className| - d1 = find_all_ordered(className) - # test including all post types at once - d2 = find_all_ordered(className, post_types) - d1.each_index do |i| - assert_equal(d1[i], d2[i]) - assert_equal_after_sort(d1[i].posts, d2[i].posts) - post_types[1..-1].each do |post_type| - # test including post_types together - d3 = find_all_ordered(className, [:posts, post_type]) - assert_equal(d1[i], d3[i]) - assert_equal_after_sort(d1[i].posts, d3[i].posts) - assert_equal_after_sort(d1[i].send(post_type), d2[i].send(post_type), d3[i].send(post_type)) - end - end - end - end - - def test_eager_with_multiple_associations_with_same_table_has_one - d1 = find_all_ordered(Firm) - d2 = find_all_ordered(Firm, :account) - d1.each_index do |i| - assert_equal(d1[i], d2[i]) - assert_equal(d1[i].account, d2[i].account) - end - end - - def test_eager_with_multiple_associations_with_same_table_belongs_to - firm_types = [:firm, :firm_with_basic_id, :firm_with_other_name, :firm_with_condition] - d1 = find_all_ordered(Client) - d2 = find_all_ordered(Client, firm_types) - d1.each_index do |i| - assert_equal(d1[i], d2[i]) - firm_types.each { |type| assert_equal(d1[i].send(type), d2[i].send(type)) } - end - end - def test_eager_with_valid_association_as_string_not_symbol - assert_nothing_raised { Post.find(:all, :include => 'comments') } - end - - def test_eager_with_floating_point_numbers - assert_queries(2) do - # Before changes, the floating point numbers will be interpreted as table names and will cause this to run in one query - Comment.find :all, :conditions => "123.456 = 123.456", :include => :post - end - end - - def test_preconfigured_includes_with_belongs_to - author = posts(:welcome).author_with_posts - assert_no_queries {assert_equal 5, author.posts.size} - end - - def test_preconfigured_includes_with_has_one - comment = posts(:sti_comments).very_special_comment_with_post - assert_no_queries {assert_equal posts(:sti_comments), comment.post} - end - - def test_preconfigured_includes_with_has_many - posts = authors(:david).posts_with_comments - one = posts.detect { |p| p.id == 1 } - assert_no_queries do - assert_equal 5, posts.size - assert_equal 2, one.comments.size - end - end - - def test_preconfigured_includes_with_habtm - posts = authors(:david).posts_with_categories - one = posts.detect { |p| p.id == 1 } - assert_no_queries do - assert_equal 5, posts.size - assert_equal 2, one.categories.size - end - end - - def test_preconfigured_includes_with_has_many_and_habtm - posts = authors(:david).posts_with_comments_and_categories - one = posts.detect { |p| p.id == 1 } - assert_no_queries do - assert_equal 5, posts.size - assert_equal 2, one.comments.size - assert_equal 2, one.categories.size - end - end - - def test_count_with_include - if current_adapter?(:SybaseAdapter) - assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15") - elsif current_adapter?(:OpenBaseAdapter) - assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(FETCHBLOB(comments.body)) > 15") - else - assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(comments.body) > 15") - end - end - - def test_load_with_sti_sharing_association - assert_queries(2) do #should not do 1 query per subclass - Comment.find :all, :include => :post - end - end - - def test_conditions_on_join_table_with_include_and_limit - assert_equal 3, Developer.find(:all, :include => 'projects', :conditions => 'developers_projects.access_level = 1', :limit => 5).size - end - - def test_order_on_join_table_with_include_and_limit - assert_equal 5, Developer.find(:all, :include => 'projects', :order => 'developers_projects.joined_on DESC', :limit => 5).size - end - - def test_eager_loading_with_order_on_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :joins => :comments, :include => :author, :order => 'comments.id DESC') - end - assert_equal posts(:eager_other), posts[0] - assert_equal authors(:mary), assert_no_queries { posts[0].author} - end - - def test_eager_loading_with_conditions_on_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - posts = assert_queries(2) do - Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id') - end - assert_equal posts(:welcome, :thinking), posts - - posts = assert_queries(2) do - Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id') - end - assert_equal posts(:welcome, :thinking), posts - - end - - def test_eager_loading_with_conditions_on_string_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => "INNER JOIN comments on comments.post_id = posts.id", :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => ["INNER JOIN comments on comments.post_id = posts.id"], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - end - - def test_eager_loading_with_select_on_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :select => 'posts.*, authors.name as author_name', :include => :comments, :joins => :author, :order => 'posts.id') - end - assert_equal 'David', posts[0].author_name - assert_equal posts(:welcome).comments, assert_no_queries { posts[0].comments} - end - - def test_eager_loading_with_conditions_on_join_model_preloads - authors = assert_queries(2) do - Author.find(:all, :include => :author_address, :joins => :comments, :conditions => "posts.title like 'Welcome%'") - end - assert_equal authors(:david), authors[0] - assert_equal author_addresses(:david_address), authors[0].author_address - end - - def test_preload_belongs_to_uses_exclusive_scope - people = Person.males.find(:all, :include => :primary_contact) - assert_not_equal people.length, 0 - people.each do |person| - assert_no_queries {assert_not_nil person.primary_contact} - assert_equal Person.find(person.id).primary_contact, person.primary_contact - end - end - - def test_preload_has_many_uses_exclusive_scope - people = Person.males.find :all, :include => :agents - people.each do |person| - assert_equal Person.find(person.id).agents, person.agents - end - end - - def test_preload_has_many_using_primary_key - expected = Firm.find(:first).clients_using_primary_key.to_a - firm = Firm.find :first, :include => :clients_using_primary_key - assert_no_queries do - assert_equal expected, firm.clients_using_primary_key - end - end - - def test_include_has_many_using_primary_key - expected = Firm.find(1).clients_using_primary_key.sort_by &:name - firm = Firm.find 1, :include => :clients_using_primary_key, :order => 'clients_using_primary_keys_companies.name' - assert_no_queries do - assert_equal expected, firm.clients_using_primary_key - end - end - - def test_preload_has_one_using_primary_key - expected = Firm.find(:first).account_using_primary_key - firm = Firm.find :first, :include => :account_using_primary_key - assert_no_queries do - assert_equal expected, firm.account_using_primary_key - end - end - - def test_include_has_one_using_primary_key - expected = Firm.find(1).account_using_primary_key - firm = Firm.find(:all, :include => :account_using_primary_key, :order => 'accounts.id').detect {|f| f.id == 1} - assert_no_queries do - assert_equal expected, firm.account_using_primary_key - end - end - - def test_preloading_empty_polymorphic_parent - t = Tagging.create!(:taggable_type => 'Post', :taggable_id => Post.maximum(:id) + 1, :tag => tags(:general)) - - assert_queries(2) { @tagging = Tagging.find(t.id, :include => :taggable) } - assert_no_queries { assert ! @tagging.taggable } - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/extension_test.rb b/vendor/rails/activerecord/test/cases/associations/extension_test.rb deleted file mode 100644 index 9390633d..00000000 --- a/vendor/rails/activerecord/test/cases/associations/extension_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/project' -require 'models/developer' -require 'models/company_in_module' - -class AssociationsExtensionsTest < ActiveRecord::TestCase - fixtures :projects, :developers, :developers_projects, :comments, :posts - - def test_extension_on_has_many - assert_equal comments(:more_greetings), posts(:welcome).comments.find_most_recent - end - - def test_extension_on_habtm - assert_equal projects(:action_controller), developers(:david).projects.find_most_recent - end - - def test_named_extension_on_habtm - assert_equal projects(:action_controller), developers(:david).projects_extended_by_name.find_most_recent - end - - def test_named_two_extensions_on_habtm - assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_twice.find_most_recent - assert_equal projects(:active_record), developers(:david).projects_extended_by_name_twice.find_least_recent - end - - def test_named_extension_and_block_on_habtm - assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_and_block.find_most_recent - assert_equal projects(:active_record), developers(:david).projects_extended_by_name_and_block.find_least_recent - end - - def test_marshalling_extensions - david = developers(:david) - assert_equal projects(:action_controller), david.projects.find_most_recent - - david = Marshal.load(Marshal.dump(david)) - assert_equal projects(:action_controller), david.projects.find_most_recent - end - - def test_marshalling_named_extensions - david = developers(:david) - assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent - - david = Marshal.load(Marshal.dump(david)) - assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent - end - - - def test_extension_name - extension = Proc.new {} - name = :association_name - - assert_equal 'DeveloperAssociationNameAssociationExtension', Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', -MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - end - - -end diff --git a/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb b/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb deleted file mode 100644 index bf3e04c3..00000000 --- a/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'cases/helper' - -class MyReader < ActiveRecord::Base - has_and_belongs_to_many :my_books -end - -class MyBook < ActiveRecord::Base - has_and_belongs_to_many :my_readers -end - -class HabtmJoinTableTest < ActiveRecord::TestCase - def setup - ActiveRecord::Base.connection.create_table :my_books, :force => true do |t| - t.string :name - end - assert ActiveRecord::Base.connection.table_exists?(:my_books) - - ActiveRecord::Base.connection.create_table :my_readers, :force => true do |t| - t.string :name - end - assert ActiveRecord::Base.connection.table_exists?(:my_readers) - - ActiveRecord::Base.connection.create_table :my_books_my_readers, :force => true do |t| - t.integer :my_book_id - t.integer :my_reader_id - end - assert ActiveRecord::Base.connection.table_exists?(:my_books_my_readers) - end - - def teardown - ActiveRecord::Base.connection.drop_table :my_books - ActiveRecord::Base.connection.drop_table :my_readers - ActiveRecord::Base.connection.drop_table :my_books_my_readers - end - - uses_transaction :test_should_raise_exception_when_join_table_has_a_primary_key - def test_should_raise_exception_when_join_table_has_a_primary_key - if ActiveRecord::Base.connection.supports_primary_key? - assert_raise ActiveRecord::ConfigurationError do - jaime = MyReader.create(:name=>"Jaime") - jaime.my_books << MyBook.create(:name=>'Great Expectations') - end - end - end - - uses_transaction :test_should_cache_result_of_primary_key_check - def test_should_cache_result_of_primary_key_check - if ActiveRecord::Base.connection.supports_primary_key? - ActiveRecord::Base.connection.stubs(:primary_key).with('my_books_my_readers').returns(false).once - weaz = MyReader.create(:name=>'Weaz') - - weaz.my_books << MyBook.create(:name=>'Great Expectations') - weaz.my_books << MyBook.create(:name=>'Greater Expectations') - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb deleted file mode 100644 index b252a54a..00000000 --- a/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ /dev/null @@ -1,827 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/computer' -require 'models/customer' -require 'models/order' -require 'models/categorization' -require 'models/category' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/tag' -require 'models/tagging' -require 'models/person' -require 'models/reader' -require 'models/parrot' -require 'models/pirate' -require 'models/treasure' -require 'models/price_estimate' -require 'models/club' -require 'models/member' -require 'models/membership' -require 'models/sponsor' - -class ProjectWithAfterCreateHook < ActiveRecord::Base - set_table_name 'projects' - has_and_belongs_to_many :developers, - :class_name => "DeveloperForProjectWithAfterCreateHook", - :join_table => "developers_projects", - :foreign_key => "project_id", - :association_foreign_key => "developer_id" - - after_create :add_david - - def add_david - david = DeveloperForProjectWithAfterCreateHook.find_by_name('David') - david.projects << self - end -end - -class DeveloperForProjectWithAfterCreateHook < ActiveRecord::Base - set_table_name 'developers' - has_and_belongs_to_many :projects, - :class_name => "ProjectWithAfterCreateHook", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :foreign_key => "developer_id" -end - -class ProjectWithSymbolsForKeys < ActiveRecord::Base - set_table_name 'projects' - has_and_belongs_to_many :developers, - :class_name => "DeveloperWithSymbolsForKeys", - :join_table => :developers_projects, - :foreign_key => :project_id, - :association_foreign_key => "developer_id" -end - -class DeveloperWithSymbolsForKeys < ActiveRecord::Base - set_table_name 'developers' - has_and_belongs_to_many :projects, - :class_name => "ProjectWithSymbolsForKeys", - :join_table => :developers_projects, - :association_foreign_key => :project_id, - :foreign_key => "developer_id" -end - -class DeveloperWithCounterSQL < ActiveRecord::Base - set_table_name 'developers' - has_and_belongs_to_many :projects, - :class_name => "DeveloperWithCounterSQL", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :foreign_key => "developer_id", - :counter_sql => 'SELECT COUNT(*) AS count_all FROM projects INNER JOIN developers_projects ON projects.id = developers_projects.project_id WHERE developers_projects.developer_id =#{id}' -end - -class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects, - :parrots, :pirates, :treasures, :price_estimates, :tags, :taggings - - def test_has_and_belongs_to_many - david = Developer.find(1) - - assert !david.projects.empty? - assert_equal 2, david.projects.size - - active_record = Project.find(1) - assert !active_record.developers.empty? - assert_equal 3, active_record.developers.size - assert active_record.developers.include?(david) - end - - def test_triple_equality - assert !(Array === Developer.find(1).projects) - assert Developer.find(1).projects === Array - end - - def test_adding_single - jamis = Developer.find(2) - jamis.projects.reload # causing the collection to load - action_controller = Project.find(2) - assert_equal 1, jamis.projects.size - assert_equal 1, action_controller.developers.size - - jamis.projects << action_controller - - assert_equal 2, jamis.projects.size - assert_equal 2, jamis.projects(true).size - assert_equal 2, action_controller.developers(true).size - end - - def test_adding_type_mismatch - jamis = Developer.find(2) - assert_raise(ActiveRecord::AssociationTypeMismatch) { jamis.projects << nil } - assert_raise(ActiveRecord::AssociationTypeMismatch) { jamis.projects << 1 } - end - - def test_adding_from_the_project - jamis = Developer.find(2) - action_controller = Project.find(2) - action_controller.developers.reload - assert_equal 1, jamis.projects.size - assert_equal 1, action_controller.developers.size - - action_controller.developers << jamis - - assert_equal 2, jamis.projects(true).size - assert_equal 2, action_controller.developers.size - assert_equal 2, action_controller.developers(true).size - end - - def test_adding_from_the_project_fixed_timestamp - jamis = Developer.find(2) - action_controller = Project.find(2) - action_controller.developers.reload - assert_equal 1, jamis.projects.size - assert_equal 1, action_controller.developers.size - updated_at = jamis.updated_at - - action_controller.developers << jamis - - assert_equal updated_at, jamis.updated_at - assert_equal 2, jamis.projects(true).size - assert_equal 2, action_controller.developers.size - assert_equal 2, action_controller.developers(true).size - end - - def test_adding_multiple - aredridel = Developer.new("name" => "Aredridel") - aredridel.save - aredridel.projects.reload - aredridel.projects.push(Project.find(1), Project.find(2)) - assert_equal 2, aredridel.projects.size - assert_equal 2, aredridel.projects(true).size - end - - def test_adding_a_collection - aredridel = Developer.new("name" => "Aredridel") - aredridel.save - aredridel.projects.reload - aredridel.projects.concat([Project.find(1), Project.find(2)]) - assert_equal 2, aredridel.projects.size - assert_equal 2, aredridel.projects(true).size - end - - def test_adding_uses_default_values_on_join_table - ac = projects(:action_controller) - assert !developers(:jamis).projects.include?(ac) - developers(:jamis).projects << ac - - assert developers(:jamis, :reload).projects.include?(ac) - project = developers(:jamis).projects.detect { |p| p == ac } - assert_equal 1, project.access_level.to_i - end - - def test_habtm_attribute_access_and_respond_to - project = developers(:jamis).projects[0] - assert project.has_attribute?("name") - assert project.has_attribute?("joined_on") - assert project.has_attribute?("access_level") - assert project.respond_to?("name") - assert project.respond_to?("name=") - assert project.respond_to?("name?") - assert project.respond_to?("joined_on") - # given that the 'join attribute' won't be persisted, I don't - # think we should define the mutators - #assert project.respond_to?("joined_on=") - assert project.respond_to?("joined_on?") - assert project.respond_to?("access_level") - #assert project.respond_to?("access_level=") - assert project.respond_to?("access_level?") - end - - def test_habtm_adding_before_save - no_of_devels = Developer.count - no_of_projects = Project.count - aredridel = Developer.new("name" => "Aredridel") - aredridel.projects.concat([Project.find(1), p = Project.new("name" => "Projekt")]) - assert aredridel.new_record? - assert p.new_record? - assert aredridel.save - assert !aredridel.new_record? - assert_equal no_of_devels+1, Developer.count - assert_equal no_of_projects+1, Project.count - assert_equal 2, aredridel.projects.size - assert_equal 2, aredridel.projects(true).size - end - - def test_habtm_saving_multiple_relationships - new_project = Project.new("name" => "Grimetime") - amount_of_developers = 4 - developers = (0...amount_of_developers).collect {|i| Developer.create(:name => "JME #{i}") }.reverse - - new_project.developer_ids = [developers[0].id, developers[1].id] - new_project.developers_with_callback_ids = [developers[2].id, developers[3].id] - assert new_project.save - - new_project.reload - assert_equal amount_of_developers, new_project.developers.size - assert_equal developers, new_project.developers - end - - def test_habtm_unique_order_preserved - assert_equal developers(:poor_jamis, :jamis, :david), projects(:active_record).non_unique_developers - assert_equal developers(:poor_jamis, :jamis, :david), projects(:active_record).developers - end - - def test_build - devel = Developer.find(1) - proj = assert_no_queries { devel.projects.build("name" => "Projekt") } - assert !devel.projects.loaded? - - assert_equal devel.projects.last, proj - assert devel.projects.loaded? - - assert proj.new_record? - devel.save - assert !proj.new_record? - assert_equal devel.projects.last, proj - assert_equal Developer.find(1).projects.sort_by(&:id).last, proj # prove join table is updated - end - - def test_build_by_new_record - devel = Developer.new(:name => "Marcel", :salary => 75000) - proj1 = devel.projects.build(:name => "Make bed") - proj2 = devel.projects.build(:name => "Lie in it") - assert_equal devel.projects.last, proj2 - assert proj2.new_record? - devel.save - assert !devel.new_record? - assert !proj2.new_record? - assert_equal devel.projects.last, proj2 - assert_equal Developer.find_by_name("Marcel").projects.last, proj2 # prove join table is updated - end - - def test_create - devel = Developer.find(1) - proj = devel.projects.create("name" => "Projekt") - assert !devel.projects.loaded? - - assert_equal devel.projects.last, proj - assert !devel.projects.loaded? - - assert !proj.new_record? - assert_equal Developer.find(1).projects.sort_by(&:id).last, proj # prove join table is updated - end - - def test_create_by_new_record - devel = Developer.new(:name => "Marcel", :salary => 75000) - proj1 = devel.projects.build(:name => "Make bed") - proj2 = devel.projects.build(:name => "Lie in it") - assert_equal devel.projects.last, proj2 - assert proj2.new_record? - devel.save - assert !devel.new_record? - assert !proj2.new_record? - assert_equal devel.projects.last, proj2 - assert_equal Developer.find_by_name("Marcel").projects.last, proj2 # prove join table is updated - end - - def test_creation_respects_hash_condition - post = categories(:general).post_with_conditions.build(:body => '') - - assert post.save - assert_equal 'Yet Another Testing Title', post.title - - another_post = categories(:general).post_with_conditions.create(:body => '') - - assert !another_post.new_record? - assert_equal 'Yet Another Testing Title', another_post.title - end - - def test_uniq_after_the_fact - dev = developers(:jamis) - dev.projects << projects(:active_record) - dev.projects << projects(:active_record) - - assert_equal 3, dev.projects.size - assert_equal 1, dev.projects.uniq.size - end - - def test_uniq_before_the_fact - projects(:active_record).developers << developers(:jamis) - projects(:active_record).developers << developers(:david) - assert_equal 3, projects(:active_record, :reload).developers.size - end - - def test_uniq_option_prevents_duplicate_push - project = projects(:active_record) - project.developers << developers(:jamis) - project.developers << developers(:david) - assert_equal 3, project.developers.size - - project.developers << developers(:david) - project.developers << developers(:jamis) - assert_equal 3, project.developers.size - end - - def test_deleting - david = Developer.find(1) - active_record = Project.find(1) - david.projects.reload - assert_equal 2, david.projects.size - assert_equal 3, active_record.developers.size - - david.projects.delete(active_record) - - assert_equal 1, david.projects.size - assert_equal 1, david.projects(true).size - assert_equal 2, active_record.developers(true).size - end - - def test_deleting_array - david = Developer.find(1) - david.projects.reload - david.projects.delete(Project.find(:all)) - assert_equal 0, david.projects.size - assert_equal 0, david.projects(true).size - end - - def test_deleting_with_sql - david = Developer.find(1) - active_record = Project.find(1) - active_record.developers.reload - assert_equal 3, active_record.developers_by_sql.size - - active_record.developers_by_sql.delete(david) - assert_equal 2, active_record.developers_by_sql(true).size - end - - def test_deleting_array_with_sql - active_record = Project.find(1) - active_record.developers.reload - assert_equal 3, active_record.developers_by_sql.size - - active_record.developers_by_sql.delete(Developer.find(:all)) - assert_equal 0, active_record.developers_by_sql(true).size - end - - def test_deleting_all - david = Developer.find(1) - david.projects.reload - david.projects.clear - assert_equal 0, david.projects.size - assert_equal 0, david.projects(true).size - end - - def test_removing_associations_on_destroy - david = DeveloperWithBeforeDestroyRaise.find(1) - assert !david.projects.empty? - assert_nothing_raised { david.destroy } - assert david.projects.empty? - assert DeveloperWithBeforeDestroyRaise.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = 1").empty? - end - - def test_additional_columns_from_join_table - assert_date_from_db Date.new(2004, 10, 10), Developer.find(1).projects.first.joined_on.to_date - end - - def test_destroying - david = Developer.find(1) - active_record = Project.find(1) - david.projects.reload - assert_equal 2, david.projects.size - assert_equal 3, active_record.developers.size - - assert_difference "Project.count", -1 do - david.projects.destroy(active_record) - end - - assert_equal 1, david.reload.projects.size - assert_equal 1, david.projects(true).size - end - - def test_destroying_array - david = Developer.find(1) - david.projects.reload - - assert_difference "Project.count", -Project.count do - david.projects.destroy(Project.find(:all)) - end - - assert_equal 0, david.reload.projects.size - assert_equal 0, david.projects(true).size - end - - def test_destroy_all - david = Developer.find(1) - david.projects.reload - assert !david.projects.empty? - david.projects.destroy_all - assert david.projects.empty? - assert david.projects(true).empty? - end - - def test_deprecated_push_with_attributes_was_removed - jamis = developers(:jamis) - assert_raise(NoMethodError) do - jamis.projects.push_with_attributes(projects(:action_controller), :joined_on => Date.today) - end - end - - def test_associations_with_conditions - assert_equal 3, projects(:active_record).developers.size - assert_equal 1, projects(:active_record).developers_named_david.size - assert_equal 1, projects(:active_record).developers_named_david_with_hash_conditions.size - - assert_equal developers(:david), projects(:active_record).developers_named_david.find(developers(:david).id) - assert_equal developers(:david), projects(:active_record).developers_named_david_with_hash_conditions.find(developers(:david).id) - assert_equal developers(:david), projects(:active_record).salaried_developers.find(developers(:david).id) - - projects(:active_record).developers_named_david.clear - assert_equal 2, projects(:active_record, :reload).developers.size - end - - def test_find_in_association - # Using sql - assert_equal developers(:david), projects(:active_record).developers.find(developers(:david).id), "SQL find" - - # Using ruby - active_record = projects(:active_record) - active_record.developers.reload - assert_equal developers(:david), active_record.developers.find(developers(:david).id), "Ruby find" - end - - def test_include_uses_array_include_after_loaded - project = projects(:active_record) - project.developers.class # force load target - - developer = project.developers.first - - assert_no_queries do - assert project.developers.loaded? - assert project.developers.include?(developer) - end - end - - def test_include_checks_if_record_exists_if_target_not_loaded - project = projects(:active_record) - developer = project.developers.first - - project.reload - assert ! project.developers.loaded? - assert_queries(1) do - assert project.developers.include?(developer) - end - assert ! project.developers.loaded? - end - - def test_include_returns_false_for_non_matching_record_to_verify_scoping - project = projects(:active_record) - developer = Developer.create :name => "Bryan", :salary => 50_000 - - assert ! project.developers.loaded? - assert ! project.developers.include?(developer) - end - - def test_find_in_association_with_custom_finder_sql - assert_equal developers(:david), projects(:active_record).developers_with_finder_sql.find(developers(:david).id), "SQL find" - - active_record = projects(:active_record) - active_record.developers_with_finder_sql.reload - assert_equal developers(:david), active_record.developers_with_finder_sql.find(developers(:david).id), "Ruby find" - end - - def test_find_in_association_with_custom_finder_sql_and_multiple_interpolations - # interpolate once: - assert_equal [developers(:david), developers(:jamis), developers(:poor_jamis)], projects(:active_record).developers_with_finder_sql, "first interpolation" - # interpolate again, for a different project id - assert_equal [developers(:david)], projects(:action_controller).developers_with_finder_sql, "second interpolation" - end - - def test_find_in_association_with_custom_finder_sql_and_string_id - assert_equal developers(:david), projects(:active_record).developers_with_finder_sql.find(developers(:david).id.to_s), "SQL find" - end - - def test_find_with_merged_options - assert_equal 1, projects(:active_record).limited_developers.size - assert_equal 1, projects(:active_record).limited_developers.find(:all).size - assert_equal 3, projects(:active_record).limited_developers.find(:all, :limit => nil).size - end - - def test_dynamic_find_should_respect_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal high_id_jamis, projects(:active_record).developers.find(:first, :conditions => "name = 'Jamis'") - assert_equal high_id_jamis, projects(:active_record).developers.find_by_name('Jamis') - end - - def test_dynamic_find_order_should_override_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal low_id_jamis, projects(:active_record).developers.find(:first, :conditions => "name = 'Jamis'", :order => 'id') - assert_equal low_id_jamis, projects(:active_record).developers.find_by_name('Jamis', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal [high_id_jamis, middle_id_jamis, low_id_jamis], projects(:active_record).developers.find(:all, :conditions => "name = 'Jamis'") - assert_equal [high_id_jamis, middle_id_jamis, low_id_jamis], projects(:active_record).developers.find_all_by_name('Jamis') - end - - def test_dynamic_find_all_order_should_override_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal [low_id_jamis, middle_id_jamis, high_id_jamis], projects(:active_record).developers.find(:all, :conditions => "name = 'Jamis'", :order => 'id') - assert_equal [low_id_jamis, middle_id_jamis, high_id_jamis], projects(:active_record).developers.find_all_by_name('Jamis', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_limit - assert_equal 1, projects(:active_record).limited_developers.find(:all, :conditions => "name = 'Jamis'").length - assert_equal 1, projects(:active_record).limited_developers.find_all_by_name('Jamis').length - end - - def test_dynamic_find_all_order_should_override_association_limit - assert_equal 2, projects(:active_record).limited_developers.find(:all, :conditions => "name = 'Jamis'", :limit => 9_000).length - assert_equal 2, projects(:active_record).limited_developers.find_all_by_name('Jamis', :limit => 9_000).length - end - - def test_dynamic_find_all_should_respect_readonly_access - projects(:active_record).readonly_developers.each { |d| assert_raise(ActiveRecord::ReadOnlyRecord) { d.save! } if d.valid?} - projects(:active_record).readonly_developers.each { |d| d.readonly? } - end - - def test_new_with_values_in_collection - jamis = DeveloperForProjectWithAfterCreateHook.find_by_name('Jamis') - david = DeveloperForProjectWithAfterCreateHook.find_by_name('David') - project = ProjectWithAfterCreateHook.new(:name => "Cooking with Bertie") - project.developers << jamis - project.save! - project.reload - - assert project.developers.include?(jamis) - assert project.developers.include?(david) - end - - def test_find_in_association_with_options - developers = projects(:active_record).developers.find(:all) - assert_equal 3, developers.size - - assert_equal developers(:poor_jamis), projects(:active_record).developers.find(:first, :conditions => "salary < 10000") - assert_equal developers(:jamis), projects(:active_record).developers.find(:first, :order => "salary DESC") - end - - def test_replace_with_less - david = developers(:david) - david.projects = [projects(:action_controller)] - assert david.save - assert_equal 1, david.projects.length - end - - def test_replace_with_new - david = developers(:david) - david.projects = [projects(:action_controller), Project.new("name" => "ActionWebSearch")] - david.save - assert_equal 2, david.projects.length - assert !david.projects.include?(projects(:active_record)) - end - - def test_replace_on_new_object - new_developer = Developer.new("name" => "Matz") - new_developer.projects = [projects(:action_controller), Project.new("name" => "ActionWebSearch")] - new_developer.save - assert_equal 2, new_developer.projects.length - end - - def test_consider_type - developer = Developer.find(:first) - special_project = SpecialProject.create("name" => "Special Project") - - other_project = developer.projects.first - developer.special_projects << special_project - developer.reload - - assert developer.projects.include?(special_project) - assert developer.special_projects.include?(special_project) - assert !developer.special_projects.include?(other_project) - end - - def test_update_attributes_after_push_without_duplicate_join_table_rows - developer = Developer.new("name" => "Kano") - project = SpecialProject.create("name" => "Special Project") - assert developer.save - developer.projects << project - developer.update_attribute("name", "Bruza") - assert_equal 1, Developer.connection.select_value(<<-end_sql).to_i - SELECT count(*) FROM developers_projects - WHERE project_id = #{project.id} - AND developer_id = #{developer.id} - end_sql - end - - def test_updating_attributes_on_non_rich_associations - welcome = categories(:technology).posts.first - welcome.title = "Something else" - assert welcome.save! - end - - def test_habtm_respects_select - categories(:technology).select_testing_posts(true).each do |o| - assert_respond_to o, :correctness_marker - end - assert_respond_to categories(:technology).select_testing_posts.find(:first), :correctness_marker - end - - def test_updating_attributes_on_rich_associations - david = projects(:action_controller).developers.first - david.name = "DHH" - assert_raise(ActiveRecord::ReadOnlyRecord) { david.save! } - end - - def test_updating_attributes_on_rich_associations_with_limited_find_from_reflection - david = projects(:action_controller).selected_developers.first - david.name = "DHH" - assert_nothing_raised { david.save! } - end - - - def test_updating_attributes_on_rich_associations_with_limited_find - david = projects(:action_controller).developers.find(:all, :select => "developers.*").first - david.name = "DHH" - assert david.save! - end - - def test_join_table_alias - assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL').size - end - - def test_join_with_group - group = Developer.columns.inject([]) do |g, c| - g << "developers.#{c.name}" - g << "developers_projects_2.#{c.name}" - end - Project.columns.each { |c| group << "projects.#{c.name}" } - - assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL', :group => group.join(",")).size - end - - def test_find_grouped - all_posts_from_category1 = Post.find(:all, :conditions => "category_id = 1", :joins => :categories) - grouped_posts_of_category1 = Post.find(:all, :conditions => "category_id = 1", :group => "author_id", :select => 'count(posts.id) as posts_count', :joins => :categories) - assert_equal 4, all_posts_from_category1.size - assert_equal 1, grouped_posts_of_category1.size - end - - def test_find_scoped_grouped - assert_equal 4, categories(:general).posts_gruoped_by_title.size - assert_equal 1, categories(:technology).posts_gruoped_by_title.size - end - - def test_find_scoped_grouped_having - assert_equal 2, projects(:active_record).well_payed_salary_groups.size - assert projects(:active_record).well_payed_salary_groups.all? { |g| g.salary > 10000 } - end - - def test_get_ids - assert_equal projects(:active_record, :action_controller).map(&:id).sort, developers(:david).project_ids.sort - assert_equal [projects(:active_record).id], developers(:jamis).project_ids - end - - def test_get_ids_for_loaded_associations - developer = developers(:david) - developer.projects(true) - assert_queries(0) do - developer.project_ids - developer.project_ids - end - end - - def test_get_ids_for_unloaded_associations_does_not_load_them - developer = developers(:david) - assert !developer.projects.loaded? - assert_equal projects(:active_record, :action_controller).map(&:id).sort, developer.project_ids.sort - assert !developer.projects.loaded? - end - - def test_assign_ids - developer = Developer.new("name" => "Joe") - developer.project_ids = projects(:active_record, :action_controller).map(&:id) - developer.save - developer.reload - assert_equal 2, developer.projects.length - assert_equal [projects(:active_record), projects(:action_controller)].map(&:id).sort, developer.project_ids.sort - end - - def test_assign_ids_ignoring_blanks - developer = Developer.new("name" => "Joe") - developer.project_ids = [projects(:active_record).id, nil, projects(:action_controller).id, ''] - developer.save - developer.reload - assert_equal 2, developer.projects.length - assert_equal [projects(:active_record), projects(:action_controller)].map(&:id).sort, developer.project_ids.sort - end - - def test_select_limited_ids_list - # Set timestamps - Developer.transaction do - Developer.find(:all, :order => 'id').each_with_index do |record, i| - record.update_attributes(:created_at => 5.years.ago + (i * 5.minutes)) - end - end - - join_base = ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase.new(Project) - join_dep = ActiveRecord::Associations::ClassMethods::JoinDependency.new(join_base, :developers, nil) - projects = Project.send(:select_limited_ids_list, {:order => 'developers.created_at'}, join_dep) - assert !projects.include?("'"), projects - assert_equal %w(1 2), projects.scan(/\d/).sort - end - - def test_scoped_find_on_through_association_doesnt_return_read_only_records - tag = Post.find(1).tags.find_by_name("General") - - assert_nothing_raised do - tag.save! - end - end - - def test_has_many_through_polymorphic_has_manys_works - assert_equal [10, 20].to_set, pirates(:redbeard).treasure_estimates.map(&:price).to_set - end - - def test_symbols_as_keys - developer = DeveloperWithSymbolsForKeys.new(:name => 'David') - project = ProjectWithSymbolsForKeys.new(:name => 'Rails Testing') - project.developers << developer - project.save! - - assert_equal 1, project.developers.size - assert_equal 1, developer.projects.size - assert_equal developer, project.developers.find(:first) - assert_equal project, developer.projects.find(:first) - end - - def test_self_referential_habtm_without_foreign_key_set_should_raise_exception - assert_raise(ActiveRecord::HasAndBelongsToManyAssociationForeignKeyNeeded) { - Member.class_eval do - has_and_belongs_to_many :friends, :class_name => "Member", :join_table => "member_friends" - end - } - end - - def test_dynamic_find_should_respect_association_include - # SQL error in sort clause if :include is not included - # due to Unknown column 'authors.id' - assert Category.find(1).posts_with_authors_sorted_by_author_id.find_by_title('Welcome to the weblog') - end - - def test_counting_on_habtm_association_and_not_array - david = Developer.find(1) - # Extra parameter just to make sure we aren't falling back to - # Array#count in Ruby >=1.8.7, which would raise an ArgumentError - assert_nothing_raised { david.projects.count(:all, :conditions => '1=1') } - end - - def test_count - david = Developer.find(1) - assert_equal 2, david.projects.count - end - - def test_count_with_counter_sql - developer = DeveloperWithCounterSQL.create(:name => 'tekin') - developer.project_ids = [projects(:active_record).id] - developer.save - developer.reload - assert_equal 1, developer.projects.count - end - - def test_association_proxy_transaction_method_starts_transaction_in_association_class - Post.expects(:transaction) - Category.find(:first).posts.transaction do - # nothing - end - end - - def test_caching_of_columns - david = Developer.find(1) - # clear cache possibly created by other tests - david.projects.reset_column_information - assert_queries(0) { david.projects.columns; david.projects.columns } - # and again to verify that reset_column_information clears the cache correctly - david.projects.reset_column_information - assert_queries(0) { david.projects.columns; david.projects.columns } - end - - def test_include_method_in_has_and_belongs_to_many_association_should_return_true_for_instance_added_with_build - project = Project.new - developer = project.developers.build - assert project.developers.include?(developer) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb deleted file mode 100644 index 2f715a46..00000000 --- a/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +++ /dev/null @@ -1,1273 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/category' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/person' -require 'models/reader' -require 'models/tagging' - -class HasManyAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :categories, :companies, :developers, :projects, - :developers_projects, :topics, :authors, :comments, :author_addresses, - :people, :posts, :readers, :taggings - - def setup - Client.destroyed_client_ids.clear - end - - def test_create_by - person = Person.create! :first_name => 'tenderlove' - post = Post.find :first - - assert_equal [], person.readers - assert_nil person.readers.find_by_post_id(post.id) - - reader = person.readers.create_by_post_id post.id - - assert_equal 1, person.readers.count - assert_equal 1, person.readers.length - assert_equal post, person.readers.first.post - assert_equal person, person.readers.first.person - end - - def test_create_by_multi - person = Person.create! :first_name => 'tenderlove' - post = Post.find :first - - assert_equal [], person.readers - - reader = person.readers.create_by_post_id_and_skimmer post.id, false - - assert_equal 1, person.readers.count - assert_equal 1, person.readers.length - assert_equal post, person.readers.first.post - assert_equal person, person.readers.first.person - end - - def test_find_or_create_by - person = Person.create! :first_name => 'tenderlove' - post = Post.find :first - - assert_equal [], person.readers - assert_nil person.readers.find_by_post_id(post.id) - - reader = person.readers.find_or_create_by_post_id post.id - - assert_equal 1, person.readers.count - assert_equal 1, person.readers.length - assert_equal post, person.readers.first.post - assert_equal person, person.readers.first.person - end - - def test_find_or_create_by_with_additional_parameters - post = Post.create! :title => 'test_find_or_create_by_with_additional_parameters', :body => 'this is the body' - comment = post.comments.create! :body => 'test comment body', :type => 'test' - - assert_equal comment, post.comments.find_or_create_by_body('test comment body') - - post.comments.find_or_create_by_body(:body => 'other test comment body', :type => 'test') - assert_equal 2, post.comments.count - assert_equal 2, post.comments.length - post.comments.find_or_create_by_body('other other test comment body', :type => 'test') - assert_equal 3, post.comments.count - assert_equal 3, post.comments.length - post.comments.find_or_create_by_body_and_type('3rd test comment body', 'test') - assert_equal 4, post.comments.count - assert_equal 4, post.comments.length - end - - def test_find_or_create_by_with_same_parameters_creates_a_single_record - author = Author.first - assert_difference "Post.count", +1 do - 2.times do - author.posts.find_or_create_by_body_and_title('one', 'two') - end - end - end - - def test_find_or_create_by_with_block - post = Post.create! :title => 'test_find_or_create_by_with_additional_parameters', :body => 'this is the body' - comment = post.comments.find_or_create_by_body('other test comment body') { |comment| comment.type = 'test' } - assert_equal 'test', comment.type - end - - def test_find_or_create - person = Person.create! :first_name => 'tenderlove' - post = Post.find :first - - assert_equal [], person.readers - assert_nil person.readers.find(:first, :conditions => { - :post_id => post.id - }) - - reader = person.readers.find_or_create :post_id => post.id - - assert_equal 1, person.readers.count - assert_equal 1, person.readers.length - assert_equal post, person.readers.first.post - assert_equal person, person.readers.first.person - end - - - def force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.each {|f| } - end - - def test_counting_with_counter_sql - assert_equal 2, Firm.find(:first).clients.count - end - - def test_counting - assert_equal 2, Firm.find(:first).plain_clients.count - end - - def test_counting_with_empty_hash_conditions - assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => {}) - end - - def test_counting_with_single_conditions - assert_equal 1, Firm.find(:first).plain_clients.count(:conditions => ['name=?', "Microsoft"]) - end - - def test_counting_with_single_hash - assert_equal 1, Firm.find(:first).plain_clients.count(:conditions => {:name => "Microsoft"}) - end - - def test_counting_with_column_name_and_hash - assert_equal 2, Firm.find(:first).plain_clients.count(:name) - end - - def test_counting_with_association_limit - firm = companies(:first_firm) - assert_equal firm.limited_clients.length, firm.limited_clients.size - assert_equal firm.limited_clients.length, firm.limited_clients.count - end - - def test_finding - assert_equal 2, Firm.find(:first).clients.length - end - - def test_find_with_blank_conditions - [[], {}, nil, ""].each do |blank| - assert_equal 2, Firm.find(:first).clients.find(:all, :conditions => blank).size - end - end - - def test_find_many_with_merged_options - assert_equal 1, companies(:first_firm).limited_clients.size - assert_equal 1, companies(:first_firm).limited_clients.find(:all).size - assert_equal 2, companies(:first_firm).limited_clients.find(:all, :limit => nil).size - end - - def test_dynamic_find_last_without_specified_order - assert_equal companies(:second_client), companies(:first_firm).unsorted_clients.find_last_by_type('Client') - end - - def test_dynamic_find_should_respect_association_order - assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.find(:first, :conditions => "type = 'Client'") - assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.find_by_type('Client') - end - - def test_dynamic_find_order_should_override_association_order - assert_equal companies(:first_client), companies(:first_firm).clients_sorted_desc.find(:first, :conditions => "type = 'Client'", :order => 'id') - assert_equal companies(:first_client), companies(:first_firm).clients_sorted_desc.find_by_type('Client', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_order - assert_equal [companies(:second_client), companies(:first_client)], companies(:first_firm).clients_sorted_desc.find(:all, :conditions => "type = 'Client'") - assert_equal [companies(:second_client), companies(:first_client)], companies(:first_firm).clients_sorted_desc.find_all_by_type('Client') - end - - def test_dynamic_find_all_order_should_override_association_order - assert_equal [companies(:first_client), companies(:second_client)], companies(:first_firm).clients_sorted_desc.find(:all, :conditions => "type = 'Client'", :order => 'id') - assert_equal [companies(:first_client), companies(:second_client)], companies(:first_firm).clients_sorted_desc.find_all_by_type('Client', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_limit - assert_equal 1, companies(:first_firm).limited_clients.find(:all, :conditions => "type = 'Client'").length - assert_equal 1, companies(:first_firm).limited_clients.find_all_by_type('Client').length - end - - def test_dynamic_find_all_limit_should_override_association_limit - assert_equal 2, companies(:first_firm).limited_clients.find(:all, :conditions => "type = 'Client'", :limit => 9_000).length - assert_equal 2, companies(:first_firm).limited_clients.find_all_by_type('Client', :limit => 9_000).length - end - - def test_dynamic_find_all_should_respect_readonly_access - companies(:first_firm).readonly_clients.find(:all).each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } - companies(:first_firm).readonly_clients.find(:all).each { |c| assert c.readonly? } - end - - def test_cant_save_has_many_readonly_association - authors(:david).readonly_comments.each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } - authors(:david).readonly_comments.each { |c| assert c.readonly? } - end - - def test_triple_equality - assert !(Array === Firm.find(:first).clients) - assert Firm.find(:first).clients === Array - end - - def test_finding_default_orders - assert_equal "Summit", Firm.find(:first).clients.first.name - end - - def test_finding_with_different_class_name_and_order - assert_equal "Microsoft", Firm.find(:first).clients_sorted_desc.first.name - end - - def test_finding_with_foreign_key - assert_equal "Microsoft", Firm.find(:first).clients_of_firm.first.name - end - - def test_finding_with_condition - assert_equal "Microsoft", Firm.find(:first).clients_like_ms.first.name - end - - def test_finding_with_condition_hash - assert_equal "Microsoft", Firm.find(:first).clients_like_ms_with_hash_conditions.first.name - end - - def test_finding_using_primary_key - assert_equal "Summit", Firm.find(:first).clients_using_primary_key.first.name - end - - def test_finding_using_sql - firm = Firm.find(:first) - first_client = firm.clients_using_sql.first - assert_not_nil first_client - assert_equal "Microsoft", first_client.name - assert_equal 1, firm.clients_using_sql.size - assert_equal 1, Firm.find(:first).clients_using_sql.size - end - - def test_counting_using_sql - assert_equal 1, Firm.find(:first).clients_using_counter_sql.size - assert Firm.find(:first).clients_using_counter_sql.any? - assert_equal 0, Firm.find(:first).clients_using_zero_counter_sql.size - assert !Firm.find(:first).clients_using_zero_counter_sql.any? - end - - def test_counting_non_existant_items_using_sql - assert_equal 0, Firm.find(:first).no_clients_using_counter_sql.size - end - - def test_belongs_to_sanity - c = Client.new - assert_nil c.firm - - if c.firm - assert false, "belongs_to failed if check" - end - - unless c.firm - else - assert false, "belongs_to failed unless check" - end - end - - def test_find_ids - firm = Firm.find(:first) - - assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find } - - client = firm.clients.find(2) - assert_kind_of Client, client - - client_ary = firm.clients.find([2]) - assert_kind_of Array, client_ary - assert_equal client, client_ary.first - - client_ary = firm.clients.find(2, 3) - assert_kind_of Array, client_ary - assert_equal 2, client_ary.size - assert_equal client, client_ary.first - - assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) } - end - - def test_find_string_ids_when_using_finder_sql - firm = Firm.find(:first) - - client = firm.clients_using_finder_sql.find("2") - assert_kind_of Client, client - - client_ary = firm.clients_using_finder_sql.find(["2"]) - assert_kind_of Array, client_ary - assert_equal client, client_ary.first - - client_ary = firm.clients_using_finder_sql.find("2", "3") - assert_kind_of Array, client_ary - assert_equal 2, client_ary.size - assert client_ary.include?(client) - end - - def test_find_all - firm = Firm.find(:first) - assert_equal 2, firm.clients.find(:all, :conditions => "#{QUOTED_TYPE} = 'Client'").length - assert_equal 1, firm.clients.find(:all, :conditions => "name = 'Summit'").length - end - - def test_find_each - firm = companies(:first_firm) - - assert ! firm.clients.loaded? - - assert_queries(3) do - firm.clients.find_each(:batch_size => 1) {|c| assert_equal firm.id, c.firm_id } - end - - assert ! firm.clients.loaded? - end - - def test_find_each_with_conditions - firm = companies(:first_firm) - - assert_queries(2) do - firm.clients.find_each(:batch_size => 1, :conditions => {:name => "Microsoft"}) do |c| - assert_equal firm.id, c.firm_id - assert_equal "Microsoft", c.name - end - end - - assert ! firm.clients.loaded? - end - - def test_find_in_batches - firm = companies(:first_firm) - - assert ! firm.clients.loaded? - - assert_queries(2) do - firm.clients.find_in_batches(:batch_size => 2) do |clients| - clients.each {|c| assert_equal firm.id, c.firm_id } - end - end - - assert ! firm.clients.loaded? - end - - def test_find_all_sanitized - firm = Firm.find(:first) - summit = firm.clients.find(:all, :conditions => "name = 'Summit'") - assert_equal summit, firm.clients.find(:all, :conditions => ["name = ?", "Summit"]) - assert_equal summit, firm.clients.find(:all, :conditions => ["name = :name", { :name => "Summit" }]) - end - - def test_find_first - firm = Firm.find(:first) - client2 = Client.find(2) - assert_equal firm.clients.first, firm.clients.find(:first) - assert_equal client2, firm.clients.find(:first, :conditions => "#{QUOTED_TYPE} = 'Client'") - end - - def test_find_first_sanitized - firm = Firm.find(:first) - client2 = Client.find(2) - assert_equal client2, firm.clients.find(:first, :conditions => ["#{QUOTED_TYPE} = ?", 'Client']) - assert_equal client2, firm.clients.find(:first, :conditions => ["#{QUOTED_TYPE} = :type", { :type => 'Client' }]) - end - - def test_find_all_with_include_and_conditions - assert_nothing_raised do - Developer.find(:all, :joins => :audit_logs, :conditions => {'audit_logs.message' => nil, :name => 'Smith'}) - end - end - - def test_find_in_collection - assert_equal Client.find(2).name, companies(:first_firm).clients.find(2).name - assert_raise(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) } - end - - def test_find_grouped - all_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1") - grouped_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1", :group => "firm_id", :select => 'firm_id, count(id) as clients_count') - assert_equal 2, all_clients_of_firm1.size - assert_equal 1, grouped_clients_of_firm1.size - end - - def test_find_scoped_grouped - assert_equal 1, companies(:first_firm).clients_grouped_by_firm_id.size - assert_equal 1, companies(:first_firm).clients_grouped_by_firm_id.length - assert_equal 2, companies(:first_firm).clients_grouped_by_name.size - assert_equal 2, companies(:first_firm).clients_grouped_by_name.length - end - - def test_find_scoped_grouped_having - assert_equal 1, authors(:david).popular_grouped_posts.length - assert_equal 0, authors(:mary).popular_grouped_posts.length - end - - def test_adding - force_signal37_to_load_all_clients_of_firm - natural = Client.new("name" => "Natural Company") - companies(:first_firm).clients_of_firm << natural - assert_equal 2, companies(:first_firm).clients_of_firm.size # checking via the collection - assert_equal 2, companies(:first_firm).clients_of_firm(true).size # checking using the db - assert_equal natural, companies(:first_firm).clients_of_firm.last - end - - def test_adding_using_create - first_firm = companies(:first_firm) - assert_equal 2, first_firm.plain_clients.size - natural = first_firm.plain_clients.create(:name => "Natural Company") - assert_equal 3, first_firm.plain_clients.length - assert_equal 3, first_firm.plain_clients.size - end - - def test_create_with_bang_on_has_many_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do - firm = Firm.new - firm.plain_clients.create! :name=>"Whoever" - end - end - - def test_regular_create_on_has_many_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do - firm = Firm.new - firm.plain_clients.create :name=>"Whoever" - end - end - - def test_create_with_bang_on_has_many_raises_when_record_not_saved - assert_raise(ActiveRecord::RecordInvalid) do - firm = Firm.find(:first) - firm.plain_clients.create! - end - end - - def test_create_with_bang_on_habtm_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do - Developer.new("name" => "Aredridel").projects.create! - end - end - - def test_adding_a_mismatch_class - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil } - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << 1 } - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << Topic.find(1) } - end - - def test_adding_a_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.concat([Client.new("name" => "Natural Company"), Client.new("name" => "Apple")]) - assert_equal 3, companies(:first_firm).clients_of_firm.size - assert_equal 3, companies(:first_firm).clients_of_firm(true).size - end - - def test_build - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build("name" => "Another Client") } - assert !company.clients_of_firm.loaded? - - assert_equal "Another Client", new_client.name - assert new_client.new_record? - assert_equal new_client, company.clients_of_firm.last - end - - def test_collection_size_after_building - company = companies(:first_firm) # company already has one client - company.clients_of_firm.build("name" => "Another Client") - company.clients_of_firm.build("name" => "Yet Another Client") - assert_equal 3, company.clients_of_firm.size - end - - def test_collection_size_twice_for_regressions - post = posts(:thinking) - assert_equal 0, post.readers.size - # This test needs a post that has no readers, we assert it to ensure it holds, - # but need to reload the post because the very call to #size hides the bug. - post.reload - post.readers.build - size1 = post.readers.size - size2 = post.readers.size - assert_equal size1, size2 - end - - def test_build_many - company = companies(:first_firm) - new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } - assert_equal 2, new_clients.size - end - - def test_build_followed_by_save_does_not_load_target - new_client = companies(:first_firm).clients_of_firm.build("name" => "Another Client") - assert companies(:first_firm).save - assert !companies(:first_firm).clients_of_firm.loaded? - end - - def test_build_without_loading_association - first_topic = topics(:first) - Reply.column_names - - assert_equal 1, first_topic.replies.length - - assert_no_queries do - first_topic.replies.build(:title => "Not saved", :content => "Superstars") - assert_equal 2, first_topic.replies.size - end - - assert_equal 2, first_topic.replies.to_ary.size - end - - def test_build_via_block - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build {|client| client.name = "Another Client" } } - assert !company.clients_of_firm.loaded? - - assert_equal "Another Client", new_client.name - assert new_client.new_record? - assert_equal new_client, company.clients_of_firm.last - end - - def test_build_many_via_block - company = companies(:first_firm) - new_clients = assert_no_queries do - company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) do |client| - client.name = "changed" - end - end - - assert_equal 2, new_clients.size - assert_equal "changed", new_clients.first.name - assert_equal "changed", new_clients.last.name - end - - def test_create_without_loading_association - first_firm = companies(:first_firm) - Firm.column_names - Client.column_names - - assert_equal 1, first_firm.clients_of_firm.size - first_firm.clients_of_firm.reset - - assert_queries(1) do - first_firm.clients_of_firm.create(:name => "Superstars") - end - - assert_equal 2, first_firm.clients_of_firm.size - end - - def test_create - force_signal37_to_load_all_clients_of_firm - new_client = companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert !new_client.new_record? - assert_equal new_client, companies(:first_firm).clients_of_firm.last - assert_equal new_client, companies(:first_firm).clients_of_firm(true).last - end - - def test_create_many - companies(:first_firm).clients_of_firm.create([{"name" => "Another Client"}, {"name" => "Another Client II"}]) - assert_equal 3, companies(:first_firm).clients_of_firm(true).size - end - - def test_create_followed_by_save_does_not_load_target - new_client = companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert companies(:first_firm).save - assert !companies(:first_firm).clients_of_firm.loaded? - end - - def test_find_or_initialize - the_client = companies(:first_firm).clients.find_or_initialize_by_name("Yet another client") - assert_equal companies(:first_firm).id, the_client.firm_id - assert_equal "Yet another client", the_client.name - assert the_client.new_record? - end - - def test_find_or_create_updates_size - number_of_clients = companies(:first_firm).clients.size - the_client = companies(:first_firm).clients.find_or_create_by_name("Yet another client") - assert_equal number_of_clients + 1, companies(:first_firm, :reload).clients.size - assert_equal the_client, companies(:first_firm).clients.find_or_create_by_name("Yet another client") - assert_equal number_of_clients + 1, companies(:first_firm, :reload).clients.size - end - - def test_deleting - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.delete(companies(:first_firm).clients_of_firm.first) - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_deleting_before_save - new_firm = Firm.new("name" => "A New Firm, Inc.") - new_client = new_firm.clients_of_firm.build("name" => "Another Client") - assert_equal 1, new_firm.clients_of_firm.size - new_firm.clients_of_firm.delete(new_client) - assert_equal 0, new_firm.clients_of_firm.size - end - - def test_deleting_updates_counter_cache - topic = Topic.first - assert_equal topic.replies.to_a.size, topic.replies_count - - topic.replies.delete(topic.replies.first) - topic.reload - assert_equal topic.replies.to_a.size, topic.replies_count - end - - def test_deleting_updates_counter_cache_without_dependent_destroy - post = posts(:welcome) - - assert_difference "post.reload.taggings_count", -1 do - post.taggings.delete(post.taggings.first) - end - end - - def test_deleting_a_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - companies(:first_firm).clients_of_firm.delete([companies(:first_firm).clients_of_firm[0], companies(:first_firm).clients_of_firm[1]]) - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_delete_all - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - companies(:first_firm).clients_of_firm.delete_all - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_delete_all_with_not_yet_loaded_association_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - companies(:first_firm).clients_of_firm.reset - companies(:first_firm).clients_of_firm.delete_all - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_clearing_an_association_collection - firm = companies(:first_firm) - client_id = firm.clients_of_firm.first.id - assert_equal 1, firm.clients_of_firm.size - - firm.clients_of_firm.clear - - assert_equal 0, firm.clients_of_firm.size - assert_equal 0, firm.clients_of_firm(true).size - assert_equal [], Client.destroyed_client_ids[firm.id] - - # Should not be destroyed since the association is not dependent. - assert_nothing_raised do - assert Client.find(client_id).firm.nil? - end - end - - def test_clearing_updates_counter_cache - topic = Topic.first - - topic.replies.clear - topic.reload - assert_equal 0, topic.replies_count - end - - def test_clearing_a_dependent_association_collection - firm = companies(:first_firm) - client_id = firm.dependent_clients_of_firm.first.id - assert_equal 1, firm.dependent_clients_of_firm.size - - # :dependent means destroy is called on each client - firm.dependent_clients_of_firm.clear - - assert_equal 0, firm.dependent_clients_of_firm.size - assert_equal 0, firm.dependent_clients_of_firm(true).size - assert_equal [client_id], Client.destroyed_client_ids[firm.id] - - # Should be destroyed since the association is dependent. - assert Client.find_by_id(client_id).nil? - end - - def test_clearing_an_exclusively_dependent_association_collection - firm = companies(:first_firm) - client_id = firm.exclusively_dependent_clients_of_firm.first.id - assert_equal 1, firm.exclusively_dependent_clients_of_firm.size - - assert_equal [], Client.destroyed_client_ids[firm.id] - - # :exclusively_dependent means each client is deleted directly from - # the database without looping through them calling destroy. - firm.exclusively_dependent_clients_of_firm.clear - - assert_equal 0, firm.exclusively_dependent_clients_of_firm.size - assert_equal 0, firm.exclusively_dependent_clients_of_firm(true).size - # no destroy-filters should have been called - assert_equal [], Client.destroyed_client_ids[firm.id] - - # Should be destroyed since the association is exclusively dependent. - assert Client.find_by_id(client_id).nil? - end - - def test_dependent_association_respects_optional_conditions_on_delete - firm = companies(:odegy) - Client.create(:client_of => firm.id, :name => "BigShot Inc.") - Client.create(:client_of => firm.id, :name => "SmallTime Inc.") - # only one of two clients is included in the association due to the :conditions key - assert_equal 2, Client.find_all_by_client_of(firm.id).size - assert_equal 1, firm.dependent_conditional_clients_of_firm.size - firm.destroy - # only the correctly associated client should have been deleted - assert_equal 1, Client.find_all_by_client_of(firm.id).size - end - - def test_dependent_association_respects_optional_sanitized_conditions_on_delete - firm = companies(:odegy) - Client.create(:client_of => firm.id, :name => "BigShot Inc.") - Client.create(:client_of => firm.id, :name => "SmallTime Inc.") - # only one of two clients is included in the association due to the :conditions key - assert_equal 2, Client.find_all_by_client_of(firm.id).size - assert_equal 1, firm.dependent_sanitized_conditional_clients_of_firm.size - firm.destroy - # only the correctly associated client should have been deleted - assert_equal 1, Client.find_all_by_client_of(firm.id).size - end - - def test_dependent_association_respects_optional_hash_conditions_on_delete - firm = companies(:odegy) - Client.create(:client_of => firm.id, :name => "BigShot Inc.") - Client.create(:client_of => firm.id, :name => "SmallTime Inc.") - # only one of two clients is included in the association due to the :conditions key - assert_equal 2, Client.find_all_by_client_of(firm.id).size - assert_equal 1, firm.dependent_sanitized_conditional_clients_of_firm.size - firm.destroy - # only the correctly associated client should have been deleted - assert_equal 1, Client.find_all_by_client_of(firm.id).size - end - - def test_delete_all_association_with_primary_key_deletes_correct_records - firm = Firm.find(:first) - # break the vanilla firm_id foreign key - assert_equal 2, firm.clients.count - firm.clients.first.update_attribute(:firm_id, nil) - assert_equal 1, firm.clients(true).count - assert_equal 1, firm.clients_using_primary_key_with_delete_all.count - old_record = firm.clients_using_primary_key_with_delete_all.first - firm = Firm.find(:first) - firm.destroy - assert Client.find_by_id(old_record.id).nil? - end - - def test_creation_respects_hash_condition - ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.build - - assert ms_client.save - assert_equal 'Microsoft', ms_client.name - - another_ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.create - - assert !another_ms_client.new_record? - assert_equal 'Microsoft', another_ms_client.name - end - - def test_dependent_delete_and_destroy_with_belongs_to - author_address = author_addresses(:david_address) - assert_equal [], AuthorAddress.destroyed_author_address_ids[authors(:david).id] - - assert_difference "AuthorAddress.count", -2 do - authors(:david).destroy - end - - assert_equal nil, AuthorAddress.find_by_id(authors(:david).author_address_id) - assert_equal nil, AuthorAddress.find_by_id(authors(:david).author_address_extra_id) - end - - def test_invalid_belongs_to_dependent_option_raises_exception - assert_raise ArgumentError do - Author.belongs_to :special_author_address, :dependent => :nullify - end - end - - def test_clearing_without_initial_access - firm = companies(:first_firm) - - firm.clients_of_firm.clear - - assert_equal 0, firm.clients_of_firm.size - assert_equal 0, firm.clients_of_firm(true).size - end - - def test_deleting_a_item_which_is_not_in_the_collection - force_signal37_to_load_all_clients_of_firm - summit = Client.find_by_name('Summit') - companies(:first_firm).clients_of_firm.delete(summit) - assert_equal 1, companies(:first_firm).clients_of_firm.size - assert_equal 1, companies(:first_firm).clients_of_firm(true).size - assert_equal 2, summit.client_of - end - - def test_deleting_type_mismatch - david = Developer.find(1) - david.projects.reload - assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) } - end - - def test_deleting_self_type_mismatch - david = Developer.find(1) - david.projects.reload - assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) } - end - - def test_destroying - force_signal37_to_load_all_clients_of_firm - - assert_difference "Client.count", -1 do - companies(:first_firm).clients_of_firm.destroy(companies(:first_firm).clients_of_firm.first) - end - - assert_equal 0, companies(:first_firm).reload.clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_destroying_by_fixnum_id - force_signal37_to_load_all_clients_of_firm - - assert_difference "Client.count", -1 do - companies(:first_firm).clients_of_firm.destroy(companies(:first_firm).clients_of_firm.first.id) - end - - assert_equal 0, companies(:first_firm).reload.clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_destroying_by_string_id - force_signal37_to_load_all_clients_of_firm - - assert_difference "Client.count", -1 do - companies(:first_firm).clients_of_firm.destroy(companies(:first_firm).clients_of_firm.first.id.to_s) - end - - assert_equal 0, companies(:first_firm).reload.clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_destroying_a_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - - assert_difference "Client.count", -2 do - companies(:first_firm).clients_of_firm.destroy([companies(:first_firm).clients_of_firm[0], companies(:first_firm).clients_of_firm[1]]) - end - - assert_equal 0, companies(:first_firm).reload.clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_destroy_all - force_signal37_to_load_all_clients_of_firm - clients = companies(:first_firm).clients_of_firm.to_a - assert !clients.empty?, "37signals has clients after load" - destroyed = companies(:first_firm).clients_of_firm.destroy_all - assert_equal clients.sort_by(&:id), destroyed.sort_by(&:id) - assert destroyed.all? { |client| client.frozen? }, "destroyed clients should be frozen" - assert companies(:first_firm).clients_of_firm.empty?, "37signals has no clients after destroy all" - assert companies(:first_firm).clients_of_firm(true).empty?, "37signals has no clients after destroy all and refresh" - end - - def test_destroy_all_with_creates_and_scope_that_doesnt_match_created_records - company = companies(:first_firm) - unloaded_client_matching_scope = companies(:second_client) - created_client_matching_scope = company.clients_of_firm.create!(:name => "Somesoft") - created_client_not_matching_scope = company.clients_of_firm.create!(:name => "OtherCo") - destroyed = company.clients_of_firm.with_oft_in_name.destroy_all - assert destroyed.include?(unloaded_client_matching_scope), "unloaded clients matching the scope destroy_all on should have been destroyed" - assert destroyed.include?(created_client_matching_scope), "loaded clients matching the scope destroy_all on should have been destroyed" - assert !destroyed.include?(created_client_not_matching_scope), "loaded clients not matching the scope destroy_all on should not have been destroyed" - end - - def test_dependence - firm = companies(:first_firm) - assert_equal 2, firm.clients.size - firm.destroy - assert Client.find(:all, :conditions => "firm_id=#{firm.id}").empty? - end - - def test_dependence_for_associations_with_hash_condition - david = authors(:david) - post = posts(:thinking).id - assert_difference('Post.count', -1) { assert david.destroy } - end - - def test_destroy_dependent_when_deleted_from_association - firm = Firm.find(:first) - assert_equal 2, firm.clients.size - - client = firm.clients.first - firm.clients.delete(client) - - assert_raise(ActiveRecord::RecordNotFound) { Client.find(client.id) } - assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(client.id) } - assert_equal 1, firm.clients.size - end - - def test_three_levels_of_dependence - topic = Topic.create "title" => "neat and simple" - reply = topic.replies.create "title" => "neat and simple", "content" => "still digging it" - silly_reply = reply.replies.create "title" => "neat and simple", "content" => "ain't complaining" - - assert_nothing_raised { topic.destroy } - end - - uses_transaction :test_dependence_with_transaction_support_on_failure - def test_dependence_with_transaction_support_on_failure - firm = companies(:first_firm) - clients = firm.clients - assert_equal 2, clients.length - clients.last.instance_eval { def before_destroy() raise "Trigger rollback" end } - - firm.destroy rescue "do nothing" - - assert_equal 2, Client.find(:all, :conditions => "firm_id=#{firm.id}").size - end - - def test_dependence_on_account - num_accounts = Account.count - companies(:first_firm).destroy - assert_equal num_accounts - 1, Account.count - end - - def test_depends_and_nullify - num_accounts = Account.count - num_companies = Company.count - - core = companies(:rails_core) - assert_equal accounts(:rails_core_account), core.account - assert_equal companies(:leetsoft, :jadedpixel), core.companies - core.destroy - assert_nil accounts(:rails_core_account).reload.firm_id - assert_nil companies(:leetsoft).reload.client_of - assert_nil companies(:jadedpixel).reload.client_of - - - assert_equal num_accounts, Account.count - end - - def test_included_in_collection - assert companies(:first_firm).clients.include?(Client.find(2)) - end - - def test_adding_array_and_collection - assert_nothing_raised { Firm.find(:first).clients + Firm.find(:all).last.clients } - end - - def test_find_all_without_conditions - firm = companies(:first_firm) - assert_equal 2, firm.clients.find(:all).length - end - - def test_replace_with_less - firm = Firm.find(:first) - firm.clients = [companies(:first_client)] - assert firm.save, "Could not save firm" - firm.reload - assert_equal 1, firm.clients.length - end - - def test_replace_with_less_and_dependent_nullify - num_companies = Company.count - companies(:rails_core).companies = [] - assert_equal num_companies, Company.count - end - - def test_replace_with_new - firm = Firm.find(:first) - firm.clients = [companies(:second_client), Client.new("name" => "New Client")] - firm.save - firm.reload - assert_equal 2, firm.clients.length - assert !firm.clients.include?(:first_client) - end - - def test_get_ids - assert_equal [companies(:first_client).id, companies(:second_client).id], companies(:first_firm).client_ids - end - - def test_get_ids_for_loaded_associations - company = companies(:first_firm) - company.clients(true) - assert_queries(0) do - company.client_ids - company.client_ids - end - end - - def test_get_ids_for_unloaded_associations_does_not_load_them - company = companies(:first_firm) - assert !company.clients.loaded? - assert_equal [companies(:first_client).id, companies(:second_client).id], company.client_ids - assert !company.clients.loaded? - end - - def test_get_ids_for_unloaded_finder_sql_associations_loads_them - company = companies(:first_firm) - assert !company.clients_using_sql.loaded? - assert_equal [companies(:second_client).id], company.clients_using_sql_ids - assert company.clients_using_sql.loaded? - end - - def test_assign_ids_ignoring_blanks - firm = Firm.create!(:name => 'Apple') - firm.client_ids = [companies(:first_client).id, nil, companies(:second_client).id, ''] - firm.save! - - assert_equal 2, firm.clients(true).size - assert firm.clients.include?(companies(:second_client)) - end - - def test_get_ids_for_through - assert_equal [comments(:eager_other_comment1).id], authors(:mary).comment_ids - end - - def test_modifying_a_through_a_has_many_should_raise - [ - lambda { authors(:mary).comment_ids = [comments(:greetings).id, comments(:more_greetings).id] }, - lambda { authors(:mary).comments = [comments(:greetings), comments(:more_greetings)] }, - lambda { authors(:mary).comments << Comment.create!(:body => "Yay", :post_id => 424242) }, - lambda { authors(:mary).comments.delete(authors(:mary).comments.first) }, - ].each {|block| assert_raise(ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection, &block) } - end - - def test_dynamic_find_should_respect_association_order_for_through - assert_equal Comment.find(10), authors(:david).comments_desc.find(:first, :conditions => "comments.type = 'SpecialComment'") - assert_equal Comment.find(10), authors(:david).comments_desc.find_by_type('SpecialComment') - end - - def test_dynamic_find_order_should_override_association_order_for_through - assert_equal Comment.find(3), authors(:david).comments_desc.find(:first, :conditions => "comments.type = 'SpecialComment'", :order => 'comments.id') - assert_equal Comment.find(3), authors(:david).comments_desc.find_by_type('SpecialComment', :order => 'comments.id') - end - - def test_dynamic_find_all_should_respect_association_order_for_through - assert_equal [Comment.find(10), Comment.find(7), Comment.find(6), Comment.find(3)], authors(:david).comments_desc.find(:all, :conditions => "comments.type = 'SpecialComment'") - assert_equal [Comment.find(10), Comment.find(7), Comment.find(6), Comment.find(3)], authors(:david).comments_desc.find_all_by_type('SpecialComment') - end - - def test_dynamic_find_all_order_should_override_association_order_for_through - assert_equal [Comment.find(3), Comment.find(6), Comment.find(7), Comment.find(10)], authors(:david).comments_desc.find(:all, :conditions => "comments.type = 'SpecialComment'", :order => 'comments.id') - assert_equal [Comment.find(3), Comment.find(6), Comment.find(7), Comment.find(10)], authors(:david).comments_desc.find_all_by_type('SpecialComment', :order => 'comments.id') - end - - def test_dynamic_find_all_should_respect_association_limit_for_through - assert_equal 1, authors(:david).limited_comments.find(:all, :conditions => "comments.type = 'SpecialComment'").length - assert_equal 1, authors(:david).limited_comments.find_all_by_type('SpecialComment').length - end - - def test_dynamic_find_all_order_should_override_association_limit_for_through - assert_equal 4, authors(:david).limited_comments.find(:all, :conditions => "comments.type = 'SpecialComment'", :limit => 9_000).length - assert_equal 4, authors(:david).limited_comments.find_all_by_type('SpecialComment', :limit => 9_000).length - end - - def test_find_all_include_over_the_same_table_for_through - assert_equal 2, people(:michael).posts.find(:all, :include => :people).length - end - - def test_has_many_through_respects_hash_conditions - assert_equal authors(:david).hello_posts, authors(:david).hello_posts_with_hash_conditions - assert_equal authors(:david).hello_post_comments, authors(:david).hello_post_comments_with_hash_conditions - end - - def test_include_uses_array_include_after_loaded - firm = companies(:first_firm) - firm.clients.class # force load target - - client = firm.clients.first - - assert_no_queries do - assert firm.clients.loaded? - assert firm.clients.include?(client) - end - end - - def test_include_checks_if_record_exists_if_target_not_loaded - firm = companies(:first_firm) - client = firm.clients.first - - firm.reload - assert ! firm.clients.loaded? - assert_queries(1) do - assert firm.clients.include?(client) - end - assert ! firm.clients.loaded? - end - - def test_include_loads_collection_if_target_uses_finder_sql - firm = companies(:first_firm) - client = firm.clients_using_sql.first - - firm.reload - assert ! firm.clients_using_sql.loaded? - assert firm.clients_using_sql.include?(client) - assert firm.clients_using_sql.loaded? - end - - - def test_include_returns_false_for_non_matching_record_to_verify_scoping - firm = companies(:first_firm) - client = Client.create!(:name => 'Not Associated') - - assert ! firm.clients.loaded? - assert ! firm.clients.include?(client) - end - - def test_calling_first_or_last_on_association_should_not_load_association - firm = companies(:first_firm) - firm.clients.first - firm.clients.last - assert !firm.clients.loaded? - end - - def test_calling_first_or_last_on_loaded_association_should_not_fetch_with_query - firm = companies(:first_firm) - firm.clients.class # force load target - assert firm.clients.loaded? - - assert_no_queries do - firm.clients.first - assert_equal 2, firm.clients.first(2).size - firm.clients.last - assert_equal 2, firm.clients.last(2).size - end - end - - def test_calling_first_or_last_on_existing_record_with_build_should_load_association - firm = companies(:first_firm) - firm.clients.build(:name => 'Foo') - assert !firm.clients.loaded? - - assert_queries 1 do - firm.clients.first - firm.clients.last - end - - assert firm.clients.loaded? - end - - def test_calling_first_or_last_on_existing_record_with_create_should_not_load_association - firm = companies(:first_firm) - firm.clients.create(:name => 'Foo') - assert !firm.clients.loaded? - - assert_queries 2 do - firm.clients.first - firm.clients.last - end - - assert !firm.clients.loaded? - end - - def test_calling_first_or_last_on_new_record_should_not_run_queries - firm = Firm.new - - assert_no_queries do - firm.clients.first - firm.clients.last - end - end - - def test_calling_first_or_last_with_find_options_on_loaded_association_should_fetch_with_query - firm = companies(:first_firm) - firm.clients.class # force load target - - assert_queries 2 do - assert firm.clients.loaded? - firm.clients.first(:order => 'name') - firm.clients.last(:order => 'name') - end - end - - def test_calling_first_or_last_with_integer_on_association_should_load_association - firm = companies(:first_firm) - - assert_queries 1 do - firm.clients.first(2) - firm.clients.last(2) - end - - assert firm.clients.loaded? - end - - def test_joins_with_namespaced_model_should_use_correct_type - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - - firm = Namespaced::Firm.create({ :name => 'Some Company' }) - firm.clients.create({ :name => 'Some Client' }) - - stats = Namespaced::Firm.find(firm.id, { - :select => "#{Namespaced::Firm.table_name}.id, COUNT(#{Namespaced::Client.table_name}.id) AS num_clients", - :joins => :clients, - :group => "#{Namespaced::Firm.table_name}.id" - }) - assert_equal 1, stats.num_clients.to_i - - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_association_proxy_transaction_method_starts_transaction_in_association_class - Comment.expects(:transaction) - Post.find(:first).comments.transaction do - # nothing - end - end - - def test_sending_new_to_association_proxy_should_have_same_effect_as_calling_new - client_association = companies(:first_firm).clients - assert_equal client_association.new.attributes, client_association.send(:new).attributes - end - - def test_respond_to_private_class_methods - client_association = companies(:first_firm).clients - assert !client_association.respond_to?(:private_method) - assert client_association.respond_to?(:private_method, true) - end - - def test_creating_using_primary_key - firm = Firm.find(:first) - client = firm.clients_using_primary_key.create!(:name => 'test') - assert_equal firm.name, client.firm_name - end - - def test_normal_method_call_in_association_proxy - assert_equal 'Welcome to the weblog', Comment.all.map { |comment| comment.post }.sort_by(&:id).first.title - end - - def test_instance_eval_in_association_proxy - assert_equal 'Welcome to the weblog', Comment.all.map { |comment| comment.post }.sort_by(&:id).first.instance_eval{title} - end - - def test_defining_has_many_association_with_delete_all_dependency_lazily_evaluates_target_class - ActiveRecord::Reflection::AssociationReflection.any_instance.expects(:class_name).never - class_eval <<-EOF - class DeleteAllModel < ActiveRecord::Base - has_many :nonentities, :dependent => :delete_all - end - EOF - end - - def test_defining_has_many_association_with_nullify_dependency_lazily_evaluates_target_class - ActiveRecord::Reflection::AssociationReflection.any_instance.expects(:class_name).never - class_eval <<-EOF - class NullifyModel < ActiveRecord::Base - has_many :nonentities, :dependent => :nullify - end - EOF - end - - def test_include_method_in_has_many_association_should_return_true_for_instance_added_with_build - post = Post.new - comment = post.comments.build - assert post.comments.include?(comment) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb deleted file mode 100644 index cc7e6dbe..00000000 --- a/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ /dev/null @@ -1,360 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/person' -require 'models/reference' -require 'models/job' -require 'models/reader' -require 'models/comment' -require 'models/tag' -require 'models/tagging' -require 'models/author' -require 'models/owner' -require 'models/pet' -require 'models/toy' -require 'models/contract' -require 'models/company' -require 'models/developer' - -class HasManyThroughAssociationsTest < ActiveRecord::TestCase - fixtures :posts, :readers, :people, :comments, :authors, :owners, :pets, :toys, - :companies - - def test_associate_existing - assert_queries(2) { posts(:thinking);people(:david) } - - posts(:thinking).people - - assert_queries(1) do - posts(:thinking).people << people(:david) - end - - assert_queries(1) do - assert posts(:thinking).people.include?(people(:david)) - end - - assert posts(:thinking).reload.people(true).include?(people(:david)) - end - - def test_associating_new - assert_queries(1) { posts(:thinking) } - new_person = nil # so block binding catches it - - assert_queries(0) do - new_person = Person.new :first_name => 'bob' - end - - # Associating new records always saves them - # Thus, 1 query for the new person record, 1 query for the new join table record - assert_queries(2) do - posts(:thinking).people << new_person - end - - assert_queries(1) do - assert posts(:thinking).people.include?(new_person) - end - - assert posts(:thinking).reload.people(true).include?(new_person) - end - - def test_associate_new_by_building - assert_queries(1) { posts(:thinking) } - - assert_queries(0) do - posts(:thinking).people.build(:first_name=>"Bob") - posts(:thinking).people.new(:first_name=>"Ted") - end - - # Should only need to load the association once - assert_queries(1) do - assert posts(:thinking).people.collect(&:first_name).include?("Bob") - assert posts(:thinking).people.collect(&:first_name).include?("Ted") - end - - # 2 queries for each new record (1 to save the record itself, 1 for the join model) - # * 2 new records = 4 - # + 1 query to save the actual post = 5 - assert_queries(5) do - posts(:thinking).body += '-changed' - posts(:thinking).save - end - - assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Bob") - assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Ted") - end - - def test_delete_association - assert_queries(2){posts(:welcome);people(:michael); } - - assert_queries(1) do - posts(:welcome).people.delete(people(:michael)) - end - - assert_queries(1) do - assert posts(:welcome).people.empty? - end - - assert posts(:welcome).reload.people(true).empty? - end - - def test_destroy_association - assert_difference "Person.count", -1 do - posts(:welcome).people.destroy(people(:michael)) - end - - assert posts(:welcome).reload.people.empty? - assert posts(:welcome).people(true).empty? - end - - def test_destroy_all - assert_difference "Person.count", -1 do - posts(:welcome).people.destroy_all - end - - assert posts(:welcome).reload.people.empty? - assert posts(:welcome).people(true).empty? - end - - def test_replace_association - assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)} - - # 1 query to delete the existing reader (michael) - # 1 query to associate the new reader (david) - assert_queries(2) do - posts(:welcome).people = [people(:david)] - end - - assert_queries(0){ - assert posts(:welcome).people.include?(people(:david)) - assert !posts(:welcome).people.include?(people(:michael)) - } - - assert posts(:welcome).reload.people(true).include?(people(:david)) - assert !posts(:welcome).reload.people(true).include?(people(:michael)) - end - - def test_replace_order_is_preserved - posts(:welcome).people.clear - posts(:welcome).people = [people(:david), people(:michael)] - assert_equal [people(:david).id, people(:michael).id], posts(:welcome).readers.all(:order => 'id').map(&:person_id) - - # Test the inverse order in case the first success was a coincidence - posts(:welcome).people.clear - posts(:welcome).people = [people(:michael), people(:david)] - assert_equal [people(:michael).id, people(:david).id], posts(:welcome).readers.all(:order => 'id').map(&:person_id) - end - - def test_replace_by_id_order_is_preserved - posts(:welcome).people.clear - posts(:welcome).person_ids = [people(:david).id, people(:michael).id] - assert_equal [people(:david).id, people(:michael).id], posts(:welcome).readers.all(:order => 'id').map(&:person_id) - - # Test the inverse order in case the first success was a coincidence - posts(:welcome).people.clear - posts(:welcome).person_ids = [people(:michael).id, people(:david).id] - assert_equal [people(:michael).id, people(:david).id], posts(:welcome).readers.all(:order => 'id').map(&:person_id) - end - - def test_associate_with_create - assert_queries(1) { posts(:thinking) } - - # 1 query for the new record, 1 for the join table record - # No need to update the actual collection yet! - assert_queries(2) do - posts(:thinking).people.create(:first_name=>"Jeb") - end - - # *Now* we actually need the collection so it's loaded - assert_queries(1) do - assert posts(:thinking).people.collect(&:first_name).include?("Jeb") - end - - assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Jeb") - end - - def test_associate_with_create_and_no_options - peeps = posts(:thinking).people.count - posts(:thinking).people.create(:first_name => 'foo') - assert_equal peeps + 1, posts(:thinking).people.count - end - - def test_associate_with_create_exclamation_and_no_options - peeps = posts(:thinking).people.count - posts(:thinking).people.create!(:first_name => 'foo') - assert_equal peeps + 1, posts(:thinking).people.count - end - - def test_associate_with_create_and_invalid_options - peeps = companies(:first_firm).developers.count - assert_nothing_raised { companies(:first_firm).developers.create(:name => '0') } - assert_equal peeps, companies(:first_firm).developers.count - end - - def test_associate_with_create_and_valid_options - peeps = companies(:first_firm).developers.count - assert_nothing_raised { companies(:first_firm).developers.create(:name => 'developer') } - assert_equal peeps + 1, companies(:first_firm).developers.count - end - - def test_associate_with_create_bang_and_invalid_options - peeps = companies(:first_firm).developers.count - assert_raises(ActiveRecord::RecordInvalid) { companies(:first_firm).developers.create!(:name => '0') } - assert_equal peeps, companies(:first_firm).developers.count - end - - def test_associate_with_create_bang_and_valid_options - peeps = companies(:first_firm).developers.count - assert_nothing_raised { companies(:first_firm).developers.create!(:name => 'developer') } - assert_equal peeps + 1, companies(:first_firm).developers.count - end - - def test_clear_associations - assert_queries(2) { posts(:welcome);posts(:welcome).people(true) } - - assert_queries(1) do - posts(:welcome).people.clear - end - - assert_queries(0) do - assert posts(:welcome).people.empty? - end - - assert posts(:welcome).reload.people(true).empty? - end - - def test_association_callback_ordering - Post.reset_log - log = Post.log - post = posts(:thinking) - - post.people_with_callbacks << people(:michael) - assert_equal [ - [:added, :before, "Michael"], - [:added, :after, "Michael"] - ], log.last(2) - - post.people_with_callbacks.push(people(:david), Person.create!(:first_name => "Bob"), Person.new(:first_name => "Lary")) - assert_equal [ - [:added, :before, "David"], - [:added, :after, "David"], - [:added, :before, "Bob"], - [:added, :after, "Bob"], - [:added, :before, "Lary"], - [:added, :after, "Lary"] - ],log.last(6) - - post.people_with_callbacks.build(:first_name => "Ted") - assert_equal [ - [:added, :before, "Ted"], - [:added, :after, "Ted"] - ], log.last(2) - - post.people_with_callbacks.create(:first_name => "Sam") - assert_equal [ - [:added, :before, "Sam"], - [:added, :after, "Sam"] - ], log.last(2) - - post.people_with_callbacks = [people(:michael),people(:david), Person.new(:first_name => "Julian"), Person.create!(:first_name => "Roger")] - assert_equal (%w(Ted Bob Sam Lary) * 2).sort, log[-12..-5].collect(&:last).sort - assert_equal [ - [:added, :before, "Julian"], - [:added, :after, "Julian"], - [:added, :before, "Roger"], - [:added, :after, "Roger"] - ], log.last(4) - - post.people_with_callbacks.clear - assert_equal (%w(Michael David Julian Roger) * 2).sort, log.last(8).collect(&:last).sort - end - - def test_dynamic_find_should_respect_association_include - # SQL error in sort clause if :include is not included - # due to Unknown column 'comments.id' - assert Person.find(1).posts_with_comments_sorted_by_comment_id.find_by_title('Welcome to the weblog') - end - - def test_count_with_include_should_alias_join_table - assert_equal 2, people(:michael).posts.count(:include => :readers) - end - - def test_inner_join_with_quoted_table_name - assert_equal 2, people(:michael).jobs.size - end - - def test_get_ids - assert_equal [posts(:welcome).id, posts(:authorless).id].sort, people(:michael).post_ids.sort - end - - def test_get_ids_for_loaded_associations - person = people(:michael) - person.posts(true) - assert_queries(0) do - person.post_ids - person.post_ids - end - end - - def test_get_ids_for_unloaded_associations_does_not_load_them - person = people(:michael) - assert !person.posts.loaded? - assert_equal [posts(:welcome).id, posts(:authorless).id].sort, person.post_ids.sort - assert !person.posts.loaded? - end - - def test_association_proxy_transaction_method_starts_transaction_in_association_class - Tag.expects(:transaction) - Post.find(:first).tags.transaction do - # nothing - end - end - - def test_has_many_association_through_a_belongs_to_association_where_the_association_doesnt_exist - author = authors(:mary) - post = Post.create!(:title => "TITLE", :body => "BODY") - assert_equal [], post.author_favorites - end - - def test_has_many_association_through_a_belongs_to_association - author = authors(:mary) - post = Post.create!(:author => author, :title => "TITLE", :body => "BODY") - author.author_favorites.create(:favorite_author_id => 1) - author.author_favorites.create(:favorite_author_id => 2) - author.author_favorites.create(:favorite_author_id => 3) - assert_equal post.author.author_favorites, post.author_favorites - end - - def test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys - assert_equal 1, owners(:blackbeard).toys.count - end - - def test_find_on_has_many_association_collection_with_include_and_conditions - post_with_no_comments = people(:michael).posts_with_no_comments.first - assert_equal post_with_no_comments, posts(:authorless) - end - - def test_has_many_through_has_one_reflection - assert_equal [comments(:eager_sti_on_associations_vs_comment)], authors(:david).very_special_comments - end - - def test_modifying_has_many_through_has_one_reflection_should_raise - [ - lambda { authors(:david).very_special_comments = [VerySpecialComment.create!(:body => "Gorp!", :post_id => 1011), VerySpecialComment.create!(:body => "Eep!", :post_id => 1012)] }, - lambda { authors(:david).very_special_comments << VerySpecialComment.create!(:body => "Hoohah!", :post_id => 1013) }, - lambda { authors(:david).very_special_comments.delete(authors(:david).very_special_comments.first) }, - ].each {|block| assert_raise(ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection, &block) } - end - - def test_include_method_in_association_through_should_return_true_for_instance_added_with_build - person = Person.new - reference = person.references.build - job = reference.build_job - assert person.jobs.include?(job) - end - - def test_include_method_in_association_through_should_return_true_for_instance_added_with_nested_builds - author = Author.new - post = author.posts.build - comment = post.comments.build - assert author.comments.include?(comment) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb deleted file mode 100644 index 69954af7..00000000 --- a/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb +++ /dev/null @@ -1,330 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' - -class HasOneAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :developers, :projects, :developers_projects - - def setup - Account.destroyed_account_ids.clear - end - - def test_has_one - assert_equal companies(:first_firm).account, Account.find(1) - assert_equal Account.find(1).credit_limit, companies(:first_firm).account.credit_limit - end - - def test_has_one_cache_nils - firm = companies(:another_firm) - assert_queries(1) { assert_nil firm.account } - assert_queries(0) { assert_nil firm.account } - - firms = Firm.find(:all, :include => :account) - assert_queries(0) { firms.each(&:account) } - end - - def test_with_select - assert_equal Firm.find(1).account_with_select.attributes.size, 2 - assert_equal Firm.find(1, :include => :account_with_select).account_with_select.attributes.size, 2 - end - - def test_finding_using_primary_key - firm = companies(:first_firm) - assert_equal Account.find_by_firm_id(firm.id), firm.account - firm.firm_id = companies(:rails_core).id - assert_equal accounts(:rails_core_account), firm.account_using_primary_key - end - - def test_update_with_foreign_and_primary_keys - firm = companies(:first_firm) - account = firm.account_using_foreign_and_primary_keys - assert_equal Account.find_by_firm_name(firm.name), account - firm.save - firm.reload - assert_equal account, firm.account_using_foreign_and_primary_keys - end - - def test_can_marshal_has_one_association_with_nil_target - firm = Firm.new - assert_nothing_raised do - assert_equal firm.attributes, Marshal.load(Marshal.dump(firm)).attributes - end - - firm.account - assert_nothing_raised do - assert_equal firm.attributes, Marshal.load(Marshal.dump(firm)).attributes - end - end - - def test_proxy_assignment - company = companies(:first_firm) - assert_nothing_raised { company.account = company.account } - end - - def test_triple_equality - assert Account === companies(:first_firm).account - assert companies(:first_firm).account === Account - end - - def test_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = 1 } - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = Project.find(1) } - end - - def test_natural_assignment - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - apple.account = citibank - assert_equal apple.id, citibank.firm_id - end - - def test_natural_assignment_to_nil - old_account_id = companies(:first_firm).account.id - companies(:first_firm).account = nil - companies(:first_firm).save - assert_nil companies(:first_firm).account - # account is dependent, therefore is destroyed when reference to owner is lost - assert_raise(ActiveRecord::RecordNotFound) { Account.find(old_account_id) } - end - - def test_nullification_on_association_change - firm = companies(:rails_core) - old_account_id = firm.account.id - firm.account = Account.new - # account is dependent with nullify, therefore its firm_id should be nil - assert_nil Account.find(old_account_id).firm_id - end - - def test_association_changecalls_delete - companies(:first_firm).deletable_account = Account.new - assert_equal [], Account.destroyed_account_ids[companies(:first_firm).id] - end - - def test_association_change_calls_destroy - companies(:first_firm).account = Account.new - assert_equal [companies(:first_firm).id], Account.destroyed_account_ids[companies(:first_firm).id] - end - - def test_natural_assignment_to_already_associated_record - company = companies(:first_firm) - account = accounts(:signals37) - assert_equal company.account, account - company.account = account - company.reload - account.reload - assert_equal company.account, account - end - - def test_assignment_without_replacement - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - apple.account = citibank - assert_equal apple.id, citibank.firm_id - - hsbc = apple.build_account({ :credit_limit => 20}, false) - assert_equal apple.id, hsbc.firm_id - hsbc.save - assert_equal apple.id, citibank.firm_id - - nykredit = apple.create_account({ :credit_limit => 30}, false) - assert_equal apple.id, nykredit.firm_id - assert_equal apple.id, citibank.firm_id - assert_equal apple.id, hsbc.firm_id - end - - def test_assignment_without_replacement_on_create - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - apple.account = citibank - assert_equal apple.id, citibank.firm_id - - hsbc = apple.create_account({:credit_limit => 10}, false) - assert_equal apple.id, hsbc.firm_id - hsbc.save - assert_equal apple.id, citibank.firm_id - end - - def test_dependence - num_accounts = Account.count - - firm = Firm.find(1) - assert !firm.account.nil? - account_id = firm.account.id - assert_equal [], Account.destroyed_account_ids[firm.id] - - firm.destroy - assert_equal num_accounts - 1, Account.count - assert_equal [account_id], Account.destroyed_account_ids[firm.id] - end - - def test_exclusive_dependence - num_accounts = Account.count - - firm = ExclusivelyDependentFirm.find(9) - assert !firm.account.nil? - account_id = firm.account.id - assert_equal [], Account.destroyed_account_ids[firm.id] - - firm.destroy - assert_equal num_accounts - 1, Account.count - assert_equal [], Account.destroyed_account_ids[firm.id] - end - - def test_dependence_with_nil_associate - firm = DependentFirm.new(:name => 'nullify') - firm.save! - assert_nothing_raised { firm.destroy } - end - - def test_succesful_build_association - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - account = firm.build_account("credit_limit" => 1000) - assert account.save - assert_equal account, firm.account - end - - def test_failing_build_association - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - account = firm.build_account - assert !account.save - assert_equal "can't be empty", account.errors.on("credit_limit") - end - - def test_build_association_twice_without_saving_affects_nothing - count_of_account = Account.count - firm = Firm.find(:first) - account1 = firm.build_account("credit_limit" => 1000) - account2 = firm.build_account("credit_limit" => 2000) - - assert_equal count_of_account, Account.count - end - - def test_create_association - firm = Firm.create(:name => "GlobalMegaCorp") - account = firm.create_account(:credit_limit => 1000) - assert_equal account, firm.reload.account - end - - def test_build - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - firm.account = account = Account.new("credit_limit" => 1000) - assert_equal account, firm.account - assert account.save - assert_equal account, firm.account - end - - def test_failing_build_association - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - firm.account = account = Account.new - assert_equal account, firm.account - assert !account.save - assert_equal account, firm.account - assert_equal "can't be empty", account.errors.on("credit_limit") - end - - def test_create - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - firm.account = account = Account.create("credit_limit" => 1000) - assert_equal account, firm.account - end - - def test_create_before_save - firm = Firm.new("name" => "GlobalMegaCorp") - firm.account = account = Account.create("credit_limit" => 1000) - assert_equal account, firm.account - end - - def test_dependence_with_missing_association - Account.destroy_all - firm = Firm.find(1) - assert firm.account.nil? - firm.destroy - end - - def test_dependence_with_missing_association_and_nullify - Account.destroy_all - firm = DependentFirm.find(:first) - assert firm.account.nil? - firm.destroy - end - - def test_finding_with_interpolated_condition - firm = Firm.find(:first) - superior = firm.clients.create(:name => 'SuperiorCo') - superior.rating = 10 - superior.save - assert_equal 10, firm.clients_with_interpolated_conditions.first.rating - end - - def test_assignment_before_child_saved - firm = Firm.find(1) - firm.account = a = Account.new("credit_limit" => 1000) - assert !a.new_record? - assert_equal a, firm.account - assert_equal a, firm.account - assert_equal a, firm.account(true) - end - - def test_save_still_works_after_accessing_nil_has_one - jp = Company.new :name => 'Jaded Pixel' - jp.dummy_account.nil? - - assert_nothing_raised do - jp.save! - end - end - - def test_cant_save_readonly_association - assert_raise(ActiveRecord::ReadOnlyRecord) { companies(:first_firm).readonly_account.save! } - assert companies(:first_firm).readonly_account.readonly? - end - - def test_has_one_proxy_should_not_respond_to_private_methods - assert_raise(NoMethodError) { accounts(:signals37).private_method } - assert_raise(NoMethodError) { companies(:first_firm).account.private_method } - end - - def test_has_one_proxy_should_respond_to_private_methods_via_send - accounts(:signals37).send(:private_method) - companies(:first_firm).account.send(:private_method) - end - - def test_save_of_record_with_loaded_has_one - @firm = companies(:first_firm) - assert_not_nil @firm.account - - assert_nothing_raised do - Firm.find(@firm.id).save! - Firm.find(@firm.id, :include => :account).save! - end - - @firm.account.destroy - - assert_nothing_raised do - Firm.find(@firm.id).save! - Firm.find(@firm.id, :include => :account).save! - end - end - - def test_build_respects_hash_condition - account = companies(:first_firm).build_account_limit_500_with_hash_conditions - assert account.save - assert_equal 500, account.credit_limit - end - - def test_create_respects_hash_condition - account = companies(:first_firm).create_account_limit_500_with_hash_conditions - assert !account.new_record? - assert_equal 500, account.credit_limit - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb deleted file mode 100644 index 9aef3eb3..00000000 --- a/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ /dev/null @@ -1,209 +0,0 @@ -require "cases/helper" -require 'models/club' -require 'models/member_type' -require 'models/member' -require 'models/membership' -require 'models/sponsor' -require 'models/organization' -require 'models/member_detail' - -class HasOneThroughAssociationsTest < ActiveRecord::TestCase - fixtures :member_types, :members, :clubs, :memberships, :sponsors, :organizations - - def setup - @member = members(:groucho) - end - - def test_has_one_through_with_has_one - assert_equal clubs(:boring_club), @member.club - end - - def test_has_one_through_with_has_many - assert_equal clubs(:moustache_club), @member.favourite_club - end - - def test_creating_association_creates_through_record - new_member = Member.create(:name => "Chris") - new_member.club = Club.create(:name => "LRUG") - assert_not_nil new_member.current_membership - assert_not_nil new_member.club - end - - def test_creating_association_builds_through_record_for_new - new_member = Member.new(:name => "Jane") - new_member.club = clubs(:moustache_club) - assert new_member.current_membership - assert_equal clubs(:moustache_club), new_member.current_membership.club - assert_equal clubs(:moustache_club), new_member.club - assert new_member.save - assert_equal clubs(:moustache_club), new_member.club - end - - def test_replace_target_record - new_club = Club.create(:name => "Marx Bros") - @member.club = new_club - @member.reload - assert_equal new_club, @member.club - end - - def test_replacing_target_record_deletes_old_association - assert_no_difference "Membership.count" do - new_club = Club.create(:name => "Bananarama") - @member.club = new_club - @member.reload - end - end - - def test_set_record_to_nil_should_delete_association - @member.club = nil - @member.reload - assert_equal nil, @member.current_membership - assert_nil @member.club - end - - def test_has_one_through_polymorphic - assert_equal clubs(:moustache_club), @member.sponsor_club - end - - def has_one_through_to_has_many - assert_equal 2, @member.fellow_members.size - end - - def test_has_one_through_eager_loading - members = assert_queries(3) do #base table, through table, clubs table - Member.find(:all, :include => :club, :conditions => ["name = ?", "Groucho Marx"]) - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].club} - end - - def test_has_one_through_eager_loading_through_polymorphic - members = assert_queries(3) do #base table, through table, clubs table - Member.find(:all, :include => :sponsor_club, :conditions => ["name = ?", "Groucho Marx"]) - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].sponsor_club} - end - - def test_has_one_through_polymorphic_with_source_type - assert_equal members(:groucho), clubs(:moustache_club).sponsored_member - end - - def test_eager_has_one_through_polymorphic_with_source_type - clubs = Club.find(:all, :include => :sponsored_member, :conditions => ["name = ?","Moustache and Eyebrow Fancier Club"]) - # Only the eyebrow fanciers club has a sponsored_member - assert_not_nil assert_no_queries {clubs[0].sponsored_member} - end - - def test_has_one_through_nonpreload_eagerloading - members = assert_queries(1) do - Member.find(:all, :include => :club, :conditions => ["members.name = ?", "Groucho Marx"], :order => 'clubs.name') #force fallback - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].club} - end - - def test_has_one_through_nonpreload_eager_loading_through_polymorphic - members = assert_queries(1) do - Member.find(:all, :include => :sponsor_club, :conditions => ["members.name = ?", "Groucho Marx"], :order => 'clubs.name') #force fallback - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].sponsor_club} - end - - def test_has_one_through_nonpreload_eager_loading_through_polymorphic_with_more_than_one_through_record - Sponsor.new(:sponsor_club => clubs(:crazy_club), :sponsorable => members(:groucho)).save! - members = assert_queries(1) do - Member.find(:all, :include => :sponsor_club, :conditions => ["members.name = ?", "Groucho Marx"], :order => 'clubs.name DESC') #force fallback - end - assert_equal 1, members.size - assert_not_nil assert_no_queries { members[0].sponsor_club } - assert_equal clubs(:crazy_club), members[0].sponsor_club - end - - def test_uninitialized_has_one_through_should_return_nil_for_unsaved_record - assert_nil Member.new.club - end - - def test_assigning_association_correctly_assigns_target - new_member = Member.create(:name => "Chris") - new_member.club = new_club = Club.create(:name => "LRUG") - assert_equal new_club, new_member.club.target - end - - def test_has_one_through_proxy_should_not_respond_to_private_methods - assert_raise(NoMethodError) { clubs(:moustache_club).private_method } - assert_raise(NoMethodError) { @member.club.private_method } - end - - def test_has_one_through_proxy_should_respond_to_private_methods_via_send - clubs(:moustache_club).send(:private_method) - @member.club.send(:private_method) - end - - def test_assigning_to_has_one_through_preserves_decorated_join_record - @organization = organizations(:nsa) - assert_difference 'MemberDetail.count', 1 do - @member_detail = MemberDetail.new(:extra_data => 'Extra') - @member.member_detail = @member_detail - @member.organization = @organization - end - assert_equal @organization, @member.organization - assert @organization.members.include?(@member) - assert_equal 'Extra', @member.member_detail.extra_data - end - - def test_reassigning_has_one_through - @organization = organizations(:nsa) - @new_organization = organizations(:discordians) - - assert_difference 'MemberDetail.count', 1 do - @member_detail = MemberDetail.new(:extra_data => 'Extra') - @member.member_detail = @member_detail - @member.organization = @organization - end - assert_equal @organization, @member.organization - assert_equal 'Extra', @member.member_detail.extra_data - assert @organization.members.include?(@member) - assert !@new_organization.members.include?(@member) - - assert_no_difference 'MemberDetail.count' do - @member.organization = @new_organization - end - assert_equal @new_organization, @member.organization - assert_equal 'Extra', @member.member_detail.extra_data - assert !@organization.members.include?(@member) - assert @new_organization.members.include?(@member) - end - - def test_preloading_has_one_through_on_belongs_to - assert_not_nil @member.member_type - @organization = organizations(:nsa) - @member_detail = MemberDetail.new - @member.member_detail = @member_detail - @member.organization = @organization - @member_details = assert_queries(3) do - MemberDetail.find(:all, :include => :member_type) - end - @new_detail = @member_details[0] - assert @new_detail.loaded_member_type? - assert_not_nil assert_no_queries { @new_detail.member_type } - end - - def test_save_of_record_with_loaded_has_one_through - @club = @member.club - assert_not_nil @club.sponsored_member - - assert_nothing_raised do - Club.find(@club.id).save! - Club.find(@club.id, :include => :sponsored_member).save! - end - - @club.sponsor.destroy - - assert_nothing_raised do - Club.find(@club.id).save! - Club.find(@club.id, :include => :sponsored_member).save! - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb b/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb deleted file mode 100644 index 71415317..00000000 --- a/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +++ /dev/null @@ -1,93 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/categorization' - -class InnerJoinAssociationTest < ActiveRecord::TestCase - fixtures :authors, :posts, :comments, :categories, :categories_posts, :categorizations - - def test_construct_finder_sql_creates_inner_joins - sql = Author.send(:construct_finder_sql, :joins => :posts) - assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql - end - - def test_construct_finder_sql_cascades_inner_joins - sql = Author.send(:construct_finder_sql, :joins => {:posts => :comments}) - assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql - assert_match /INNER JOIN .?comments.? ON .?comments.?.post_id = posts.id/, sql - end - - def test_construct_finder_sql_inner_joins_through_associations - sql = Author.send(:construct_finder_sql, :joins => :categorized_posts) - assert_match /INNER JOIN .?categorizations.?.*INNER JOIN .?posts.?/, sql - end - - def test_construct_finder_sql_applies_association_conditions - sql = Author.send(:construct_finder_sql, :joins => :categories_like_general, :conditions => "TERMINATING_MARKER") - assert_match /INNER JOIN .?categories.? ON.*AND.*.?General.?.*TERMINATING_MARKER/, sql - end - - def test_construct_finder_sql_applies_aliases_tables_on_association_conditions - result = Author.find(:all, :joins => [:thinking_posts, :welcome_posts]) - assert_equal authors(:david), result.first - end - - def test_construct_finder_sql_unpacks_nested_joins - sql = Author.send(:construct_finder_sql, :joins => {:posts => [[:comments]]}) - assert_no_match /inner join.*inner join.*inner join/i, sql, "only two join clauses should be present" - assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql - assert_match /INNER JOIN .?comments.? ON .?comments.?.post_id = .?posts.?.id/, sql - end - - def test_construct_finder_sql_ignores_empty_joins_hash - sql = Author.send(:construct_finder_sql, :joins => {}) - assert_no_match /JOIN/i, sql - end - - def test_construct_finder_sql_ignores_empty_joins_array - sql = Author.send(:construct_finder_sql, :joins => []) - assert_no_match /JOIN/i, sql - end - - def test_find_with_implicit_inner_joins_honors_readonly_without_select - authors = Author.find(:all, :joins => :posts) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| a.readonly? }, "expected all authors to be readonly" - end - - def test_find_with_implicit_inner_joins_honors_readonly_with_select - authors = Author.find(:all, :select => 'authors.*', :joins => :posts) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| !a.readonly? }, "expected no authors to be readonly" - end - - def test_find_with_implicit_inner_joins_honors_readonly_false - authors = Author.find(:all, :joins => :posts, :readonly => false) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| !a.readonly? }, "expected no authors to be readonly" - end - - def test_find_with_implicit_inner_joins_does_not_set_associations - authors = Author.find(:all, :select => 'authors.*', :joins => :posts) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| !a.send(:instance_variable_names).include?("@posts")}, "expected no authors to have the @posts association loaded" - end - - def test_count_honors_implicit_inner_joins - real_count = Author.find(:all).sum{|a| a.posts.count } - assert_equal real_count, Author.count(:joins => :posts), "plain inner join count should match the number of referenced posts records" - end - - def test_calculate_honors_implicit_inner_joins - real_count = Author.find(:all).sum{|a| a.posts.count } - assert_equal real_count, Author.calculate(:count, 'authors.id', :joins => :posts), "plain inner join count should match the number of referenced posts records" - end - - def test_calculate_honors_implicit_inner_joins_and_distinct_and_conditions - real_count = Author.find(:all).select {|a| a.posts.any? {|p| p.title =~ /^Welcome/} }.length - authors_with_welcoming_post_titles = Author.calculate(:count, 'authors.id', :joins => :posts, :distinct => true, :conditions => "posts.title like 'Welcome%'") - assert_equal real_count, authors_with_welcoming_post_titles, "inner join and conditions should have only returned authors posting titles starting with 'Welcome'" - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/inverse_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/inverse_associations_test.rb deleted file mode 100644 index ee027b27..00000000 --- a/vendor/rails/activerecord/test/cases/associations/inverse_associations_test.rb +++ /dev/null @@ -1,566 +0,0 @@ -require "cases/helper" -require 'models/man' -require 'models/face' -require 'models/interest' -require 'models/zine' -require 'models/club' -require 'models/sponsor' - -class InverseAssociationTests < ActiveRecord::TestCase - def test_should_allow_for_inverse_of_options_in_associations - assert_nothing_raised(ArgumentError, 'ActiveRecord should allow the inverse_of options on has_many') do - Class.new(ActiveRecord::Base).has_many(:wheels, :inverse_of => :car) - end - - assert_nothing_raised(ArgumentError, 'ActiveRecord should allow the inverse_of options on has_one') do - Class.new(ActiveRecord::Base).has_one(:engine, :inverse_of => :car) - end - - assert_nothing_raised(ArgumentError, 'ActiveRecord should allow the inverse_of options on belongs_to') do - Class.new(ActiveRecord::Base).belongs_to(:car, :inverse_of => :driver) - end - end - - def test_should_be_able_to_ask_a_reflection_if_it_has_an_inverse - has_one_with_inverse_ref = Man.reflect_on_association(:face) - assert has_one_with_inverse_ref.respond_to?(:has_inverse?) - assert has_one_with_inverse_ref.has_inverse? - - has_many_with_inverse_ref = Man.reflect_on_association(:interests) - assert has_many_with_inverse_ref.respond_to?(:has_inverse?) - assert has_many_with_inverse_ref.has_inverse? - - belongs_to_with_inverse_ref = Face.reflect_on_association(:man) - assert belongs_to_with_inverse_ref.respond_to?(:has_inverse?) - assert belongs_to_with_inverse_ref.has_inverse? - - has_one_without_inverse_ref = Club.reflect_on_association(:sponsor) - assert has_one_without_inverse_ref.respond_to?(:has_inverse?) - assert !has_one_without_inverse_ref.has_inverse? - - has_many_without_inverse_ref = Club.reflect_on_association(:memberships) - assert has_many_without_inverse_ref.respond_to?(:has_inverse?) - assert !has_many_without_inverse_ref.has_inverse? - - belongs_to_without_inverse_ref = Sponsor.reflect_on_association(:sponsor_club) - assert belongs_to_without_inverse_ref.respond_to?(:has_inverse?) - assert !belongs_to_without_inverse_ref.has_inverse? - end - - def test_should_be_able_to_ask_a_reflection_what_it_is_the_inverse_of - has_one_ref = Man.reflect_on_association(:face) - assert has_one_ref.respond_to?(:inverse_of) - - has_many_ref = Man.reflect_on_association(:interests) - assert has_many_ref.respond_to?(:inverse_of) - - belongs_to_ref = Face.reflect_on_association(:man) - assert belongs_to_ref.respond_to?(:inverse_of) - end - - def test_inverse_of_method_should_supply_the_actual_reflection_instance_it_is_the_inverse_of - has_one_ref = Man.reflect_on_association(:face) - assert_equal Face.reflect_on_association(:man), has_one_ref.inverse_of - - has_many_ref = Man.reflect_on_association(:interests) - assert_equal Interest.reflect_on_association(:man), has_many_ref.inverse_of - - belongs_to_ref = Face.reflect_on_association(:man) - assert_equal Man.reflect_on_association(:face), belongs_to_ref.inverse_of - end - - def test_associations_with_no_inverse_of_should_return_nil - has_one_ref = Club.reflect_on_association(:sponsor) - assert_nil has_one_ref.inverse_of - - has_many_ref = Club.reflect_on_association(:memberships) - assert_nil has_many_ref.inverse_of - - belongs_to_ref = Sponsor.reflect_on_association(:sponsor_club) - assert_nil belongs_to_ref.inverse_of - end -end - -class InverseHasOneTests < ActiveRecord::TestCase - fixtures :men, :faces - - def test_parent_instance_should_be_shared_with_child_on_find - m = men(:gordon) - f = m.face - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to child-owned instance" - end - - def test_parent_instance_should_be_shared_with_eager_loaded_child_on_find - m = Man.find(:first, :conditions => {:name => 'Gordon'}, :include => :face) - f = m.face - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to child-owned instance" - - m = Man.find(:first, :conditions => {:name => 'Gordon'}, :include => :face, :order => 'faces.id') - f = m.face - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_built_child - m = men(:gordon) - f = m.build_face(:description => 'haunted') - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to just-built-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_created_child - m = men(:gordon) - f = m.create_face(:description => 'haunted') - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_created_child_via_bang_method - m = Man.find(:first) - f = m.face.create!(:description => 'haunted') - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_built_child_when_we_dont_replace_existing - m = Man.find(:first) - f = m.build_face({:description => 'haunted'}, false) - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to just-built-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_created_child_when_we_dont_replace_existing - m = Man.find(:first) - f = m.create_face({:description => 'haunted'}, false) - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_created_child_via_bang_method_when_we_dont_replace_existing - m = Man.find(:first) - f = m.face.create!({:description => 'haunted'}, false) - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_replaced_via_accessor_child - m = Man.find(:first) - f = Face.new(:description => 'haunted') - m.face = f - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to replaced-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_replaced_via_method_child - m = Man.find(:first) - f = Face.new(:description => 'haunted') - m.face.replace(f) - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to replaced-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_replaced_via_method_child_when_we_dont_replace_existing - m = Man.find(:first) - f = Face.new(:description => 'haunted') - m.face.replace(f, false) - assert_not_nil f.man - assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to parent instance" - f.man.name = 'Mungo' - assert_equal m.name, f.man.name, "Name of man should be the same after changes to replaced-child-owned instance" - end - - def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error - assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Man.find(:first).dirty_face } - end -end - -class InverseHasManyTests < ActiveRecord::TestCase - fixtures :men, :interests - - def test_parent_instance_should_be_shared_with_every_child_on_find - m = men(:gordon) - is = m.interests - is.each do |i| - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to child-owned instance" - end - end - - def test_parent_instance_should_be_shared_with_eager_loaded_children - m = Man.find(:first, :conditions => {:name => 'Gordon'}, :include => :interests) - is = m.interests - is.each do |i| - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to child-owned instance" - end - - m = Man.find(:first, :conditions => {:name => 'Gordon'}, :include => :interests, :order => 'interests.id') - is = m.interests - is.each do |i| - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to child-owned instance" - end - end - - def test_parent_instance_should_be_shared_with_newly_built_child - m = men(:gordon) - i = m.interests.build(:topic => 'Industrial Revolution Re-enactment') - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to just-built-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_block_style_built_child - m = Man.find(:first) - i = m.interests.build {|ii| ii.topic = 'Industrial Revolution Re-enactment'} - assert_not_nil i.topic, "Child attributes supplied to build via blocks should be populated" - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to just-built-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_created_child - m = men(:gordon) - i = m.interests.create(:topic => 'Industrial Revolution Re-enactment') - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_created_via_bang_method_child - m = Man.find(:first) - i = m.interests.create!(:topic => 'Industrial Revolution Re-enactment') - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_newly_block_style_created_child - m = Man.find(:first) - i = m.interests.create {|ii| ii.topic = 'Industrial Revolution Re-enactment'} - assert_not_nil i.topic, "Child attributes supplied to create via blocks should be populated" - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_poked_in_child - m = men(:gordon) - i = Interest.create(:topic => 'Industrial Revolution Re-enactment') - m.interests << i - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to newly-created-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_replaced_via_accessor_children - m = Man.find(:first) - i = Interest.new(:topic => 'Industrial Revolution Re-enactment') - m.interests = [i] - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to replaced-child-owned instance" - end - - def test_parent_instance_should_be_shared_with_replaced_via_method_children - m = Man.find(:first) - i = Interest.new(:topic => 'Industrial Revolution Re-enactment') - m.interests.replace([i]) - assert_not_nil i.man - assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" - m.name = 'Bongo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" - i.man.name = 'Mungo' - assert_equal m.name, i.man.name, "Name of man should be the same after changes to replaced-child-owned instance" - end - - def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error - assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Man.find(:first).secret_interests } - end -end - -class InverseBelongsToTests < ActiveRecord::TestCase - fixtures :men, :faces, :interests - - def test_child_instance_should_be_shared_with_parent_on_find - f = faces(:trusting) - m = f.man - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to parent-owned instance" - end - - def test_eager_loaded_child_instance_should_be_shared_with_parent_on_find - f = Face.find(:first, :include => :man, :conditions => {:description => 'trusting'}) - m = f.man - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to parent-owned instance" - - f = Face.find(:first, :include => :man, :order => 'men.id', :conditions => {:description => 'trusting'}) - m = f.man - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to parent-owned instance" - end - - def test_child_instance_should_be_shared_with_newly_built_parent - f = faces(:trusting) - m = f.build_man(:name => 'Charles') - assert_not_nil m.face - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to just-built-parent-owned instance" - end - - def test_child_instance_should_be_shared_with_newly_created_parent - f = faces(:trusting) - m = f.create_man(:name => 'Charles') - assert_not_nil m.face - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to newly-created-parent-owned instance" - end - - def test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many - i = interests(:trainspotting) - m = i.man - assert_not_nil m.interests - iz = m.interests.detect {|iz| iz.id == i.id} - assert_not_nil iz - assert_equal i.topic, iz.topic, "Interest topics should be the same before changes to child" - i.topic = 'Eating cheese with a spoon' - assert_not_equal i.topic, iz.topic, "Interest topics should not be the same after changes to child" - iz.topic = 'Cow tipping' - assert_not_equal i.topic, iz.topic, "Interest topics should not be the same after changes to parent-owned instance" - end - - def test_child_instance_should_be_shared_with_replaced_via_accessor_parent - f = Face.find(:first) - m = Man.new(:name => 'Charles') - f.man = m - assert_not_nil m.face - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to replaced-parent-owned instance" - end - - def test_child_instance_should_be_shared_with_replaced_via_method_parent - f = faces(:trusting) - assert_not_nil f.man - m = Man.new(:name => 'Charles') - f.man.replace(m) - assert_not_nil m.face - assert_equal f.description, m.face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to child instance" - m.face.description = 'pleasing' - assert_equal f.description, m.face.description, "Description of face should be the same after changes to replaced-parent-owned instance" - end - - def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error - assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.find(:first).horrible_man } - end -end - -class InversePolymorphicBelongsToTests < ActiveRecord::TestCase - fixtures :men, :faces, :interests - - def test_child_instance_should_be_shared_with_parent_on_find - f = Face.find(:first, :conditions => {:description => 'confused'}) - m = f.polymorphic_man - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same after changes to child instance" - m.polymorphic_face.description = 'pleasing' - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same after changes to parent-owned instance" - end - - def test_eager_loaded_child_instance_should_be_shared_with_parent_on_find - f = Face.find(:first, :conditions => {:description => 'confused'}, :include => :man) - m = f.polymorphic_man - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same after changes to child instance" - m.polymorphic_face.description = 'pleasing' - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same after changes to parent-owned instance" - - f = Face.find(:first, :conditions => {:description => 'confused'}, :include => :man, :order => 'men.id') - m = f.polymorphic_man - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same before changes to child instance" - f.description = 'gormless' - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same after changes to child instance" - m.polymorphic_face.description = 'pleasing' - assert_equal f.description, m.polymorphic_face.description, "Description of face should be the same after changes to parent-owned instance" - end - - def test_child_instance_should_be_shared_with_replaced_via_accessor_parent - face = faces(:confused) - old_man = face.polymorphic_man - new_man = Man.new - - assert_not_nil face.polymorphic_man - face.polymorphic_man = new_man - - assert_equal face.description, new_man.polymorphic_face.description, "Description of face should be the same before changes to parent instance" - face.description = 'Bongo' - assert_equal face.description, new_man.polymorphic_face.description, "Description of face should be the same after changes to parent instance" - new_man.polymorphic_face.description = 'Mungo' - assert_equal face.description, new_man.polymorphic_face.description, "Description of face should be the same after changes to replaced-parent-owned instance" - end - - def test_child_instance_should_be_shared_with_replaced_via_method_parent - face = faces(:confused) - old_man = face.polymorphic_man - new_man = Man.new - - assert_not_nil face.polymorphic_man - face.polymorphic_man.replace(new_man) - - assert_equal face.description, new_man.polymorphic_face.description, "Description of face should be the same before changes to parent instance" - face.description = 'Bongo' - assert_equal face.description, new_man.polymorphic_face.description, "Description of face should be the same after changes to parent instance" - new_man.polymorphic_face.description = 'Mungo' - assert_equal face.description, new_man.polymorphic_face.description, "Description of face should be the same after changes to replaced-parent-owned instance" - end - - def test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many - i = interests(:llama_wrangling) - m = i.polymorphic_man - assert_not_nil m.polymorphic_interests - iz = m.polymorphic_interests.detect {|iz| iz.id == i.id} - assert_not_nil iz - assert_equal i.topic, iz.topic, "Interest topics should be the same before changes to child" - i.topic = 'Eating cheese with a spoon' - assert_not_equal i.topic, iz.topic, "Interest topics should not be the same after changes to child" - iz.topic = 'Cow tipping' - assert_not_equal i.topic, iz.topic, "Interest topics should not be the same after changes to parent-owned instance" - end - - def test_trying_to_access_inverses_that_dont_exist_shouldnt_raise_an_error - # Ideally this would, if only for symmetry's sake with other association types - assert_nothing_raised(ActiveRecord::InverseOfAssociationNotFoundError) { Face.find(:first).horrible_polymorphic_man } - end - - def test_trying_to_set_polymorphic_inverses_that_dont_exist_at_all_should_raise_an_error - # fails because no class has the correct inverse_of for horrible_polymorphic_man - assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.find(:first).horrible_polymorphic_man = Man.first } - end - - def test_trying_to_set_polymorphic_inverses_that_dont_exist_on_the_instance_being_set_should_raise_an_error - # passes because Man does have the correct inverse_of - assert_nothing_raised(ActiveRecord::InverseOfAssociationNotFoundError) { Face.find(:first).polymorphic_man = Man.first } - # fails because Interest does have the correct inverse_of - assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.find(:first).polymorphic_man = Interest.first } - end -end - -# NOTE - these tests might not be meaningful, ripped as they were from the parental_control plugin -# which would guess the inverse rather than look for an explicit configuration option. -class InverseMultipleHasManyInversesForSameModel < ActiveRecord::TestCase - fixtures :men, :interests, :zines - - def test_that_we_can_load_associations_that_have_the_same_reciprocal_name_from_different_models - assert_nothing_raised(ActiveRecord::AssociationTypeMismatch) do - i = Interest.find(:first) - z = i.zine - m = i.man - end - end - - def test_that_we_can_create_associations_that_have_the_same_reciprocal_name_from_different_models - assert_nothing_raised(ActiveRecord::AssociationTypeMismatch) do - i = Interest.find(:first) - i.build_zine(:title => 'Get Some in Winter! 2008') - i.build_man(:name => 'Gordon') - i.save! - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/join_model_test.rb b/vendor/rails/activerecord/test/cases/associations/join_model_test.rb deleted file mode 100644 index 21412d1e..00000000 --- a/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +++ /dev/null @@ -1,712 +0,0 @@ -require "cases/helper" -require 'models/tag' -require 'models/tagging' -require 'models/post' -require 'models/item' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/categorization' -require 'models/vertex' -require 'models/edge' -require 'models/book' -require 'models/citation' - -class AssociationsJoinModelTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items, :books - - def test_has_many - assert authors(:david).categories.include?(categories(:general)) - end - - def test_has_many_inherited - assert authors(:mary).categories.include?(categories(:sti_test)) - end - - def test_inherited_has_many - assert categories(:sti_test).authors.include?(authors(:mary)) - end - - def test_has_many_uniq_through_join_model - assert_equal 2, authors(:mary).categorized_posts.size - assert_equal 1, authors(:mary).unique_categorized_posts.size - end - - def test_has_many_uniq_through_count - author = authors(:mary) - assert !authors(:mary).unique_categorized_posts.loaded? - assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count } - assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count(:title) } - assert_queries(1) { assert_equal 0, author.unique_categorized_posts.count(:title, :conditions => "title is NULL") } - assert !authors(:mary).unique_categorized_posts.loaded? - end - - def test_has_many_uniq_through_find - assert_equal 1, authors(:mary).unique_categorized_posts.find(:all).size - end - - def test_has_many_uniq_through_dynamic_find - assert_equal 1, authors(:mary).unique_categorized_posts.find_all_by_title("So I was thinking").size - end - - def test_polymorphic_has_many - assert posts(:welcome).taggings.include?(taggings(:welcome_general)) - end - - def test_polymorphic_has_one - assert_equal taggings(:welcome_general), posts(:welcome).tagging - end - - def test_polymorphic_belongs_to - assert_equal posts(:welcome), posts(:welcome).taggings.first.taggable - end - - def test_polymorphic_has_many_going_through_join_model - assert_equal tags(:general), tag = posts(:welcome).tags.first - assert_no_queries do - tag.tagging - end - end - - def test_count_polymorphic_has_many - assert_equal 1, posts(:welcome).taggings.count - assert_equal 1, posts(:welcome).tags.count - end - - def test_polymorphic_has_many_going_through_join_model_with_find - assert_equal tags(:general), tag = posts(:welcome).tags.find(:first) - assert_no_queries do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_include_on_source_reflection - assert_equal tags(:general), tag = posts(:welcome).funky_tags.first - assert_no_queries do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_include_on_source_reflection_with_find - assert_equal tags(:general), tag = posts(:welcome).funky_tags.find(:first) - assert_no_queries do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_disabled_include - assert_equal tags(:general), tag = posts(:welcome).tags.add_joins_and_select.first - assert_queries 1 do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_custom_select_and_joins - assert_equal tags(:general), tag = posts(:welcome).tags.add_joins_and_select.first - tag.author_id - end - - def test_polymorphic_has_many_going_through_join_model_with_custom_foreign_key - assert_equal tags(:misc), taggings(:welcome_general).super_tag - assert_equal tags(:misc), posts(:welcome).super_tags.first - end - - def test_polymorphic_has_many_create_model_with_inheritance_and_custom_base_class - post = SubStiPost.create :title => 'SubStiPost', :body => 'SubStiPost body' - assert_instance_of SubStiPost, post - - tagging = tags(:misc).taggings.create(:taggable => post) - assert_equal "SubStiPost", tagging.taggable_type - end - - def test_polymorphic_has_many_going_through_join_model_with_inheritance - assert_equal tags(:general), posts(:thinking).tags.first - end - - def test_polymorphic_has_many_going_through_join_model_with_inheritance_with_custom_class_name - assert_equal tags(:general), posts(:thinking).funky_tags.first - end - - def test_polymorphic_has_many_create_model_with_inheritance - post = posts(:thinking) - assert_instance_of SpecialPost, post - - tagging = tags(:misc).taggings.create(:taggable => post) - assert_equal "Post", tagging.taggable_type - end - - def test_polymorphic_has_one_create_model_with_inheritance - tagging = tags(:misc).create_tagging(:taggable => posts(:thinking)) - assert_equal "Post", tagging.taggable_type - end - - def test_set_polymorphic_has_many - tagging = tags(:misc).taggings.create - posts(:thinking).taggings << tagging - assert_equal "Post", tagging.taggable_type - end - - def test_set_polymorphic_has_one - tagging = tags(:misc).taggings.create - posts(:thinking).tagging = tagging - assert_equal "Post", tagging.taggable_type - end - - def test_create_polymorphic_has_many_with_scope - old_count = posts(:welcome).taggings.count - tagging = posts(:welcome).taggings.create(:tag => tags(:misc)) - assert_equal "Post", tagging.taggable_type - assert_equal old_count+1, posts(:welcome).taggings.count - end - - def test_create_bang_polymorphic_with_has_many_scope - old_count = posts(:welcome).taggings.count - tagging = posts(:welcome).taggings.create!(:tag => tags(:misc)) - assert_equal "Post", tagging.taggable_type - assert_equal old_count+1, posts(:welcome).taggings.count - end - - def test_create_polymorphic_has_one_with_scope - old_count = Tagging.count - tagging = posts(:welcome).tagging.create(:tag => tags(:misc)) - assert_equal "Post", tagging.taggable_type - assert_equal old_count+1, Tagging.count - end - - def test_delete_polymorphic_has_many_with_delete_all - assert_equal 1, posts(:welcome).taggings.count - posts(:welcome).taggings.first.update_attribute :taggable_type, 'PostWithHasManyDeleteAll' - post = find_post_with_dependency(1, :has_many, :taggings, :delete_all) - - old_count = Tagging.count - post.destroy - assert_equal old_count-1, Tagging.count - assert_equal 0, posts(:welcome).taggings.count - end - - def test_delete_polymorphic_has_many_with_destroy - assert_equal 1, posts(:welcome).taggings.count - posts(:welcome).taggings.first.update_attribute :taggable_type, 'PostWithHasManyDestroy' - post = find_post_with_dependency(1, :has_many, :taggings, :destroy) - - old_count = Tagging.count - post.destroy - assert_equal old_count-1, Tagging.count - assert_equal 0, posts(:welcome).taggings.count - end - - def test_delete_polymorphic_has_many_with_nullify - assert_equal 1, posts(:welcome).taggings.count - posts(:welcome).taggings.first.update_attribute :taggable_type, 'PostWithHasManyNullify' - post = find_post_with_dependency(1, :has_many, :taggings, :nullify) - - old_count = Tagging.count - post.destroy - assert_equal old_count, Tagging.count - assert_equal 0, posts(:welcome).taggings.count - end - - def test_delete_polymorphic_has_one_with_destroy - assert posts(:welcome).tagging - posts(:welcome).tagging.update_attribute :taggable_type, 'PostWithHasOneDestroy' - post = find_post_with_dependency(1, :has_one, :tagging, :destroy) - - old_count = Tagging.count - post.destroy - assert_equal old_count-1, Tagging.count - assert_nil posts(:welcome).tagging(true) - end - - def test_delete_polymorphic_has_one_with_nullify - assert posts(:welcome).tagging - posts(:welcome).tagging.update_attribute :taggable_type, 'PostWithHasOneNullify' - post = find_post_with_dependency(1, :has_one, :tagging, :nullify) - - old_count = Tagging.count - post.destroy - assert_equal old_count, Tagging.count - assert_nil posts(:welcome).tagging(true) - end - - def test_has_many_with_piggyback - assert_equal "2", categories(:sti_test).authors.first.post_id.to_s - end - - def test_include_has_many_through - posts = Post.find(:all, :order => 'posts.id') - posts_with_authors = Post.find(:all, :include => :authors, :order => 'posts.id') - assert_equal posts.length, posts_with_authors.length - posts.length.times do |i| - assert_equal posts[i].authors.length, assert_no_queries { posts_with_authors[i].authors.length } - end - end - - def test_include_polymorphic_has_one - post = Post.find_by_id(posts(:welcome).id, :include => :tagging) - tagging = taggings(:welcome_general) - assert_no_queries do - assert_equal tagging, post.tagging - end - end - - def test_include_polymorphic_has_one_defined_in_abstract_parent - item = Item.find_by_id(items(:dvd).id, :include => :tagging) - tagging = taggings(:godfather) - assert_no_queries do - assert_equal tagging, item.tagging - end - end - - def test_include_polymorphic_has_many_through - posts = Post.find(:all, :order => 'posts.id') - posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id') - assert_equal posts.length, posts_with_tags.length - posts.length.times do |i| - assert_equal posts[i].tags.length, assert_no_queries { posts_with_tags[i].tags.length } - end - end - - def test_include_polymorphic_has_many - posts = Post.find(:all, :order => 'posts.id') - posts_with_taggings = Post.find(:all, :include => :taggings, :order => 'posts.id') - assert_equal posts.length, posts_with_taggings.length - posts.length.times do |i| - assert_equal posts[i].taggings.length, assert_no_queries { posts_with_taggings[i].taggings.length } - end - end - - def test_has_many_find_all - assert_equal [categories(:general)], authors(:david).categories.find(:all) - end - - def test_has_many_find_first - assert_equal categories(:general), authors(:david).categories.find(:first) - end - - def test_has_many_with_hash_conditions - assert_equal categories(:general), authors(:david).categories_like_general.find(:first) - end - - def test_has_many_find_conditions - assert_equal categories(:general), authors(:david).categories.find(:first, :conditions => "categories.name = 'General'") - assert_equal nil, authors(:david).categories.find(:first, :conditions => "categories.name = 'Technology'") - end - - def test_has_many_class_methods_called_by_method_missing - assert_equal categories(:general), authors(:david).categories.find_all_by_name('General').first - assert_equal nil, authors(:david).categories.find_by_name('Technology') - end - - def test_has_many_array_methods_called_by_method_missing - assert true, authors(:david).categories.any? { |category| category.name == 'General' } - assert_nothing_raised { authors(:david).categories.sort } - end - - def test_has_many_going_through_join_model_with_custom_foreign_key - assert_equal [], posts(:thinking).authors - assert_equal [authors(:mary)], posts(:authorless).authors - end - - def test_both_scoped_and_explicit_joins_should_be_respected - assert_nothing_raised do - Post.send(:with_scope, :find => {:joins => "left outer join comments on comments.id = posts.id"}) do - Post.find :all, :select => "comments.id, authors.id", :joins => "left outer join authors on authors.id = posts.author_id" - end - end - end - - def test_belongs_to_polymorphic_with_counter_cache - assert_equal 1, posts(:welcome)[:taggings_count] - tagging = posts(:welcome).taggings.create(:tag => tags(:general)) - assert_equal 2, posts(:welcome, :reload)[:taggings_count] - tagging.destroy - assert_equal 1, posts(:welcome, :reload)[:taggings_count] - end - - def test_unavailable_through_reflection - assert_raise(ActiveRecord::HasManyThroughAssociationNotFoundError) { authors(:david).nothings } - end - - def test_has_many_through_join_model_with_conditions - assert_equal [], posts(:welcome).invalid_taggings - assert_equal [], posts(:welcome).invalid_tags - end - - def test_has_many_polymorphic - assert_raise ActiveRecord::HasManyThroughAssociationPolymorphicError do - assert_equal posts(:welcome, :thinking), tags(:general).taggables - end - assert_raise ActiveRecord::EagerLoadPolymorphicError do - assert_equal posts(:welcome, :thinking), tags(:general).taggings.find(:all, :include => :taggable, :conditions => 'bogus_table.column = 1') - end - end - - def test_has_many_polymorphic_with_source_type - assert_equal posts(:welcome, :thinking), tags(:general).tagged_posts - end - - def test_eager_has_many_polymorphic_with_source_type - tag_with_include = Tag.find(tags(:general).id, :include => :tagged_posts) - desired = posts(:welcome, :thinking) - assert_no_queries do - assert_equal desired, tag_with_include.tagged_posts - end - assert_equal 5, tag_with_include.taggings.length - end - - def test_has_many_through_has_many_find_all - assert_equal comments(:greetings), authors(:david).comments.find(:all, :order => 'comments.id').first - end - - def test_has_many_through_has_many_find_all_with_custom_class - assert_equal comments(:greetings), authors(:david).funky_comments.find(:all, :order => 'comments.id').first - end - - def test_has_many_through_has_many_find_first - assert_equal comments(:greetings), authors(:david).comments.find(:first, :order => 'comments.id') - end - - def test_has_many_through_has_many_find_conditions - options = { :conditions => "comments.#{QUOTED_TYPE}='SpecialComment'", :order => 'comments.id' } - assert_equal comments(:does_it_hurt), authors(:david).comments.find(:first, options) - end - - def test_has_many_through_has_many_find_by_id - assert_equal comments(:more_greetings), authors(:david).comments.find(2) - end - - def test_has_many_through_polymorphic_has_one - assert_equal Tagging.find(1,2).sort_by { |t| t.id }, authors(:david).tagging - end - - def test_has_many_through_polymorphic_has_many - assert_equal taggings(:welcome_general, :thinking_general), authors(:david).taggings.uniq.sort_by { |t| t.id } - end - - def test_include_has_many_through_polymorphic_has_many - author = Author.find_by_id(authors(:david).id, :include => :taggings) - expected_taggings = taggings(:welcome_general, :thinking_general) - assert_no_queries do - assert_equal expected_taggings, author.taggings.uniq.sort_by { |t| t.id } - end - end - - def test_has_many_through_has_many_through - assert_raise(ActiveRecord::HasManyThroughSourceAssociationMacroError) { authors(:david).tags } - end - - def test_has_many_through_habtm - assert_raise(ActiveRecord::HasManyThroughSourceAssociationMacroError) { authors(:david).post_categories } - end - - def test_eager_load_has_many_through_has_many - author = Author.find :first, :conditions => ['name = ?', 'David'], :include => :comments, :order => 'comments.id' - SpecialComment.new; VerySpecialComment.new - assert_no_queries do - assert_equal [1,2,3,5,6,7,8,9,10], author.comments.collect(&:id) - end - end - - def test_eager_load_has_many_through_has_many_with_conditions - post = Post.find(:first, :include => :invalid_tags) - assert_no_queries do - post.invalid_tags - end - end - - def test_eager_belongs_to_and_has_one_not_singularized - assert_nothing_raised do - Author.find(:first, :include => :author_address) - AuthorAddress.find(:first, :include => :author) - end - end - - def test_self_referential_has_many_through - assert_equal [authors(:mary)], authors(:david).favorite_authors - assert_equal [], authors(:mary).favorite_authors - end - - def test_add_to_self_referential_has_many_through - new_author = Author.create(:name => "Bob") - authors(:david).author_favorites.create :favorite_author => new_author - assert_equal new_author, authors(:david).reload.favorite_authors.first - end - - def test_has_many_through_uses_conditions_specified_on_the_has_many_association - author = Author.find(:first) - assert !author.comments.blank? - assert author.nonexistant_comments.blank? - end - - def test_has_many_through_uses_correct_attributes - assert_nil posts(:thinking).tags.find_by_name("General").attributes["tag_id"] - end - - def test_associating_unsaved_records_with_has_many_through - saved_post = posts(:thinking) - new_tag = Tag.new(:name => "new") - - saved_post.tags << new_tag - assert !new_tag.new_record? #consistent with habtm! - assert !saved_post.new_record? - assert saved_post.tags.include?(new_tag) - - assert !new_tag.new_record? - assert saved_post.reload.tags(true).include?(new_tag) - - - new_post = Post.new(:title => "Association replacmenet works!", :body => "You best believe it.") - saved_tag = tags(:general) - - new_post.tags << saved_tag - assert new_post.new_record? - assert !saved_tag.new_record? - assert new_post.tags.include?(saved_tag) - - new_post.save! - assert !new_post.new_record? - assert new_post.reload.tags(true).include?(saved_tag) - - assert posts(:thinking).tags.build.new_record? - assert posts(:thinking).tags.new.new_record? - end - - def test_create_associate_when_adding_to_has_many_through - count = posts(:thinking).tags.count - push = Tag.create!(:name => 'pushme') - post_thinking = posts(:thinking) - assert_nothing_raised { post_thinking.tags << push } - assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, - message = "Expected a Tag in tags collection, got #{wrong.class}.") - assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging }, - message = "Expected a Tagging in taggings collection, got #{wrong.class}.") - assert_equal(count + 1, post_thinking.tags.size) - assert_equal(count + 1, post_thinking.tags(true).size) - - assert_kind_of Tag, post_thinking.tags.create!(:name => 'foo') - assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, - message = "Expected a Tag in tags collection, got #{wrong.class}.") - assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging }, - message = "Expected a Tagging in taggings collection, got #{wrong.class}.") - assert_equal(count + 2, post_thinking.tags.size) - assert_equal(count + 2, post_thinking.tags(true).size) - - assert_nothing_raised { post_thinking.tags.concat(Tag.create!(:name => 'abc'), Tag.create!(:name => 'def')) } - assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, - message = "Expected a Tag in tags collection, got #{wrong.class}.") - assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging }, - message = "Expected a Tagging in taggings collection, got #{wrong.class}.") - assert_equal(count + 4, post_thinking.tags.size) - assert_equal(count + 4, post_thinking.tags(true).size) - - # Raises if the wrong reflection name is used to set the Edge belongs_to - assert_nothing_raised { vertices(:vertex_1).sinks << vertices(:vertex_5) } - end - - def test_has_many_through_collection_size_doesnt_load_target_if_not_loaded - author = authors(:david) - assert_equal 9, author.comments.size - assert !author.comments.loaded? - end - - def test_has_many_through_collection_size_uses_counter_cache_if_it_exists - author = authors(:david) - author.stubs(:read_attribute).with('comments_count').returns(100) - assert_equal 100, author.comments.size - assert !author.comments.loaded? - end - - def test_adding_junk_to_has_many_through_should_raise_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags << "Uhh what now?" } - end - - def test_adding_to_has_many_through_should_return_self - tags = posts(:thinking).tags - assert_equal tags, posts(:thinking).tags.push(tags(:general)) - end - - def test_delete_associate_when_deleting_from_has_many_through_with_nonstandard_id - count = books(:awdr).references.count - references_before = books(:awdr).references - book = Book.create!(:name => 'Getting Real') - book_awdr = books(:awdr) - book_awdr.references << book - assert_equal(count + 1, book_awdr.references(true).size) - - assert_nothing_raised { book_awdr.references.delete(book) } - assert_equal(count, book_awdr.references.size) - assert_equal(count, book_awdr.references(true).size) - assert_equal(references_before.sort, book_awdr.references.sort) - end - - def test_delete_associate_when_deleting_from_has_many_through - count = posts(:thinking).tags.count - tags_before = posts(:thinking).tags - tag = Tag.create!(:name => 'doomed') - post_thinking = posts(:thinking) - post_thinking.tags << tag - assert_equal(count + 1, post_thinking.taggings(true).size) - assert_equal(count + 1, post_thinking.tags(true).size) - - assert_nothing_raised { post_thinking.tags.delete(tag) } - assert_equal(count, post_thinking.tags.size) - assert_equal(count, post_thinking.tags(true).size) - assert_equal(count, post_thinking.taggings(true).size) - assert_equal(tags_before.sort, post_thinking.tags.sort) - end - - def test_delete_associate_when_deleting_from_has_many_through_with_multiple_tags - count = posts(:thinking).tags.count - tags_before = posts(:thinking).tags - doomed = Tag.create!(:name => 'doomed') - doomed2 = Tag.create!(:name => 'doomed2') - quaked = Tag.create!(:name => 'quaked') - post_thinking = posts(:thinking) - post_thinking.tags << doomed << doomed2 - assert_equal(count + 2, post_thinking.tags(true).size) - - assert_nothing_raised { post_thinking.tags.delete(doomed, doomed2, quaked) } - assert_equal(count, post_thinking.tags.size) - assert_equal(count, post_thinking.tags(true).size) - assert_equal(tags_before.sort, post_thinking.tags.sort) - end - - def test_deleting_junk_from_has_many_through_should_raise_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags.delete("Uhh what now?") } - end - - def test_has_many_through_sum_uses_calculations - assert_nothing_raised { authors(:david).comments.sum(:post_id) } - end - - def test_calculations_on_has_many_through_should_disambiguate_fields - assert_nothing_raised { authors(:david).categories.maximum(:id) } - end - - def test_calculations_on_has_many_through_should_not_disambiguate_fields_unless_necessary - assert_nothing_raised { authors(:david).categories.maximum("categories.id") } - end - - def test_has_many_through_has_many_with_sti - assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments - end - - def test_uniq_has_many_through_should_retain_order - comment_ids = authors(:david).comments.map(&:id) - assert_equal comment_ids.sort, authors(:david).ordered_uniq_comments.map(&:id) - assert_equal comment_ids.sort.reverse, authors(:david).ordered_uniq_comments_desc.map(&:id) - end - - def test_polymorphic_has_many - expected = taggings(:welcome_general) - p = Post.find(posts(:welcome).id, :include => :taggings) - assert_no_queries {assert p.taggings.include?(expected)} - assert posts(:welcome).taggings.include?(taggings(:welcome_general)) - end - - def test_polymorphic_has_one - expected = posts(:welcome) - - tagging = Tagging.find(taggings(:welcome_general).id, :include => :taggable) - assert_no_queries { assert_equal expected, tagging.taggable} - end - - def test_polymorphic_belongs_to - p = Post.find(posts(:welcome).id, :include => {:taggings => :taggable}) - assert_no_queries {assert_equal posts(:welcome), p.taggings.first.taggable} - end - - def test_preload_polymorphic_has_many_through - posts = Post.find(:all, :order => 'posts.id') - posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id') - assert_equal posts.length, posts_with_tags.length - posts.length.times do |i| - assert_equal posts[i].tags.length, assert_no_queries { posts_with_tags[i].tags.length } - end - end - - def test_preload_polymorph_many_types - taggings = Tagging.find :all, :include => :taggable, :conditions => ['taggable_type != ?', 'FakeModel'] - assert_no_queries do - taggings.first.taggable.id - taggings[1].taggable.id - end - - taggables = taggings.map(&:taggable) - assert taggables.include?(items(:dvd)) - assert taggables.include?(posts(:welcome)) - end - - def test_preload_nil_polymorphic_belongs_to - assert_nothing_raised do - taggings = Tagging.find(:all, :include => :taggable, :conditions => ['taggable_type IS NULL']) - end - end - - def test_preload_polymorphic_has_many - posts = Post.find(:all, :order => 'posts.id') - posts_with_taggings = Post.find(:all, :include => :taggings, :order => 'posts.id') - assert_equal posts.length, posts_with_taggings.length - posts.length.times do |i| - assert_equal posts[i].taggings.length, assert_no_queries { posts_with_taggings[i].taggings.length } - end - end - - def test_belongs_to_shared_parent - comments = Comment.find(:all, :include => :post, :conditions => 'post_id = 1') - assert_no_queries do - assert_equal comments.first.post, comments[1].post - end - end - - def test_has_many_through_include_uses_array_include_after_loaded - david = authors(:david) - david.categories.class # force load target - - category = david.categories.first - - assert_no_queries do - assert david.categories.loaded? - assert david.categories.include?(category) - end - end - - def test_has_many_through_include_checks_if_record_exists_if_target_not_loaded - david = authors(:david) - category = david.categories.first - - david.reload - assert ! david.categories.loaded? - assert_queries(1) do - assert david.categories.include?(category) - end - assert ! david.categories.loaded? - end - - def test_has_many_through_include_returns_false_for_non_matching_record_to_verify_scoping - david = authors(:david) - category = Category.create!(:name => 'Not Associated') - - assert ! david.categories.loaded? - assert ! david.categories.include?(category) - end - - def test_has_many_through_goes_through_all_sti_classes - sub_sti_post = SubStiPost.create!(:title => 'test', :body => 'test', :author_id => 1) - new_comment = sub_sti_post.comments.create(:body => 'test') - - assert_equal [9, 10, new_comment.id], authors(:david).sti_post_comments.map(&:id).sort - end - - private - # create dynamic Post models to allow different dependency options - def find_post_with_dependency(post_id, association, association_name, dependency) - class_name = "PostWith#{association.to_s.classify}#{dependency.to_s.classify}" - Post.find(post_id).update_attribute :type, class_name - klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) - klass.set_table_name 'posts' - klass.send(association, association_name, :as => :taggable, :dependent => dependency) - klass.find(post_id) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations_test.rb b/vendor/rails/activerecord/test/cases/associations_test.rb deleted file mode 100644 index 048d042b..00000000 --- a/vendor/rails/activerecord/test/cases/associations_test.rb +++ /dev/null @@ -1,282 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/computer' -require 'models/customer' -require 'models/order' -require 'models/categorization' -require 'models/category' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/tag' -require 'models/tagging' -require 'models/person' -require 'models/reader' -require 'models/parrot' -require 'models/pirate' -require 'models/treasure' -require 'models/price_estimate' -require 'models/club' -require 'models/member' -require 'models/membership' -require 'models/sponsor' - -class AssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :developers, :projects, :developers_projects, - :computers, :people, :readers - - def test_include_with_order_works - assert_nothing_raised {Account.find(:first, :order => 'id', :include => :firm)} - assert_nothing_raised {Account.find(:first, :order => :id, :include => :firm)} - end - - def test_bad_collection_keys - assert_raise(ArgumentError, 'ActiveRecord should have barked on bad collection keys') do - Class.new(ActiveRecord::Base).has_many(:wheels, :name => 'wheels') - end - end - - def test_should_construct_new_finder_sql_after_create - person = Person.new :first_name => 'clark' - assert_equal [], person.readers.find(:all) - person.save! - reader = Reader.create! :person => person, :post => Post.new(:title => "foo", :body => "bar") - assert person.readers.find(reader.id) - end - - def test_force_reload - firm = Firm.new("name" => "A New Firm, Inc") - firm.save - firm.clients.each {|c|} # forcing to load all clients - assert firm.clients.empty?, "New firm shouldn't have client objects" - assert_equal 0, firm.clients.size, "New firm should have 0 clients" - - client = Client.new("name" => "TheClient.com", "firm_id" => firm.id) - client.save - - assert firm.clients.empty?, "New firm should have cached no client objects" - assert_equal 0, firm.clients.size, "New firm should have cached 0 clients count" - - assert !firm.clients(true).empty?, "New firm should have reloaded client objects" - assert_equal 1, firm.clients(true).size, "New firm should have reloaded clients count" - end - - def test_force_reload_is_uncached - firm = Firm.create!("name" => "A New Firm, Inc") - client = Client.create!("name" => "TheClient.com", :firm => firm) - ActiveRecord::Base.cache do - firm.clients.each {} - assert_queries(0) { assert_not_nil firm.clients.each {} } - assert_queries(1) { assert_not_nil firm.clients(true).each {} } - end - end - - def test_using_limitable_reflections_helper - using_limitable_reflections = lambda { |reflections| ActiveRecord::Base.send :using_limitable_reflections?, reflections } - belongs_to_reflections = [Tagging.reflect_on_association(:tag), Tagging.reflect_on_association(:super_tag)] - has_many_reflections = [Tag.reflect_on_association(:taggings), Developer.reflect_on_association(:projects)] - mixed_reflections = (belongs_to_reflections + has_many_reflections).uniq - assert using_limitable_reflections.call(belongs_to_reflections), "Belong to associations are limitable" - assert !using_limitable_reflections.call(has_many_reflections), "All has many style associations are not limitable" - assert !using_limitable_reflections.call(mixed_reflections), "No collection associations (has many style) should pass" - end - - def test_storing_in_pstore - require "tmpdir" - store_filename = File.join(Dir.tmpdir, "ar-pstore-association-test") - File.delete(store_filename) if File.exist?(store_filename) - require "pstore" - apple = Firm.create("name" => "Apple") - natural = Client.new("name" => "Natural Company") - apple.clients << natural - - db = PStore.new(store_filename) - db.transaction do - db["apple"] = apple - end - - db = PStore.new(store_filename) - db.transaction do - assert_equal "Natural Company", db["apple"].clients.first.name - end - end -end - -class AssociationProxyTest < ActiveRecord::TestCase - fixtures :authors, :posts, :categorizations, :categories, :developers, :projects, :developers_projects - - def test_proxy_accessors - welcome = posts(:welcome) - assert_equal welcome, welcome.author.proxy_owner - assert_equal welcome.class.reflect_on_association(:author), welcome.author.proxy_reflection - welcome.author.class # force load target - assert_equal welcome.author, welcome.author.proxy_target - - david = authors(:david) - assert_equal david, david.posts.proxy_owner - assert_equal david.class.reflect_on_association(:posts), david.posts.proxy_reflection - david.posts.class # force load target - assert_equal david.posts, david.posts.proxy_target - - assert_equal david, david.posts_with_extension.testing_proxy_owner - assert_equal david.class.reflect_on_association(:posts_with_extension), david.posts_with_extension.testing_proxy_reflection - david.posts_with_extension.class # force load target - assert_equal david.posts_with_extension, david.posts_with_extension.testing_proxy_target - end - - def test_push_does_not_load_target - david = authors(:david) - - david.posts << (post = Post.new(:title => "New on Edge", :body => "More cool stuff!")) - assert !david.posts.loaded? - assert david.posts.include?(post) - end - - def test_push_has_many_through_does_not_load_target - david = authors(:david) - - david.categories << categories(:technology) - assert !david.categories.loaded? - assert david.categories.include?(categories(:technology)) - end - - def test_push_followed_by_save_does_not_load_target - david = authors(:david) - - david.posts << (post = Post.new(:title => "New on Edge", :body => "More cool stuff!")) - assert !david.posts.loaded? - david.save - assert !david.posts.loaded? - assert david.posts.include?(post) - end - - def test_push_does_not_lose_additions_to_new_record - josh = Author.new(:name => "Josh") - josh.posts << Post.new(:title => "New on Edge", :body => "More cool stuff!") - assert josh.posts.loaded? - assert_equal 1, josh.posts.size - end - - def test_save_on_parent_does_not_load_target - david = developers(:david) - - assert !david.projects.loaded? - david.update_attribute(:created_at, Time.now) - assert !david.projects.loaded? - end - - def test_inspect_does_not_reload_a_not_yet_loaded_target - andreas = Developer.new :name => 'Andreas', :log => 'new developer added' - assert !andreas.audit_logs.loaded? - assert_match(/message: "new developer added"/, andreas.audit_logs.inspect) - end - - def test_save_on_parent_saves_children - developer = Developer.create :name => "Bryan", :salary => 50_000 - assert_equal 1, developer.reload.audit_logs.size - end - - def test_create_via_association_with_block - post = authors(:david).posts.create(:title => "New on Edge") {|p| p.body = "More cool stuff!"} - assert_equal post.title, "New on Edge" - assert_equal post.body, "More cool stuff!" - end - - def test_create_with_bang_via_association_with_block - post = authors(:david).posts.create!(:title => "New on Edge") {|p| p.body = "More cool stuff!"} - assert_equal post.title, "New on Edge" - assert_equal post.body, "More cool stuff!" - end - - def test_failed_reload_returns_nil - p = setup_dangling_association - assert_nil p.author.reload - end - - def test_failed_reset_returns_nil - p = setup_dangling_association - assert_nil p.author.reset - end - - def test_reload_returns_assocition - david = developers(:david) - assert_nothing_raised do - assert_equal david.projects, david.projects.reload.reload - end - end - - def setup_dangling_association - josh = Author.create(:name => "Josh") - p = Post.create(:title => "New on Edge", :body => "More cool stuff!", :author => josh) - josh.destroy - p - end -end - -class OverridingAssociationsTest < ActiveRecord::TestCase - class Person < ActiveRecord::Base; end - class DifferentPerson < ActiveRecord::Base; end - - class PeopleList < ActiveRecord::Base - has_and_belongs_to_many :has_and_belongs_to_many, :before_add => :enlist - has_many :has_many, :before_add => :enlist - belongs_to :belongs_to - has_one :has_one - end - - class DifferentPeopleList < PeopleList - # Different association with the same name, callbacks should be omitted here. - has_and_belongs_to_many :has_and_belongs_to_many, :class_name => 'DifferentPerson' - has_many :has_many, :class_name => 'DifferentPerson' - belongs_to :belongs_to, :class_name => 'DifferentPerson' - has_one :has_one, :class_name => 'DifferentPerson' - end - - def test_habtm_association_redefinition_callbacks_should_differ_and_not_inherited - # redeclared association on AR descendant should not inherit callbacks from superclass - callbacks = PeopleList.read_inheritable_attribute(:before_add_for_has_and_belongs_to_many) - assert_equal([:enlist], callbacks) - callbacks = DifferentPeopleList.read_inheritable_attribute(:before_add_for_has_and_belongs_to_many) - assert_equal([], callbacks) - end - - def test_has_many_association_redefinition_callbacks_should_differ_and_not_inherited - # redeclared association on AR descendant should not inherit callbacks from superclass - callbacks = PeopleList.read_inheritable_attribute(:before_add_for_has_many) - assert_equal([:enlist], callbacks) - callbacks = DifferentPeopleList.read_inheritable_attribute(:before_add_for_has_many) - assert_equal([], callbacks) - end - - def test_habtm_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:has_and_belongs_to_many), - DifferentPeopleList.reflect_on_association(:has_and_belongs_to_many) - ) - end - - def test_has_many_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:has_many), - DifferentPeopleList.reflect_on_association(:has_many) - ) - end - - def test_belongs_to_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:belongs_to), - DifferentPeopleList.reflect_on_association(:belongs_to) - ) - end - - def test_has_one_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:has_one), - DifferentPeopleList.reflect_on_association(:has_one) - ) - end -end diff --git a/vendor/rails/activerecord/test/cases/attribute_methods_test.rb b/vendor/rails/activerecord/test/cases/attribute_methods_test.rb deleted file mode 100644 index 17ed3024..00000000 --- a/vendor/rails/activerecord/test/cases/attribute_methods_test.rb +++ /dev/null @@ -1,305 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/minimalistic' - -class AttributeMethodsTest < ActiveRecord::TestCase - fixtures :topics - def setup - @old_suffixes = ActiveRecord::Base.send(:attribute_method_suffixes).dup - @target = Class.new(ActiveRecord::Base) - @target.table_name = 'topics' - end - - def teardown - ActiveRecord::Base.send(:attribute_method_suffixes).clear - ActiveRecord::Base.attribute_method_suffix *@old_suffixes - end - - def test_match_attribute_method_query_returns_match_data - assert_not_nil md = @target.match_attribute_method?('title=') - assert_equal 'title', md.pre_match - assert_equal ['='], md.captures - - %w(_hello_world ist! _maybe?).each do |suffix| - @target.class_eval "def attribute#{suffix}(*args) args end" - @target.attribute_method_suffix suffix - - assert_not_nil md = @target.match_attribute_method?("title#{suffix}") - assert_equal 'title', md.pre_match - assert_equal [suffix], md.captures - end - end - - def test_declared_attribute_method_affects_respond_to_and_method_missing - topic = @target.new(:title => 'Budget') - assert topic.respond_to?('title') - assert_equal 'Budget', topic.title - assert !topic.respond_to?('title_hello_world') - assert_raise(NoMethodError) { topic.title_hello_world } - - %w(_hello_world _it! _candidate= able?).each do |suffix| - @target.class_eval "def attribute#{suffix}(*args) args end" - @target.attribute_method_suffix suffix - - meth = "title#{suffix}" - assert topic.respond_to?(meth) - assert_equal ['title'], topic.send(meth) - assert_equal ['title', 'a'], topic.send(meth, 'a') - assert_equal ['title', 1, 2, 3], topic.send(meth, 1, 2, 3) - end - end - - def test_should_unserialize_attributes_for_frozen_records - myobj = {:value1 => :value2} - topic = Topic.create("content" => myobj) - topic.freeze - assert_equal myobj, topic.content - end - - def test_typecast_attribute_from_select_to_false - topic = Topic.create(:title => 'Budget') - topic = Topic.find(:first, :select => "topics.*, 1=2 as is_test") - assert !topic.is_test? - end - - def test_typecast_attribute_from_select_to_true - topic = Topic.create(:title => 'Budget') - topic = Topic.find(:first, :select => "topics.*, 2=2 as is_test") - assert topic.is_test? - end - - def test_kernel_methods_not_implemented_in_activerecord - %w(test name display y).each do |method| - assert !ActiveRecord::Base.instance_method_already_implemented?(method), "##{method} is defined" - end - end - - def test_primary_key_implemented - assert Class.new(ActiveRecord::Base).instance_method_already_implemented?('id') - end - - def test_defined_kernel_methods_implemented_in_model - %w(test name display y).each do |method| - klass = Class.new ActiveRecord::Base - klass.class_eval "def #{method}() 'defined #{method}' end" - assert klass.instance_method_already_implemented?(method), "##{method} is not defined" - end - end - - def test_defined_kernel_methods_implemented_in_model_abstract_subclass - %w(test name display y).each do |method| - abstract = Class.new ActiveRecord::Base - abstract.class_eval "def #{method}() 'defined #{method}' end" - abstract.abstract_class = true - klass = Class.new abstract - assert klass.instance_method_already_implemented?(method), "##{method} is not defined" - end - end - - def test_raises_dangerous_attribute_error_when_defining_activerecord_method_in_model - %w(save create_or_update).each do |method| - klass = Class.new ActiveRecord::Base - klass.class_eval "def #{method}() 'defined #{method}' end" - assert_raise ActiveRecord::DangerousAttributeError do - klass.instance_method_already_implemented?(method) - end - end - end - - def test_only_time_related_columns_are_meant_to_be_cached_by_default - expected = %w(datetime timestamp time date).sort - assert_equal expected, ActiveRecord::Base.attribute_types_cached_by_default.map(&:to_s).sort - end - - def test_declaring_attributes_as_cached_adds_them_to_the_attributes_cached_by_default - default_attributes = Topic.cached_attributes - Topic.cache_attributes :replies_count - expected = default_attributes + ["replies_count"] - assert_equal expected.sort, Topic.cached_attributes.sort - Topic.instance_variable_set "@cached_attributes", nil - end - - def test_time_related_columns_are_actually_cached - column_types = %w(datetime timestamp time date).map(&:to_sym) - column_names = Topic.columns.select{|c| column_types.include?(c.type) }.map(&:name) - - assert_equal column_names.sort, Topic.cached_attributes.sort - assert_equal time_related_columns_on_topic.sort, Topic.cached_attributes.sort - end - - def test_accessing_cached_attributes_caches_the_converted_values_and_nothing_else - t = topics(:first) - cache = t.instance_variable_get "@attributes_cache" - - assert_not_nil cache - assert cache.empty? - - all_columns = Topic.columns.map(&:name) - cached_columns = time_related_columns_on_topic - uncached_columns = all_columns - cached_columns - - all_columns.each do |attr_name| - attribute_gets_cached = Topic.cache_attribute?(attr_name) - val = t.send attr_name unless attr_name == "type" - if attribute_gets_cached - assert cached_columns.include?(attr_name) - assert_equal val, cache[attr_name] - else - assert uncached_columns.include?(attr_name) - assert !cache.include?(attr_name) - end - end - end - - def test_time_attributes_are_retrieved_in_current_time_zone - in_time_zone "Pacific Time (US & Canada)" do - utc_time = Time.utc(2008, 1, 1) - record = @target.new - record[:written_on] = utc_time - assert_equal utc_time, record.written_on # record.written on is equal to (i.e., simultaneous with) utc_time - assert_kind_of ActiveSupport::TimeWithZone, record.written_on # but is a TimeWithZone - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone # and is in the current Time.zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time # and represents time values adjusted accordingly - end - end - - def test_setting_time_zone_aware_attribute_to_utc - in_time_zone "Pacific Time (US & Canada)" do - utc_time = Time.utc(2008, 1, 1) - record = @target.new - record.written_on = utc_time - assert_equal utc_time, record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - - def test_setting_time_zone_aware_attribute_in_other_time_zone - utc_time = Time.utc(2008, 1, 1) - cst_time = utc_time.in_time_zone("Central Time (US & Canada)") - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = cst_time - assert_equal utc_time, record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - - def test_setting_time_zone_aware_attribute_with_string - utc_time = Time.utc(2008, 1, 1) - (-11..13).each do |timezone_offset| - time_string = utc_time.in_time_zone(timezone_offset).to_s - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = time_string - assert_equal Time.zone.parse(time_string), record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - end - - def test_setting_time_zone_aware_attribute_to_blank_string_returns_nil - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = ' ' - assert_nil record.written_on - end - end - - def test_setting_time_zone_aware_attribute_interprets_time_zone_unaware_string_in_time_zone - time_string = 'Tue Jan 01 00:00:00 2008' - (-11..13).each do |timezone_offset| - in_time_zone timezone_offset do - record = @target.new - record.written_on = time_string - assert_equal Time.zone.parse(time_string), record.written_on - assert_equal ActiveSupport::TimeZone[timezone_offset], record.written_on.time_zone - assert_equal Time.utc(2008, 1, 1), record.written_on.time - end - end - end - - def test_setting_time_zone_aware_attribute_in_current_time_zone - utc_time = Time.utc(2008, 1, 1) - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = utc_time.in_time_zone - assert_equal utc_time, record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - - def test_setting_time_zone_conversion_for_attributes_should_write_value_on_class_variable - Topic.skip_time_zone_conversion_for_attributes = [:field_a] - Minimalistic.skip_time_zone_conversion_for_attributes = [:field_b] - - assert_equal [:field_a], Topic.skip_time_zone_conversion_for_attributes - assert_equal [:field_b], Minimalistic.skip_time_zone_conversion_for_attributes - end - - def test_read_attributes_respect_access_control - privatize("title") - - topic = @target.new(:title => "The pros and cons of programming naked.") - assert !topic.respond_to?(:title) - exception = assert_raise(NoMethodError) { topic.title } - assert_equal "Attempt to call private method", exception.message - assert_equal "I'm private", topic.send(:title) - end - - def test_write_attributes_respect_access_control - privatize("title=(value)") - - topic = @target.new - assert !topic.respond_to?(:title=) - exception = assert_raise(NoMethodError) { topic.title = "Pants"} - assert_equal "Attempt to call private method", exception.message - topic.send(:title=, "Very large pants") - end - - def test_question_attributes_respect_access_control - privatize("title?") - - topic = @target.new(:title => "Isaac Newton's pants") - assert !topic.respond_to?(:title?) - exception = assert_raise(NoMethodError) { topic.title? } - assert_equal "Attempt to call private method", exception.message - assert topic.send(:title?) - end - - def test_bulk_update_respects_access_control - privatize("title=(value)") - - assert_raise(ActiveRecord::UnknownAttributeError) { topic = @target.new(:title => "Rants about pants") } - assert_raise(ActiveRecord::UnknownAttributeError) { @target.new.attributes = { :title => "Ants in pants" } } - end - - private - def time_related_columns_on_topic - Topic.columns.select{|c| [:time, :date, :datetime, :timestamp].include?(c.type)}.map(&:name) - end - - def in_time_zone(zone) - old_zone = Time.zone - old_tz = ActiveRecord::Base.time_zone_aware_attributes - - Time.zone = zone ? ActiveSupport::TimeZone[zone] : nil - ActiveRecord::Base.time_zone_aware_attributes = !zone.nil? - yield - ensure - Time.zone = old_zone - ActiveRecord::Base.time_zone_aware_attributes = old_tz - end - - def privatize(method_signature) - @target.class_eval <<-private_method - private - def #{method_signature} - "I'm private" - end - private_method - end -end diff --git a/vendor/rails/activerecord/test/cases/autosave_association_test.rb b/vendor/rails/activerecord/test/cases/autosave_association_test.rb deleted file mode 100644 index adbc608d..00000000 --- a/vendor/rails/activerecord/test/cases/autosave_association_test.rb +++ /dev/null @@ -1,1218 +0,0 @@ -require 'cases/helper' -require 'models/bird' -require 'models/company' -require 'models/customer' -require 'models/developer' -require 'models/invoice' -require 'models/line_item' -require 'models/order' -require 'models/parrot' -require 'models/person' -require 'models/pirate' -require 'models/post' -require 'models/reader' -require 'models/ship' -require 'models/ship_part' -require 'models/treasure' - -class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase - def test_autosave_should_be_a_valid_option_for_has_one - assert base.valid_keys_for_has_one_association.include?(:autosave) - end - - def test_autosave_should_be_a_valid_option_for_belongs_to - assert base.valid_keys_for_belongs_to_association.include?(:autosave) - end - - def test_autosave_should_be_a_valid_option_for_has_many - assert base.valid_keys_for_has_many_association.include?(:autosave) - end - - def test_autosave_should_be_a_valid_option_for_has_and_belongs_to_many - assert base.valid_keys_for_has_and_belongs_to_many_association.include?(:autosave) - end - - def test_should_not_add_the_same_callbacks_multiple_times_for_has_one - assert_no_difference_when_adding_callbacks_twice_for Pirate, :ship - end - - def test_should_not_add_the_same_callbacks_multiple_times_for_belongs_to - assert_no_difference_when_adding_callbacks_twice_for Ship, :pirate - end - - def test_should_not_add_the_same_callbacks_multiple_times_for_has_many - assert_no_difference_when_adding_callbacks_twice_for Pirate, :birds - end - - def test_should_not_add_the_same_callbacks_multiple_times_for_has_and_belongs_to_many - assert_no_difference_when_adding_callbacks_twice_for Pirate, :parrots - end - - private - - def base - ActiveRecord::Base - end - - def assert_no_difference_when_adding_callbacks_twice_for(model, association_name) - reflection = model.reflect_on_association(association_name) - assert_no_difference "callbacks_for_model(#{model.name}).length" do - model.send(:add_autosave_association_callbacks, reflection) - end - end - - def callbacks_for_model(model) - model.instance_variables.grep(/_callbacks$/).map do |ivar| - model.instance_variable_get(ivar) - end.flatten - end -end - -class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase - def test_should_save_parent_but_not_invalid_child - firm = Firm.new(:name => 'GlobalMegaCorp') - assert firm.valid? - - firm.build_account_using_primary_key - assert !firm.build_account_using_primary_key.valid? - - assert firm.save - assert firm.account_using_primary_key.new_record? - end - - def test_save_fails_for_invalid_has_one - firm = Firm.find(:first) - assert firm.valid? - - firm.account = Account.new - - assert !firm.account.valid? - assert !firm.valid? - assert !firm.save - assert_equal "is invalid", firm.errors.on("account") - end - - def test_save_succeeds_for_invalid_has_one_with_validate_false - firm = Firm.find(:first) - assert firm.valid? - - firm.unvalidated_account = Account.new - - assert !firm.unvalidated_account.valid? - assert firm.valid? - assert firm.save - end - - def test_build_before_child_saved - firm = Firm.find(1) - - account = firm.account.build("credit_limit" => 1000) - assert_equal account, firm.account - assert account.new_record? - assert firm.save - assert_equal account, firm.account - assert !account.new_record? - end - - def test_build_before_either_saved - firm = Firm.new("name" => "GlobalMegaCorp") - - firm.account = account = Account.new("credit_limit" => 1000) - assert_equal account, firm.account - assert account.new_record? - assert firm.save - assert_equal account, firm.account - assert !account.new_record? - end - - def test_assignment_before_parent_saved - firm = Firm.new("name" => "GlobalMegaCorp") - firm.account = a = Account.find(1) - assert firm.new_record? - assert_equal a, firm.account - assert firm.save - assert_equal a, firm.account - assert_equal a, firm.account(true) - end - - def test_assignment_before_either_saved - firm = Firm.new("name" => "GlobalMegaCorp") - firm.account = a = Account.new("credit_limit" => 1000) - assert firm.new_record? - assert a.new_record? - assert_equal a, firm.account - assert firm.save - assert !firm.new_record? - assert !a.new_record? - assert_equal a, firm.account - assert_equal a, firm.account(true) - end - - def test_not_resaved_when_unchanged - firm = Firm.find(:first, :include => :account) - firm.name += '-changed' - assert_queries(1) { firm.save! } - - firm = Firm.find(:first) - firm.account = Account.find(:first) - assert_queries(Firm.partial_updates? ? 0 : 1) { firm.save! } - - firm = Firm.find(:first).clone - firm.account = Account.find(:first) - assert_queries(2) { firm.save! } - - firm = Firm.find(:first).clone - firm.account = Account.find(:first).clone - assert_queries(2) { firm.save! } - end -end - -class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase - def test_should_save_parent_but_not_invalid_child - client = Client.new(:name => 'Joe (the Plumber)') - assert client.valid? - - client.build_firm - assert !client.firm.valid? - - assert client.save - assert client.firm.new_record? - end - - def test_save_fails_for_invalid_belongs_to - assert log = AuditLog.create(:developer_id => 0, :message => "") - - log.developer = Developer.new - assert !log.developer.valid? - assert !log.valid? - assert !log.save - assert_equal "is invalid", log.errors.on("developer") - end - - def test_save_succeeds_for_invalid_belongs_to_with_validate_false - assert log = AuditLog.create(:developer_id => 0, :message=> "") - - log.unvalidated_developer = Developer.new - assert !log.unvalidated_developer.valid? - assert log.valid? - assert log.save - end - - def test_assignment_before_parent_saved - client = Client.find(:first) - apple = Firm.new("name" => "Apple") - client.firm = apple - assert_equal apple, client.firm - assert apple.new_record? - assert client.save - assert apple.save - assert !apple.new_record? - assert_equal apple, client.firm - assert_equal apple, client.firm(true) - end - - def test_assignment_before_either_saved - final_cut = Client.new("name" => "Final Cut") - apple = Firm.new("name" => "Apple") - final_cut.firm = apple - assert final_cut.new_record? - assert apple.new_record? - assert final_cut.save - assert !final_cut.new_record? - assert !apple.new_record? - assert_equal apple, final_cut.firm - assert_equal apple, final_cut.firm(true) - end - - def test_store_two_association_with_one_save - num_orders = Order.count - num_customers = Customer.count - order = Order.new - - customer1 = order.billing = Customer.new - customer2 = order.shipping = Customer.new - assert order.save - assert_equal customer1, order.billing - assert_equal customer2, order.shipping - - order.reload - - assert_equal customer1, order.billing - assert_equal customer2, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +2, Customer.count - end - - def test_store_association_in_two_relations_with_one_save - num_orders = Order.count - num_customers = Customer.count - order = Order.new - - customer = order.billing = order.shipping = Customer.new - assert order.save - assert_equal customer, order.billing - assert_equal customer, order.shipping - - order.reload - - assert_equal customer, order.billing - assert_equal customer, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +1, Customer.count - end - - def test_store_association_in_two_relations_with_one_save_in_existing_object - num_orders = Order.count - num_customers = Customer.count - order = Order.create - - customer = order.billing = order.shipping = Customer.new - assert order.save - assert_equal customer, order.billing - assert_equal customer, order.shipping - - order.reload - - assert_equal customer, order.billing - assert_equal customer, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +1, Customer.count - end - - def test_store_association_in_two_relations_with_one_save_in_existing_object_with_values - num_orders = Order.count - num_customers = Customer.count - order = Order.create - - customer = order.billing = order.shipping = Customer.new - assert order.save - assert_equal customer, order.billing - assert_equal customer, order.shipping - - order.reload - - customer = order.billing = order.shipping = Customer.new - - assert order.save - order.reload - - assert_equal customer, order.billing - assert_equal customer, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +2, Customer.count - end -end - -class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase - fixtures :companies, :people - - def test_invalid_adding - firm = Firm.find(1) - assert !(firm.clients_of_firm << c = Client.new) - assert c.new_record? - assert !firm.valid? - assert !firm.save - assert c.new_record? - end - - def test_invalid_adding_before_save - no_of_firms = Firm.count - no_of_clients = Client.count - new_firm = Firm.new("name" => "A New Firm, Inc") - new_firm.clients_of_firm.concat([c = Client.new, Client.new("name" => "Apple")]) - assert c.new_record? - assert !c.valid? - assert !new_firm.valid? - assert !new_firm.save - assert c.new_record? - assert new_firm.new_record? - end - - def test_invalid_adding_with_validate_false - firm = Firm.find(:first) - client = Client.new - firm.unvalidated_clients_of_firm << client - - assert firm.valid? - assert !client.valid? - assert firm.save - assert client.new_record? - end - - def test_valid_adding_with_validate_false - no_of_clients = Client.count - - firm = Firm.find(:first) - client = Client.new("name" => "Apple") - - assert firm.valid? - assert client.valid? - assert client.new_record? - - firm.unvalidated_clients_of_firm << client - - assert firm.save - assert !client.new_record? - assert_equal no_of_clients+1, Client.count - end - - def test_invalid_build - new_client = companies(:first_firm).clients_of_firm.build - assert new_client.new_record? - assert !new_client.valid? - assert_equal new_client, companies(:first_firm).clients_of_firm.last - assert !companies(:first_firm).save - assert new_client.new_record? - assert_equal 1, companies(:first_firm).clients_of_firm(true).size - end - - def test_adding_before_save - no_of_firms = Firm.count - no_of_clients = Client.count - - new_firm = Firm.new("name" => "A New Firm, Inc") - c = Client.new("name" => "Apple") - - new_firm.clients_of_firm.push Client.new("name" => "Natural Company") - assert_equal 1, new_firm.clients_of_firm.size - new_firm.clients_of_firm << c - assert_equal 2, new_firm.clients_of_firm.size - - assert_equal no_of_firms, Firm.count # Firm was not saved to database. - assert_equal no_of_clients, Client.count # Clients were not saved to database. - assert new_firm.save - assert !new_firm.new_record? - assert !c.new_record? - assert_equal new_firm, c.firm - assert_equal no_of_firms+1, Firm.count # Firm was saved to database. - assert_equal no_of_clients+2, Client.count # Clients were saved to database. - - assert_equal 2, new_firm.clients_of_firm.size - assert_equal 2, new_firm.clients_of_firm(true).size - end - - def test_assign_ids - firm = Firm.new("name" => "Apple") - firm.client_ids = [companies(:first_client).id, companies(:second_client).id] - firm.save - firm.reload - assert_equal 2, firm.clients.length - assert firm.clients.include?(companies(:second_client)) - end - - def test_assign_ids_for_through_a_belongs_to - post = Post.new(:title => "Assigning IDs works!", :body => "You heared it here first, folks!") - post.person_ids = [people(:david).id, people(:michael).id] - post.save - post.reload - assert_equal 2, post.people.length - assert post.people.include?(people(:david)) - end - - def test_build_before_save - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build("name" => "Another Client") } - assert !company.clients_of_firm.loaded? - - company.name += '-changed' - assert_queries(2) { assert company.save } - assert !new_client.new_record? - assert_equal 2, company.clients_of_firm(true).size - end - - def test_build_many_before_save - company = companies(:first_firm) - new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } - - company.name += '-changed' - assert_queries(3) { assert company.save } - assert_equal 3, company.clients_of_firm(true).size - end - - def test_build_via_block_before_save - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build {|client| client.name = "Another Client" } } - assert !company.clients_of_firm.loaded? - - company.name += '-changed' - assert_queries(2) { assert company.save } - assert !new_client.new_record? - assert_equal 2, company.clients_of_firm(true).size - end - - def test_build_many_via_block_before_save - company = companies(:first_firm) - new_clients = assert_no_queries do - company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) do |client| - client.name = "changed" - end - end - - company.name += '-changed' - assert_queries(3) { assert company.save } - assert_equal 3, company.clients_of_firm(true).size - end - - def test_replace_on_new_object - firm = Firm.new("name" => "New Firm") - firm.clients = [companies(:second_client), Client.new("name" => "New Client")] - assert firm.save - firm.reload - assert_equal 2, firm.clients.length - assert firm.clients.include?(Client.find_by_name("New Client")) - end -end - -class TestDefaultAutosaveAssociationOnNewRecord < ActiveRecord::TestCase - def test_autosave_new_record_on_belongs_to_can_be_disabled_per_relationship - new_account = Account.new("credit_limit" => 1000) - new_firm = Firm.new("name" => "some firm") - - assert new_firm.new_record? - new_account.firm = new_firm - new_account.save! - - assert !new_firm.new_record? - - new_account = Account.new("credit_limit" => 1000) - new_autosaved_firm = Firm.new("name" => "some firm") - - assert new_autosaved_firm.new_record? - new_account.unautosaved_firm = new_autosaved_firm - new_account.save! - - assert new_autosaved_firm.new_record? - end - - def test_autosave_new_record_on_has_one_can_be_disabled_per_relationship - firm = Firm.new("name" => "some firm") - account = Account.new("credit_limit" => 1000) - - assert account.new_record? - firm.account = account - firm.save! - - assert !account.new_record? - - firm = Firm.new("name" => "some firm") - account = Account.new("credit_limit" => 1000) - - firm.unautosaved_account = account - - assert account.new_record? - firm.unautosaved_account = account - firm.save! - - assert account.new_record? - end - - def test_autosave_new_record_on_has_many_can_be_disabled_per_relationship - firm = Firm.new("name" => "some firm") - account = Account.new("credit_limit" => 1000) - - assert account.new_record? - firm.accounts << account - - firm.save! - assert !account.new_record? - - firm = Firm.new("name" => "some firm") - account = Account.new("credit_limit" => 1000) - - assert account.new_record? - firm.unautosaved_accounts << account - - firm.save! - assert account.new_record? - end -end - -class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @ship = @pirate.create_ship(:name => 'Nights Dirty Lightning') - end - - # reload - def test_a_marked_for_destruction_record_should_not_be_be_marked_after_reload - @pirate.mark_for_destruction - @pirate.ship.mark_for_destruction - - assert !@pirate.reload.marked_for_destruction? - assert !@pirate.ship.marked_for_destruction? - end - - # has_one - def test_should_destroy_a_child_association_as_part_of_the_save_transaction_if_it_was_marked_for_destroyal - assert !@pirate.ship.marked_for_destruction? - - @pirate.ship.mark_for_destruction - id = @pirate.ship.id - - assert @pirate.ship.marked_for_destruction? - assert Ship.find_by_id(id) - - @pirate.save - assert_nil @pirate.reload.ship - assert_nil Ship.find_by_id(id) - end - - def test_should_skip_validation_on_a_child_association_if_marked_for_destruction - @pirate.ship.name = '' - assert !@pirate.valid? - - @pirate.ship.mark_for_destruction - @pirate.ship.expects(:valid?).never - assert_difference('Ship.count', -1) { @pirate.save! } - end - - def test_a_child_marked_for_destruction_should_not_be_destroyed_twice - @pirate.ship.mark_for_destruction - assert @pirate.save - @pirate.ship.expects(:destroy).never - assert @pirate.save - end - - def test_should_rollback_destructions_if_an_exception_occurred_while_saving_a_child - # Stub the save method of the @pirate.ship instance to destroy and then raise an exception - class << @pirate.ship - def save(*args) - super - destroy - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_not_nil @pirate.reload.ship - end - - # belongs_to - def test_should_destroy_a_parent_association_as_part_of_the_save_transaction_if_it_was_marked_for_destroyal - assert !@ship.pirate.marked_for_destruction? - - @ship.pirate.mark_for_destruction - id = @ship.pirate.id - - assert @ship.pirate.marked_for_destruction? - assert Pirate.find_by_id(id) - - @ship.save - assert_nil @ship.reload.pirate - assert_nil Pirate.find_by_id(id) - end - - def test_should_skip_validation_on_a_parent_association_if_marked_for_destruction - @ship.pirate.catchphrase = '' - assert !@ship.valid? - - @ship.pirate.mark_for_destruction - @ship.pirate.expects(:valid?).never - assert_difference('Pirate.count', -1) { @ship.save! } - end - - def test_a_parent_marked_for_destruction_should_not_be_destroyed_twice - @ship.pirate.mark_for_destruction - assert @ship.save - @ship.pirate.expects(:destroy).never - assert @ship.save - end - - def test_should_rollback_destructions_if_an_exception_occurred_while_saving_a_parent - # Stub the save method of the @ship.pirate instance to destroy and then raise an exception - class << @ship.pirate - def save(*args) - super - destroy - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@ship.save } - assert_not_nil @ship.reload.pirate - end - - # has_many & has_and_belongs_to - %w{ parrots birds }.each do |association_name| - define_method("test_should_destroy_#{association_name}_as_part_of_the_save_transaction_if_they_were_marked_for_destroyal") do - 2.times { |i| @pirate.send(association_name).create!(:name => "#{association_name}_#{i}") } - - assert !@pirate.send(association_name).any? { |child| child.marked_for_destruction? } - - @pirate.send(association_name).each { |child| child.mark_for_destruction } - klass = @pirate.send(association_name).first.class - ids = @pirate.send(association_name).map(&:id) - - assert @pirate.send(association_name).all? { |child| child.marked_for_destruction? } - ids.each { |id| assert klass.find_by_id(id) } - - @pirate.save - assert @pirate.reload.send(association_name).empty? - ids.each { |id| assert_nil klass.find_by_id(id) } - end - - define_method("test_should_skip_validation_on_the_#{association_name}_association_if_marked_for_destruction") do - 2.times { |i| @pirate.send(association_name).create!(:name => "#{association_name}_#{i}") } - children = @pirate.send(association_name) - - children.each { |child| child.name = '' } - assert !@pirate.valid? - - children.each do |child| - child.mark_for_destruction - child.expects(:valid?).never - end - assert_difference("#{association_name.classify}.count", -2) { @pirate.save! } - end - - define_method("test_should_skip_validation_on_the_#{association_name}_association_if_destroyed") do - @pirate.send(association_name).create!(:name => "#{association_name}_1") - children = @pirate.send(association_name) - - children.each { |child| child.name = '' } - assert !@pirate.valid? - - children.each { |child| child.destroy } - assert @pirate.valid? - end - - define_method("test_a_child_marked_for_destruction_should_not_be_destroyed_twice_while_saving_#{association_name}") do - @pirate.send(association_name).create!(:name => "#{association_name}_1") - children = @pirate.send(association_name) - - children.each { |child| child.mark_for_destruction } - assert @pirate.save - children.each { |child| child.expects(:destroy).never } - assert @pirate.save - end - - define_method("test_should_rollback_destructions_if_an_exception_occurred_while_saving_#{association_name}") do - 2.times { |i| @pirate.send(association_name).create!(:name => "#{association_name}_#{i}") } - before = @pirate.send(association_name).map { |c| c.mark_for_destruction ; c } - - # Stub the destroy method of the the second child to raise an exception - class << before.last - def destroy(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert before.first.frozen? # the first child was indeed destroyed - assert_equal before, @pirate.reload.send(association_name) - end - - # Add and remove callbacks tests for association collections. - %w{ method proc }.each do |callback_type| - define_method("test_should_run_add_callback_#{callback_type}s_for_#{association_name}") do - association_name_with_callbacks = "#{association_name}_with_#{callback_type}_callbacks" - - pirate = Pirate.new(:catchphrase => "Arr") - pirate.send(association_name_with_callbacks).build(:name => "Crowe the One-Eyed") - - expected = [ - "before_adding_#{callback_type}_#{association_name.singularize}_<new>", - "after_adding_#{callback_type}_#{association_name.singularize}_<new>" - ] - - assert_equal expected, pirate.ship_log - end - - define_method("test_should_run_remove_callback_#{callback_type}s_for_#{association_name}") do - association_name_with_callbacks = "#{association_name}_with_#{callback_type}_callbacks" - - @pirate.send(association_name_with_callbacks).create!(:name => "Crowe the One-Eyed") - @pirate.send(association_name_with_callbacks).each { |c| c.mark_for_destruction } - child_id = @pirate.send(association_name_with_callbacks).first.id - - @pirate.ship_log.clear - @pirate.save - - expected = [ - "before_removing_#{callback_type}_#{association_name.singularize}_#{child_id}", - "after_removing_#{callback_type}_#{association_name.singularize}_#{child_id}" - ] - - assert_equal expected, @pirate.ship_log - end - end - end -end - -class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @ship = @pirate.create_ship(:name => 'Nights Dirty Lightning') - end - - def test_should_still_work_without_an_associated_model - @ship.destroy - @pirate.reload.catchphrase = "Arr" - @pirate.save - assert 'Arr', @pirate.reload.catchphrase - end - - def test_should_automatically_save_the_associated_model - @pirate.ship.name = 'The Vile Insanity' - @pirate.save - assert_equal 'The Vile Insanity', @pirate.reload.ship.name - end - - def test_should_automatically_save_bang_the_associated_model - @pirate.ship.name = 'The Vile Insanity' - @pirate.save! - assert_equal 'The Vile Insanity', @pirate.reload.ship.name - end - - def test_should_automatically_validate_the_associated_model - @pirate.ship.name = '' - assert !@pirate.valid? - assert_equal "can't be blank", @pirate.errors.on(:"ship.name") - end - - def test_should_merge_errors_on_the_associated_models_onto_the_parent_even_if_it_is_not_valid - @pirate.ship.name = nil - @pirate.catchphrase = nil - assert !@pirate.valid? - assert @pirate.errors.full_messages.include?("Name can't be blank") - assert @pirate.errors.full_messages.include?("Catchphrase can't be blank") - end - - def test_should_still_allow_to_bypass_validations_on_the_associated_model - @pirate.catchphrase = '' - @pirate.ship.name = '' - @pirate.save(false) - assert_equal ['', ''], [@pirate.reload.catchphrase, @pirate.ship.name] - end - - def test_should_allow_to_bypass_validations_on_associated_models_at_any_depth - 2.times { |i| @pirate.ship.parts.create!(:name => "part #{i}") } - - @pirate.catchphrase = '' - @pirate.ship.name = '' - @pirate.ship.parts.each { |part| part.name = '' } - @pirate.save(false) - - values = [@pirate.reload.catchphrase, @pirate.ship.name, *@pirate.ship.parts.map(&:name)] - assert_equal ['', '', '', ''], values - end - - def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that - @pirate.ship.name = '' - assert_raise(ActiveRecord::RecordInvalid) do - @pirate.save! - end - end - - def test_should_not_save_and_return_false_if_a_callback_cancelled_saving - pirate = Pirate.new(:catchphrase => 'Arr') - ship = pirate.build_ship(:name => 'The Vile Insanity') - ship.cancel_save_from_callback = true - - assert_no_difference 'Pirate.count' do - assert_no_difference 'Ship.count' do - assert !pirate.save - end - end - end - - def test_should_rollback_any_changes_if_an_exception_occurred_while_saving - before = [@pirate.catchphrase, @pirate.ship.name] - - @pirate.catchphrase = 'Arr' - @pirate.ship.name = 'The Vile Insanity' - - # Stub the save method of the @pirate.ship instance to raise an exception - class << @pirate.ship - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_equal before, [@pirate.reload.catchphrase, @pirate.ship.name] - end - - def test_should_not_load_the_associated_model - assert_queries(1) { @pirate.catchphrase = 'Arr'; @pirate.save! } - end -end - -class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @ship = Ship.create(:name => 'Nights Dirty Lightning') - @pirate = @ship.create_pirate(:catchphrase => "Don' botharrr talkin' like one, savvy?") - end - - def test_should_still_work_without_an_associated_model - @pirate.destroy - @ship.reload.name = "The Vile Insanity" - @ship.save - assert 'The Vile Insanity', @ship.reload.name - end - - def test_should_automatically_save_the_associated_model - @ship.pirate.catchphrase = 'Arr' - @ship.save - assert_equal 'Arr', @ship.reload.pirate.catchphrase - end - - def test_should_automatically_save_bang_the_associated_model - @ship.pirate.catchphrase = 'Arr' - @ship.save! - assert_equal 'Arr', @ship.reload.pirate.catchphrase - end - - def test_should_automatically_validate_the_associated_model - @ship.pirate.catchphrase = '' - assert !@ship.valid? - assert_equal "can't be blank", @ship.errors.on(:"pirate.catchphrase") - end - - def test_should_merge_errors_on_the_associated_model_onto_the_parent_even_if_it_is_not_valid - @ship.name = nil - @ship.pirate.catchphrase = nil - assert !@ship.valid? - assert @ship.errors.full_messages.include?("Name can't be blank") - assert @ship.errors.full_messages.include?("Catchphrase can't be blank") - end - - def test_should_still_allow_to_bypass_validations_on_the_associated_model - @ship.pirate.catchphrase = '' - @ship.name = '' - @ship.save(false) - assert_equal ['', ''], [@ship.reload.name, @ship.pirate.catchphrase] - end - - def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that - @ship.pirate.catchphrase = '' - assert_raise(ActiveRecord::RecordInvalid) do - @ship.save! - end - end - - def test_should_not_save_and_return_false_if_a_callback_cancelled_saving - ship = Ship.new(:name => 'The Vile Insanity') - pirate = ship.build_pirate(:catchphrase => 'Arr') - pirate.cancel_save_from_callback = true - - assert_no_difference 'Ship.count' do - assert_no_difference 'Pirate.count' do - assert !ship.save - end - end - end - - def test_should_rollback_any_changes_if_an_exception_occurred_while_saving - before = [@ship.pirate.catchphrase, @ship.name] - - @ship.pirate.catchphrase = 'Arr' - @ship.name = 'The Vile Insanity' - - # Stub the save method of the @ship.pirate instance to raise an exception - class << @ship.pirate - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@ship.save } - assert_equal before, [@ship.pirate.reload.catchphrase, @ship.reload.name] - end - - def test_should_not_load_the_associated_model - assert_queries(1) { @ship.name = 'The Vile Insanity'; @ship.save! } - end -end - -module AutosaveAssociationOnACollectionAssociationTests - def test_should_automatically_save_the_associated_models - new_names = ['Grace OMalley', 'Privateers Greed'] - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - - @pirate.save - assert_equal new_names, @pirate.reload.send(@association_name).map(&:name) - end - - def test_should_automatically_save_bang_the_associated_models - new_names = ['Grace OMalley', 'Privateers Greed'] - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - - @pirate.save! - assert_equal new_names, @pirate.reload.send(@association_name).map(&:name) - end - - def test_should_automatically_validate_the_associated_models - @pirate.send(@association_name).each { |child| child.name = '' } - - assert !@pirate.valid? - assert @pirate.errors.full_messages.include?("Name can't be blank") - assert @pirate.errors.on(@association_name).blank? - end - - def test_should_not_use_default_invalid_error_on_associated_models - @pirate.send(@association_name).build(:name => '') - - assert !@pirate.valid? - assert_equal "can't be blank", @pirate.errors.on("#{@association_name}.name") - assert @pirate.errors.on(@association_name).blank? - end - - def test_should_merge_errors_on_the_associated_models_onto_the_parent_even_if_it_is_not_valid - @pirate.send(@association_name).each { |child| child.name = '' } - @pirate.catchphrase = nil - - assert !@pirate.valid? - assert_equal "can't be blank", @pirate.errors.on("#{@association_name}.name") - assert !@pirate.errors.on(:catchphrase).blank? - end - - def test_should_allow_to_bypass_validations_on_the_associated_models_on_update - @pirate.catchphrase = '' - @pirate.send(@association_name).each { |child| child.name = '' } - - assert @pirate.save(false) - assert_equal ['', '', ''], [ - @pirate.reload.catchphrase, - @pirate.send(@association_name).first.name, - @pirate.send(@association_name).last.name - ] - end - - def test_should_validation_the_associated_models_on_create - assert_no_difference("#{ @association_name == :birds ? 'Bird' : 'Parrot' }.count") do - 2.times { @pirate.send(@association_name).build } - @pirate.save(true) - end - end - - def test_should_allow_to_bypass_validations_on_the_associated_models_on_create - assert_difference("#{ @association_name == :birds ? 'Bird' : 'Parrot' }.count", +2) do - 2.times { @pirate.send(@association_name).build } - @pirate.save(false) - end - end - - def test_should_not_save_and_return_false_if_a_callback_cancelled_saving_in_either_create_or_update - @pirate.catchphrase = 'Changed' - @child_1.name = 'Changed' - @child_1.cancel_save_from_callback = true - - assert !@pirate.save - assert_equal "Don' botharrr talkin' like one, savvy?", @pirate.reload.catchphrase - assert_equal "Posideons Killer", @child_1.reload.name - - new_pirate = Pirate.new(:catchphrase => 'Arr') - new_child = new_pirate.send(@association_name).build(:name => 'Grace OMalley') - new_child.cancel_save_from_callback = true - - assert_no_difference 'Pirate.count' do - assert_no_difference "#{new_child.class.name}.count" do - assert !new_pirate.save - end - end - end - - def test_should_rollback_any_changes_if_an_exception_occurred_while_saving - before = [@pirate.catchphrase, *@pirate.send(@association_name).map(&:name)] - new_names = ['Grace OMalley', 'Privateers Greed'] - - @pirate.catchphrase = 'Arr' - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - - # Stub the save method of the first child instance to raise an exception - class << @pirate.send(@association_name).first - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_equal before, [@pirate.reload.catchphrase, *@pirate.send(@association_name).map(&:name)] - end - - def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that - @pirate.send(@association_name).each { |child| child.name = '' } - assert_raise(ActiveRecord::RecordInvalid) do - @pirate.save! - end - end - - def test_should_not_load_the_associated_models_if_they_were_not_loaded_yet - assert_queries(1) { @pirate.catchphrase = 'Arr'; @pirate.save! } - - @pirate.send(@association_name).class # hack to load the target - - assert_queries(3) do - @pirate.catchphrase = 'Yarr' - new_names = ['Grace OMalley', 'Privateers Greed'] - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - @pirate.save! - end - end -end - -class TestAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @association_name = :birds - - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @child_1 = @pirate.birds.create(:name => 'Posideons Killer') - @child_2 = @pirate.birds.create(:name => 'Killer bandita Dionne') - end - - include AutosaveAssociationOnACollectionAssociationTests -end - -class TestAutosaveAssociationOnAHasAndBelongsToManyAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @association_name = :parrots - @habtm = true - - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @child_1 = @pirate.parrots.create(:name => 'Posideons Killer') - @child_2 = @pirate.parrots.create(:name => 'Killer bandita Dionne') - end - - include AutosaveAssociationOnACollectionAssociationTests -end - -class TestAutosaveAssociationValidationsOnAHasManyAssocication < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @pirate.birds.create(:name => 'cookoo') - end - - test "should automatically validate associations" do - assert @pirate.valid? - @pirate.birds.each { |bird| bird.name = '' } - - assert !@pirate.valid? - end -end - -class TestAutosaveAssociationValidationsOnAHasOneAssocication < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @pirate.create_ship(:name => 'titanic') - end - - test "should automatically validate associations with :validate => true" do - assert @pirate.valid? - @pirate.ship.name = '' - assert !@pirate.valid? - end - - test "should not automatically validate associations without :validate => true" do - assert @pirate.valid? - @pirate.non_validated_ship.name = '' - assert @pirate.valid? - end -end - -class TestAutosaveAssociationValidationsOnABelongsToAssocication < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - end - - test "should automatically validate associations with :validate => true" do - assert @pirate.valid? - @pirate.parrot = Parrot.new(:name => '') - assert !@pirate.valid? - end - - test "should not automatically validate associations without :validate => true" do - assert @pirate.valid? - @pirate.non_validated_parrot = Parrot.new(:name => '') - assert @pirate.valid? - end -end - -class TestAutosaveAssociationValidationsOnAHABTMAssocication < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - end - - test "should automatically validate associations with :validate => true" do - assert @pirate.valid? - @pirate.parrots = [ Parrot.new(:name => 'popuga') ] - @pirate.parrots.each { |parrot| parrot.name = '' } - assert !@pirate.valid? - end - - test "should not automatically validate associations without :validate => true" do - assert @pirate.valid? - @pirate.non_validated_parrots = [ Parrot.new(:name => 'popuga') ] - @pirate.non_validated_parrots.each { |parrot| parrot.name = '' } - assert @pirate.valid? - end -end - -class TestAutosaveAssociationValidationMethodsGeneration < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.new - end - - test "should generate validation methods for has_many associations" do - assert @pirate.respond_to?(:validate_associated_records_for_birds) - end - - test "should generate validation methods for has_one associations with :validate => true" do - assert @pirate.respond_to?(:validate_associated_records_for_ship) - end - - test "should not generate validation methods for has_one associations without :validate => true" do - assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_ship) - end - - test "should generate validation methods for belongs_to associations with :validate => true" do - assert @pirate.respond_to?(:validate_associated_records_for_parrot) - end - - test "should not generate validation methods for belongs_to associations without :validate => true" do - assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrot) - end - - test "should generate validation methods for HABTM associations with :validate => true" do - assert @pirate.respond_to?(:validate_associated_records_for_parrots) - end - - test "should not generate validation methods for HABTM associations without :validate => true" do - assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrots) - end -end - -class TestAutosaveAssociationWithTouch < ActiveRecord::TestCase - def test_autosave_with_touch_should_not_raise_system_stack_error - invoice = Invoice.create - assert_nothing_raised { invoice.line_items.create(:amount => 10) } - end -end diff --git a/vendor/rails/activerecord/test/cases/base_test.rb b/vendor/rails/activerecord/test/cases/base_test.rb deleted file mode 100755 index 242be2af..00000000 --- a/vendor/rails/activerecord/test/cases/base_test.rb +++ /dev/null @@ -1,2160 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/event_author' -require 'models/topic' -require 'models/reply' -require 'models/category' -require 'models/company' -require 'models/customer' -require 'models/developer' -require 'models/project' -require 'models/default' -require 'models/auto_id' -require 'models/column_name' -require 'models/subscriber' -require 'models/keyboard' -require 'models/comment' -require 'models/minimalistic' -require 'models/warehouse_thing' -require 'models/parrot' -require 'rexml/document' - -class Category < ActiveRecord::Base; end -class Categorization < ActiveRecord::Base; end -class Smarts < ActiveRecord::Base; end -class CreditCard < ActiveRecord::Base - class PinNumber < ActiveRecord::Base - class CvvCode < ActiveRecord::Base; end - class SubCvvCode < CvvCode; end - end - class SubPinNumber < PinNumber; end - class Brand < Category; end -end -class MasterCreditCard < ActiveRecord::Base; end -class Post < ActiveRecord::Base; end -class Computer < ActiveRecord::Base; end -class NonExistentTable < ActiveRecord::Base; end -class TestOracleDefault < ActiveRecord::Base; end - -class LoosePerson < ActiveRecord::Base - self.table_name = 'people' - self.abstract_class = true - attr_protected :credit_rating, :administrator -end - -class LooseDescendant < LoosePerson - attr_protected :phone_number -end - -class LooseDescendantSecond< LoosePerson - attr_protected :phone_number - attr_protected :name -end - -class TightPerson < ActiveRecord::Base - self.table_name = 'people' - attr_accessible :name, :address -end - -class TightDescendant < TightPerson - attr_accessible :phone_number -end - -class ReadonlyTitlePost < Post - attr_readonly :title -end - -class Booleantest < ActiveRecord::Base; end - -class Task < ActiveRecord::Base - attr_protected :starting -end - -class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base - self.table_name = 'topics' - attr_accessible :author_name - attr_protected :content -end - -class BasicsTest < ActiveRecord::TestCase - fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts - - def test_column_names_are_escaped - conn = ActiveRecord::Base.connection - classname = conn.class.name[/[^:]*$/] - badchar = { - 'SQLite3Adapter' => '"', - 'MysqlAdapter' => '`', - 'Mysql2Adapter' => '`', - 'PostgreSQLAdapter' => '"', - 'OracleAdapter' => '"', - }.fetch(classname) { - raise "need a bad char for #{classname}" - } - - quoted = conn.quote_column_name "foo#{badchar}bar" - assert_equal("#{badchar}foo#{badchar * 2}bar#{badchar}", quoted) - end - - def test_table_exists - assert !NonExistentTable.table_exists? - assert Topic.table_exists? - end - - def test_set_attributes - topic = Topic.find(1) - topic.attributes = { "title" => "Budget", "author_name" => "Jason" } - topic.save - assert_equal("Budget", topic.title) - assert_equal("Jason", topic.author_name) - assert_equal(topics(:first).author_email_address, Topic.find(1).author_email_address) - end - - def test_integers_as_nil - test = AutoId.create('value' => '') - assert_nil AutoId.find(test.id).value - end - - def test_set_attributes_with_block - topic = Topic.new do |t| - t.title = "Budget" - t.author_name = "Jason" - end - - assert_equal("Budget", topic.title) - assert_equal("Jason", topic.author_name) - end - - def test_respond_to? - topic = Topic.find(1) - assert topic.respond_to?("title") - assert topic.respond_to?("title?") - assert topic.respond_to?("title=") - assert topic.respond_to?(:title) - assert topic.respond_to?(:title?) - assert topic.respond_to?(:title=) - assert topic.respond_to?("author_name") - assert topic.respond_to?("attribute_names") - assert !topic.respond_to?("nothingness") - assert !topic.respond_to?(:nothingness) - end - - def test_array_content - topic = Topic.new - topic.content = %w( one two three ) - topic.save - - assert_equal(%w( one two three ), Topic.find(topic.id).content) - end - - def test_read_attributes_before_type_cast - category = Category.new({:name=>"Test categoty", :type => nil}) - category_attrs = {"name"=>"Test categoty", "type" => nil, "categorizations_count" => nil} - assert_equal category_attrs , category.attributes_before_type_cast - end - - if current_adapter?(:MysqlAdapter) - def test_read_attributes_before_type_cast_on_boolean - bool = Booleantest.create({ "value" => false }) - assert_equal "0", bool.reload.attributes_before_type_cast["value"] - end - end - - def test_read_attributes_before_type_cast_on_datetime - developer = Developer.find(:first) - assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"] - end - - def test_hash_content - topic = Topic.new - topic.content = { "one" => 1, "two" => 2 } - topic.save - - assert_equal 2, Topic.find(topic.id).content["two"] - - topic.content_will_change! - topic.content["three"] = 3 - topic.save - - assert_equal 3, Topic.find(topic.id).content["three"] - end - - def test_update_array_content - topic = Topic.new - topic.content = %w( one two three ) - - topic.content.push "four" - assert_equal(%w( one two three four ), topic.content) - - topic.save - - topic = Topic.find(topic.id) - topic.content << "five" - assert_equal(%w( one two three four five ), topic.content) - end - - def test_case_sensitive_attributes_hash - # DB2 is not case-sensitive - return true if current_adapter?(:DB2Adapter) - - assert_equal @loaded_fixtures['computers']['workstation'].to_hash, Computer.find(:first).attributes - end - - def test_create - topic = Topic.new - topic.title = "New Topic" - topic.save - topic_reloaded = Topic.find(topic.id) - assert_equal("New Topic", topic_reloaded.title) - end - - def test_save! - topic = Topic.new(:title => "New Topic") - assert topic.save! - - reply = Reply.new - assert_raise(ActiveRecord::RecordInvalid) { reply.save! } - end - - def test_save_null_string_attributes - topic = Topic.find(1) - topic.attributes = { "title" => "null", "author_name" => "null" } - topic.save! - topic.reload - assert_equal("null", topic.title) - assert_equal("null", topic.author_name) - end - - def test_save_nil_string_attributes - topic = Topic.find(1) - topic.title = nil - topic.save! - topic.reload - assert_nil topic.title - end - - def test_save_for_record_with_only_primary_key - minimalistic = Minimalistic.new - assert_nothing_raised { minimalistic.save } - end - - def test_save_for_record_with_only_primary_key_that_is_provided - assert_nothing_raised { Minimalistic.create!(:id => 2) } - end - - def test_hashes_not_mangled - new_topic = { :title => "New Topic" } - new_topic_values = { :title => "AnotherTopic" } - - topic = Topic.new(new_topic) - assert_equal new_topic[:title], topic.title - - topic.attributes= new_topic_values - assert_equal new_topic_values[:title], topic.title - end - - def test_create_many - topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) - assert_equal 2, topics.size - assert_equal "first", topics.first.title - end - - def test_create_columns_not_equal_attributes - topic = Topic.new - topic.title = 'Another New Topic' - topic.send :write_attribute, 'does_not_exist', 'test' - assert_nothing_raised { topic.save } - end - - def test_create_through_factory - topic = Topic.create("title" => "New Topic") - topicReloaded = Topic.find(topic.id) - assert_equal(topic, topicReloaded) - end - - def test_create_through_factory_with_block - topic = Topic.create("title" => "New Topic") do |t| - t.author_name = "David" - end - topicReloaded = Topic.find(topic.id) - assert_equal("New Topic", topic.title) - assert_equal("David", topic.author_name) - end - - def test_create_many_through_factory_with_block - topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) do |t| - t.author_name = "David" - end - assert_equal 2, topics.size - topic1, topic2 = Topic.find(topics[0].id), Topic.find(topics[1].id) - assert_equal "first", topic1.title - assert_equal "David", topic1.author_name - assert_equal "second", topic2.title - assert_equal "David", topic2.author_name - end - - def test_update - topic = Topic.new - topic.title = "Another New Topic" - topic.written_on = "2003-12-12 23:23:00" - topic.save - topicReloaded = Topic.find(topic.id) - assert_equal("Another New Topic", topicReloaded.title) - - topicReloaded.title = "Updated topic" - topicReloaded.save - - topicReloadedAgain = Topic.find(topic.id) - - assert_equal("Updated topic", topicReloadedAgain.title) - end - - def test_update_columns_not_equal_attributes - topic = Topic.new - topic.title = "Still another topic" - topic.save - - topicReloaded = Topic.find(topic.id) - topicReloaded.title = "A New Topic" - topicReloaded.send :write_attribute, 'does_not_exist', 'test' - assert_nothing_raised { topicReloaded.save } - end - - def test_update_for_record_with_only_primary_key - minimalistic = minimalistics(:first) - assert_nothing_raised { minimalistic.save } - end - - def test_write_attribute - topic = Topic.new - topic.send(:write_attribute, :title, "Still another topic") - assert_equal "Still another topic", topic.title - - topic.send(:write_attribute, "title", "Still another topic: part 2") - assert_equal "Still another topic: part 2", topic.title - end - - def test_read_attribute - topic = Topic.new - topic.title = "Don't change the topic" - assert_equal "Don't change the topic", topic.send(:read_attribute, "title") - assert_equal "Don't change the topic", topic["title"] - - assert_equal "Don't change the topic", topic.send(:read_attribute, :title) - assert_equal "Don't change the topic", topic[:title] - end - - def test_read_attribute_when_false - topic = topics(:first) - topic.approved = false - assert !topic.approved?, "approved should be false" - topic.approved = "false" - assert !topic.approved?, "approved should be false" - end - - def test_read_attribute_when_true - topic = topics(:first) - topic.approved = true - assert topic.approved?, "approved should be true" - topic.approved = "true" - assert topic.approved?, "approved should be true" - end - - def test_read_write_boolean_attribute - topic = Topic.new - # puts "" - # puts "New Topic" - # puts topic.inspect - topic.approved = "false" - # puts "Expecting false" - # puts topic.inspect - assert !topic.approved?, "approved should be false" - topic.approved = "false" - # puts "Expecting false" - # puts topic.inspect - assert !topic.approved?, "approved should be false" - topic.approved = "true" - # puts "Expecting true" - # puts topic.inspect - assert topic.approved?, "approved should be true" - topic.approved = "true" - # puts "Expecting true" - # puts topic.inspect - assert topic.approved?, "approved should be true" - # puts "" - end - - def test_query_attribute_string - [nil, "", " "].each do |value| - assert_equal false, Topic.new(:author_name => value).author_name? - end - - assert_equal true, Topic.new(:author_name => "Name").author_name? - end - - def test_query_attribute_number - [nil, 0, "0"].each do |value| - assert_equal false, Developer.new(:salary => value).salary? - end - - assert_equal true, Developer.new(:salary => 1).salary? - assert_equal true, Developer.new(:salary => "1").salary? - end - - def test_query_attribute_boolean - [nil, "", false, "false", "f", 0].each do |value| - assert_equal false, Topic.new(:approved => value).approved? - end - - [true, "true", "1", 1].each do |value| - assert_equal true, Topic.new(:approved => value).approved? - end - end - - def test_query_attribute_with_custom_fields - object = Company.find_by_sql(<<-SQL).first - SELECT c1.*, c2.ruby_type as string_value, c2.rating as int_value - FROM companies c1, companies c2 - WHERE c1.firm_id = c2.id - AND c1.id = 2 - SQL - - assert_equal "Firm", object.string_value - assert object.string_value? - - object.string_value = " " - assert !object.string_value? - - assert_equal 1, object.int_value.to_i - assert object.int_value? - - object.int_value = "0" - assert !object.int_value? - end - - - def test_reader_for_invalid_column_names - Topic.send(:define_read_method, "mumub-jumbo".to_sym, "mumub-jumbo", nil) - assert !Topic.generated_methods.include?("mumub-jumbo") - end - - def test_non_attribute_access_and_assignment - topic = Topic.new - assert !topic.respond_to?("mumbo") - assert_raise(NoMethodError) { topic.mumbo } - assert_raise(NoMethodError) { topic.mumbo = 5 } - end - - def test_preserving_date_objects - if current_adapter?(:SybaseAdapter, :OracleAdapter) - # Sybase ctlib does not (yet?) support the date type; use datetime instead. - # Oracle treats all dates/times as Time. - assert_kind_of( - Time, Topic.find(1).last_read, - "The last_read attribute should be of the Time class" - ) - else - assert_kind_of( - Date, Topic.find(1).last_read, - "The last_read attribute should be of the Date class" - ) - end - end - - def test_preserving_time_objects - assert_kind_of( - Time, Topic.find(1).bonus_time, - "The bonus_time attribute should be of the Time class" - ) - - assert_kind_of( - Time, Topic.find(1).written_on, - "The written_on attribute should be of the Time class" - ) - - # For adapters which support microsecond resolution. - if current_adapter?(:PostgreSQLAdapter) - assert_equal 11, Topic.find(1).written_on.sec - assert_equal 223300, Topic.find(1).written_on.usec - assert_equal 9900, Topic.find(2).written_on.usec - end - end - - def test_custom_mutator - topic = Topic.find(1) - # This mutator is protected in the class definition - topic.send(:approved=, true) - assert topic.instance_variable_get("@custom_approved") - end - - def test_delete - topic = Topic.find(1) - assert_equal topic, topic.delete, 'topic.delete did not return self' - assert topic.frozen?, 'topic not frozen after delete' - assert topic.destroyed?, 'topic not marked as being destroyed' - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(topic.id) } - end - - def test_delete_doesnt_run_callbacks - Topic.find(1).delete - assert_not_nil Topic.find(2) - end - - def test_destroy - topic = Topic.find(1) - assert_equal topic, topic.destroy, 'topic.destroy did not return self' - assert topic.frozen?, 'topic not frozen after destroy' - assert topic.destroyed?, 'topic not marked as being destroyed' - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(topic.id) } - end - - def test_record_not_found_exception - assert_raise(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) } - end - - def test_initialize_with_attributes - topic = Topic.new({ - "title" => "initialized from attributes", "written_on" => "2003-12-12 23:23" - }) - - assert_equal("initialized from attributes", topic.title) - end - - def test_initialize_with_invalid_attribute - begin - topic = Topic.new({ "title" => "test", - "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"}) - rescue ActiveRecord::MultiparameterAssignmentErrors => ex - assert_equal(1, ex.errors.size) - assert_equal("last_read", ex.errors[0].attribute) - end - end - - def test_load - topics = Topic.find(:all, :order => 'id') - assert_equal(4, topics.size) - assert_equal(topics(:first).title, topics.first.title) - end - - def test_load_with_condition - topics = Topic.find(:all, :conditions => "author_name = 'Mary'") - - assert_equal(1, topics.size) - assert_equal(topics(:second).title, topics.first.title) - end - - def test_table_name_guesses - classes = [Category, Smarts, CreditCard, CreditCard::PinNumber, CreditCard::PinNumber::CvvCode, CreditCard::SubPinNumber, CreditCard::Brand, MasterCreditCard] - - assert_equal "topics", Topic.table_name - - assert_equal "categories", Category.table_name - assert_equal "smarts", Smarts.table_name - assert_equal "credit_cards", CreditCard.table_name - assert_equal "credit_card_pin_numbers", CreditCard::PinNumber.table_name - assert_equal "credit_card_pin_number_cvv_codes", CreditCard::PinNumber::CvvCode.table_name - assert_equal "credit_card_pin_numbers", CreditCard::SubPinNumber.table_name - assert_equal "categories", CreditCard::Brand.table_name - assert_equal "master_credit_cards", MasterCreditCard.table_name - - ActiveRecord::Base.pluralize_table_names = false - classes.each(&:reset_table_name) - - assert_equal "category", Category.table_name - assert_equal "smarts", Smarts.table_name - assert_equal "credit_card", CreditCard.table_name - assert_equal "credit_card_pin_number", CreditCard::PinNumber.table_name - assert_equal "credit_card_pin_number_cvv_code", CreditCard::PinNumber::CvvCode.table_name - assert_equal "credit_card_pin_number", CreditCard::SubPinNumber.table_name - assert_equal "category", CreditCard::Brand.table_name - assert_equal "master_credit_card", MasterCreditCard.table_name - - ActiveRecord::Base.pluralize_table_names = true - classes.each(&:reset_table_name) - - ActiveRecord::Base.table_name_prefix = "test_" - Category.reset_table_name - assert_equal "test_categories", Category.table_name - ActiveRecord::Base.table_name_suffix = "_test" - Category.reset_table_name - assert_equal "test_categories_test", Category.table_name - ActiveRecord::Base.table_name_prefix = "" - Category.reset_table_name - assert_equal "categories_test", Category.table_name - ActiveRecord::Base.table_name_suffix = "" - Category.reset_table_name - assert_equal "categories", Category.table_name - - ActiveRecord::Base.pluralize_table_names = false - ActiveRecord::Base.table_name_prefix = "test_" - Category.reset_table_name - assert_equal "test_category", Category.table_name - ActiveRecord::Base.table_name_suffix = "_test" - Category.reset_table_name - assert_equal "test_category_test", Category.table_name - ActiveRecord::Base.table_name_prefix = "" - Category.reset_table_name - assert_equal "category_test", Category.table_name - ActiveRecord::Base.table_name_suffix = "" - Category.reset_table_name - assert_equal "category", Category.table_name - - ActiveRecord::Base.pluralize_table_names = true - classes.each(&:reset_table_name) - end - - def test_destroy_all - conditions = "author_name = 'Mary'" - topics_by_mary = Topic.all(:conditions => conditions, :order => 'id') - assert ! topics_by_mary.empty? - - assert_difference('Topic.count', -topics_by_mary.size) do - destroyed = Topic.destroy_all(conditions).sort_by(&:id) - assert_equal topics_by_mary, destroyed - assert destroyed.all? { |topic| topic.frozen? } - end - end - - def test_destroy_many - clients = Client.find([2, 3], :order => 'id') - - assert_difference('Client.count', -2) do - destroyed = Client.destroy([2, 3]).sort_by(&:id) - assert_equal clients, destroyed - assert destroyed.all? { |client| client.frozen? } - end - end - - def test_delete_many - original_count = Topic.count - Topic.delete(deleting = [1, 2]) - assert_equal original_count - deleting.size, Topic.count - end - - def test_boolean_attributes - assert ! Topic.find(1).approved? - assert Topic.find(2).approved? - end - - def test_update_all - assert_equal Topic.count, Topic.update_all("content = 'bulk updated!'") - assert_equal "bulk updated!", Topic.find(1).content - assert_equal "bulk updated!", Topic.find(2).content - - assert_equal Topic.count, Topic.update_all(['content = ?', 'bulk updated again!']) - assert_equal "bulk updated again!", Topic.find(1).content - assert_equal "bulk updated again!", Topic.find(2).content - - assert_equal Topic.count, Topic.update_all(['content = ?', nil]) - assert_nil Topic.find(1).content - end - - def test_update_all_with_hash - assert_not_nil Topic.find(1).last_read - assert_equal Topic.count, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil) - assert_equal "bulk updated with hash!", Topic.find(1).content - assert_equal "bulk updated with hash!", Topic.find(2).content - assert_nil Topic.find(1).last_read - assert_nil Topic.find(2).last_read - end - - def test_update_all_with_non_standard_table_name - assert_equal 1, WarehouseThing.update_all(['value = ?', 0], ['id = ?', 1]) - assert_equal 0, WarehouseThing.find(1).value - end - - if current_adapter?(:MysqlAdapter) - def test_update_all_with_order_and_limit - assert_equal 1, Topic.update_all("content = 'bulk updated!'", nil, :limit => 1, :order => 'id DESC') - end - end - - def test_update_all_ignores_order_without_limit_from_association - author = authors(:david) - assert_nothing_raised do - assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ]) - end - end - - def test_update_all_with_order_and_limit_updates_subset_only - author = authors(:david) - assert_nothing_raised do - assert_equal 1, author.posts_sorted_by_id_limited.size - assert_equal 2, author.posts_sorted_by_id_limited.find(:all, :limit => 2).size - assert_equal 1, author.posts_sorted_by_id_limited.update_all([ "body = ?", "bulk update!" ]) - assert_equal "bulk update!", posts(:welcome).body - assert_not_equal "bulk update!", posts(:thinking).body - end - end - - def test_update_many - topic_data = { 1 => { "content" => "1 updated" }, 2 => { "content" => "2 updated" } } - updated = Topic.update(topic_data.keys, topic_data.values) - - assert_equal 2, updated.size - assert_equal "1 updated", Topic.find(1).content - assert_equal "2 updated", Topic.find(2).content - end - - def test_delete_all - assert Topic.count > 0 - - assert_equal Topic.count, Topic.delete_all - end - - def test_update_by_condition - Topic.update_all "content = 'bulk updated!'", ["approved = ?", true] - assert_equal "Have a nice day", Topic.find(1).content - assert_equal "bulk updated!", Topic.find(2).content - end - - def test_attribute_present - t = Topic.new - t.title = "hello there!" - t.written_on = Time.now - assert t.attribute_present?("title") - assert t.attribute_present?("written_on") - assert !t.attribute_present?("content") - end - - def test_attribute_keys_on_new_instance - t = Topic.new - assert_equal nil, t.title, "The topics table has a title column, so it should be nil" - assert_raise(NoMethodError) { t.title2 } - end - - def test_class_name - ActiveSupport::Deprecation.silence do - assert_equal "Firm", ActiveRecord::Base.class_name("firms") - assert_equal "Category", ActiveRecord::Base.class_name("categories") - assert_equal "AccountHolder", ActiveRecord::Base.class_name("account_holder") - - ActiveRecord::Base.pluralize_table_names = false - assert_equal "Firms", ActiveRecord::Base.class_name( "firms" ) - ActiveRecord::Base.pluralize_table_names = true - - ActiveRecord::Base.table_name_prefix = "test_" - assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms" ) - ActiveRecord::Base.table_name_suffix = "_tests" - assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms_tests" ) - ActiveRecord::Base.table_name_prefix = "" - assert_equal "Firm", ActiveRecord::Base.class_name( "firms_tests" ) - ActiveRecord::Base.table_name_suffix = "" - assert_equal "Firm", ActiveRecord::Base.class_name( "firms" ) - end - end - - def test_null_fields - assert_nil Topic.find(1).parent_id - assert_nil Topic.create("title" => "Hey you").parent_id - end - - def test_default_values - topic = Topic.new - assert topic.approved? - assert_nil topic.written_on - assert_nil topic.bonus_time - assert_nil topic.last_read - - topic.save - - topic = Topic.find(topic.id) - assert topic.approved? - assert_nil topic.last_read - - # Oracle has some funky default handling, so it requires a bit of - # extra testing. See ticket #2788. - if current_adapter?(:OracleAdapter) - test = TestOracleDefault.new - assert_equal "X", test.test_char - assert_equal "hello", test.test_string - assert_equal 3, test.test_int - end - end - - # Oracle, and Sybase do not have a TIME datatype. - unless current_adapter?(:OracleAdapter, :SybaseAdapter) - def test_utc_as_time_zone - Topic.default_timezone = :utc - attributes = { "bonus_time" => "5:42:00AM" } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time - Topic.default_timezone = :local - end - - def test_utc_as_time_zone_and_new - Topic.default_timezone = :utc - attributes = { "bonus_time(1i)"=>"2000", - "bonus_time(2i)"=>"1", - "bonus_time(3i)"=>"1", - "bonus_time(4i)"=>"10", - "bonus_time(5i)"=>"35", - "bonus_time(6i)"=>"50" } - topic = Topic.new(attributes) - assert_equal Time.utc(2000, 1, 1, 10, 35, 50), topic.bonus_time - Topic.default_timezone = :local - end - end - - def test_default_values_on_empty_strings - topic = Topic.new - topic.approved = nil - topic.last_read = nil - - topic.save - - topic = Topic.find(topic.id) - assert_nil topic.last_read - - # Sybase adapter does not allow nulls in boolean columns - if current_adapter?(:SybaseAdapter) - assert topic.approved == false - else - assert_nil topic.approved - end - end - - def test_equality - assert_equal Topic.find(1), Topic.find(2).topic - end - - def test_equality_of_new_records - assert_not_equal Topic.new, Topic.new - end - - def test_hashing - assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ] - end - - def test_delete_new_record - client = Client.new - client.delete - assert client.frozen? - end - - def test_delete_record_with_associations - client = Client.find(3) - client.delete - assert client.frozen? - assert_kind_of Firm, client.firm - assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" } - end - - def test_destroy_new_record - client = Client.new - client.destroy - assert client.frozen? - end - - def test_destroy_record_with_associations - client = Client.find(3) - client.destroy - assert client.frozen? - assert_kind_of Firm, client.firm - assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" } - end - - def test_update_attribute - assert !Topic.find(1).approved? - Topic.find(1).update_attribute("approved", true) - assert Topic.find(1).approved? - - Topic.find(1).update_attribute(:approved, false) - assert !Topic.find(1).approved? - end - - def test_update_attributes - topic = Topic.find(1) - assert !topic.approved? - assert_equal "The First Topic", topic.title - - topic.update_attributes("approved" => true, "title" => "The First Topic Updated") - topic.reload - assert topic.approved? - assert_equal "The First Topic Updated", topic.title - - topic.update_attributes(:approved => false, :title => "The First Topic") - topic.reload - assert !topic.approved? - assert_equal "The First Topic", topic.title - end - - def test_update_attributes! - reply = Reply.find(2) - assert_equal "The Second Topic of the day", reply.title - assert_equal "Have a nice day", reply.content - - reply.update_attributes!("title" => "The Second Topic of the day updated", "content" => "Have a nice evening") - reply.reload - assert_equal "The Second Topic of the day updated", reply.title - assert_equal "Have a nice evening", reply.content - - reply.update_attributes!(:title => "The Second Topic of the day", :content => "Have a nice day") - reply.reload - assert_equal "The Second Topic of the day", reply.title - assert_equal "Have a nice day", reply.content - - assert_raise(ActiveRecord::RecordInvalid) { reply.update_attributes!(:title => nil, :content => "Have a nice evening") } - end - - def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used - topic = TopicWithProtectedContentAndAccessibleAuthorName.new - assert_raise(RuntimeError) { topic.attributes = { "author_name" => "me" } } - assert_raise(RuntimeError) { topic.attributes = { "content" => "stuff" } } - end - - def test_mass_assignment_protection - firm = Firm.new - firm.attributes = { "name" => "Next Angle", "rating" => 5 } - assert_equal 1, firm.rating - end - - def test_mass_assignment_protection_against_class_attribute_writers - [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging, - :default_timezone, :schema_format, :lock_optimistically, :record_timestamps].each do |method| - assert Task.respond_to?(method) - assert Task.respond_to?("#{method}=") - assert Task.new.respond_to?(method) - assert !Task.new.respond_to?("#{method}=") - end - end - - def test_customized_primary_key_remains_protected - subscriber = Subscriber.new(:nick => 'webster123', :name => 'nice try') - assert_nil subscriber.id - - keyboard = Keyboard.new(:key_number => 9, :name => 'nice try') - assert_nil keyboard.id - end - - def test_customized_primary_key_remains_protected_when_referred_to_as_id - subscriber = Subscriber.new(:id => 'webster123', :name => 'nice try') - assert_nil subscriber.id - - keyboard = Keyboard.new(:id => 9, :name => 'nice try') - assert_nil keyboard.id - end - - def test_mass_assigning_invalid_attribute - firm = Firm.new - - assert_raise(ActiveRecord::UnknownAttributeError) do - firm.attributes = { "id" => 5, "type" => "Client", "i_dont_even_exist" => 20 } - end - end - - def test_mass_assignment_protection_on_defaults - firm = Firm.new - firm.attributes = { "id" => 5, "type" => "Client" } - assert_nil firm.id - assert_equal "Firm", firm[:type] - end - - def test_mass_assignment_accessible - reply = Reply.new("title" => "hello", "content" => "world", "approved" => true) - reply.save - - assert reply.approved? - - reply.approved = false - reply.save - - assert !reply.approved? - end - - def test_mass_assignment_protection_inheritance - assert_nil LoosePerson.accessible_attributes - assert_equal Set.new([ 'credit_rating', 'administrator' ]), LoosePerson.protected_attributes - - assert_nil LooseDescendant.accessible_attributes - assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number' ]), LooseDescendant.protected_attributes - - assert_nil LooseDescendantSecond.accessible_attributes - assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number', 'name' ]), LooseDescendantSecond.protected_attributes, 'Running attr_protected twice in one class should merge the protections' - - assert_nil TightPerson.protected_attributes - assert_equal Set.new([ 'name', 'address' ]), TightPerson.accessible_attributes - - assert_nil TightDescendant.protected_attributes - assert_equal Set.new([ 'name', 'address', 'phone_number' ]), TightDescendant.accessible_attributes - end - - def test_readonly_attributes - assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes - - post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable") - post.reload - assert_equal "cannot change this", post.title - - post.update_attributes(:title => "try to change", :body => "changed") - post.reload - assert_equal "cannot change this", post.title - assert_equal "changed", post.body - end - - def test_multiparameter_attribute_assignment_via_association_proxy - multiparameter_date_attribute = { - "ends_on(1i)" => "2004", "ends_on(2i)" => "6", "ends_on(3i)" => "24", - "ends_on(4i)" => "16", "ends_on(5i)" => "24", "ends_on(6i)" => "00" - } - - author = Author.create(:name => "dhh") - event = author.events.create(multiparameter_date_attribute) - - assert_equal Time.local(2004,6,24,16,24,0),event.ends_on - end - - def test_multiparameter_attributes_on_date - attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "24" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(2004, 6, 24), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_year - attributes = { "last_read(1i)" => "", "last_read(2i)" => "6", "last_read(3i)" => "24" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(1, 6, 24), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_month - attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "", "last_read(3i)" => "24" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(2004, 1, 24), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_day - attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(2004, 6, 1), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_day_and_year - attributes = { "last_read(1i)" => "", "last_read(2i)" => "6", "last_read(3i)" => "" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(1, 6, 1), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_day_and_month - attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "", "last_read(3i)" => "" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(2004, 1, 1), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_year_and_month - attributes = { "last_read(1i)" => "", "last_read(2i)" => "", "last_read(3i)" => "24" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(1, 1, 24), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_all_empty - attributes = { "last_read(1i)" => "", "last_read(2i)" => "", "last_read(3i)" => "" } - topic = Topic.find(1) - topic.attributes = attributes - assert_nil topic.last_read - end - - def test_multiparameter_attributes_on_time - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on - end - - def test_multiparameter_attributes_on_time_with_old_date - attributes = { - "written_on(1i)" => "1850", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - # testing against to_s(:db) representation because either a Time or a DateTime might be returned, depending on platform - assert_equal "1850-06-24 16:24:00", topic.written_on.to_s(:db) - end - - def test_multiparameter_attributes_on_time_with_utc - ActiveRecord::Base.default_timezone = :utc - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on - ensure - ActiveRecord::Base.default_timezone = :local - end - - def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2004, 6, 24, 23, 24, 0), topic.written_on - assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on.time - assert_equal Time.zone, topic.written_on.time_zone - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil - end - - def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_false - ActiveRecord::Base.time_zone_aware_attributes = false - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on - assert_equal false, topic.written_on.respond_to?(:time_zone) - ensure - Time.zone = nil - end - - def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_attributes - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - Topic.skip_time_zone_conversion_for_attributes = [:written_on] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on - assert_equal false, topic.written_on.respond_to?(:time_zone) - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil - Topic.skip_time_zone_conversion_for_attributes = [] - end - - def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "bonus_time(1i)" => "2000", "bonus_time(2i)" => "1", "bonus_time(3i)" => "1", - "bonus_time(4i)" => "16", "bonus_time(5i)" => "24" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2000, 1, 1, 16, 24, 0), topic.bonus_time - assert topic.bonus_time.utc? - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil - end - - def test_multiparameter_attributes_on_time_with_empty_seconds - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on - end - - def test_multiparameter_mass_assignment_protector - task = Task.new - time = Time.mktime(2000, 1, 1, 1) - task.starting = time - attributes = { "starting(1i)" => "2004", "starting(2i)" => "6", "starting(3i)" => "24" } - task.attributes = attributes - assert_equal time, task.starting - end - - def test_multiparameter_assignment_of_aggregation - customer = Customer.new - address = Address.new("The Street", "The City", "The Country") - attributes = { "address(1)" => address.street, "address(2)" => address.city, "address(3)" => address.country } - customer.attributes = attributes - assert_equal address, customer.address - end - - def test_attributes_on_dummy_time - # Oracle, and Sybase do not have a TIME datatype. - return true if current_adapter?(:OracleAdapter, :SybaseAdapter) - - attributes = { - "bonus_time" => "5:42:00AM" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time - end - - def test_boolean - b_nil = Booleantest.create({ "value" => nil }) - nil_id = b_nil.id - b_false = Booleantest.create({ "value" => false }) - false_id = b_false.id - b_true = Booleantest.create({ "value" => true }) - true_id = b_true.id - - b_nil = Booleantest.find(nil_id) - assert_nil b_nil.value - b_false = Booleantest.find(false_id) - assert !b_false.value? - b_true = Booleantest.find(true_id) - assert b_true.value? - end - - def test_boolean_cast_from_string - b_blank = Booleantest.create({ "value" => "" }) - blank_id = b_blank.id - b_false = Booleantest.create({ "value" => "0" }) - false_id = b_false.id - b_true = Booleantest.create({ "value" => "1" }) - true_id = b_true.id - - b_blank = Booleantest.find(blank_id) - assert_nil b_blank.value - b_false = Booleantest.find(false_id) - assert !b_false.value? - b_true = Booleantest.find(true_id) - assert b_true.value? - end - - def test_new_record_returns_boolean - assert_equal Topic.new.new_record?, true - assert_equal Topic.find(1).new_record?, false - end - - def test_clone - topic = Topic.find(1) - cloned_topic = nil - assert_nothing_raised { cloned_topic = topic.clone } - assert_equal topic.title, cloned_topic.title - assert cloned_topic.new_record? - - # test if the attributes have been cloned - topic.title = "a" - cloned_topic.title = "b" - assert_equal "a", topic.title - assert_equal "b", cloned_topic.title - - # test if the attribute values have been cloned - topic.title = {"a" => "b"} - cloned_topic = topic.clone - cloned_topic.title["a"] = "c" - assert_equal "b", topic.title["a"] - - #test if attributes set as part of after_initialize are cloned correctly - assert_equal topic.author_email_address, cloned_topic.author_email_address - - # test if saved clone object differs from original - cloned_topic.save - assert !cloned_topic.new_record? - assert cloned_topic.id != topic.id - end - - def test_clone_with_aggregate_of_same_name_as_attribute - dev = DeveloperWithAggregate.find(1) - assert_kind_of DeveloperSalary, dev.salary - - clone = nil - assert_nothing_raised { clone = dev.clone } - assert_kind_of DeveloperSalary, clone.salary - assert_equal dev.salary.amount, clone.salary.amount - assert clone.new_record? - - # test if the attributes have been cloned - original_amount = clone.salary.amount - dev.salary.amount = 1 - assert_equal original_amount, clone.salary.amount - - assert clone.save - assert !clone.new_record? - assert clone.id != dev.id - end - - def test_clone_preserves_subtype - clone = nil - assert_nothing_raised { clone = Company.find(3).clone } - assert_kind_of Client, clone - end - - def test_bignum - company = Company.find(1) - company.rating = 2147483647 - company.save - company = Company.find(1) - assert_equal 2147483647, company.rating - end - - # TODO: extend defaults tests to other databases! - if current_adapter?(:PostgreSQLAdapter) - def test_default - default = Default.new - - # fixed dates / times - assert_equal Date.new(2004, 1, 1), default.fixed_date - assert_equal Time.local(2004, 1,1,0,0,0,0), default.fixed_time - - # char types - assert_equal 'Y', default.char1 - assert_equal 'a varchar field', default.char2 - assert_equal 'a text field', default.char3 - end - - class Geometric < ActiveRecord::Base; end - def test_geometric_content - - # accepted format notes: - # ()'s aren't required - # values can be a mix of float or integer - - g = Geometric.new( - :a_point => '(5.0, 6.1)', - #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql - :a_line_segment => '(2.0, 3), (5.5, 7.0)', - :a_box => '2.0, 3, 5.5, 7.0', - :a_path => '[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]', # [ ] is an open path - :a_polygon => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', - :a_circle => '<(5.3, 10.4), 2>' - ) - - assert g.save - - # Reload and check that we have all the geometric attributes. - h = Geometric.find(g.id) - - assert_equal '(5,6.1)', h.a_point - assert_equal '[(2,3),(5.5,7)]', h.a_line_segment - assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner - assert_equal '[(2,3),(5.5,7),(8.5,11)]', h.a_path - assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon - assert_equal '<(5.3,10.4),2>', h.a_circle - - # use a geometric function to test for an open path - objs = Geometric.find_by_sql ["select isopen(a_path) from geometrics where id = ?", g.id] - assert_equal objs[0].isopen, 't' - - # test alternate formats when defining the geometric types - - g = Geometric.new( - :a_point => '5.0, 6.1', - #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql - :a_line_segment => '((2.0, 3), (5.5, 7.0))', - :a_box => '(2.0, 3), (5.5, 7.0)', - :a_path => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', # ( ) is a closed path - :a_polygon => '2.0, 3, 5.5, 7.0, 8.5, 11.0', - :a_circle => '((5.3, 10.4), 2)' - ) - - assert g.save - - # Reload and check that we have all the geometric attributes. - h = Geometric.find(g.id) - - assert_equal '(5,6.1)', h.a_point - assert_equal '[(2,3),(5.5,7)]', h.a_line_segment - assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner - assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_path - assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon - assert_equal '<(5.3,10.4),2>', h.a_circle - - # use a geometric function to test for an closed path - objs = Geometric.find_by_sql ["select isclosed(a_path) from geometrics where id = ?", g.id] - assert_equal objs[0].isclosed, 't' - end - end - - class NumericData < ActiveRecord::Base - self.table_name = 'numeric_data' - end - - def test_numeric_fields - m = NumericData.new( - :bank_balance => 1586.43, - :big_bank_balance => BigDecimal("1000234000567.95"), - :world_population => 6000000000, - :my_house_population => 3 - ) - assert m.save - - m1 = NumericData.find(m.id) - assert_not_nil m1 - - # As with migration_test.rb, we should make world_population >= 2**62 - # to cover 64-bit platforms and test it is a Bignum, but the main thing - # is that it's an Integer. - assert_kind_of Integer, m1.world_population - assert_equal 6000000000, m1.world_population - - assert_kind_of Fixnum, m1.my_house_population - assert_equal 3, m1.my_house_population - - assert_kind_of BigDecimal, m1.bank_balance - assert_equal BigDecimal("1586.43"), m1.bank_balance - - assert_kind_of BigDecimal, m1.big_bank_balance - assert_equal BigDecimal("1000234000567.95"), m1.big_bank_balance - end - - def test_auto_id - auto = AutoId.new - auto.save - assert (auto.id > 0) - end - - def quote_column_name(name) - "<#{name}>" - end - - def test_quote_keys - ar = AutoId.new - source = {"foo" => "bar", "baz" => "quux"} - actual = ar.send(:quote_columns, self, source) - inverted = actual.invert - assert_equal("<foo>", inverted["bar"]) - assert_equal("<baz>", inverted["quux"]) - end - - def test_sql_injection_via_find - assert_raise(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do - Topic.find("123456 OR id > 0") - end - end - - def test_column_name_properly_quoted - col_record = ColumnName.new - col_record.references = 40 - assert col_record.save - col_record.references = 41 - assert col_record.save - assert_not_nil c2 = ColumnName.find(col_record.id) - assert_equal(41, c2.references) - end - - def test_quoting_arrays - replies = Reply.find(:all, :conditions => [ "id IN (?)", topics(:first).replies.collect(&:id) ]) - assert_equal topics(:first).replies.size, replies.size - - replies = Reply.find(:all, :conditions => [ "id IN (?)", [] ]) - assert_equal 0, replies.size - end - - MyObject = Struct.new :attribute1, :attribute2 - - def test_serialized_attribute - myobj = MyObject.new('value1', 'value2') - topic = Topic.create("content" => myobj) - Topic.serialize("content", MyObject) - assert_equal(myobj, topic.content) - end - - def test_serialized_time_attribute - myobj = Time.local(2008,1,1,1,0) - topic = Topic.create("content" => myobj).reload - assert_equal(myobj, topic.content) - end - - def test_serialized_string_attribute - myobj = "Yes" - topic = Topic.create("content" => myobj).reload - assert_equal(myobj, topic.content) - end - - def test_nil_serialized_attribute_with_class_constraint - myobj = MyObject.new('value1', 'value2') - topic = Topic.new - assert_nil topic.content - end - - def test_should_raise_exception_on_serialized_attribute_with_type_mismatch - myobj = MyObject.new('value1', 'value2') - topic = Topic.new(:content => myobj) - assert topic.save - Topic.serialize(:content, Hash) - assert_raise(ActiveRecord::SerializationTypeMismatch) { Topic.find(topic.id).content } - ensure - Topic.serialize(:content) - end - - def test_serialized_attribute_with_class_constraint - settings = { "color" => "blue" } - Topic.serialize(:content, Hash) - topic = Topic.new(:content => settings) - assert topic.save - assert_equal(settings, Topic.find(topic.id).content) - ensure - Topic.serialize(:content) - end - - def test_quote - author_name = "\\ \001 ' \n \\n \"" - topic = Topic.create('author_name' => author_name) - assert_equal author_name, Topic.find(topic.id).author_name - end - - if RUBY_VERSION < '1.9' - def test_quote_chars - with_kcode('UTF8') do - str = 'The Narrator' - topic = Topic.create(:author_name => str) - assert_equal str, topic.author_name - - assert_kind_of ActiveSupport::Multibyte.proxy_class, str.mb_chars - topic = Topic.find_by_author_name(str.mb_chars) - - assert_kind_of Topic, topic - assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars" - end - end - end - - def test_class_level_destroy - should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world") - Topic.find(1).replies << should_be_destroyed_reply - - Topic.destroy(1) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1) } - assert_raise(ActiveRecord::RecordNotFound) { Reply.find(should_be_destroyed_reply.id) } - end - - def test_class_level_delete - should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world") - Topic.find(1).replies << should_be_destroyed_reply - - Topic.delete(1) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1) } - assert_nothing_raised { Reply.find(should_be_destroyed_reply.id) } - end - - def test_increment_attribute - assert_equal 50, accounts(:signals37).credit_limit - accounts(:signals37).increment! :credit_limit - assert_equal 51, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).increment(:credit_limit).increment!(:credit_limit) - assert_equal 53, accounts(:signals37, :reload).credit_limit - end - - def test_increment_nil_attribute - assert_nil topics(:first).parent_id - topics(:first).increment! :parent_id - assert_equal 1, topics(:first).parent_id - end - - def test_increment_attribute_by - assert_equal 50, accounts(:signals37).credit_limit - accounts(:signals37).increment! :credit_limit, 5 - assert_equal 55, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).increment(:credit_limit, 1).increment!(:credit_limit, 3) - assert_equal 59, accounts(:signals37, :reload).credit_limit - end - - def test_decrement_attribute - assert_equal 50, accounts(:signals37).credit_limit - - accounts(:signals37).decrement!(:credit_limit) - assert_equal 49, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).decrement(:credit_limit).decrement!(:credit_limit) - assert_equal 47, accounts(:signals37, :reload).credit_limit - end - - def test_decrement_attribute_by - assert_equal 50, accounts(:signals37).credit_limit - accounts(:signals37).decrement! :credit_limit, 5 - assert_equal 45, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).decrement(:credit_limit, 1).decrement!(:credit_limit, 3) - assert_equal 41, accounts(:signals37, :reload).credit_limit - end - - def test_toggle_attribute - assert !topics(:first).approved? - topics(:first).toggle!(:approved) - assert topics(:first).approved? - topic = topics(:first) - topic.toggle(:approved) - assert !topic.approved? - topic.reload - assert topic.approved? - end - - def test_reload - t1 = Topic.find(1) - t2 = Topic.find(1) - t1.title = "something else" - t1.save - t2.reload - assert_equal t1.title, t2.title - end - - def test_reload_with_exclusive_scope - dev = DeveloperCalledDavid.first - dev.update_attributes!( :name => "NotDavid" ) - assert_equal dev, dev.reload - end - - def test_define_attr_method_with_value - k = Class.new( ActiveRecord::Base ) - k.send(:define_attr_method, :table_name, "foo") - assert_equal "foo", k.table_name - end - - def test_define_attr_method_with_block - k = Class.new( ActiveRecord::Base ) - k.send(:define_attr_method, :primary_key) { "sys_" + original_primary_key } - assert_equal "sys_id", k.primary_key - end - - def test_set_table_name_with_value - k = Class.new( ActiveRecord::Base ) - k.table_name = "foo" - assert_equal "foo", k.table_name - k.set_table_name "bar" - assert_equal "bar", k.table_name - end - - def test_set_table_name_with_block - k = Class.new( ActiveRecord::Base ) - k.set_table_name { "ks" } - assert_equal "ks", k.table_name - end - - def test_set_primary_key_with_value - k = Class.new( ActiveRecord::Base ) - k.primary_key = "foo" - assert_equal "foo", k.primary_key - k.set_primary_key "bar" - assert_equal "bar", k.primary_key - end - - def test_set_primary_key_with_block - k = Class.new( ActiveRecord::Base ) - k.set_primary_key { "sys_" + original_primary_key } - assert_equal "sys_id", k.primary_key - end - - def test_set_inheritance_column_with_value - k = Class.new( ActiveRecord::Base ) - k.inheritance_column = "foo" - assert_equal "foo", k.inheritance_column - k.set_inheritance_column "bar" - assert_equal "bar", k.inheritance_column - end - - def test_set_inheritance_column_with_block - k = Class.new( ActiveRecord::Base ) - k.set_inheritance_column { original_inheritance_column + "_id" } - assert_equal "type_id", k.inheritance_column - end - - def test_count_with_join - res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'" - - res2 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'", :joins => "LEFT JOIN comments ON posts.id=comments.post_id") - assert_equal res, res2 - - res3 = nil - assert_nothing_raised do - res3 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'", - :joins => "LEFT JOIN comments ON posts.id=comments.post_id") - end - assert_equal res, res3 - - res4 = Post.count_by_sql "SELECT COUNT(p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id" - res5 = nil - assert_nothing_raised do - res5 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id", - :joins => "p, comments co", - :select => "p.id") - end - - assert_equal res4, res5 - - unless current_adapter?(:SQLite2Adapter, :DeprecatedSQLiteAdapter) - res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id" - res7 = nil - assert_nothing_raised do - res7 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id", - :joins => "p, comments co", - :select => "p.id", - :distinct => true) - end - assert_equal res6, res7 - end - end - - def test_clear_association_cache_stored - firm = Firm.find(1) - assert_kind_of Firm, firm - - firm.clear_association_cache - assert_equal Firm.find(1).clients.collect{ |x| x.name }.sort, firm.clients.collect{ |x| x.name }.sort - end - - def test_clear_association_cache_new_record - firm = Firm.new - client_stored = Client.find(3) - client_new = Client.new - client_new.name = "The Joneses" - clients = [ client_stored, client_new ] - - firm.clients << clients - assert_equal clients.map(&:name).to_set, firm.clients.map(&:name).to_set - - firm.clear_association_cache - assert_equal clients.map(&:name).to_set, firm.clients.map(&:name).to_set - end - - def test_interpolate_sql - assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo@bar') } - assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo bar) baz') } - assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo bar} baz') } - end - - def test_scoped_find_conditions - scoped_developers = Developer.with_scope(:find => { :conditions => 'salary > 90000' }) do - Developer.find(:all, :conditions => 'id < 5') - end - assert !scoped_developers.include?(developers(:david)) # David's salary is less than 90,000 - assert_equal 3, scoped_developers.size - end - - def test_scoped_find_limit_offset - scoped_developers = Developer.with_scope(:find => { :limit => 3, :offset => 2 }) do - Developer.find(:all, :order => 'id') - end - assert !scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 3, scoped_developers.size - - # Test without scoped find conditions to ensure we get the whole thing - developers = Developer.find(:all, :order => 'id') - assert_equal Developer.count, developers.size - end - - def test_scoped_find_order - # Test order in scope - scoped_developers = Developer.with_scope(:find => { :limit => 1, :order => 'salary DESC' }) do - Developer.find(:all) - end - assert_equal 'Jamis', scoped_developers.first.name - assert scoped_developers.include?(developers(:jamis)) - # Test scope without order and order in find - scoped_developers = Developer.with_scope(:find => { :limit => 1 }) do - Developer.find(:all, :order => 'salary DESC') - end - # Test scope order + find order, find has priority - scoped_developers = Developer.with_scope(:find => { :limit => 3, :order => 'id DESC' }) do - Developer.find(:all, :order => 'salary ASC') - end - assert scoped_developers.include?(developers(:poor_jamis)) - assert scoped_developers.include?(developers(:david)) - assert scoped_developers.include?(developers(:dev_10)) - # Test without scoped find conditions to ensure we get the right thing - developers = Developer.find(:all, :order => 'id', :limit => 1) - assert scoped_developers.include?(developers(:david)) - end - - def test_scoped_find_limit_offset_including_has_many_association - topics = Topic.with_scope(:find => {:limit => 1, :offset => 1, :include => :replies}) do - Topic.find(:all, :order => "topics.id") - end - assert_equal 1, topics.size - assert_equal 2, topics.first.id - end - - def test_scoped_find_order_including_has_many_association - developers = Developer.with_scope(:find => { :order => 'developers.salary DESC', :include => :projects }) do - Developer.find(:all) - end - assert developers.size >= 2 - for i in 1...developers.size - assert developers[i-1].salary >= developers[i].salary - end - end - - def test_scoped_find_with_group_and_having - developers = Developer.with_scope(:find => { :group => 'developers.salary', :having => "SUM(salary) > 10000", :select => "SUM(salary) as salary" }) do - Developer.find(:all) - end - assert_equal 3, developers.size - end - - def test_find_last - last = Developer.find :last - assert_equal last, Developer.find(:first, :order => 'id desc') - end - - def test_last - assert_equal Developer.find(:first, :order => 'id desc'), Developer.last - end - - def test_all_with_conditions - assert_equal Developer.find(:all, :order => 'id desc'), Developer.all(:order => 'id desc') - end - - def test_find_ordered_last - last = Developer.find :last, :order => 'developers.salary ASC' - assert_equal last, Developer.find(:all, :order => 'developers.salary ASC').last - end - - def test_find_reverse_ordered_last - last = Developer.find :last, :order => 'developers.salary DESC' - assert_equal last, Developer.find(:all, :order => 'developers.salary DESC').last - end - - def test_find_multiple_ordered_last - last = Developer.find :last, :order => 'developers.name, developers.salary DESC' - assert_equal last, Developer.find(:all, :order => 'developers.name, developers.salary DESC').last - end - - def test_find_symbol_ordered_last - last = Developer.find :last, :order => :salary - assert_equal last, Developer.find(:all, :order => :salary).last - end - - def test_find_scoped_ordered_last - last_developer = Developer.with_scope(:find => { :order => 'developers.salary ASC' }) do - Developer.find(:last) - end - assert_equal last_developer, Developer.find(:all, :order => 'developers.salary ASC').last - end - - def test_abstract_class - assert !ActiveRecord::Base.abstract_class? - assert LoosePerson.abstract_class? - assert !LooseDescendant.abstract_class? - end - - def test_base_class - assert_equal LoosePerson, LoosePerson.base_class - assert_equal LooseDescendant, LooseDescendant.base_class - assert_equal TightPerson, TightPerson.base_class - assert_equal TightPerson, TightDescendant.base_class - - assert_equal Post, Post.base_class - assert_equal Post, SpecialPost.base_class - assert_equal Post, StiPost.base_class - assert_equal SubStiPost, SubStiPost.base_class - end - - def test_descends_from_active_record - # Tries to call Object.abstract_class? - assert_raise(NoMethodError) do - ActiveRecord::Base.descends_from_active_record? - end - - # Abstract subclass of AR::Base. - assert LoosePerson.descends_from_active_record? - - # Concrete subclass of an abstract class. - assert LooseDescendant.descends_from_active_record? - - # Concrete subclass of AR::Base. - assert TightPerson.descends_from_active_record? - - # Concrete subclass of a concrete class but has no type column. - assert TightDescendant.descends_from_active_record? - - # Concrete subclass of AR::Base. - assert Post.descends_from_active_record? - - # Abstract subclass of a concrete class which has a type column. - # This is pathological, as you'll never have Sub < Abstract < Concrete. - assert !StiPost.descends_from_active_record? - - # Concrete subclasses an abstract class which has a type column. - assert !SubStiPost.descends_from_active_record? - end - - def test_find_on_abstract_base_class_doesnt_use_type_condition - old_class = LooseDescendant - Object.send :remove_const, :LooseDescendant - - descendant = old_class.create! :first_name => 'bob' - assert_not_nil LoosePerson.find(descendant.id), "Should have found instance of LooseDescendant when finding abstract LoosePerson: #{descendant.inspect}" - ensure - unless Object.const_defined?(:LooseDescendant) - Object.const_set :LooseDescendant, old_class - end - end - - def test_assert_queries - query = lambda { ActiveRecord::Base.connection.execute 'select count(*) from developers' } - assert_queries(2) { 2.times { query.call } } - assert_queries 1, &query - assert_no_queries { assert true } - end - - def test_to_xml - xml = REXML::Document.new(topics(:first).to_xml(:indent => 0)) - bonus_time_in_current_timezone = topics(:first).bonus_time.xmlschema - written_on_in_current_timezone = topics(:first).written_on.xmlschema - last_read_in_current_timezone = topics(:first).last_read.xmlschema - - assert_equal "topic", xml.root.name - assert_equal "The First Topic" , xml.elements["//title"].text - assert_equal "David" , xml.elements["//author-name"].text - - assert_equal "1", xml.elements["//id"].text - assert_equal "integer" , xml.elements["//id"].attributes['type'] - - assert_equal "1", xml.elements["//replies-count"].text - assert_equal "integer" , xml.elements["//replies-count"].attributes['type'] - - assert_equal written_on_in_current_timezone, xml.elements["//written-on"].text - assert_equal "datetime" , xml.elements["//written-on"].attributes['type'] - - assert_equal "--- Have a nice day\n" , xml.elements["//content"].text - assert_equal "yaml" , xml.elements["//content"].attributes['type'] - - assert_equal "david@loudthinking.com", xml.elements["//author-email-address"].text - - assert_equal nil, xml.elements["//parent-id"].text - assert_equal "integer", xml.elements["//parent-id"].attributes['type'] - assert_equal "true", xml.elements["//parent-id"].attributes['nil'] - - if current_adapter?(:SybaseAdapter, :OracleAdapter) - assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text - assert_equal "datetime" , xml.elements["//last-read"].attributes['type'] - else - assert_equal "2004-04-15", xml.elements["//last-read"].text - assert_equal "date" , xml.elements["//last-read"].attributes['type'] - end - - # Oracle and DB2 don't have true boolean or time-only fields - unless current_adapter?(:OracleAdapter, :DB2Adapter) - assert_equal "false", xml.elements["//approved"].text - assert_equal "boolean" , xml.elements["//approved"].attributes['type'] - - assert_equal bonus_time_in_current_timezone, xml.elements["//bonus-time"].text - assert_equal "datetime" , xml.elements["//bonus-time"].attributes['type'] - end - end - - def test_to_xml_skipping_attributes - xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :replies_count]) - assert_equal "<topic>", xml.first(7) - assert !xml.include?(%(<title>The First Topic</title>)) - assert xml.include?(%(<author-name>David</author-name>)) - - xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :author_name, :replies_count]) - assert !xml.include?(%(<title>The First Topic</title>)) - assert !xml.include?(%(<author-name>David</author-name>)) - end - - def test_to_xml_including_has_many_association - xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :include => :replies, :except => :replies_count) - assert_equal "<topic>", xml.first(7) - assert xml.include?(%(<replies type="array"><reply>)) - assert xml.include?(%(<title>The Second Topic of the day</title>)) - end - - def test_array_to_xml_including_has_many_association - xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :include => :replies) - assert xml.include?(%(<replies type="array"><reply>)) - end - - def test_array_to_xml_including_methods - xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :methods => [ :topic_id ]) - assert xml.include?(%(<topic-id type="integer">#{topics(:first).topic_id}</topic-id>)), xml - assert xml.include?(%(<topic-id type="integer">#{topics(:second).topic_id}</topic-id>)), xml - end - - def test_array_to_xml_including_has_one_association - xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account) - assert xml.include?(companies(:first_firm).account.to_xml(:indent => 0, :skip_instruct => true)) - assert xml.include?(companies(:rails_core).account.to_xml(:indent => 0, :skip_instruct => true)) - end - - def test_array_to_xml_including_belongs_to_association - xml = [ companies(:first_client), companies(:second_client), companies(:another_client) ].to_xml(:indent => 0, :skip_instruct => true, :include => :firm) - assert xml.include?(companies(:first_client).to_xml(:indent => 0, :skip_instruct => true)) - assert xml.include?(companies(:second_client).firm.to_xml(:indent => 0, :skip_instruct => true)) - assert xml.include?(companies(:another_client).firm.to_xml(:indent => 0, :skip_instruct => true)) - end - - def test_to_xml_including_belongs_to_association - xml = companies(:first_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm) - assert !xml.include?("<firm>") - - xml = companies(:second_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm) - assert xml.include?("<firm>") - end - - def test_to_xml_including_multiple_associations - xml = companies(:first_firm).to_xml(:indent => 0, :skip_instruct => true, :include => [ :clients, :account ]) - assert_equal "<firm>", xml.first(6) - assert xml.include?(%(<account>)) - assert xml.include?(%(<clients type="array"><client>)) - end - - def test_to_xml_including_multiple_associations_with_options - xml = companies(:first_firm).to_xml( - :indent => 0, :skip_instruct => true, - :include => { :clients => { :only => :name } } - ) - - assert_equal "<firm>", xml.first(6) - assert xml.include?(%(<client><name>Summit</name></client>)) - assert xml.include?(%(<clients type="array"><client>)) - end - - def test_to_xml_including_methods - xml = Company.new.to_xml(:methods => :arbitrary_method, :skip_instruct => true) - assert_equal "<company>", xml.first(9) - assert xml.include?(%(<arbitrary-method>I am Jack's profound disappointment</arbitrary-method>)) - end - - def test_to_xml_with_block - value = "Rockin' the block" - xml = Company.new.to_xml(:skip_instruct => true) do |xml| - xml.tag! "arbitrary-element", value - end - assert_equal "<company>", xml.first(9) - assert xml.include?(%(<arbitrary-element>#{value}</arbitrary-element>)) - end - - def test_type_name_with_module_should_handle_beginning - assert_equal 'ActiveRecord::Person', ActiveRecord::Base.send(:type_name_with_module, 'Person') - assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person') - end - - def test_to_param_should_return_string - assert_kind_of String, Client.find(:first).to_param - end - - def test_inspect_class - assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect - assert_equal 'LoosePerson(abstract)', LoosePerson.inspect - assert_match(/^Topic\(id: integer, title: string/, Topic.inspect) - end - - def test_inspect_instance - topic = topics(:first) - assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", approved: false, replies_count: 1, parent_id: nil, parent_title: nil, type: nil, group: nil>), topic.inspect - end - - def test_inspect_new_instance - assert_match /Topic id: nil/, Topic.new.inspect - end - - def test_inspect_limited_select_instance - assert_equal %(#<Topic id: 1>), Topic.find(:first, :select => 'id', :conditions => 'id = 1').inspect - assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => 'id, title', :conditions => 'id = 1').inspect - end - - def test_inspect_class_without_table - assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect - end - - def test_attribute_for_inspect - t = topics(:first) - t.title = "The First Topic Now Has A Title With\nNewlines And More Than 50 Characters" - - assert_equal %("#{t.written_on.to_s(:db)}"), t.attribute_for_inspect(:written_on) - assert_equal '"The First Topic Now Has A Title With\nNewlines And M..."', t.attribute_for_inspect(:title) - end - - def test_becomes - assert_kind_of Reply, topics(:first).becomes(Reply) - assert_equal "The First Topic", topics(:first).becomes(Reply).title - end - - def test_silence_sets_log_level_to_error_in_block - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.logger.level = Logger::DEBUG - ActiveRecord::Base.silence do - ActiveRecord::Base.logger.warn "warn" - ActiveRecord::Base.logger.error "error" - end - assert_equal "error\n", log.string - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_silence_sets_log_level_back_to_level_before_yield - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.logger.level = Logger::WARN - ActiveRecord::Base.silence do - end - assert_equal Logger::WARN, ActiveRecord::Base.logger.level - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_benchmark_with_log_level - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.logger.level = Logger::WARN - ActiveRecord::Base.benchmark("Debug Topic Count", Logger::DEBUG) { Topic.count } - ActiveRecord::Base.benchmark("Warn Topic Count", Logger::WARN) { Topic.count } - ActiveRecord::Base.benchmark("Error Topic Count", Logger::ERROR) { Topic.count } - assert_no_match /Debug Topic Count/, log.string - assert_match /Warn Topic Count/, log.string - assert_match /Error Topic Count/, log.string - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_benchmark_with_use_silence - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.benchmark("Logging", Logger::DEBUG, true) { ActiveRecord::Base.logger.debug "Loud" } - ActiveRecord::Base.benchmark("Logging", Logger::DEBUG, false) { ActiveRecord::Base.logger.debug "Quiet" } - assert_no_match /Loud/, log.string - assert_match /Quiet/, log.string - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_create_with_custom_timestamps - custom_datetime = 1.hour.ago.beginning_of_day - - %w(created_at created_on updated_at updated_on).each do |attribute| - parrot = LiveParrot.create(:name => "colombian", attribute => custom_datetime) - assert_equal custom_datetime, parrot[attribute] - end - end -end diff --git a/vendor/rails/activerecord/test/cases/batches_test.rb b/vendor/rails/activerecord/test/cases/batches_test.rb deleted file mode 100644 index 3bf8bc8a..00000000 --- a/vendor/rails/activerecord/test/cases/batches_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'cases/helper' -require 'models/post' - -class EachTest < ActiveRecord::TestCase - fixtures :posts - - def setup - @posts = Post.all(:order => "id asc") - @total = Post.count - end - - def test_each_should_excecute_one_query_per_batch - assert_queries(Post.count + 1) do - Post.find_each(:batch_size => 1) do |post| - assert_kind_of Post, post - end - end - end - - def test_each_should_raise_if_the_order_is_set - assert_raise(RuntimeError) do - Post.find_each(:order => "title") { |post| post } - end - end - - def test_each_should_raise_if_the_limit_is_set - assert_raise(RuntimeError) do - Post.find_each(:limit => 1) { |post| post } - end - end - - def test_find_in_batches_should_return_batches - assert_queries(Post.count + 1) do - Post.find_in_batches(:batch_size => 1) do |batch| - assert_kind_of Array, batch - assert_kind_of Post, batch.first - end - end - end - - def test_find_in_batches_should_start_from_the_start_option - assert_queries(Post.count) do - Post.find_in_batches(:batch_size => 1, :start => 2) do |batch| - assert_kind_of Array, batch - assert_kind_of Post, batch.first - end - end - end - - def test_find_in_batches_shouldnt_excute_query_unless_needed - post_count = Post.count - - assert_queries(2) do - Post.find_in_batches(:batch_size => post_count) {|batch| assert_kind_of Array, batch } - end - - assert_queries(1) do - Post.find_in_batches(:batch_size => post_count + 1) {|batch| assert_kind_of Array, batch } - end - end - - def test_find_in_batches_doesnt_clog_conditions - Post.find_in_batches(:conditions => {:id => posts(:welcome).id}) do - assert_nothing_raised { Post.find(posts(:thinking).id) } - end - end - - def test_each_should_raise_if_select_is_set_without_id - assert_raise(RuntimeError) do - Post.find_each(:select => :title, :batch_size => 1) { |post| post } - end - end - - def test_each_should_execute_if_id_is_in_select - assert_queries(4) do - Post.find_each(:select => "id, title, type", :batch_size => 2) do |post| - assert_kind_of Post, post - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/binary_test.rb b/vendor/rails/activerecord/test/cases/binary_test.rb deleted file mode 100644 index 8545ba97..00000000 --- a/vendor/rails/activerecord/test/cases/binary_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "cases/helper" - -# Without using prepared statements, it makes no sense to test -# BLOB data with DB2 or Firebird, because the length of a statement -# is limited to 32KB. -unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter) - require 'models/binary' - - class BinaryTest < ActiveRecord::TestCase - FIXTURES = %w(flowers.jpg example.log) - - def test_load_save - Binary.delete_all - - FIXTURES.each do |filename| - data = File.read(ASSETS_ROOT + "/#{filename}") - data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) - data.freeze - - bin = Binary.new(:data => data) - assert_equal data, bin.data, 'Newly assigned data differs from original' - - bin.save! - assert_equal data, bin.data, 'Data differs from original after save' - - assert_equal data, bin.reload.data, 'Reloaded data differs from original' - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/calculations_test.rb b/vendor/rails/activerecord/test/cases/calculations_test.rb deleted file mode 100644 index d5bb3589..00000000 --- a/vendor/rails/activerecord/test/cases/calculations_test.rb +++ /dev/null @@ -1,360 +0,0 @@ -require "cases/helper" -require 'models/company' -require 'models/topic' -require 'models/edge' -require 'models/owner' -require 'models/pet' -require 'models/toy' -require 'models/club' -require 'models/organization' - -Company.has_many :accounts - -class NumericData < ActiveRecord::Base - self.table_name = 'numeric_data' -end - -class CalculationsTest < ActiveRecord::TestCase - fixtures :companies, :accounts, :topics, :owners, :pets, :toys - - def test_should_sum_field - assert_equal 318, Account.sum(:credit_limit) - end - - def test_should_average_field - value = Account.average(:credit_limit) - assert_equal 53.0, value - end - - def test_should_return_nil_as_average - assert_nil NumericData.average(:bank_balance) - end - - def test_type_cast_calculated_value_should_convert_db_averages_of_fixnum_class_to_decimal - assert_equal 0, NumericData.send(:type_cast_calculated_value, 0, nil, 'avg') - assert_equal 53.0, NumericData.send(:type_cast_calculated_value, 53, nil, 'avg') - end - - def test_should_get_maximum_of_field - assert_equal 60, Account.maximum(:credit_limit) - end - - def test_should_get_maximum_of_field_with_include - assert_equal 50, Account.maximum(:credit_limit, :include => :firm, :conditions => "companies.name != 'Summit'") - end - - def test_should_get_maximum_of_field_with_scoped_include - Account.with_scope :find => { :include => :firm, :conditions => "companies.name != 'Summit'" } do - assert_equal 50, Account.maximum(:credit_limit) - end - end - - def test_should_get_minimum_of_field - assert_equal 50, Account.minimum(:credit_limit) - end - - def test_should_group_by_field - c = Account.sum(:credit_limit, :group => :firm_id) - [1,6,2].each { |firm_id| assert c.keys.include?(firm_id) } - end - - def test_should_group_by_multiple_fields - c = Account.count(:all, :group => ['firm_id', :credit_limit]) - [ [nil, 50], [1, 50], [6, 50], [6, 55], [9, 53], [2, 60] ].each { |firm_and_limit| assert c.keys.include?(firm_and_limit) } - end - - def test_should_group_by_multiple_fields_having_functions - c = Topic.count(:all, :group => [:author_name, 'COALESCE(type, title)']) - assert_equal 1, c[["Nick", "The Third Topic of the day"]] - assert_equal 1, c[["Mary", "Reply"]] - assert_equal 1, c[["David", "The First Topic"]] - assert_equal 1, c[["Carl", "Reply"]] - end - - def test_should_group_by_summed_field - c = Account.sum(:credit_limit, :group => :firm_id) - assert_equal 50, c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_order_by_grouped_field - c = Account.sum(:credit_limit, :group => :firm_id, :order => "firm_id") - assert_equal [1, 2, 6, 9], c.keys.compact - end - - def test_should_order_by_calculation - c = Account.sum(:credit_limit, :group => :firm_id, :order => "sum_credit_limit desc, firm_id") - assert_equal [105, 60, 53, 50, 50], c.keys.collect { |k| c[k] } - assert_equal [6, 2, 9, 1], c.keys.compact - end - - def test_should_limit_calculation - c = Account.sum(:credit_limit, :conditions => "firm_id IS NOT NULL", - :group => :firm_id, :order => "firm_id", :limit => 2) - assert_equal [1, 2], c.keys.compact - end - - def test_should_limit_calculation_with_offset - c = Account.sum(:credit_limit, :conditions => "firm_id IS NOT NULL", - :group => :firm_id, :order => "firm_id", :limit => 2, :offset => 1) - assert_equal [2, 6], c.keys.compact - end - - def test_should_group_by_summed_field_having_condition - c = Account.sum(:credit_limit, :group => :firm_id, - :having => 'sum(credit_limit) > 50') - assert_nil c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_group_by_summed_field_having_sanitized_condition - c = Account.sum(:credit_limit, :group => :firm_id, - :having => ['sum(credit_limit) > ?', 50]) - assert_nil c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_group_by_summed_association - c = Account.sum(:credit_limit, :group => :firm) - assert_equal 50, c[companies(:first_firm)] - assert_equal 105, c[companies(:rails_core)] - assert_equal 60, c[companies(:first_client)] - end - - def test_should_sum_field_with_conditions - assert_equal 105, Account.sum(:credit_limit, :conditions => 'firm_id = 6') - end - - def test_should_return_zero_if_sum_conditions_return_nothing - assert_equal 0, Account.sum(:credit_limit, :conditions => '1 = 2') - assert_equal 0, companies(:rails_core).companies.sum(:id, :conditions => '1 = 2') - end - - def test_sum_should_return_valid_values_for_decimals - NumericData.create(:bank_balance => 19.83) - assert_equal 19.83, NumericData.sum(:bank_balance) - end - - def test_should_group_by_summed_field_with_conditions - c = Account.sum(:credit_limit, :conditions => 'firm_id > 1', - :group => :firm_id) - assert_nil c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_group_by_summed_field_with_conditions_and_having - c = Account.sum(:credit_limit, :conditions => 'firm_id > 1', - :group => :firm_id, - :having => 'sum(credit_limit) > 60') - assert_nil c[1] - assert_equal 105, c[6] - assert_nil c[2] - end - - def test_should_group_by_fields_with_table_alias - c = Account.sum(:credit_limit, :group => 'accounts.firm_id') - assert_equal 50, c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_calculate_with_invalid_field - assert_equal 6, Account.calculate(:count, '*') - assert_equal 6, Account.calculate(:count, :all) - end - - def test_should_calculate_grouped_with_invalid_field - c = Account.count(:all, :group => 'accounts.firm_id') - assert_equal 1, c[1] - assert_equal 2, c[6] - assert_equal 1, c[2] - end - - def test_should_calculate_grouped_association_with_invalid_field - c = Account.count(:all, :group => :firm) - assert_equal 1, c[companies(:first_firm)] - assert_equal 2, c[companies(:rails_core)] - assert_equal 1, c[companies(:first_client)] - end - - def test_should_group_by_association_with_non_numeric_foreign_key - ActiveRecord::Base.connection.expects(:select_all).returns([{"count_all" => 1, "firm_id" => "ABC"}]) - - firm = mock() - firm.expects(:id).returns("ABC") - firm.expects(:class).returns(Firm) - Company.expects(:find).with(["ABC"]).returns([firm]) - - column = mock() - column.expects(:name).at_least_once.returns(:firm_id) - column.expects(:type_cast).with("ABC").returns("ABC") - Account.expects(:columns).at_least_once.returns([column]) - - c = Account.count(:all, :group => :firm) - first_key = c.keys.first - assert_equal Firm, first_key.class - assert_equal 1, c[first_key] - end - - def test_should_calculate_grouped_association_with_foreign_key_option - Account.belongs_to :another_firm, :class_name => 'Firm', :foreign_key => 'firm_id' - c = Account.count(:all, :group => :another_firm) - assert_equal 1, c[companies(:first_firm)] - assert_equal 2, c[companies(:rails_core)] - assert_equal 1, c[companies(:first_client)] - end - - def test_should_not_modify_options_when_using_includes - options = {:conditions => 'companies.id > 1', :include => :firm} - options_copy = options.dup - - Account.count(:all, options) - assert_equal options_copy, options - end - - def test_should_calculate_grouped_by_function - c = Company.count(:all, :group => "UPPER(#{QUOTED_TYPE})") - assert_equal 2, c[nil] - assert_equal 1, c['DEPENDENTFIRM'] - assert_equal 3, c['CLIENT'] - assert_equal 2, c['FIRM'] - end - - def test_should_calculate_grouped_by_function_with_table_alias - c = Company.count(:all, :group => "UPPER(companies.#{QUOTED_TYPE})") - assert_equal 2, c[nil] - assert_equal 1, c['DEPENDENTFIRM'] - assert_equal 3, c['CLIENT'] - assert_equal 2, c['FIRM'] - end - - def test_should_not_overshadow_enumerable_sum - assert_equal 6, [1, 2, 3].sum(&:abs) - end - - def test_should_sum_scoped_field - assert_equal 15, companies(:rails_core).companies.sum(:id) - end - - def test_should_sum_scoped_field_with_from - assert_equal Club.count, Organization.clubs.count - end - - def test_should_sum_scoped_field_with_conditions - assert_equal 8, companies(:rails_core).companies.sum(:id, :conditions => 'id > 7') - end - - def test_should_group_by_scoped_field - c = companies(:rails_core).companies.sum(:id, :group => :name) - assert_equal 7, c['Leetsoft'] - assert_equal 8, c['Jadedpixel'] - end - - def test_should_group_by_summed_field_with_conditions_and_having - c = companies(:rails_core).companies.sum(:id, :group => :name, - :having => 'sum(id) > 7') - assert_nil c['Leetsoft'] - assert_equal 8, c['Jadedpixel'] - end - - def test_should_reject_invalid_options - assert_nothing_raised do - [:count, :sum].each do |func| - # empty options are valid - Company.send(:validate_calculation_options, func) - # these options are valid for all calculations - [:select, :conditions, :joins, :order, :group, :having, :distinct].each do |opt| - Company.send(:validate_calculation_options, func, opt => true) - end - end - - # :include is only valid on :count - Company.send(:validate_calculation_options, :count, :include => true) - end - - assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) } - assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) } - end - - def test_should_count_selected_field_with_include - assert_equal 6, Account.count(:distinct => true, :include => :firm) - assert_equal 4, Account.count(:distinct => true, :include => :firm, :select => :credit_limit) - end - - def test_should_count_manual_select_with_include - assert_equal 6, Account.count(:select => "DISTINCT accounts.id", :include => :firm) - end - - def test_count_with_column_parameter - assert_equal 5, Account.count(:firm_id) - end - - def test_count_with_column_and_options_parameter - assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50") - end - - def test_count_with_no_parameters_isnt_deprecated - assert_not_deprecated { Account.count } - end - - def test_count_with_too_many_parameters_raises - assert_raise(ArgumentError) { Account.count(1, 2, 3) } - end - - def test_count_with_scoped_has_many_through_association - assert_equal 1, owners(:blackbeard).toys.with_name('Bone').count - end - - def test_should_sum_expression - assert_equal 636, Account.sum("2 * credit_limit").to_i - end - - def test_count_with_from_option - assert_equal Company.count(:all), Company.count(:all, :from => 'companies') - assert_equal Account.count(:all, :conditions => "credit_limit = 50"), - Account.count(:all, :from => 'accounts', :conditions => "credit_limit = 50") - assert_equal Company.count(:type, :conditions => {:type => "Firm"}), - Company.count(:type, :conditions => {:type => "Firm"}, :from => 'companies') - end - - def test_sum_with_from_option - assert_equal Account.sum(:credit_limit), Account.sum(:credit_limit, :from => 'accounts') - assert_equal Account.sum(:credit_limit, :conditions => "credit_limit > 50"), - Account.sum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_average_with_from_option - assert_equal Account.average(:credit_limit), Account.average(:credit_limit, :from => 'accounts') - assert_equal Account.average(:credit_limit, :conditions => "credit_limit > 50"), - Account.average(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_minimum_with_from_option - assert_equal Account.minimum(:credit_limit), Account.minimum(:credit_limit, :from => 'accounts') - assert_equal Account.minimum(:credit_limit, :conditions => "credit_limit > 50"), - Account.minimum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_maximum_with_from_option - assert_equal Account.maximum(:credit_limit), Account.maximum(:credit_limit, :from => 'accounts') - assert_equal Account.maximum(:credit_limit, :conditions => "credit_limit > 50"), - Account.maximum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_from_option_with_specified_index - if Edge.connection.adapter_name == 'MySQL' - assert_equal Edge.count(:all), Edge.count(:all, :from => 'edges USE INDEX(unique_edge_index)') - assert_equal Edge.count(:all, :conditions => 'sink_id < 5'), - Edge.count(:all, :from => 'edges USE INDEX(unique_edge_index)', :conditions => 'sink_id < 5') - end - end - - def test_from_option_with_table_different_than_class - assert_equal Account.count(:all), Company.count(:all, :from => 'accounts') - end - -end diff --git a/vendor/rails/activerecord/test/cases/callbacks_observers_test.rb b/vendor/rails/activerecord/test/cases/callbacks_observers_test.rb deleted file mode 100644 index 87de5249..00000000 --- a/vendor/rails/activerecord/test/cases/callbacks_observers_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "cases/helper" - -class Comment < ActiveRecord::Base - attr_accessor :callers - - before_validation :record_callers - - def after_validation - record_callers - end - - def record_callers - callers << self.class if callers - end -end - -class CommentObserver < ActiveRecord::Observer - attr_accessor :callers - - def after_validation(model) - callers << self.class if callers - end -end - -class CallbacksObserversTest < ActiveRecord::TestCase - def test_model_callbacks_fire_before_observers_are_notified - callers = [] - - comment = Comment.new - comment.callers = callers - - CommentObserver.instance.callers = callers - - comment.valid? - - assert_equal [Comment, Comment, CommentObserver], callers, "model callbacks did not fire before observers were notified" - end -end diff --git a/vendor/rails/activerecord/test/cases/callbacks_test.rb b/vendor/rails/activerecord/test/cases/callbacks_test.rb deleted file mode 100644 index 95fddaee..00000000 --- a/vendor/rails/activerecord/test/cases/callbacks_test.rb +++ /dev/null @@ -1,438 +0,0 @@ -require "cases/helper" - -class CallbackDeveloper < ActiveRecord::Base - set_table_name 'developers' - - class << self - def callback_string(callback_method) - "history << [#{callback_method.to_sym.inspect}, :string]" - end - - def callback_proc(callback_method) - Proc.new { |model| model.history << [callback_method, :proc] } - end - - def define_callback_method(callback_method) - define_method("#{callback_method}_method") do |model| - model.history << [callback_method, :method] - end - end - - def callback_object(callback_method) - klass = Class.new - klass.send(:define_method, callback_method) do |model| - model.history << [callback_method, :object] - end - klass.new - end - end - - ActiveRecord::Callbacks::CALLBACKS.each do |callback_method| - callback_method_sym = callback_method.to_sym - define_callback_method(callback_method_sym) - send(callback_method, callback_method_sym) - send(callback_method, callback_string(callback_method_sym)) - send(callback_method, callback_proc(callback_method_sym)) - send(callback_method, callback_object(callback_method_sym)) - send(callback_method) { |model| model.history << [callback_method_sym, :block] } - end - - def history - @history ||= [] - end - - # after_initialize and after_find are invoked only if instance methods have been defined. - def after_initialize - end - - def after_find - end -end - -class ParentDeveloper < ActiveRecord::Base - set_table_name 'developers' - attr_accessor :after_save_called - before_validation {|record| record.after_save_called = true} -end - -class ChildDeveloper < ParentDeveloper - -end - -class RecursiveCallbackDeveloper < ActiveRecord::Base - set_table_name 'developers' - - before_save :on_before_save - after_save :on_after_save - - attr_reader :on_before_save_called, :on_after_save_called - - def on_before_save - @on_before_save_called ||= 0 - @on_before_save_called += 1 - save unless @on_before_save_called > 1 - end - - def on_after_save - @on_after_save_called ||= 0 - @on_after_save_called += 1 - save unless @on_after_save_called > 1 - end -end - -class ImmutableDeveloper < ActiveRecord::Base - set_table_name 'developers' - - validates_inclusion_of :salary, :in => 50000..200000 - - before_save :cancel - before_destroy :cancel - - def cancelled? - @cancelled == true - end - - private - def cancel - @cancelled = true - false - end -end - -class ImmutableMethodDeveloper < ActiveRecord::Base - set_table_name 'developers' - - validates_inclusion_of :salary, :in => 50000..200000 - - def cancelled? - @cancelled == true - end - - def before_save - @cancelled = true - false - end - - def before_destroy - @cancelled = true - false - end -end - -class CallbackCancellationDeveloper < ActiveRecord::Base - set_table_name 'developers' - - attr_reader :after_save_called, :after_create_called, :after_update_called, :after_destroy_called - attr_accessor :cancel_before_save, :cancel_before_create, :cancel_before_update, :cancel_before_destroy - - def before_save; !@cancel_before_save; end - def before_create; !@cancel_before_create; end - def before_update; !@cancel_before_update; end - def before_destroy; !@cancel_before_destroy; end - - def after_save; @after_save_called = true; end - def after_update; @after_update_called = true; end - def after_create; @after_create_called = true; end - def after_destroy; @after_destroy_called = true; end -end - -class CallbacksTest < ActiveRecord::TestCase - fixtures :developers - - def test_initialize - david = CallbackDeveloper.new - assert_equal [ - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - ], david.history - end - - def test_find - david = CallbackDeveloper.find(1) - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - ], david.history - end - - def test_new_valid? - david = CallbackDeveloper.new - david.valid? - assert_equal [ - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_create, :string ], - [ :before_validation_on_create, :proc ], - [ :before_validation_on_create, :object ], - [ :before_validation_on_create, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_create, :string ], - [ :after_validation_on_create, :proc ], - [ :after_validation_on_create, :object ], - [ :after_validation_on_create, :block ] - ], david.history - end - - def test_existing_valid? - david = CallbackDeveloper.find(1) - david.valid? - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_update, :string ], - [ :before_validation_on_update, :proc ], - [ :before_validation_on_update, :object ], - [ :before_validation_on_update, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_update, :string ], - [ :after_validation_on_update, :proc ], - [ :after_validation_on_update, :object ], - [ :after_validation_on_update, :block ] - ], david.history - end - - def test_create - david = CallbackDeveloper.create('name' => 'David', 'salary' => 1000000) - assert_equal [ - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_create, :string ], - [ :before_validation_on_create, :proc ], - [ :before_validation_on_create, :object ], - [ :before_validation_on_create, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_create, :string ], - [ :after_validation_on_create, :proc ], - [ :after_validation_on_create, :object ], - [ :after_validation_on_create, :block ], - [ :before_save, :string ], - [ :before_save, :proc ], - [ :before_save, :object ], - [ :before_save, :block ], - [ :before_create, :string ], - [ :before_create, :proc ], - [ :before_create, :object ], - [ :before_create, :block ], - [ :after_create, :string ], - [ :after_create, :proc ], - [ :after_create, :object ], - [ :after_create, :block ], - [ :after_save, :string ], - [ :after_save, :proc ], - [ :after_save, :object ], - [ :after_save, :block ] - ], david.history - end - - def test_save - david = CallbackDeveloper.find(1) - david.save - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_update, :string ], - [ :before_validation_on_update, :proc ], - [ :before_validation_on_update, :object ], - [ :before_validation_on_update, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_update, :string ], - [ :after_validation_on_update, :proc ], - [ :after_validation_on_update, :object ], - [ :after_validation_on_update, :block ], - [ :before_save, :string ], - [ :before_save, :proc ], - [ :before_save, :object ], - [ :before_save, :block ], - [ :before_update, :string ], - [ :before_update, :proc ], - [ :before_update, :object ], - [ :before_update, :block ], - [ :after_update, :string ], - [ :after_update, :proc ], - [ :after_update, :object ], - [ :after_update, :block ], - [ :after_save, :string ], - [ :after_save, :proc ], - [ :after_save, :object ], - [ :after_save, :block ] - ], david.history - end - - def test_destroy - david = CallbackDeveloper.find(1) - david.destroy - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_destroy, :string ], - [ :before_destroy, :proc ], - [ :before_destroy, :object ], - [ :before_destroy, :block ], - [ :after_destroy, :string ], - [ :after_destroy, :proc ], - [ :after_destroy, :object ], - [ :after_destroy, :block ] - ], david.history - end - - def test_delete - david = CallbackDeveloper.find(1) - CallbackDeveloper.delete(david.id) - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - ], david.history - end - - def test_before_save_returning_false - david = ImmutableDeveloper.find(1) - assert david.valid? - assert !david.save - assert_raise(ActiveRecord::RecordNotSaved) { david.save! } - - david = ImmutableDeveloper.find(1) - david.salary = 10_000_000 - assert !david.valid? - assert !david.save - assert_raise(ActiveRecord::RecordInvalid) { david.save! } - - someone = CallbackCancellationDeveloper.find(1) - someone.cancel_before_save = true - assert someone.valid? - assert !someone.save - assert_save_callbacks_not_called(someone) - end - - def test_before_create_returning_false - someone = CallbackCancellationDeveloper.new - someone.cancel_before_create = true - assert someone.valid? - assert !someone.save - assert_save_callbacks_not_called(someone) - end - - def test_before_update_returning_false - someone = CallbackCancellationDeveloper.find(1) - someone.cancel_before_update = true - assert someone.valid? - assert !someone.save - assert_save_callbacks_not_called(someone) - end - - def test_before_destroy_returning_false - david = ImmutableDeveloper.find(1) - assert !david.destroy - assert_not_nil ImmutableDeveloper.find_by_id(1) - - someone = CallbackCancellationDeveloper.find(1) - someone.cancel_before_destroy = true - assert !someone.destroy - assert !someone.after_destroy_called - end - - def assert_save_callbacks_not_called(someone) - assert !someone.after_save_called - assert !someone.after_create_called - assert !someone.after_update_called - end - private :assert_save_callbacks_not_called - - def test_zzz_callback_returning_false # must be run last since we modify CallbackDeveloper - david = CallbackDeveloper.find(1) - CallbackDeveloper.before_validation proc { |model| model.history << [:before_validation, :returning_false]; return false } - CallbackDeveloper.before_validation proc { |model| model.history << [:before_validation, :should_never_get_here] } - david.save - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation, :returning_false ] - ], david.history - end - - def test_inheritence_of_callbacks - parent = ParentDeveloper.new - assert !parent.after_save_called - parent.save - assert parent.after_save_called - - child = ChildDeveloper.new - assert !child.after_save_called - child.save - assert child.after_save_called - end - -end diff --git a/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb b/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb deleted file mode 100644 index abeb63c5..00000000 --- a/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test/unit' -require "cases/helper" -require 'active_support/core_ext/class/inheritable_attributes' - -class A - include ClassInheritableAttributes -end - -class B < A - write_inheritable_array "first", [ :one, :two ] -end - -class C < A - write_inheritable_array "first", [ :three ] -end - -class D < B - write_inheritable_array "first", [ :four ] -end - - -class ClassInheritableAttributesTest < ActiveRecord::TestCase - def test_first_level - assert_equal [ :one, :two ], B.read_inheritable_attribute("first") - assert_equal [ :three ], C.read_inheritable_attribute("first") - end - - def test_second_level - assert_equal [ :one, :two, :four ], D.read_inheritable_attribute("first") - assert_equal [ :one, :two ], B.read_inheritable_attribute("first") - end -end diff --git a/vendor/rails/activerecord/test/cases/column_alias_test.rb b/vendor/rails/activerecord/test/cases/column_alias_test.rb deleted file mode 100644 index 40707d9c..00000000 --- a/vendor/rails/activerecord/test/cases/column_alias_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "cases/helper" -require 'models/topic' - -class TestColumnAlias < ActiveRecord::TestCase - fixtures :topics - - QUERY = if 'Oracle' == ActiveRecord::Base.connection.adapter_name - 'SELECT id AS pk FROM topics WHERE ROWNUM < 2' - else - 'SELECT id AS pk FROM topics' - end - - def test_column_alias - records = Topic.connection.select_all(QUERY) - assert_equal 'pk', records[0].keys[0] - end -end diff --git a/vendor/rails/activerecord/test/cases/column_definition_test.rb b/vendor/rails/activerecord/test/cases/column_definition_test.rb deleted file mode 100644 index fc9a0ac9..00000000 --- a/vendor/rails/activerecord/test/cases/column_definition_test.rb +++ /dev/null @@ -1,70 +0,0 @@ -require "cases/helper" - -class ColumnDefinitionTest < ActiveRecord::TestCase - def setup - @adapter = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(nil) - def @adapter.native_database_types - {:string => "varchar"} - end - end - - # Avoid column definitions in create table statements like: - # `title` varchar(255) DEFAULT NULL - def test_should_not_include_default_clause_when_default_is_null - column = ActiveRecord::ConnectionAdapters::Column.new("title", nil, "varchar(20)") - column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( - @adapter, column.name, "string", - column.limit, column.precision, column.scale, column.default, column.null) - assert_equal "title varchar(20)", column_def.to_sql - end - - def test_should_include_default_clause_when_default_is_present - column = ActiveRecord::ConnectionAdapters::Column.new("title", "Hello", "varchar(20)") - column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( - @adapter, column.name, "string", - column.limit, column.precision, column.scale, column.default, column.null) - assert_equal %Q{title varchar(20) DEFAULT 'Hello'}, column_def.to_sql - end - - def test_should_specify_not_null_if_null_option_is_false - column = ActiveRecord::ConnectionAdapters::Column.new("title", "Hello", "varchar(20)", false) - column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( - @adapter, column.name, "string", - column.limit, column.precision, column.scale, column.default, column.null) - assert_equal %Q{title varchar(20) DEFAULT 'Hello' NOT NULL}, column_def.to_sql - end - - if current_adapter?(:MysqlAdapter) - def test_should_set_default_for_mysql_binary_data_types - binary_column = ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", "a", "binary(1)") - assert_equal "a", binary_column.default - - varbinary_column = ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", "a", "varbinary(1)") - assert_equal "a", varbinary_column.default - end - - def test_should_not_set_default_for_blob_and_text_data_types - assert_raise ArgumentError do - ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", "a", "blob") - end - - assert_raise ArgumentError do - ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", "Hello", "text") - end - - text_column = ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", nil, "text") - assert_equal nil, text_column.default - - not_null_text_column = ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", nil, "text", false) - assert_equal "", not_null_text_column.default - end - - def test_has_default_should_return_false_for_blog_and_test_data_types - blob_column = ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", nil, "blob") - assert !blob_column.has_default? - - text_column = ActiveRecord::ConnectionAdapters::MysqlColumn.new("title", nil, "text") - assert !text_column.has_default? - end - end -end diff --git a/vendor/rails/activerecord/test/cases/connection_pool_test.rb b/vendor/rails/activerecord/test/cases/connection_pool_test.rb deleted file mode 100644 index cc9b2a45..00000000 --- a/vendor/rails/activerecord/test/cases/connection_pool_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "cases/helper" - -class ConnectionManagementTest < ActiveRecord::TestCase - def setup - @env = {} - @app = stub('App') - @management = ActiveRecord::ConnectionAdapters::ConnectionManagement.new(@app) - - @connections_cleared = false - ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true } - end - - test "clears active connections after each call" do - @app.expects(:call).with(@env) - @management.call(@env) - assert @connections_cleared - end - - test "doesn't clear active connections when running in a test case" do - @env['rack.test'] = true - @app.expects(:call).with(@env) - @management.call(@env) - assert !@connections_cleared - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/connection_test_firebird.rb b/vendor/rails/activerecord/test/cases/connection_test_firebird.rb deleted file mode 100644 index f57ea686..00000000 --- a/vendor/rails/activerecord/test/cases/connection_test_firebird.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "cases/helper" - -class FirebirdConnectionTest < ActiveRecord::TestCase - def test_charset_properly_set - fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection) - assert_equal 'UTF8', fb_conn.database.character_set - end -end diff --git a/vendor/rails/activerecord/test/cases/connection_test_mysql.rb b/vendor/rails/activerecord/test/cases/connection_test_mysql.rb deleted file mode 100644 index ddec85b5..00000000 --- a/vendor/rails/activerecord/test/cases/connection_test_mysql.rb +++ /dev/null @@ -1,65 +0,0 @@ -require "cases/helper" - -class MysqlConnectionTest < ActiveRecord::TestCase - def setup - super - @connection = ActiveRecord::Base.connection - end - - def test_mysql_reconnect_attribute_after_connection_with_reconnect_true - run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.merge({:reconnect => true})) - assert ActiveRecord::Base.connection.raw_connection.reconnect - end - end - - def test_mysql_reconnect_attribute_after_connection_with_reconnect_false - run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.merge({:reconnect => false})) - assert !ActiveRecord::Base.connection.raw_connection.reconnect - end - end - - def test_no_automatic_reconnection_after_timeout - assert @connection.active? - @connection.update('set @@wait_timeout=1') - sleep 2 - assert !@connection.active? - end - - def test_successful_reconnection_after_timeout_with_manual_reconnect - assert @connection.active? - @connection.update('set @@wait_timeout=1') - sleep 2 - @connection.reconnect! - assert @connection.active? - end - - def test_successful_reconnection_after_timeout_with_verify - assert @connection.active? - @connection.update('set @@wait_timeout=1') - sleep 2 - @connection.verify! - assert @connection.active? - end - - # Test that MySQL allows multiple results for stored procedures - if Mysql.const_defined?(:CLIENT_MULTI_RESULTS) - def test_multi_results - rows = ActiveRecord::Base.connection.select_rows('CALL ten();') - assert_equal 10, rows[0][0].to_i, "ten() did not return 10 as expected: #{rows.inspect}" - assert @connection.active?, "Bad connection use by 'MysqlAdapter.select_rows'" - end - end - - private - - def run_without_connection - original_connection = ActiveRecord::Base.remove_connection - begin - yield original_connection - ensure - ActiveRecord::Base.establish_connection(original_connection) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb b/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb deleted file mode 100644 index de8af309..00000000 --- a/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +++ /dev/null @@ -1,80 +0,0 @@ -require "cases/helper" - -class CopyTableTest < ActiveRecord::TestCase - fixtures :companies, :comments - - def setup - @connection = ActiveRecord::Base.connection - class << @connection - public :copy_table, :table_structure, :indexes - end - end - - def test_copy_table(from = 'customers', to = 'customers2', options = {}) - assert_nothing_raised {copy_table(from, to, options)} - assert_equal row_count(from), row_count(to) - - if block_given? - yield from, to, options - else - assert_equal column_names(from), column_names(to) - end - - @connection.drop_table(to) rescue nil - end - - def test_copy_table_renaming_column - test_copy_table('customers', 'customers2', - :rename => {'name' => 'person_name'}) do |from, to, options| - expected = column_values(from, 'name') - assert expected.any?, 'only nils in resultset; real values are needed' - assert_equal expected, column_values(to, 'person_name') - end - end - - def test_copy_table_with_index - test_copy_table('comments', 'comments_with_index') do - @connection.add_index('comments_with_index', ['post_id', 'type']) - test_copy_table('comments_with_index', 'comments_with_index2') do - assert_equal table_indexes_without_name('comments_with_index'), - table_indexes_without_name('comments_with_index2') - end - end - end - - def test_copy_table_without_primary_key - test_copy_table('developers_projects', 'programmers_projects') - end - - def test_copy_table_with_id_col_that_is_not_primary_key - test_copy_table('goofy_string_id', 'goofy_string_id2') do |from, to, options| - original_id = @connection.columns('goofy_string_id').detect{|col| col.name == 'id' } - copied_id = @connection.columns('goofy_string_id2').detect{|col| col.name == 'id' } - assert_equal original_id.type, copied_id.type - assert_equal original_id.sql_type, copied_id.sql_type - assert_equal original_id.limit, copied_id.limit - assert_equal original_id.primary, copied_id.primary - end - end - -protected - def copy_table(from, to, options = {}) - @connection.copy_table(from, to, {:temporary => true}.merge(options)) - end - - def column_names(table) - @connection.table_structure(table).map {|column| column['name']} - end - - def column_values(table, column) - @connection.select_all("SELECT #{column} FROM #{table} ORDER BY id").map {|row| row[column]} - end - - def table_indexes_without_name(table) - @connection.indexes('comments_with_index').delete(:name) - end - - def row_count(table) - @connection.select_one("SELECT COUNT(*) AS count FROM #{table}")['count'] - end -end diff --git a/vendor/rails/activerecord/test/cases/counter_cache_test.rb b/vendor/rails/activerecord/test/cases/counter_cache_test.rb deleted file mode 100755 index acfd28c0..00000000 --- a/vendor/rails/activerecord/test/cases/counter_cache_test.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'cases/helper' -require 'models/topic' -require 'models/reply' -require 'models/category' -require 'models/categorization' - -class CounterCacheTest < ActiveRecord::TestCase - fixtures :topics, :categories, :categorizations - - class SpecialTopic < ::Topic - has_many :special_replies, :foreign_key => 'parent_id' - end - - class SpecialReply < ::Reply - belongs_to :special_topic, :foreign_key => 'parent_id', :counter_cache => 'replies_count' - end - - test "increment counter" do - topic = Topic.find(1) - assert_difference 'topic.reload.replies_count' do - Topic.increment_counter(:replies_count, topic.id) - end - end - - test "decrement counter" do - topic = Topic.find(1) - assert_difference 'topic.reload.replies_count', -1 do - Topic.decrement_counter(:replies_count, topic.id) - end - end - - test "reset counters" do - topic = Topic.find(1) - # throw the count off by 1 - Topic.increment_counter(:replies_count, topic.id) - - # check that it gets reset - assert_difference 'topic.reload.replies_count', -1 do - Topic.reset_counters(topic.id, :replies) - end - end - - test "reset counters with string argument" do - topic = Topic.find(1) - Topic.increment_counter('replies_count', topic.id) - - assert_difference 'topic.reload.replies_count', -1 do - Topic.reset_counters(topic.id, 'replies') - end - end - - test "reset counters with modularized and camelized classnames" do - special = SpecialTopic.create!(:title => 'Special') - SpecialTopic.increment_counter(:replies_count, special.id) - - assert_difference 'special.reload.replies_count', -1 do - SpecialTopic.reset_counters(special.id, :special_replies) - end - end - - test "update counter with initial null value" do - category = categories(:general) - assert_equal 2, category.categorizations.count - assert_nil category.categorizations_count - - Category.update_counters(category.id, :categorizations_count => category.categorizations.count) - assert_equal 2, category.reload.categorizations_count - end - - test "update counter for decrement" do - topic = Topic.find(1) - assert_difference 'topic.reload.replies_count', -3 do - Topic.update_counters(topic.id, :replies_count => -3) - end - end - - test "update counters of multiple records" do - t1, t2 = topics(:first, :second) - - assert_difference ['t1.reload.replies_count', 't2.reload.replies_count'], 2 do - Topic.update_counters([t1.id, t2.id], :replies_count => 2) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/database_statements_test.rb b/vendor/rails/activerecord/test/cases/database_statements_test.rb deleted file mode 100644 index 6274d525..00000000 --- a/vendor/rails/activerecord/test/cases/database_statements_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "cases/helper" - -class DatabaseStatementsTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.connection - end - - def test_insert_should_return_the_inserted_id - id = @connection.insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)") - assert_not_nil id - end -end diff --git a/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb b/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb deleted file mode 100644 index 88fb6f73..00000000 --- a/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb +++ /dev/null @@ -1,204 +0,0 @@ -require "cases/helper" - -class PostgresqlArray < ActiveRecord::Base -end - -class PostgresqlMoney < ActiveRecord::Base -end - -class PostgresqlNumber < ActiveRecord::Base -end - -class PostgresqlTime < ActiveRecord::Base -end - -class PostgresqlNetworkAddress < ActiveRecord::Base -end - -class PostgresqlBitString < ActiveRecord::Base -end - -class PostgresqlOid < ActiveRecord::Base -end - -class PostgresqlDataTypeTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @connection = ActiveRecord::Base.connection - @connection.execute("set lc_monetary = 'C'") - - @connection.execute("INSERT INTO postgresql_arrays (commission_by_quarter, nicknames) VALUES ( '{35000,21000,18000,17000}', '{foo,bar,baz}' )") - @first_array = PostgresqlArray.find(1) - - @connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('567.89'::money)") - @connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('-567.89'::money)") - @first_money = PostgresqlMoney.find(1) - @second_money = PostgresqlMoney.find(2) - - @connection.execute("INSERT INTO postgresql_numbers (single, double) VALUES (123.456, 123456.789)") - @first_number = PostgresqlNumber.find(1) - - @connection.execute("INSERT INTO postgresql_times (time_interval) VALUES ('1 year 2 days ago')") - @first_time = PostgresqlTime.find(1) - - @connection.execute("INSERT INTO postgresql_network_addresses (cidr_address, inet_address, mac_address) VALUES('192.168.0/24', '172.16.1.254/32', '01:23:45:67:89:0a')") - @first_network_address = PostgresqlNetworkAddress.find(1) - - @connection.execute("INSERT INTO postgresql_bit_strings (bit_string, bit_string_varying) VALUES (B'00010101', X'15')") - @first_bit_string = PostgresqlBitString.find(1) - - @connection.execute("INSERT INTO postgresql_oids (obj_id) VALUES (1234)") - @first_oid = PostgresqlOid.find(1) - end - - def test_data_type_of_array_types - assert_equal :string, @first_array.column_for_attribute(:commission_by_quarter).type - assert_equal :string, @first_array.column_for_attribute(:nicknames).type - end - - def test_data_type_of_money_types - assert_equal :decimal, @first_money.column_for_attribute(:wealth).type - end - - def test_data_type_of_number_types - assert_equal :float, @first_number.column_for_attribute(:single).type - assert_equal :float, @first_number.column_for_attribute(:double).type - end - - def test_data_type_of_time_types - assert_equal :string, @first_time.column_for_attribute(:time_interval).type - end - - def test_data_type_of_network_address_types - assert_equal :string, @first_network_address.column_for_attribute(:cidr_address).type - assert_equal :string, @first_network_address.column_for_attribute(:inet_address).type - assert_equal :string, @first_network_address.column_for_attribute(:mac_address).type - end - - def test_data_type_of_bit_string_types - assert_equal :string, @first_bit_string.column_for_attribute(:bit_string).type - assert_equal :string, @first_bit_string.column_for_attribute(:bit_string_varying).type - end - - def test_data_type_of_oid_types - assert_equal :integer, @first_oid.column_for_attribute(:obj_id).type - end - - def test_array_values - assert_equal '{35000,21000,18000,17000}', @first_array.commission_by_quarter - assert_equal '{foo,bar,baz}', @first_array.nicknames - end - - def test_money_values - assert_equal 567.89, @first_money.wealth - assert_equal -567.89, @second_money.wealth - end - - def test_number_values - assert_equal 123.456, @first_number.single - assert_equal 123456.789, @first_number.double - end - - def test_time_values - assert_equal '-1 years -2 days', @first_time.time_interval - end - - def test_network_address_values - assert_equal '192.168.0.0/24', @first_network_address.cidr_address - assert_equal '172.16.1.254', @first_network_address.inet_address - assert_equal '01:23:45:67:89:0a', @first_network_address.mac_address - end - - def test_bit_string_values - assert_equal '00010101', @first_bit_string.bit_string - assert_equal '00010101', @first_bit_string.bit_string_varying - end - - def test_oid_values - assert_equal 1234, @first_oid.obj_id - end - - def test_update_integer_array - new_value = '{32800,95000,29350,17000}' - assert @first_array.commission_by_quarter = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.commission_by_quarter, new_value - assert @first_array.commission_by_quarter = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.commission_by_quarter, new_value - end - - def test_update_text_array - new_value = '{robby,robert,rob,robbie}' - assert @first_array.nicknames = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.nicknames, new_value - assert @first_array.nicknames = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.nicknames, new_value - end - - def test_update_money - new_value = BigDecimal.new('123.45') - assert @first_money.wealth = new_value - assert @first_money.save - assert @first_money.reload - assert_equal new_value, @first_money.wealth - end - - def test_update_number - new_single = 789.012 - new_double = 789012.345 - assert @first_number.single = new_single - assert @first_number.double = new_double - assert @first_number.save - assert @first_number.reload - assert_equal @first_number.single, new_single - assert_equal @first_number.double, new_double - end - - def test_update_time - assert @first_time.time_interval = '2 years 3 minutes' - assert @first_time.save - assert @first_time.reload - assert_equal @first_time.time_interval, '2 years 00:03:00' - end - - def test_update_network_address - new_cidr_address = '10.1.2.3/32' - new_inet_address = '10.0.0.0/8' - new_mac_address = 'bc:de:f0:12:34:56' - assert @first_network_address.cidr_address = new_cidr_address - assert @first_network_address.inet_address = new_inet_address - assert @first_network_address.mac_address = new_mac_address - assert @first_network_address.save - assert @first_network_address.reload - assert_equal @first_network_address.cidr_address, new_cidr_address - assert_equal @first_network_address.inet_address, new_inet_address - assert_equal @first_network_address.mac_address, new_mac_address - end - - def test_update_bit_string - new_bit_string = '11111111' - new_bit_string_varying = 'FF' - assert @first_bit_string.bit_string = new_bit_string - assert @first_bit_string.bit_string_varying = new_bit_string_varying - assert @first_bit_string.save - assert @first_bit_string.reload - assert_equal @first_bit_string.bit_string, new_bit_string - assert_equal @first_bit_string.bit_string, @first_bit_string.bit_string_varying - end - - def test_update_oid - new_value = 567890 - assert @first_oid.obj_id = new_value - assert @first_oid.save - assert @first_oid.reload - assert_equal @first_oid.obj_id, new_value - end -end diff --git a/vendor/rails/activerecord/test/cases/date_time_test.rb b/vendor/rails/activerecord/test/cases/date_time_test.rb deleted file mode 100644 index 36e1caa0..00000000 --- a/vendor/rails/activerecord/test/cases/date_time_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/task' - -class DateTimeTest < ActiveRecord::TestCase - def test_saves_both_date_and_time - time_values = [1807, 2, 10, 15, 30, 45] - now = DateTime.civil(*time_values) - - task = Task.new - task.starting = now - task.save! - - # check against Time.local_time, since some platforms will return a Time instead of a DateTime - assert_equal Time.local_time(*time_values), Task.find(task.id).starting - end - - def test_assign_empty_date_time - task = Task.new - task.starting = '' - task.ending = nil - assert_nil task.starting - assert_nil task.ending - end - - def test_assign_empty_date - topic = Topic.new - topic.last_read = '' - assert_nil topic.last_read - end - - def test_assign_empty_time - topic = Topic.new - topic.bonus_time = '' - assert_nil topic.bonus_time - end -end diff --git a/vendor/rails/activerecord/test/cases/default_test_firebird.rb b/vendor/rails/activerecord/test/cases/default_test_firebird.rb deleted file mode 100644 index 713c7e11..00000000 --- a/vendor/rails/activerecord/test/cases/default_test_firebird.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "cases/helper" -require 'models/default' - -class DefaultTest < ActiveRecord::TestCase - def test_default_timestamp - default = Default.new - assert_instance_of(Time, default.default_timestamp) - assert_equal(:datetime, default.column_for_attribute(:default_timestamp).type) - - # Variance should be small; increase if required -- e.g., if test db is on - # remote host and clocks aren't synchronized. - t1 = Time.new - accepted_variance = 1.0 - assert_in_delta(t1.to_f, default.default_timestamp.to_f, accepted_variance) - end -end diff --git a/vendor/rails/activerecord/test/cases/defaults_test.rb b/vendor/rails/activerecord/test/cases/defaults_test.rb deleted file mode 100644 index b4032c23..00000000 --- a/vendor/rails/activerecord/test/cases/defaults_test.rb +++ /dev/null @@ -1,111 +0,0 @@ -require "cases/helper" -require 'models/default' -require 'models/entrant' - -class DefaultTest < ActiveRecord::TestCase - def test_nil_defaults_for_not_null_columns - column_defaults = - if current_adapter?(:MysqlAdapter) && (Mysql.client_version < 50051 || (50100..50122).include?(Mysql.client_version)) - { 'id' => nil, 'name' => '', 'course_id' => nil } - else - { 'id' => nil, 'name' => nil, 'course_id' => nil } - end - - column_defaults.each do |name, default| - column = Entrant.columns_hash[name] - assert !column.null, "#{name} column should be NOT NULL" - assert_equal default, column.default, "#{name} column should be DEFAULT #{default.inspect}" - end - end - - if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter) - def test_default_integers - default = Default.new - assert_instance_of Fixnum, default.positive_integer - assert_equal 1, default.positive_integer - assert_instance_of Fixnum, default.negative_integer - assert_equal -1, default.negative_integer - assert_instance_of BigDecimal, default.decimal_number - assert_equal BigDecimal.new("2.78"), default.decimal_number - end - end - - if current_adapter?(:PostgreSQLAdapter) - def test_multiline_default_text - # older postgres versions represent the default with escapes ("\\012" for a newline) - assert ( "--- []\n\n" == Default.columns_hash['multiline_default'].default || - "--- []\\012\\012" == Default.columns_hash['multiline_default'].default) - end - end -end - -if current_adapter?(:MysqlAdapter) - class DefaultsTestWithoutTransactionalFixtures < ActiveRecord::TestCase - # ActiveRecord::Base#create! (and #save and other related methods) will - # open a new transaction. When in transactional fixtures mode, this will - # cause ActiveRecord to create a new savepoint. However, since MySQL doesn't - # support DDL transactions, creating a table will result in any created - # savepoints to be automatically released. This in turn causes the savepoint - # release code in AbstractAdapter#transaction to fail. - # - # We don't want that to happen, so we disable transactional fixtures here. - self.use_transactional_fixtures = false - - # MySQL 5 and higher is quirky with not null text/blob columns. - # With MySQL Text/blob columns cannot have defaults. If the column is not - # null MySQL will report that the column has a null default - # but it behaves as though the column had a default of '' - def test_mysql_text_not_null_defaults - klass = Class.new(ActiveRecord::Base) - klass.table_name = 'test_mysql_text_not_null_defaults' - klass.connection.create_table klass.table_name do |t| - t.column :non_null_text, :text, :null => false - t.column :non_null_blob, :blob, :null => false - t.column :null_text, :text, :null => true - t.column :null_blob, :blob, :null => true - end - assert_equal '', klass.columns_hash['non_null_blob'].default - assert_equal '', klass.columns_hash['non_null_text'].default - - assert_equal nil, klass.columns_hash['null_blob'].default - assert_equal nil, klass.columns_hash['null_text'].default - - assert_nothing_raised do - instance = klass.create! - assert_equal '', instance.non_null_text - assert_equal '', instance.non_null_blob - assert_nil instance.null_text - assert_nil instance.null_blob - end - ensure - klass.connection.drop_table(klass.table_name) rescue nil - end - - # MySQL uses an implicit default 0 rather than NULL unless in strict mode. - # We use an implicit NULL so schema.rb is compatible with other databases. - def test_mysql_integer_not_null_defaults - klass = Class.new(ActiveRecord::Base) - klass.table_name = 'test_integer_not_null_default_zero' - klass.connection.create_table klass.table_name do |t| - t.column :zero, :integer, :null => false, :default => 0 - t.column :omit, :integer, :null => false - end - - assert_equal 0, klass.columns_hash['zero'].default - assert !klass.columns_hash['zero'].null - # 0 in MySQL 4, nil in 5. - assert [0, nil].include?(klass.columns_hash['omit'].default) - assert !klass.columns_hash['omit'].null - - assert_raise(ActiveRecord::StatementInvalid) { klass.create! } - - assert_nothing_raised do - instance = klass.create!(:omit => 1) - assert_equal 0, instance.zero - assert_equal 1, instance.omit - end - ensure - klass.connection.drop_table(klass.table_name) rescue nil - end - end -end diff --git a/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb b/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb deleted file mode 100644 index 2afc91b7..00000000 --- a/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "cases/helper" -require 'models/entrant' - -class DeprecatedFinderTest < ActiveRecord::TestCase - fixtures :entrants - - def test_deprecated_find_all_was_removed - assert_raise(NoMethodError) { Entrant.find_all } - end - - def test_deprecated_find_first_was_removed - assert_raise(NoMethodError) { Entrant.find_first } - end - - def test_deprecated_find_on_conditions_was_removed - assert_raise(NoMethodError) { Entrant.find_on_conditions } - end - - def test_count - assert_equal(0, Entrant.count(:conditions => "id > 3")) - assert_equal(1, Entrant.count(:conditions => ["id > ?", 2])) - assert_equal(2, Entrant.count(:conditions => ["id > ?", 1])) - end - - def test_count_by_sql - assert_equal(0, Entrant.count_by_sql("SELECT COUNT(*) FROM entrants WHERE id > 3")) - assert_equal(1, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 2])) - assert_equal(2, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 1])) - end -end diff --git a/vendor/rails/activerecord/test/cases/dirty_test.rb b/vendor/rails/activerecord/test/cases/dirty_test.rb deleted file mode 100644 index fb3d26f6..00000000 --- a/vendor/rails/activerecord/test/cases/dirty_test.rb +++ /dev/null @@ -1,316 +0,0 @@ -require 'cases/helper' -require 'models/topic' # For booleans -require 'models/pirate' # For timestamps -require 'models/parrot' -require 'models/person' # For optimistic locking - -class Pirate # Just reopening it, not defining it - attr_accessor :detected_changes_in_after_update # Boolean for if changes are detected - attr_accessor :changes_detected_in_after_update # Actual changes - - after_update :check_changes - -private - # after_save/update in sweepers, observers, and the model itself - # can end up checking dirty status and acting on the results - def check_changes - if self.changed? - self.detected_changes_in_after_update = true - self.changes_detected_in_after_update = self.changes - end - end -end - -class NumericData < ActiveRecord::Base - self.table_name = 'numeric_data' -end - -class DirtyTest < ActiveRecord::TestCase - def test_attribute_changes - # New record - no changes. - pirate = Pirate.new - assert !pirate.catchphrase_changed? - assert_nil pirate.catchphrase_change - - # Change catchphrase. - pirate.catchphrase = 'arrr' - assert pirate.catchphrase_changed? - assert_nil pirate.catchphrase_was - assert_equal [nil, 'arrr'], pirate.catchphrase_change - - # Saved - no changes. - pirate.save! - assert !pirate.catchphrase_changed? - assert_nil pirate.catchphrase_change - - # Same value - no changes. - pirate.catchphrase = 'arrr' - assert !pirate.catchphrase_changed? - assert_nil pirate.catchphrase_change - end - - def test_aliased_attribute_changes - # the actual attribute here is name, title is an - # alias setup via alias_attribute - parrot = Parrot.new - assert !parrot.title_changed? - assert_nil parrot.title_change - - parrot.name = 'Sam' - assert parrot.title_changed? - assert_nil parrot.title_was - assert_equal parrot.name_change, parrot.title_change - end - - def test_nullable_number_not_marked_as_changed_if_new_value_is_blank - pirate = Pirate.new - - ["", nil].each do |value| - pirate.parrot_id = value - assert !pirate.parrot_id_changed? - assert_nil pirate.parrot_id_change - end - end - - def test_nullable_decimal_not_marked_as_changed_if_new_value_is_blank - numeric_data = NumericData.new - - ["", nil].each do |value| - numeric_data.bank_balance = value - assert !numeric_data.bank_balance_changed? - assert_nil numeric_data.bank_balance_change - end - end - - def test_nullable_float_not_marked_as_changed_if_new_value_is_blank - numeric_data = NumericData.new - - ["", nil].each do |value| - numeric_data.temperature = value - assert !numeric_data.temperature_changed? - assert_nil numeric_data.temperature_change - end - end - - def test_nullable_integer_zero_to_string_zero_not_marked_as_changed - pirate = Pirate.new - pirate.parrot_id = 0 - pirate.catchphrase = 'arrr' - assert pirate.save! - - assert !pirate.changed? - - pirate.parrot_id = '0' - assert !pirate.changed? - end - - def test_zero_to_blank_marked_as_changed - pirate = Pirate.new - pirate.catchphrase = "Yarrrr, me hearties" - pirate.parrot_id = 1 - pirate.save - - # check the change from 1 to '' - pirate = Pirate.find_by_catchphrase("Yarrrr, me hearties") - pirate.parrot_id = '' - assert pirate.parrot_id_changed? - assert_equal([1, nil], pirate.parrot_id_change) - pirate.save - - # check the change from nil to 0 - pirate = Pirate.find_by_catchphrase("Yarrrr, me hearties") - pirate.parrot_id = 0 - assert pirate.parrot_id_changed? - assert_equal([nil, 0], pirate.parrot_id_change) - pirate.save - - # check the change from 0 to '' - pirate = Pirate.find_by_catchphrase("Yarrrr, me hearties") - pirate.parrot_id = '' - assert pirate.parrot_id_changed? - assert_equal([0, nil], pirate.parrot_id_change) - end - - def test_object_should_be_changed_if_any_attribute_is_changed - pirate = Pirate.new - assert !pirate.changed? - assert_equal [], pirate.changed - assert_equal Hash.new, pirate.changes - - pirate.catchphrase = 'arrr' - assert pirate.changed? - assert_nil pirate.catchphrase_was - assert_equal %w(catchphrase), pirate.changed - assert_equal({'catchphrase' => [nil, 'arrr']}, pirate.changes) - - pirate.save - assert !pirate.changed? - assert_equal [], pirate.changed - assert_equal Hash.new, pirate.changes - end - - def test_attribute_will_change! - pirate = Pirate.create!(:catchphrase => 'arr') - - pirate.catchphrase << ' matey' - assert !pirate.catchphrase_changed? - - assert pirate.catchphrase_will_change! - assert pirate.catchphrase_changed? - assert_equal ['arr matey', 'arr matey'], pirate.catchphrase_change - - pirate.catchphrase << '!' - assert pirate.catchphrase_changed? - assert_equal ['arr matey', 'arr matey!'], pirate.catchphrase_change - end - - def test_association_assignment_changes_foreign_key - pirate = Pirate.create!(:catchphrase => 'jarl') - pirate.parrot = Parrot.create!(:name => 'Lorre') - assert pirate.changed? - assert_equal %w(parrot_id), pirate.changed - end - - def test_attribute_should_be_compared_with_type_cast - topic = Topic.new - assert topic.approved? - assert !topic.approved_changed? - - # Coming from web form. - params = {:topic => {:approved => 1}} - # In the controller. - topic.attributes = params[:topic] - assert topic.approved? - assert !topic.approved_changed? - end - - def test_partial_update - pirate = Pirate.new(:catchphrase => 'foo') - old_updated_on = 1.hour.ago.beginning_of_day - - with_partial_updates Pirate, false do - assert_queries(2) { 2.times { pirate.save! } } - Pirate.update_all({ :updated_on => old_updated_on }, :id => pirate.id) - end - - with_partial_updates Pirate, true do - assert_queries(0) { 2.times { pirate.save! } } - assert_equal old_updated_on, pirate.reload.updated_on - - assert_queries(1) { pirate.catchphrase = 'bar'; pirate.save! } - assert_not_equal old_updated_on, pirate.reload.updated_on - end - end - - def test_partial_update_with_optimistic_locking - person = Person.new(:first_name => 'foo') - old_lock_version = 1 - - with_partial_updates Person, false do - assert_queries(2) { 2.times { person.save! } } - Person.update_all({ :first_name => 'baz' }, :id => person.id) - end - - with_partial_updates Person, true do - assert_queries(0) { 2.times { person.save! } } - assert_equal old_lock_version, person.reload.lock_version - - assert_queries(1) { person.first_name = 'bar'; person.save! } - assert_not_equal old_lock_version, person.reload.lock_version - end - end - - def test_changed_attributes_should_be_preserved_if_save_failure - pirate = Pirate.new - pirate.parrot_id = 1 - assert !pirate.save - check_pirate_after_save_failure(pirate) - - pirate = Pirate.new - pirate.parrot_id = 1 - assert_raise(ActiveRecord::RecordInvalid) { pirate.save! } - check_pirate_after_save_failure(pirate) - end - - def test_reload_should_clear_changed_attributes - pirate = Pirate.create!(:catchphrase => "shiver me timbers") - pirate.catchphrase = "*hic*" - assert pirate.changed? - pirate.reload - assert !pirate.changed? - end - - def test_reverted_changes_are_not_dirty - phrase = "shiver me timbers" - pirate = Pirate.create!(:catchphrase => phrase) - pirate.catchphrase = "*hic*" - assert pirate.changed? - pirate.catchphrase = phrase - assert !pirate.changed? - end - - def test_reverted_changes_are_not_dirty_after_multiple_changes - phrase = "shiver me timbers" - pirate = Pirate.create!(:catchphrase => phrase) - 10.times do |i| - pirate.catchphrase = "*hic*" * i - assert pirate.changed? - end - assert pirate.changed? - pirate.catchphrase = phrase - assert !pirate.changed? - end - - - def test_reverted_changes_are_not_dirty_going_from_nil_to_value_and_back - pirate = Pirate.create!(:catchphrase => "Yar!") - - pirate.parrot_id = 1 - assert pirate.changed? - assert pirate.parrot_id_changed? - assert !pirate.catchphrase_changed? - - pirate.parrot_id = nil - assert !pirate.changed? - assert !pirate.parrot_id_changed? - assert !pirate.catchphrase_changed? - end - - def test_save_should_store_serialized_attributes_even_with_partial_updates - with_partial_updates(Topic) do - topic = Topic.create!(:content => {:a => "a"}) - topic.content[:b] = "b" - #assert topic.changed? # Known bug, will fail - topic.save! - assert_equal "b", topic.content[:b] - topic.reload - assert_equal "b", topic.content[:b] - end - end - - def test_save_should_not_save_serialized_attribute_with_partial_updates_if_not_present - with_partial_updates(Topic) do - Topic.create!(:author_name => 'Bill', :content => {:a => "a"}) - topic = Topic.first(:select => 'id, author_name') - topic.update_attribute :author_name, 'John' - topic = Topic.first - assert_not_nil topic.content - end - end - - private - def with_partial_updates(klass, on = true) - old = klass.partial_updates? - klass.partial_updates = on - yield - ensure - klass.partial_updates = old - end - - def check_pirate_after_save_failure(pirate) - assert pirate.changed? - assert pirate.parrot_id_changed? - assert_equal %w(parrot_id), pirate.changed - assert_nil pirate.parrot_id_was - end -end diff --git a/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb b/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb deleted file mode 100644 index 4e6fecf1..00000000 --- a/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -require "cases/helper" -require 'models/topic' - -class FinderRespondToTest < ActiveRecord::TestCase - - fixtures :topics - - def test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method - class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) { } - assert Topic.respond_to?(:method_added_for_finder_respond_to_test) - ensure - class << Topic; self; end.send(:remove_method, :method_added_for_finder_respond_to_test) - end - - def test_should_preserve_normal_respond_to_behaviour_and_respond_to_standard_object_method - assert Topic.respond_to?(:to_s) - end - - def test_should_respond_to_find_by_one_attribute_before_caching - ensure_topic_method_is_not_cached(:find_by_title) - assert Topic.respond_to?(:find_by_title) - end - - def test_should_respond_to_find_all_by_one_attribute - ensure_topic_method_is_not_cached(:find_all_by_title) - assert Topic.respond_to?(:find_all_by_title) - end - - def test_should_respond_to_find_all_by_two_attributes - ensure_topic_method_is_not_cached(:find_all_by_title_and_author_name) - assert Topic.respond_to?(:find_all_by_title_and_author_name) - end - - def test_should_respond_to_find_by_two_attributes - ensure_topic_method_is_not_cached(:find_by_title_and_author_name) - assert Topic.respond_to?(:find_by_title_and_author_name) - end - - def test_should_respond_to_find_or_initialize_from_one_attribute - ensure_topic_method_is_not_cached(:find_or_initialize_by_title) - assert Topic.respond_to?(:find_or_initialize_by_title) - end - - def test_should_respond_to_find_or_initialize_from_two_attributes - ensure_topic_method_is_not_cached(:find_or_initialize_by_title_and_author_name) - assert Topic.respond_to?(:find_or_initialize_by_title_and_author_name) - end - - def test_should_respond_to_find_or_create_from_one_attribute - ensure_topic_method_is_not_cached(:find_or_create_by_title) - assert Topic.respond_to?(:find_or_create_by_title) - end - - def test_should_respond_to_find_or_create_from_two_attributes - ensure_topic_method_is_not_cached(:find_or_create_by_title_and_author_name) - assert Topic.respond_to?(:find_or_create_by_title_and_author_name) - end - - def test_should_not_respond_to_find_by_one_missing_attribute - assert !Topic.respond_to?(:find_by_undertitle) - end - - def test_should_not_respond_to_find_by_invalid_method_syntax - assert !Topic.respond_to?(:fail_to_find_by_title) - assert !Topic.respond_to?(:find_by_title?) - assert !Topic.respond_to?(:fail_to_find_or_create_by_title) - assert !Topic.respond_to?(:find_or_create_by_title?) - end - - private - - def ensure_topic_method_is_not_cached(method_id) - class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.any? { |m| m.to_s == method_id.to_s } - end - -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/finder_test.rb b/vendor/rails/activerecord/test/cases/finder_test.rb deleted file mode 100644 index c779a69f..00000000 --- a/vendor/rails/activerecord/test/cases/finder_test.rb +++ /dev/null @@ -1,1070 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/author' -require 'models/categorization' -require 'models/comment' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/entrant' -require 'models/developer' -require 'models/customer' -require 'models/job' -require 'models/categorization' - -class DynamicFinderMatchTest < ActiveRecord::TestCase - def test_find_no_match - assert_nil ActiveRecord::DynamicFinderMatch.match("not_a_finder") - end - - def test_find_by - match = ActiveRecord::DynamicFinderMatch.match("find_by_age_and_sex_and_location") - assert_not_nil match - assert match.finder? - assert_equal :first, match.finder - assert_equal %w(age sex location), match.attribute_names - end - - def find_by_bang - match = ActiveRecord::DynamicFinderMatch.match("find_by_age_and_sex_and_location!") - assert_not_nil match - assert match.finder? - assert match.bang? - assert_equal :first, match.finder - assert_equal %w(age sex location), match.attribute_names - end - - def test_find_all_by - match = ActiveRecord::DynamicFinderMatch.match("find_all_by_age_and_sex_and_location") - assert_not_nil match - assert match.finder? - assert_equal :all, match.finder - assert_equal %w(age sex location), match.attribute_names - end - - def test_find_or_initialize_by - match = ActiveRecord::DynamicFinderMatch.match("find_or_initialize_by_age_and_sex_and_location") - assert_not_nil match - assert !match.finder? - assert match.instantiator? - assert_equal :first, match.finder - assert_equal :new, match.instantiator - assert_equal %w(age sex location), match.attribute_names - end - - def test_find_or_create_by - match = ActiveRecord::DynamicFinderMatch.match("find_or_create_by_age_and_sex_and_location") - assert_not_nil match - assert !match.finder? - assert match.instantiator? - assert_equal :first, match.finder - assert_equal :create, match.instantiator - assert_equal %w(age sex location), match.attribute_names - end -end - -class FinderTest < ActiveRecord::TestCase - fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors, :customers - - def test_find - assert_equal(topics(:first).title, Topic.find(1).title) - end - - # find should handle strings that come from URLs - # (example: Category.find(params[:id])) - def test_find_with_string - assert_equal(Topic.find(1).title,Topic.find("1").title) - end - - def test_exists - assert Topic.exists?(1) - assert Topic.exists?("1") - assert Topic.exists?(:author_name => "David") - assert Topic.exists?(:author_name => "Mary", :approved => true) - assert Topic.exists?(["parent_id = ?", 1]) - assert !Topic.exists?(45) - - begin - assert !Topic.exists?("foo") - rescue ActiveRecord::StatementInvalid - # PostgreSQL complains about string comparison with integer field - rescue Exception - flunk - end - - assert_raise(NoMethodError) { Topic.exists?([1,2]) } - end - - def test_exists_returns_true_with_one_record_and_no_args - assert Topic.exists? - end - - def test_does_not_exist_with_empty_table_and_no_args_given - Topic.delete_all - assert !Topic.exists? - end - - def test_exists_with_aggregate_having_three_mappings - existing_address = customers(:david).address - assert Customer.exists?(:address => existing_address) - end - - def test_exists_with_aggregate_having_three_mappings_with_one_difference - existing_address = customers(:david).address - assert !Customer.exists?(:address => - Address.new(existing_address.street, existing_address.city, existing_address.country + "1")) - assert !Customer.exists?(:address => - Address.new(existing_address.street, existing_address.city + "1", existing_address.country)) - assert !Customer.exists?(:address => - Address.new(existing_address.street + "1", existing_address.city, existing_address.country)) - end - - def test_exists_with_scoped_include - Developer.with_scope(:find => { :include => :projects, :order => "projects.name" }) do - assert Developer.exists? - end - end - - def test_find_by_array_of_one_id - assert_kind_of(Array, Topic.find([ 1 ])) - assert_equal(1, Topic.find([ 1 ]).length) - end - - def test_find_by_ids - assert_equal 2, Topic.find(1, 2).size - assert_equal topics(:second).title, Topic.find([2]).first.title - end - - def test_find_by_ids_with_limit_and_offset - assert_equal 2, Entrant.find([1,3,2], :limit => 2).size - assert_equal 1, Entrant.find([1,3,2], :limit => 3, :offset => 2).size - - # Also test an edge case: If you have 11 results, and you set a - # limit of 3 and offset of 9, then you should find that there - # will be only 2 results, regardless of the limit. - devs = Developer.find :all - last_devs = Developer.find devs.map(&:id), :limit => 3, :offset => 9 - assert_equal 2, last_devs.size - end - - def test_find_an_empty_array - assert_equal [], Topic.find([]) - end - - def test_find_by_ids_missing_one - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, 2, 45) } - end - - def test_find_all_with_limit - assert_equal(2, Entrant.find(:all, :limit => 2).size) - assert_equal(0, Entrant.find(:all, :limit => 0).size) - end - - def test_find_all_with_prepared_limit_and_offset - entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 1) - - assert_equal(2, entrants.size) - assert_equal(entrants(:second).name, entrants.first.name) - - assert_equal 3, Entrant.count - entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 2) - assert_equal(1, entrants.size) - assert_equal(entrants(:third).name, entrants.first.name) - end - - def test_find_all_with_limit_and_offset_and_multiple_order_clauses - first_three_posts = Post.find :all, :order => 'author_id, id', :limit => 3, :offset => 0 - second_three_posts = Post.find :all, :order => ' author_id,id ', :limit => 3, :offset => 3 - last_posts = Post.find :all, :order => ' author_id, id ', :limit => 3, :offset => 6 - - assert_equal [[0,3],[1,1],[1,2]], first_three_posts.map { |p| [p.author_id, p.id] } - assert_equal [[1,4],[1,5],[1,6]], second_three_posts.map { |p| [p.author_id, p.id] } - assert_equal [[2,7]], last_posts.map { |p| [p.author_id, p.id] } - end - - - def test_find_with_group - developers = Developer.find(:all, :group => "salary", :select => "salary") - assert_equal 4, developers.size - assert_equal 4, developers.map(&:salary).uniq.size - end - - def test_find_with_group_and_having - developers = Developer.find(:all, :group => "salary", :having => "sum(salary) > 10000", :select => "salary") - assert_equal 3, developers.size - assert_equal 3, developers.map(&:salary).uniq.size - assert developers.all? { |developer| developer.salary > 10000 } - end - - def test_find_with_group_and_sanitized_having - developers = Developer.find(:all, :group => "salary", :having => ["sum(salary) > ?", 10000], :select => "salary") - assert_equal 3, developers.size - assert_equal 3, developers.map(&:salary).uniq.size - assert developers.all? { |developer| developer.salary > 10000 } - end - - def test_find_with_entire_select_statement - topics = Topic.find_by_sql "SELECT * FROM topics WHERE author_name = 'Mary'" - - assert_equal(1, topics.size) - assert_equal(topics(:second).title, topics.first.title) - end - - def test_find_with_prepared_select_statement - topics = Topic.find_by_sql ["SELECT * FROM topics WHERE author_name = ?", "Mary"] - - assert_equal(1, topics.size) - assert_equal(topics(:second).title, topics.first.title) - end - - def test_find_by_sql_with_sti_on_joined_table - accounts = Account.find_by_sql("SELECT * FROM accounts INNER JOIN companies ON companies.id = accounts.firm_id") - assert_equal [Account], accounts.collect(&:class).uniq - end - - def test_find_first - first = Topic.find(:first, :conditions => "title = 'The First Topic'") - assert_equal(topics(:first).title, first.title) - end - - def test_find_first_failing - first = Topic.find(:first, :conditions => "title = 'The First Topic!'") - assert_nil(first) - end - - def test_first - assert_equal topics(:second).title, Topic.first(:conditions => "title = 'The Second Topic of the day'").title - end - - def test_first_failing - assert_nil Topic.first(:conditions => "title = 'The Second Topic of the day!'") - end - - def test_unexisting_record_exception_handling - assert_raise(ActiveRecord::RecordNotFound) { - Topic.find(1).parent - } - - Topic.find(2).topic - end - - def test_find_only_some_columns - topic = Topic.find(1, :select => "author_name") - assert_raise(ActiveRecord::MissingAttributeError) {topic.title} - assert_equal "David", topic.author_name - assert !topic.attribute_present?("title") - #assert !topic.respond_to?("title") - assert topic.attribute_present?("author_name") - assert topic.respond_to?("author_name") - end - - def test_find_on_blank_conditions - [nil, " ", [], {}].each do |blank| - assert_nothing_raised { Topic.find(:first, :conditions => blank) } - end - end - - def test_find_on_blank_bind_conditions - [ [""], ["",{}] ].each do |blank| - assert_nothing_raised { Topic.find(:first, :conditions => blank) } - end - end - - def test_find_on_array_conditions - assert Topic.find(1, :conditions => ["approved = ?", false]) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) } - end - - def test_find_on_hash_conditions - assert Topic.find(1, :conditions => { :approved => false }) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) } - end - - def test_find_on_hash_conditions_with_explicit_table_name - assert Topic.find(1, :conditions => { 'topics.approved' => false }) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { 'topics.approved' => true }) } - end - - def test_find_on_hash_conditions_with_hashed_table_name - assert Topic.find(1, :conditions => {:topics => { :approved => false }}) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => {:topics => { :approved => true }}) } - end - - def test_find_with_hash_conditions_on_joined_table - firms = Firm.all :joins => :account, :conditions => {:accounts => { :credit_limit => 50 }} - assert_equal 1, firms.size - assert_equal companies(:first_firm), firms.first - end - - def test_find_with_hash_conditions_on_joined_table_and_with_range - firms = DependentFirm.all :joins => :account, :conditions => {:name => 'RailsCore', :accounts => { :credit_limit => 55..60 }} - assert_equal 1, firms.size - assert_equal companies(:rails_core), firms.first - end - - def test_find_on_hash_conditions_with_explicit_table_name_and_aggregate - david = customers(:david) - assert Customer.find(david.id, :conditions => { 'customers.name' => david.name, :address => david.address }) - assert_raise(ActiveRecord::RecordNotFound) { - Customer.find(david.id, :conditions => { 'customers.name' => david.name + "1", :address => david.address }) - } - end - - def test_find_on_association_proxy_conditions - assert_equal [1, 2, 3, 5, 6, 7, 8, 9, 10], Comment.find_all_by_post_id(authors(:david).posts).map(&:id).sort - end - - def test_find_on_hash_conditions_with_range - assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1..2 }).map(&:id).sort - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) } - end - - def test_find_on_hash_conditions_with_end_exclusive_range - assert_equal [1,2,3], Topic.find(:all, :conditions => { :id => 1..3 }).map(&:id).sort - assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1...3 }).map(&:id).sort - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(3, :conditions => { :id => 2...3 }) } - end - - def test_find_on_hash_conditions_with_multiple_ranges - assert_equal [1,2,3], Comment.find(:all, :conditions => { :id => 1..3, :post_id => 1..2 }).map(&:id).sort - assert_equal [1], Comment.find(:all, :conditions => { :id => 1..1, :post_id => 1..10 }).map(&:id).sort - end - - def test_find_on_multiple_hash_conditions - assert Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => false }) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "HHC", :replies_count => 1, :approved => false }) } - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } - end - - def test_condition_interpolation - assert_kind_of Firm, Company.find(:first, :conditions => ["name = '%s'", "37signals"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!' OR 1=1"]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = %d", 1]).written_on - end - - def test_condition_array_interpolation - assert_kind_of Firm, Company.find(:first, :conditions => ["name = '%s'", "37signals"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!' OR 1=1"]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = %d", 1]).written_on - end - - def test_condition_hash_interpolation - assert_kind_of Firm, Company.find(:first, :conditions => { :name => "37signals"}) - assert_nil Company.find(:first, :conditions => { :name => "37signals!"}) - assert_kind_of Time, Topic.find(:first, :conditions => {:id => 1}).written_on - end - - def test_hash_condition_find_malformed - assert_raise(ActiveRecord::StatementInvalid) { - Company.find(:first, :conditions => { :id => 2, :dhh => true }) - } - end - - def test_hash_condition_find_with_escaped_characters - Company.create("name" => "Ain't noth'n like' \#stuff") - assert Company.find(:first, :conditions => { :name => "Ain't noth'n like' \#stuff" }) - end - - def test_hash_condition_find_with_array - p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => { :id => [p1, p2] }, :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => { :id => [p1, p2.id] }, :order => 'id asc') - end - - def test_hash_condition_find_with_nil - topic = Topic.find(:first, :conditions => { :last_read => nil } ) - assert_not_nil topic - assert_nil topic.last_read - end - - def test_hash_condition_find_with_aggregate_having_one_mapping - balance = customers(:david).balance - assert_kind_of Money, balance - found_customer = Customer.find(:first, :conditions => {:balance => balance}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_attribute_having_same_name_as_field_and_key_value_being_aggregate - gps_location = customers(:david).gps_location - assert_kind_of GpsLocation, gps_location - found_customer = Customer.find(:first, :conditions => {:gps_location => gps_location}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_having_one_mapping_and_key_value_being_attribute_value - balance = customers(:david).balance - assert_kind_of Money, balance - found_customer = Customer.find(:first, :conditions => {:balance => balance.amount}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_attribute_having_same_name_as_field_and_key_value_being_attribute_value - gps_location = customers(:david).gps_location - assert_kind_of GpsLocation, gps_location - found_customer = Customer.find(:first, :conditions => {:gps_location => gps_location.gps_location}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_having_three_mappings - address = customers(:david).address - assert_kind_of Address, address - found_customer = Customer.find(:first, :conditions => {:address => address}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_one_condition_being_aggregate_and_another_not - address = customers(:david).address - assert_kind_of Address, address - found_customer = Customer.find(:first, :conditions => {:address => address, :name => customers(:david).name}) - assert_equal customers(:david), found_customer - end - - def test_bind_variables - assert_kind_of Firm, Company.find(:first, :conditions => ["name = ?", "37signals"]) - assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!"]) - assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!' OR 1=1"]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = ?", 1]).written_on - assert_raise(ActiveRecord::PreparedStatementInvalid) { - Company.find(:first, :conditions => ["id=? AND name = ?", 2]) - } - assert_raise(ActiveRecord::PreparedStatementInvalid) { - Company.find(:first, :conditions => ["id=?", 2, 3, 4]) - } - end - - def test_bind_variables_with_quotes - Company.create("name" => "37signals' go'es agains") - assert Company.find(:first, :conditions => ["name = ?", "37signals' go'es agains"]) - end - - def test_named_bind_variables_with_quotes - Company.create("name" => "37signals' go'es agains") - assert Company.find(:first, :conditions => ["name = :name", {:name => "37signals' go'es agains"}]) - end - - def test_bind_arity - assert_nothing_raised { bind '' } - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '', 1 } - - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?' } - assert_nothing_raised { bind '?', 1 } - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 } - end - - def test_named_bind_variables - assert_equal '1', bind(':a', :a => 1) # ' ruby-mode - assert_equal '1 1', bind(':a :a', :a => 1) # ' ruby-mode - - assert_nothing_raised { bind("'+00:00'", :foo => "bar") } - - assert_kind_of Firm, Company.find(:first, :conditions => ["name = :name", { :name => "37signals" }]) - assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!" }]) - assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!' OR 1=1" }]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = :id", { :id => 1 }]).written_on - end - - def test_bind_enumerable - quoted_abc = %(#{ActiveRecord::Base.connection.quote('a')},#{ActiveRecord::Base.connection.quote('b')},#{ActiveRecord::Base.connection.quote('c')}) - - assert_equal '1,2,3', bind('?', [1, 2, 3]) - assert_equal quoted_abc, bind('?', %w(a b c)) - - assert_equal '1,2,3', bind(':a', :a => [1, 2, 3]) - assert_equal quoted_abc, bind(':a', :a => %w(a b c)) # ' - - require 'set' - assert_equal '1,2,3', bind('?', Set.new([1, 2, 3])) - assert_equal quoted_abc, bind('?', Set.new(%w(a b c))) - - assert_equal '1,2,3', bind(':a', :a => Set.new([1, 2, 3])) - assert_equal quoted_abc, bind(':a', :a => Set.new(%w(a b c))) # ' - end - - def test_bind_empty_enumerable - quoted_nil = ActiveRecord::Base.connection.quote(nil) - assert_equal quoted_nil, bind('?', []) - assert_equal " in (#{quoted_nil})", bind(' in (?)', []) - assert_equal "foo in (#{quoted_nil})", bind('foo in (?)', []) - end - - def test_bind_string - assert_equal ActiveRecord::Base.connection.quote(''), bind('?', '') - end - - def test_bind_chars - quoted_bambi = ActiveRecord::Base.connection.quote("Bambi") - quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote("Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi}", bind('name=?', "Bambi") - assert_equal "name=#{quoted_bambi_and_thumper}", bind('name=?', "Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi}", bind('name=?', "Bambi".mb_chars) - assert_equal "name=#{quoted_bambi_and_thumper}", bind('name=?', "Bambi\nand\nThumper".mb_chars) - end - - def test_bind_record - o = Struct.new(:quoted_id).new(1) - assert_equal '1', bind('?', o) - - os = [o] * 3 - assert_equal '1,1,1', bind('?', os) - end - - def test_named_bind_with_postgresql_type_casts - l = Proc.new { bind(":a::integer '2009-01-01'::date", :a => '10') } - assert_nothing_raised(&l) - assert_equal "#{ActiveRecord::Base.quote_value('10')}::integer '2009-01-01'::date", l.call - end - - def test_string_sanitation - assert_not_equal "'something ' 1=1'", ActiveRecord::Base.sanitize("something ' 1=1") - assert_equal "'something; select table'", ActiveRecord::Base.sanitize("something; select table") - end - - def test_count - assert_equal(0, Entrant.count(:conditions => "id > 3")) - assert_equal(1, Entrant.count(:conditions => ["id > ?", 2])) - assert_equal(2, Entrant.count(:conditions => ["id > ?", 1])) - end - - def test_count_by_sql - assert_equal(0, Entrant.count_by_sql("SELECT COUNT(*) FROM entrants WHERE id > 3")) - assert_equal(1, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 2])) - assert_equal(2, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 1])) - end - - def test_dynamic_finders_should_go_through_the_find_class_method - Topic.expects(:find).with(:first, :conditions => { :title => 'The First Topic!' }) - Topic.find_by_title("The First Topic!") - - Topic.expects(:find).with(:last, :conditions => { :title => 'The Last Topic!' }) - Topic.find_last_by_title("The Last Topic!") - - Topic.expects(:find).with(:all, :conditions => { :title => 'A Topic.' }) - Topic.find_all_by_title("A Topic.") - - Topic.expects(:find).with(:first, :conditions => { :title => 'Does not exist yet for sure!' }).times(2) - Topic.find_or_initialize_by_title('Does not exist yet for sure!') - Topic.find_or_create_by_title('Does not exist yet for sure!') - end - - def test_find_by_one_attribute - assert_equal topics(:first), Topic.find_by_title("The First Topic") - assert_nil Topic.find_by_title("The First Topic!") - end - - def test_find_by_one_attribute_bang - assert_equal topics(:first), Topic.find_by_title!("The First Topic") - assert_raise(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") } - end - - def test_find_by_one_attribute_caches_dynamic_finder - # ensure this test can run independently of order - class << Topic; self; end.send(:remove_method, :find_by_title) if Topic.public_methods.any? { |m| m.to_s == 'find_by_title' } - assert !Topic.public_methods.any? { |m| m.to_s == 'find_by_title' } - t = Topic.find_by_title("The First Topic") - assert Topic.public_methods.any? { |m| m.to_s == 'find_by_title' } - end - - def test_dynamic_finder_returns_same_results_after_caching - # ensure this test can run independently of order - class << Topic; self; end.send(:remove_method, :find_by_title) if Topic.public_method_defined?(:find_by_title) - t = Topic.find_by_title("The First Topic") - assert_equal t, Topic.find_by_title("The First Topic") # find_by_title has been cached - end - - def test_find_by_one_attribute_with_order_option - assert_equal accounts(:signals37), Account.find_by_credit_limit(50, :order => 'id') - assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :order => 'id DESC') - end - - def test_find_by_one_attribute_with_conditions - assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) - end - - def test_find_by_one_attribute_that_is_an_aggregate - address = customers(:david).address - assert_kind_of Address, address - found_customer = Customer.find_by_address(address) - assert_equal customers(:david), found_customer - end - - def test_find_by_one_attribute_that_is_an_aggregate_with_one_attribute_difference - address = customers(:david).address - assert_kind_of Address, address - missing_address = Address.new(address.street, address.city, address.country + "1") - assert_nil Customer.find_by_address(missing_address) - missing_address = Address.new(address.street, address.city + "1", address.country) - assert_nil Customer.find_by_address(missing_address) - missing_address = Address.new(address.street + "1", address.city, address.country) - assert_nil Customer.find_by_address(missing_address) - end - - def test_find_by_two_attributes_that_are_both_aggregates - balance = customers(:david).balance - address = customers(:david).address - assert_kind_of Money, balance - assert_kind_of Address, address - found_customer = Customer.find_by_balance_and_address(balance, address) - assert_equal customers(:david), found_customer - end - - def test_find_by_two_attributes_with_one_being_an_aggregate - balance = customers(:david).balance - assert_kind_of Money, balance - found_customer = Customer.find_by_balance_and_name(balance, customers(:david).name) - assert_equal customers(:david), found_customer - end - - def test_dynamic_finder_on_one_attribute_with_conditions_caches_method - # ensure this test can run independently of order - class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - assert !Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - a = Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) - assert Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - end - - def test_dynamic_finder_on_one_attribute_with_conditions_returns_same_results_after_caching - # ensure this test can run independently of order - class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - a = Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) - assert_equal a, Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) # find_by_credit_limit has been cached - end - - def test_find_by_one_attribute_with_several_options - assert_equal accounts(:unknown), Account.find_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3]) - end - - def test_find_by_one_missing_attribute - assert_raise(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } - end - - def test_find_by_invalid_method_syntax - assert_raise(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") } - assert_raise(NoMethodError) { Topic.find_by_title?("The First Topic") } - assert_raise(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") } - assert_raise(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") } - end - - def test_find_by_two_attributes - assert_equal topics(:first), Topic.find_by_title_and_author_name("The First Topic", "David") - assert_nil Topic.find_by_title_and_author_name("The First Topic", "Mary") - end - - def test_find_last_by_one_attribute - assert_equal Topic.last, Topic.find_last_by_title(Topic.last.title) - assert_nil Topic.find_last_by_title("A title with no matches") - end - - def test_find_last_by_one_attribute_caches_dynamic_finder - # ensure this test can run independently of order - class << Topic; self; end.send(:remove_method, :find_last_by_title) if Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' } - assert !Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' } - t = Topic.find_last_by_title(Topic.last.title) - assert Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' } - end - - def test_find_last_by_invalid_method_syntax - assert_raise(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") } - assert_raise(NoMethodError) { Topic.find_last_by_title?("The First Topic") } - end - - def test_find_last_by_one_attribute_with_several_options - assert_equal accounts(:signals37), Account.find_last_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3]) - end - - def test_find_last_by_one_missing_attribute - assert_raise(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") } - end - - def test_find_last_by_two_attributes - topic = Topic.last - assert_equal topic, Topic.find_last_by_title_and_author_name(topic.title, topic.author_name) - assert_nil Topic.find_last_by_title_and_author_name(topic.title, "Anonymous") - end - - def test_find_all_by_one_attribute - topics = Topic.find_all_by_content("Have a nice day") - assert_equal 2, topics.size - assert topics.include?(topics(:first)) - - assert_equal [], Topic.find_all_by_title("The First Topic!!") - end - - def test_find_all_by_one_attribute_that_is_an_aggregate - balance = customers(:david).balance - assert_kind_of Money, balance - found_customers = Customer.find_all_by_balance(balance) - assert_equal 1, found_customers.size - assert_equal customers(:david), found_customers.first - end - - def test_find_all_by_two_attributes_that_are_both_aggregates - balance = customers(:david).balance - address = customers(:david).address - assert_kind_of Money, balance - assert_kind_of Address, address - found_customers = Customer.find_all_by_balance_and_address(balance, address) - assert_equal 1, found_customers.size - assert_equal customers(:david), found_customers.first - end - - def test_find_all_by_two_attributes_with_one_being_an_aggregate - balance = customers(:david).balance - assert_kind_of Money, balance - found_customers = Customer.find_all_by_balance_and_name(balance, customers(:david).name) - assert_equal 1, found_customers.size - assert_equal customers(:david), found_customers.first - end - - def test_find_all_by_one_attribute_with_options - topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC") - assert topics(:first), topics.last - - topics = Topic.find_all_by_content("Have a nice day", :order => "id") - assert topics(:first), topics.first - end - - def test_find_all_by_array_attribute - assert_equal 2, Topic.find_all_by_title(["The First Topic", "The Second Topic of the day"]).size - end - - def test_find_all_by_boolean_attribute - topics = Topic.find_all_by_approved(false) - assert_equal 1, topics.size - assert topics.include?(topics(:first)) - - topics = Topic.find_all_by_approved(true) - assert_equal 3, topics.size - assert topics.include?(topics(:second)) - end - - def test_find_by_nil_attribute - topic = Topic.find_by_last_read nil - assert_not_nil topic - assert_nil topic.last_read - end - - def test_find_all_by_nil_attribute - topics = Topic.find_all_by_last_read nil - assert_equal 3, topics.size - assert topics.collect(&:last_read).all?(&:nil?) - end - - def test_find_by_nil_and_not_nil_attributes - topic = Topic.find_by_last_read_and_author_name nil, "Mary" - assert_equal "Mary", topic.author_name - end - - def test_find_all_by_nil_and_not_nil_attributes - topics = Topic.find_all_by_last_read_and_author_name nil, "Mary" - assert_equal 1, topics.size - assert_equal "Mary", topics[0].author_name - end - - def test_find_or_create_from_one_attribute - number_of_companies = Company.count - sig38 = Company.find_or_create_by_name("38signals") - assert_equal number_of_companies + 1, Company.count - assert_equal sig38, Company.find_or_create_by_name("38signals") - assert !sig38.new_record? - end - - def test_find_or_create_from_two_attributes - number_of_topics = Topic.count - another = Topic.find_or_create_by_title_and_author_name("Another topic","John") - assert_equal number_of_topics + 1, Topic.count - assert_equal another, Topic.find_or_create_by_title_and_author_name("Another topic", "John") - assert !another.new_record? - end - - def test_find_or_create_from_two_attributes_with_one_being_an_aggregate - number_of_customers = Customer.count - created_customer = Customer.find_or_create_by_balance_and_name(Money.new(123), "Elizabeth") - assert_equal number_of_customers + 1, Customer.count - assert_equal created_customer, Customer.find_or_create_by_balance(Money.new(123), "Elizabeth") - assert !created_customer.new_record? - end - - def test_find_or_create_from_one_attribute_and_hash - number_of_companies = Company.count - sig38 = Company.find_or_create_by_name({:name => "38signals", :firm_id => 17, :client_of => 23}) - assert_equal number_of_companies + 1, Company.count - assert_equal sig38, Company.find_or_create_by_name({:name => "38signals", :firm_id => 17, :client_of => 23}) - assert !sig38.new_record? - assert_equal "38signals", sig38.name - assert_equal 17, sig38.firm_id - assert_equal 23, sig38.client_of - end - - def test_find_or_create_from_one_aggregate_attribute - number_of_customers = Customer.count - created_customer = Customer.find_or_create_by_balance(Money.new(123)) - assert_equal number_of_customers + 1, Customer.count - assert_equal created_customer, Customer.find_or_create_by_balance(Money.new(123)) - assert !created_customer.new_record? - end - - def test_find_or_create_from_one_aggregate_attribute_and_hash - number_of_customers = Customer.count - balance = Money.new(123) - name = "Elizabeth" - created_customer = Customer.find_or_create_by_balance({:balance => balance, :name => name}) - assert_equal number_of_customers + 1, Customer.count - assert_equal created_customer, Customer.find_or_create_by_balance({:balance => balance, :name => name}) - assert !created_customer.new_record? - assert_equal balance, created_customer.balance - assert_equal name, created_customer.name - end - - def test_find_or_initialize_from_one_attribute - sig38 = Company.find_or_initialize_by_name("38signals") - assert_equal "38signals", sig38.name - assert sig38.new_record? - end - - def test_find_or_initialize_from_one_aggregate_attribute - new_customer = Customer.find_or_initialize_by_balance(Money.new(123)) - assert_equal 123, new_customer.balance.amount - assert new_customer.new_record? - end - - def test_find_or_initialize_from_one_attribute_should_not_set_attribute_even_when_protected - c = Company.find_or_initialize_by_name({:name => "Fortune 1000", :rating => 1000}) - assert_equal "Fortune 1000", c.name - assert_not_equal 1000, c.rating - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_from_one_attribute_should_not_set_attribute_even_when_protected - c = Company.find_or_create_by_name({:name => "Fortune 1000", :rating => 1000}) - assert_equal "Fortune 1000", c.name - assert_not_equal 1000, c.rating - assert c.valid? - assert !c.new_record? - end - - def test_find_or_initialize_from_one_attribute_should_set_attribute_even_when_protected_and_also_set_the_hash - c = Company.find_or_initialize_by_rating(1000, {:name => "Fortune 1000"}) - assert_equal "Fortune 1000", c.name - assert_equal 1000, c.rating - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_from_one_attribute_should_set_attribute_even_when_protected_and_also_set_the_hash - c = Company.find_or_create_by_rating(1000, {:name => "Fortune 1000"}) - assert_equal "Fortune 1000", c.name - assert_equal 1000, c.rating - assert c.valid? - assert !c.new_record? - end - - def test_find_or_initialize_from_one_attribute_should_set_attribute_even_when_protected - c = Company.find_or_initialize_by_name_and_rating("Fortune 1000", 1000) - assert_equal "Fortune 1000", c.name - assert_equal 1000, c.rating - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_from_one_attribute_should_set_attribute_even_when_protected - c = Company.find_or_create_by_name_and_rating("Fortune 1000", 1000) - assert_equal "Fortune 1000", c.name - assert_equal 1000, c.rating - assert c.valid? - assert !c.new_record? - end - - def test_find_or_initialize_should_set_protected_attributes_if_given_as_block - c = Company.find_or_initialize_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 } - assert_equal "Fortune 1000", c.name - assert_equal 1000.to_f, c.rating.to_f - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_should_set_protected_attributes_if_given_as_block - c = Company.find_or_create_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 } - assert_equal "Fortune 1000", c.name - assert_equal 1000.to_f, c.rating.to_f - assert c.valid? - assert !c.new_record? - end - - def test_find_or_create_should_work_with_block_on_first_call - class << Company - undef_method(:find_or_create_by_name) if method_defined?(:find_or_create_by_name) - end - c = Company.find_or_create_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 } - assert_equal "Fortune 1000", c.name - assert_equal 1000.to_f, c.rating.to_f - assert c.valid? - assert !c.new_record? - end - - def test_dynamic_find_or_initialize_from_one_attribute_caches_method - class << Company; self; end.send(:remove_method, :find_or_initialize_by_name) if Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' } - assert !Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' } - sig38 = Company.find_or_initialize_by_name("38signals") - assert Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' } - end - - def test_find_or_initialize_from_two_attributes - another = Topic.find_or_initialize_by_title_and_author_name("Another topic","John") - assert_equal "Another topic", another.title - assert_equal "John", another.author_name - assert another.new_record? - end - - def test_find_or_initialize_from_one_aggregate_attribute_and_one_not - new_customer = Customer.find_or_initialize_by_balance_and_name(Money.new(123), "Elizabeth") - assert_equal 123, new_customer.balance.amount - assert_equal "Elizabeth", new_customer.name - assert new_customer.new_record? - end - - def test_find_or_initialize_from_one_attribute_and_hash - sig38 = Company.find_or_initialize_by_name({:name => "38signals", :firm_id => 17, :client_of => 23}) - assert_equal "38signals", sig38.name - assert_equal 17, sig38.firm_id - assert_equal 23, sig38.client_of - assert sig38.new_record? - end - - def test_find_or_initialize_from_one_aggregate_attribute_and_hash - balance = Money.new(123) - name = "Elizabeth" - new_customer = Customer.find_or_initialize_by_balance({:balance => balance, :name => name}) - assert_equal balance, new_customer.balance - assert_equal name, new_customer.name - assert new_customer.new_record? - end - - def test_find_with_bad_sql - assert_raise(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" } - end - - def test_find_with_invalid_params - assert_raise(ArgumentError) { Topic.find :first, :join => "It should be `joins'" } - assert_raise(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" } - end - - def test_dynamic_finder_with_invalid_params - assert_raise(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" } - end - - def test_find_all_with_join - developers_on_project_one = Developer.find( - :all, - :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id', - :conditions => 'project_id=1' - ) - assert_equal 3, developers_on_project_one.length - developer_names = developers_on_project_one.map { |d| d.name } - assert developer_names.include?('David') - assert developer_names.include?('Jamis') - end - - def test_joins_dont_clobber_id - first = Firm.find( - :first, - :joins => 'INNER JOIN companies AS clients ON clients.firm_id = companies.id', - :conditions => 'companies.id = 1' - ) - assert_equal 1, first.id - end - - def test_joins_with_string_array - person_with_reader_and_post = Post.find( - :all, - :joins => [ - "INNER JOIN categorizations ON categorizations.post_id = posts.id", - "INNER JOIN categories ON categories.id = categorizations.category_id AND categories.type = 'SpecialCategory'" - ] - ) - assert_equal 1, person_with_reader_and_post.size - end - - def test_find_by_id_with_conditions_with_or - assert_nothing_raised do - Post.find([1,2,3], - :conditions => "posts.id <= 3 OR posts.#{QUOTED_TYPE} = 'Post'") - end - end - - # http://dev.rubyonrails.org/ticket/6778 - def test_find_ignores_previously_inserted_record - post = Post.create!(:title => 'test', :body => 'it out') - assert_equal [], Post.find_all_by_id(nil) - end - - def test_find_by_empty_ids - assert_equal [], Post.find([]) - end - - def test_find_by_empty_in_condition - assert_equal [], Post.find(:all, :conditions => ['id in (?)', []]) - end - - def test_find_by_records - p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2]], :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2.id]], :order => 'id asc') - end - - def test_select_value - assert_equal "37signals", Company.connection.select_value("SELECT name FROM companies WHERE id = 1") - assert_nil Company.connection.select_value("SELECT name FROM companies WHERE id = -1") - # make sure we didn't break count... - assert_equal 0, Company.count_by_sql("SELECT COUNT(*) FROM companies WHERE name = 'Halliburton'") - assert_equal 1, Company.count_by_sql("SELECT COUNT(*) FROM companies WHERE name = '37signals'") - end - - def test_select_values - assert_equal ["1","2","3","4","5","6","7","8","9"], Company.connection.select_values("SELECT id FROM companies ORDER BY id").map! { |i| i.to_s } - assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel", "Odegy"], Company.connection.select_values("SELECT name FROM companies ORDER BY id") - end - - def test_select_rows - assert_equal( - [["1", nil, nil, "37signals"], - ["2", "1", "2", "Summit"], - ["3", "1", "1", "Microsoft"]], - Company.connection.select_rows("SELECT id, firm_id, client_of, name FROM companies WHERE id IN (1,2,3) ORDER BY id").map! {|i| i.map! {|j| j.to_s unless j.nil?}}) - assert_equal [["1", "37signals"], ["2", "Summit"], ["3", "Microsoft"]], - Company.connection.select_rows("SELECT id, name FROM companies WHERE id IN (1,2,3) ORDER BY id").map! {|i| i.map! {|j| j.to_s unless j.nil?}} - end - - def test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct - assert_equal 2, Post.find(:all, :include => { :authors => :author_address }, :order => ' author_addresses.id DESC ', :limit => 2).size - - assert_equal 3, Post.find(:all, :include => { :author => :author_address, :authors => :author_address}, - :order => ' author_addresses_authors.id DESC ', :limit => 3).size - end - - def test_with_limiting_with_custom_select - posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3, :order => 'posts.id') - assert_equal 3, posts.size - assert_equal [0, 1, 1], posts.map(&:author_id).sort - end - - def test_finder_with_scoped_from - all_topics = Topic.all - - Topic.with_scope(:find => { :from => 'fake_topics' }) do - assert_equal all_topics, Topic.all(:from => 'topics') - end - end - - protected - def bind(statement, *vars) - if vars.first.is_a?(Hash) - ActiveRecord::Base.send(:replace_named_bind_variables, statement, vars.first) - else - ActiveRecord::Base.send(:replace_bind_variables, statement, vars) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/fixtures_test.rb b/vendor/rails/activerecord/test/cases/fixtures_test.rb deleted file mode 100644 index e9c28023..00000000 --- a/vendor/rails/activerecord/test/cases/fixtures_test.rb +++ /dev/null @@ -1,661 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/binary' -require 'models/topic' -require 'models/computer' -require 'models/developer' -require 'models/company' -require 'models/task' -require 'models/reply' -require 'models/joke' -require 'models/course' -require 'models/category' -require 'models/parrot' -require 'models/pirate' -require 'models/treasure' -require 'models/matey' -require 'models/ship' -require 'models/book' - -class FixturesTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = true - self.use_transactional_fixtures = false - - fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries - - FIXTURES = %w( accounts binaries companies customers - developers developers_projects entrants - movies projects subscribers topics tasks ) - MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/ - - def test_clean_fixtures - FIXTURES.each do |name| - fixtures = nil - assert_nothing_raised { fixtures = create_fixtures(name) } - assert_kind_of(Fixtures, fixtures) - fixtures.each { |name, fixture| - fixture.each { |key, value| - assert_match(MATCH_ATTRIBUTE_NAME, key) - } - } - end - end - - def test_multiple_clean_fixtures - fixtures_array = nil - assert_nothing_raised { fixtures_array = create_fixtures(*FIXTURES) } - assert_kind_of(Array, fixtures_array) - fixtures_array.each { |fixtures| assert_kind_of(Fixtures, fixtures) } - end - - def test_attributes - topics = create_fixtures("topics") - assert_equal("The First Topic", topics["first"]["title"]) - assert_nil(topics["second"]["author_email_address"]) - end - - def test_inserts - topics = create_fixtures("topics") - first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'") - assert_equal("The First Topic", first_row["title"]) - - second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'") - assert_nil(second_row["author_email_address"]) - end - - if ActiveRecord::Base.connection.supports_migrations? - def test_inserts_with_pre_and_suffix - # Reset cache to make finds on the new table work - Fixtures.reset_cache - - ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t| - t.column :title, :string - t.column :author_name, :string - t.column :author_email_address, :string - t.column :written_on, :datetime - t.column :bonus_time, :time - t.column :last_read, :date - t.column :content, :string - t.column :approved, :boolean, :default => true - t.column :replies_count, :integer, :default => 0 - t.column :parent_id, :integer - t.column :type, :string, :limit => 50 - end - - # Store existing prefix/suffix - old_prefix = ActiveRecord::Base.table_name_prefix - old_suffix = ActiveRecord::Base.table_name_suffix - - # Set a prefix/suffix we can test against - ActiveRecord::Base.table_name_prefix = 'prefix_' - ActiveRecord::Base.table_name_suffix = '_suffix' - - topics = create_fixtures("topics") - - first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'") - assert_equal("The First Topic", first_row["title"]) - - second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'") - assert_nil(second_row["author_email_address"]) - - # This checks for a caching problem which causes a bug in the fixtures - # class-level configuration helper. - assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create" - ensure - # Restore prefix/suffix to its previous values - ActiveRecord::Base.table_name_prefix = old_prefix - ActiveRecord::Base.table_name_suffix = old_suffix - - ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil - end - end - - def test_insert_with_datetime - topics = create_fixtures("tasks") - first = Task.find(1) - assert first - end - - def test_logger_level_invariant - level = ActiveRecord::Base.logger.level - create_fixtures('topics') - assert_equal level, ActiveRecord::Base.logger.level - end - - def test_instantiation - topics = create_fixtures("topics") - assert_kind_of Topic, topics["first"].find - end - - def test_complete_instantiation - assert_equal 4, @topics.size - assert_equal "The First Topic", @first.title - end - - def test_fixtures_from_root_yml_with_instantiation - # assert_equal 2, @accounts.size - assert_equal 50, @unknown.credit_limit - end - - def test_erb_in_fixtures - assert_equal 11, @developers.size - assert_equal "fixture_5", @dev_5.name - end - - def test_empty_yaml_fixture - assert_not_nil Fixtures.new( Account.connection, "accounts", 'Account', FIXTURES_ROOT + "/naked/yml/accounts") - end - - def test_empty_yaml_fixture_with_a_comment_in_it - assert_not_nil Fixtures.new( Account.connection, "companies", 'Company', FIXTURES_ROOT + "/naked/yml/companies") - end - - def test_dirty_dirty_yaml_file - assert_raise(Fixture::FormatError) do - Fixtures.new( Account.connection, "courses", 'Course', FIXTURES_ROOT + "/naked/yml/courses") - end - end - - def test_empty_csv_fixtures - assert_not_nil Fixtures.new( Account.connection, "accounts", 'Account', FIXTURES_ROOT + "/naked/csv/accounts") - end - - def test_omap_fixtures - assert_nothing_raised do - fixtures = Fixtures.new(Account.connection, 'categories', 'Category', FIXTURES_ROOT + "/categories_ordered") - - i = 0 - fixtures.each do |name, fixture| - assert_equal "fixture_no_#{i}", name - assert_equal "Category #{i}", fixture['name'] - i += 1 - end - end - end - - def test_yml_file_in_subdirectory - assert_equal(categories(:sub_special_1).name, "A special category in a subdir file") - assert_equal(categories(:sub_special_1).class, SpecialCategory) - end - - def test_subsubdir_file_with_arbitrary_name - assert_equal(categories(:sub_special_3).name, "A special category in an arbitrarily named subsubdir file") - assert_equal(categories(:sub_special_3).class, SpecialCategory) - end - - def test_binary_in_fixtures - assert_equal 1, @binaries.size - data = File.open(ASSETS_ROOT + "/flowers.jpg", 'rb') { |f| f.read } - data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) - data.freeze - assert_equal data, @flowers.data - end -end - -if Account.connection.respond_to?(:reset_pk_sequence!) - class FixturesResetPkSequenceTest < ActiveRecord::TestCase - fixtures :accounts - fixtures :companies - - def setup - @instances = [Account.new(:credit_limit => 50), Company.new(:name => 'RoR Consulting')] - Fixtures.reset_cache # make sure tables get reinitialized - end - - def test_resets_to_min_pk_with_specified_pk_and_sequence - @instances.each do |instance| - model = instance.class - model.delete_all - model.connection.reset_pk_sequence!(model.table_name, model.primary_key, model.sequence_name) - - instance.save! - assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed." - end - end - - def test_resets_to_min_pk_with_default_pk_and_sequence - @instances.each do |instance| - model = instance.class - model.delete_all - model.connection.reset_pk_sequence!(model.table_name) - - instance.save! - assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed." - end - end - - def test_create_fixtures_resets_sequences_when_not_cached - @instances.each do |instance| - max_id = create_fixtures(instance.class.table_name).inject(0) do |max_id, (name, fixture)| - fixture_id = fixture['id'].to_i - fixture_id > max_id ? fixture_id : max_id - end - - # Clone the last fixture to check that it gets the next greatest id. - instance.save! - assert_equal max_id + 1, instance.id, "Sequence reset for #{instance.class.table_name} failed." - end - end - end -end - -class FixturesWithoutInstantiationTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = false - fixtures :topics, :developers, :accounts - - def test_without_complete_instantiation - assert_nil @first - assert_nil @topics - assert_nil @developers - assert_nil @accounts - end - - def test_fixtures_from_root_yml_without_instantiation - assert_nil @unknown - end - - def test_visibility_of_accessor_method - assert_equal false, respond_to?(:topics, false), "should be private method" - assert_equal true, respond_to?(:topics, true), "confirm to respond surely" - end - - def test_accessor_methods - assert_equal "The First Topic", topics(:first).title - assert_equal "Jamis", developers(:jamis).name - assert_equal 50, accounts(:signals37).credit_limit - end - - def test_accessor_methods_with_multiple_args - assert_equal 2, topics(:first, :second).size - assert_raise(StandardError) { topics([:first, :second]) } - end - - def test_reloading_fixtures_through_accessor_methods - assert_equal "The First Topic", topics(:first).title - @loaded_fixtures['topics']['first'].expects(:find).returns(stub(:title => "Fresh Topic!")) - assert_equal "Fresh Topic!", topics(:first, true).title - end -end - -class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = true - self.use_instantiated_fixtures = :no_instances - - fixtures :topics, :developers, :accounts - - def test_without_instance_instantiation - assert_nil @first - assert_not_nil @topics - assert_not_nil @developers - assert_not_nil @accounts - end -end - -class TransactionalFixturesTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = true - self.use_transactional_fixtures = true - - fixtures :topics - - def test_destroy - assert_not_nil @first - @first.destroy - end - - def test_destroy_just_kidding - assert_not_nil @first - end -end - -class MultipleFixturesTest < ActiveRecord::TestCase - fixtures :topics - fixtures :developers, :accounts - - def test_fixture_table_names - assert_equal %w(topics developers accounts), fixture_table_names - end -end - -class SetupTest < ActiveRecord::TestCase - # fixtures :topics - - def setup - @first = true - end - - def test_nothing - end -end - -class SetupSubclassTest < SetupTest - def setup - super - @second = true - end - - def test_subclassing_should_preserve_setups - assert @first - assert @second - end -end - - -class OverlappingFixturesTest < ActiveRecord::TestCase - fixtures :topics, :developers - fixtures :developers, :accounts - - def test_fixture_table_names - assert_equal %w(topics developers accounts), fixture_table_names - end -end - -class ForeignKeyFixturesTest < ActiveRecord::TestCase - fixtures :fk_test_has_pk, :fk_test_has_fk - - # if foreign keys are implemented and fixtures - # are not deleted in reverse order then this test - # case will raise StatementInvalid - - def test_number1 - assert true - end - - def test_number2 - assert true - end -end - -class CheckSetTableNameFixturesTest < ActiveRecord::TestCase - set_fixture_class :funny_jokes => 'Joke' - fixtures :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_table_method - assert_kind_of Joke, funny_jokes(:a_joke) - end -end - -class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase - set_fixture_class :items => Book - fixtures :items - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_named_accessor - assert_kind_of Book, items(:dvd) - end -end - -class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase - set_fixture_class :items => Book, :funny_jokes => Joke - fixtures :items, :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_named_accessor_of_differently_named_fixture - assert_kind_of Book, items(:dvd) - end - - def test_named_accessor_of_same_named_fixture - assert_kind_of Joke, funny_jokes(:a_joke) - end -end - -class CustomConnectionFixturesTest < ActiveRecord::TestCase - set_fixture_class :courses => Course - fixtures :courses - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_connection - assert_kind_of Course, courses(:ruby) - assert_equal Course.connection, courses(:ruby).connection - end -end - -class InvalidTableNameFixturesTest < ActiveRecord::TestCase - fixtures :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our lack of set_fixture_class - self.use_transactional_fixtures = false - - def test_raises_error - assert_raise FixtureClassNotFound do - funny_jokes(:a_joke) - end - end -end - -class CheckEscapedYamlFixturesTest < ActiveRecord::TestCase - set_fixture_class :funny_jokes => 'Joke' - fixtures :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_proper_escaped_fixture - assert_equal "The \\n Aristocrats\nAte the candy\n", funny_jokes(:another_joke).name - end -end - -class DevelopersProject; end -class ManyToManyFixturesWithClassDefined < ActiveRecord::TestCase - fixtures :developers_projects - - def test_this_should_run_cleanly - assert true - end -end - -class FixturesBrokenRollbackTest < ActiveRecord::TestCase - def blank_setup; end - alias_method :ar_setup_fixtures, :setup_fixtures - alias_method :setup_fixtures, :blank_setup - alias_method :setup, :blank_setup - - def blank_teardown; end - alias_method :ar_teardown_fixtures, :teardown_fixtures - alias_method :teardown_fixtures, :blank_teardown - alias_method :teardown, :blank_teardown - - def test_no_rollback_in_teardown_unless_transaction_active - assert_equal 0, ActiveRecord::Base.connection.open_transactions - assert_raise(RuntimeError) { ar_setup_fixtures } - assert_equal 0, ActiveRecord::Base.connection.open_transactions - assert_nothing_raised { ar_teardown_fixtures } - assert_equal 0, ActiveRecord::Base.connection.open_transactions - end - - private - def load_fixtures - raise 'argh' - end -end - -class LoadAllFixturesTest < ActiveRecord::TestCase - self.fixture_path = FIXTURES_ROOT + "/all" - fixtures :all - - def test_all_there - assert_equal %w(developers people tasks), fixture_table_names.sort - end -end - -class FasterFixturesTest < ActiveRecord::TestCase - fixtures :categories, :authors - - def load_extra_fixture(name) - fixture = create_fixtures(name) - assert fixture.is_a?(Fixtures) - @loaded_fixtures[fixture.table_name] = fixture - end - - def test_cache - assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'categories') - assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'authors') - - assert_no_queries do - create_fixtures('categories') - create_fixtures('authors') - end - - load_extra_fixture('posts') - assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'posts') - self.class.setup_fixture_accessors('posts') - assert_equal 'Welcome to the weblog', posts(:welcome).title - end -end - -class FoxyFixturesTest < ActiveRecord::TestCase - fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers - - def test_identifies_strings - assert_equal(Fixtures.identify("foo"), Fixtures.identify("foo")) - assert_not_equal(Fixtures.identify("foo"), Fixtures.identify("FOO")) - end - - def test_identifies_symbols - assert_equal(Fixtures.identify(:foo), Fixtures.identify(:foo)) - end - - def test_identifies_consistently - assert_equal 207281424, Fixtures.identify(:ruby) - assert_equal 1066363776, Fixtures.identify(:sapphire_2) - end - - TIMESTAMP_COLUMNS = %w(created_at created_on updated_at updated_on) - - def test_populates_timestamp_columns - TIMESTAMP_COLUMNS.each do |property| - assert_not_nil(parrots(:george).send(property), "should set #{property}") - end - end - - def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false - TIMESTAMP_COLUMNS.each do |property| - assert_nil(ships(:black_pearl).send(property), "should not set #{property}") - end - end - - def test_populates_all_columns_with_the_same_time - last = nil - - TIMESTAMP_COLUMNS.each do |property| - current = parrots(:george).send(property) - last ||= current - - assert_equal(last, current) - last = current - end - end - - def test_only_populates_columns_that_exist - assert_not_nil(pirates(:blackbeard).created_on) - assert_not_nil(pirates(:blackbeard).updated_on) - end - - def test_preserves_existing_fixture_data - assert_equal(2.weeks.ago.to_date, pirates(:redbeard).created_on.to_date) - assert_equal(2.weeks.ago.to_date, pirates(:redbeard).updated_on.to_date) - end - - def test_generates_unique_ids - assert_not_nil(parrots(:george).id) - assert_not_equal(parrots(:george).id, parrots(:louis).id) - end - - def test_automatically_sets_primary_key - assert_not_nil(ships(:black_pearl)) - end - - def test_preserves_existing_primary_key - assert_equal(2, ships(:interceptor).id) - end - - def test_resolves_belongs_to_symbols - assert_equal(parrots(:george), pirates(:blackbeard).parrot) - end - - def test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same - assert_equal(developers(:david), computers(:workstation).developer) - end - - def test_supports_join_tables - assert(pirates(:blackbeard).parrots.include?(parrots(:george))) - assert(pirates(:blackbeard).parrots.include?(parrots(:louis))) - assert(parrots(:george).pirates.include?(pirates(:blackbeard))) - end - - def test_supports_inline_habtm - assert(parrots(:george).treasures.include?(treasures(:diamond))) - assert(parrots(:george).treasures.include?(treasures(:sapphire))) - assert(!parrots(:george).treasures.include?(treasures(:ruby))) - end - - def test_supports_inline_habtm_with_specified_id - assert(parrots(:polly).treasures.include?(treasures(:ruby))) - assert(parrots(:polly).treasures.include?(treasures(:sapphire))) - assert(!parrots(:polly).treasures.include?(treasures(:diamond))) - end - - def test_supports_yaml_arrays - assert(parrots(:louis).treasures.include?(treasures(:diamond))) - assert(parrots(:louis).treasures.include?(treasures(:sapphire))) - end - - def test_strips_DEFAULTS_key - assert_raise(StandardError) { parrots(:DEFAULTS) } - - # this lets us do YAML defaults and not have an extra fixture entry - %w(sapphire ruby).each { |t| assert(parrots(:davey).treasures.include?(treasures(t))) } - end - - def test_supports_label_interpolation - assert_equal("frederick", parrots(:frederick).name) - end - - def test_supports_polymorphic_belongs_to - assert_equal(pirates(:redbeard), treasures(:sapphire).looter) - assert_equal(parrots(:louis), treasures(:ruby).looter) - end - - def test_only_generates_a_pk_if_necessary - m = Matey.find(:first) - m.pirate = pirates(:blackbeard) - m.target = pirates(:redbeard) - end - - def test_supports_sti - assert_kind_of DeadParrot, parrots(:polly) - assert_equal pirates(:blackbeard), parrots(:polly).killer - end -end - -class ActiveSupportSubclassWithFixturesTest < ActiveRecord::TestCase - fixtures :parrots - - # This seemingly useless assertion catches a bug that caused the fixtures - # setup code call nil[] - def test_foo - assert_equal parrots(:louis), Parrot.find_by_name("King Louis") - end -end - -class FixtureLoadingTest < ActiveRecord::TestCase - def test_logs_message_for_failed_dependency_load - ActiveRecord::TestCase.expects(:require_dependency).with(:does_not_exist).raises(LoadError) - ActiveRecord::Base.logger.expects(:warn) - ActiveRecord::TestCase.try_to_load_dependency(:does_not_exist) - end - - def test_does_not_logs_message_for_successful_dependency_load - ActiveRecord::TestCase.expects(:require_dependency).with(:works_out_fine) - ActiveRecord::Base.logger.expects(:warn).never - ActiveRecord::TestCase.try_to_load_dependency(:works_out_fine) - end -end diff --git a/vendor/rails/activerecord/test/cases/helper.rb b/vendor/rails/activerecord/test/cases/helper.rb deleted file mode 100644 index 1ef38c99..00000000 --- a/vendor/rails/activerecord/test/cases/helper.rb +++ /dev/null @@ -1,68 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../../lib') -$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') - -require 'config' - -require 'rubygems' -require 'test/unit' -require 'stringio' - -require 'active_record' -require 'active_record/test_case' -require 'active_record/fixtures' -require 'connection' - -require 'cases/repair_helper' - -# Show backtraces for deprecated behavior for quicker cleanup. -ActiveSupport::Deprecation.debug = true - -# Quote "type" if it's a reserved word for the current connection. -QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') - -def current_adapter?(*types) - types.any? do |type| - ActiveRecord::ConnectionAdapters.const_defined?(type) && - ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters.const_get(type)) - end -end - -ActiveRecord::Base.connection.class.class_eval do - IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /SHOW FIELDS/] - - def execute_with_query_record(sql, name = nil, &block) - $queries_executed ||= [] - $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r } - execute_without_query_record(sql, name, &block) - end - - alias_method_chain :execute, :query_record -end - -# Make with_scope public for tests -class << ActiveRecord::Base - public :with_scope, :with_exclusive_scope -end - -unless ENV['FIXTURE_DEBUG'] - module ActiveRecord::TestFixtures::ClassMethods - def try_to_load_dependency_with_silence(*args) - ActiveRecord::Base.logger.silence { try_to_load_dependency_without_silence(*args)} - end - - alias_method_chain :try_to_load_dependency, :silence - end -end - -class ActiveSupport::TestCase - include ActiveRecord::TestFixtures - include ActiveRecord::Testing::RepairHelper - - self.fixture_path = FIXTURES_ROOT - self.use_instantiated_fixtures = false - self.use_transactional_fixtures = true - - def create_fixtures(*table_names, &block) - Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block) - end -end diff --git a/vendor/rails/activerecord/test/cases/i18n_test.rb b/vendor/rails/activerecord/test/cases/i18n_test.rb deleted file mode 100644 index d59c53ce..00000000 --- a/vendor/rails/activerecord/test/cases/i18n_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' - -class ActiveRecordI18nTests < Test::Unit::TestCase - - def setup - I18n.backend = I18n::Backend::Simple.new - end - - def test_translated_model_attributes - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } } - assert_equal 'topic title attribute', Topic.human_attribute_name('title') - end - - def test_translated_model_attributes_with_symbols - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } } - assert_equal 'topic title attribute', Topic.human_attribute_name(:title) - end - - def test_translated_model_attributes_with_sti - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:reply => {:title => 'reply title attribute'} } } - assert_equal 'reply title attribute', Reply.human_attribute_name('title') - end - - def test_translated_model_attributes_with_sti_fallback - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } } - assert_equal 'topic title attribute', Reply.human_attribute_name('title') - end - - def test_translated_model_names - I18n.backend.store_translations 'en', :activerecord => {:models => {:topic => 'topic model'} } - assert_equal 'topic model', Topic.human_name - end - - def test_translated_model_names_with_sti - I18n.backend.store_translations 'en', :activerecord => {:models => {:reply => 'reply model'} } - assert_equal 'reply model', Reply.human_name - end - - def test_translated_model_names_with_sti_fallback - I18n.backend.store_translations 'en', :activerecord => {:models => {:topic => 'topic model'} } - assert_equal 'topic model', Reply.human_name - end -end - diff --git a/vendor/rails/activerecord/test/cases/inheritance_test.rb b/vendor/rails/activerecord/test/cases/inheritance_test.rb deleted file mode 100644 index eae5a608..00000000 --- a/vendor/rails/activerecord/test/cases/inheritance_test.rb +++ /dev/null @@ -1,262 +0,0 @@ -require "cases/helper" -require 'models/company' -require 'models/project' -require 'models/subscriber' - -class InheritanceTest < ActiveRecord::TestCase - fixtures :companies, :projects, :subscribers, :accounts - - def test_class_with_store_full_sti_class_returns_full_name - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - assert_equal 'Namespaced::Company', Namespaced::Company.sti_name - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_class_without_store_full_sti_class_returns_demodulized_name - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = false - assert_equal 'Company', Namespaced::Company.sti_name - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_should_store_demodulized_class_name_with_store_full_sti_class_option_disabled - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = false - item = Namespaced::Company.new - assert_equal 'Company', item[:type] - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_should_store_full_class_name_with_store_full_sti_class_option_enabled - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - item = Namespaced::Company.new - assert_equal 'Namespaced::Company', item[:type] - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_different_namespace_subclass_should_load_correctly_with_store_full_sti_class_option - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - item = Namespaced::Company.create :name => "Wolverine 2" - assert_not_nil Company.find(item.id) - assert_not_nil Namespaced::Company.find(item.id) - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_company_descends_from_active_record - assert_raise(NoMethodError) { ActiveRecord::Base.descends_from_active_record? } - assert AbstractCompany.descends_from_active_record?, 'AbstractCompany should descend from ActiveRecord::Base' - assert Company.descends_from_active_record?, 'Company should descend from ActiveRecord::Base' - assert !Class.new(Company).descends_from_active_record?, 'Company subclass should not descend from ActiveRecord::Base' - end - - def test_a_bad_type_column - #SQLServer need to turn Identity Insert On before manually inserting into the Identity column - if current_adapter?(:SybaseAdapter) - Company.connection.execute "SET IDENTITY_INSERT companies ON" - end - Company.connection.insert "INSERT INTO companies (id, #{QUOTED_TYPE}, name) VALUES(100, 'bad_class!', 'Not happening')" - - #We then need to turn it back Off before continuing. - if current_adapter?(:SybaseAdapter) - Company.connection.execute "SET IDENTITY_INSERT companies OFF" - end - assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) } - end - - def test_inheritance_find - assert Company.find(1).kind_of?(Firm), "37signals should be a firm" - assert Firm.find(1).kind_of?(Firm), "37signals should be a firm" - assert Company.find(2).kind_of?(Client), "Summit should be a client" - assert Client.find(2).kind_of?(Client), "Summit should be a client" - end - - def test_alt_inheritance_find - switch_to_alt_inheritance_column - test_inheritance_find - switch_to_default_inheritance_column - end - - def test_inheritance_find_all - companies = Company.find(:all, :order => 'id') - assert companies[0].kind_of?(Firm), "37signals should be a firm" - assert companies[1].kind_of?(Client), "Summit should be a client" - end - - def test_alt_inheritance_find_all - switch_to_alt_inheritance_column - test_inheritance_find_all - switch_to_default_inheritance_column - end - - def test_inheritance_save - firm = Firm.new - firm.name = "Next Angle" - firm.save - - next_angle = Company.find(firm.id) - assert next_angle.kind_of?(Firm), "Next Angle should be a firm" - end - - def test_alt_inheritance_save - switch_to_alt_inheritance_column - test_inheritance_save - switch_to_default_inheritance_column - end - - def test_inheritance_condition - assert_equal 9, Company.count - assert_equal 2, Firm.count - assert_equal 3, Client.count - end - - def test_alt_inheritance_condition - switch_to_alt_inheritance_column - test_inheritance_condition - switch_to_default_inheritance_column - end - - def test_finding_incorrect_type_data - assert_raise(ActiveRecord::RecordNotFound) { Firm.find(2) } - assert_nothing_raised { Firm.find(1) } - end - - def test_alt_finding_incorrect_type_data - switch_to_alt_inheritance_column - test_finding_incorrect_type_data - switch_to_default_inheritance_column - end - - def test_update_all_within_inheritance - Client.update_all "name = 'I am a client'" - assert_equal "I am a client", Client.find(:all).first.name - assert_equal "37signals", Firm.find(:all).first.name - end - - def test_alt_update_all_within_inheritance - switch_to_alt_inheritance_column - test_update_all_within_inheritance - switch_to_default_inheritance_column - end - - def test_destroy_all_within_inheritance - Client.destroy_all - assert_equal 0, Client.count - assert_equal 2, Firm.count - end - - def test_alt_destroy_all_within_inheritance - switch_to_alt_inheritance_column - test_destroy_all_within_inheritance - switch_to_default_inheritance_column - end - - def test_find_first_within_inheritance - assert_kind_of Firm, Company.find(:first, :conditions => "name = '37signals'") - assert_kind_of Firm, Firm.find(:first, :conditions => "name = '37signals'") - assert_nil Client.find(:first, :conditions => "name = '37signals'") - end - - def test_alt_find_first_within_inheritance - switch_to_alt_inheritance_column - test_find_first_within_inheritance - switch_to_default_inheritance_column - end - - def test_complex_inheritance - very_special_client = VerySpecialClient.create("name" => "veryspecial") - assert_equal very_special_client, VerySpecialClient.find(:first, :conditions => "name = 'veryspecial'") - assert_equal very_special_client, SpecialClient.find(:first, :conditions => "name = 'veryspecial'") - assert_equal very_special_client, Company.find(:first, :conditions => "name = 'veryspecial'") - assert_equal very_special_client, Client.find(:first, :conditions => "name = 'veryspecial'") - assert_equal 1, Client.find(:all, :conditions => "name = 'Summit'").size - assert_equal very_special_client, Client.find(very_special_client.id) - end - - def test_alt_complex_inheritance - switch_to_alt_inheritance_column - test_complex_inheritance - switch_to_default_inheritance_column - end - - def test_eager_load_belongs_to_something_inherited - account = Account.find(1, :include => :firm) - assert_not_nil account.instance_variable_get("@firm"), "nil proves eager load failed" - end - - def test_eager_load_belongs_to_primary_key_quoting - con = Account.connection - assert_sql(/\(#{con.quote_table_name('companies')}.#{con.quote_column_name('id')} = 1\)/) do - Account.find(1, :include => :firm) - end - end - - def test_alt_eager_loading - switch_to_alt_inheritance_column - test_eager_load_belongs_to_something_inherited - switch_to_default_inheritance_column - end - - def test_inheritance_without_mapping - assert_kind_of SpecialSubscriber, SpecialSubscriber.find("webster132") - assert_nothing_raised { s = SpecialSubscriber.new("name" => "And breaaaaathe!"); s.id = 'roger'; s.save } - end - - private - def switch_to_alt_inheritance_column - # we don't want misleading test results, so get rid of the values in the type column - Company.find(:all, :order => 'id').each do |c| - c['type'] = nil - c.save - end - [ Company, Firm, Client].each { |klass| klass.reset_column_information } - Company.set_inheritance_column('ruby_type') - end - def switch_to_default_inheritance_column - [ Company, Firm, Client].each { |klass| klass.reset_column_information } - Company.set_inheritance_column('type') - end -end - - -class InheritanceComputeTypeTest < ActiveRecord::TestCase - fixtures :companies - - def setup - ActiveSupport::Dependencies.log_activity = true - end - - def teardown - ActiveSupport::Dependencies.log_activity = false - self.class.const_remove :FirmOnTheFly rescue nil - Firm.const_remove :FirmOnTheFly rescue nil - end - - def test_instantiation_doesnt_try_to_require_corresponding_file - foo = Firm.find(:first).clone - foo.ruby_type = foo.type = 'FirmOnTheFly' - foo.save! - - # Should fail without FirmOnTheFly in the type condition. - assert_raise(ActiveRecord::RecordNotFound) { Firm.find(foo.id) } - - # Nest FirmOnTheFly in the test case where Dependencies won't see it. - self.class.const_set :FirmOnTheFly, Class.new(Firm) - assert_raise(ActiveRecord::SubclassNotFound) { Firm.find(foo.id) } - - # Nest FirmOnTheFly in Firm where Dependencies will see it. - # This is analogous to nesting models in a migration. - Firm.const_set :FirmOnTheFly, Class.new(Firm) - - # And instantiate will find the existing constant rather than trying - # to require firm_on_the_fly. - assert_nothing_raised { assert_kind_of Firm::FirmOnTheFly, Firm.find(foo.id) } - end -end diff --git a/vendor/rails/activerecord/test/cases/invalid_date_test.rb b/vendor/rails/activerecord/test/cases/invalid_date_test.rb deleted file mode 100644 index e2bb17c3..00000000 --- a/vendor/rails/activerecord/test/cases/invalid_date_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'cases/helper' -require 'models/topic' - -class InvalidDateTest < Test::Unit::TestCase - def test_assign_valid_dates - valid_dates = [[2007, 11, 30], [1993, 2, 28], [2008, 2, 29]] - - invalid_dates = [[2007, 11, 31], [1993, 2, 29], [2007, 2, 29]] - - topic = Topic.new - - valid_dates.each do |date_src| - topic = Topic.new("last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s) - assert_equal(topic.last_read, Date.new(*date_src)) - end - - invalid_dates.each do |date_src| - assert_nothing_raised do - topic = Topic.new({"last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s}) - assert_equal(topic.last_read, Time.local(*date_src).to_date, "The date should be modified according to the behaviour of the Time object") - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/json_serialization_test.rb b/vendor/rails/activerecord/test/cases/json_serialization_test.rb deleted file mode 100644 index 7f13e493..00000000 --- a/vendor/rails/activerecord/test/cases/json_serialization_test.rb +++ /dev/null @@ -1,219 +0,0 @@ -require "cases/helper" -require 'models/contact' -require 'models/post' -require 'models/author' -require 'models/tagging' -require 'models/tag' -require 'models/comment' - -class JsonSerializationTest < ActiveRecord::TestCase - class NamespacedContact < Contact - column :name, :string - end - - def setup - @contact = Contact.new( - :name => 'Konata Izumi', - :age => 16, - :avatar => 'binarydata', - :created_at => Time.utc(2006, 8, 1), - :awesome => true, - :preferences => { :shows => 'anime' } - ) - end - - def test_should_demodulize_root_in_json - NamespacedContact.include_root_in_json = true - @contact = NamespacedContact.new :name => 'whatever' - json = @contact.to_json - assert_match %r{^\{"namespaced_contact":\{}, json - end - - def test_should_include_root_in_json - Contact.include_root_in_json = true - json = @contact.to_json - - assert_match %r{^\{"contact":\{}, json - assert_match %r{"name":"Konata Izumi"}, json - assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"awesome":true}, json - assert_match %r{"preferences":\{"shows":"anime"\}}, json - ensure - Contact.include_root_in_json = false - end - - def test_should_include_root_in_json - Contact.include_root_in_json = true - json = @contact.to_json(:root => 'json_contact') - - assert_match %r{^\{"json_contact":\{}, json - assert_match %r{"name":"Konata Izumi"}, json - assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"awesome":true}, json - assert_match %r{"preferences":\{"shows":"anime"\}}, json - ensure - Contact.include_root_in_json = false - end - - def test_should_encode_all_encodable_attributes - json = @contact.to_json - - assert_match %r{"name":"Konata Izumi"}, json - assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"awesome":true}, json - assert_match %r{"preferences":\{"shows":"anime"\}}, json - end - - def test_should_allow_attribute_filtering_with_only - json = @contact.to_json(:only => [:name, :age]) - - assert_match %r{"name":"Konata Izumi"}, json - assert_match %r{"age":16}, json - assert_no_match %r{"awesome":true}, json - assert !json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_no_match %r{"preferences":\{"shows":"anime"\}}, json - end - - def test_should_allow_attribute_filtering_with_except - json = @contact.to_json(:except => [:name, :age]) - - assert_no_match %r{"name":"Konata Izumi"}, json - assert_no_match %r{"age":16}, json - assert_match %r{"awesome":true}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"preferences":\{"shows":"anime"\}}, json - end - - def test_methods_are_called_on_object - # Define methods on fixture. - def @contact.label; "Has cheezburger"; end - def @contact.favorite_quote; "Constraints are liberating"; end - - # Single method. - assert_match %r{"label":"Has cheezburger"}, @contact.to_json(:only => :name, :methods => :label) - - # Both methods. - methods_json = @contact.to_json(:only => :name, :methods => [:label, :favorite_quote]) - assert_match %r{"label":"Has cheezburger"}, methods_json - assert_match %r{"favorite_quote":"Constraints are liberating"}, methods_json - end -end - -class DatabaseConnectedJsonEncodingTest < ActiveRecord::TestCase - fixtures :authors, :posts, :comments, :tags, :taggings - - def setup - @david = authors(:david) - @mary = authors(:mary) - end - - def test_includes_uses_association_name - json = @david.to_json(:include => :posts) - - assert_match %r{"posts":\[}, json - - assert_match %r{"id":1}, json - assert_match %r{"name":"David"}, json - - assert_match %r{"author_id":1}, json - assert_match %r{"title":"Welcome to the weblog"}, json - assert_match %r{"body":"Such a lovely day"}, json - - assert_match %r{"title":"So I was thinking"}, json - assert_match %r{"body":"Like I hopefully always am"}, json - end - - def test_includes_uses_association_name_and_applies_attribute_filters - json = @david.to_json(:include => { :posts => { :only => :title } }) - - assert_match %r{"name":"David"}, json - assert_match %r{"posts":\[}, json - - assert_match %r{"title":"Welcome to the weblog"}, json - assert_no_match %r{"body":"Such a lovely day"}, json - - assert_match %r{"title":"So I was thinking"}, json - assert_no_match %r{"body":"Like I hopefully always am"}, json - end - - def test_includes_fetches_second_level_associations - json = @david.to_json(:include => { :posts => { :include => { :comments => { :only => :body } } } }) - - assert_match %r{"name":"David"}, json - assert_match %r{"posts":\[}, json - - assert_match %r{"comments":\[}, json - assert_match %r{\{"body":"Thank you again for the welcome"\}}, json - assert_match %r{\{"body":"Don't think too hard"\}}, json - assert_no_match %r{"post_id":}, json - end - - def test_includes_fetches_nth_level_associations - json = @david.to_json( - :include => { - :posts => { - :include => { - :taggings => { - :include => { - :tag => { :only => :name } - } - } - } - } - }) - - assert_match %r{"name":"David"}, json - assert_match %r{"posts":\[}, json - - assert_match %r{"taggings":\[}, json - assert_match %r{"tag":\{"name":"General"\}}, json - end - - def test_should_not_call_methods_on_associations_that_dont_respond - def @david.favorite_quote; "Constraints are liberating"; end - json = @david.to_json(:include => :posts, :methods => :favorite_quote) - - assert !@david.posts.first.respond_to?(:favorite_quote) - assert_match %r{"favorite_quote":"Constraints are liberating"}, json - assert_equal %r{"favorite_quote":}.match(json).size, 1 - end - - def test_should_allow_only_option_for_list_of_authors - authors = [@david, @mary] - - assert_equal %([{"name":"David"},{"name":"Mary"}]), ActiveSupport::JSON.encode(authors, :only => :name) - end - - def test_should_allow_except_option_for_list_of_authors - authors = [@david, @mary] - - assert_equal %([{"id":1},{"id":2}]), ActiveSupport::JSON.encode(authors, :except => [:name, :author_address_id, :author_address_extra_id]) - end - - def test_should_allow_includes_for_list_of_authors - authors = [@david, @mary] - json = ActiveSupport::JSON.encode(authors, - :only => :name, - :include => { - :posts => { :only => :id } - } - ) - - ['"name":"David"', '"posts":[', '{"id":1}', '{"id":2}', '{"id":4}', - '{"id":5}', '{"id":6}', '"name":"Mary"', '"posts":[{"id":7}]'].each do |fragment| - assert json.include?(fragment), json - end - end - - def test_should_allow_options_for_hash_of_authors - authors_hash = { - 1 => @david, - 2 => @mary - } - - assert_equal %({"1":{"name":"David"}}), ActiveSupport::JSON.encode(authors_hash, :only => [1, :name]) - end -end diff --git a/vendor/rails/activerecord/test/cases/lifecycle_test.rb b/vendor/rails/activerecord/test/cases/lifecycle_test.rb deleted file mode 100644 index 54fb3d8c..00000000 --- a/vendor/rails/activerecord/test/cases/lifecycle_test.rb +++ /dev/null @@ -1,193 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/developer' -require 'models/reply' -require 'models/minimalistic' - -class Topic; def after_find() end end -class Developer; def after_find() end end -class SpecialDeveloper < Developer; end - -class TopicManualObserver - include Singleton - - attr_reader :action, :object, :callbacks - - def initialize - Topic.add_observer(self) - @callbacks = [] - end - - def update(callback_method, object) - @callbacks << { "callback_method" => callback_method, "object" => object } - end - - def has_been_notified? - !@callbacks.empty? - end -end - -class TopicaAuditor < ActiveRecord::Observer - observe :topic - - attr_reader :topic - - def after_find(topic) - @topic = topic - end -end - -class TopicObserver < ActiveRecord::Observer - attr_reader :topic - - def after_find(topic) - @topic = topic - end -end - -class MinimalisticObserver < ActiveRecord::Observer - attr_reader :minimalistic - - def after_find(minimalistic) - @minimalistic = minimalistic - end -end - -class MultiObserver < ActiveRecord::Observer - attr_reader :record - - def self.observed_class() [ Topic, Developer ] end - - cattr_reader :last_inherited - @@last_inherited = nil - - def observed_class_inherited_with_testing(subclass) - observed_class_inherited_without_testing(subclass) - @@last_inherited = subclass - end - - alias_method_chain :observed_class_inherited, :testing - - def after_find(record) - @record = record - end -end - -class LifecycleTest < ActiveRecord::TestCase - fixtures :topics, :developers, :minimalistics - - def test_before_destroy - original_count = Topic.count - (topic_to_be_destroyed = Topic.find(1)).destroy - assert_equal original_count - (1 + topic_to_be_destroyed.replies.size), Topic.count - end - - def test_after_save - ActiveRecord::Base.observers = :topic_manual_observer - ActiveRecord::Base.instantiate_observers - - topic = Topic.find(1) - topic.title = "hello" - topic.save - - assert TopicManualObserver.instance.has_been_notified? - assert_equal :after_save, TopicManualObserver.instance.callbacks.last["callback_method"] - end - - def test_observer_update_on_save - ActiveRecord::Base.observers = TopicManualObserver - ActiveRecord::Base.instantiate_observers - - topic = Topic.find(1) - assert TopicManualObserver.instance.has_been_notified? - assert_equal :after_find, TopicManualObserver.instance.callbacks.first["callback_method"] - end - - def test_auto_observer - topic_observer = TopicaAuditor.instance - assert_nil TopicaAuditor.observed_class - assert_equal [Topic], TopicaAuditor.instance.observed_classes.to_a - - topic = Topic.find(1) - assert_equal topic.title, topic_observer.topic.title - end - - def test_inferred_auto_observer - topic_observer = TopicObserver.instance - assert_equal Topic, TopicObserver.observed_class - - topic = Topic.find(1) - assert_equal topic.title, topic_observer.topic.title - end - - def test_observing_two_classes - multi_observer = MultiObserver.instance - - topic = Topic.find(1) - assert_equal topic.title, multi_observer.record.title - - developer = Developer.find(1) - assert_equal developer.name, multi_observer.record.name - end - - def test_observing_subclasses - multi_observer = MultiObserver.instance - - developer = SpecialDeveloper.find(1) - assert_equal developer.name, multi_observer.record.name - - klass = Class.new(Developer) - assert_equal klass, multi_observer.last_inherited - - developer = klass.find(1) - assert_equal developer.name, multi_observer.record.name - end - - def test_after_find_can_be_observed_when_its_not_defined_on_the_model - observer = MinimalisticObserver.instance - assert_equal Minimalistic, MinimalisticObserver.observed_class - - minimalistic = Minimalistic.find(1) - assert_equal minimalistic, observer.minimalistic - end - - def test_after_find_can_be_observed_when_its_defined_on_the_model - observer = TopicObserver.instance - assert_equal Topic, TopicObserver.observed_class - - topic = Topic.find(1) - assert_equal topic, observer.topic - end - - def test_after_find_is_not_created_if_its_not_used - # use a fresh class so an observer can't have defined an - # after_find on it - model_class = Class.new(ActiveRecord::Base) - observer_class = Class.new(ActiveRecord::Observer) - observer_class.observe(model_class) - - observer = observer_class.instance - - assert !model_class.method_defined?(:after_find) - end - - def test_after_find_is_not_clobbered_if_it_already_exists - # use a fresh observer class so we can instantiate it (Observer is - # a Singleton) - model_class = Class.new(ActiveRecord::Base) do - def after_find; end - end - original_method = model_class.instance_method(:after_find) - observer_class = Class.new(ActiveRecord::Observer) do - def after_find; end - end - observer_class.observe(model_class) - - observer = observer_class.instance - assert_equal original_method, model_class.instance_method(:after_find) - end - - def test_invalid_observer - assert_raise(ArgumentError) { Topic.observers = Object.new; Topic.instantiate_observers } - end -end diff --git a/vendor/rails/activerecord/test/cases/locking_test.rb b/vendor/rails/activerecord/test/cases/locking_test.rb deleted file mode 100644 index a2d9d924..00000000 --- a/vendor/rails/activerecord/test/cases/locking_test.rb +++ /dev/null @@ -1,350 +0,0 @@ -require "cases/helper" -require 'models/person' -require 'models/reader' -require 'models/legacy_thing' -require 'models/reference' - -class LockWithoutDefault < ActiveRecord::Base; end - -class LockWithCustomColumnWithoutDefault < ActiveRecord::Base - set_table_name :lock_without_defaults_cust - set_locking_column :custom_lock_version -end - -class ReadonlyFirstNamePerson < Person - attr_readonly :first_name -end - -class OptimisticLockingTest < ActiveRecord::TestCase - fixtures :people, :legacy_things, :references - - # need to disable transactional fixtures, because otherwise the sqlite3 - # adapter (at least) chokes when we try and change the schema in the middle - # of a test (see test_increment_counter_*). - self.use_transactional_fixtures = false - - def test_lock_existing - p1 = Person.find(1) - p2 = Person.find(1) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'stu' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - p2.first_name = 'sue' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - end - - # See Lighthouse ticket #1966 - def test_lock_destroy - p1 = Person.find(1) - p2 = Person.find(1) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'stu' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - assert_raises(ActiveRecord::StaleObjectError) { p2.destroy } - - assert p1.destroy - assert p1.frozen? - assert p1.destroyed? - assert_raises(ActiveRecord::RecordNotFound) { Person.find(1) } - end - - def test_lock_repeating - p1 = Person.find(1) - p2 = Person.find(1) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'stu' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - p2.first_name = 'sue' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - p2.first_name = 'sue2' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - end - - def test_lock_new - p1 = Person.new(:first_name => 'anika') - assert_equal 0, p1.lock_version - - p1.first_name = 'anika2' - p1.save! - p2 = Person.find(p1.id) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'anika3' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - p2.first_name = 'sue' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - end - - def test_lock_new_with_nil - p1 = Person.new(:first_name => 'anika') - p1.save! - p1.lock_version = nil # simulate bad fixture or column with no default - p1.save! - assert_equal 1, p1.lock_version - end - - - def test_lock_column_name_existing - t1 = LegacyThing.find(1) - t2 = LegacyThing.find(1) - assert_equal 0, t1.version - assert_equal 0, t2.version - - t1.tps_report_number = 700 - t1.save! - assert_equal 1, t1.version - assert_equal 0, t2.version - - t2.tps_report_number = 800 - assert_raise(ActiveRecord::StaleObjectError) { t2.save! } - end - - def test_lock_column_is_mass_assignable - p1 = Person.create(:first_name => 'bianca') - assert_equal 0, p1.lock_version - assert_equal p1.lock_version, Person.new(p1.attributes).lock_version - - p1.first_name = 'bianca2' - p1.save! - assert_equal 1, p1.lock_version - assert_equal p1.lock_version, Person.new(p1.attributes).lock_version - end - - def test_lock_without_default_sets_version_to_zero - t1 = LockWithoutDefault.new - assert_equal 0, t1.lock_version - end - - def test_lock_with_custom_column_without_default_sets_version_to_zero - t1 = LockWithCustomColumnWithoutDefault.new - assert_equal 0, t1.custom_lock_version - end - - def test_readonly_attributes - assert_equal Set.new([ 'first_name' ]), ReadonlyFirstNamePerson.readonly_attributes - - p = ReadonlyFirstNamePerson.create(:first_name => "unchangeable name") - p.reload - assert_equal "unchangeable name", p.first_name - - p.update_attributes(:first_name => "changed name") - p.reload - assert_equal "unchangeable name", p.first_name - end - - { :lock_version => Person, :custom_lock_version => LegacyThing }.each do |name, model| - define_method("test_increment_counter_updates_#{name}") do - counter_test model, 1 do |id| - model.increment_counter :test_count, id - end - end - - define_method("test_decrement_counter_updates_#{name}") do - counter_test model, -1 do |id| - model.decrement_counter :test_count, id - end - end - - define_method("test_update_counters_updates_#{name}") do - counter_test model, 1 do |id| - model.update_counters id, :test_count => 1 - end - end - end - - # See Lighthouse ticket #1966 - def test_destroy_dependents - # Establish dependent relationship between People and LegacyThing - add_counter_column_to(Person, 'legacy_things_count') - LegacyThing.connection.add_column LegacyThing.table_name, 'person_id', :integer - LegacyThing.reset_column_information - LegacyThing.class_eval do - belongs_to :person, :counter_cache => true - end - Person.class_eval do - has_many :legacy_things, :dependent => :destroy - end - - # Make sure that counter incrementing doesn't cause problems - p1 = Person.new(:first_name => 'fjord') - p1.save! - t = LegacyThing.new(:person => p1) - t.save! - p1.reload - assert_equal 1, p1.legacy_things_count - assert p1.destroy - assert_equal true, p1.frozen? - assert_raises(ActiveRecord::RecordNotFound) { Person.find(p1.id) } - assert_raises(ActiveRecord::RecordNotFound) { LegacyThing.find(t.id) } - end - - def test_quote_table_name - ref = references(:michael_magician) - ref.favourite = !ref.favourite - assert ref.save - end - - # Useful for partial updates, don't only update the lock_version if there - # is nothing else being updated. - def test_update_without_attributes_does_not_only_update_lock_version - assert_nothing_raised do - p1 = Person.new(:first_name => 'anika') - p1.send(:update_with_lock, []) - end - end - - private - - def add_counter_column_to(model, col='test_count') - model.connection.add_column model.table_name, col, :integer, :null => false, :default => 0 - model.reset_column_information - # OpenBase does not set a value to existing rows when adding a not null default column - model.update_all(col => 0) if current_adapter?(:OpenBaseAdapter) - end - - def remove_counter_column_from(model) - model.connection.remove_column model.table_name, :test_count - model.reset_column_information - end - - def counter_test(model, expected_count) - add_counter_column_to(model) - object = model.find(:first) - assert_equal 0, object.test_count - assert_equal 0, object.send(model.locking_column) - yield object.id - object.reload - assert_equal expected_count, object.test_count - assert_equal 1, object.send(model.locking_column) - ensure - remove_counter_column_from(model) - end -end - - -# TODO: test against the generated SQL since testing locking behavior itself -# is so cumbersome. Will deadlock Ruby threads if the underlying db.execute -# blocks, so separate script called by Kernel#system is needed. -# (See exec vs. async_exec in the PostgreSQL adapter.) - -# TODO: The Sybase, and OpenBase adapters currently have no support for pessimistic locking - -unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) - class PessimisticLockingTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :people, :readers - - def setup - # Avoid introspection queries during tests. - Person.columns; Reader.columns - end - - # Test typical find. - def test_sane_find_with_lock - assert_nothing_raised do - Person.transaction do - Person.find 1, :lock => true - end - end - end - - # Test scoped lock. - def test_sane_find_with_scoped_lock - assert_nothing_raised do - Person.transaction do - Person.with_scope(:find => { :lock => true }) do - Person.find 1 - end - end - end - end - - # PostgreSQL protests SELECT ... FOR UPDATE on an outer join. - unless current_adapter?(:PostgreSQLAdapter) - # Test locked eager find. - def test_eager_find_with_lock - assert_nothing_raised do - Person.transaction do - Person.find 1, :include => :readers, :lock => true - end - end - end - end - - # Locking a record reloads it. - def test_sane_lock_method - assert_nothing_raised do - Person.transaction do - person = Person.find 1 - old, person.first_name = person.first_name, 'fooman' - person.lock! - assert_equal old, person.first_name - end - end - end - - if current_adapter?(:PostgreSQLAdapter, :OracleAdapter) - use_concurrent_connections - - def test_no_locks_no_wait - first, second = duel { Person.find 1 } - assert first.end > second.end - end - - def test_second_lock_waits - assert [0.2, 1, 5].any? { |zzz| - first, second = duel(zzz) { Person.find 1, :lock => true } - second.end > first.end - } - end - - protected - def duel(zzz = 5) - t0, t1, t2, t3 = nil, nil, nil, nil - - a = Thread.new do - t0 = Time.now - Person.transaction do - yield - sleep zzz # block thread 2 for zzz seconds - end - t1 = Time.now - end - - b = Thread.new do - sleep zzz / 2.0 # ensure thread 1 tx starts first - t2 = Time.now - Person.transaction { yield } - t3 = Time.now - end - - a.join - b.join - - assert t1 > t0 + zzz - assert t2 > t0 - assert t3 > t2 - [t0.to_f..t1.to_f, t2.to_f..t3.to_f] - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/method_scoping_test.rb b/vendor/rails/activerecord/test/cases/method_scoping_test.rb deleted file mode 100644 index d8246f49..00000000 --- a/vendor/rails/activerecord/test/cases/method_scoping_test.rb +++ /dev/null @@ -1,704 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/author' -require 'models/developer' -require 'models/project' -require 'models/comment' -require 'models/category' - -class MethodScopingTest < ActiveRecord::TestCase - fixtures :authors, :developers, :projects, :comments, :posts, :developers_projects - - def test_set_conditions - Developer.with_scope(:find => { :conditions => 'just a test...' }) do - assert_equal 'just a test...', Developer.send(:current_scoped_methods)[:find][:conditions] - end - end - - def test_scoped_find - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - assert_nothing_raised { Developer.find(1) } - end - end - - def test_scoped_find_first - Developer.with_scope(:find => { :conditions => "salary = 100000" }) do - assert_equal Developer.find(10), Developer.find(:first, :order => 'name') - end - end - - def test_scoped_find_last - highest_salary = Developer.find(:first, :order => "salary DESC") - - Developer.with_scope(:find => { :order => "salary" }) do - assert_equal highest_salary, Developer.last - end - end - - def test_scoped_find_last_preserves_scope - lowest_salary = Developer.find(:first, :order => "salary ASC") - highest_salary = Developer.find(:first, :order => "salary DESC") - - Developer.with_scope(:find => { :order => "salary" }) do - assert_equal highest_salary, Developer.last - assert_equal lowest_salary, Developer.first - end - end - - def test_scoped_find_combines_conditions - Developer.with_scope(:find => { :conditions => "salary = 9000" }) do - assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => "name = 'Jamis'") - end - end - - def test_scoped_find_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_equal developers(:poor_jamis), Developer.find(:first) - end - end - - def test_scoped_find_combines_and_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => ['name = ?', 'Jamis']) - end - end - - def test_scoped_find_all - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - assert_equal [developers(:david)], Developer.find(:all) - end - end - - def test_scoped_find_select - Developer.with_scope(:find => { :select => "id, name" }) do - developer = Developer.find(:first, :conditions => "name = 'David'") - assert_equal "David", developer.name - assert !developer.has_attribute?(:salary) - end - end - - def test_options_select_replaces_scope_select - Developer.with_scope(:find => { :select => "id, name" }) do - developer = Developer.find(:first, :select => 'id, salary', :conditions => "name = 'David'") - assert_equal 80000, developer.salary - assert !developer.has_attribute?(:name) - end - end - - def test_scoped_count - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - assert_equal 1, Developer.count - end - - Developer.with_scope(:find => { :conditions => 'salary = 100000' }) do - assert_equal 8, Developer.count - assert_equal 1, Developer.count(:conditions => "name LIKE 'fixture_1%'") - end - end - - def test_scoped_find_include - # with the include, will retrieve only developers for the given project - scoped_developers = Developer.with_scope(:find => { :include => :projects }) do - Developer.find(:all, :conditions => 'projects.id = 2') - end - assert scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 1, scoped_developers.size - end - - def test_scoped_find_joins - scoped_developers = Developer.with_scope(:find => { :joins => 'JOIN developers_projects ON id = developer_id' } ) do - Developer.find(:all, :conditions => 'developers_projects.project_id = 2') - end - assert scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 1, scoped_developers.size - assert_equal developers(:david).attributes, scoped_developers.first.attributes - end - - def test_scoped_find_using_new_style_joins - scoped_developers = Developer.with_scope(:find => { :joins => :projects }) do - Developer.find(:all, :conditions => 'projects.id = 2') - end - assert scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 1, scoped_developers.size - assert_equal developers(:david).attributes, scoped_developers.first.attributes - end - - def test_scoped_find_merges_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => 'INNER JOIN posts ON authors.id = posts.author_id ' }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => 'INNER JOIN comments ON posts.id = comments.post_id', :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_new_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => :comments, :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_new_and_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => 'JOIN comments ON posts.id = comments.post_id', :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_string_array_style_and_string_style_joins - scoped_authors = Author.with_scope(:find => { :joins => ["INNER JOIN posts ON posts.author_id = authors.id"]}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => 'INNER JOIN comments ON posts.id = comments.post_id', :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_string_array_style_and_hash_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => ['INNER JOIN comments ON posts.id = comments.post_id'], :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_joins_and_eliminates_duplicate_string_joins - scoped_authors = Author.with_scope(:find => { :joins => 'INNER JOIN posts ON posts.author_id = authors.id'}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => ["INNER JOIN posts ON posts.author_id = authors.id", "INNER JOIN comments ON posts.id = comments.post_id"], :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_strips_spaces_from_string_joins_and_eliminates_duplicate_string_joins - scoped_authors = Author.with_scope(:find => { :joins => ' INNER JOIN posts ON posts.author_id = authors.id '}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => ['INNER JOIN posts ON posts.author_id = authors.id'], :conditions => 'posts.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_count_include - # with the include, will retrieve only developers for the given project - Developer.with_scope(:find => { :include => :projects }) do - assert_equal 1, Developer.count(:conditions => 'projects.id = 2') - end - end - - def test_scoped_create - new_comment = nil - - VerySpecialComment.with_scope(:create => { :post_id => 1 }) do - assert_equal({ :post_id => 1 }, VerySpecialComment.send(:current_scoped_methods)[:create]) - new_comment = VerySpecialComment.create :body => "Wonderful world" - end - - assert Post.find(1).comments.include?(new_comment) - end - - def test_immutable_scope - options = { :conditions => "name = 'David'" } - Developer.with_scope(:find => options) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - options[:conditions] = "name != 'David'" - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - - scope = { :find => { :conditions => "name = 'David'" }} - Developer.with_scope(scope) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - scope[:find][:conditions] = "name != 'David'" - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - - def test_scoped_with_duck_typing - scoping = Struct.new(:method_scoping).new(:find => { :conditions => ["name = ?", 'David'] }) - Developer.with_scope(scoping) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - - def test_ensure_that_method_scoping_is_correctly_restored - scoped_methods = Developer.instance_eval('current_scoped_methods') - - begin - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - raise "an exception" - end - rescue - end - assert_equal scoped_methods, Developer.instance_eval('current_scoped_methods') - end -end - -class NestedScopingTest < ActiveRecord::TestCase - fixtures :authors, :developers, :projects, :comments, :posts - - def test_merge_options - Developer.with_scope(:find => { :conditions => 'salary = 80000' }) do - Developer.with_scope(:find => { :limit => 10 }) do - merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :conditions => 'salary = 80000', :limit => 10 }, merged_option) - end - end - end - - def test_merge_inner_scope_has_priority - Developer.with_scope(:find => { :limit => 5 }) do - Developer.with_scope(:find => { :limit => 10 }) do - merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :limit => 10 }, merged_option) - end - end - end - - def test_replace_options - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do - assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Developer.instance_eval('current_scoped_methods')) - assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Developer.send(:scoped_methods)[-1]) - end - end - end - - def test_append_conditions - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - Developer.with_scope(:find => { :conditions => 'salary = 80000' }) do - appended_condition = Developer.instance_eval('current_scoped_methods')[:find][:conditions] - assert_equal("(name = 'David') AND (salary = 80000)", appended_condition) - assert_equal(1, Developer.count) - end - Developer.with_scope(:find => { :conditions => "name = 'Maiha'" }) do - assert_equal(0, Developer.count) - end - end - end - - def test_merge_and_append_options - Developer.with_scope(:find => { :conditions => 'salary = 80000', :limit => 10 }) do - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :conditions => "(salary = 80000) AND (name = 'David')", :limit => 10 }, merged_option) - end - end - end - - def test_nested_scoped_find - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.with_exclusive_scope(:find => { :conditions => "name = 'David'" }) do - assert_nothing_raised { Developer.find(1) } - assert_equal('David', Developer.find(:first).name) - end - assert_equal('Jamis', Developer.find(:first).name) - end - end - - def test_nested_scoped_find_include - Developer.with_scope(:find => { :include => :projects }) do - Developer.with_scope(:find => { :conditions => "projects.id = 2" }) do - assert_nothing_raised { Developer.find(1) } - assert_equal('David', Developer.find(:first).name) - end - end - end - - def test_nested_scoped_find_merged_include - # :include's remain unique and don't "double up" when merging - Developer.with_scope(:find => { :include => :projects, :conditions => "projects.id = 2" }) do - Developer.with_scope(:find => { :include => :projects }) do - assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length - assert_equal('David', Developer.find(:first).name) - end - end - - # the nested scope doesn't remove the first :include - Developer.with_scope(:find => { :include => :projects, :conditions => "projects.id = 2" }) do - Developer.with_scope(:find => { :include => [] }) do - assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length - assert_equal('David', Developer.find(:first).name) - end - end - - # mixing array and symbol include's will merge correctly - Developer.with_scope(:find => { :include => [:projects], :conditions => "projects.id = 2" }) do - Developer.with_scope(:find => { :include => :projects }) do - assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length - assert_equal('David', Developer.find(:first).name) - end - end - end - - def test_nested_scoped_find_replace_include - Developer.with_scope(:find => { :include => :projects }) do - Developer.with_exclusive_scope(:find => { :include => [] }) do - assert_equal 0, Developer.instance_eval('current_scoped_methods')[:find][:include].length - end - end - end - - def test_three_level_nested_exclusive_scoped_find - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - assert_equal('Jamis', Developer.find(:first).name) - - Developer.with_exclusive_scope(:find => { :conditions => "name = 'David'" }) do - assert_equal('David', Developer.find(:first).name) - - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Maiha'" }) do - assert_equal(nil, Developer.find(:first)) - end - - # ensure that scoping is restored - assert_equal('David', Developer.find(:first).name) - end - - # ensure that scoping is restored - assert_equal('Jamis', Developer.find(:first).name) - end - end - - def test_merged_scoped_find - poor_jamis = developers(:poor_jamis) - Developer.with_scope(:find => { :conditions => "salary < 100000" }) do - Developer.with_scope(:find => { :offset => 1, :order => 'id asc' }) do - assert_sql /ORDER BY id asc / do - assert_equal(poor_jamis, Developer.find(:first, :order => 'id asc')) - end - end - end - end - - def test_merged_scoped_find_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ["name = ?", 'David'] }) do - Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_raise(ActiveRecord::RecordNotFound) { developers(:poor_jamis) } - end - end - end - - def test_nested_scoped_find_combines_and_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ["name = ?", 'David'] }) do - Developer.with_exclusive_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_equal developers(:poor_jamis), Developer.find(:first) - assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => ['name = ?', 'Jamis']) - end - end - end - - def test_merged_scoped_find_combines_and_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ["name = ?", 'David'] }) do - Developer.with_scope(:find => { :conditions => ['salary > ?', 9000] }) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - end - - def test_nested_scoped_create - comment = nil - Comment.with_scope(:create => { :post_id => 1}) do - Comment.with_scope(:create => { :post_id => 2}) do - assert_equal({ :post_id => 2 }, Comment.send(:current_scoped_methods)[:create]) - comment = Comment.create :body => "Hey guys, nested scopes are broken. Please fix!" - end - end - assert_equal 2, comment.post_id - end - - def test_nested_exclusive_scope_for_create - comment = nil - Comment.with_scope(:create => { :body => "Hey guys, nested scopes are broken. Please fix!" }) do - Comment.with_exclusive_scope(:create => { :post_id => 1 }) do - assert_equal({ :post_id => 1 }, Comment.send(:current_scoped_methods)[:create]) - comment = Comment.create :body => "Hey guys" - end - end - assert_equal 1, comment.post_id - assert_equal 'Hey guys', comment.body - end - - def test_merged_scoped_find_on_blank_conditions - [nil, " ", [], {}].each do |blank| - Developer.with_scope(:find => {:conditions => blank}) do - Developer.with_scope(:find => {:conditions => blank}) do - assert_nothing_raised { Developer.find(:first) } - end - end - end - end - - def test_merged_scoped_find_on_blank_bind_conditions - [ [""], ["",{}] ].each do |blank| - Developer.with_scope(:find => {:conditions => blank}) do - Developer.with_scope(:find => {:conditions => blank}) do - assert_nothing_raised { Developer.find(:first) } - end - end - end - end - - def test_immutable_nested_scope - options1 = { :conditions => "name = 'Jamis'" } - options2 = { :conditions => "name = 'David'" } - Developer.with_scope(:find => options1) do - Developer.with_exclusive_scope(:find => options2) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - options1[:conditions] = options2[:conditions] = nil - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - end - - def test_immutable_merged_scope - options1 = { :conditions => "name = 'Jamis'" } - options2 = { :conditions => "salary > 10000" } - Developer.with_scope(:find => options1) do - Developer.with_scope(:find => options2) do - assert_equal %w(Jamis), Developer.find(:all).map { |d| d.name } - options1[:conditions] = options2[:conditions] = nil - assert_equal %w(Jamis), Developer.find(:all).map { |d| d.name } - end - end - end - - def test_ensure_that_method_scoping_is_correctly_restored - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - scoped_methods = Developer.instance_eval('current_scoped_methods') - begin - Developer.with_scope(:find => { :conditions => "name = 'Maiha'" }) do - raise "an exception" - end - rescue - end - assert_equal scoped_methods, Developer.instance_eval('current_scoped_methods') - end - end - - def test_nested_scoped_find_merges_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => 'INNER JOIN posts ON authors.id = posts.author_id' }) do - Author.with_scope(:find => { :joins => 'INNER JOIN comments ON posts.id = comments.post_id' }) do - Author.find(:all, :select => 'DISTINCT authors.*', :conditions => 'comments.id = 1') - end - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_nested_scoped_find_merges_new_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.with_scope(:find => { :joins => :comments }) do - Author.find(:all, :select => 'DISTINCT authors.*', :conditions => 'comments.id = 1') - end - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_nested_scoped_find_merges_new_and_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.with_scope(:find => { :joins => 'INNER JOIN comments ON posts.id = comments.post_id' }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => '', :conditions => 'comments.id = 1') - end - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end -end - -class HasManyScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts - - def setup - @welcome = Post.find(1) - end - - def test_forwarding_of_static_methods - assert_equal 'a comment...', Comment.what_are_you - assert_equal 'a comment...', @welcome.comments.what_are_you - end - - def test_forwarding_to_scoped - assert_equal 4, Comment.search_by_type('Comment').size - assert_equal 2, @welcome.comments.search_by_type('Comment').size - end - - def test_forwarding_to_dynamic_finders - assert_equal 4, Comment.find_all_by_type('Comment').size - assert_equal 2, @welcome.comments.find_all_by_type('Comment').size - end - - def test_nested_scope - Comment.with_scope(:find => { :conditions => '1=1' }) do - assert_equal 'a comment...', @welcome.comments.what_are_you - end - end -end - -class HasAndBelongsToManyScopingTest< ActiveRecord::TestCase - fixtures :posts, :categories, :categories_posts - - def setup - @welcome = Post.find(1) - end - - def test_forwarding_of_static_methods - assert_equal 'a category...', Category.what_are_you - assert_equal 'a category...', @welcome.categories.what_are_you - end - - def test_forwarding_to_dynamic_finders - assert_equal 4, Category.find_all_by_type('SpecialCategory').size - assert_equal 0, @welcome.categories.find_all_by_type('SpecialCategory').size - assert_equal 2, @welcome.categories.find_all_by_type('Category').size - end - - def test_nested_scope - Category.with_scope(:find => { :conditions => '1=1' }) do - assert_equal 'a comment...', @welcome.comments.what_are_you - end - end -end - -class DefaultScopingTest < ActiveRecord::TestCase - fixtures :developers - - def test_default_scope - expected = Developer.find(:all, :order => 'salary DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.find(:all).collect { |dev| dev.salary } - assert_equal expected, received - end - - def test_default_scope_with_conditions_string - assert_equal Developer.find_all_by_name('David').map(&:id).sort, DeveloperCalledDavid.all.map(&:id).sort - assert_equal nil, DeveloperCalledDavid.create!.name - end - - def test_default_scope_with_conditions_hash - assert_equal Developer.find_all_by_name('Jamis').map(&:id).sort, DeveloperCalledJamis.all.map(&:id).sort - assert_equal 'Jamis', DeveloperCalledJamis.create!.name - end - - def test_default_scoping_with_threads - scope = [{ :create => {}, :find => { :order => 'salary DESC' } }] - - 2.times do - Thread.new { assert_equal scope, DeveloperOrderedBySalary.send(:scoped_methods) }.join - end - end - - def test_default_scoping_with_inheritance - scope = [{ :create => {}, :find => { :order => 'salary DESC' } }] - - # Inherit a class having a default scope and define a new default scope - klass = Class.new(DeveloperOrderedBySalary) - klass.send :default_scope, {} - - # Scopes added on children should append to parent scope - expected_klass_scope = [{ :create => {}, :find => { :order => 'salary DESC' }}, { :create => {}, :find => {} }] - assert_equal expected_klass_scope, klass.send(:scoped_methods) - - # Parent should still have the original scope - assert_equal scope, DeveloperOrderedBySalary.send(:scoped_methods) - end - - def test_method_scope - expected = Developer.find(:all, :order => 'name DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.all_ordered_by_name.collect { |dev| dev.salary } - assert_equal expected, received - end - - def test_nested_scope - expected = Developer.find(:all, :order => 'name DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.with_scope(:find => { :order => 'name DESC'}) do - DeveloperOrderedBySalary.find(:all).collect { |dev| dev.salary } - end - assert_equal expected, received - end - - def test_named_scope_overwrites_default - expected = Developer.find(:all, :order => 'name DESC').collect { |dev| dev.name } - received = DeveloperOrderedBySalary.by_name.find(:all).collect { |dev| dev.name } - assert_equal expected, received - end - - def test_nested_exclusive_scope - expected = Developer.find(:all, :limit => 100).collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.with_exclusive_scope(:find => { :limit => 100 }) do - DeveloperOrderedBySalary.find(:all).collect { |dev| dev.salary } - end - assert_equal expected, received - end - - def test_overwriting_default_scope - expected = Developer.find(:all, :order => 'salary').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.find(:all, :order => 'salary').collect { |dev| dev.salary } - assert_equal expected, received - end -end - -=begin -# We disabled the scoping for has_one and belongs_to as we can't think of a proper use case - -class BelongsToScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts - - def setup - @greetings = Comment.find(1) - end - - def test_forwarding_of_static_method - assert_equal 'a post...', Post.what_are_you - assert_equal 'a post...', @greetings.post.what_are_you - end - - def test_forwarding_to_dynamic_finders - assert_equal 4, Post.find_all_by_type('Post').size - assert_equal 1, @greetings.post.find_all_by_type('Post').size - end - -end - -class HasOneScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts - - def setup - @sti_comments = Post.find(4) - end - - def test_forwarding_of_static_methods - assert_equal 'a comment...', Comment.what_are_you - assert_equal 'a very special comment...', @sti_comments.very_special_comment.what_are_you - end - - def test_forwarding_to_dynamic_finders - assert_equal 1, Comment.find_all_by_type('VerySpecialComment').size - assert_equal 1, @sti_comments.very_special_comment.find_all_by_type('VerySpecialComment').size - assert_equal 0, @sti_comments.very_special_comment.find_all_by_type('Comment').size - end - -end - -=end diff --git a/vendor/rails/activerecord/test/cases/migration_test.rb b/vendor/rails/activerecord/test/cases/migration_test.rb deleted file mode 100644 index 4692f914..00000000 --- a/vendor/rails/activerecord/test/cases/migration_test.rb +++ /dev/null @@ -1,1649 +0,0 @@ -require "cases/helper" -require 'bigdecimal/util' - -require 'models/person' -require 'models/topic' -require 'models/developer' - -require MIGRATIONS_ROOT + "/valid/1_people_have_last_names" -require MIGRATIONS_ROOT + "/valid/2_we_need_reminders" -require MIGRATIONS_ROOT + "/decimal/1_give_me_big_numbers" -require MIGRATIONS_ROOT + "/interleaved/pass_3/2_i_raise_on_down" - -if ActiveRecord::Base.connection.supports_migrations? - class BigNumber < ActiveRecord::Base; end - - class Reminder < ActiveRecord::Base; end - - class ActiveRecord::Migration - class <<self - attr_accessor :message_count - def puts(text="") - self.message_count ||= 0 - self.message_count += 1 - end - end - end - - class MigrationTableAndIndexTest < ActiveRecord::TestCase - def test_add_schema_info_respects_prefix_and_suffix - conn = ActiveRecord::Base.connection - - conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name) - ActiveRecord::Base.table_name_prefix = 'foo_' - ActiveRecord::Base.table_name_suffix = '_bar' - conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name) - - conn.initialize_schema_migrations_table - - assert_equal "foo_unique_schema_migrations_bar", conn.indexes(ActiveRecord::Migrator.schema_migrations_table_name)[0][:name] - ensure - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - end - end - - class MigrationTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - fixtures :people - - def setup - ActiveRecord::Migration.verbose = true - PeopleHaveLastNames.message_count = 0 - end - - def teardown - ActiveRecord::Base.connection.initialize_schema_migrations_table - ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}" - - %w(reminders people_reminders prefix_reminders_suffix).each do |table| - Reminder.connection.drop_table(table) rescue nil - end - Reminder.reset_column_information - - %w(last_name key bio age height wealth birthday favorite_day - moment_of_truth male administrator funny).each do |column| - Person.connection.remove_column('people', column) rescue nil - end - Person.connection.remove_column("people", "first_name") rescue nil - Person.connection.remove_column("people", "middle_name") rescue nil - Person.connection.add_column("people", "first_name", :string, :limit => 40) - Person.reset_column_information - end - - def test_add_index - # Limit size of last_name and key columns to support Firebird index limitations - Person.connection.add_column "people", "last_name", :string, :limit => 100 - Person.connection.add_column "people", "key", :string, :limit => 100 - Person.connection.add_column "people", "administrator", :boolean - - assert_nothing_raised { Person.connection.add_index("people", "last_name") } - assert_nothing_raised { Person.connection.remove_index("people", "last_name") } - - # Orcl nds shrt indx nms. Sybs 2. - # OpenBase does not have named indexes. You must specify a single column name - unless current_adapter?(:OracleAdapter, :SybaseAdapter, :OpenBaseAdapter) - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.add_index("people", ["last_name"], :length => 10) } - assert_nothing_raised { Person.connection.remove_index("people", "last_name") } - assert_nothing_raised { Person.connection.add_index("people", ["last_name"], :length => {:last_name => 10}) } - assert_nothing_raised { Person.connection.remove_index("people", ["last_name"]) } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"], :length => 10) } - assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"], :length => {:last_name => 10, :first_name => 20}) } - assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } - end - - # quoting - # Note: changed index name from "key" to "key_idx" since "key" is a Firebird reserved word - # OpenBase does not have named indexes. You must specify a single column name - unless current_adapter?(:OpenBaseAdapter) - Person.update_all "#{Person.connection.quote_column_name 'key'}=#{Person.connection.quote_column_name 'id'}" #some databases (including sqlite2 won't add a unique index if existing data non unique) - assert_nothing_raised { Person.connection.add_index("people", ["key"], :name => "key_idx", :unique => true) } - assert_nothing_raised { Person.connection.remove_index("people", :name => "key_idx", :unique => true) } - end - - # Sybase adapter does not support indexes on :boolean columns - # OpenBase does not have named indexes. You must specify a single column - unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) - assert_nothing_raised { Person.connection.add_index("people", %w(last_name first_name administrator), :name => "named_admin") } - assert_nothing_raised { Person.connection.remove_index("people", :name => "named_admin") } - end - end - - def test_index_symbol_names - assert_nothing_raised { Person.connection.add_index :people, :primary_contact_id, :name => :symbol_index_name } - assert Person.connection.index_exists?(:people, :symbol_index_name, true) - assert_nothing_raised { Person.connection.remove_index :people, :name => :symbol_index_name } - assert_equal true, !Person.connection.index_exists?(:people, :symbol_index_name, false) - end - - def test_add_index_length_limit - good_index_name = 'x' * Person.connection.index_name_length - too_long_index_name = good_index_name + 'x' - assert_nothing_raised { Person.connection.add_index("people", "first_name", :name => too_long_index_name) } - assert !Person.connection.index_exists?("people", too_long_index_name, false) - assert_nothing_raised { Person.connection.add_index("people", "first_name", :name => good_index_name) } - assert Person.connection.index_exists?("people", good_index_name, false) - end - - def test_remove_nonexistent_index - # we do this by name, so OpenBase is a wash as noted above - unless current_adapter?(:OpenBaseAdapter) - assert_nothing_raised { Person.connection.remove_index("people", "no_such_index") } - end - end - - def test_rename_index - unless current_adapter?(:OpenBaseAdapter) - # keep the names short to make Oracle and similar behave - Person.connection.add_index('people', [:first_name], :name => 'old_idx') - assert_nothing_raised { Person.connection.rename_index('people', 'old_idx', 'new_idx') } - # if the adapter doesn't support the indexes call, pick defaults that let the test pass - assert !Person.connection.index_exists?('people', 'old_idx', false) - assert Person.connection.index_exists?('people', 'new_idx', true) - end - end - - def test_double_add_index - unless current_adapter?(:OpenBaseAdapter) - Person.connection.add_index('people', [:first_name], :name => 'some_idx') - assert_nothing_raised { Person.connection.add_index('people', [:first_name], :name => 'some_idx') } - end - end - - def testing_table_with_only_foo_attribute - Person.connection.create_table :testings, :id => false do |t| - t.column :foo, :string - end - - yield Person.connection - ensure - Person.connection.drop_table :testings rescue nil - end - protected :testing_table_with_only_foo_attribute - - def test_create_table_without_id - testing_table_with_only_foo_attribute do |connection| - assert_equal connection.columns(:testings).size, 1 - end - end - - def test_add_column_with_primary_key_attribute - testing_table_with_only_foo_attribute do |connection| - assert_nothing_raised { connection.add_column :testings, :id, :primary_key } - assert_equal connection.columns(:testings).size, 2 - end - end - - def test_create_table_adds_id - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - assert_equal %w(foo id), - Person.connection.columns(:testings).map { |c| c.name }.sort - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_not_null_column - assert_nothing_raised do - Person.connection.create_table :testings do |t| - t.column :foo, :string, :null => false - end - end - - assert_raise(ActiveRecord::StatementInvalid) do - Person.connection.execute "insert into testings (foo) values (NULL)" - end - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_defaults - # MySQL doesn't allow defaults on TEXT or BLOB columns. - mysql = current_adapter?(:MysqlAdapter) - - Person.connection.create_table :testings do |t| - t.column :one, :string, :default => "hello" - t.column :two, :boolean, :default => true - t.column :three, :boolean, :default => false - t.column :four, :integer, :default => 1 - t.column :five, :text, :default => "hello" unless mysql - end - - columns = Person.connection.columns(:testings) - one = columns.detect { |c| c.name == "one" } - two = columns.detect { |c| c.name == "two" } - three = columns.detect { |c| c.name == "three" } - four = columns.detect { |c| c.name == "four" } - five = columns.detect { |c| c.name == "five" } unless mysql - - assert_equal "hello", one.default - assert_equal true, two.default - assert_equal false, three.default - assert_equal 1, four.default - assert_equal "hello", five.default unless mysql - - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_limits - assert_nothing_raised do - Person.connection.create_table :testings do |t| - t.column :foo, :string, :limit => 255 - - t.column :default_int, :integer - - t.column :one_int, :integer, :limit => 1 - t.column :four_int, :integer, :limit => 4 - t.column :eight_int, :integer, :limit => 8 - t.column :eleven_int, :integer, :limit => 11 - end - end - - columns = Person.connection.columns(:testings) - foo = columns.detect { |c| c.name == "foo" } - assert_equal 255, foo.limit - - default = columns.detect { |c| c.name == "default_int" } - one = columns.detect { |c| c.name == "one_int" } - four = columns.detect { |c| c.name == "four_int" } - eight = columns.detect { |c| c.name == "eight_int" } - eleven = columns.detect { |c| c.name == "eleven_int" } - - if current_adapter?(:PostgreSQLAdapter) - assert_equal 'integer', default.sql_type - assert_equal 'smallint', one.sql_type - assert_equal 'integer', four.sql_type - assert_equal 'bigint', eight.sql_type - assert_equal 'integer', eleven.sql_type - elsif current_adapter?(:MysqlAdapter) - assert_match 'int(11)', default.sql_type - assert_match 'tinyint', one.sql_type - assert_match 'int', four.sql_type - assert_match 'bigint', eight.sql_type - assert_match 'int(11)', eleven.sql_type - elsif current_adapter?(:OracleAdapter) - assert_equal 'NUMBER(38)', default.sql_type - assert_equal 'NUMBER(1)', one.sql_type - assert_equal 'NUMBER(4)', four.sql_type - assert_equal 'NUMBER(8)', eight.sql_type - end - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_primary_key_prefix_as_table_name_with_underscore - ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore - - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - assert_equal %w(foo testing_id), Person.connection.columns(:testings).map { |c| c.name }.sort - ensure - Person.connection.drop_table :testings rescue nil - ActiveRecord::Base.primary_key_prefix_type = nil - end - - def test_create_table_with_primary_key_prefix_as_table_name - ActiveRecord::Base.primary_key_prefix_type = :table_name - - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - assert_equal %w(foo testingid), Person.connection.columns(:testings).map { |c| c.name }.sort - ensure - Person.connection.drop_table :testings rescue nil - ActiveRecord::Base.primary_key_prefix_type = nil - end - - def test_create_table_with_force_true_does_not_drop_nonexisting_table - if Person.connection.table_exists?(:testings2) - Person.connection.drop_table :testings2 - end - - # using a copy as we need the drop_table method to - # continue to work for the ensure block of the test - temp_conn = Person.connection.dup - temp_conn.expects(:drop_table).never - temp_conn.create_table :testings2, :force => true do |t| - t.column :foo, :string - end - ensure - Person.connection.drop_table :testings2 rescue nil - end - - def test_create_table_with_timestamps_should_create_datetime_columns - table_name = :testings - - Person.connection.create_table table_name do |t| - t.timestamps - end - created_columns = Person.connection.columns(table_name) - - created_at_column = created_columns.detect {|c| c.name == 'created_at' } - updated_at_column = created_columns.detect {|c| c.name == 'updated_at' } - - assert created_at_column.null - assert updated_at_column.null - ensure - Person.connection.drop_table table_name rescue nil - end - - def test_create_table_with_timestamps_should_create_datetime_columns_with_options - table_name = :testings - - Person.connection.create_table table_name do |t| - t.timestamps :null => false - end - created_columns = Person.connection.columns(table_name) - - created_at_column = created_columns.detect {|c| c.name == 'created_at' } - updated_at_column = created_columns.detect {|c| c.name == 'updated_at' } - - assert !created_at_column.null - assert !updated_at_column.null - ensure - Person.connection.drop_table table_name rescue nil - end - - def test_create_table_without_a_block - table_name = :testings - Person.connection.create_table table_name - ensure - Person.connection.drop_table table_name rescue nil - end - - # Sybase, and SQLite3 will not allow you to add a NOT NULL - # column to a table without a default value. - unless current_adapter?(:SybaseAdapter, :SQLiteAdapter) - def test_add_column_not_null_without_default - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - Person.connection.add_column :testings, :bar, :string, :null => false - - assert_raise(ActiveRecord::StatementInvalid) do - Person.connection.execute "insert into testings (foo, bar) values ('hello', NULL)" - end - ensure - Person.connection.drop_table :testings rescue nil - end - end - - def test_add_column_not_null_with_default - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - con = Person.connection - Person.connection.enable_identity_insert("testings", true) if current_adapter?(:SybaseAdapter) - Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')" - Person.connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter) - assert_nothing_raised {Person.connection.add_column :testings, :bar, :string, :null => false, :default => "default" } - - assert_raise(ActiveRecord::StatementInvalid) do - unless current_adapter?(:OpenBaseAdapter) - Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)" - else - Person.connection.insert("INSERT INTO testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) VALUES (2, 'hello', NULL)", - "Testing Insert","id",2) - end - end - ensure - Person.connection.drop_table :testings rescue nil - end - - # We specifically do a manual INSERT here, and then test only the SELECT - # functionality. This allows us to more easily catch INSERT being broken, - # but SELECT actually working fine. - def test_native_decimal_insert_manual_vs_automatic - correct_value = '0012345678901234567890.0123456789'.to_d - - Person.delete_all - Person.connection.add_column "people", "wealth", :decimal, :precision => '30', :scale => '10' - Person.reset_column_information - - # Do a manual insertion - if current_adapter?(:OracleAdapter) - Person.connection.execute "insert into people (id, wealth) values (people_seq.nextval, 12345678901234567890.0123456789)" - elsif current_adapter?(:OpenBaseAdapter) || (current_adapter?(:MysqlAdapter) && Mysql.client_version < 50003) #before mysql 5.0.3 decimals stored as strings - Person.connection.execute "insert into people (wealth) values ('12345678901234567890.0123456789')" - else - Person.connection.execute "insert into people (wealth) values (12345678901234567890.0123456789)" - end - - # SELECT - row = Person.find(:first) - assert_kind_of BigDecimal, row.wealth - - # If this assert fails, that means the SELECT is broken! - unless current_adapter?(:SQLite3Adapter) - assert_equal correct_value, row.wealth - end - - # Reset to old state - Person.delete_all - - # Now use the Rails insertion - assert_nothing_raised { Person.create :wealth => BigDecimal.new("12345678901234567890.0123456789") } - - # SELECT - row = Person.find(:first) - assert_kind_of BigDecimal, row.wealth - - # If these asserts fail, that means the INSERT (create function, or cast to SQL) is broken! - unless current_adapter?(:SQLite3Adapter) - assert_equal correct_value, row.wealth - end - - # Reset to old state - Person.connection.del_column "people", "wealth" rescue nil - Person.reset_column_information - end - - def test_add_column_with_precision_and_scale - Person.connection.add_column 'people', 'wealth', :decimal, :precision => 9, :scale => 7 - Person.reset_column_information - - wealth_column = Person.columns_hash['wealth'] - assert_equal 9, wealth_column.precision - assert_equal 7, wealth_column.scale - end - - def test_native_types - Person.delete_all - Person.connection.add_column "people", "last_name", :string - Person.connection.add_column "people", "bio", :text - Person.connection.add_column "people", "age", :integer - Person.connection.add_column "people", "height", :float - Person.connection.add_column "people", "wealth", :decimal, :precision => '30', :scale => '10' - Person.connection.add_column "people", "birthday", :datetime - Person.connection.add_column "people", "favorite_day", :date - Person.connection.add_column "people", "moment_of_truth", :datetime - Person.connection.add_column "people", "male", :boolean - Person.reset_column_information - - assert_nothing_raised do - Person.create :first_name => 'bob', :last_name => 'bobsen', - :bio => "I was born ....", :age => 18, :height => 1.78, - :wealth => BigDecimal.new("12345678901234567890.0123456789"), - :birthday => 18.years.ago, :favorite_day => 10.days.ago, - :moment_of_truth => "1782-10-10 21:40:18", :male => true - end - - bob = Person.find(:first) - assert_equal 'bob', bob.first_name - assert_equal 'bobsen', bob.last_name - assert_equal "I was born ....", bob.bio - assert_equal 18, bob.age - - # Test for 30 significent digits (beyond the 16 of float), 10 of them - # after the decimal place. - - unless current_adapter?(:SQLite3Adapter) - assert_equal BigDecimal.new("0012345678901234567890.0123456789"), bob.wealth - end - - assert_equal true, bob.male? - - assert_equal String, bob.first_name.class - assert_equal String, bob.last_name.class - assert_equal String, bob.bio.class - assert_equal Fixnum, bob.age.class - assert_equal Time, bob.birthday.class - - if current_adapter?(:OracleAdapter, :SybaseAdapter) - # Sybase, and Oracle don't differentiate between date/time - assert_equal Time, bob.favorite_day.class - else - assert_equal Date, bob.favorite_day.class - end - - # Test DateTime column and defaults, including timezone. - # FIXME: moment of truth may be Time on 64-bit platforms. - if bob.moment_of_truth.is_a?(DateTime) - - with_env_tz 'US/Eastern' do - assert_equal DateTime.local_offset, bob.moment_of_truth.offset - assert_not_equal 0, bob.moment_of_truth.offset - assert_not_equal "Z", bob.moment_of_truth.zone - # US/Eastern is -5 hours from GMT - assert_equal Rational(-5, 24), bob.moment_of_truth.offset - assert_match /\A-05:?00\Z/, bob.moment_of_truth.zone #ruby 1.8.6 uses HH:MM, prior versions use HHMM - assert_equal DateTime::ITALY, bob.moment_of_truth.start - end - end - - assert_equal TrueClass, bob.male?.class - assert_kind_of BigDecimal, bob.wealth - end - - if current_adapter?(:MysqlAdapter) - def test_unabstracted_database_dependent_types - Person.delete_all - - ActiveRecord::Migration.add_column :people, :intelligence_quotient, :tinyint - Person.reset_column_information - assert_match /tinyint/, Person.columns_hash['intelligence_quotient'].sql_type - ensure - ActiveRecord::Migration.remove_column :people, :intelligence_quotient rescue nil - end - end - - def test_add_remove_single_field_using_string_arguments - assert !Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.add_column 'people', 'last_name', :string - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.remove_column 'people', 'last_name' - - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - end - - def test_add_remove_single_field_using_symbol_arguments - assert !Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.add_column :people, :last_name, :string - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.remove_column :people, :last_name - - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - end - - if current_adapter?(:MysqlAdapter) - def testing_table_for_positioning - Person.connection.create_table :testings, :id => false do |t| - t.column :first, :integer - t.column :second, :integer - t.column :third, :integer - end - - yield Person.connection - ensure - Person.connection.drop_table :testings rescue nil - end - protected :testing_table_for_positioning - - def test_column_positioning - testing_table_for_positioning do |conn| - assert_equal %w(first second third), conn.columns(:testings).map {|c| c.name } - end - end - - def test_add_column_with_positioning - testing_table_for_positioning do |conn| - conn.add_column :testings, :new_col, :integer - assert_equal %w(first second third new_col), conn.columns(:testings).map {|c| c.name } - end - testing_table_for_positioning do |conn| - conn.add_column :testings, :new_col, :integer, :first => true - assert_equal %w(new_col first second third), conn.columns(:testings).map {|c| c.name } - end - testing_table_for_positioning do |conn| - conn.add_column :testings, :new_col, :integer, :after => :first - assert_equal %w(first new_col second third), conn.columns(:testings).map {|c| c.name } - end - end - - def test_change_column_with_positioning - testing_table_for_positioning do |conn| - conn.change_column :testings, :second, :integer, :first => true - assert_equal %w(second first third), conn.columns(:testings).map {|c| c.name } - end - testing_table_for_positioning do |conn| - conn.change_column :testings, :second, :integer, :after => :third - assert_equal %w(first third second), conn.columns(:testings).map {|c| c.name } - end - end - end - - def test_add_rename - Person.delete_all - - begin - Person.connection.add_column "people", "girlfriend", :string - Person.reset_column_information - Person.create :girlfriend => 'bobette' - - Person.connection.rename_column "people", "girlfriend", "exgirlfriend" - - Person.reset_column_information - bob = Person.find(:first) - - assert_equal "bobette", bob.exgirlfriend - ensure - Person.connection.remove_column("people", "girlfriend") rescue nil - Person.connection.remove_column("people", "exgirlfriend") rescue nil - end - - end - - def test_rename_column_using_symbol_arguments - begin - names_before = Person.find(:all).map(&:first_name) - Person.connection.rename_column :people, :first_name, :nick_name - Person.reset_column_information - assert Person.column_names.include?("nick_name") - assert_equal names_before, Person.find(:all).map(&:nick_name) - ensure - Person.connection.remove_column("people","nick_name") - Person.connection.add_column("people","first_name", :string) - end - end - - def test_rename_column - begin - names_before = Person.find(:all).map(&:first_name) - Person.connection.rename_column "people", "first_name", "nick_name" - Person.reset_column_information - assert Person.column_names.include?("nick_name") - assert_equal names_before, Person.find(:all).map(&:nick_name) - ensure - Person.connection.remove_column("people","nick_name") - Person.connection.add_column("people","first_name", :string) - end - end - - def test_rename_column_preserves_default_value_not_null - begin - default_before = Developer.connection.columns("developers").find { |c| c.name == "salary" }.default - assert_equal 70000, default_before - Developer.connection.rename_column "developers", "salary", "anual_salary" - Developer.reset_column_information - assert Developer.column_names.include?("anual_salary") - default_after = Developer.connection.columns("developers").find { |c| c.name == "anual_salary" }.default - assert_equal 70000, default_after - ensure - Developer.connection.rename_column "developers", "anual_salary", "salary" - Developer.reset_column_information - end - end - - def test_rename_nonexistent_column - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :default => nil - end - exception = if current_adapter?(:PostgreSQLAdapter) - ActiveRecord::StatementInvalid - else - ActiveRecord::ActiveRecordError - end - assert_raise(exception) do - Person.connection.rename_column "hats", "nonexistent", "should_fail" - end - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_rename_column_with_sql_reserved_word - begin - assert_nothing_raised { Person.connection.rename_column "people", "first_name", "group" } - Person.reset_column_information - assert Person.column_names.include?("group") - ensure - Person.connection.remove_column("people", "group") rescue nil - Person.connection.add_column("people", "first_name", :string) rescue nil - end - end - - def test_rename_column_with_an_index - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :limit => 100 - table.column :hat_size, :integer - end - Person.connection.add_index :hats, :hat_name - assert_nothing_raised do - Person.connection.rename_column "hats", "hat_name", "name" - end - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_remove_column_with_index - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :limit => 100 - table.column :hat_size, :integer - end - ActiveRecord::Base.connection.add_index "hats", "hat_size" - - assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") } - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_remove_column_with_multi_column_index - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :limit => 100 - table.column :hat_size, :integer - table.column :hat_style, :string, :limit => 100 - end - ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true - - assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") } - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_remove_column_no_second_parameter_raises_exception - assert_raise(ArgumentError) { Person.connection.remove_column("funny") } - end - - def test_change_type_of_not_null_column - assert_nothing_raised do - Topic.connection.change_column "topics", "written_on", :datetime, :null => false - Topic.reset_column_information - - Topic.connection.change_column "topics", "written_on", :datetime, :null => false - Topic.reset_column_information - end - end - - def test_rename_table - begin - ActiveRecord::Base.connection.create_table :octopuses do |t| - t.column :url, :string - end - ActiveRecord::Base.connection.rename_table :octopuses, :octopi - - # Using explicit id in insert for compatibility across all databases - con = ActiveRecord::Base.connection - con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter) - assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" } - con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter) - - assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") - - ensure - ActiveRecord::Base.connection.drop_table :octopuses rescue nil - ActiveRecord::Base.connection.drop_table :octopi rescue nil - end - end - - def test_change_column_nullability - Person.delete_all - Person.connection.add_column "people", "funny", :boolean - Person.reset_column_information - assert Person.columns_hash["funny"].null, "Column 'funny' must initially allow nulls" - Person.connection.change_column "people", "funny", :boolean, :null => false, :default => true - Person.reset_column_information - assert !Person.columns_hash["funny"].null, "Column 'funny' must *not* allow nulls at this point" - Person.connection.change_column "people", "funny", :boolean, :null => true - Person.reset_column_information - assert Person.columns_hash["funny"].null, "Column 'funny' must allow nulls again at this point" - end - - def test_rename_table_with_an_index - begin - ActiveRecord::Base.connection.create_table :octopuses do |t| - t.column :url, :string - end - ActiveRecord::Base.connection.add_index :octopuses, :url - - ActiveRecord::Base.connection.rename_table :octopuses, :octopi - - # Using explicit id in insert for compatibility across all databases - con = ActiveRecord::Base.connection - con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter) - assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" } - con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter) - - assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") - assert ActiveRecord::Base.connection.indexes(:octopi).first.columns.include?("url") - ensure - ActiveRecord::Base.connection.drop_table :octopuses rescue nil - ActiveRecord::Base.connection.drop_table :octopi rescue nil - end - end - - def test_change_column - Person.connection.add_column 'people', 'age', :integer - old_columns = Person.connection.columns(Person.table_name, "#{name} Columns") - assert old_columns.find { |c| c.name == 'age' and c.type == :integer } - - assert_nothing_raised { Person.connection.change_column "people", "age", :string } - - new_columns = Person.connection.columns(Person.table_name, "#{name} Columns") - assert_nil new_columns.find { |c| c.name == 'age' and c.type == :integer } - assert new_columns.find { |c| c.name == 'age' and c.type == :string } - - old_columns = Topic.connection.columns(Topic.table_name, "#{name} Columns") - assert old_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true } - assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => false } - new_columns = Topic.connection.columns(Topic.table_name, "#{name} Columns") - assert_nil new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true } - assert new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == false } - assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => true } - end - - def test_change_column_with_nil_default - Person.connection.add_column "people", "contributor", :boolean, :default => true - Person.reset_column_information - assert Person.new.contributor? - - assert_nothing_raised { Person.connection.change_column "people", "contributor", :boolean, :default => nil } - Person.reset_column_information - assert !Person.new.contributor? - assert_nil Person.new.contributor - ensure - Person.connection.remove_column("people", "contributor") rescue nil - end - - def test_change_column_with_new_default - Person.connection.add_column "people", "administrator", :boolean, :default => true - Person.reset_column_information - assert Person.new.administrator? - - assert_nothing_raised { Person.connection.change_column "people", "administrator", :boolean, :default => false } - Person.reset_column_information - assert !Person.new.administrator? - ensure - Person.connection.remove_column("people", "administrator") rescue nil - end - - def test_change_column_default - Person.connection.change_column_default "people", "first_name", "Tester" - Person.reset_column_information - assert_equal "Tester", Person.new.first_name - end - - def test_change_column_quotes_column_names - Person.connection.create_table :testings do |t| - t.column :select, :string - end - - assert_nothing_raised { Person.connection.change_column :testings, :select, :string, :limit => 10 } - - assert_nothing_raised { Person.connection.execute "insert into testings (#{Person.connection.quote_column_name('select')}) values ('7 chars')" } - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_keeping_default_and_notnull_constaint_on_change - Person.connection.create_table :testings do |t| - t.column :title, :string - end - person_klass = Class.new(Person) - person_klass.set_table_name 'testings' - - person_klass.connection.add_column "testings", "wealth", :integer, :null => false, :default => 99 - person_klass.reset_column_information - assert_equal 99, person_klass.columns_hash["wealth"].default - assert_equal false, person_klass.columns_hash["wealth"].null - assert_nothing_raised {person_klass.connection.execute("insert into testings (title) values ('tester')")} - - # change column default to see that column doesn't lose its not null definition - person_klass.connection.change_column_default "testings", "wealth", 100 - person_klass.reset_column_information - assert_equal 100, person_klass.columns_hash["wealth"].default - assert_equal false, person_klass.columns_hash["wealth"].null - - # rename column to see that column doesn't lose its not null and/or default definition - person_klass.connection.rename_column "testings", "wealth", "money" - person_klass.reset_column_information - assert_nil person_klass.columns_hash["wealth"] - assert_equal 100, person_klass.columns_hash["money"].default - assert_equal false, person_klass.columns_hash["money"].null - - # change column - person_klass.connection.change_column "testings", "money", :integer, :null => false, :default => 1000 - person_klass.reset_column_information - assert_equal 1000, person_klass.columns_hash["money"].default - assert_equal false, person_klass.columns_hash["money"].null - - # change column, make it nullable and clear default - person_klass.connection.change_column "testings", "money", :integer, :null => true, :default => nil - person_klass.reset_column_information - assert_nil person_klass.columns_hash["money"].default - assert_equal true, person_klass.columns_hash["money"].null - - # change_column_null, make it not nullable and set null values to a default value - person_klass.connection.execute('UPDATE testings SET money = NULL') - person_klass.connection.change_column_null "testings", "money", false, 2000 - person_klass.reset_column_information - assert_nil person_klass.columns_hash["money"].default - assert_equal false, person_klass.columns_hash["money"].null - assert_equal [2000], Person.connection.select_values("SELECT money FROM testings").map { |s| s.to_i }.sort - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_change_column_default_to_null - Person.connection.change_column_default "people", "first_name", nil - Person.reset_column_information - assert_nil Person.new.first_name - end - - def test_add_table - assert !Reminder.table_exists? - - WeNeedReminders.up - - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - - WeNeedReminders.down - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } - end - - def test_add_table_with_decimals - Person.connection.drop_table :big_numbers rescue nil - - assert !BigNumber.table_exists? - GiveMeBigNumbers.up - - assert BigNumber.create( - :bank_balance => 1586.43, - :big_bank_balance => BigDecimal("1000234000567.95"), - :world_population => 6000000000, - :my_house_population => 3, - :value_of_e => BigDecimal("2.7182818284590452353602875") - ) - - b = BigNumber.find(:first) - assert_not_nil b - - assert_not_nil b.bank_balance - assert_not_nil b.big_bank_balance - assert_not_nil b.world_population - assert_not_nil b.my_house_population - assert_not_nil b.value_of_e - - # TODO: set world_population >= 2**62 to cover 64-bit platforms and test - # is_a?(Bignum) - assert_kind_of Integer, b.world_population - assert_equal 6000000000, b.world_population - assert_kind_of Fixnum, b.my_house_population - assert_equal 3, b.my_house_population - assert_kind_of BigDecimal, b.bank_balance - assert_equal BigDecimal("1586.43"), b.bank_balance - assert_kind_of BigDecimal, b.big_bank_balance - assert_equal BigDecimal("1000234000567.95"), b.big_bank_balance - - # This one is fun. The 'value_of_e' field is defined as 'DECIMAL' with - # precision/scale explicitly left out. By the SQL standard, numbers - # assigned to this field should be truncated but that's seldom respected. - if current_adapter?(:PostgreSQLAdapter, :SQLite2Adapter) - # - PostgreSQL changes the SQL spec on columns declared simply as - # "decimal" to something more useful: instead of being given a scale - # of 0, they take on the compile-time limit for precision and scale, - # so the following should succeed unless you have used really wacky - # compilation options - # - SQLite2 has the default behavior of preserving all data sent in, - # so this happens there too - assert_kind_of BigDecimal, b.value_of_e - assert_equal BigDecimal("2.7182818284590452353602875"), b.value_of_e - elsif current_adapter?(:SQLiteAdapter) - # - SQLite3 stores a float, in violation of SQL - assert_kind_of BigDecimal, b.value_of_e - assert_equal BigDecimal("2.71828182845905"), b.value_of_e - else - # - SQL standard is an integer - assert_kind_of Fixnum, b.value_of_e - assert_equal 2, b.value_of_e - end - - GiveMeBigNumbers.down - assert_raise(ActiveRecord::StatementInvalid) { BigNumber.find(:first) } - end - - def test_migrator - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid") - - assert_equal 3, ActiveRecord::Migrator.current_version - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid") - - assert_equal 0, ActiveRecord::Migrator.current_version - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } - end - - def test_migrator_one_up - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 2) - - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - end - - def test_migrator_one_down - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid") - - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 1) - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - end - - def test_migrator_one_up_one_down - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0) - - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - end - - def test_migrator_double_up - assert_equal(0, ActiveRecord::Migrator.current_version) - ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) - assert_nothing_raised { ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) } - assert_equal(1, ActiveRecord::Migrator.current_version) - end - - def test_migrator_double_down - assert_equal(0, ActiveRecord::Migrator.current_version) - ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) - ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 1) - assert_nothing_raised { ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 1) } - assert_equal(0, ActiveRecord::Migrator.current_version) - end - - if ActiveRecord::Base.connection.supports_ddl_transactions? - def test_migrator_one_up_with_exception_and_rollback - assert !Person.column_methods_hash.include?(:last_name) - - e = assert_raise(StandardError) do - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/broken", 100) - end - - assert_equal "An error has occurred, this and all later migrations canceled:\n\nSomething broke", e.message - - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - end - end - - def test_finds_migrations - migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations - - [[1, 'PeopleHaveLastNames'], [2, 'WeNeedReminders'], [3, 'InnocentJointable']].each_with_index do |pair, i| - assert_equal migrations[i].version, pair.first - assert_equal migrations[i].name, pair.last - end - end - - def test_finds_pending_migrations - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_2", 1) - migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/interleaved/pass_2").pending_migrations - - assert_equal 1, migrations.size - assert_equal migrations[0].version, 3 - assert_equal migrations[0].name, 'InnocentJointable' - end - - def test_only_loads_pending_migrations - # migrate up to 1 - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - - # now unload the migrations that have been defined - PeopleHaveLastNames.unloadable - ActiveSupport::Dependencies.remove_unloadable_constants! - - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", nil) - - assert !defined? PeopleHaveLastNames - - %w(WeNeedReminders, InnocentJointable).each do |migration| - assert defined? migration - end - - ensure - load(MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb") - end - - def test_target_version_zero_should_run_only_once - # migrate up to 1 - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1) - - # migrate down to 0 - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0) - - # now unload the migrations that have been defined - PeopleHaveLastNames.unloadable - ActiveSupport::Dependencies.remove_unloadable_constants! - - # migrate down to 0 again - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0) - - assert !defined? PeopleHaveLastNames - ensure - load(MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb") - end - - def test_migrator_interleaved_migrations - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_1") - - assert_nothing_raised do - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_2") - end - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - - assert_nothing_raised do - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/interleaved/pass_3") - end - end - - def test_migrator_db_has_no_schema_migrations_table - ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations;") - assert_nothing_raised do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1) - end - end - - def test_migrator_verbosity - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - assert PeopleHaveLastNames.message_count > 0 - PeopleHaveLastNames.message_count = 0 - - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0) - assert PeopleHaveLastNames.message_count > 0 - PeopleHaveLastNames.message_count = 0 - end - - def test_migrator_verbosity_off - PeopleHaveLastNames.verbose = false - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - assert PeopleHaveLastNames.message_count.zero? - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0) - assert PeopleHaveLastNames.message_count.zero? - end - - def test_migrator_going_down_due_to_version_target - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0) - - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - end - - def test_migrator_rollback - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") - assert_equal(3, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(2, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(1, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(0, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(0, ActiveRecord::Migrator.current_version) - end - - def test_schema_migrations_table_name - ActiveRecord::Base.table_name_prefix = "prefix_" - ActiveRecord::Base.table_name_suffix = "_suffix" - Reminder.reset_table_name - assert_equal "prefix_schema_migrations_suffix", ActiveRecord::Migrator.schema_migrations_table_name - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - Reminder.reset_table_name - assert_equal "schema_migrations", ActiveRecord::Migrator.schema_migrations_table_name - ensure - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - end - - def test_proper_table_name - assert_equal "table", ActiveRecord::Migrator.proper_table_name('table') - assert_equal "table", ActiveRecord::Migrator.proper_table_name(:table) - assert_equal "reminders", ActiveRecord::Migrator.proper_table_name(Reminder) - Reminder.reset_table_name - assert_equal Reminder.table_name, ActiveRecord::Migrator.proper_table_name(Reminder) - - # Use the model's own prefix/suffix if a model is given - ActiveRecord::Base.table_name_prefix = "ARprefix_" - ActiveRecord::Base.table_name_suffix = "_ARsuffix" - Reminder.table_name_prefix = 'prefix_' - Reminder.table_name_suffix = '_suffix' - Reminder.reset_table_name - assert_equal "prefix_reminders_suffix", ActiveRecord::Migrator.proper_table_name(Reminder) - Reminder.table_name_prefix = '' - Reminder.table_name_suffix = '' - Reminder.reset_table_name - - # Use AR::Base's prefix/suffix if string or symbol is given - ActiveRecord::Base.table_name_prefix = "prefix_" - ActiveRecord::Base.table_name_suffix = "_suffix" - Reminder.reset_table_name - assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name('table') - assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name(:table) - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - Reminder.reset_table_name - end - - def test_add_drop_table_with_prefix_and_suffix - assert !Reminder.table_exists? - ActiveRecord::Base.table_name_prefix = 'prefix_' - ActiveRecord::Base.table_name_suffix = '_suffix' - Reminder.reset_table_name - Reminder.reset_sequence_name - WeNeedReminders.up - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - - WeNeedReminders.down - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } - ensure - ActiveRecord::Base.table_name_prefix = '' - ActiveRecord::Base.table_name_suffix = '' - Reminder.reset_table_name - Reminder.reset_sequence_name - end - - def test_create_table_with_binary_column - Person.connection.drop_table :binary_testings rescue nil - - assert_nothing_raised { - Person.connection.create_table :binary_testings do |t| - t.column "data", :binary, :null => false - end - } - - columns = Person.connection.columns(:binary_testings) - data_column = columns.detect { |c| c.name == "data" } - - if current_adapter?(:MysqlAdapter) - assert_equal '', data_column.default - else - assert_nil data_column.default - end - - Person.connection.drop_table :binary_testings rescue nil - end - - def test_migrator_with_duplicates - assert_raise(ActiveRecord::DuplicateMigrationVersionError) do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate", nil) - end - end - - def test_migrator_with_duplicate_names - assert_raise(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate_names", nil) - end - end - - def test_migrator_with_missing_version_numbers - assert_raise(ActiveRecord::UnknownMigrationVersionError) do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 500) - end - end - - def test_create_table_with_custom_sequence_name - return unless current_adapter? :OracleAdapter - - # table name is 29 chars, the standard sequence name will - # be 33 chars and fail - assert_raise(ActiveRecord::StatementInvalid) do - begin - Person.connection.create_table :table_with_name_thats_just_ok do |t| - t.column :foo, :string, :null => false - end - ensure - Person.connection.drop_table :table_with_name_thats_just_ok rescue nil - end - end - - # should be all good w/ a custom sequence name - assert_nothing_raised do - begin - Person.connection.create_table :table_with_name_thats_just_ok, - :sequence_name => 'suitably_short_seq' do |t| - t.column :foo, :string, :null => false - end - - Person.connection.execute("select suitably_short_seq.nextval from dual") - - ensure - Person.connection.drop_table :table_with_name_thats_just_ok, - :sequence_name => 'suitably_short_seq' rescue nil - end - end - - # confirm the custom sequence got dropped - assert_raise(ActiveRecord::StatementInvalid) do - Person.connection.execute("select suitably_short_seq.nextval from dual") - end - end - - protected - def with_env_tz(new_tz = 'US/Eastern') - old_tz, ENV['TZ'] = ENV['TZ'], new_tz - yield - ensure - old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') - end - - end - - class SexyMigrationsTest < ActiveRecord::TestCase - def test_references_column_type_adds_id - with_new_table do |t| - t.expects(:column).with('customer_id', :integer, {}) - t.references :customer - end - end - - def test_references_column_type_with_polymorphic_adds_type - with_new_table do |t| - t.expects(:column).with('taggable_type', :string, {}) - t.expects(:column).with('taggable_id', :integer, {}) - t.references :taggable, :polymorphic => true - end - end - - def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag - with_new_table do |t| - t.expects(:column).with('taggable_type', :string, {:null => false}) - t.expects(:column).with('taggable_id', :integer, {:null => false}) - t.references :taggable, :polymorphic => true, :null => false - end - end - - def test_belongs_to_works_like_references - with_new_table do |t| - t.expects(:column).with('customer_id', :integer, {}) - t.belongs_to :customer - end - end - - def test_timestamps_creates_updated_at_and_created_at - with_new_table do |t| - t.expects(:column).with(:created_at, :datetime, kind_of(Hash)) - t.expects(:column).with(:updated_at, :datetime, kind_of(Hash)) - t.timestamps - end - end - - def test_integer_creates_integer_column - with_new_table do |t| - t.expects(:column).with(:foo, 'integer', {}) - t.expects(:column).with(:bar, 'integer', {}) - t.integer :foo, :bar - end - end - - def test_string_creates_string_column - with_new_table do |t| - t.expects(:column).with(:foo, 'string', {}) - t.expects(:column).with(:bar, 'string', {}) - t.string :foo, :bar - end - end - - if current_adapter?(:PostgreSQLAdapter) - def test_xml_creates_xml_column - with_new_table do |t| - t.expects(:column).with(:data, 'xml', {}) - t.xml :data - end - end - end - - protected - def with_new_table - Person.connection.create_table :delete_me, :force => true do |t| - yield t - end - ensure - Person.connection.drop_table :delete_me rescue nil - end - - end # SexyMigrationsTest - - class ChangeTableMigrationsTest < ActiveRecord::TestCase - def setup - @connection = Person.connection - @connection.create_table :delete_me, :force => true do |t| - end - end - - def teardown - Person.connection.drop_table :delete_me rescue nil - end - - def test_references_column_type_adds_id - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'customer_id', :integer, {}) - t.references :customer - end - end - - def test_remove_references_column_type_removes_id - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'customer_id') - t.remove_references :customer - end - end - - def test_add_belongs_to_works_like_add_references - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'customer_id', :integer, {}) - t.belongs_to :customer - end - end - - def test_remove_belongs_to_works_like_remove_references - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'customer_id') - t.remove_belongs_to :customer - end - end - - def test_references_column_type_with_polymorphic_adds_type - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'taggable_type', :string, {}) - @connection.expects(:add_column).with(:delete_me, 'taggable_id', :integer, {}) - t.references :taggable, :polymorphic => true - end - end - - def test_remove_references_column_type_with_polymorphic_removes_type - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'taggable_type') - @connection.expects(:remove_column).with(:delete_me, 'taggable_id') - t.remove_references :taggable, :polymorphic => true - end - end - - def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'taggable_type', :string, {:null => false}) - @connection.expects(:add_column).with(:delete_me, 'taggable_id', :integer, {:null => false}) - t.references :taggable, :polymorphic => true, :null => false - end - end - - def test_remove_references_column_type_with_polymorphic_and_options_null_is_false_removes_table_flag - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'taggable_type') - @connection.expects(:remove_column).with(:delete_me, 'taggable_id') - t.remove_references :taggable, :polymorphic => true, :null => false - end - end - - def test_timestamps_creates_updated_at_and_created_at - with_change_table do |t| - @connection.expects(:add_timestamps).with(:delete_me) - t.timestamps - end - end - - def test_remove_timestamps_creates_updated_at_and_created_at - with_change_table do |t| - @connection.expects(:remove_timestamps).with(:delete_me) - t.remove_timestamps - end - end - - def string_column - if current_adapter?(:PostgreSQLAdapter) - "character varying(255)" - else - 'varchar(255)' - end - end - - def integer_column - if current_adapter?(:MysqlAdapter) - 'int(11)' - else - 'integer' - end - end - - def test_integer_creates_integer_column - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :foo, integer_column, {}) - @connection.expects(:add_column).with(:delete_me, :bar, integer_column, {}) - t.integer :foo, :bar - end - end - - def test_string_creates_string_column - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :foo, string_column, {}) - @connection.expects(:add_column).with(:delete_me, :bar, string_column, {}) - t.string :foo, :bar - end - end - - def test_column_creates_column - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :bar, :integer, {}) - t.column :bar, :integer - end - end - - def test_column_creates_column_with_options - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :bar, :integer, {:null => false}) - t.column :bar, :integer, :null => false - end - end - - def test_index_creates_index - with_change_table do |t| - @connection.expects(:add_index).with(:delete_me, :bar, {}) - t.index :bar - end - end - - def test_index_creates_index_with_options - with_change_table do |t| - @connection.expects(:add_index).with(:delete_me, :bar, {:unique => true}) - t.index :bar, :unique => true - end - end - - def test_change_changes_column - with_change_table do |t| - @connection.expects(:change_column).with(:delete_me, :bar, :string, {}) - t.change :bar, :string - end - end - - def test_change_changes_column_with_options - with_change_table do |t| - @connection.expects(:change_column).with(:delete_me, :bar, :string, {:null => true}) - t.change :bar, :string, :null => true - end - end - - def test_change_default_changes_column - with_change_table do |t| - @connection.expects(:change_column_default).with(:delete_me, :bar, :string) - t.change_default :bar, :string - end - end - - def test_remove_drops_single_column - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, [:bar]) - t.remove :bar - end - end - - def test_remove_drops_multiple_columns - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, [:bar, :baz]) - t.remove :bar, :baz - end - end - - def test_remove_index_removes_index_with_options - with_change_table do |t| - @connection.expects(:remove_index).with(:delete_me, {:unique => true}) - t.remove_index :unique => true - end - end - - def test_rename_renames_column - with_change_table do |t| - @connection.expects(:rename_column).with(:delete_me, :bar, :baz) - t.rename :bar, :baz - end - end - - protected - def with_change_table - Person.connection.change_table :delete_me do |t| - yield t - end - end - end -end - diff --git a/vendor/rails/activerecord/test/cases/migration_test_firebird.rb b/vendor/rails/activerecord/test/cases/migration_test_firebird.rb deleted file mode 100644 index 710661b9..00000000 --- a/vendor/rails/activerecord/test/cases/migration_test_firebird.rb +++ /dev/null @@ -1,124 +0,0 @@ -require "cases/helper" -require 'models/course' - -class FirebirdMigrationTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - # using Course connection for tests -- need a db that doesn't already have a BOOLEAN domain - @connection = Course.connection - @fireruby_connection = @connection.instance_variable_get(:@connection) - end - - def teardown - @connection.drop_table :foo rescue nil - @connection.execute("DROP DOMAIN D_BOOLEAN") rescue nil - end - - def test_create_table_with_custom_sequence_name - assert_nothing_raised do - @connection.create_table(:foo, :sequence => 'foo_custom_seq') do |f| - f.column :bar, :string - end - end - assert !sequence_exists?('foo_seq') - assert sequence_exists?('foo_custom_seq') - - assert_nothing_raised { @connection.drop_table(:foo, :sequence => 'foo_custom_seq') } - assert !sequence_exists?('foo_custom_seq') - ensure - FireRuby::Generator.new('foo_custom_seq', @fireruby_connection).drop rescue nil - end - - def test_create_table_without_sequence - assert_nothing_raised do - @connection.create_table(:foo, :sequence => false) do |f| - f.column :bar, :string - end - end - assert !sequence_exists?('foo_seq') - assert_nothing_raised { @connection.drop_table :foo } - - assert_nothing_raised do - @connection.create_table(:foo, :id => false) do |f| - f.column :bar, :string - end - end - assert !sequence_exists?('foo_seq') - assert_nothing_raised { @connection.drop_table :foo } - end - - def test_create_table_with_boolean_column - assert !boolean_domain_exists? - assert_nothing_raised do - @connection.create_table :foo do |f| - f.column :bar, :string - f.column :baz, :boolean - end - end - assert boolean_domain_exists? - end - - def test_add_boolean_column - assert !boolean_domain_exists? - @connection.create_table :foo do |f| - f.column :bar, :string - end - - assert_nothing_raised { @connection.add_column :foo, :baz, :boolean } - assert boolean_domain_exists? - assert_equal :boolean, @connection.columns(:foo).find { |c| c.name == "baz" }.type - end - - def test_change_column_to_boolean - assert !boolean_domain_exists? - # Manually create table with a SMALLINT column, which can be changed to a BOOLEAN - @connection.execute "CREATE TABLE foo (bar SMALLINT)" - assert_equal :integer, @connection.columns(:foo).find { |c| c.name == "bar" }.type - - assert_nothing_raised { @connection.change_column :foo, :bar, :boolean } - assert boolean_domain_exists? - assert_equal :boolean, @connection.columns(:foo).find { |c| c.name == "bar" }.type - end - - def test_rename_table_with_data_and_index - @connection.create_table :foo do |f| - f.column :baz, :string, :limit => 50 - end - 100.times { |i| @connection.execute "INSERT INTO foo VALUES (GEN_ID(foo_seq, 1), 'record #{i+1}')" } - @connection.add_index :foo, :baz - - assert_nothing_raised { @connection.rename_table :foo, :bar } - assert !@connection.tables.include?("foo") - assert @connection.tables.include?("bar") - assert_equal "index_bar_on_baz", @connection.indexes("bar").first.name - assert_equal 100, FireRuby::Generator.new("bar_seq", @fireruby_connection).last - assert_equal 100, @connection.select_one("SELECT COUNT(*) FROM bar")["count"] - ensure - @connection.drop_table :bar rescue nil - end - - def test_renaming_table_with_fk_constraint_raises_error - @connection.create_table :parent do |p| - p.column :name, :string - end - @connection.create_table :child do |c| - c.column :parent_id, :integer - end - @connection.execute "ALTER TABLE child ADD CONSTRAINT fk_child_parent FOREIGN KEY(parent_id) REFERENCES parent(id)" - assert_raise(ActiveRecord::ActiveRecordError) { @connection.rename_table :child, :descendant } - ensure - @connection.drop_table :child rescue nil - @connection.drop_table :descendant rescue nil - @connection.drop_table :parent rescue nil - end - - private - def boolean_domain_exists? - !@connection.select_one("SELECT 1 FROM rdb$fields WHERE rdb$field_name = 'D_BOOLEAN'").nil? - end - - def sequence_exists?(sequence_name) - FireRuby::Generator.exists?(sequence_name, @fireruby_connection) - end -end diff --git a/vendor/rails/activerecord/test/cases/mixin_test.rb b/vendor/rails/activerecord/test/cases/mixin_test.rb deleted file mode 100644 index f927c139..00000000 --- a/vendor/rails/activerecord/test/cases/mixin_test.rb +++ /dev/null @@ -1,96 +0,0 @@ -require "cases/helper" - -class Mixin < ActiveRecord::Base -end - -# Let us control what Time.now returns for the TouchTest suite -class Time - @@forced_now_time = nil - cattr_accessor :forced_now_time - - class << self - def now_with_forcing - if @@forced_now_time - @@forced_now_time - else - now_without_forcing - end - end - alias_method_chain :now, :forcing - end -end - - -class TouchTest < ActiveRecord::TestCase - fixtures :mixins - - def setup - Time.forced_now_time = Time.now - end - - def teardown - Time.forced_now_time = nil - end - - def test_time_mocking - five_minutes_ago = 5.minutes.ago - Time.forced_now_time = five_minutes_ago - assert_equal five_minutes_ago, Time.now - - Time.forced_now_time = nil - assert_not_equal five_minutes_ago, Time.now - end - - def test_update - stamped = Mixin.new - - assert_nil stamped.updated_at - assert_nil stamped.created_at - stamped.save - assert_equal Time.now, stamped.updated_at - assert_equal Time.now, stamped.created_at - end - - def test_create - obj = Mixin.create - assert_equal Time.now, obj.updated_at - assert_equal Time.now, obj.created_at - end - - def test_many_updates - stamped = Mixin.new - - assert_nil stamped.updated_at - assert_nil stamped.created_at - stamped.save - assert_equal Time.now, stamped.created_at - assert_equal Time.now, stamped.updated_at - - old_updated_at = stamped.updated_at - - Time.forced_now_time = 5.minutes.from_now - stamped.lft_will_change! - stamped.save - - assert_equal Time.now, stamped.updated_at - assert_equal old_updated_at, stamped.created_at - end - - def test_create_turned_off - Mixin.record_timestamps = false - - mixin = Mixin.new - - assert_nil mixin.updated_at - mixin.save - assert_nil mixin.updated_at - - # Make sure Mixin.record_timestamps gets reset, even if this test fails, - # so that other tests do not fail because Mixin.record_timestamps == false - rescue Exception => e - raise e - ensure - Mixin.record_timestamps = true - end - -end diff --git a/vendor/rails/activerecord/test/cases/modules_test.rb b/vendor/rails/activerecord/test/cases/modules_test.rb deleted file mode 100644 index 62d54015..00000000 --- a/vendor/rails/activerecord/test/cases/modules_test.rb +++ /dev/null @@ -1,109 +0,0 @@ -require "cases/helper" -require 'models/company_in_module' - -class ModulesTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :projects, :developers - - def setup - # need to make sure Object::Firm and Object::Client are not defined, - # so that constantize will not be able to cheat when having to load namespaced classes - @undefined_consts = {} - - [:Firm, :Client].each do |const| - @undefined_consts.merge! const => Object.send(:remove_const, const) if Object.const_defined?(const) - end - end - - def teardown - # reinstate the constants that we undefined in the setup - @undefined_consts.each do |constant, value| - Object.send :const_set, constant, value unless value.nil? - end - end - - def test_module_spanning_associations - firm = MyApplication::Business::Firm.find(:first) - assert !firm.clients.empty?, "Firm should have clients" - assert_nil firm.class.table_name.match('::'), "Firm shouldn't have the module appear in its table name" - end - - def test_module_spanning_has_and_belongs_to_many_associations - project = MyApplication::Business::Project.find(:first) - project.developers << MyApplication::Business::Developer.create("name" => "John") - assert "John", project.developers.last.name - end - - def test_associations_spanning_cross_modules - account = MyApplication::Billing::Account.find(:first, :order => 'id') - assert_kind_of MyApplication::Business::Firm, account.firm - assert_kind_of MyApplication::Billing::Firm, account.qualified_billing_firm - assert_kind_of MyApplication::Billing::Firm, account.unqualified_billing_firm - assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_qualified_billing_firm - assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_unqualified_billing_firm - end - - def test_find_account_and_include_company - account = MyApplication::Billing::Account.find(1, :include => :firm) - assert_kind_of MyApplication::Business::Firm, account.instance_variable_get('@firm') - assert_kind_of MyApplication::Business::Firm, account.firm - end - - def test_table_name - assert_equal 'accounts', MyApplication::Billing::Account.table_name, 'table_name for ActiveRecord model in module' - assert_equal 'companies', MyApplication::Business::Client.table_name, 'table_name for ActiveRecord model subclass' - assert_equal 'company_contacts', MyApplication::Business::Client::Contact.table_name, 'table_name for ActiveRecord model enclosed by another ActiveRecord model' - end - - def test_assign_ids - firm = MyApplication::Business::Firm.first - - assert_nothing_raised NameError, "Should be able to resolve all class constants via reflection" do - firm.client_ids = [MyApplication::Business::Client.first.id] - end - end - - # need to add an eager loading condition to force the eager loading model into - # the old join model, to test that. See http://dev.rubyonrails.org/ticket/9640 - def test_eager_loading_in_modules - clients = [] - - assert_nothing_raised NameError, "Should be able to resolve all class constants via reflection" do - clients << MyApplication::Business::Client.find(3, :include => {:firm => :account}, :conditions => 'accounts.id IS NOT NULL') - clients << MyApplication::Business::Client.find(3, :include => {:firm => :account}) - end - - clients.each do |client| - assert_no_queries do - assert_not_nil(client.firm.account) - end - end - end - - def test_module_table_name_prefix - assert_equal 'prefixed_companies', MyApplication::Business::Prefixed::Company.table_name, 'inferred table_name for ActiveRecord model in module with table_name_prefix' - assert_equal 'prefixed_companies', MyApplication::Business::Prefixed::Nested::Company.table_name, 'table_name for ActiveRecord model in nested module with a parent table_name_prefix' - assert_equal 'companies', MyApplication::Business::Prefixed::Firm.table_name, 'explicit table_name for ActiveRecord model in module with table_name_prefix should not be prefixed' - end - - def test_module_table_name_prefix_with_global_prefix - classes = [ MyApplication::Business::Company, - MyApplication::Business::Firm, - MyApplication::Business::Client, - MyApplication::Business::Client::Contact, - MyApplication::Business::Developer, - MyApplication::Business::Project, - MyApplication::Business::Prefixed::Company, - MyApplication::Business::Prefixed::Nested::Company, - MyApplication::Billing::Account ] - - ActiveRecord::Base.table_name_prefix = 'global_' - classes.each(&:reset_table_name) - assert_equal 'global_companies', MyApplication::Business::Company.table_name, 'inferred table_name for ActiveRecord model in module without table_name_prefix' - assert_equal 'prefixed_companies', MyApplication::Business::Prefixed::Company.table_name, 'inferred table_name for ActiveRecord model in module with table_name_prefix' - assert_equal 'prefixed_companies', MyApplication::Business::Prefixed::Nested::Company.table_name, 'table_name for ActiveRecord model in nested module with a parent table_name_prefix' - assert_equal 'companies', MyApplication::Business::Prefixed::Firm.table_name, 'explicit table_name for ActiveRecord model in module with table_name_prefix should not be prefixed' - ensure - ActiveRecord::Base.table_name_prefix = '' - classes.each(&:reset_table_name) - end -end diff --git a/vendor/rails/activerecord/test/cases/multiple_db_test.rb b/vendor/rails/activerecord/test/cases/multiple_db_test.rb deleted file mode 100644 index 7c3e0f2c..00000000 --- a/vendor/rails/activerecord/test/cases/multiple_db_test.rb +++ /dev/null @@ -1,85 +0,0 @@ -require "cases/helper" -require 'models/entrant' - -# So we can test whether Course.connection survives a reload. -require_dependency 'models/course' - -class MultipleDbTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @courses = create_fixtures("courses") { Course.retrieve_connection } - @entrants = create_fixtures("entrants") - end - - def test_connected - assert_not_nil Entrant.connection - assert_not_nil Course.connection - end - - def test_proper_connection - assert_not_equal(Entrant.connection, Course.connection) - assert_equal(Entrant.connection, Entrant.retrieve_connection) - assert_equal(Course.connection, Course.retrieve_connection) - assert_equal(ActiveRecord::Base.connection, Entrant.connection) - end - - def test_find - c1 = Course.find(1) - assert_equal "Ruby Development", c1.name - c2 = Course.find(2) - assert_equal "Java Development", c2.name - e1 = Entrant.find(1) - assert_equal "Ruby Developer", e1.name - e2 = Entrant.find(2) - assert_equal "Ruby Guru", e2.name - e3 = Entrant.find(3) - assert_equal "Java Lover", e3.name - end - - def test_associations - c1 = Course.find(1) - assert_equal 2, c1.entrants.count - e1 = Entrant.find(1) - assert_equal e1.course.id, c1.id - c2 = Course.find(2) - assert_equal 1, c2.entrants.count - e3 = Entrant.find(3) - assert_equal e3.course.id, c2.id - end - - def test_course_connection_should_survive_dependency_reload - assert Course.connection - - ActiveSupport::Dependencies.clear - Object.send(:remove_const, :Course) - require_dependency 'models/course' - - assert Course.connection - end - - def test_transactions_across_databases - c1 = Course.find(1) - e1 = Entrant.find(1) - - begin - Course.transaction do - Entrant.transaction do - c1.name = "Typo" - e1.name = "Typo" - c1.save - e1.save - raise "No I messed up." - end - end - rescue - # Yup caught it - end - - assert_equal "Typo", c1.name - assert_equal "Typo", e1.name - - assert_equal "Ruby Development", Course.find(1).name - assert_equal "Ruby Developer", Entrant.find(1).name - end -end diff --git a/vendor/rails/activerecord/test/cases/named_scope_test.rb b/vendor/rails/activerecord/test/cases/named_scope_test.rb deleted file mode 100644 index 755fb047..00000000 --- a/vendor/rails/activerecord/test/cases/named_scope_test.rb +++ /dev/null @@ -1,372 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/topic' -require 'models/comment' -require 'models/reply' -require 'models/author' -require 'models/developer' - -class NamedScopeTest < ActiveRecord::TestCase - fixtures :posts, :authors, :topics, :comments, :author_addresses - - def test_named_scope_with_STI - assert_equal 5,Post.with_type_self.count - assert_equal 1,SpecialPost.with_type_self.count - end - - def test_implements_enumerable - assert !Topic.find(:all).empty? - - assert_equal Topic.find(:all), Topic.base - assert_equal Topic.find(:all), Topic.base.to_a - assert_equal Topic.find(:first), Topic.base.first - assert_equal Topic.find(:all), Topic.base.map { |i| i } - end - - def test_found_items_are_cached - Topic.columns - all_posts = Topic.base - - assert_queries(1) do - all_posts.collect - all_posts.collect - end - end - - def test_reload_expires_cache_of_found_items - all_posts = Topic.base - all_posts.inspect - - new_post = Topic.create! - assert !all_posts.include?(new_post) - assert all_posts.reload.include?(new_post) - end - - def test_delegates_finds_and_calculations_to_the_base_class - assert !Topic.find(:all).empty? - - assert_equal Topic.find(:all), Topic.base.find(:all) - assert_equal Topic.find(:first), Topic.base.find(:first) - assert_equal Topic.count, Topic.base.count - assert_equal Topic.average(:replies_count), Topic.base.average(:replies_count) - end - - def test_scope_should_respond_to_own_methods_and_methods_of_the_proxy - assert Topic.approved.respond_to?(:proxy_found) - assert Topic.approved.respond_to?(:count) - assert Topic.approved.respond_to?(:length) - end - - def test_respond_to_respects_include_private_parameter - assert !Topic.approved.respond_to?(:load_found) - assert Topic.approved.respond_to?(:load_found, true) - end - - def test_subclasses_inherit_scopes - assert Topic.scopes.include?(:base) - - assert Reply.scopes.include?(:base) - assert_equal Reply.find(:all), Reply.base - end - - def test_scopes_with_options_limit_finds_to_those_matching_the_criteria_specified - assert !Topic.find(:all, :conditions => {:approved => true}).empty? - - assert_equal Topic.find(:all, :conditions => {:approved => true}), Topic.approved - assert_equal Topic.count(:conditions => {:approved => true}), Topic.approved.count - end - - def test_scopes_with_string_name_can_be_composed - # NOTE that scopes defined with a string as a name worked on their own - # but when called on another scope the other scope was completely replaced - assert_equal Topic.replied.approved, Topic.replied.approved_as_string - end - - def test_scopes_can_be_specified_with_deep_hash_conditions - assert_equal Topic.replied.approved, Topic.replied.approved_as_hash_condition - end - - def test_scopes_are_composable - assert_equal (approved = Topic.find(:all, :conditions => {:approved => true})), Topic.approved - assert_equal (replied = Topic.find(:all, :conditions => 'replies_count > 0')), Topic.replied - assert !(approved == replied) - assert !(approved & replied).empty? - - assert_equal approved & replied, Topic.approved.replied - end - - def test_procedural_scopes - topics_written_before_the_third = Topic.find(:all, :conditions => ['written_on < ?', topics(:third).written_on]) - topics_written_before_the_second = Topic.find(:all, :conditions => ['written_on < ?', topics(:second).written_on]) - assert_not_equal topics_written_before_the_second, topics_written_before_the_third - - assert_equal topics_written_before_the_third, Topic.written_before(topics(:third).written_on) - assert_equal topics_written_before_the_second, Topic.written_before(topics(:second).written_on) - end - - def test_procedural_scopes_returning_nil - all_topics = Topic.find(:all) - - assert_equal all_topics, Topic.written_before(nil) - end - - def test_scopes_with_joins - address = author_addresses(:david_address) - posts_with_authors_at_address = Post.find( - :all, :joins => 'JOIN authors ON authors.id = posts.author_id', - :conditions => [ 'authors.author_address_id = ?', address.id ] - ) - assert_equal posts_with_authors_at_address, Post.with_authors_at_address(address) - end - - def test_scopes_with_joins_respects_custom_select - address = author_addresses(:david_address) - posts_with_authors_at_address_titles = Post.find(:all, - :select => 'title', - :joins => 'JOIN authors ON authors.id = posts.author_id', - :conditions => [ 'authors.author_address_id = ?', address.id ] - ) - assert_equal posts_with_authors_at_address_titles, Post.with_authors_at_address(address).find(:all, :select => 'title') - end - - def test_extensions - assert_equal 1, Topic.anonymous_extension.one - assert_equal 2, Topic.named_extension.two - end - - def test_multiple_extensions - assert_equal 2, Topic.multiple_extensions.extension_two - assert_equal 1, Topic.multiple_extensions.extension_one - end - - def test_has_many_associations_have_access_to_named_scopes - assert_not_equal Post.containing_the_letter_a, authors(:david).posts - assert !Post.containing_the_letter_a.empty? - - assert_equal authors(:david).posts & Post.containing_the_letter_a, authors(:david).posts.containing_the_letter_a - end - - def test_nested_named_scopes_doesnt_duplicate_conditions_on_child_scopes - comments_scope = posts(:welcome).comments.send(:construct_sql) - named_scope_sql_conditions = posts(:welcome).comments.containing_the_letter_e.send(:current_scoped_methods)[:find][:conditions] - assert_no_match /#{comments_scope}.*#{comments_scope}/i, named_scope_sql_conditions - end - - def test_has_many_through_associations_have_access_to_named_scopes - assert_not_equal Comment.containing_the_letter_e, authors(:david).comments - assert !Comment.containing_the_letter_e.empty? - - assert_equal authors(:david).comments & Comment.containing_the_letter_e, authors(:david).comments.containing_the_letter_e - end - - def test_named_scopes_honor_current_scopes_from_when_defined - assert !Post.ranked_by_comments.limit(5).empty? - assert !authors(:david).posts.ranked_by_comments.limit(5).empty? - assert_not_equal Post.ranked_by_comments.limit(5), authors(:david).posts.ranked_by_comments.limit(5) - assert_not_equal Post.top(5), authors(:david).posts.top(5) - assert_equal authors(:david).posts.ranked_by_comments.limit(5), authors(:david).posts.top(5) - assert_equal Post.ranked_by_comments.limit(5), Post.top(5) - end - - def test_active_records_have_scope_named__all__ - assert !Topic.find(:all).empty? - - assert_equal Topic.find(:all), Topic.base - end - - def test_active_records_have_scope_named__scoped__ - assert !Topic.find(:all, scope = {:conditions => "content LIKE '%Have%'"}).empty? - - assert_equal Topic.find(:all, scope), Topic.scoped(scope) - end - - def test_proxy_options - expected_proxy_options = { :conditions => { :approved => true } } - assert_equal expected_proxy_options, Topic.approved.proxy_options - end - - def test_first_and_last_should_support_find_options - assert_equal Topic.base.first(:order => 'title'), Topic.base.find(:first, :order => 'title') - assert_equal Topic.base.last(:order => 'title'), Topic.base.find(:last, :order => 'title') - end - - def test_first_and_last_should_allow_integers_for_limit - assert_equal Topic.base.first(2), Topic.base.to_a.first(2) - assert_equal Topic.base.last(2), Topic.base.to_a.last(2) - end - - def test_first_and_last_should_not_use_query_when_results_are_loaded - topics = Topic.base - topics.reload # force load - assert_no_queries do - topics.first - topics.last - end - end - - def test_first_and_last_find_options_should_use_query_when_results_are_loaded - topics = Topic.base - topics.reload # force load - assert_queries(2) do - topics.first(:order => 'title') - topics.last(:order => 'title') - end - end - - def test_empty_should_not_load_results - topics = Topic.base - assert_queries(2) do - topics.empty? # use count query - topics.collect # force load - topics.empty? # use loaded (no query) - end - end - - def test_any_should_not_load_results - topics = Topic.base - assert_queries(2) do - topics.any? # use count query - topics.collect # force load - topics.any? # use loaded (no query) - end - end - - def test_any_should_call_proxy_found_if_using_a_block - topics = Topic.base - assert_queries(1) do - topics.expects(:empty?).never - topics.any? { true } - end - end - - def test_any_should_not_fire_query_if_named_scope_loaded - topics = Topic.base - topics.collect # force load - assert_no_queries { assert topics.any? } - end - - def test_should_build_with_proxy_options - topic = Topic.approved.build({}) - assert topic.approved - end - - def test_should_build_new_with_proxy_options - topic = Topic.approved.new - assert topic.approved - end - - def test_should_create_with_proxy_options - topic = Topic.approved.create({}) - assert topic.approved - end - - def test_should_create_with_bang_with_proxy_options - topic = Topic.approved.create!({}) - assert topic.approved - end - - def test_should_build_with_proxy_options_chained - topic = Topic.approved.by_lifo.build({}) - assert topic.approved - assert_equal 'lifo', topic.author_name - end - - def test_find_all_should_behave_like_select - assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved) - end - - def test_rand_should_select_a_random_object_from_proxy - assert Topic.approved.sample.is_a?(Topic) - end - - def test_should_use_where_in_query_for_named_scope - assert_equal Developer.find_all_by_name('Jamis').to_set, Developer.find_all_by_id(Developer.jamises).to_set - end - - def test_size_should_use_count_when_results_are_not_loaded - topics = Topic.base - assert_queries(1) do - assert_sql(/COUNT/i) { topics.size } - end - end - - def test_size_should_use_length_when_results_are_loaded - topics = Topic.base - topics.reload # force load - assert_no_queries do - topics.size # use loaded (no query) - end - end - - def test_chaining_with_duplicate_joins - join = "INNER JOIN comments ON comments.post_id = posts.id" - post = Post.find(1) - assert_equal post.comments.size, Post.scoped(:joins => join).scoped(:joins => join, :conditions => "posts.id = #{post.id}").size - end - - def test_chaining_should_use_latest_conditions_when_creating - post = Topic.rejected.new - assert !post.approved? - - post = Topic.rejected.approved.new - assert post.approved? - - post = Topic.approved.rejected.new - assert !post.approved? - - post = Topic.approved.rejected.approved.new - assert post.approved? - end - - def test_chaining_should_use_latest_conditions_when_searching - # Normal hash conditions - assert_equal Topic.all(:conditions => {:approved => true}), Topic.rejected.approved.all - assert_equal Topic.all(:conditions => {:approved => false}), Topic.approved.rejected.all - - # Nested hash conditions with same keys - assert_equal [posts(:sti_comments)], Post.with_special_comments.with_very_special_comments.all - - # Nested hash conditions with different keys - assert_equal [posts(:sti_comments)], Post.with_special_comments.with_post(4).all.uniq - end - - def test_named_scopes_batch_finders - assert_equal 3, Topic.approved.count - - assert_queries(4) do - Topic.approved.find_each(:batch_size => 1) {|t| assert t.approved? } - end - - assert_queries(2) do - Topic.approved.find_in_batches(:batch_size => 2) do |group| - group.each {|t| assert t.approved? } - end - end - end - - def test_table_names_for_chaining_scopes_with_and_without_table_name_included - assert_nothing_raised do - Comment.for_first_post.for_first_author.all - end - end -end - -class DynamicScopeMatchTest < ActiveRecord::TestCase - def test_scoped_by_no_match - assert_nil ActiveRecord::DynamicScopeMatch.match("not_scoped_at_all") - end - - def test_scoped_by - match = ActiveRecord::DynamicScopeMatch.match("scoped_by_age_and_sex_and_location") - assert_not_nil match - assert match.scope? - assert_equal %w(age sex location), match.attribute_names - end -end - -class DynamicScopeTest < ActiveRecord::TestCase - def test_dynamic_scope - assert_equal Post.scoped_by_author_id(1).find(1), Post.find(1) - assert_equal Post.scoped_by_author_id_and_title(1, "Welcome to the weblog").first, Post.find(:first, :conditions => { :author_id => 1, :title => "Welcome to the weblog"}) - end -end diff --git a/vendor/rails/activerecord/test/cases/nested_attributes_test.rb b/vendor/rails/activerecord/test/cases/nested_attributes_test.rb deleted file mode 100644 index 6b144a14..00000000 --- a/vendor/rails/activerecord/test/cases/nested_attributes_test.rb +++ /dev/null @@ -1,840 +0,0 @@ -require "cases/helper" -require "models/pirate" -require "models/ship" -require "models/ship_part" -require "models/bird" -require "models/parrot" -require "models/treasure" -require "models/man" -require "models/interest" -require "models/owner" -require "models/pet" - -module AssertRaiseWithMessage - def assert_raise_with_message(expected_exception, expected_message) - begin - error_raised = false - yield - rescue expected_exception => error - error_raised = true - actual_message = error.message - end - assert error_raised - assert_equal expected_message, actual_message - end -end - -class TestNestedAttributesInGeneral < ActiveRecord::TestCase - include AssertRaiseWithMessage - - def teardown - Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_base_should_have_an_empty_nested_attributes_options - assert_equal Hash.new, ActiveRecord::Base.nested_attributes_options - end - - def test_should_add_a_proc_to_nested_attributes_options - assert_equal ActiveRecord::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC, - Pirate.nested_attributes_options[:birds_with_reject_all_blank][:reject_if] - - [:parrots, :birds].each do |name| - assert_instance_of Proc, Pirate.nested_attributes_options[name][:reject_if] - end - end - - def test_should_not_build_a_new_record_if_reject_all_blank_returns_false - pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - pirate.birds_with_reject_all_blank_attributes = [{:name => '', :color => ''}] - pirate.save! - - assert pirate.birds_with_reject_all_blank.empty? - end - - def test_should_build_a_new_record_if_reject_all_blank_does_not_return_false - pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - pirate.birds_with_reject_all_blank_attributes = [{:name => 'Tweetie', :color => ''}] - pirate.save! - - assert_equal 1, pirate.birds_with_reject_all_blank.count - end - - def test_should_raise_an_ArgumentError_for_non_existing_associations - assert_raise_with_message ArgumentError, "No association found for name `honesty'. Has it been defined yet?" do - Pirate.accepts_nested_attributes_for :honesty - end - end - - def test_should_disable_allow_destroy_by_default - Pirate.accepts_nested_attributes_for :ship - - pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - ship = pirate.create_ship(:name => 'Nights Dirty Lightning') - - assert_no_difference('Ship.count') do - pirate.update_attributes(:ship_attributes => { '_destroy' => true }) - end - end - - def test_a_model_should_respond_to_underscore_destroy_and_return_if_it_is_marked_for_destruction - ship = Ship.create!(:name => 'Nights Dirty Lightning') - assert !ship._destroy - ship.mark_for_destruction - assert ship._destroy - end - - def test_reject_if_method_without_arguments - Pirate.accepts_nested_attributes_for :ship, :reject_if => :new_record? - - pirate = Pirate.new(:catchphrase => "Stop wastin' me time") - pirate.ship_attributes = { :name => 'Black Pearl' } - assert_no_difference('Ship.count') { pirate.save! } - end - - def test_reject_if_method_with_arguments - Pirate.accepts_nested_attributes_for :ship, :reject_if => :reject_empty_ships_on_create - - pirate = Pirate.new(:catchphrase => "Stop wastin' me time") - pirate.ship_attributes = { :name => 'Red Pearl', :_reject_me_if_new => true } - assert_no_difference('Ship.count') { pirate.save! } - - # pirate.reject_empty_ships_on_create returns false for saved records - pirate.ship_attributes = { :name => 'Red Pearl', :_reject_me_if_new => true } - assert_difference('Ship.count') { pirate.save! } - end - - def test_reject_if_with_indifferent_keys - Pirate.accepts_nested_attributes_for :ship, :reject_if => proc {|attributes| attributes[:name].blank? } - - pirate = Pirate.new(:catchphrase => "Stop wastin' me time") - pirate.ship_attributes = { :name => 'Hello Pearl' } - assert_difference('Ship.count') { pirate.save! } - end -end - -class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase - include AssertRaiseWithMessage - - def setup - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @ship = @pirate.create_ship(:name => 'Nights Dirty Lightning') - end - - def test_should_raise_argument_error_if_trying_to_build_polymorphic_belongs_to - assert_raise_with_message ArgumentError, "Cannot build association looter. Are you trying to build a polymorphic one-to-one association?" do - Treasure.new(:name => 'pearl', :looter_attributes => {:catchphrase => "Arrr"}) - end - end - - def test_should_define_an_attribute_writer_method_for_the_association - assert_respond_to @pirate, :ship_attributes= - end - - def test_should_build_a_new_record_if_there_is_no_id - @ship.destroy - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger' } - - assert @pirate.ship.new_record? - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_not_build_a_new_record_if_there_is_no_id_and_destroy_is_truthy - @ship.destroy - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger', :_destroy => '1' } - - assert_nil @pirate.ship - end - - def test_should_not_build_a_new_record_if_a_reject_if_proc_returns_false - @ship.destroy - @pirate.reload.ship_attributes = {} - - assert_nil @pirate.ship - end - - def test_should_replace_an_existing_record_if_there_is_no_id - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger' } - - assert @pirate.ship.new_record? - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - assert_equal 'Nights Dirty Lightning', @ship.name - end - - def test_should_not_replace_an_existing_record_if_there_is_no_id_and_destroy_is_truthy - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger', :_destroy => '1' } - - assert_equal @ship, @pirate.ship - assert_equal 'Nights Dirty Lightning', @pirate.ship.name - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_id - @pirate.reload.ship_attributes = { :id => @ship.id, :name => 'Davy Jones Gold Dagger' } - - assert_equal @ship, @pirate.ship - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record - assert_raise_with_message ActiveRecord::RecordNotFound, "Couldn't find Ship with ID=1234567890 for Pirate with ID=#{@pirate.id}" do - @pirate.ship_attributes = { :id => 1234567890 } - end - end - - def test_should_take_a_hash_with_string_keys_and_update_the_associated_model - @pirate.reload.ship_attributes = { 'id' => @ship.id, 'name' => 'Davy Jones Gold Dagger' } - - assert_equal @ship, @pirate.ship - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_composite_id - @ship.stubs(:id).returns('ABC1X') - @pirate.ship_attributes = { :id => @ship.id, :name => 'Davy Jones Gold Dagger' } - - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_destroy_an_existing_record_if_there_is_a_matching_id_and_destroy_is_truthy - @pirate.ship.destroy - [1, '1', true, 'true'].each do |truth| - @pirate.reload.create_ship(:name => 'Mister Pablo') - assert_difference('Ship.count', -1) do - @pirate.update_attribute(:ship_attributes, { :id => @pirate.ship.id, :_destroy => truth }) - end - end - end - - def test_should_not_destroy_an_existing_record_if_destroy_is_not_truthy - [nil, '0', 0, 'false', false].each do |not_truth| - assert_no_difference('Ship.count') do - @pirate.update_attribute(:ship_attributes, { :id => @pirate.ship.id, :_destroy => not_truth }) - end - end - end - - def test_should_not_destroy_an_existing_record_if_allow_destroy_is_false - Pirate.accepts_nested_attributes_for :ship, :allow_destroy => false, :reject_if => proc { |attributes| attributes.empty? } - - assert_no_difference('Ship.count') do - @pirate.update_attribute(:ship_attributes, { :id => @pirate.ship.id, :_destroy => '1' }) - end - - Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_should_also_work_with_a_HashWithIndifferentAccess - @pirate.ship_attributes = HashWithIndifferentAccess.new(:id => @ship.id, :name => 'Davy Jones Gold Dagger') - - assert !@pirate.ship.new_record? - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_work_with_update_attributes_as_well - @pirate.update_attributes({ :catchphrase => 'Arr', :ship_attributes => { :id => @ship.id, :name => 'Mister Pablo' } }) - @pirate.reload - - assert_equal 'Arr', @pirate.catchphrase - assert_equal 'Mister Pablo', @pirate.ship.name - end - - def test_should_not_destroy_the_associated_model_until_the_parent_is_saved - assert_no_difference('Ship.count') do - @pirate.attributes = { :ship_attributes => { :id => @ship.id, :_destroy => '1' } } - end - assert_difference('Ship.count', -1) do - @pirate.save - end - end - - def test_should_automatically_enable_autosave_on_the_association - assert Pirate.reflect_on_association(:ship).options[:autosave] - end - - def test_should_accept_update_only_option - @pirate.update_attribute(:update_only_ship_attributes, { :id => @pirate.ship.id, :name => 'Mayflower' }) - end - - def test_should_create_new_model_when_nothing_is_there_and_update_only_is_true - @ship.delete - assert_difference('Ship.count', 1) do - @pirate.reload.update_attribute(:update_only_ship_attributes, { :name => 'Mayflower' }) - end - end - - def test_should_update_existing_when_update_only_is_true_and_no_id_is_given - @ship.delete - @ship = @pirate.create_update_only_ship(:name => 'Nights Dirty Lightning') - - assert_no_difference('Ship.count') do - @pirate.update_attributes(:update_only_ship_attributes => { :name => 'Mayflower' }) - end - assert_equal 'Mayflower', @ship.reload.name - end -end - -class TestNestedAttributesOnABelongsToAssociation < ActiveRecord::TestCase - include AssertRaiseWithMessage - - def setup - @ship = Ship.new(:name => 'Nights Dirty Lightning') - @pirate = @ship.build_pirate(:catchphrase => 'Aye') - @ship.save! - end - - def test_should_define_an_attribute_writer_method_for_the_association - assert_respond_to @ship, :pirate_attributes= - end - - def test_should_build_a_new_record_if_there_is_no_id - @pirate.destroy - @ship.reload.pirate_attributes = { :catchphrase => 'Arr' } - - assert @ship.pirate.new_record? - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_not_build_a_new_record_if_there_is_no_id_and_destroy_is_truthy - @pirate.destroy - @ship.reload.pirate_attributes = { :catchphrase => 'Arr', :_destroy => '1' } - - assert_nil @ship.pirate - end - - def test_should_not_build_a_new_record_if_a_reject_if_proc_returns_false - @pirate.destroy - @ship.reload.pirate_attributes = {} - - assert_nil @ship.pirate - end - - def test_should_replace_an_existing_record_if_there_is_no_id - @ship.reload.pirate_attributes = { :catchphrase => 'Arr' } - - assert @ship.pirate.new_record? - assert_equal 'Arr', @ship.pirate.catchphrase - assert_equal 'Aye', @pirate.catchphrase - end - - def test_should_not_replace_an_existing_record_if_there_is_no_id_and_destroy_is_truthy - @ship.reload.pirate_attributes = { :catchphrase => 'Arr', :_destroy => '1' } - - assert_equal @pirate, @ship.pirate - assert_equal 'Aye', @ship.pirate.catchphrase - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_id - @ship.reload.pirate_attributes = { :id => @pirate.id, :catchphrase => 'Arr' } - - assert_equal @pirate, @ship.pirate - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record - assert_raise_with_message ActiveRecord::RecordNotFound, "Couldn't find Pirate with ID=1234567890 for Ship with ID=#{@ship.id}" do - @ship.pirate_attributes = { :id => 1234567890 } - end - end - - def test_should_take_a_hash_with_string_keys_and_update_the_associated_model - @ship.reload.pirate_attributes = { 'id' => @pirate.id, 'catchphrase' => 'Arr' } - - assert_equal @pirate, @ship.pirate - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_composite_id - @pirate.stubs(:id).returns('ABC1X') - @ship.pirate_attributes = { :id => @pirate.id, :catchphrase => 'Arr' } - - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_destroy_an_existing_record_if_there_is_a_matching_id_and_destroy_is_truthy - @ship.pirate.destroy - [1, '1', true, 'true'].each do |truth| - @ship.reload.create_pirate(:catchphrase => 'Arr') - assert_difference('Pirate.count', -1) do - @ship.update_attribute(:pirate_attributes, { :id => @ship.pirate.id, :_destroy => truth }) - end - end - end - - def test_should_not_destroy_an_existing_record_if_destroy_is_not_truthy - [nil, '0', 0, 'false', false].each do |not_truth| - assert_no_difference('Pirate.count') do - @ship.update_attribute(:pirate_attributes, { :id => @ship.pirate.id, :_destroy => not_truth }) - end - end - end - - def test_should_not_destroy_an_existing_record_if_allow_destroy_is_false - Ship.accepts_nested_attributes_for :pirate, :allow_destroy => false, :reject_if => proc { |attributes| attributes.empty? } - - assert_no_difference('Pirate.count') do - @ship.update_attribute(:pirate_attributes, { :id => @ship.pirate.id, :_destroy => '1' }) - end - - Ship.accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_should_work_with_update_attributes_as_well - @ship.update_attributes({ :name => 'Mister Pablo', :pirate_attributes => { :catchphrase => 'Arr' } }) - @ship.reload - - assert_equal 'Mister Pablo', @ship.name - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_not_destroy_the_associated_model_until_the_parent_is_saved - assert_no_difference('Pirate.count') do - @ship.attributes = { :pirate_attributes => { :id => @ship.pirate.id, '_destroy' => true } } - end - assert_difference('Pirate.count', -1) { @ship.save } - end - - def test_should_automatically_enable_autosave_on_the_association - assert Ship.reflect_on_association(:pirate).options[:autosave] - end - - def test_should_create_new_model_when_nothing_is_there_and_update_only_is_true - @pirate.delete - assert_difference('Pirate.count', 1) do - @ship.reload.update_attribute(:update_only_pirate_attributes, { :catchphrase => 'Arr' }) - end - end - - def test_should_update_existing_when_update_only_is_true_and_no_id_is_given - @pirate.delete - @pirate = @ship.create_update_only_pirate(:catchphrase => 'Aye') - - assert_no_difference('Pirate.count') do - @ship.update_attributes(:update_only_pirate_attributes => { :catchphrase => 'Arr' }) - end - assert_equal 'Arr', @pirate.reload.catchphrase - end -end - -module NestedAttributesOnACollectionAssociationTests - include AssertRaiseWithMessage - - def test_should_define_an_attribute_writer_method_for_the_association - assert_respond_to @pirate, association_setter - end - - def test_should_save_only_one_association_on_create - pirate = Pirate.create!({ - :catchphrase => 'Arr', - association_getter => { 'foo' => { :name => 'Grace OMalley' } } - }) - - assert_equal 1, pirate.reload.send(@association_name).count - end - - def test_should_take_a_hash_with_string_keys_and_assign_the_attributes_to_the_associated_models - @alternate_params[association_getter].stringify_keys! - @pirate.update_attributes @alternate_params - assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.reload.name, @child_2.reload.name] - end - - def test_should_take_an_array_and_assign_the_attributes_to_the_associated_models - @pirate.send(association_setter, @alternate_params[association_getter].values) - @pirate.save - assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.reload.name, @child_2.reload.name] - end - - def test_should_also_work_with_a_HashWithIndifferentAccess - @pirate.send(association_setter, HashWithIndifferentAccess.new('foo' => HashWithIndifferentAccess.new(:id => @child_1.id, :name => 'Grace OMalley'))) - @pirate.save - assert_equal 'Grace OMalley', @child_1.reload.name - end - - def test_should_take_a_hash_and_assign_the_attributes_to_the_associated_models - @pirate.attributes = @alternate_params - assert_equal 'Grace OMalley', @pirate.send(@association_name).first.name - assert_equal 'Privateers Greed', @pirate.send(@association_name).last.name - end - - def test_should_not_load_association_when_updating_existing_records - @pirate.reload - @pirate.send(association_setter, [{ :id => @child_1.id, :name => 'Grace OMalley' }]) - assert ! @pirate.send(@association_name).loaded? - - @pirate.save - assert ! @pirate.send(@association_name).loaded? - assert_equal 'Grace OMalley', @child_1.reload.name - end - - def test_should_not_overwrite_unsaved_updates_when_loading_association - @pirate.reload - @pirate.send(association_setter, [{ :id => @child_1.id, :name => 'Grace OMalley' }]) - assert_equal 'Grace OMalley', @pirate.send(@association_name).send(:load_target).find { |r| r.id == @child_1.id }.name - end - - def test_should_preserve_order_when_not_overwriting_unsaved_updates - @pirate.reload - @pirate.send(association_setter, [{ :id => @child_1.id, :name => 'Grace OMalley' }]) - assert_equal @child_1.id, @pirate.send(@association_name).send(:load_target).first.id - end - - def test_should_refresh_saved_records_when_not_overwriting_unsaved_updates - @pirate.reload - record = @pirate.class.reflect_on_association(@association_name).klass.new(:name => 'Grace OMalley') - @pirate.send(@association_name) << record - record.save! - @pirate.send(@association_name).last.update_attributes!(:name => 'Polly') - assert_equal 'Polly', @pirate.send(@association_name).send(:load_target).last.name - end - - def test_should_not_remove_scheduled_destroys_when_loading_association - @pirate.reload - @pirate.send(association_setter, [{ :id => @child_1.id, :_destroy => '1' }]) - assert @pirate.send(@association_name).send(:load_target).find { |r| r.id == @child_1.id }.marked_for_destruction? - end - - def test_should_take_a_hash_with_composite_id_keys_and_assign_the_attributes_to_the_associated_models - @child_1.stubs(:id).returns('ABC1X') - @child_2.stubs(:id).returns('ABC2X') - - @pirate.attributes = { - association_getter => [ - { :id => @child_1.id, :name => 'Grace OMalley' }, - { :id => @child_2.id, :name => 'Privateers Greed' } - ] - } - - assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.name, @child_2.name] - end - - def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record - assert_raise_with_message ActiveRecord::RecordNotFound, "Couldn't find #{@child_1.class.name} with ID=1234567890 for Pirate with ID=#{@pirate.id}" do - @pirate.attributes = { association_getter => [{ :id => 1234567890 }] } - end - end - - def test_should_automatically_build_new_associated_models_for_each_entry_in_a_hash_where_the_id_is_missing - @pirate.send(@association_name).destroy_all - @pirate.reload.attributes = { - association_getter => { 'foo' => { :name => 'Grace OMalley' }, 'bar' => { :name => 'Privateers Greed' }} - } - - assert @pirate.send(@association_name).first.new_record? - assert_equal 'Grace OMalley', @pirate.send(@association_name).first.name - - assert @pirate.send(@association_name).last.new_record? - assert_equal 'Privateers Greed', @pirate.send(@association_name).last.name - end - - def test_should_not_assign_destroy_key_to_a_record - assert_nothing_raised ActiveRecord::UnknownAttributeError do - @pirate.send(association_setter, { 'foo' => { '_destroy' => '0' }}) - end - end - - def test_should_ignore_new_associated_records_with_truthy_destroy_attribute - @pirate.send(@association_name).destroy_all - @pirate.reload.attributes = { - association_getter => { - 'foo' => { :name => 'Grace OMalley' }, - 'bar' => { :name => 'Privateers Greed', '_destroy' => '1' } - } - } - - assert_equal 1, @pirate.send(@association_name).length - assert_equal 'Grace OMalley', @pirate.send(@association_name).first.name - end - - def test_should_ignore_new_associated_records_if_a_reject_if_proc_returns_false - @alternate_params[association_getter]['baz'] = {} - assert_no_difference("@pirate.send(@association_name).count") do - @pirate.attributes = @alternate_params - end - end - - def test_should_sort_the_hash_by_the_keys_before_building_new_associated_models - attributes = ActiveSupport::OrderedHash.new - attributes['123726353'] = { :name => 'Grace OMalley' } - attributes['2'] = { :name => 'Privateers Greed' } # 2 is lower then 123726353 - @pirate.send(association_setter, attributes) - - assert_equal ['Posideons Killer', 'Killer bandita Dionne', 'Privateers Greed', 'Grace OMalley'].to_set, @pirate.send(@association_name).map(&:name).to_set - end - - def test_should_raise_an_argument_error_if_something_else_than_a_hash_is_passed - assert_nothing_raised(ArgumentError) { @pirate.send(association_setter, {}) } - assert_nothing_raised(ArgumentError) { @pirate.send(association_setter, ActiveSupport::OrderedHash.new) } - - assert_raise_with_message ArgumentError, 'Hash or Array expected, got String ("foo")' do - @pirate.send(association_setter, "foo") - end - end - - def test_should_work_with_update_attributes_as_well - @pirate.update_attributes(:catchphrase => 'Arr', - association_getter => { 'foo' => { :id => @child_1.id, :name => 'Grace OMalley' }}) - - assert_equal 'Grace OMalley', @child_1.reload.name - end - - def test_should_update_existing_records_and_add_new_ones_that_have_no_id - @alternate_params[association_getter]['baz'] = { :name => 'Buccaneers Servant' } - assert_difference('@pirate.send(@association_name).count', +1) do - @pirate.update_attributes @alternate_params - end - assert_equal ['Grace OMalley', 'Privateers Greed', 'Buccaneers Servant'].to_set, @pirate.reload.send(@association_name).map(&:name).to_set - end - - def test_should_be_possible_to_destroy_a_record - ['1', 1, 'true', true].each do |true_variable| - record = @pirate.reload.send(@association_name).create!(:name => 'Grace OMalley') - @pirate.send(association_setter, - @alternate_params[association_getter].merge('baz' => { :id => record.id, '_destroy' => true_variable }) - ) - - assert_difference('@pirate.send(@association_name).count', -1) do - @pirate.save - end - end - end - - def test_should_not_destroy_the_associated_model_with_a_non_truthy_argument - [nil, '', '0', 0, 'false', false].each do |false_variable| - @alternate_params[association_getter]['foo']['_destroy'] = false_variable - assert_no_difference('@pirate.send(@association_name).count') do - @pirate.update_attributes(@alternate_params) - end - end - end - - def test_should_not_destroy_the_associated_model_until_the_parent_is_saved - assert_no_difference('@pirate.send(@association_name).count') do - @pirate.send(association_setter, @alternate_params[association_getter].merge('baz' => { :id => @child_1.id, '_destroy' => true })) - end - assert_difference('@pirate.send(@association_name).count', -1) { @pirate.save } - end - - def test_should_automatically_enable_autosave_on_the_association - assert Pirate.reflect_on_association(@association_name).options[:autosave] - end - - def test_validate_presence_of_parent_works_with_inverse_of - Man.accepts_nested_attributes_for(:interests) - assert_equal :man, Man.reflect_on_association(:interests).options[:inverse_of] - assert_equal :interests, Interest.reflect_on_association(:man).options[:inverse_of] - - repair_validations(Interest) do - Interest.validates_presence_of(:man) - assert_difference 'Man.count' do - assert_difference 'Interest.count', 2 do - man = Man.create!(:name => 'John', - :interests_attributes => [{:topic=>'Cars'}, {:topic=>'Sports'}]) - assert_equal 2, man.interests.count - end - end - end - end - - def test_validate_presence_of_parent_fails_without_inverse_of - Man.accepts_nested_attributes_for(:interests) - Man.reflect_on_association(:interests).options.delete(:inverse_of) - Interest.reflect_on_association(:man).options.delete(:inverse_of) - - repair_validations(Interest) do - Interest.validates_presence_of(:man) - assert_no_difference ['Man.count', 'Interest.count'] do - man = Man.create(:name => 'John', - :interests_attributes => [{:topic=>'Cars'}, {:topic=>'Sports'}]) - assert !man.errors[:'interests.man'].empty? - end - end - # restore :inverse_of - Man.reflect_on_association(:interests).options[:inverse_of] = :man - Interest.reflect_on_association(:man).options[:inverse_of] = :interests - end - - private - - def association_setter - @association_setter ||= "#{@association_name}_attributes=".to_sym - end - - def association_getter - @association_getter ||= "#{@association_name}_attributes".to_sym - end -end - -class TestNestedAttributesOnAHasManyAssociation < ActiveRecord::TestCase - def setup - @association_type = :has_many - @association_name = :birds - - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @pirate.birds.create!(:name => 'Posideons Killer') - @pirate.birds.create!(:name => 'Killer bandita Dionne') - - @child_1, @child_2 = @pirate.birds - - @alternate_params = { - :birds_attributes => { - 'foo' => { :id => @child_1.id, :name => 'Grace OMalley' }, - 'bar' => { :id => @child_2.id, :name => 'Privateers Greed' } - } - } - end - - include NestedAttributesOnACollectionAssociationTests -end - -class TestNestedAttributesOnAHasAndBelongsToManyAssociation < ActiveRecord::TestCase - def setup - @association_type = :has_and_belongs_to_many - @association_name = :parrots - - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @pirate.parrots.create!(:name => 'Posideons Killer') - @pirate.parrots.create!(:name => 'Killer bandita Dionne') - - @child_1, @child_2 = @pirate.parrots - - @alternate_params = { - :parrots_attributes => { - 'foo' => { :id => @child_1.id, :name => 'Grace OMalley' }, - 'bar' => { :id => @child_2.id, :name => 'Privateers Greed' } - } - } - end - - include NestedAttributesOnACollectionAssociationTests -end - -class TestNestedAttributesLimit < ActiveRecord::TestCase - def setup - Pirate.accepts_nested_attributes_for :parrots, :limit => 2 - - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - end - - def teardown - Pirate.accepts_nested_attributes_for :parrots, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_limit_with_less_records - @pirate.attributes = { :parrots_attributes => { 'foo' => { :name => 'Big Big Love' } } } - assert_difference('Parrot.count') { @pirate.save! } - end - - def test_limit_with_number_exact_records - @pirate.attributes = { :parrots_attributes => { 'foo' => { :name => 'Lovely Day' }, 'bar' => { :name => 'Blown Away' } } } - assert_difference('Parrot.count', 2) { @pirate.save! } - end - - def test_limit_with_exceeding_records - assert_raises(ActiveRecord::NestedAttributes::TooManyRecords) do - @pirate.attributes = { :parrots_attributes => { 'foo' => { :name => 'Lovely Day' }, - 'bar' => { :name => 'Blown Away' }, - 'car' => { :name => 'The Happening' }} } - end - end -end - -class TestNestedAttributesWithNonStandardPrimaryKeys < ActiveRecord::TestCase - fixtures :owners, :pets - - def setup - Owner.accepts_nested_attributes_for :pets - - @owner = owners(:ashley) - @pet1, @pet2 = pets(:chew), pets(:mochi) - - @params = { - :pets_attributes => { - '0' => { :id => @pet1.id, :name => 'Foo' }, - '1' => { :id => @pet2.id, :name => 'Bar' } - } - } - end - - def test_should_update_existing_records_with_non_standard_primary_key - @owner.update_attributes(@params) - assert_equal ['Foo', 'Bar'], @owner.pets.map(&:name) - end -end - -class TestHasOneAutosaveAssoictaionWhichItselfHasAutosaveAssociations < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create!(:catchphrase => "My baby takes tha mornin' train!") - @ship = @pirate.create_ship(:name => "The good ship Dollypop") - @part = @ship.parts.create!(:name => "Mast") - @trinket = @part.trinkets.create!(:name => "Necklace") - end - - test "when great-grandchild changed in memory, saving parent should save great-grandchild" do - @trinket.name = "changed" - @pirate.save - assert_equal "changed", @trinket.reload.name - end - - test "when great-grandchild changed via attributes, saving parent should save great-grandchild" do - @pirate.attributes = {:ship_attributes => {:id => @ship.id, :parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :name => "changed"}]}]}} - @pirate.save - assert_equal "changed", @trinket.reload.name - end - - test "when great-grandchild marked_for_destruction via attributes, saving parent should destroy great-grandchild" do - @pirate.attributes = {:ship_attributes => {:id => @ship.id, :parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :_destroy => true}]}]}} - assert_difference('@part.trinkets.count', -1) { @pirate.save } - end - - test "when great-grandchild added via attributes, saving parent should create great-grandchild" do - @pirate.attributes = {:ship_attributes => {:id => @ship.id, :parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:name => "created"}]}]}} - assert_difference('@part.trinkets.count', 1) { @pirate.save } - end - - test "when extra records exist for associations, validate (which calls nested_records_changed_for_autosave?) should not load them up" do - @trinket.name = "changed" - Ship.create!(:pirate => @pirate, :name => "The Black Rock") - ShipPart.create!(:ship => @ship, :name => "Stern") - assert_no_queries { @pirate.valid? } - end -end - -class TestHasManyAutosaveAssoictaionWhichItselfHasAutosaveAssociations < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @ship = Ship.create!(:name => "The good ship Dollypop") - @part = @ship.parts.create!(:name => "Mast") - @trinket = @part.trinkets.create!(:name => "Necklace") - end - - test "when grandchild changed in memory, saving parent should save grandchild" do - @trinket.name = "changed" - @ship.save - assert_equal "changed", @trinket.reload.name - end - - test "when grandchild changed via attributes, saving parent should save grandchild" do - @ship.attributes = {:parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :name => "changed"}]}]} - @ship.save - assert_equal "changed", @trinket.reload.name - end - - test "when grandchild marked_for_destruction via attributes, saving parent should destroy grandchild" do - @ship.attributes = {:parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :_destroy => true}]}]} - assert_difference('@part.trinkets.count', -1) { @ship.save } - end - - test "when grandchild added via attributes, saving parent should create grandchild" do - @ship.attributes = {:parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:name => "created"}]}]} - assert_difference('@part.trinkets.count', 1) { @ship.save } - end - - test "when extra records exist for associations, validate (which calls nested_records_changed_for_autosave?) should not load them up" do - @trinket.name = "changed" - Ship.create!(:name => "The Black Rock") - ShipPart.create!(:ship => @ship, :name => "Stern") - assert_no_queries { @ship.valid? } - end -end diff --git a/vendor/rails/activerecord/test/cases/pk_test.rb b/vendor/rails/activerecord/test/cases/pk_test.rb deleted file mode 100644 index c121e0aa..00000000 --- a/vendor/rails/activerecord/test/cases/pk_test.rb +++ /dev/null @@ -1,119 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/subscriber' -require 'models/movie' -require 'models/keyboard' -require 'models/mixed_case_monkey' - -class PrimaryKeysTest < ActiveRecord::TestCase - fixtures :topics, :subscribers, :movies, :mixed_case_monkeys - - def test_integer_key - topic = Topic.find(1) - assert_equal(topics(:first).author_name, topic.author_name) - topic = Topic.find(2) - assert_equal(topics(:second).author_name, topic.author_name) - - topic = Topic.new - topic.title = "New Topic" - assert_equal(nil, topic.id) - assert_nothing_raised { topic.save! } - id = topic.id - - topicReloaded = Topic.find(id) - assert_equal("New Topic", topicReloaded.title) - end - - def test_customized_primary_key_auto_assigns_on_save - Keyboard.delete_all - keyboard = Keyboard.new(:name => 'HHKB') - assert_nothing_raised { keyboard.save! } - assert_equal keyboard.id, Keyboard.find_by_name('HHKB').id - end - - def test_customized_primary_key_can_be_get_before_saving - keyboard = Keyboard.new - assert_nil keyboard.id - assert_nothing_raised { assert_nil keyboard.key_number } - end - - def test_customized_string_primary_key_settable_before_save - subscriber = Subscriber.new - assert_nothing_raised { subscriber.id = 'webster123' } - assert_equal 'webster123', subscriber.id - assert_equal 'webster123', subscriber.nick - end - - def test_string_key - subscriber = Subscriber.find(subscribers(:first).nick) - assert_equal(subscribers(:first).name, subscriber.name) - subscriber = Subscriber.find(subscribers(:second).nick) - assert_equal(subscribers(:second).name, subscriber.name) - - subscriber = Subscriber.new - subscriber.id = "jdoe" - assert_equal("jdoe", subscriber.id) - subscriber.name = "John Doe" - assert_nothing_raised { subscriber.save! } - assert_equal("jdoe", subscriber.id) - - subscriberReloaded = Subscriber.find("jdoe") - assert_equal("John Doe", subscriberReloaded.name) - end - - def test_find_with_more_than_one_string_key - assert_equal 2, Subscriber.find(subscribers(:first).nick, subscribers(:second).nick).length - end - - def test_primary_key_prefix - ActiveRecord::Base.primary_key_prefix_type = :table_name - Topic.reset_primary_key - assert_equal "topicid", Topic.primary_key - - ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore - Topic.reset_primary_key - assert_equal "topic_id", Topic.primary_key - - ActiveRecord::Base.primary_key_prefix_type = nil - Topic.reset_primary_key - assert_equal "id", Topic.primary_key - end - - def test_delete_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.delete(1) } - end - def test_update_counters_should_quote_pkey_and_quote_counter_columns - assert_nothing_raised { MixedCaseMonkey.update_counters(1, :fleaCount => 99) } - end - def test_find_with_one_id_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find(1) } - end - def test_find_with_multiple_ids_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find([1,2]) } - end - def test_instance_update_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find(1).save } - end - def test_instance_destroy_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find(1).destroy } - end - - def test_supports_primary_key - assert_nothing_raised NoMethodError do - ActiveRecord::Base.connection.supports_primary_key? - end - end - - def test_primary_key_returns_value_if_it_exists - if ActiveRecord::Base.connection.supports_primary_key? - assert_equal 'id', ActiveRecord::Base.connection.primary_key('developers') - end - end - - def test_primary_key_returns_nil_if_it_does_not_exist - if ActiveRecord::Base.connection.supports_primary_key? - assert_nil ActiveRecord::Base.connection.primary_key('developers_projects') - end - end -end diff --git a/vendor/rails/activerecord/test/cases/pooled_connections_test.rb b/vendor/rails/activerecord/test/cases/pooled_connections_test.rb deleted file mode 100644 index 2649a935..00000000 --- a/vendor/rails/activerecord/test/cases/pooled_connections_test.rb +++ /dev/null @@ -1,103 +0,0 @@ -require "cases/helper" - -class PooledConnectionsTest < ActiveRecord::TestCase - def setup - super - @connection = ActiveRecord::Base.remove_connection - end - - def teardown - ActiveRecord::Base.clear_all_connections! - ActiveRecord::Base.establish_connection(@connection) - super - end - - def checkout_connections - ActiveRecord::Base.establish_connection(@connection.merge({:pool => 2, :wait_timeout => 0.3})) - @connections = [] - @timed_out = 0 - - 4.times do - Thread.new do - begin - @connections << ActiveRecord::Base.connection_pool.checkout - rescue ActiveRecord::ConnectionTimeoutError - @timed_out += 1 - end - end.join - end - end - - # Will deadlock due to lack of Monitor timeouts in 1.9 - if RUBY_VERSION < '1.9' - def test_pooled_connection_checkout - checkout_connections - assert_equal @connections.length, 2 - assert_equal @timed_out, 2 - end - end - - def checkout_checkin_connections(pool_size, threads) - ActiveRecord::Base.establish_connection(@connection.merge({:pool => pool_size, :wait_timeout => 0.5})) - @connection_count = 0 - @timed_out = 0 - threads.times do - Thread.new do - begin - conn = ActiveRecord::Base.connection_pool.checkout - sleep 0.1 - ActiveRecord::Base.connection_pool.checkin conn - @connection_count += 1 - rescue ActiveRecord::ConnectionTimeoutError - @timed_out += 1 - end - end.join - end - end - - def test_pooled_connection_checkin_one - checkout_checkin_connections 1, 2 - assert_equal 2, @connection_count - assert_equal 0, @timed_out - end - - def test_pooled_connection_checkin_two - checkout_checkin_connections 2, 3 - assert_equal 3, @connection_count - assert_equal 0, @timed_out - end - - def test_pooled_connection_checkout_existing_first - ActiveRecord::Base.establish_connection(@connection.merge({:pool => 1})) - conn_pool = ActiveRecord::Base.connection_pool - conn = conn_pool.checkout - conn_pool.checkin(conn) - conn = conn_pool.checkout - assert ActiveRecord::ConnectionAdapters::AbstractAdapter === conn - conn_pool.checkin(conn) - end - - def test_not_connected_defined_connection_returns_false - ActiveRecord::Base.establish_connection(@connection) - assert ! ActiveRecord::Base.connected? - end - - def test_undefined_connection_returns_false - old_handler = ActiveRecord::Base.connection_handler - ActiveRecord::Base.connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new - assert_equal false, ActiveRecord::Base.connected? - ensure - ActiveRecord::Base.connection_handler = old_handler - end -end unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name - -class AllowConcurrencyDeprecatedTest < ActiveRecord::TestCase - def test_allow_concurrency_is_deprecated - assert_deprecated('ActiveRecord::Base.allow_concurrency') do - ActiveRecord::Base.allow_concurrency - end - assert_deprecated('ActiveRecord::Base.allow_concurrency=') do - ActiveRecord::Base.allow_concurrency = true - end - end -end diff --git a/vendor/rails/activerecord/test/cases/query_cache_test.rb b/vendor/rails/activerecord/test/cases/query_cache_test.rb deleted file mode 100644 index f7f97774..00000000 --- a/vendor/rails/activerecord/test/cases/query_cache_test.rb +++ /dev/null @@ -1,129 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/task' -require 'models/course' -require 'models/category' -require 'models/post' - - -class QueryCacheTest < ActiveRecord::TestCase - fixtures :tasks, :topics, :categories, :posts, :categories_posts - - def test_find_queries - assert_queries(2) { Task.find(1); Task.find(1) } - end - - def test_find_queries_with_cache - Task.cache do - assert_queries(1) { Task.find(1); Task.find(1) } - end - end - - def test_count_queries_with_cache - Task.cache do - assert_queries(1) { Task.count; Task.count } - end - end - - def test_query_cache_dups_results_correctly - Task.cache do - now = Time.now.utc - task = Task.find 1 - assert_not_equal now, task.starting - task.starting = now - task.reload - assert_not_equal now, task.starting - end - end - - def test_cache_is_flat - Task.cache do - Topic.columns # don't count this query - assert_queries(1) { Topic.find(1); Topic.find(1); } - end - - ActiveRecord::Base.cache do - assert_queries(1) { Task.find(1); Task.find(1) } - end - end - - def test_cache_does_not_wrap_string_results_in_arrays - require 'sqlite3/version' if current_adapter?(:SQLite3Adapter) - - Task.cache do - if current_adapter?(:SQLite3Adapter) && SQLite3::Version::VERSION > '1.2.5' - assert_instance_of Fixnum, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks") - else - assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks") - end - end - end -end - -class QueryCacheExpiryTest < ActiveRecord::TestCase - fixtures :tasks, :posts, :categories, :categories_posts - - def test_find - Task.connection.expects(:clear_query_cache).times(1) - - assert !Task.connection.query_cache_enabled - Task.cache do - assert Task.connection.query_cache_enabled - Task.find(1) - - Task.uncached do - assert !Task.connection.query_cache_enabled - Task.find(1) - end - - assert Task.connection.query_cache_enabled - end - assert !Task.connection.query_cache_enabled - end - - def test_update - Task.connection.expects(:clear_query_cache).times(2) - - Task.cache do - task = Task.find(1) - task.starting = Time.now.utc - task.save! - end - end - - def test_destroy - Task.connection.expects(:clear_query_cache).times(2) - - Task.cache do - Task.find(1).destroy - end - end - - def test_insert - ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) - - Task.cache do - Task.create! - end - end - - def test_cache_is_expired_by_habtm_update - ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) - ActiveRecord::Base.cache do - c = Category.find(:first) - p = Post.find(:first) - p.categories << c - end - end - - def test_cache_is_expired_by_habtm_delete - ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) - ActiveRecord::Base.cache do - c = Category.find(1) - p = Post.find(1) - assert p.categories.any? - p.categories.delete_all - end - end -end diff --git a/vendor/rails/activerecord/test/cases/readonly_test.rb b/vendor/rails/activerecord/test/cases/readonly_test.rb deleted file mode 100644 index b921cbdc..00000000 --- a/vendor/rails/activerecord/test/cases/readonly_test.rb +++ /dev/null @@ -1,107 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/developer' -require 'models/project' -require 'models/reader' -require 'models/person' - -# Dummy class methods to test implicit association scoping. -def Comment.foo() find :first end -def Project.foo() find :first end - - -class ReadOnlyTest < ActiveRecord::TestCase - fixtures :posts, :comments, :developers, :projects, :developers_projects - - def test_cant_save_readonly_record - dev = Developer.find(1) - assert !dev.readonly? - - dev.readonly! - assert dev.readonly? - - assert_nothing_raised do - dev.name = 'Luscious forbidden fruit.' - assert !dev.save - dev.name = 'Forbidden.' - end - assert_raise(ActiveRecord::ReadOnlyRecord) { dev.save } - assert_raise(ActiveRecord::ReadOnlyRecord) { dev.save! } - end - - - def test_find_with_readonly_option - Developer.find(:all).each { |d| assert !d.readonly? } - Developer.find(:all, :readonly => false).each { |d| assert !d.readonly? } - Developer.find(:all, :readonly => true).each { |d| assert d.readonly? } - end - - - def test_find_with_joins_option_implies_readonly - # Blank joins don't count. - Developer.find(:all, :joins => ' ').each { |d| assert !d.readonly? } - Developer.find(:all, :joins => ' ', :readonly => false).each { |d| assert !d.readonly? } - - # Others do. - Developer.find(:all, :joins => ', projects').each { |d| assert d.readonly? } - Developer.find(:all, :joins => ', projects', :readonly => false).each { |d| assert !d.readonly? } - end - - - def test_habtm_find_readonly - dev = Developer.find(1) - assert !dev.projects.empty? - assert dev.projects.all?(&:readonly?) - assert dev.projects.find(:all).all?(&:readonly?) - assert dev.projects.find(:all, :readonly => true).all?(&:readonly?) - end - - def test_has_many_find_readonly - post = Post.find(1) - assert !post.comments.empty? - assert !post.comments.any?(&:readonly?) - assert !post.comments.find(:all).any?(&:readonly?) - assert post.comments.find(:all, :readonly => true).all?(&:readonly?) - end - - def test_has_many_with_through_is_not_implicitly_marked_readonly - assert people = Post.find(1).people - assert !people.any?(&:readonly?) - end - - def test_readonly_scoping - Post.with_scope(:find => { :conditions => '1=1' }) do - assert !Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - - Post.with_scope(:find => { :joins => ' ' }) do - assert !Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - - # Oracle barfs on this because the join includes unqualified and - # conflicting column names - unless current_adapter?(:OracleAdapter) - Post.with_scope(:find => { :joins => ', developers' }) do - assert Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - end - - Post.with_scope(:find => { :readonly => true }) do - assert Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - end - - def test_association_collection_method_missing_scoping_not_readonly - assert !Developer.find(1).projects.foo.readonly? - assert !Post.find(1).comments.foo.readonly? - end -end diff --git a/vendor/rails/activerecord/test/cases/reflection_test.rb b/vendor/rails/activerecord/test/cases/reflection_test.rb deleted file mode 100644 index 8cf85051..00000000 --- a/vendor/rails/activerecord/test/cases/reflection_test.rb +++ /dev/null @@ -1,234 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/customer' -require 'models/company' -require 'models/company_in_module' -require 'models/subscriber' -require 'models/ship' -require 'models/pirate' - -class ReflectionTest < ActiveRecord::TestCase - include ActiveRecord::Reflection - - fixtures :topics, :customers, :companies, :subscribers - - def setup - @first = Topic.find(1) - end - - def test_column_null_not_null - subscriber = Subscriber.find(:first) - assert subscriber.column_for_attribute("name").null - assert !subscriber.column_for_attribute("nick").null - end - - def test_read_attribute_names - assert_equal( - %w( id title author_name author_email_address bonus_time written_on last_read content group approved replies_count parent_id parent_title type ).sort, - @first.attribute_names - ) - end - - def test_columns - assert_equal 14, Topic.columns.length - end - - def test_columns_are_returned_in_the_order_they_were_declared - column_names = Topic.columns.map { |column| column.name } - assert_equal %w(id title author_name author_email_address written_on bonus_time last_read content approved replies_count parent_id parent_title type group), column_names - end - - def test_content_columns - content_columns = Topic.content_columns - content_column_names = content_columns.map {|column| column.name} - assert_equal 10, content_columns.length - assert_equal %w(title author_name author_email_address written_on bonus_time last_read content group approved parent_title).sort, content_column_names.sort - end - - def test_column_string_type_and_limit - assert_equal :string, @first.column_for_attribute("title").type - assert_equal 255, @first.column_for_attribute("title").limit - end - - def test_column_null_not_null - subscriber = Subscriber.find(:first) - assert subscriber.column_for_attribute("name").null - assert !subscriber.column_for_attribute("nick").null - end - - def test_human_name_for_column - assert_equal "Author name", @first.column_for_attribute("author_name").human_name - end - - def test_integer_columns - assert_equal :integer, @first.column_for_attribute("id").type - end - - def test_reflection_klass_for_nested_class_name - reflection = MacroReflection.new(nil, nil, { :class_name => 'MyApplication::Business::Company' }, nil) - assert_nothing_raised do - assert_equal MyApplication::Business::Company, reflection.klass - end - end - - def test_aggregation_reflection - reflection_for_address = AggregateReflection.new( - :composed_of, :address, { :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ] }, Customer - ) - - reflection_for_balance = AggregateReflection.new( - :composed_of, :balance, { :class_name => "Money", :mapping => %w(balance amount) }, Customer - ) - - reflection_for_gps_location = AggregateReflection.new( - :composed_of, :gps_location, { }, Customer - ) - - assert Customer.reflect_on_all_aggregations.include?(reflection_for_gps_location) - assert Customer.reflect_on_all_aggregations.include?(reflection_for_balance) - assert Customer.reflect_on_all_aggregations.include?(reflection_for_address) - - assert_equal reflection_for_address, Customer.reflect_on_aggregation(:address) - - assert_equal Address, Customer.reflect_on_aggregation(:address).klass - - assert_equal Money, Customer.reflect_on_aggregation(:balance).klass - end - - def test_reflect_on_all_autosave_associations - expected = Pirate.reflect_on_all_associations.select { |r| r.options[:autosave] } - received = Pirate.reflect_on_all_autosave_associations - - assert !received.empty? - assert_not_equal Pirate.reflect_on_all_associations.length, received.length - assert_equal expected, received - end - - def test_has_many_reflection - reflection_for_clients = AssociationReflection.new(:has_many, :clients, { :order => "id", :dependent => :destroy }, Firm) - - assert_equal reflection_for_clients, Firm.reflect_on_association(:clients) - - assert_equal Client, Firm.reflect_on_association(:clients).klass - assert_equal 'companies', Firm.reflect_on_association(:clients).table_name - - assert_equal Client, Firm.reflect_on_association(:clients_of_firm).klass - assert_equal 'companies', Firm.reflect_on_association(:clients_of_firm).table_name - end - - def test_has_one_reflection - reflection_for_account = AssociationReflection.new(:has_one, :account, { :foreign_key => "firm_id", :dependent => :destroy }, Firm) - assert_equal reflection_for_account, Firm.reflect_on_association(:account) - - assert_equal Account, Firm.reflect_on_association(:account).klass - assert_equal 'accounts', Firm.reflect_on_association(:account).table_name - end - - def test_belongs_to_inferred_foreign_key_from_assoc_name - Company.belongs_to :foo - assert_equal "foo_id", Company.reflect_on_association(:foo).primary_key_name - Company.belongs_to :bar, :class_name => "Xyzzy" - assert_equal "bar_id", Company.reflect_on_association(:bar).primary_key_name - Company.belongs_to :baz, :class_name => "Xyzzy", :foreign_key => "xyzzy_id" - assert_equal "xyzzy_id", Company.reflect_on_association(:baz).primary_key_name - end - - def test_association_reflection_in_modules - assert_reflection MyApplication::Business::Firm, - :clients_of_firm, - :klass => MyApplication::Business::Client, - :class_name => 'Client', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :firm, - :klass => MyApplication::Business::Firm, - :class_name => 'MyApplication::Business::Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :qualified_billing_firm, - :klass => MyApplication::Billing::Firm, - :class_name => 'MyApplication::Billing::Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :unqualified_billing_firm, - :klass => MyApplication::Billing::Firm, - :class_name => 'Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :nested_qualified_billing_firm, - :klass => MyApplication::Billing::Nested::Firm, - :class_name => 'MyApplication::Billing::Nested::Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :nested_unqualified_billing_firm, - :klass => MyApplication::Billing::Nested::Firm, - :class_name => 'Nested::Firm', - :table_name => 'companies' - end - - def test_reflection_of_all_associations - # FIXME these assertions bust a lot - assert_equal 36, Firm.reflect_on_all_associations.size - assert_equal 26, Firm.reflect_on_all_associations(:has_many).size - assert_equal 10, Firm.reflect_on_all_associations(:has_one).size - assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size - end - - def test_reflection_should_not_raise_error_when_compared_to_other_object - assert_nothing_raised { Firm.reflections[:clients] == Object.new } - end - - def test_has_many_through_reflection - assert_kind_of ThroughReflection, Subscriber.reflect_on_association(:books) - end - - def test_collection_association - assert Pirate.reflect_on_association(:birds).collection? - assert Pirate.reflect_on_association(:parrots).collection? - - assert !Pirate.reflect_on_association(:ship).collection? - assert !Ship.reflect_on_association(:pirate).collection? - end - - def test_default_association_validation - assert AssociationReflection.new(:has_many, :clients, {}, Firm).validate? - - assert !AssociationReflection.new(:has_one, :client, {}, Firm).validate? - assert !AssociationReflection.new(:belongs_to, :client, {}, Firm).validate? - assert !AssociationReflection.new(:has_and_belongs_to_many, :clients, {}, Firm).validate? - end - - def test_always_validate_association_if_explicit - assert AssociationReflection.new(:has_one, :client, { :validate => true }, Firm).validate? - assert AssociationReflection.new(:belongs_to, :client, { :validate => true }, Firm).validate? - assert AssociationReflection.new(:has_many, :clients, { :validate => true }, Firm).validate? - assert AssociationReflection.new(:has_and_belongs_to_many, :clients, { :validate => true }, Firm).validate? - end - - def test_validate_association_if_autosave - assert AssociationReflection.new(:has_one, :client, { :autosave => true }, Firm).validate? - assert AssociationReflection.new(:belongs_to, :client, { :autosave => true }, Firm).validate? - assert AssociationReflection.new(:has_many, :clients, { :autosave => true }, Firm).validate? - assert AssociationReflection.new(:has_and_belongs_to_many, :clients, { :autosave => true }, Firm).validate? - end - - def test_never_validate_association_if_explicit - assert !AssociationReflection.new(:has_one, :client, { :autosave => true, :validate => false }, Firm).validate? - assert !AssociationReflection.new(:belongs_to, :client, { :autosave => true, :validate => false }, Firm).validate? - assert !AssociationReflection.new(:has_many, :clients, { :autosave => true, :validate => false }, Firm).validate? - assert !AssociationReflection.new(:has_and_belongs_to_many, :clients, { :autosave => true, :validate => false }, Firm).validate? - end - - private - def assert_reflection(klass, association, options) - assert reflection = klass.reflect_on_association(association) - options.each do |method, value| - assert_equal(value, reflection.send(method)) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/reload_models_test.rb b/vendor/rails/activerecord/test/cases/reload_models_test.rb deleted file mode 100644 index 0d16a352..00000000 --- a/vendor/rails/activerecord/test/cases/reload_models_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require "cases/helper" -require 'models/owner' -require 'models/pet' - -class ReloadModelsTest < ActiveRecord::TestCase - fixtures :pets - - def test_has_one_with_reload - pet = Pet.find_by_name('parrot') - pet.owner = Owner.find_by_name('ashley') - - # Reload the class Owner, simulating auto-reloading of model classes in a - # development environment. Note that meanwhile the class Pet is not - # reloaded, simulating a class that is present in a plugin. - Object.class_eval { remove_const :Owner } - Kernel.load(File.expand_path(File.join(File.dirname(__FILE__), "../models/owner.rb"))) - - pet = Pet.find_by_name('parrot') - pet.owner = Owner.find_by_name('ashley') - assert_equal pet.owner, Owner.find_by_name('ashley') - end -end diff --git a/vendor/rails/activerecord/test/cases/repair_helper.rb b/vendor/rails/activerecord/test/cases/repair_helper.rb deleted file mode 100644 index 01556688..00000000 --- a/vendor/rails/activerecord/test/cases/repair_helper.rb +++ /dev/null @@ -1,50 +0,0 @@ -module ActiveRecord - module Testing - module RepairHelper - def self.included(base) - base.class_eval do - extend ClassMethods - end - end - - module Toolbox - def self.record_validations(*model_classes) - model_classes.inject({}) do |repair, klass| - repair[klass] ||= {} - [:validate, :validate_on_create, :validate_on_update].each do |callback| - the_callback = klass.instance_variable_get("@#{callback.to_s}_callbacks") - repair[klass][callback] = (the_callback.nil? ? nil : the_callback.dup) - end - repair - end - end - - def self.reset_validations(recorded) - recorded.each do |klass, repairs| - [:validate, :validate_on_create, :validate_on_update].each do |callback| - klass.instance_variable_set("@#{callback.to_s}_callbacks", repairs[callback]) - end - end - end - end - - module ClassMethods - def repair_validations(*model_classes) - setup do - @validation_repairs = ActiveRecord::Testing::RepairHelper::Toolbox.record_validations(*model_classes) - end - teardown do - ActiveRecord::Testing::RepairHelper::Toolbox.reset_validations(@validation_repairs) - end - end - end - - def repair_validations(*model_classes, &block) - validation_repairs = ActiveRecord::Testing::RepairHelper::Toolbox.record_validations(*model_classes) - return block.call - ensure - ActiveRecord::Testing::RepairHelper::Toolbox.reset_validations(validation_repairs) - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb b/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb deleted file mode 100644 index ce1622bb..00000000 --- a/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb +++ /dev/null @@ -1,176 +0,0 @@ -require "cases/helper" - -class Group < ActiveRecord::Base - Group.table_name = 'group' - belongs_to :select, :class_name => 'Select' - has_one :values -end - -class Select < ActiveRecord::Base - Select.table_name = 'select' - has_many :groups -end - -class Values < ActiveRecord::Base - Values.table_name = 'values' -end - -class Distinct < ActiveRecord::Base - Distinct.table_name = 'distinct' - has_and_belongs_to_many :selects - has_many :values, :through => :groups -end - -# a suite of tests to ensure the ConnectionAdapters#MysqlAdapter can handle tables with -# reserved word names (ie: group, order, values, etc...) -class MysqlReservedWordTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.connection - - # we call execute directly here (and do similar below) because ActiveRecord::Base#create_table() - # will fail with these table names if these test cases fail - - create_tables_directly 'group'=>'id int auto_increment primary key, `order` varchar(255), select_id int', - 'select'=>'id int auto_increment primary key', - 'values'=>'id int auto_increment primary key, group_id int', - 'distinct'=>'id int auto_increment primary key', - 'distincts_selects'=>'distinct_id int, select_id int' - end - - def teardown - drop_tables_directly ['group', 'select', 'values', 'distinct', 'distincts_selects', 'order'] - end - - # create tables with reserved-word names and columns - def test_create_tables - assert_nothing_raised { - @connection.create_table :order do |t| - t.column :group, :string - end - } - end - - # rename tables with reserved-word names - def test_rename_tables - assert_nothing_raised { @connection.rename_table(:group, :order) } - end - - # alter column with a reserved-word name in a table with a reserved-word name - def test_change_columns - assert_nothing_raised { @connection.change_column_default(:group, :order, 'whatever') } - #the quoting here will reveal any double quoting issues in change_column's interaction with the column method in the adapter - assert_nothing_raised { @connection.change_column('group', 'order', :Int, :default => 0) } - assert_nothing_raised { @connection.rename_column(:group, :order, :values) } - end - - # dump structure of table with reserved word name - def test_structure_dump - assert_nothing_raised { @connection.structure_dump } - end - - # introspect table with reserved word name - def test_introspect - assert_nothing_raised { @connection.columns(:group) } - assert_nothing_raised { @connection.indexes(:group) } - end - - #fixtures - self.use_instantiated_fixtures = true - self.use_transactional_fixtures = false - - #fixtures :group - - def test_fixtures - f = create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - - assert_nothing_raised { - f.each do |x| - x.delete_existing_fixtures - end - } - - assert_nothing_raised { - f.each do |x| - x.insert_fixtures - end - } - end - - #activerecord model class with reserved-word table name - def test_activerecord_model - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - x = nil - assert_nothing_raised { x = Group.new } - x.order = 'x' - assert_nothing_raised { x.save } - x.order = 'y' - assert_nothing_raised { x.save } - assert_nothing_raised { y = Group.find_by_order('y') } - assert_nothing_raised { y = Group.find(1) } - x = Group.find(1) - end - - # has_one association with reserved-word table name - def test_has_one_associations - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - v = nil - assert_nothing_raised { v = Group.find(1).values } - assert_equal v.id, 2 - end - - # belongs_to association with reserved-word table name - def test_belongs_to_associations - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - gs = nil - assert_nothing_raised { gs = Select.find(2).groups } - assert_equal gs.length, 2 - assert(gs.collect{|x| x.id}.sort == [2, 3]) - end - - # has_and_belongs_to_many with reserved-word table name - def test_has_and_belongs_to_many - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - s = nil - assert_nothing_raised { s = Distinct.find(1).selects } - assert_equal s.length, 2 - assert(s.collect{|x|x.id}.sort == [1, 2]) - end - - # activerecord model introspection with reserved-word table and column names - def test_activerecord_introspection - assert_nothing_raised { Group.table_exists? } - assert_nothing_raised { Group.columns } - end - - # Calculations - def test_calculations_work_with_reserved_words - assert_nothing_raised { Group.count } - end - - def test_associations_work_with_reserved_words - assert_nothing_raised { Select.find(:all, :include => [:groups]) } - end - - #the following functions were added to DRY test cases - - private - # custom fixture loader, uses Fixtures#create_fixtures and appends base_path to the current file's path - def create_test_fixtures(*fixture_names) - Fixtures.create_fixtures(FIXTURES_ROOT + "/reserved_words", fixture_names) - end - - # custom drop table, uses execute on connection to drop a table if it exists. note: escapes table_name - def drop_tables_directly(table_names, connection = @connection) - table_names.each do |name| - connection.execute("DROP TABLE IF EXISTS `#{name}`") - end - end - - # custom create table, uses execute on connection to create a table, note: escapes table_name, does NOT escape columns - def create_tables_directly (tables, connection = @connection) - tables.each do |table_name, column_properties| - connection.execute("CREATE TABLE `#{table_name}` ( #{column_properties} )") - end - end - -end diff --git a/vendor/rails/activerecord/test/cases/sanitize_test.rb b/vendor/rails/activerecord/test/cases/sanitize_test.rb deleted file mode 100644 index 817897ce..00000000 --- a/vendor/rails/activerecord/test/cases/sanitize_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "cases/helper" -require 'models/binary' - -class SanitizeTest < ActiveRecord::TestCase - def setup - end - - def test_sanitize_sql_array_handles_string_interpolation - quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi") - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"]) - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi".mb_chars]) - quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote_string("Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper"]) - assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper".mb_chars]) - end - - def test_sanitize_sql_array_handles_bind_variables - quoted_bambi = ActiveRecord::Base.connection.quote("Bambi") - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi"]) - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi".mb_chars]) - quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote("Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper"]) - assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper".mb_chars]) - end -end diff --git a/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb b/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb deleted file mode 100644 index ba775451..00000000 --- a/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb +++ /dev/null @@ -1,75 +0,0 @@ -require "cases/helper" - -class SchemaThing < ActiveRecord::Base -end - -class SchemaAuthorizationTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - TABLE_NAME = 'schema_things' - COLUMNS = [ - 'id serial primary key', - 'name character varying(50)' - ] - USERS = ['rails_pg_schema_user1', 'rails_pg_schema_user2'] - - def setup - @connection = ActiveRecord::Base.connection - @connection.execute "SET search_path TO '$user',public" - set_session_auth - USERS.each do |u| - @connection.execute "CREATE USER #{u}" rescue nil - @connection.execute "CREATE SCHEMA AUTHORIZATION #{u}" rescue nil - set_session_auth u - @connection.execute "CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})" - @connection.execute "INSERT INTO #{TABLE_NAME} (name) VALUES ('#{u}')" - set_session_auth - end - end - - def teardown - set_session_auth - @connection.execute "RESET search_path" - USERS.each do |u| - @connection.execute "DROP SCHEMA #{u} CASCADE" - @connection.execute "DROP USER #{u}" - end - end - - def test_schema_invisible - assert_raise(ActiveRecord::StatementInvalid) do - set_session_auth - @connection.execute "SELECT * FROM #{TABLE_NAME}" - end - end - - def test_schema_uniqueness - assert_nothing_raised do - set_session_auth - USERS.each do |u| - set_session_auth u - assert_equal u, @connection.select_value("SELECT name FROM #{TABLE_NAME} WHERE id = 1") - set_session_auth - end - end - end - - def test_sequence_schema_caching - assert_nothing_raised do - USERS.each do |u| - set_session_auth u - st = SchemaThing.new :name => 'TEST1' - st.save! - st = SchemaThing.new :id => 5, :name => 'TEST2' - st.save! - set_session_auth - end - end - end - - private - def set_session_auth auth = nil - @connection.execute "SET SESSION AUTHORIZATION #{auth || 'default'}" - end - -end diff --git a/vendor/rails/activerecord/test/cases/schema_dumper_test.rb b/vendor/rails/activerecord/test/cases/schema_dumper_test.rb deleted file mode 100644 index ba714a95..00000000 --- a/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +++ /dev/null @@ -1,211 +0,0 @@ -require "cases/helper" -require 'stringio' - - -class SchemaDumperTest < ActiveRecord::TestCase - def standard_dump - stream = StringIO.new - ActiveRecord::SchemaDumper.ignore_tables = [] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - stream.string - end - - def test_schema_dump - output = standard_dump - assert_match %r{create_table "accounts"}, output - assert_match %r{create_table "authors"}, output - assert_no_match %r{create_table "schema_migrations"}, output - end - - def test_schema_dump_excludes_sqlite_sequence - output = standard_dump - assert_no_match %r{create_table "sqlite_sequence"}, output - end - - def test_schema_dump_includes_camelcase_table_name - output = standard_dump - assert_match %r{create_table "CamelCase"}, output - end - - def assert_line_up(lines, pattern, required = false) - return assert(true) if lines.empty? - matches = lines.map { |line| line.match(pattern) } - assert matches.all? if required - matches.compact! - return assert(true) if matches.empty? - assert_equal 1, matches.map{ |match| match.offset(0).first }.uniq.length - end - - def column_definition_lines(output = standard_dump) - output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) } - end - - def test_types_line_up - column_definition_lines.each do |column_set| - next if column_set.empty? - - lengths = column_set.map do |column| - if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/) - match[0].length - end - end - - assert_equal 1, lengths.uniq.length - end - end - - def test_arguments_line_up - column_definition_lines.each do |column_set| - assert_line_up(column_set, /:default => /) - assert_line_up(column_set, /:limit => /) - assert_line_up(column_set, /:null => /) - end - end - - def test_no_dump_errors - output = standard_dump - assert_no_match %r{\# Could not dump table}, output - end - - def test_schema_dump_includes_not_null_columns - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_match %r{:null => false}, output - end - - def test_schema_dump_includes_limit_constraint_for_integer_columns - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = [/^(?!integer_limits)/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - - if current_adapter?(:PostgreSQLAdapter) - assert_match %r{c_int_1.*:limit => 2}, output - assert_match %r{c_int_2.*:limit => 2}, output - - # int 3 is 4 bytes in postgresql - assert_match %r{c_int_3.*}, output - assert_no_match %r{c_int_3.*:limit}, output - - assert_match %r{c_int_4.*}, output - assert_no_match %r{c_int_4.*:limit}, output - elsif current_adapter?(:MysqlAdapter) - assert_match %r{c_int_1.*:limit => 1}, output - assert_match %r{c_int_2.*:limit => 2}, output - assert_match %r{c_int_3.*:limit => 3}, output - - assert_match %r{c_int_4.*}, output - assert_no_match %r{c_int_4.*:limit}, output - elsif current_adapter?(:SQLiteAdapter) - assert_match %r{c_int_1.*:limit => 1}, output - assert_match %r{c_int_2.*:limit => 2}, output - assert_match %r{c_int_3.*:limit => 3}, output - assert_match %r{c_int_4.*:limit => 4}, output - end - assert_match %r{c_int_without_limit.*}, output - assert_no_match %r{c_int_without_limit.*:limit}, output - - if current_adapter?(:SQLiteAdapter) - assert_match %r{c_int_5.*:limit => 5}, output - assert_match %r{c_int_6.*:limit => 6}, output - assert_match %r{c_int_7.*:limit => 7}, output - assert_match %r{c_int_8.*:limit => 8}, output - else - assert_match %r{c_int_5.*:limit => 8}, output - assert_match %r{c_int_6.*:limit => 8}, output - assert_match %r{c_int_7.*:limit => 8}, output - assert_match %r{c_int_8.*:limit => 8}, output - end - end - - def test_schema_dump_with_string_ignored_table - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = ['accounts'] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_no_match %r{create_table "accounts"}, output - assert_match %r{create_table "authors"}, output - assert_no_match %r{create_table "schema_migrations"}, output - end - - def test_schema_dump_with_regexp_ignored_table - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = [/^account/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_no_match %r{create_table "accounts"}, output - assert_match %r{create_table "authors"}, output - assert_no_match %r{create_table "schema_migrations"}, output - end - - def test_schema_dump_illegal_ignored_table_value - stream = StringIO.new - ActiveRecord::SchemaDumper.ignore_tables = [5] - assert_raise(StandardError) do - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - end - end - - def test_schema_dumps_index_columns_in_right_order - index_definition = standard_dump.split(/\n/).grep(/add_index.*companies/).first.strip - assert_equal 'add_index "companies", ["firm_id", "type", "rating", "ruby_type"], :name => "company_index"', index_definition - end - - def test_schema_dump_should_honor_nonstandard_primary_keys - output = standard_dump - match = output.match(%r{create_table "movies"(.*)do}) - assert_not_nil(match, "nonstandardpk table not found") - assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved" - end - - if current_adapter?(:MysqlAdapter) - def test_schema_dump_should_not_add_default_value_for_mysql_text_field - output = standard_dump - assert_match %r{t.text\s+"body",\s+:null => false$}, output - end - - def test_schema_dump_includes_length_for_mysql_blob_and_text_fields - output = standard_dump - assert_match %r{t.binary\s+"tiny_blob",\s+:limit => 255$}, output - assert_match %r{t.binary\s+"normal_blob"$}, output - assert_match %r{t.binary\s+"medium_blob",\s+:limit => 16777215$}, output - assert_match %r{t.binary\s+"long_blob",\s+:limit => 2147483647$}, output - assert_match %r{t.text\s+"tiny_text",\s+:limit => 255$}, output - assert_match %r{t.text\s+"normal_text"$}, output - assert_match %r{t.text\s+"medium_text",\s+:limit => 16777215$}, output - assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output - end - end - - def test_schema_dump_includes_decimal_options - stream = StringIO.new - ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_match %r{:precision => 3,[[:space:]]+:scale => 2,[[:space:]]+:default => 2.78}, output - end - - if current_adapter?(:PostgreSQLAdapter) - def test_schema_dump_includes_xml_shorthand_definition - output = standard_dump - if %r{create_table "postgresql_xml_data_type"} =~ output - assert_match %r{t.xml "data"}, output - end - end - end - - def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added - output = standard_dump - match = output.match(%r{create_table "goofy_string_id"(.*)do.*\n(.*)\n}) - assert_not_nil(match, "goofy_string_id table not found") - assert_match %r(:id => false), match[1], "no table id not preserved" - assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved" - end -end - diff --git a/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb b/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb deleted file mode 100644 index 96d325b2..00000000 --- a/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +++ /dev/null @@ -1,178 +0,0 @@ -require "cases/helper" - -class SchemaTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - SCHEMA_NAME = 'test_schema' - SCHEMA2_NAME = 'test_schema2' - TABLE_NAME = 'things' - CAPITALIZED_TABLE_NAME = 'Things' - INDEX_A_NAME = 'a_index_things_on_name' - INDEX_B_NAME = 'b_index_things_on_different_columns_in_each_schema' - INDEX_A_COLUMN = 'name' - INDEX_B_COLUMN_S1 = 'email' - INDEX_B_COLUMN_S2 = 'moment' - COLUMNS = [ - 'id integer', - 'name character varying(50)', - 'email character varying(50)', - 'moment timestamp without time zone default now()' - ] - - class Thing1 < ActiveRecord::Base - set_table_name "test_schema.things" - end - - class Thing2 < ActiveRecord::Base - set_table_name "test_schema2.things" - end - - class Thing3 < ActiveRecord::Base - set_table_name 'test_schema."things.table"' - end - - class Thing4 < ActiveRecord::Base - set_table_name 'test_schema."Things"' - end - - def setup - @connection = ActiveRecord::Base.connection - @connection.execute "CREATE SCHEMA #{SCHEMA_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})" - @connection.execute "CREATE TABLE #{SCHEMA_NAME}.\"#{TABLE_NAME}.table\" (#{COLUMNS.join(',')})" - @connection.execute "CREATE TABLE #{SCHEMA_NAME}.\"#{CAPITALIZED_TABLE_NAME}\" (#{COLUMNS.join(',')})" - @connection.execute "CREATE SCHEMA #{SCHEMA2_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})" - @connection.execute "CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME} USING btree (#{INDEX_A_COLUMN});" - @connection.execute "CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING btree (#{INDEX_A_COLUMN});" - @connection.execute "CREATE INDEX #{INDEX_B_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME} USING btree (#{INDEX_B_COLUMN_S1});" - @connection.execute "CREATE INDEX #{INDEX_B_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING btree (#{INDEX_B_COLUMN_S2});" - end - - def teardown - @connection.execute "DROP SCHEMA #{SCHEMA2_NAME} CASCADE" - @connection.execute "DROP SCHEMA #{SCHEMA_NAME} CASCADE" - end - - def test_with_schema_prefixed_table_name - assert_nothing_raised do - assert_equal COLUMNS, columns("#{SCHEMA_NAME}.#{TABLE_NAME}") - end - end - - def test_with_schema_prefixed_capitalized_table_name - assert_nothing_raised do - assert_equal COLUMNS, columns("#{SCHEMA_NAME}.#{CAPITALIZED_TABLE_NAME}") - end - end - - def test_with_schema_search_path - assert_nothing_raised do - with_schema_search_path(SCHEMA_NAME) do - assert_equal COLUMNS, columns(TABLE_NAME) - end - end - end - - - def test_proper_encoding_of_table_name - assert_equal '"table_name"', @connection.quote_table_name('table_name') - assert_equal '"table.name"', @connection.quote_table_name('"table.name"') - assert_equal '"schema_name"."table_name"', @connection.quote_table_name('schema_name.table_name') - assert_equal '"schema_name"."table.name"', @connection.quote_table_name('schema_name."table.name"') - assert_equal '"schema.name"."table_name"', @connection.quote_table_name('"schema.name".table_name') - assert_equal '"schema.name"."table.name"', @connection.quote_table_name('"schema.name"."table.name"') - end - - def test_classes_with_qualified_schema_name - assert_equal 0, Thing1.count - assert_equal 0, Thing2.count - assert_equal 0, Thing3.count - assert_equal 0, Thing4.count - - Thing1.create(:id => 1, :name => "thing1", :email => "thing1@localhost", :moment => Time.now) - assert_equal 1, Thing1.count - assert_equal 0, Thing2.count - assert_equal 0, Thing3.count - assert_equal 0, Thing4.count - - Thing2.create(:id => 1, :name => "thing1", :email => "thing1@localhost", :moment => Time.now) - assert_equal 1, Thing1.count - assert_equal 1, Thing2.count - assert_equal 0, Thing3.count - assert_equal 0, Thing4.count - - Thing3.create(:id => 1, :name => "thing1", :email => "thing1@localhost", :moment => Time.now) - assert_equal 1, Thing1.count - assert_equal 1, Thing2.count - assert_equal 1, Thing3.count - assert_equal 0, Thing4.count - - Thing4.create(:id => 1, :name => "thing1", :email => "thing1@localhost", :moment => Time.now) - assert_equal 1, Thing1.count - assert_equal 1, Thing2.count - assert_equal 1, Thing3.count - assert_equal 1, Thing4.count - end - - def test_raise_on_unquoted_schema_name - assert_raise(ActiveRecord::StatementInvalid) do - with_schema_search_path '$user,public' - end - end - - def test_without_schema_search_path - assert_raise(ActiveRecord::StatementInvalid) { columns(TABLE_NAME) } - end - - def test_ignore_nil_schema_search_path - assert_nothing_raised { with_schema_search_path nil } - end - - def test_dump_indexes_for_schema_one - do_dump_index_tests_for_schema(SCHEMA_NAME, INDEX_A_COLUMN, INDEX_B_COLUMN_S1) - end - - def test_dump_indexes_for_schema_two - do_dump_index_tests_for_schema(SCHEMA2_NAME, INDEX_A_COLUMN, INDEX_B_COLUMN_S2) - end - - def test_with_uppercase_index_name - ActiveRecord::Base.connection.execute "CREATE INDEX \"things_Index\" ON #{SCHEMA_NAME}.things (name)" - assert_nothing_raised { ActiveRecord::Base.connection.remove_index! "things", "#{SCHEMA_NAME}.things_Index"} - - ActiveRecord::Base.connection.execute "CREATE INDEX \"things_Index\" ON #{SCHEMA_NAME}.things (name)" - ActiveRecord::Base.connection.schema_search_path = SCHEMA_NAME - assert_nothing_raised { ActiveRecord::Base.connection.remove_index! "things", "things_Index"} - ActiveRecord::Base.connection.schema_search_path = "public" - end - - private - def columns(table_name) - @connection.send(:column_definitions, table_name).map do |name, type, default| - "#{name} #{type}" + (default ? " default #{default}" : '') - end - end - - def with_schema_search_path(schema_search_path) - @connection.schema_search_path = schema_search_path - yield if block_given? - ensure - @connection.schema_search_path = "'$user', public" - end - - def do_dump_index_tests_for_schema(this_schema_name, first_index_column_name, second_index_column_name) - with_schema_search_path(this_schema_name) do - indexes = @connection.indexes(TABLE_NAME).sort_by {|i| i.name} - assert_equal 2,indexes.size - - do_dump_index_assertions_for_one_index(indexes[0], INDEX_A_NAME, first_index_column_name) - do_dump_index_assertions_for_one_index(indexes[1], INDEX_B_NAME, second_index_column_name) - end - end - - def do_dump_index_assertions_for_one_index(this_index, this_index_name, this_index_column) - assert_equal TABLE_NAME, this_index.table - assert_equal 1, this_index.columns.size - assert_equal this_index_column, this_index.columns[0] - assert_equal this_index_name, this_index.name - end -end diff --git a/vendor/rails/activerecord/test/cases/serialization_test.rb b/vendor/rails/activerecord/test/cases/serialization_test.rb deleted file mode 100644 index 88416942..00000000 --- a/vendor/rails/activerecord/test/cases/serialization_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "cases/helper" -require 'models/contact' - -class SerializationTest < ActiveRecord::TestCase - FORMATS = [ :xml, :json ] - - def setup - @contact_attributes = { - :name => 'aaron stack', - :age => 25, - :avatar => 'binarydata', - :created_at => Time.utc(2006, 8, 1), - :awesome => false, - :preferences => { :gem => '<strong>ruby</strong>' } - } - - @contact = Contact.new(@contact_attributes) - end - - def test_serialize_should_be_reversible - for format in FORMATS - @serialized = Contact.new.send("to_#{format}") - contact = Contact.new.send("from_#{format}", @serialized) - - assert_equal @contact_attributes.keys.collect(&:to_s).sort, contact.attributes.keys.collect(&:to_s).sort, "For #{format}" - end - end - - def test_serialize_should_allow_attribute_only_filtering - for format in FORMATS - @serialized = Contact.new(@contact_attributes).send("to_#{format}", :only => [ :age, :name ]) - contact = Contact.new.send("from_#{format}", @serialized) - assert_equal @contact_attributes[:name], contact.name, "For #{format}" - assert_nil contact.avatar, "For #{format}" - end - end - - def test_serialize_should_allow_attribute_except_filtering - for format in FORMATS - @serialized = Contact.new(@contact_attributes).send("to_#{format}", :except => [ :age, :name ]) - contact = Contact.new.send("from_#{format}", @serialized) - assert_nil contact.name, "For #{format}" - assert_nil contact.age, "For #{format}" - assert_equal @contact_attributes[:awesome], contact.awesome, "For #{format}" - end - end -end diff --git a/vendor/rails/activerecord/test/cases/sp_test_mysql.rb b/vendor/rails/activerecord/test/cases/sp_test_mysql.rb deleted file mode 100644 index 1f6da4bc..00000000 --- a/vendor/rails/activerecord/test/cases/sp_test_mysql.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/minimalistic' - -class StoredProcedureTest < ActiveRecord::TestCase - fixtures :topics - - # Test that MySQL allows multiple results for stored procedures - if Mysql.const_defined?(:CLIENT_MULTI_RESULTS) - def test_multi_results_from_find_by_sql - topics = Topic.find_by_sql 'CALL topics();' - assert_equal 1, topics.size - assert ActiveRecord::Base.connection.active?, "Bad connection use by 'MysqlAdapter.select'" - end - end -end diff --git a/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb b/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb deleted file mode 100644 index b9a422a6..00000000 --- a/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/subject' - -# confirm that synonyms work just like tables; in this case -# the "subjects" table in Oracle (defined in oci.sql) is just -# a synonym to the "topics" table - -class TestOracleSynonym < ActiveRecord::TestCase - - def test_oracle_synonym - topic = Topic.new - subject = Subject.new - assert_equal(topic.attributes, subject.attributes) - end - -end diff --git a/vendor/rails/activerecord/test/cases/timestamp_test.rb b/vendor/rails/activerecord/test/cases/timestamp_test.rb deleted file mode 100644 index 24b237a7..00000000 --- a/vendor/rails/activerecord/test/cases/timestamp_test.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'cases/helper' -require 'models/developer' -require 'models/owner' -require 'models/pet' - -class TimestampTest < ActiveRecord::TestCase - fixtures :developers, :owners, :pets - - def setup - @developer = Developer.first - @previously_updated_at = @developer.updated_at - end - - def test_saving_a_changed_record_updates_its_timestamp - @developer.name = "Jack Bauer" - @developer.save! - - assert @previously_updated_at != @developer.updated_at - end - - def test_saving_a_unchanged_record_doesnt_update_its_timestamp - @developer.save! - - assert @previously_updated_at == @developer.updated_at - end - - def test_touching_a_record_updates_its_timestamp - @developer.touch - - assert @previously_updated_at != @developer.updated_at - end - - def test_touching_a_different_attribute - previously_created_at = @developer.created_at - @developer.touch(:created_at) - - assert previously_created_at != @developer.created_at - end - - def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at - pet = Pet.first - owner = pet.owner - previously_owner_updated_at = owner.updated_at - - pet.name = "Fluffy the Third" - pet.save - - assert previously_owner_updated_at != pet.owner.updated_at - end - - def test_destroying_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at - pet = Pet.first - owner = pet.owner - previously_owner_updated_at = owner.updated_at - - pet.destroy - - assert previously_owner_updated_at != pet.owner.updated_at - end - - def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_attribute_the_parent_should_update_that_attribute - Pet.belongs_to :owner, :touch => :happy_at - - pet = Pet.first - owner = pet.owner - previously_owner_happy_at = owner.happy_at - - pet.name = "Fluffy the Third" - pet.save - - assert previously_owner_happy_at != pet.owner.happy_at - ensure - Pet.belongs_to :owner, :touch => true - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/transactions_test.rb b/vendor/rails/activerecord/test/cases/transactions_test.rb deleted file mode 100644 index a4184d81..00000000 --- a/vendor/rails/activerecord/test/cases/transactions_test.rb +++ /dev/null @@ -1,543 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/developer' -require 'models/book' -require 'models/author' -require 'models/post' - -class TransactionTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :topics, :developers, :authors, :posts - - def setup - @first, @second = Topic.find(1, 2).sort_by { |t| t.id } - end - - def test_successful - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - end - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - end - - def transaction_with_return - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - return - end - end - - def test_update_attributes_should_rollback_on_failure - author = Author.find(1) - posts_count = author.posts.size - assert posts_count > 0 - status = author.update_attributes(:name => nil, :post_ids => []) - assert !status - assert_equal posts_count, author.posts(true).size - end - - def test_update_attributes_should_rollback_on_failure! - author = Author.find(1) - posts_count = author.posts.size - assert posts_count > 0 - assert_raise(ActiveRecord::RecordInvalid) do - author.update_attributes!(:name => nil, :post_ids => []) - end - assert_equal posts_count, author.posts(true).size - end - - def test_successful_with_return - class << Topic.connection - alias :real_commit_db_transaction :commit_db_transaction - def commit_db_transaction - $committed = true - real_commit_db_transaction - end - end - - $committed = false - transaction_with_return - assert $committed - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - ensure - class << Topic.connection - alias :commit_db_transaction :real_commit_db_transaction rescue nil - end - end - - def test_successful_with_instance_method - @first.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - end - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - end - - def test_failing_on_exception - begin - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - raise "Bad things!" - end - rescue - # caught it - end - - assert @first.approved?, "First should still be changed in the objects" - assert !@second.approved?, "Second should still be changed in the objects" - - assert !Topic.find(1).approved?, "First shouldn't have been approved" - assert Topic.find(2).approved?, "Second should still be approved" - end - - def test_raising_exception_in_callback_rollbacks_in_save - add_exception_raising_after_save_callback_to_topic - - begin - @first.approved = true - @first.save - flunk - rescue => e - assert_equal "Make the transaction rollback", e.message - assert !Topic.find(1).approved? - ensure - remove_exception_raising_after_save_callback_to_topic - end - end - - def test_cancellation_from_before_destroy_rollbacks_in_destroy - add_cancelling_before_destroy_with_db_side_effect_to_topic - begin - nbooks_before_destroy = Book.count - status = @first.destroy - assert !status - assert_nothing_raised(ActiveRecord::RecordNotFound) { @first.reload } - assert_equal nbooks_before_destroy, Book.count - ensure - remove_cancelling_before_destroy_with_db_side_effect_to_topic - end - end - - def test_cancellation_from_before_filters_rollbacks_in_save - %w(validation save).each do |filter| - send("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") - begin - nbooks_before_save = Book.count - original_author_name = @first.author_name - @first.author_name += '_this_should_not_end_up_in_the_db' - status = @first.save - assert !status - assert_equal original_author_name, @first.reload.author_name - assert_equal nbooks_before_save, Book.count - ensure - send("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") - end - end - end - - def test_cancellation_from_before_filters_rollbacks_in_save! - %w(validation save).each do |filter| - send("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") - begin - nbooks_before_save = Book.count - original_author_name = @first.author_name - @first.author_name += '_this_should_not_end_up_in_the_db' - @first.save! - flunk - rescue => e - assert_equal original_author_name, @first.reload.author_name - assert_equal nbooks_before_save, Book.count - ensure - send("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") - end - end - end - - def test_callback_rollback_in_create - new_topic = Topic.new( - :title => "A new topic", - :author_name => "Ben", - :author_email_address => "ben@example.com", - :written_on => "2003-07-16t15:28:11.2233+01:00", - :last_read => "2004-04-15", - :bonus_time => "2005-01-30t15:28:00.00+01:00", - :content => "Have a nice day", - :approved => false) - new_record_snapshot = new_topic.new_record? - id_present = new_topic.has_attribute?(Topic.primary_key) - id_snapshot = new_topic.id - - # Make sure the second save gets the after_create callback called. - 2.times do - begin - add_exception_raising_after_create_callback_to_topic - new_topic.approved = true - new_topic.save - flunk - rescue => e - assert_equal "Make the transaction rollback", e.message - assert_equal new_record_snapshot, new_topic.new_record?, "The topic should have its old new_record value" - assert_equal id_snapshot, new_topic.id, "The topic should have its old id" - assert_equal id_present, new_topic.has_attribute?(Topic.primary_key) - ensure - remove_exception_raising_after_create_callback_to_topic - end - end - end - - def test_nested_explicit_transactions - Topic.transaction do - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - end - end - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - end - - def test_manually_rolling_back_a_transaction - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - - raise ActiveRecord::Rollback - end - - assert @first.approved?, "First should still be changed in the objects" - assert !@second.approved?, "Second should still be changed in the objects" - - assert !Topic.find(1).approved?, "First shouldn't have been approved" - assert Topic.find(2).approved?, "Second should still be approved" - end - - def test_invalid_keys_for_transaction - assert_raise ArgumentError do - Topic.transaction :nested => true do - end - end - end - - def test_force_savepoint_in_nested_transaction - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save! - @second.save! - - begin - Topic.transaction :requires_new => true do - @first.happy = false - @first.save! - raise - end - rescue - end - end - - assert @first.reload.approved? - assert !@second.reload.approved? - end if Topic.connection.supports_savepoints? - - def test_no_savepoint_in_nested_transaction_without_force - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save! - @second.save! - - begin - Topic.transaction do - @first.approved = false - @first.save! - raise - end - rescue - end - end - - assert !@first.reload.approved? - assert !@second.reload.approved? - end if Topic.connection.supports_savepoints? - - def test_many_savepoints - Topic.transaction do - @first.content = "One" - @first.save! - - begin - Topic.transaction :requires_new => true do - @first.content = "Two" - @first.save! - - begin - Topic.transaction :requires_new => true do - @first.content = "Three" - @first.save! - - begin - Topic.transaction :requires_new => true do - @first.content = "Four" - @first.save! - raise - end - rescue - end - - @three = @first.reload.content - raise - end - rescue - end - - @two = @first.reload.content - raise - end - rescue - end - - @one = @first.reload.content - end - - assert_equal "One", @one - assert_equal "Two", @two - assert_equal "Three", @three - end if Topic.connection.supports_savepoints? - - def test_rollback_when_commit_raises - Topic.connection.expects(:begin_db_transaction) - Topic.connection.expects(:commit_db_transaction).raises('OH NOES') - Topic.connection.expects(:outside_transaction?).returns(false) - Topic.connection.expects(:rollback_db_transaction) - - assert_raise RuntimeError do - Topic.transaction do - # do nothing - end - end - end - - if current_adapter?(:PostgreSQLAdapter) && defined?(PGconn::PQTRANS_IDLE) - def test_outside_transaction_works - assert Topic.connection.outside_transaction? - Topic.connection.begin_db_transaction - assert !Topic.connection.outside_transaction? - Topic.connection.rollback_db_transaction - assert Topic.connection.outside_transaction? - end - - def test_rollback_wont_be_executed_if_no_transaction_active - assert_raise RuntimeError do - Topic.transaction do - Topic.connection.rollback_db_transaction - Topic.connection.expects(:rollback_db_transaction).never - raise "Rails doesn't scale!" - end - end - end - - def test_open_transactions_count_is_reset_to_zero_if_no_transaction_active - Topic.transaction do - Topic.transaction do - Topic.connection.rollback_db_transaction - end - assert_equal 0, Topic.connection.open_transactions - end - assert_equal 0, Topic.connection.open_transactions - end - end - - def test_sqlite_add_column_in_transaction - return true unless current_adapter?(:SQLite3Adapter, :SQLiteAdapter) - - # Test first if column creation/deletion works correctly when no - # transaction is in place. - # - # We go back to the connection for the column queries because - # Topic.columns is cached and won't report changes to the DB - - assert_nothing_raised do - Topic.reset_column_information - Topic.connection.add_column('topics', 'stuff', :string) - assert Topic.column_names.include?('stuff') - - Topic.reset_column_information - Topic.connection.remove_column('topics', 'stuff') - assert !Topic.column_names.include?('stuff') - end - - if Topic.connection.supports_ddl_transactions? - assert_nothing_raised do - Topic.transaction { Topic.connection.add_column('topics', 'stuff', :string) } - end - else - Topic.transaction do - assert_raise(ActiveRecord::StatementInvalid) { Topic.connection.add_column('topics', 'stuff', :string) } - raise ActiveRecord::Rollback - end - end - end - - private - def add_exception_raising_after_save_callback_to_topic - Topic.class_eval { def after_save() raise "Make the transaction rollback" end } - end - - def remove_exception_raising_after_save_callback_to_topic - Topic.class_eval { remove_method :after_save } - end - - def add_exception_raising_after_create_callback_to_topic - Topic.class_eval { def after_create() raise "Make the transaction rollback" end } - end - - def remove_exception_raising_after_create_callback_to_topic - Topic.class_eval { remove_method :after_create } - end - - %w(validation save destroy).each do |filter| - define_method("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") do - Topic.class_eval "def before_#{filter}() Book.create; false end" - end - - define_method("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") do - Topic.class_eval "remove_method :before_#{filter}" - end - end -end - -class TransactionsWithTransactionalFixturesTest < ActiveRecord::TestCase - self.use_transactional_fixtures = true - fixtures :topics - - def test_automatic_savepoint_in_outer_transaction - @first = Topic.find(1) - - begin - Topic.transaction do - @first.approved = true - @first.save! - raise - end - rescue - assert !@first.reload.approved? - end - end - - def test_no_automatic_savepoint_for_inner_transaction - @first = Topic.find(1) - - Topic.transaction do - @first.approved = true - @first.save! - - begin - Topic.transaction do - @first.approved = false - @first.save! - raise - end - rescue - end - end - - assert !@first.reload.approved? - end -end if Topic.connection.supports_savepoints? - -if current_adapter?(:PostgreSQLAdapter) - class ConcurrentTransactionTest < TransactionTest - use_concurrent_connections - - # This will cause transactions to overlap and fail unless they are performed on - # separate database connections. - def test_transaction_per_thread - assert_nothing_raised do - threads = (1..3).map do - Thread.new do - Topic.transaction do - topic = Topic.find(1) - topic.approved = !topic.approved? - topic.save! - topic.approved = !topic.approved? - topic.save! - end - end - end - - threads.each { |t| t.join } - end - end - - # Test for dirty reads among simultaneous transactions. - def test_transaction_isolation__read_committed - # Should be invariant. - original_salary = Developer.find(1).salary - temporary_salary = 200000 - - assert_nothing_raised do - threads = (1..3).map do - Thread.new do - Developer.transaction do - # Expect original salary. - dev = Developer.find(1) - assert_equal original_salary, dev.salary - - dev.salary = temporary_salary - dev.save! - - # Expect temporary salary. - dev = Developer.find(1) - assert_equal temporary_salary, dev.salary - - dev.salary = original_salary - dev.save! - - # Expect original salary. - dev = Developer.find(1) - assert_equal original_salary, dev.salary - end - end - end - - # Keep our eyes peeled. - threads << Thread.new do - 10.times do - sleep 0.05 - Developer.transaction do - # Always expect original salary. - assert_equal original_salary, Developer.find(1).salary - end - end - end - - threads.each { |t| t.join } - end - - assert_equal original_salary, Developer.find(1).salary - end - end -end diff --git a/vendor/rails/activerecord/test/cases/unconnected_test.rb b/vendor/rails/activerecord/test/cases/unconnected_test.rb deleted file mode 100644 index 23ad10f3..00000000 --- a/vendor/rails/activerecord/test/cases/unconnected_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "cases/helper" - -class TestRecord < ActiveRecord::Base -end - -class TestUnconnectedAdapter < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @underlying = ActiveRecord::Base.connection - @specification = ActiveRecord::Base.remove_connection - end - - def teardown - @underlying = nil - ActiveRecord::Base.establish_connection(@specification) - end - - def test_connection_no_longer_established - assert_raise(ActiveRecord::ConnectionNotEstablished) do - TestRecord.find(1) - end - - assert_raise(ActiveRecord::ConnectionNotEstablished) do - TestRecord.new.save - end - end - - def test_underlying_adapter_no_longer_active - assert !@underlying.active?, "Removed adapter should no longer be active" - end -end diff --git a/vendor/rails/activerecord/test/cases/validations_i18n_test.rb b/vendor/rails/activerecord/test/cases/validations_i18n_test.rb deleted file mode 100644 index 88850d35..00000000 --- a/vendor/rails/activerecord/test/cases/validations_i18n_test.rb +++ /dev/null @@ -1,925 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/person' - -module ActiveRecordValidationsI18nTestHelper - def store_translations(*args) - data = args.extract_options! - locale = args.shift || 'en' - I18n.backend.send(:init_translations) - I18n.backend.store_translations(locale, :activerecord => data) - end - - def delete_translation(key) - I18n.backend.instance_eval do - keys = I18n.send(:normalize_translation_keys, 'en', key, nil) - keys.inject(translations) { |result, k| keys.last == k ? result.delete(k.to_sym) : result[k.to_sym] } - end - end - - def reset_callbacks(*models) - models.each do |model| - model.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - model.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - model.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - end - end -end - - -# ACTIVERECORD VALIDATIONS -# -# For each validation: -# -# * test expect that it adds an error with the appropriate arguments -# * test that it looks up the correct default message - -class ActiveRecordValidationsI18nTests < ActiveSupport::TestCase - include ActiveRecordValidationsI18nTestHelper - - def setup - reset_callbacks(Topic) - @topic = Topic.new - @reply = Reply.new - @old_load_path, @old_backend = I18n.load_path, I18n.backend - I18n.load_path.clear - I18n.backend = I18n::Backend::Simple.new - I18n.backend.store_translations('en', :activerecord => {:errors => {:messages => {:custom => nil}}}) - end - - def teardown - reset_callbacks(Topic) - I18n.load_path.replace(@old_load_path) - I18n.backend = @old_backend - end - - def expect_error_added(model, attribute, type, options) - model.errors.expects(:add).with(attribute, type, options) - yield - model.valid? - end - - def assert_message_translations(model, attribute, type, &block) - assert_default_message_translation(model, attribute, type, &block) - reset_callbacks(model.class) - model.errors.clear - assert_custom_message_translation(model, attribute, type, &block) - end - - def assert_custom_message_translation(model, attribute, type) - store_translations(:errors => { :models => { model.class.name.underscore => { :attributes => { attribute => { type => 'custom message' } } } } }) - yield - model.valid? - assert_equal 'custom message', model.errors.on(attribute) - end - - def assert_default_message_translation(model, attribute, type) - store_translations(:errors => { :messages => { type => 'default message' } }) - yield - model.valid? - assert_equal 'default message', model.errors.on(attribute) - end - - def unique_topic - @unique ||= Topic.create(:title => 'unique!') - end - - def replied_topic - @replied_topic ||= begin - topic = Topic.create(:title => "topic") - topic.replies << Reply.new - topic - end - end - - # validates_confirmation_of - - test "#validates_confirmation_of given no custom message" do - expect_error_added(@topic, :title, :confirmation, :default => nil) do - Topic.validates_confirmation_of :title - @topic.title = 'title' - @topic.title_confirmation = 'foo' - end - end - - test "#validates_confirmation_of given a custom message" do - expect_error_added(@topic, :title, :confirmation, :default => 'custom') do - Topic.validates_confirmation_of :title, :message => 'custom' - @topic.title_confirmation = 'foo' - end - end - - test "#validates_confirmation_of finds the correct message translations" do - assert_message_translations(@topic, :title, :confirmation) do - Topic.validates_confirmation_of :title - @topic.title_confirmation = 'foo' - end - end - - # validates_acceptance_of - - test "#validates_acceptance_of given no custom message" do - expect_error_added(@topic, :title, :accepted, :default => nil) do - Topic.validates_acceptance_of :title, :allow_nil => false - end - end - - test "#validates_acceptance_of given a custom message" do - expect_error_added(@topic, :title, :accepted, :default => 'custom') do - Topic.validates_acceptance_of :title, :message => 'custom', :allow_nil => false - end - end - - test "#validates_acceptance_of finds the correct message translations" do - assert_message_translations(@topic, :title, :accepted) do - Topic.validates_acceptance_of :title, :allow_nil => false - end - end - - # validates_presence_of - - test "#validates_presence_of given no custom message" do - expect_error_added(@topic, :title, :blank, :default => nil) do - Topic.validates_presence_of :title - end - end - - test "#validates_presence_of given a custom message" do - expect_error_added(@topic, :title, :blank, :default => 'custom') do - Topic.validates_presence_of :title, :message => 'custom' - end - end - - test "#validates_presence_of finds the correct message translations" do - assert_message_translations(@topic, :title, :blank) do - Topic.validates_presence_of :title - end - end - - # validates_length_of :too_short - - test "#validates_length_of (:too_short) and no custom message" do - expect_error_added(@topic, :title, :too_short, :default => nil, :count => 3) do - Topic.validates_length_of :title, :within => 3..5 - end - end - - test "#validates_length_of (:too_short) and a custom message" do - expect_error_added(@topic, :title, :too_short, :default => 'custom', :count => 3) do - Topic.validates_length_of :title, :within => 3..5, :too_short => 'custom' - end - end - - test "#validates_length_of (:too_short) finds the correct message translations" do - assert_message_translations(@topic, :title, :too_short) do - Topic.validates_length_of :title, :within => 3..5 - end - end - - # validates_length_of :too_long - - test "#validates_length_of (:too_long) and no custom message" do - expect_error_added(@topic, :title, :too_long, :default => nil, :count => 5) do - Topic.validates_length_of :title, :within => 3..5 - @topic.title = 'this title is too long' - end - end - - test "#validates_length_of (:too_long) and a custom message" do - expect_error_added(@topic, :title, :too_long, :default => 'custom', :count => 5) do - Topic.validates_length_of :title, :within => 3..5, :too_long => 'custom' - @topic.title = 'this title is too long' - end - end - - test "#validates_length_of (:too_long) finds the correct message translations" do - assert_message_translations(@topic, :title, :too_long) do - Topic.validates_length_of :title, :within => 3..5 - @topic.title = 'this title is too long' - end - end - - # validates_length_of :is - - test "#validates_length_of (:is) and no custom message" do - expect_error_added(@topic, :title, :wrong_length, :default => nil, :count => 5) do - Topic.validates_length_of :title, :is => 5 - @topic.title = 'this title has the wrong length' - end - end - - test "#validates_length_of (:is) and a custom message" do - expect_error_added(@topic, :title, :wrong_length, :default => 'custom', :count => 5) do - Topic.validates_length_of :title, :is => 5, :wrong_length => 'custom' - @topic.title = 'this title has the wrong length' - end - end - - test "#validates_length_of (:is) finds the correct message translations" do - assert_message_translations(@topic, :title, :wrong_length) do - Topic.validates_length_of :title, :is => 5 - @topic.title = 'this title has the wrong length' - end - end - - # validates_uniqueness_of - - test "#validates_uniqueness_of and no custom message" do - expect_error_added(@topic, :title, :taken, :default => nil, :value => 'unique!') do - Topic.validates_uniqueness_of :title - @topic.title = unique_topic.title - end - end - - test "#validates_uniqueness_of and a custom message" do - expect_error_added(@topic, :title, :taken, :default => 'custom', :value => 'unique!') do - Topic.validates_uniqueness_of :title, :message => 'custom' - @topic.title = unique_topic.title - end - end - - test "#validates_uniqueness_of finds the correct message translations" do - assert_message_translations(@topic, :title, :taken) do - Topic.validates_uniqueness_of :title - @topic.title = unique_topic.title - end - end - - # validates_format_of - - test "#validates_format_of and no custom message" do - expect_error_added(@topic, :title, :invalid, :default => nil, :value => '72x') do - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/ - @topic.title = '72x' - end - end - - test "#validates_format_of and a custom message" do - expect_error_added(@topic, :title, :invalid, :default => 'custom', :value => '72x') do - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/, :message => 'custom' - @topic.title = '72x' - end - end - - test "#validates_format_of finds the correct message translations" do - assert_message_translations(@topic, :title, :invalid) do - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/ - @topic.title = '72x' - end - end - - # validates_inclusion_of - - test "#validates_inclusion_of and no custom message" do - list = %w(a b c) - expect_error_added(@topic, :title, :inclusion, :default => nil, :value => 'z') do - Topic.validates_inclusion_of :title, :in => list - @topic.title = 'z' - end - end - - test "#validates_inclusion_of and a custom message" do - list = %w(a b c) - expect_error_added(@topic, :title, :inclusion, :default => 'custom', :value => 'z') do - Topic.validates_inclusion_of :title, :in => list, :message => 'custom' - @topic.title = 'z' - end - end - - test "#validates_inclusion_of finds the correct message translations" do - list = %w(a b c) - assert_message_translations(@topic, :title, :inclusion) do - Topic.validates_inclusion_of :title, :in => list - @topic.title = 'z' - end - end - - # validates_exclusion_of - - test "#validates_exclusion_of and no custom message" do - list = %w(a b c) - expect_error_added(@topic, :title, :exclusion, :default => nil, :value => 'a') do - Topic.validates_exclusion_of :title, :in => list - @topic.title = 'a' - end - end - - test "#validates_exclusion_of and a custom message" do - list = %w(a b c) - expect_error_added(@topic, :title, :exclusion, :default => 'custom', :value => 'a') do - Topic.validates_exclusion_of :title, :in => list, :message => 'custom' - @topic.title = 'a' - end - end - - test "#validates_exclusion_of finds the correct message translations" do - list = %w(a b c) - assert_message_translations(@topic, :title, :exclusion) do - Topic.validates_exclusion_of :title, :in => list - @topic.title = 'a' - end - end - - # validates_numericality_of :not_a_number, without :only_integer - - test "#validates_numericality_of (:not_a_number, w/o :only_integer) no custom message" do - expect_error_added(@topic, :title, :not_a_number, :default => nil, :value => 'a') do - Topic.validates_numericality_of :title - @topic.title = 'a' - end - end - - test "#validates_numericality_of (:not_a_number, w/o :only_integer) and a custom message" do - expect_error_added(@topic, :title, :not_a_number, :default => 'custom', :value => 'a') do - Topic.validates_numericality_of :title, :message => 'custom' - @topic.title = 'a' - end - end - - test "#validates_numericality_of (:not_a_number, w/o :only_integer) finds the correct message translations" do - assert_message_translations(@topic, :title, :not_a_number) do - Topic.validates_numericality_of :title - @topic.title = 'a' - end - end - - # validates_numericality_of :not_a_number, with :only_integer - - test "#validates_numericality_of (:not_a_number, with :only_integer) no custom message" do - expect_error_added(@topic, :title, :not_a_number, :default => nil, :value => 'a') do - Topic.validates_numericality_of :title, :only_integer => true - @topic.title = 'a' - end - end - - test "#validates_numericality_of (:not_a_number, with :only_integer) and a custom message" do - expect_error_added(@topic, :title, :not_a_number, :default => 'custom', :value => 'a') do - Topic.validates_numericality_of :title, :only_integer => true, :message => 'custom' - @topic.title = 'a' - end - end - - test "#validates_numericality_of (:not_a_number, with :only_integer) finds the correct message translations" do - assert_message_translations(@topic, :title, :not_a_number) do - Topic.validates_numericality_of :title, :only_integer => true - @topic.title = 'a' - end - end - - # validates_numericality_of :odd - - test "#validates_numericality_of (:odd) no custom message" do - expect_error_added(@topic, :title, :odd, :default => nil, :value => 0) do - Topic.validates_numericality_of :title, :only_integer => true, :odd => true - @topic.title = 0 - end - end - - test "#validates_numericality_of (:odd) and a custom message" do - expect_error_added(@topic, :title, :odd, :default => 'custom', :value => 0) do - Topic.validates_numericality_of :title, :only_integer => true, :odd => true, :message => 'custom' - @topic.title = 0 - end - end - - test "#validates_numericality_of (:odd) finds the correct message translations" do - assert_message_translations(@topic, :title, :odd) do - Topic.validates_numericality_of :title, :only_integer => true, :odd => true - @topic.title = 0 - end - end - - # validates_numericality_of :even - - test "#validates_numericality_of (:even) no custom message" do - expect_error_added(@topic, :title, :even, :default => nil, :value => 1) do - Topic.validates_numericality_of :title, :only_integer => true, :even => true - @topic.title = 1 - end - end - - test "#validates_numericality_of (:even) and a custom message" do - expect_error_added(@topic, :title, :even, :default => 'custom', :value => 1) do - Topic.validates_numericality_of :title, :only_integer => true, :even => true, :message => 'custom' - @topic.title = 1 - end - end - - test "#validates_numericality_of (:even) finds the correct message translations" do - assert_message_translations(@topic, :title, :even) do - Topic.validates_numericality_of :title, :only_integer => true, :even => true - @topic.title = 1 - end - end - - # validates_numericality_of :less_than - - test "#validates_numericality_of (:less_than) no custom message" do - expect_error_added(@topic, :title, :less_than, :default => nil, :value => 1, :count => 0) do - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0 - @topic.title = 1 - end - end - - test "#validates_numericality_of (:less_than) and a custom message" do - expect_error_added(@topic, :title, :less_than, :default => 'custom', :value => 1, :count => 0) do - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0, :message => 'custom' - @topic.title = 1 - end - end - - test "#validates_numericality_of (:less_than) finds the correct message translations" do - assert_message_translations(@topic, :title, :less_than) do - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0 - @topic.title = 1 - end - end - - # validates_associated - - test "#validates_associated no custom message" do - expect_error_added(replied_topic, :replies, :invalid, :default => nil, :value => replied_topic.replies) do - Topic.validates_associated :replies - end - end - - test "#validates_associated and a custom message" do - expect_error_added(replied_topic, :replies, :invalid, :default => 'custom', :value => replied_topic.replies) do - Topic.validates_associated :replies, :message => 'custom' - end - end - - test "#validates_associated finds the correct message translations" do - assert_message_translations(replied_topic, :replies, :invalid) do - Topic.validates_associated :replies - end - end -end - - -# ACTIVERECORD ERROR -# -# * test that it passes given interpolation arguments, the human model name and human attribute name -# * test that it looks messages up with the the correct keys -# * test that it looks up the correct default messages - -class ActiveRecordErrorI18nTests < ActiveSupport::TestCase - include ActiveRecordValidationsI18nTestHelper - - def setup - @reply = Reply.new - @old_backend, I18n.backend = I18n.backend, I18n::Backend::Simple.new - end - - def teardown - I18n.backend = @old_backend - I18n.locale = nil - end - - def assert_error_message(message, *args) - assert_equal message, ActiveRecord::Error.new(@reply, *args).message - end - - def assert_full_message(message, *args) - assert_equal message, ActiveRecord::Error.new(@reply, *args).full_message - end - - test ":default is only given to message if a symbol is supplied" do - store_translations(:errors => { :messages => { :"foo bar" => "You fooed: %{value}." } }) - @reply.errors.add(:title, :inexistent, :default => "foo bar") - assert_equal "foo bar", @reply.errors[:title] - end - - test "#generate_message passes the model attribute value for interpolation" do - store_translations(:errors => { :messages => { :foo => "You fooed: %{value}." } }) - @reply.title = "da title" - assert_error_message 'You fooed: da title.', :title, :foo - end - - test "#generate_message passes the human_name of the model for interpolation" do - store_translations( - :errors => { :messages => { :foo => "You fooed: %{model}." } }, - :models => { :topic => 'da topic' } - ) - assert_error_message 'You fooed: da topic.', :title, :foo - end - - test "#generate_message passes the human_name of the attribute for interpolation" do - store_translations( - :errors => { :messages => { :foo => "You fooed: %{attribute}." } }, - :attributes => { :topic => { :title => 'da topic title' } } - ) - assert_error_message 'You fooed: da topic title.', :title, :foo - end - - # generate_message will look up the key for the error message (e.g. :blank) in these namespaces: - # - # activerecord.errors.models.reply.attributes.title - # activerecord.errors.models.reply - # activerecord.errors.models.topic.attributes.title - # activerecord.errors.models.topic - # [default from class level :validates_foo statement if this is a String] - # activerecord.errors.messages - - test "#generate_message key fallbacks (given a String as key)" do - store_translations( - :errors => { - :models => { - :reply => { - :attributes => { :title => { :custom => 'activerecord.errors.models.reply.attributes.title.custom' } }, - :custom => 'activerecord.errors.models.reply.custom' - }, - :topic => { - :attributes => { :title => { :custom => 'activerecord.errors.models.topic.attributes.title.custom' } }, - :custom => 'activerecord.errors.models.topic.custom' - } - }, - :messages => { - :custom => 'activerecord.errors.messages.custom', - :kaputt => 'activerecord.errors.messages.kaputt' - } - } - ) - - assert_error_message 'activerecord.errors.models.reply.attributes.title.custom', :title, :kaputt, :message => 'custom' - delete_translation :'activerecord.errors.models.reply.attributes.title.custom' - - assert_error_message 'activerecord.errors.models.reply.custom', :title, :kaputt, :message => 'custom' - delete_translation :'activerecord.errors.models.reply.custom' - - assert_error_message 'activerecord.errors.models.topic.attributes.title.custom', :title, :kaputt, :message => 'custom' - delete_translation :'activerecord.errors.models.topic.attributes.title.custom' - - assert_error_message 'activerecord.errors.models.topic.custom', :title, :kaputt, :message => 'custom' - delete_translation :'activerecord.errors.models.topic.custom' - - assert_error_message 'activerecord.errors.messages.custom', :title, :kaputt, :message => 'custom' - delete_translation :'activerecord.errors.messages.custom' - - # Implementing this would clash with the AR default behaviour of using validates_foo :message => 'foo' - # as an untranslated string. I.e. at this point we can either fall back to the given string from the - # class-level macro (validates_*) or fall back to the default message for this validation type. - # assert_error_message 'activerecord.errors.messages.kaputt', :title, :kaputt, :message => 'custom' - - assert_error_message 'custom', :title, :kaputt, :message => 'custom' - end - - test "#generate_message key fallbacks (given a Symbol as key)" do - store_translations( - :errors => { - :models => { - :reply => { - :attributes => { :title => { :kaputt => 'activerecord.errors.models.reply.attributes.title.kaputt' } }, - :kaputt => 'activerecord.errors.models.reply.kaputt' - }, - :topic => { - :attributes => { :title => { :kaputt => 'activerecord.errors.models.topic.attributes.title.kaputt' } }, - :kaputt => 'activerecord.errors.models.topic.kaputt' - } - }, - :messages => { - :kaputt => 'activerecord.errors.messages.kaputt' - } - } - ) - - assert_error_message 'activerecord.errors.models.reply.attributes.title.kaputt', :title, :kaputt - delete_translation :'activerecord.errors.models.reply.attributes.title.kaputt' - - assert_error_message 'activerecord.errors.models.reply.kaputt', :title, :kaputt - delete_translation :'activerecord.errors.models.reply.kaputt' - - assert_error_message 'activerecord.errors.models.topic.attributes.title.kaputt', :title, :kaputt - delete_translation :'activerecord.errors.models.topic.attributes.title.kaputt' - - assert_error_message 'activerecord.errors.models.topic.kaputt', :title, :kaputt - delete_translation :'activerecord.errors.models.topic.kaputt' - - assert_error_message 'activerecord.errors.messages.kaputt', :title, :kaputt - end - - # full_messages - - test "#full_message with no format present" do - store_translations(:errors => { :messages => { :kaputt => 'is kaputt' } }) - assert_full_message 'Title is kaputt', :title, :kaputt - end - - test "#full_message with a format present" do - store_translations(:errors => { :messages => { :kaputt => 'is kaputt' }, :full_messages => { :format => '%{attribute}: %{message}' } }) - assert_full_message 'Title: is kaputt', :title, :kaputt - end - - test "#full_message with a type specific format present" do - store_translations(:errors => { :messages => { :kaputt => 'is kaputt' }, :full_messages => { :kaputt => '%{attribute} %{message}!' } }) - assert_full_message 'Title is kaputt!', :title, :kaputt - end - - test "#full_message with class-level specified custom message" do - store_translations(:errors => { :messages => { :broken => 'is kaputt' }, :full_messages => { :broken => '%{attribute} %{message}?!' } }) - assert_full_message 'Title is kaputt?!', :title, :kaputt, :message => :broken - end - - test "#full_message with different scope" do - store_translations(:my_errors => { :messages => { :kaputt => 'is kaputt' } }) - assert_full_message 'Title is kaputt', :title, :kaputt, :scope => [:activerecord, :my_errors] - - store_translations(:my_errors => { :full_messages => { :kaputt => '%{attribute} %{message}!' } }) - assert_full_message 'Title is kaputt!', :title, :kaputt, :scope => [:activerecord, :my_errors] - end - - # switch locales - - test "#message allows to switch locales" do - store_translations(:en, :errors => { :messages => { :kaputt => 'is kaputt' } }) - store_translations(:de, :errors => { :messages => { :kaputt => 'ist kaputt' } }) - - assert_error_message 'is kaputt', :title, :kaputt - I18n.locale = :de - assert_error_message 'ist kaputt', :title, :kaputt - I18n.locale = :en - assert_error_message 'is kaputt', :title, :kaputt - end - - test "#full_message allows to switch locales" do - store_translations(:en, :errors => { :messages => { :kaputt => 'is kaputt' } }, :attributes => { :topic => { :title => 'The title' } }) - store_translations(:de, :errors => { :messages => { :kaputt => 'ist kaputt' } }, :attributes => { :topic => { :title => 'Der Titel' } }) - - assert_full_message 'The title is kaputt', :title, :kaputt - I18n.locale = :de - assert_full_message 'Der Titel ist kaputt', :title, :kaputt - I18n.locale = :en - assert_full_message 'The title is kaputt', :title, :kaputt - end -end - -# ACTIVERECORD DEFAULT ERROR MESSAGES -# -# * test that Error generates the default error messages - -class ActiveRecordDefaultErrorMessagesI18nTests < ActiveSupport::TestCase - def assert_default_error_message(message, *args) - assert_equal message, error_message(*args) - end - - def error_message(*args) - ActiveRecord::Error.new(Topic.new, :title, *args).message - end - - # used by: validates_inclusion_of - test "default error message: inclusion" do - assert_default_error_message 'is not included in the list', :inclusion, :value => 'title' - end - - # used by: validates_exclusion_of - test "default error message: exclusion" do - assert_default_error_message 'is reserved', :exclusion, :value => 'title' - end - - # used by: validates_associated and validates_format_of - test "default error message: invalid" do - assert_default_error_message 'is invalid', :invalid, :value => 'title' - end - - # used by: validates_confirmation_of - test "default error message: confirmation" do - assert_default_error_message "doesn't match confirmation", :confirmation, :default => nil - end - - # used by: validates_acceptance_of - test "default error message: accepted" do - assert_default_error_message "must be accepted", :accepted - end - - # used by: add_on_empty - test "default error message: empty" do - assert_default_error_message "can't be empty", :empty - end - - # used by: add_on_blank - test "default error message: blank" do - assert_default_error_message "can't be blank", :blank - end - - # used by: validates_length_of - test "default error message: too_long" do - assert_default_error_message "is too long (maximum is 10 characters)", :too_long, :count => 10 - end - - # used by: validates_length_of - test "default error message: too_short" do - assert_default_error_message "is too short (minimum is 10 characters)", :too_short, :count => 10 - end - - # used by: validates_length_of - test "default error message: wrong_length" do - assert_default_error_message "is the wrong length (should be 10 characters)", :wrong_length, :count => 10 - end - - # used by: validates_uniqueness_of - test "default error message: taken" do - assert_default_error_message "has already been taken", :taken, :value => 'title' - end - - # used by: validates_numericality_of - test "default error message: not_a_number" do - assert_default_error_message "is not a number", :not_a_number, :value => 'title' - end - - # used by: validates_numericality_of - test "default error message: greater_than" do - assert_default_error_message "must be greater than 10", :greater_than, :value => 'title', :count => 10 - end - - # used by: validates_numericality_of - test "default error message: greater_than_or_equal_to" do - assert_default_error_message "must be greater than or equal to 10", :greater_than_or_equal_to, :value => 'title', :count => 10 - end - - # used by: validates_numericality_of - test "default error message: equal_to" do - assert_default_error_message "must be equal to 10", :equal_to, :value => 'title', :count => 10 - end - - # used by: validates_numericality_of - test "default error message: less_than" do - assert_default_error_message "must be less than 10", :less_than, :value => 'title', :count => 10 - end - - # used by: validates_numericality_of - test "default error message: less_than_or_equal_to" do - assert_default_error_message "must be less than or equal to 10", :less_than_or_equal_to, :value => 'title', :count => 10 - end - - # used by: validates_numericality_of - test "default error message: odd" do - assert_default_error_message "must be odd", :odd, :value => 'title', :count => 10 - end - - # used by: validates_numericality_of - test "default error message: even" do - assert_default_error_message "must be even", :even, :value => 'title', :count => 10 - end - - test "custom message string interpolation" do - assert_equal 'custom message title', error_message(:invalid, :default => 'custom message %{value}', :value => 'title') - end -end - -# ACTIVERECORD VALIDATION ERROR MESSAGES - FULL STACK -# -# * test a few combinations full stack to ensure the tests above are correct - -class I18nPerson < Person -end - -class ActiveRecordValidationsI18nFullStackTests < ActiveSupport::TestCase - include ActiveRecordValidationsI18nTestHelper - - def setup - reset_callbacks(I18nPerson) - @old_backend, I18n.backend = I18n.backend, I18n::Backend::Simple.new - @person = I18nPerson.new - end - - def teardown - reset_callbacks(I18nPerson) - I18n.backend = @old_backend - end - - def assert_name_invalid(message) - yield - @person.valid? - assert_equal message, @person.errors.on(:name) - end - - # Symbols as class-level validation messages - - test "Symbol as class level validation message translated per attribute (translation on child class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:i18n_person => {:attributes => {:name => {:broken => "is broken"}}}}} - I18nPerson.validates_presence_of :name, :message => :broken - end - end - - test "Symbol as class level validation message translated per attribute (translation on base class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:person => {:attributes => {:name => {:broken => "is broken"}}}}} - I18nPerson.validates_presence_of :name, :message => :broken - end - end - - test "Symbol as class level validation message translated per model (translation on child class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:i18n_person => {:broken => "is broken"}}} - I18nPerson.validates_presence_of :name, :message => :broken - end - end - - test "Symbol as class level validation message translated per model (translation on base class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:person => {:broken => "is broken"}}} - I18nPerson.validates_presence_of :name, :message => :broken - end - end - - test "Symbol as class level validation message translated as error message" do - assert_name_invalid("is broken") do - store_translations :errors => {:messages => {:broken => "is broken"}} - I18nPerson.validates_presence_of :name, :message => :broken - end - end - - # Strings as class-level validation messages - - test "String as class level validation message translated per attribute (translation on child class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:i18n_person => {:attributes => {:name => {"is broken" => "is broken"}}}}} - I18nPerson.validates_presence_of :name, :message => "is broken" - end - end - - test "String as class level validation message translated per attribute (translation on base class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:person => {:attributes => {:name => {"is broken" => "is broken"}}}}} - I18nPerson.validates_presence_of :name, :message => "is broken" - end - end - - test "String as class level validation message translated per model (translation on child class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:i18n_person => {"is broken" => "is broken"}}} - I18nPerson.validates_presence_of :name, :message => "is broken" - end - end - - test "String as class level validation message translated per model (translation on base class)" do - assert_name_invalid("is broken") do - store_translations :errors => {:models => {:person => {"is broken" => "is broken"}}} - I18nPerson.validates_presence_of :name, :message => "is broken" - end - end - - test "String as class level validation message translated as error message" do - assert_name_invalid("is broken") do - store_translations :errors => {:messages => {"is broken" => "is broken"}} - I18nPerson.validates_presence_of :name, :message => "is broken" - end - end - - test "String as class level validation message not translated (uses message as default)" do - assert_name_invalid("is broken!") do - I18nPerson.validates_presence_of :name, :message => "is broken!" - end - end -end - -class ActiveRecordValidationsI18nFullMessagesFullStackTests < ActiveSupport::TestCase - include ActiveRecordValidationsI18nTestHelper - - def setup - reset_callbacks(I18nPerson) - @old_backend, I18n.backend = I18n.backend, I18n::Backend::Simple.new - @person = I18nPerson.new - end - - def teardown - reset_callbacks(I18nPerson) - I18n.backend = @old_backend - end - - def assert_full_message(message) - yield - @person.valid? - assert_equal message, @person.errors.full_messages.join - end - - test "full_message format stored per custom error message key" do - assert_full_message("Name is broken!") do - store_translations :errors => { :messages => { :broken => 'is broken' }, :full_messages => { :broken => '%{attribute} %{message}!' } } - I18nPerson.validates_presence_of :name, :message => :broken - end - end - - test "full_message format stored per error type" do - assert_full_message("Name can't be blank!") do - store_translations :errors => { :full_messages => { :blank => '%{attribute} %{message}!' } } - I18nPerson.validates_presence_of :name - end - end - # ActiveRecord#RecordInvalid exception - - test "full_message format stored as default" do - assert_full_message("Name: can't be blank") do - store_translations :errors => { :full_messages => { :format => '%{attribute}: %{message}' } } - I18nPerson.validates_presence_of :name - end - end - test "RecordInvalid exception can be localized" do - topic = Topic.new - topic.errors.add(:title, :invalid) - topic.errors.add(:title, :blank) - assert_equal "Validation failed: Title is invalid, Title can't be blank", ActiveRecord::RecordInvalid.new(topic).message - end -end diff --git a/vendor/rails/activerecord/test/cases/validations_test.rb b/vendor/rails/activerecord/test/cases/validations_test.rb deleted file mode 100644 index d57da790..00000000 --- a/vendor/rails/activerecord/test/cases/validations_test.rb +++ /dev/null @@ -1,1684 +0,0 @@ -# encoding: utf-8 -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/person' -require 'models/developer' -require 'models/warehouse_thing' -require 'models/guid' -require 'models/owner' -require 'models/pet' -require 'models/event' -require 'models/man' -require 'models/interest' - -# The following methods in Topic are used in test_conditional_validation_* -class Topic - has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" - has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" - - def condition_is_true - true - end - - def condition_is_true_but_its_not - false - end -end - -class ProtectedPerson < ActiveRecord::Base - set_table_name 'people' - attr_accessor :addon - attr_protected :first_name - - def special_error - this_method_does_not_exist! - rescue - errors.add(:special_error, "This method does not exist") - end -end - -class UniqueReply < Reply - validates_uniqueness_of :content, :scope => 'parent_id' -end - -class SillyUniqueReply < UniqueReply -end - -class Wizard < ActiveRecord::Base - self.abstract_class = true - - validates_uniqueness_of :name -end - -class IneptWizard < Wizard - validates_uniqueness_of :city -end - -class Conjurer < IneptWizard -end - -class Thaumaturgist < IneptWizard -end - - -class ValidationsTest < ActiveRecord::TestCase - fixtures :topics, :developers, 'warehouse-things' - - # Most of the tests mess with the validations of Topic, so lets repair it all the time. - # Other classes we mess with will be dealt with in the specific tests - repair_validations(Topic) - - def test_single_field_validation - r = Reply.new - r.title = "There's no content!" - assert !r.valid?, "A reply without content shouldn't be saveable" - - r.content = "Messa content!" - assert r.valid?, "A reply with content should be saveable" - end - - def test_single_attr_validation_and_error_msg - r = Reply.new - r.title = "There's no content!" - assert !r.valid? - assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid" - assert_equal "Empty", r.errors.on("content"), "A reply without content should contain an error" - assert_equal 1, r.errors.count - end - - def test_double_attr_validation_and_error_msg - r = Reply.new - assert !r.valid? - - assert r.errors.invalid?("title"), "A reply without title should mark that attribute as invalid" - assert_equal "Empty", r.errors.on("title"), "A reply without title should contain an error" - - assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid" - assert_equal "Empty", r.errors.on("content"), "A reply without content should contain an error" - - assert_equal 2, r.errors.count - end - - def test_error_on_create - r = Reply.new - r.title = "Wrong Create" - assert !r.valid? - assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid" - assert_equal "is Wrong Create", r.errors.on("title"), "A reply with a bad content should contain an error" - end - - def test_error_on_update - r = Reply.new - r.title = "Bad" - r.content = "Good" - assert r.save, "First save should be successful" - - r.title = "Wrong Update" - assert !r.save, "Second save should fail" - - assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid" - assert_equal "is Wrong Update", r.errors.on("title"), "A reply with a bad content should contain an error" - end - - def test_invalid_record_exception - assert_raise(ActiveRecord::RecordInvalid) { Reply.create! } - assert_raise(ActiveRecord::RecordInvalid) { Reply.new.save! } - - begin - r = Reply.new - r.save! - flunk - rescue ActiveRecord::RecordInvalid => invalid - assert_equal r, invalid.record - end - end - - def test_exception_on_create_bang_many - assert_raise(ActiveRecord::RecordInvalid) do - Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }]) - end - end - - def test_exception_on_create_bang_with_block - assert_raise(ActiveRecord::RecordInvalid) do - Reply.create!({ "title" => "OK" }) do |r| - r.content = nil - end - end - end - - def test_exception_on_create_bang_many_with_block - assert_raise(ActiveRecord::RecordInvalid) do - Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r| - r.content = nil - end - end - end - - def test_scoped_create_without_attributes - Reply.with_scope(:create => {}) do - assert_raise(ActiveRecord::RecordInvalid) { Reply.create! } - end - end - - def test_create_with_exceptions_using_scope_for_protected_attributes - assert_nothing_raised do - ProtectedPerson.with_scope( :create => { :first_name => "Mary" } ) do - person = ProtectedPerson.create! :addon => "Addon" - assert_equal person.first_name, "Mary", "scope should ignore attr_protected" - end - end - end - - def test_create_with_exceptions_using_scope_and_empty_attributes - assert_nothing_raised do - ProtectedPerson.with_scope( :create => { :first_name => "Mary" } ) do - person = ProtectedPerson.create! - assert_equal person.first_name, "Mary", "should be ok when no attributes are passed to create!" - end - end - end - - def test_values_are_not_retrieved_unless_needed - assert_nothing_raised do - person = ProtectedPerson.new - person.special_error - assert_equal "This method does not exist", person.errors[:special_error] - end - end - - def test_single_error_string_per_attr_iteration - r = Reply.new - r.save - - errors = [] - r.errors.each { |attr, msg| errors << [attr, msg] } - - assert errors.include?(["title", "Empty"]) - assert errors.include?(["content", "Empty"]) - end - - def test_single_error_object_per_attr_iteration - r = Reply.new - r.save - - errors = [] - r.errors.each_error { |attr, error| errors << [attr, error.attribute] } - - assert errors.include?(["title", "title"]) - assert errors.include?(["content", "content"]) - end - - def test_multiple_errors_per_attr_iteration_with_full_error_composition - r = Reply.new - r.title = "Wrong Create" - r.content = "Mismatch" - r.save - - errors = [] - r.errors.each_full { |error| errors << error } - - assert_equal "Title is Wrong Create", errors[0] - assert_equal "Title is Content Mismatch", errors[1] - assert_equal 2, r.errors.count - end - - def test_errors_on_base - r = Reply.new - r.content = "Mismatch" - r.save - r.errors.add_to_base "Reply is not dignifying" - - errors = [] - r.errors.each_full { |error| errors << error } - - assert_equal "Reply is not dignifying", r.errors.on_base - - assert errors.include?("Title Empty") - assert errors.include?("Reply is not dignifying") - assert_equal 2, r.errors.count - end - - def test_create_without_validation - reply = Reply.new - assert !reply.save - assert reply.save(false) - end - - def test_create_without_validation_bang - count = Reply.count - assert_nothing_raised { Reply.new.save_without_validation! } - assert count+1, Reply.count - end - - def test_validates_each - hits = 0 - Topic.validates_each(:title, :content, [:title, :content]) do |record, attr| - record.errors.add attr, 'gotcha' - hits += 1 - end - t = Topic.new("title" => "valid", "content" => "whatever") - assert !t.save - assert_equal 4, hits - assert_equal %w(gotcha gotcha), t.errors.on(:title) - assert_equal %w(gotcha gotcha), t.errors.on(:content) - end - - def test_no_title_confirmation - Topic.validates_confirmation_of(:title) - - t = Topic.new(:author_name => "Plutarch") - assert t.valid? - - t.title_confirmation = "Parallel Lives" - assert !t.valid? - - t.title_confirmation = nil - t.title = "Parallel Lives" - assert t.valid? - - t.title_confirmation = "Parallel Lives" - assert t.valid? - end - - def test_title_confirmation - Topic.validates_confirmation_of(:title) - - t = Topic.create("title" => "We should be confirmed","title_confirmation" => "") - assert !t.save - - t.title_confirmation = "We should be confirmed" - assert t.save - end - - def test_terms_of_service_agreement_no_acceptance - Topic.validates_acceptance_of(:terms_of_service, :on => :create) - - t = Topic.create("title" => "We should not be confirmed") - assert t.save - end - - def test_terms_of_service_agreement - Topic.validates_acceptance_of(:terms_of_service, :on => :create) - - t = Topic.create("title" => "We should be confirmed","terms_of_service" => "") - assert !t.save - assert_equal "must be accepted", t.errors.on(:terms_of_service) - - t.terms_of_service = "1" - assert t.save - end - - - def test_eula - Topic.validates_acceptance_of(:eula, :message => "must be abided", :on => :create) - - t = Topic.create("title" => "We should be confirmed","eula" => "") - assert !t.save - assert_equal "must be abided", t.errors.on(:eula) - - t.eula = "1" - assert t.save - end - - def test_terms_of_service_agreement_with_accept_value - Topic.validates_acceptance_of(:terms_of_service, :on => :create, :accept => "I agree.") - - t = Topic.create("title" => "We should be confirmed", "terms_of_service" => "") - assert !t.save - assert_equal "must be accepted", t.errors.on(:terms_of_service) - - t.terms_of_service = "I agree." - assert t.save - end - - def test_validates_acceptance_of_as_database_column - repair_validations(Reply) do - Reply.validates_acceptance_of(:author_name) - - reply = Reply.create("author_name" => "Dan Brown") - assert_equal "Dan Brown", reply["author_name"] - end - end - - def test_validates_acceptance_of_with_non_existant_table - Object.const_set :IncorporealModel, Class.new(ActiveRecord::Base) - - assert_nothing_raised ActiveRecord::StatementInvalid do - IncorporealModel.validates_acceptance_of(:incorporeal_column) - end - end - - def test_validate_presences - Topic.validates_presence_of(:title, :content) - - t = Topic.create - assert !t.save - assert_equal "can't be blank", t.errors.on(:title) - assert_equal "can't be blank", t.errors.on(:content) - - t.title = "something" - t.content = " " - - assert !t.save - assert_equal "can't be blank", t.errors.on(:content) - - t.content = "like stuff" - - assert t.save - end - - def test_validates_presence_of_belongs_to_association__parent_is_new_record - repair_validations(Interest) do - # Note that Interest and Man have the :inverse_of option set - Interest.validates_presence_of(:man) - man = Man.new(:name => 'John') - interest = man.interests.build(:topic => 'Airplanes') - assert interest.valid?, "Expected interest to be valid, but was not. Interest should have a man object associated" - end - end - - def test_validates_presence_of_belongs_to_association__existing_parent - repair_validations(Interest) do - Interest.validates_presence_of(:man) - man = Man.create!(:name => 'John') - interest = man.interests.build(:topic => 'Airplanes') - assert interest.valid?, "Expected interest to be valid, but was not. Interest should have a man object associated" - end - end - - def test_validate_uniqueness - Topic.validates_uniqueness_of(:title) - - t = Topic.new("title" => "I'm uniqué!") - assert t.save, "Should save t as unique" - - t.content = "Remaining unique" - assert t.save, "Should still save t as unique" - - t2 = Topic.new("title" => "I'm uniqué!") - assert !t2.valid?, "Shouldn't be valid" - assert !t2.save, "Shouldn't save t2 as unique" - assert_equal "has already been taken", t2.errors.on(:title) - - t2.title = "Now Im really also unique" - assert t2.save, "Should now save t2 as unique" - end - - def test_validates_uniquness_with_newline_chars - Topic.validates_uniqueness_of(:title, :case_sensitive => false) - - t = Topic.new("title" => "new\nline") - assert t.save, "Should save t as unique" - end - - def test_validate_uniqueness_with_scope - repair_validations(Reply) do - Reply.validates_uniqueness_of(:content, :scope => "parent_id") - - t = Topic.create("title" => "I'm unique!") - - r1 = t.replies.create "title" => "r1", "content" => "hello world" - assert r1.valid?, "Saving r1" - - r2 = t.replies.create "title" => "r2", "content" => "hello world" - assert !r2.valid?, "Saving r2 first time" - - r2.content = "something else" - assert r2.save, "Saving r2 second time" - - t2 = Topic.create("title" => "I'm unique too!") - r3 = t2.replies.create "title" => "r3", "content" => "hello world" - assert r3.valid?, "Saving r3" - end - end - - def test_validate_uniqueness_with_reserved_word_as_scope - repair_validations(Reply) do - Topic.validates_uniqueness_of(:content, :scope => "group") - - t1 = Topic.create "title" => "t1", "content" => "hello world2" - assert t1.valid? - - t2 = Topic.create "title" => "t2", "content" => "hello world2" - assert !t2.valid? - end - end - - def test_validate_uniqueness_scoped_to_defining_class - t = Topic.create("title" => "What, me worry?") - - r1 = t.unique_replies.create "title" => "r1", "content" => "a barrel of fun" - assert r1.valid?, "Saving r1" - - r2 = t.silly_unique_replies.create "title" => "r2", "content" => "a barrel of fun" - assert !r2.valid?, "Saving r2" - - # Should succeed as validates_uniqueness_of only applies to - # UniqueReply and its subclasses - r3 = t.replies.create "title" => "r2", "content" => "a barrel of fun" - assert r3.valid?, "Saving r3" - end - - def test_validate_uniqueness_with_scope_array - repair_validations(Reply) do - Reply.validates_uniqueness_of(:author_name, :scope => [:author_email_address, :parent_id]) - - t = Topic.create("title" => "The earth is actually flat!") - - r1 = t.replies.create "author_name" => "jeremy", "author_email_address" => "jeremy@rubyonrails.com", "title" => "You're crazy!", "content" => "Crazy reply" - assert r1.valid?, "Saving r1" - - r2 = t.replies.create "author_name" => "jeremy", "author_email_address" => "jeremy@rubyonrails.com", "title" => "You're crazy!", "content" => "Crazy reply again..." - assert !r2.valid?, "Saving r2. Double reply by same author." - - r2.author_email_address = "jeremy_alt_email@rubyonrails.com" - assert r2.save, "Saving r2 the second time." - - r3 = t.replies.create "author_name" => "jeremy", "author_email_address" => "jeremy_alt_email@rubyonrails.com", "title" => "You're wrong", "content" => "It's cubic" - assert !r3.valid?, "Saving r3" - - r3.author_name = "jj" - assert r3.save, "Saving r3 the second time." - - r3.author_name = "jeremy" - assert !r3.save, "Saving r3 the third time." - end - end - - def test_validate_case_insensitive_uniqueness - Topic.validates_uniqueness_of(:title, :parent_id, :case_sensitive => false, :allow_nil => true) - - t = Topic.new("title" => "I'm unique!", :parent_id => 2) - assert t.save, "Should save t as unique" - - t.content = "Remaining unique" - assert t.save, "Should still save t as unique" - - t2 = Topic.new("title" => "I'm UNIQUE!", :parent_id => 1) - assert !t2.valid?, "Shouldn't be valid" - assert !t2.save, "Shouldn't save t2 as unique" - assert t2.errors.on(:title) - assert t2.errors.on(:parent_id) - assert_equal "has already been taken", t2.errors.on(:title) - - t2.title = "I'm truly UNIQUE!" - assert !t2.valid?, "Shouldn't be valid" - assert !t2.save, "Shouldn't save t2 as unique" - assert_nil t2.errors.on(:title) - assert t2.errors.on(:parent_id) - - t2.parent_id = 4 - assert t2.save, "Should now save t2 as unique" - - t2.parent_id = nil - t2.title = nil - assert t2.valid?, "should validate with nil" - assert t2.save, "should save with nil" - - with_kcode('UTF8') do - t_utf8 = Topic.new("title" => "Я тоже уникальный!") - assert t_utf8.save, "Should save t_utf8 as unique" - - # If database hasn't UTF-8 character set, this test fails - if Topic.find(t_utf8, :select => 'LOWER(title) AS title').title == "я тоже уникальный!" - t2_utf8 = Topic.new("title" => "я тоже УНИКАЛЬНЫЙ!") - assert !t2_utf8.valid?, "Shouldn't be valid" - assert !t2_utf8.save, "Shouldn't save t2_utf8 as unique" - end - end - end - - def test_validate_case_sensitive_uniqueness - Topic.validates_uniqueness_of(:title, :case_sensitive => true, :allow_nil => true) - - t = Topic.new("title" => "I'm unique!") - assert t.save, "Should save t as unique" - - t.content = "Remaining unique" - assert t.save, "Should still save t as unique" - - t2 = Topic.new("title" => "I'M UNIQUE!") - assert t2.valid?, "Should be valid" - assert t2.save, "Should save t2 as unique" - assert !t2.errors.on(:title) - assert !t2.errors.on(:parent_id) - assert_not_equal "has already been taken", t2.errors.on(:title) - - t3 = Topic.new("title" => "I'M uNiQUe!") - assert t3.valid?, "Should be valid" - assert t3.save, "Should save t2 as unique" - assert !t3.errors.on(:title) - assert !t3.errors.on(:parent_id) - assert_not_equal "has already been taken", t3.errors.on(:title) - end - - def test_validate_case_sensitive_uniqueness_with_attribute_passed_as_integer - Topic.validates_uniqueness_of(:title, :case_sensitve => true) - t = Topic.create!('title' => 101) - - t2 = Topic.new('title' => 101) - assert !t2.valid? - assert t2.errors.on(:title) - end - - def test_validate_uniqueness_with_non_standard_table_names - i1 = WarehouseThing.create(:value => 1000) - assert !i1.valid?, "i1 should not be valid" - assert i1.errors.on(:value), "Should not be empty" - end - - def test_validates_uniqueness_inside_with_scope - Topic.validates_uniqueness_of(:title) - - Topic.with_scope(:find => { :conditions => { :author_name => "David" } }) do - t1 = Topic.new("title" => "I'm unique!", "author_name" => "Mary") - assert t1.save - t2 = Topic.new("title" => "I'm unique!", "author_name" => "David") - assert !t2.valid? - end - end - - def test_validate_uniqueness_with_columns_which_are_sql_keywords - repair_validations(Guid) do - Guid.validates_uniqueness_of :key - g = Guid.new - g.key = "foo" - assert_nothing_raised { !g.valid? } - end - end - - def test_validate_uniqueness_with_limit - # Event.title is limited to 5 characters - e1 = Event.create(:title => "abcde") - assert e1.valid?, "Could not create an event with a unique, 5 character title" - e2 = Event.create(:title => "abcdefgh") - assert !e2.valid?, "Created an event whose title, with limit taken into account, is not unique" - end - - def test_validate_uniqueness_with_limit_and_utf8 - with_kcode('UTF8') do - # Event.title is limited to 5 characters - e1 = Event.create(:title => "一二三四五") - assert e1.valid?, "Could not create an event with a unique, 5 character title" - e2 = Event.create(:title => "一二三四五六七八") - assert !e2.valid?, "Created an event whose title, with limit taken into account, is not unique" - end - end - - def test_validate_straight_inheritance_uniqueness - w1 = IneptWizard.create(:name => "Rincewind", :city => "Ankh-Morpork") - assert w1.valid?, "Saving w1" - - # Should use validation from base class (which is abstract) - w2 = IneptWizard.new(:name => "Rincewind", :city => "Quirm") - assert !w2.valid?, "w2 shouldn't be valid" - assert w2.errors.on(:name), "Should have errors for name" - assert_equal "has already been taken", w2.errors.on(:name), "Should have uniqueness message for name" - - w3 = Conjurer.new(:name => "Rincewind", :city => "Quirm") - assert !w3.valid?, "w3 shouldn't be valid" - assert w3.errors.on(:name), "Should have errors for name" - assert_equal "has already been taken", w3.errors.on(:name), "Should have uniqueness message for name" - - w4 = Conjurer.create(:name => "The Amazing Bonko", :city => "Quirm") - assert w4.valid?, "Saving w4" - - w5 = Thaumaturgist.new(:name => "The Amazing Bonko", :city => "Lancre") - assert !w5.valid?, "w5 shouldn't be valid" - assert w5.errors.on(:name), "Should have errors for name" - assert_equal "has already been taken", w5.errors.on(:name), "Should have uniqueness message for name" - - w6 = Thaumaturgist.new(:name => "Mustrum Ridcully", :city => "Quirm") - assert !w6.valid?, "w6 shouldn't be valid" - assert w6.errors.on(:city), "Should have errors for city" - assert_equal "has already been taken", w6.errors.on(:city), "Should have uniqueness message for city" - end - - def test_validate_format - Topic.validates_format_of(:title, :content, :with => /^Validation\smacros \w+!$/, :message => "is bad data") - - t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!") - assert !t.valid?, "Shouldn't be valid" - assert !t.save, "Shouldn't save because it's invalid" - assert_equal "is bad data", t.errors.on(:title) - assert_nil t.errors.on(:content) - - t.title = "Validation macros rule!" - - assert t.save - assert_nil t.errors.on(:title) - - assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) } - end - - def test_validate_format_with_allow_blank - Topic.validates_format_of(:title, :with => /^Validation\smacros \w+!$/, :allow_blank=>true) - assert !Topic.create("title" => "Shouldn't be valid").valid? - assert Topic.create("title" => "").valid? - assert Topic.create("title" => nil).valid? - assert Topic.create("title" => "Validation macros rule!").valid? - end - - # testing ticket #3142 - def test_validate_format_numeric - Topic.validates_format_of(:title, :content, :with => /^[1-9][0-9]*$/, :message => "is bad data") - - t = Topic.create("title" => "72x", "content" => "6789") - assert !t.valid?, "Shouldn't be valid" - assert !t.save, "Shouldn't save because it's invalid" - assert_equal "is bad data", t.errors.on(:title) - assert_nil t.errors.on(:content) - - t.title = "-11" - assert !t.valid?, "Shouldn't be valid" - - t.title = "03" - assert !t.valid?, "Shouldn't be valid" - - t.title = "z44" - assert !t.valid?, "Shouldn't be valid" - - t.title = "5v7" - assert !t.valid?, "Shouldn't be valid" - - t.title = "1" - - assert t.save - assert_nil t.errors.on(:title) - end - - def test_validate_format_with_formatted_message - Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => "can't be %{value}") - t = Topic.create(:title => 'Invalid title') - assert_equal "can't be Invalid title", t.errors.on(:title) - end - - def test_validates_inclusion_of - Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ) ) - - assert !Topic.create("title" => "a!", "content" => "abc").valid? - assert !Topic.create("title" => "a b", "content" => "abc").valid? - assert !Topic.create("title" => nil, "content" => "def").valid? - - t = Topic.create("title" => "a", "content" => "I know you are but what am I?") - assert t.valid? - t.title = "uhoh" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is not included in the list", t.errors["title"] - - assert_raise(ArgumentError) { Topic.validates_inclusion_of( :title, :in => nil ) } - assert_raise(ArgumentError) { Topic.validates_inclusion_of( :title, :in => 0) } - - assert_nothing_raised(ArgumentError) { Topic.validates_inclusion_of( :title, :in => "hi!" ) } - assert_nothing_raised(ArgumentError) { Topic.validates_inclusion_of( :title, :in => {} ) } - assert_nothing_raised(ArgumentError) { Topic.validates_inclusion_of( :title, :in => [] ) } - end - - def test_validates_inclusion_of_with_allow_nil - Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :allow_nil=>true ) - - assert !Topic.create("title" => "a!", "content" => "abc").valid? - assert !Topic.create("title" => "", "content" => "abc").valid? - assert Topic.create("title" => nil, "content" => "abc").valid? - end - - def test_numericality_with_getter_method - repair_validations(Developer) do - Developer.validates_numericality_of( :salary ) - developer = Developer.new("name" => "michael", "salary" => nil) - developer.instance_eval("def salary; read_attribute('salary') ? read_attribute('salary') : 100000; end") - assert developer.valid? - end - end - - def test_validates_length_of_with_allow_nil - Topic.validates_length_of( :title, :is => 5, :allow_nil=>true ) - - assert !Topic.create("title" => "ab").valid? - assert !Topic.create("title" => "").valid? - assert Topic.create("title" => nil).valid? - assert Topic.create("title" => "abcde").valid? - end - - def test_validates_length_of_with_allow_blank - Topic.validates_length_of( :title, :is => 5, :allow_blank=>true ) - - assert !Topic.create("title" => "ab").valid? - assert Topic.create("title" => "").valid? - assert Topic.create("title" => nil).valid? - assert Topic.create("title" => "abcde").valid? - end - - def test_validates_inclusion_of_with_formatted_message - Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => "option %{value} is not in the list" ) - - assert Topic.create("title" => "a", "content" => "abc").valid? - - t = Topic.create("title" => "uhoh", "content" => "abc") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "option uhoh is not in the list", t.errors["title"] - end - - def test_numericality_with_allow_nil_and_getter_method - repair_validations(Developer) do - Developer.validates_numericality_of( :salary, :allow_nil => true) - developer = Developer.new("name" => "michael", "salary" => nil) - developer.instance_eval("def salary; read_attribute('salary') ? read_attribute('salary') : 100000; end") - assert developer.valid? - end - end - - def test_validates_exclusion_of - Topic.validates_exclusion_of( :title, :in => %w( abe monkey ) ) - - assert Topic.create("title" => "something", "content" => "abc").valid? - assert !Topic.create("title" => "monkey", "content" => "abc").valid? - end - - def test_validates_exclusion_of_with_formatted_message - Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => "option %{value} is restricted" ) - - assert Topic.create("title" => "something", "content" => "abc") - - t = Topic.create("title" => "monkey") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "option monkey is restricted", t.errors["title"] - end - - def test_validates_length_of_using_minimum - Topic.validates_length_of :title, :minimum => 5 - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = "not" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - - t.title = "" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - - t.title = nil - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - end - - def test_optionally_validates_length_of_using_minimum - Topic.validates_length_of :title, :minimum => 5, :allow_nil => true - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_validates_length_of_using_maximum - Topic.validates_length_of :title, :maximum => 5 - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = "notvalid" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors["title"] - - t.title = "" - assert t.valid? - - t.title = nil - assert !t.valid? - end - - def test_optionally_validates_length_of_using_maximum - Topic.validates_length_of :title, :maximum => 5, :allow_nil => true - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_validates_length_of_using_within - Topic.validates_length_of(:title, :content, :within => 3..5) - - t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long") - assert !t.valid? - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors.on(:content) - - t.title = nil - t.content = nil - assert !t.valid? - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title) - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:content) - - t.title = "abe" - t.content = "mad" - assert t.valid? - end - - def test_optionally_validates_length_of_using_within - Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true - - t = Topic.create('title' => 'abc', 'content' => 'abcd') - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_optionally_validates_length_of_using_within_on_create - Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "my string is too long: %{count}" - - t = Topic.create("title" => "thisisnotvalid", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - assert_equal "my string is too long: 10", t.errors[:title] - - t.title = "butthisis" - assert t.save - - t.title = "few" - assert t.save - - t.content = "andthisislong" - assert t.save - - t.content = t.title = "iamfine" - assert t.save - end - - def test_optionally_validates_length_of_using_within_on_update - Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "my string is too short: %{count}" - - t = Topic.create("title" => "vali", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - - t.title = "not" - assert !t.save - assert t.errors.on(:title) - assert_equal "my string is too short: 5", t.errors[:title] - - t.title = "valid" - t.content = "andthisistoolong" - assert !t.save - assert t.errors.on(:content) - - t.content = "iamfine" - assert t.save - end - - def test_validates_length_of_using_is - Topic.validates_length_of :title, :is => 5 - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = "notvalid" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is the wrong length (should be 5 characters)", t.errors["title"] - - t.title = "" - assert !t.valid? - - t.title = nil - assert !t.valid? - end - - def test_optionally_validates_length_of_using_is - Topic.validates_length_of :title, :is => 5, :allow_nil => true - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_validates_length_of_using_bignum - bigmin = 2 ** 30 - bigmax = 2 ** 32 - bigrange = bigmin...bigmax - assert_nothing_raised do - Topic.validates_length_of :title, :is => bigmin + 5 - Topic.validates_length_of :title, :within => bigrange - Topic.validates_length_of :title, :in => bigrange - Topic.validates_length_of :title, :minimum => bigmin - Topic.validates_length_of :title, :maximum => bigmax - end - end - - def test_validates_length_with_globally_modified_error_message - defaults = ActiveSupport::Deprecation.silence { ActiveRecord::Errors.default_error_messages } - original_message = defaults[:too_short] - defaults[:too_short] = 'tu est trops petit hombre %{count}' - - Topic.validates_length_of :title, :minimum => 10 - t = Topic.create(:title => 'too short') - assert !t.valid? - - assert_equal 'tu est trops petit hombre 10', t.errors['title'] - - ensure - defaults[:too_short] = original_message - end - - def test_validates_size_of_association - repair_validations(Owner) do - assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } - o = Owner.new('name' => 'nopets') - assert !o.save - assert o.errors.on(:pets) - pet = o.pets.build('name' => 'apet') - assert o.valid? - end - end - - def test_validates_size_of_association_using_within - repair_validations(Owner) do - assert_nothing_raised { Owner.validates_size_of :pets, :within => 1..2 } - o = Owner.new('name' => 'nopets') - assert !o.save - assert o.errors.on(:pets) - - pet = o.pets.build('name' => 'apet') - assert o.valid? - - 2.times { o.pets.build('name' => 'apet') } - assert !o.save - assert o.errors.on(:pets) - end - end - - def test_validates_length_of_nasty_params - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :minimum=>6, :maximum=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>6, :maximum=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>6, :minimum=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>6, :is=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :minimum=>"a") } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :maximum=>"a") } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>"a") } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :is=>"a") } - end - - def test_validates_length_of_custom_errors_for_minimum_with_message - Topic.validates_length_of( :title, :minimum=>5, :message=>"boo %{count}" ) - t = Topic.create("title" => "uhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "boo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_minimum_with_too_short - Topic.validates_length_of( :title, :minimum=>5, :too_short=>"hoo %{count}" ) - t = Topic.create("title" => "uhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_maximum_with_message - Topic.validates_length_of( :title, :maximum=>5, :message=>"boo %{count}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "boo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_in - Topic.validates_length_of(:title, :in => 10..20, :message => "hoo %{count}") - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 10", t.errors["title"] - - t = Topic.create("title" => "uhohuhohuhohuhohuhohuhohuhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 20", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_maximum_with_too_long - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_is_with_message - Topic.validates_length_of( :title, :is=>5, :message=>"boo %{count}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "boo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_is_with_wrong_length - Topic.validates_length_of( :title, :is=>5, :wrong_length=>"hoo %{count}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_length_of_using_minimum_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :minimum => 5 - - t = Topic.create("title" => "一二三四五", "content" => "whatever") - assert t.valid? - - t.title = "一二三四" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - end - end - - def test_validates_length_of_using_maximum_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :maximum => 5 - - t = Topic.create("title" => "一二三四五", "content" => "whatever") - assert t.valid? - - t.title = "一二34五六" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors["title"] - end - end - - def test_validates_length_of_using_within_utf8 - with_kcode('UTF8') do - Topic.validates_length_of(:title, :content, :within => 3..5) - - t = Topic.new("title" => "一二", "content" => "12三四五六七") - assert !t.valid? - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors.on(:content) - t.title = "一二三" - t.content = "12三" - assert t.valid? - end - end - - def test_optionally_validates_length_of_using_within_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 3..5, :allow_nil => true - - t = Topic.create(:title => "一二三四五") - assert t.valid?, t.errors.inspect - - t = Topic.create(:title => "一二三") - assert t.valid?, t.errors.inspect - - t.title = nil - assert t.valid?, t.errors.inspect - end - end - - def test_optionally_validates_length_of_using_within_on_create_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: %{count}" - - t = Topic.create("title" => "一二三四五六七八九十A", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - assert_equal "長すぎます: 10", t.errors[:title] - - t.title = "一二三四五六七八九" - assert t.save - - t.title = "一二3" - assert t.save - - t.content = "一二三四五六七八九十" - assert t.save - - t.content = t.title = "一二三四五六" - assert t.save - end - end - - def test_optionally_validates_length_of_using_within_on_update_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: %{count}" - - t = Topic.create("title" => "一二三4", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - - t.title = "1二三4" - assert !t.save - assert t.errors.on(:title) - assert_equal "短すぎます: 5", t.errors[:title] - - t.title = "一二三四五六七八九十A" - assert !t.save - assert t.errors.on(:title) - - t.title = "一二345" - assert t.save - end - end - - def test_validates_length_of_using_is_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :is => 5 - - t = Topic.create("title" => "一二345", "content" => "whatever") - assert t.valid? - - t.title = "一二345六" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is the wrong length (should be 5 characters)", t.errors["title"] - end - end - - def test_validates_length_of_with_block - Topic.validates_length_of :content, :minimum => 5, :too_short=>"Your essay must be at least %{count} words.", - :tokenizer => lambda {|str| str.scan(/\w+/) } - t = Topic.create!(:content => "this content should be long enough") - assert t.valid? - - t.content = "not long enough" - assert !t.valid? - assert t.errors.on(:content) - assert_equal "Your essay must be at least 5 words.", t.errors[:content] - end - - def test_validates_size_of_association_utf8 - repair_validations(Owner) do - with_kcode('UTF8') do - assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } - o = Owner.new('name' => 'あいうえおかきくけこ') - assert !o.save - assert o.errors.on(:pets) - o.pets.build('name' => 'あいうえおかきくけこ') - assert o.valid? - end - end - end - - def test_validates_associated_many - Topic.validates_associated( :replies ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - t.replies << [r = Reply.new("title" => "A reply"), r2 = Reply.new("title" => "Another reply", "content" => "non-empty"), r3 = Reply.new("title" => "Yet another reply"), r4 = Reply.new("title" => "The last reply", "content" => "non-empty")] - assert !t.valid? - assert t.errors.on(:replies) - assert_equal 1, r.errors.count # make sure all associated objects have been validated - assert_equal 0, r2.errors.count - assert_equal 1, r3.errors.count - assert_equal 0, r4.errors.count - r.content = r3.content = "non-empty" - assert t.valid? - end - - def test_validates_associated_one - repair_validations(Reply) do - Reply.validates_associated( :topic ) - Topic.validates_presence_of( :content ) - r = Reply.new("title" => "A reply", "content" => "with content!") - r.topic = Topic.create("title" => "uhohuhoh") - assert !r.valid? - assert r.errors.on(:topic) - r.topic.content = "non-empty" - assert r.valid? - end - end - - def test_validate_block - Topic.validate { |topic| topic.errors.add("title", "will never be valid") } - t = Topic.create("title" => "Title", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "will never be valid", t.errors["title"] - end - - def test_invalid_validator - Topic.validate 3 - assert_raise(ArgumentError) { t = Topic.create } - end - - def test_throw_away_typing - d = Developer.new("name" => "David", "salary" => "100,000") - assert !d.valid? - assert_equal 100, d.salary - assert_equal "100,000", d.salary_before_type_cast - end - - def test_validates_acceptance_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_acceptance_of :salary, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.salary = "0" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last - end - end - - def test_validates_confirmation_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_confirmation_of :name, :message=> "confirm 'single' and \"double\" quotes" - d = Developer.new - d.name = "John" - d.name_confirmation = "Johnny" - assert !d.valid? - assert_equal "confirm 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_format_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_format_of :name, :with => /^(A-Z*)$/, :message=> "format 'single' and \"double\" quotes" - d = Developer.new - d.name = d.name_confirmation = "John 32" - assert !d.valid? - assert_equal "format 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_inclusion_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_inclusion_of :salary, :in => 1000..80000, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.salary = "90,000" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last - end - end - - def test_validates_length_of_with_custom_too_long_using_quotes - repair_validations(Developer) do - Developer.validates_length_of :name, :maximum => 4, :too_long=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Jeffrey" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_length_of_with_custom_too_short_using_quotes - repair_validations(Developer) do - Developer.validates_length_of :name, :minimum => 4, :too_short=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Joe" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_length_of_with_custom_message_using_quotes - repair_validations(Developer) do - Developer.validates_length_of :name, :minimum => 4, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Joe" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_presence_of_with_custom_message_using_quotes - repair_validations(Developer) do - Developer.validates_presence_of :non_existent, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Joe" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:non_existent) - end - end - - def test_validates_uniqueness_of_with_custom_message_using_quotes - repair_validations(Developer) do - Developer.validates_uniqueness_of :name, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "David" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_associated_with_custom_message_using_quotes - repair_validations(Reply) do - Reply.validates_associated :topic, :message=> "This string contains 'single' and \"double\" quotes" - Topic.validates_presence_of :content - r = Reply.create("title" => "A reply", "content" => "with content!") - r.topic = Topic.create("title" => "uhohuhoh") - assert !r.valid? - assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic) - end - end - - def test_if_validation_using_method_true - # When the method returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => :condition_is_true ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_unless_validation_using_method_true - # When the method returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => :condition_is_true ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_if_validation_using_method_false - # When the method returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => :condition_is_true_but_its_not ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_unless_validation_using_method_false - # When the method returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => :condition_is_true_but_its_not ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_if_validation_using_string_true - # When the evaluated string returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => "a = 1; a == 1" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_unless_validation_using_string_true - # When the evaluated string returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => "a = 1; a == 1" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_if_validation_using_string_false - # When the evaluated string returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => "false") - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_unless_validation_using_string_false - # When the evaluated string returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => "false") - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_if_validation_using_block_true - # When the block returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", - :if => Proc.new { |r| r.content.size > 4 } ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_unless_validation_using_block_true - # When the block returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", - :unless => Proc.new { |r| r.content.size > 4 } ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_if_validation_using_block_false - # When the block returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", - :if => Proc.new { |r| r.title != "uhohuhoh"} ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_unless_validation_using_block_false - # When the block returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", - :unless => Proc.new { |r| r.title != "uhohuhoh"} ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_associated_missing - repair_validations(Reply) do - Reply.validates_presence_of(:topic) - r = Reply.create("title" => "A reply", "content" => "with content!") - assert !r.valid? - assert r.errors.on(:topic) - - r.topic = Topic.find :first - assert r.valid? - end - end - - def test_errors_to_xml - r = Reply.new :title => "Wrong Create" - assert !r.valid? - xml = r.errors.to_xml(:skip_instruct => true) - assert_equal "<errors>", xml.first(8) - assert xml.include?("<error>Title is Wrong Create</error>") - assert xml.include?("<error>Content Empty</error>") - end - - def test_validation_order - Topic.validates_presence_of :title, :author_name - Topic.validate {|topic| topic.errors.add('author_email_address', 'will never be valid')} - Topic.validates_length_of :title, :content, :minimum => 2 - - t = Topic.new :title => '' - t.valid? - e = t.errors.instance_variable_get '@errors' - assert_equal 'title', key = e.keys.first - assert_equal "can't be blank", t.errors.on(key).first - assert_equal 'is too short (minimum is 2 characters)', t.errors.on(key).second - assert_equal 'author_name', key = e.keys.second - assert_equal "can't be blank", t.errors.on(key) - assert_equal 'author_email_address', key = e.keys.third - assert_equal 'will never be valid', t.errors.on(key) - assert_equal 'content', key = e.keys.fourth - assert_equal 'is too short (minimum is 2 characters)', t.errors.on(key) - end - - def test_invalid_should_be_the_opposite_of_valid - Topic.validates_presence_of :title - - t = Topic.new - assert t.invalid? - assert t.errors.invalid?(:title) - - t.title = 'Things are going to change' - assert !t.invalid? - end - - # previous implementation of validates_presence_of eval'd the - # string with the wrong binding, this regression test is to - # ensure that it works correctly - def test_validation_with_if_as_string - Topic.validates_presence_of(:title) - Topic.validates_presence_of(:author_name, :if => "title.to_s.match('important')") - - t = Topic.new - assert !t.valid?, "A topic without a title should not be valid" - assert !t.errors.invalid?("author_name"), "A topic without an 'important' title should not require an author" - - t.title = "Just a title" - assert t.valid?, "A topic with a basic title should be valid" - - t.title = "A very important title" - assert !t.valid?, "A topic with an important title, but without an author, should not be valid" - assert t.errors.invalid?("author_name"), "A topic with an 'important' title should require an author" - - t.author_name = "Hubert J. Farnsworth" - assert t.valid?, "A topic with an important title and author should be valid" - end -end - - -class ValidatesNumericalityTest < ActiveRecord::TestCase - NIL = [nil] - BLANK = ["", " ", " \t \r \n"] - BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits - FLOAT_STRINGS = %w(0.0 +0.0 -0.0 10.0 10.5 -10.5 -0.0001 -090.1 90.1e1 -90.1e5 -90.1e-5 90e-5) - INTEGER_STRINGS = %w(0 +0 -0 10 +10 -10 0090 -090) - FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS - INTEGERS = [0, 10, -10] + INTEGER_STRINGS - BIGDECIMAL = BIGDECIMAL_STRINGS.collect! { |bd| BigDecimal.new(bd) } - JUNK = ["not a number", "42 not a number", "0xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"] - INFINITY = [1.0/0.0] - - repair_validations(Topic) - - def test_default_validates_numericality_of - Topic.validates_numericality_of :approved - - invalid!(NIL + BLANK + JUNK) - valid!(FLOATS + INTEGERS + BIGDECIMAL + INFINITY) - end - - def test_validates_numericality_of_with_nil_allowed - Topic.validates_numericality_of :approved, :allow_nil => true - - invalid!(JUNK) - valid!(NIL + BLANK + FLOATS + INTEGERS + BIGDECIMAL + INFINITY) - end - - def test_validates_numericality_of_with_integer_only - Topic.validates_numericality_of :approved, :only_integer => true - - invalid!(NIL + BLANK + JUNK + FLOATS + BIGDECIMAL + INFINITY) - valid!(INTEGERS) - end - - def test_validates_numericality_of_with_integer_only_and_nil_allowed - Topic.validates_numericality_of :approved, :only_integer => true, :allow_nil => true - - invalid!(JUNK + FLOATS + BIGDECIMAL + INFINITY) - valid!(NIL + BLANK + INTEGERS) - end - - def test_validates_numericality_with_greater_than - Topic.validates_numericality_of :approved, :greater_than => 10 - - invalid!([-10, 10], 'must be greater than 10') - valid!([11]) - end - - def test_validates_numericality_with_greater_than_or_equal - Topic.validates_numericality_of :approved, :greater_than_or_equal_to => 10 - - invalid!([-9, 9], 'must be greater than or equal to 10') - valid!([10]) - end - - def test_validates_numericality_with_equal_to - Topic.validates_numericality_of :approved, :equal_to => 10 - - invalid!([-10, 11] + INFINITY, 'must be equal to 10') - valid!([10]) - end - - def test_validates_numericality_with_less_than - Topic.validates_numericality_of :approved, :less_than => 10 - - invalid!([10], 'must be less than 10') - valid!([-9, 9]) - end - - def test_validates_numericality_with_less_than_or_equal_to - Topic.validates_numericality_of :approved, :less_than_or_equal_to => 10 - - invalid!([11], 'must be less than or equal to 10') - valid!([-10, 10]) - end - - def test_validates_numericality_with_odd - Topic.validates_numericality_of :approved, :odd => true - - invalid!([-2, 2], 'must be odd') - valid!([-1, 1]) - end - - def test_validates_numericality_with_even - Topic.validates_numericality_of :approved, :even => true - - invalid!([-1, 1], 'must be even') - valid!([-2, 2]) - end - - def test_validates_numericality_with_greater_than_less_than_and_even - Topic.validates_numericality_of :approved, :greater_than => 1, :less_than => 4, :even => true - - invalid!([1, 3, 4]) - valid!([2]) - end - - def test_validates_numericality_with_numeric_message - Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than %{count}" - topic = Topic.new("title" => "numeric test", "approved" => 10) - - assert !topic.valid? - assert_equal "smaller than 4", topic.errors.on(:approved) - - Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than %{count}" - topic = Topic.new("title" => "numeric test", "approved" => 1) - - assert !topic.valid? - assert_equal "greater than 4", topic.errors.on(:approved) - end - - private - def invalid!(values, error=nil) - with_each_topic_approved_value(values) do |topic, value| - assert !topic.valid?, "#{value.inspect} not rejected as a number" - assert topic.errors.on(:approved) - assert_equal error, topic.errors.on(:approved) if error - end - end - - def valid!(values) - with_each_topic_approved_value(values) do |topic, value| - assert topic.valid?, "#{value.inspect} not accepted as a number" - end - end - - def with_each_topic_approved_value(values) - topic = Topic.new("title" => "numeric test", "content" => "whatever") - values.each do |value| - topic.approved = value - yield topic, value - end - end -end diff --git a/vendor/rails/activerecord/test/cases/xml_serialization_test.rb b/vendor/rails/activerecord/test/cases/xml_serialization_test.rb deleted file mode 100644 index d8d952be..00000000 --- a/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +++ /dev/null @@ -1,240 +0,0 @@ -require "cases/helper" -require 'models/contact' -require 'models/post' -require 'models/author' -require 'models/tagging' -require 'models/comment' -require 'models/company_in_module' - -class XmlSerializationTest < ActiveRecord::TestCase - def test_should_serialize_default_root - @xml = Contact.new.to_xml - assert_match %r{^<contact>}, @xml - assert_match %r{</contact>$}, @xml - end - - def test_should_serialize_default_root_with_namespace - @xml = Contact.new.to_xml :namespace=>"http://xml.rubyonrails.org/contact" - assert_match %r{^<contact xmlns="http://xml.rubyonrails.org/contact">}, @xml - assert_match %r{</contact>$}, @xml - end - - def test_should_serialize_custom_root - @xml = Contact.new.to_xml :root => 'xml_contact' - assert_match %r{^<xml-contact>}, @xml - assert_match %r{</xml-contact>$}, @xml - end - - def test_should_allow_undasherized_tags - @xml = Contact.new.to_xml :root => 'xml_contact', :dasherize => false - assert_match %r{^<xml_contact>}, @xml - assert_match %r{</xml_contact>$}, @xml - assert_match %r{<created_at}, @xml - end - - def test_should_allow_camelized_tags - @xml = Contact.new.to_xml :root => 'xml_contact', :camelize => true - assert_match %r{^<XmlContact>}, @xml - assert_match %r{</XmlContact>$}, @xml - assert_match %r{<CreatedAt}, @xml - end - - def test_should_allow_skipped_types - @xml = Contact.new(:age => 25).to_xml :skip_types => true - assert %r{<age>25</age>}.match(@xml) - end - - def test_should_include_yielded_additions - @xml = Contact.new.to_xml do |xml| - xml.creator "David" - end - assert_match %r{<creator>David</creator>}, @xml - end -end - -class DefaultXmlSerializationTest < ActiveRecord::TestCase - def setup - @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml - end - - def test_should_serialize_string - assert_match %r{<name>aaron stack</name>}, @xml - end - - def test_should_serialize_integer - assert_match %r{<age type="integer">25</age>}, @xml - end - - def test_should_serialize_binary - assert_match %r{YmluYXJ5ZGF0YQ==\n</avatar>}, @xml - assert_match %r{<avatar(.*)(type="binary")}, @xml - assert_match %r{<avatar(.*)(encoding="base64")}, @xml - end - - def test_should_serialize_datetime - assert_match %r{<created-at type=\"datetime\">2006-08-01T00:00:00Z</created-at>}, @xml - end - - def test_should_serialize_boolean - assert_match %r{<awesome type=\"boolean\">false</awesome>}, @xml - end - - def test_should_serialize_yaml - assert_match %r{<preferences type=\"yaml\">--- \n:gem: ruby\n</preferences>}, @xml - end -end - -class NilXmlSerializationTest < ActiveRecord::TestCase - def setup - @xml = Contact.new.to_xml(:root => 'xml_contact') - end - - def test_should_serialize_string - assert_match %r{<name nil="true"></name>}, @xml - end - - def test_should_serialize_integer - assert %r{<age (.*)></age>}.match(@xml) - attributes = $1 - assert_match %r{nil="true"}, attributes - assert_match %r{type="integer"}, attributes - end - - def test_should_serialize_binary - assert %r{<avatar (.*)></avatar>}.match(@xml) - attributes = $1 - assert_match %r{type="binary"}, attributes - assert_match %r{encoding="base64"}, attributes - assert_match %r{nil="true"}, attributes - end - - def test_should_serialize_datetime - assert %r{<created-at (.*)></created-at>}.match(@xml) - attributes = $1 - assert_match %r{nil="true"}, attributes - assert_match %r{type="datetime"}, attributes - end - - def test_should_serialize_boolean - assert %r{<awesome (.*)></awesome>}.match(@xml) - attributes = $1 - assert_match %r{type="boolean"}, attributes - assert_match %r{nil="true"}, attributes - end - - def test_should_serialize_yaml - assert %r{<preferences(.*)></preferences>}.match(@xml) - attributes = $1 - assert_match %r{type="yaml"}, attributes - assert_match %r{nil="true"}, attributes - end -end - -class DatabaseConnectedXmlModuleSerializationTest < ActiveRecord::TestCase - - fixtures :projects, :developers, :developers_projects - - def test_module - project = MyApplication::Business::Project.find :first - xml = project.to_xml - assert_match %r{<my-application-business-project>}, xml - assert_match %r{</my-application-business-project>}, xml - end - - def test_module_with_include - project = MyApplication::Business::Project.find :first - xml = project.to_xml :include => :developers - assert_match %r{<developer type="MyApplication::Business::Developer">}, xml - assert_match %r{</developer>}, xml - end -end - -class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase - fixtures :authors, :posts - # to_xml used to mess with the hash the user provided which - # caused the builder to be reused. This meant the document kept - # getting appended to. - def test_passing_hash_shouldnt_reuse_builder - options = {:include=>:posts} - david = authors(:david) - first_xml_size = david.to_xml(options).size - second_xml_size = david.to_xml(options).size - assert_equal first_xml_size, second_xml_size - end - - def test_include_uses_association_name - xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0 - assert_match %r{<hello-posts type="array">}, xml - assert_match %r{<hello-post type="Post">}, xml - assert_match %r{<hello-post type="StiPost">}, xml - end - - def test_included_associations_should_skip_types - xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0, :skip_types => true - assert_match %r{<hello-posts>}, xml - assert_match %r{<hello-post>}, xml - assert_match %r{<hello-post>}, xml - end - - def test_methods_are_called_on_object - xml = authors(:david).to_xml :methods => :label, :indent => 0 - assert_match %r{<label>.*</label>}, xml - end - - def test_should_not_call_methods_on_associations_that_dont_respond - xml = authors(:david).to_xml :include=>:hello_posts, :methods => :label, :indent => 2 - assert !authors(:david).hello_posts.first.respond_to?(:label) - assert_match %r{^ <label>.*</label>}, xml - assert_no_match %r{^ <label>}, xml - end - - def test_procs_are_called_on_object - proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') } - xml = authors(:david).to_xml(:procs => [ proc ]) - assert_match %r{<nationality>Danish</nationality>}, xml - end - - def test_top_level_procs_arent_applied_to_associations - author_proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') } - xml = authors(:david).to_xml(:procs => [ author_proc ], :include => :posts, :indent => 2) - - assert_match %r{^ <nationality>Danish</nationality>}, xml - assert_no_match %r{^ {6}<nationality>Danish</nationality>}, xml - end - - def test_procs_on_included_associations_are_called - posts_proc = Proc.new { |options| options[:builder].tag!('copyright', 'DHH') } - xml = authors(:david).to_xml( - :indent => 2, - :include => { - :posts => { :procs => [ posts_proc ] } - } - ) - - assert_no_match %r{^ <copyright>DHH</copyright>}, xml - assert_match %r{^ {6}<copyright>DHH</copyright>}, xml - end - - def test_should_include_empty_has_many_as_empty_array - authors(:david).posts.delete_all - xml = authors(:david).to_xml :include=>:posts, :indent => 2 - - assert_equal [], Hash.from_xml(xml)['author']['posts'] - assert_match %r{^ <posts type="array"/>}, xml - end - - def test_should_has_many_array_elements_should_include_type_when_different_from_guessed_value - xml = authors(:david).to_xml :include=>:posts_with_comments, :indent => 2 - - assert Hash.from_xml(xml) - assert_match %r{^ <posts-with-comments type="array">}, xml - assert_match %r{^ <posts-with-comment type="Post">}, xml - assert_match %r{^ <posts-with-comment type="StiPost">}, xml - - types = Hash.from_xml(xml)['author']['posts_with_comments'].collect {|t| t['type'] } - assert types.include?('SpecialPost') - assert types.include?('Post') - assert types.include?('StiPost') - end - -end diff --git a/vendor/rails/activerecord/test/cases/yaml_serialization_test.rb b/vendor/rails/activerecord/test/cases/yaml_serialization_test.rb deleted file mode 100644 index f221def6..00000000 --- a/vendor/rails/activerecord/test/cases/yaml_serialization_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "cases/helper" -require 'models/topic' - -class YamlSerializationTest < ActiveRecord::TestCase - def test_to_yaml_with_time_with_zone_should_not_raise_exception - Time.zone = ActiveSupport::TimeZone["Pacific Time (US & Canada)"] - ActiveRecord::Base.time_zone_aware_attributes = true - topic = Topic.new(:written_on => DateTime.now) - assert_nothing_raised { topic.to_yaml } - end -end diff --git a/vendor/rails/activerecord/test/config.rb b/vendor/rails/activerecord/test/config.rb deleted file mode 100644 index 6e2e8b21..00000000 --- a/vendor/rails/activerecord/test/config.rb +++ /dev/null @@ -1,5 +0,0 @@ -TEST_ROOT = File.expand_path(File.dirname(__FILE__)) -ASSETS_ROOT = TEST_ROOT + "/assets" -FIXTURES_ROOT = TEST_ROOT + "/fixtures" -MIGRATIONS_ROOT = TEST_ROOT + "/migrations" -SCHEMA_ROOT = TEST_ROOT + "/schema" diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcderby/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcderby/connection.rb deleted file mode 100644 index 222ef5db..00000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcderby/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using Derby via JRuby, activerecord-jdbc-adapter and activerecord-jdbcderby-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcderby', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbcderby', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbch2/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbch2/connection.rb deleted file mode 100644 index 9d2875e8..00000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbch2/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using H2 via JRuby, activerecord-jdbc-adapter and activerecord-jdbch2-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbch2', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbch2', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb deleted file mode 100644 index fa943c2c..00000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using HSQLDB via JRuby, activerecord-jdbc-adapter and activerecord-jdbchsqldb-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbchsqldb', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbchsqldb', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcmysql/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcmysql/connection.rb deleted file mode 100644 index e2517a50..00000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcmysql/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using MySQL via JRuby, activerecord-jdbc-adapter and activerecord-jdbcmysql-adapter\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcmysql', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'jdbcmysql', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb deleted file mode 100644 index 0685da44..00000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using Postgrsql via JRuby, activerecord-jdbc-adapter and activerecord-postgresql-adapter\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# createuser rails --createdb --no-superuser --no-createrole -# createdb -O rails activerecord_unittest -# createdb -O rails activerecord_unittest2 - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcpostgresql', - :username => ENV['USER'] || 'rails', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbcpostgresql', - :username => ENV['USER'] || 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb deleted file mode 100644 index 26d4676f..00000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using SQLite3 via JRuby, activerecord-jdbc-adapter and activerecord-jdbcsqlite3-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'jdbcsqlite3', :database => db_file, :timeout => 5000 } } - unless File.exist?(db_file) - puts "SQLite3 database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite3 "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/vendor/rails/activerecord/test/connections/native_db2/connection.rb b/vendor/rails/activerecord/test/connections/native_db2/connection.rb deleted file mode 100644 index 324315d2..00000000 --- a/vendor/rails/activerecord/test/connections/native_db2/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native DB2\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'db2', - :host => 'localhost', - :username => 'arunit', - :password => 'arunit', - :database => 'arunit' - }, - 'arunit2' => { - :adapter => 'db2', - :host => 'localhost', - :username => 'arunit', - :password => 'arunit', - :database => 'arunit2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_firebird/connection.rb b/vendor/rails/activerecord/test/connections/native_firebird/connection.rb deleted file mode 100644 index 67a936ca..00000000 --- a/vendor/rails/activerecord/test/connections/native_firebird/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using native Firebird\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'firebird', - :host => 'localhost', - :username => 'rails', - :password => 'rails', - :database => 'activerecord_unittest', - :charset => 'UTF8' - }, - 'arunit2' => { - :adapter => 'firebird', - :host => 'localhost', - :username => 'rails', - :password => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb b/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb deleted file mode 100644 index c01d864a..00000000 --- a/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb +++ /dev/null @@ -1,27 +0,0 @@ -puts 'Using native Frontbase' -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'frontbase', - :host => 'localhost', - :username => 'rails', - :password => '', - :database => 'activerecord_unittest', - :session_name => "unittest-#{$$}" - }, - 'arunit2' => { - :adapter => 'frontbase', - :host => 'localhost', - :username => 'rails', - :password => '', - :database => 'activerecord_unittest2', - :session_name => "unittest-#{$$}" - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_mysql/connection.rb b/vendor/rails/activerecord/test/connections/native_mysql/connection.rb deleted file mode 100644 index 140e06d6..00000000 --- a/vendor/rails/activerecord/test/connections/native_mysql/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native MySQL\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'mysql', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'mysql', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_openbase/connection.rb b/vendor/rails/activerecord/test/connections/native_openbase/connection.rb deleted file mode 100644 index 655cb9ca..00000000 --- a/vendor/rails/activerecord/test/connections/native_openbase/connection.rb +++ /dev/null @@ -1,21 +0,0 @@ -print "Using native OpenBase\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'openbase', - :username => 'admin', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'openbase', - :username => 'admin', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_oracle/connection.rb b/vendor/rails/activerecord/test/connections/native_oracle/connection.rb deleted file mode 100644 index 0954b27f..00000000 --- a/vendor/rails/activerecord/test/connections/native_oracle/connection.rb +++ /dev/null @@ -1,27 +0,0 @@ -print "Using Oracle\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new STDOUT -ActiveRecord::Base.logger.level = Logger::WARN - -# Set these to your database connection strings -db = ENV['ARUNIT_DB'] || 'activerecord_unittest' - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'oracle', - :username => 'arunit', - :password => 'arunit', - :database => db, - }, - 'arunit2' => { - :adapter => 'oracle', - :username => 'arunit2', - :password => 'arunit2', - :database => db - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb b/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb deleted file mode 100644 index 3b5ff900..00000000 --- a/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb +++ /dev/null @@ -1,21 +0,0 @@ -print "Using native PostgreSQL\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'postgresql', - :database => 'activerecord_unittest', - :min_messages => 'warning' - }, - 'arunit2' => { - :adapter => 'postgresql', - :database => 'activerecord_unittest2', - :min_messages => 'warning' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb b/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb deleted file mode 100644 index fea985d8..00000000 --- a/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native SQlite\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite', :database => db_file } } - unless File.exist?(db_file) - puts "SQLite database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb b/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb deleted file mode 100644 index c517c237..00000000 --- a/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native SQLite3\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => db_file, :timeout => 5000 } } - unless File.exist?(db_file) - puts "SQLite3 database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite3 "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb b/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb deleted file mode 100644 index 6aba9719..00000000 --- a/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using native SQLite3\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -def make_connection(clazz, db_definitions_file) - clazz.establish_connection(:adapter => 'sqlite3', :database => ':memory:') - File.read(SCHEMA_ROOT + "/#{db_definitions_file}").split(';').each do |command| - clazz.connection.execute(command) unless command.strip.empty? - end -end - -make_connection(ActiveRecord::Base, 'sqlite.sql') -make_connection(Course, 'sqlite2.sql') -load(SCHEMA_ROOT + "/schema.rb") diff --git a/vendor/rails/activerecord/test/connections/native_sybase/connection.rb b/vendor/rails/activerecord/test/connections/native_sybase/connection.rb deleted file mode 100644 index 3282d269..00000000 --- a/vendor/rails/activerecord/test/connections/native_sybase/connection.rb +++ /dev/null @@ -1,23 +0,0 @@ -print "Using native Sybase Open Client\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'sybase', - :host => 'database_ASE', - :username => 'sa', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'sybase', - :host => 'database_ASE', - :username => 'sa', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/fixtures/accounts.yml b/vendor/rails/activerecord/test/fixtures/accounts.yml deleted file mode 100644 index 32583042..00000000 --- a/vendor/rails/activerecord/test/fixtures/accounts.yml +++ /dev/null @@ -1,29 +0,0 @@ -signals37: - id: 1 - firm_id: 1 - credit_limit: 50 - firm_name: 37signals - -unknown: - id: 2 - credit_limit: 50 - -rails_core_account: - id: 3 - firm_id: 6 - credit_limit: 50 - -last_account: - id: 4 - firm_id: 2 - credit_limit: 60 - -rails_core_account_2: - id: 5 - firm_id: 6 - credit_limit: 55 - -odegy_account: - id: 6 - firm_id: 9 - credit_limit: 53 diff --git a/vendor/rails/activerecord/test/fixtures/all/developers.yml b/vendor/rails/activerecord/test/fixtures/all/developers.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/activerecord/test/fixtures/all/people.csv b/vendor/rails/activerecord/test/fixtures/all/people.csv deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/activerecord/test/fixtures/all/tasks.yml b/vendor/rails/activerecord/test/fixtures/all/tasks.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/activerecord/test/fixtures/author_addresses.yml b/vendor/rails/activerecord/test/fixtures/author_addresses.yml deleted file mode 100644 index 7b905721..00000000 --- a/vendor/rails/activerecord/test/fixtures/author_addresses.yml +++ /dev/null @@ -1,5 +0,0 @@ -david_address: - id: 1 - -david_address_extra: - id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/author_favorites.yml b/vendor/rails/activerecord/test/fixtures/author_favorites.yml deleted file mode 100644 index e81fdac7..00000000 --- a/vendor/rails/activerecord/test/fixtures/author_favorites.yml +++ /dev/null @@ -1,4 +0,0 @@ -david_mary: - id: 1 - author_id: 1 - favorite_author_id: 2 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/authors.yml b/vendor/rails/activerecord/test/fixtures/authors.yml deleted file mode 100644 index de2ec7d3..00000000 --- a/vendor/rails/activerecord/test/fixtures/authors.yml +++ /dev/null @@ -1,9 +0,0 @@ -david: - id: 1 - name: David - author_address_id: 1 - author_address_extra_id: 2 - -mary: - id: 2 - name: Mary diff --git a/vendor/rails/activerecord/test/fixtures/binaries.yml b/vendor/rails/activerecord/test/fixtures/binaries.yml deleted file mode 100644 index d150c570..00000000 --- a/vendor/rails/activerecord/test/fixtures/binaries.yml +++ /dev/null @@ -1,132 +0,0 @@ -flowers: - id: 1 - data: !binary | /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCQoKCg4LCw4UDQsNFBcRDg4R - FxsVFRUVFRsbFRcXFxcVGxoeICEgHhonJyoqJyc1NTU1NTY2NjY2NjY2Njb/ - 2wBDAQ4NDRERERcRERcXExQTFx0ZGhoZHSYdHR4dHSYsJCAgICAkLCgrJiYm - KygvLywsLy82NjY2NjY2NjY2NjY2Njb/wAARCACvAIMDAREAAhEBAxEB/8QA - GwAAAgMBAQEAAAAAAAAAAAAABAUAAwYCAQf/xABAEAACAQMCBAMFBwMBBQkA - AAABAgMABBESIQUTMUEiUWEUMnGBkQYjQlKxwdEzYqGSFSRD4fAlNUVyc4Ki - svH/xAAZAQADAQEBAAAAAAAAAAAAAAAAAQIDBAX/xAAqEQACAgEEAQQCAgID - AAAAAAAAAQIRAxIhMUFRBBMiYTJxgaFCUpGxwf/aAAwDAQACEQMRAD8A+nUA - SgCUASgDxmCjJ2A6k0ADe3QumqFhID7rA+E/OgBNLecbWcCVoRA2f6Wcj/Vv - USvyNHDtI5y7s3zqCgWR2S7gjiy0koZQM4Axg5+NC+hkHFr8WcjpIYriL3kf - xAMp8S+KnbQqHEHGXG06Z/uT+KpT8icRnBcwzjMTBvMdx8RVkltAEoAlAEoA - lAEoAlAEoArmmSBNbnb9aAEtxdG7bTKP927x9Q3ofOp1DoTwCSy4okMAK2TB - pY4z2/Og+ZyKm9yqD2bVO594NupO2M/h+VJgjmWPmIVyyZ7r1pDJw9Iku44V - Yu8Ebl+Zu+XK75/xVRJZXxzh8WmS7ErRM2kMgAIdiQo+dOaHB7nMCFECMzNj - 8T7k/SoGEBuURIjaXXcMD+tCYmh7bXetE52EkbHwJ8hWpAVTAlAEoAlAEoAl - AFc0ywxl26D/ADQAjurlpW5khwOw8hWTZSQMLiAn3x/18aQwTi03s8UV0oyI - ZAzEdkPhfb4GgaDgV2ZTqB3B86BFVwCQGV9Dr7rfh+DVEl/DAGt7qJLiKULm - 5cOknpnBwfhp2pwyL+Q8l97O72+ZUEpR1ZFG2fEBg7+tW3YkW/HY0iiMB086 - SAsYM7623Pb0+FVZI2sL3mfdSf1B0P5v+dXGVioOqhEoAlAEoA8JxuelAGNu - ftDeX1/7Na2x5eWEJfbVp6t8+1RzwVQXDwtrkcziO7fhgU4VfiV61SQr8Hb8 - E4eR4UMZ7FHYH9TRSCxfDYXEuoQzAJpAZJBqDasg7j+KiKstsEtzfWlxdZjV - wjBCAdtlDArnsQaTQfYf7RxEdbGT5Ff5o0sNvIvEgF8sxhdZnDKsW27dBsPS - s6qV9gXXd5ccnBtpIiWXS5G2QwP12q2OIQvEZ239jm33zpPf5U6Yie2Xsp0w - 2uG6EOQCMeeaVAR4+KgBpGjjUnBAOo/oP1p6aJs7g4bNIqzG8kVveXQo28uu - acY9hfRqbSbmxDJy42f4+fzrQkvoAlAEoAV8cuWjhECdZfeOcYUdd/Wom9hx - EFhHjiMTYO2r8QONjUwLlwP61Mzk0AAWGxYeg/eoh2VLoC4iUteIrPM3+7Xa - cps7BZI/d+qk0pFR4/QzkuFiVGOcMQNgT1rTolLkSSpJJc61KIBLpjYn3ve2 - +O/asq1PYsae1WsdseYA7QeNde+SncD0rSqKhjbkl5Flp9qPapFXkMZG1agp - 8K4G2TjvSTO+fpNHYfDe25lRWOJZAdJII6dck4p/Zz5fTtptdFl2fCo9c/QU - pnEi2DaJB6CnHoT5CbaflSBvwnZvhTAcUASgCUAZ/i6e0SK222eozttUTKiL - 7WEJexMWX3vygHofKpiUx3Wpmck0AL7Q4kb/AMv71EOypcIB+0EkLRpE5wUc - SasZC4OdwO2KT8eCsf0WT36sXXK+AqkZ8R+9xq+80dh5VZajQseaWVI5IHCR - MwZkIHhckAOPyrkdKlPnoNqdLdkml9mI0za0VtAjCr/VOWLMRjrTGpNU2BSH - lxy3HD5dAClZYG6nR4QQcYI3+NJb7o9DDnWaPyj8r5DC9w0cVsYyyrCGUrjU - 8vhJ0b48PlT+hKUVJ773/Q4kLmGMPq5nLOvVjVnGN9O1KfR52SnOTXAWmyge - lX0YnuaAGfCrkzwMGxqiYrt+X8JpAHUwKrltMZ8ztQAg4mhJXwlgwK4H1qJF - RFqQyNd240MMON8Y6bmpiyn2aA1qZlRkUSCPPjIyB6ClfQAMBxK3wP61OPk1 - q6Qn4pJcyXeI49UUiaZCPy1r7bt/cTphh0WvKPeCS+02oZtTSkYYquBkbAlt - qK+KtkyT0pbJFV/dSxW8kZBLNEq83w6HcnG4x1rOXZnJbbeQO9RrSKKMnW6t - 45Nj4hjYbZ6GufMpbU+DBthXBrG61ZeZo4bZtXs4B0bjOGzse1XhHGTXAebZ - b/dzh4yrow/Cd+nyq49minpYXMfHj+0D6miXKIXYXWhBKAOOBTSxXZidTpbK - E42yNxWa5KfBpa0JBLxt1X50AKOKe5Gdup66vL+2omVHkVxY9rg2QeMdpM1E - eS3wNrq/htQzSnSFGf8A8rY0xencv5FnD76PiN61xETohBU5HXsNPp5+tZ6L - nqsnNg9trfkF4rfrbRvp8cm66B6nbP8AFbQhTbuzpw4qpsVT3XD3n5d1cttE - MFchAxzkeHoR5GtHOG5eTPDeIJFx8w2/Kt5Gj8eU22GWydq5jgk+PsvueJST - BeeBIi7YAwSD3x50tW+5pKq2e5JZ2uFS3c/dBmKsBuc+dZzfSMn8ugi3llsp - fBI0nNULIr+bdCPlWduMkl2QuRvDOLTVzPTVjfSPXFdscdJts6vYcld0WwTx - XcjGM5Axg/ChQU02gWH4Nh5IAyeg6mkcp6hJAJGn41NgBWsgSUuCMq+fecdD - UdmlbGuVtQBHQ7itTMAuDmVvTagBfxCUxquBnrUTKiK2upDLEFAXUwGc+tRH - ktAvFkubZpI5NUyTKyjIz4z00/Stj1MUoNKtmgHhd+bSRrd9UK8soW/EvcN8 - DWCk1N2rPOnqlle1/IW8QnnwfEdW5yPI9cfKqlq1N3syvUxyY5PfkVQ8oSa5 - TshB0fm9KaOWP2X35iuZOZbJ4QMyaBgAeZA6U0VL8VRdaSxkYmy6Lkjpnby1 - VlKO4vDHFhcw+EIcsQS6YBchd8IfM5p49q8mi/tlF8US45aKwyOcS/hZQ2+N - O9LJ8XZD5aBH4s7HlP8A0s+IrsxX1qpSlJVexXvSez4HlrcQq5e3O0gAx0C4 - 863nmhFLQehKcdCSDBfXEsZCqAc+HUwHw8Jx0/WuaTnJPT/ZwSxveQRBE4TU - +qSRRnfGB323OanHjfMm2zI8trqXHbT8d60NDT8Pn5tnE7bMRv8ALatUzMGk - OXY+ppgA8UH+7Z6EHYk4/WoycDRnVvUjViyDndE1HYefn9a5sOR63GS/Rv6f - 8qmWcFuGmnHtPVieSzncjyz3O1dn7Ov1cYxinF7+DvjEltcXSK7qlvb+BmA8 - z4lb08qIuLel8h6OaipLnI/J3NwuEqDbeDBXWPe1Rjqu/wCYV0PGmazcskdL - Kr37OcOuHWSNeTkqSE93HcaexIp+xBmD9NB/TOG+zdnCJmtQUeVWRIycp4hp - 3zk+tKWBdCl6ZU62A2+y0VtbLqLTyKCZCh07/wBoINYyxUYS9PVFdnAIIo8R - bFG9paUeMdT91q2Bx9ajSTpSsFDR3Gow6pvDp5jDEjd/EMnp0rly25KkZP5P - gEdIYyBpyw643GfM57071JdCrpIbcrRJaCI632MrdUC+WO9dkcKSS/5PRji2 - j/Y2iWGS4eGNkDLh1wPCenu5zWkMSi3XBosaiuORlDcxgmJ2CuOgI05/mpyQ - o5M2Ct0B2yQ6D4Vzuerj9q5aMR9w9glpGoG2P39atGbPasQNf7wYzjJ8gf1q - ZcDjyZjjNr9ykyyeOLvjr8umP1qFR2YpxpxmrAU4YdpGkC3Kf6D5fCn7eqPN - DXptcdeoJ4ct887TcyCNR4csQdQ7rpP61p6aNdhg7Td/9jb2hh+TI2+7YEf6 - etdp2RRwbiViREpbT72O1cmT1Si6FKUV3R6t+Op2PTftW+PIpqy1G9wKbjCS - utvCGdnb7x12wnfSehNKcujmyvpFL3DBy64a3CFnGC+wbJKE/pWL5OeSr9Ir - jis7hG9mHLlc6o2IwXGdye/eolBTT68EabVoL4TwlJpi08XQEddjj8461msT - tXVIUYb2MWtYLxHMOiO4hfSM+4WXorY3x8K3U6Ov5w47QktmntzpuAIry2zE - yY2zksuCeqsp6+Vaavjd7hHNcN+UH3V3rg1toFzEA2gHOdW3gz19Ky9x72Rj - z03e6KeHz3CSK12GUxnVGrZJPVTo8t6y35ZjPz5NDbXDNCpVCR500c4bViBe - IIWtyR1Xfy9KiXA0Zu+R1hbEYJ8iwz8t6xst/QFPy2iRYoWhf/ian15P6CsM - mR1pWyRPuyrTewTwuZVK2zJHpc+++c+gFb+jzfJQdb/5dm3pslOhoPYJWZYQ - khT3yuCF+JG1esqZ6MZ32VgTQKTHjSxzgiuXJ6GMnY5YoyOBaId5xqDdc9M+ - tb48KxqiuFR5d20FtDI+eTgasjAJ076ct50pr7OfL58Gdu5IeIrG0UmZzsFi - BAC4911Pr5Vzs43Ut+w7hHtNvbkOhTUwKnGl8HqwDb9qUXzsPEjQcLmymVyx - zplkI0sxHmKLNdKdlHE/ub1buFFMGwkRAch+xYLQaY8lQcH+XkRcavFuLyK6 - 3PKTl4PQjuNt+hxuaiUjz55PlsW8znWjzxwgLFiMBcHAG++odKV2my7uOoL4 - bMjW2F0q+nGnfVqPUnPb0HrQpXF+Rt6kWiK7xtJPj00gfLBqorYnY1FwwiLk - gkKeijJ+gpvbczEfFOLAjkhBo/FzMgj4qP3rly5b2/8ABGflu87xx/dxnOvG - AfXVuTUJP9DPfazO5d/eY5b4msZ3bsRxc40nPQg/pRDlMa2GHCOI8Lg4ZDFH - IMJpWRejyTP1AXvv3r24TVI78WSOlbjXUs4wv9IEgsdskdhmtdR0KQDHfxQX - Pss7aucmuINtqUErpGe9S59ClkV1wxZxy/itrf2csJTINLQtvjyOe1ZzmjHP - ljTXkF4HPwzh8trcysA4fSTk5GrwuSOmBnY+VYnJcUl5Hl6sE105X75cAmWN - vmACDRaOiLDLS7UHMhA7KuQNvTOKRbXAp+0ExS5SSJuXzFOtVbr2ye24rnzN - pqjlzPfkzzylpWxvj/raj8kmznHfApFS1uhJup/4R6Nt3+taRquTbF+Dst4d - JHaJonZR+UqPwnz071OuK7FexsrBoZ7WOWLdG6eEjvitVJEF12CJWx33FUBk - +MWXFOYzuRNbA6gVwgGe5Xz9azd8ktMUuPDg4YfHIqHJeBaGTaVyxOmYBUEW - n38bD5j/ADUThrX2NffJzejl2zPICOX4WHffp1rmjF60ijOgCNo3R8nZsjqp - 8jnuPSvQuhJ1wHzz390BJLNoVGDKo93I74pvP/LNfdm+yrifEpL2USEjIAVf - T4UtTk7kRPI5MHt7d7iQIvXclv3p0wSbouktOSjcwb7fLPSs2pahSjRbacbn - srRrRUR0bOJCMMurr0OD6VoVGdD3iH2i4W9nCLLLXsWATIh93GD6Ghmksol5 - rSku8hLMe46fSuWTMXueezg+IOMkjbfejVs1RNfYdHbyhdTKQvn28utRpl/A - 1fAwtOGyP4mU47Yx9Sa0hj8l15PodlFybWGP8qAV1USU3y7q3ypgAXKh4XU9 - MGpl2Bl723iMMoCqpKnGFK+tYmj4YDaW91I0fO2B3EmMkY33P7mhJmSvkb3t - vBPaj7tvZiMs2Nyo6Y1uSd+m9VJdlGOveGCE5WTVEc6fCc/x/mlHI/8AUWkY - 8AurKAv7eNOpcQM4OnQOoHXeqpcmkWhdeexy3MrW33dv6/sKndGUudgeJnjc - GFipHQjbHwqtbBNnsvN0qskjOoJxk567nNGpvrcLb5OhbpJgINR2AGd/lUW1 - yBwLaXSZhGdKEAt8a05Q6DH+5VNSNkjbbqeprmS1N7gN+C21tcoJllTnr1jf - dRnoD339K2hjXkSGl/NKIbi2dTq0rJ5hl1AZDdznber+ike8OTmvFGFbxsB7 - n75qVyU+Dd4rYgquk1xHzG4+VACxsaTnpijoDN3kC8s+JjnqMmudmoQvD/b7 - O1YYVdAWXG2dOV7Vt0QnyNXijePlsoKYxj4dKdEmV43ZJaYDkurKTk7+n6Vn - LYtdiyLhVxeWYuWAECjRGPxNjPTemkSlqYm0EOQDgjbI6fKhiregm3tlOkyS - feO+APLHeplfXRMgmaCK5i0qzFwckbduuKmGz3Bc7hElhZ5ieNgjkZAyR7oD - Z7jI771tJKnwzZxj0VtfzItxa4xLlgrZ93OOnbfvU6tG3NE66tFllwDiE9rG - I7kLG+S8erKgfhbbz8utSop7rkzD7fgt3Zyq8kSXMfuycv39PoD+1Dj53Aa8 - RSKGxRYwQGdQNWScbtjxb9qp0o8FxGH2bi5s+v8ADCM/+47ClBFSNRWpBKAF - NzHy2dO2+PhR0Blblm5ZBbY1zmo24If+zYvTUP8A5GtlwjNhpqhCT7RQiSOI - noGIP6/tWeToqIN/4CiqMkb48vGaTfxFwzOPb4dv7jt/ArGMrlSJ7PBGyb9h - 512JFHrtoGfd9cUUn0Kgq0iadrf8hfUMjv2NTJdLgfRxdWfst1ytWuVgGd/N - m3OK5skWuyDVwW/IxygNJ6r0+JFbxjVFBQqwAuNDMEX/AKoP0BqZ8DjyaPgN - mbWxXUPvZfG/z6D6URWwMZVQiUADXsOtNQ95f070AYi5wMr+Un9aw7NehpwT - /u+P4v8A/Y1rHhGbDqoQs41g22M76gcd6znwVHkWx3kX+zfZ9LM+46bDxZ61 - Mn8K8g+RfPExboCcZz6+Qq4YUqFR5GpVgwzpO5U7q3xBrUVFrmX3kiAC9gMf - SqCjt2bSHxpc/wCKUr4oEcjl3d4zS+5lQfkB0rnmvluVWw9W5hHc1epE0WLc - w/mp6kFBENkvEpoRkGGF+ZL8gcL8zRyBpaYEoAlAEoAx/wBobBrWcyqMwTEk - H8rdSv8AFZTXZafQutOJSxwLBHhQhbfGTuSe9NS2Bota6lb3nJ+dTYUgaZiw - 60mMF3UEb77mhAeI+kjX3z8q3TAJiuo4gRpGr1rTUQ4lct5IeunHlijULSBc - ySRyMjbqDsR/NS5F0Fwx/XzrnfIwxM0AXRxSSuI0XLscAetArNhw2xWxtxEN - 3O8jebVqiAumBKAJQBKAKbm2iuoWhmGqNxgikBirngsvDZWV/HGxJjkx7w8j - 61k40aJlWnekByy0wB3U0ADTLgnoNXVjVxYFPNDjDdvP9iN6sD1iMfi2/vH7 - 0WBLePXINI2+v+TUyYDaOLA6VmIvSMswUdT7oHegDUcJ4WLRebLvcMP9I8hW - iRDGdUBKAJQBKAJQBKAK54IriMxyrqQ9qQGZ4jwaW1JeMGWDz7r8R+9Q4lJi - rH9tSM5ZCR0/xQBXLbcwYxin+gF83D7nV4Vz/dmrUh2epw+7OxGB6n/nRqDY - YW9qkA3bxd6ixB9rayXL6IFLHv5D4mnQjS8O4TFZ+NvHP+fy9Fq0ibGFMCUA - SgCUASgCUASgCUASgAC74PbXOTvE5/En7jpSoLE8/wBn7uPJjKyj46T9D/NT - pKsXyQzxNpdNP0/akB5484WkMKh4RfXG4UafNmH7b0UxWMrb7Nxg6rl9Z/Im - w+vWq0iscQwxQroiUIvkKsRZQBKAJQBKAJQB/9k= diff --git a/vendor/rails/activerecord/test/fixtures/books.yml b/vendor/rails/activerecord/test/fixtures/books.yml deleted file mode 100644 index 473663ff..00000000 --- a/vendor/rails/activerecord/test/fixtures/books.yml +++ /dev/null @@ -1,7 +0,0 @@ -awdr: - id: 1 - name: "Agile Web Development with Rails" - -rfr: - id: 2 - name: "Ruby for Rails" diff --git a/vendor/rails/activerecord/test/fixtures/categories.yml b/vendor/rails/activerecord/test/fixtures/categories.yml deleted file mode 100644 index b0770a09..00000000 --- a/vendor/rails/activerecord/test/fixtures/categories.yml +++ /dev/null @@ -1,14 +0,0 @@ -general: - id: 1 - name: General - type: Category - -technology: - id: 2 - name: Technology - type: Category - -sti_test: - id: 3 - name: Special category - type: SpecialCategory diff --git a/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml b/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml deleted file mode 100644 index 517fc8f7..00000000 --- a/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml +++ /dev/null @@ -1,9 +0,0 @@ -sub_special_1: - id: 100 - name: A special category in a subdir file - type: SpecialCategory - -sub_special_2: - id: 101 - name: Another special category - type: SpecialCategory diff --git a/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml b/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml deleted file mode 100644 index 389a04a5..00000000 --- a/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +++ /dev/null @@ -1,4 +0,0 @@ -sub_special_3: - id: 102 - name: A special category in an arbitrarily named subsubdir file - type: SpecialCategory diff --git a/vendor/rails/activerecord/test/fixtures/categories_ordered.yml b/vendor/rails/activerecord/test/fixtures/categories_ordered.yml deleted file mode 100644 index 2afc6cb5..00000000 --- a/vendor/rails/activerecord/test/fixtures/categories_ordered.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- !!omap -<% 100.times do |i| %> -- fixture_no_<%= i %>: - id: <%= i %> - name: <%= "Category #{i}" %> - type: Category -<% end %> diff --git a/vendor/rails/activerecord/test/fixtures/categories_posts.yml b/vendor/rails/activerecord/test/fixtures/categories_posts.yml deleted file mode 100644 index 9b67ab4f..00000000 --- a/vendor/rails/activerecord/test/fixtures/categories_posts.yml +++ /dev/null @@ -1,23 +0,0 @@ -general_welcome: - category_id: 1 - post_id: 1 - -technology_welcome: - category_id: 2 - post_id: 1 - -general_thinking: - category_id: 1 - post_id: 2 - -general_sti_habtm: - category_id: 1 - post_id: 6 - -sti_test_sti_habtm: - category_id: 3 - post_id: 6 - -general_hello: - category_id: 1 - post_id: 4 diff --git a/vendor/rails/activerecord/test/fixtures/categorizations.yml b/vendor/rails/activerecord/test/fixtures/categorizations.yml deleted file mode 100644 index c5b6fc9a..00000000 --- a/vendor/rails/activerecord/test/fixtures/categorizations.yml +++ /dev/null @@ -1,17 +0,0 @@ -david_welcome_general: - id: 1 - author_id: 1 - post_id: 1 - category_id: 1 - -mary_thinking_sti: - id: 2 - author_id: 2 - post_id: 2 - category_id: 3 - -mary_thinking_general: - id: 3 - author_id: 2 - post_id: 2 - category_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/clubs.yml b/vendor/rails/activerecord/test/fixtures/clubs.yml deleted file mode 100644 index 1986d282..00000000 --- a/vendor/rails/activerecord/test/fixtures/clubs.yml +++ /dev/null @@ -1,6 +0,0 @@ -boring_club: - name: Banana appreciation society -moustache_club: - name: Moustache and Eyebrow Fancier Club -crazy_club: - name: Skull and bones \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/comments.yml b/vendor/rails/activerecord/test/fixtures/comments.yml deleted file mode 100644 index 236bdb2e..00000000 --- a/vendor/rails/activerecord/test/fixtures/comments.yml +++ /dev/null @@ -1,59 +0,0 @@ -greetings: - id: 1 - post_id: 1 - body: Thank you for the welcome - type: Comment - -more_greetings: - id: 2 - post_id: 1 - body: Thank you again for the welcome - type: Comment - -does_it_hurt: - id: 3 - post_id: 2 - body: Don't think too hard - type: SpecialComment - -eager_sti_on_associations_vs_comment: - id: 5 - post_id: 4 - body: Very Special type - type: VerySpecialComment - -eager_sti_on_associations_s_comment1: - id: 6 - post_id: 4 - body: Special type - type: SpecialComment - -eager_sti_on_associations_s_comment2: - id: 7 - post_id: 4 - body: Special type 2 - type: SpecialComment - -eager_sti_on_associations_comment: - id: 8 - post_id: 4 - body: Normal type - type: Comment - -check_eager_sti_on_associations: - id: 9 - post_id: 5 - body: Normal type - type: Comment - -check_eager_sti_on_associations2: - id: 10 - post_id: 5 - body: Special Type - type: SpecialComment - -eager_other_comment1: - id: 11 - post_id: 7 - body: go crazy - type: SpecialComment diff --git a/vendor/rails/activerecord/test/fixtures/companies.yml b/vendor/rails/activerecord/test/fixtures/companies.yml deleted file mode 100644 index e7691fde..00000000 --- a/vendor/rails/activerecord/test/fixtures/companies.yml +++ /dev/null @@ -1,56 +0,0 @@ -first_client: - id: 2 - type: Client - firm_id: 1 - client_of: 2 - name: Summit - ruby_type: Client - firm_name: 37signals - -first_firm: - id: 1 - type: Firm - name: 37signals - ruby_type: Firm - -second_client: - id: 3 - type: Client - firm_id: 1 - client_of: 1 - name: Microsoft - ruby_type: Client - -another_firm: - id: 4 - type: Firm - name: Flamboyant Software - ruby_type: Firm - -another_client: - id: 5 - type: Client - firm_id: 4 - client_of: 4 - name: Ex Nihilo - ruby_type: Client - -rails_core: - id: 6 - name: RailsCore - type: DependentFirm - -leetsoft: - id: 7 - name: Leetsoft - client_of: 6 - -jadedpixel: - id: 8 - name: Jadedpixel - client_of: 6 - -odegy: - id: 9 - name: Odegy - type: ExclusivelyDependentFirm diff --git a/vendor/rails/activerecord/test/fixtures/computers.yml b/vendor/rails/activerecord/test/fixtures/computers.yml deleted file mode 100644 index daf969d7..00000000 --- a/vendor/rails/activerecord/test/fixtures/computers.yml +++ /dev/null @@ -1,4 +0,0 @@ -workstation: - id: 1 - developer: 1 - extendedWarranty: 1 diff --git a/vendor/rails/activerecord/test/fixtures/courses.yml b/vendor/rails/activerecord/test/fixtures/courses.yml deleted file mode 100644 index 5ee19160..00000000 --- a/vendor/rails/activerecord/test/fixtures/courses.yml +++ /dev/null @@ -1,7 +0,0 @@ -ruby: - id: 1 - name: Ruby Development - -java: - id: 2 - name: Java Development diff --git a/vendor/rails/activerecord/test/fixtures/customers.yml b/vendor/rails/activerecord/test/fixtures/customers.yml deleted file mode 100644 index 0399ff83..00000000 --- a/vendor/rails/activerecord/test/fixtures/customers.yml +++ /dev/null @@ -1,26 +0,0 @@ -david: - id: 1 - name: David - balance: 50 - address_street: Funny Street - address_city: Scary Town - address_country: Loony Land - gps_location: 35.544623640962634x-105.9309951055148 - -zaphod: - id: 2 - name: Zaphod - balance: 62 - address_street: Avenue Road - address_city: Hamlet Town - address_country: Nation Land - gps_location: NULL - -barney: - id: 3 - name: Barney Gumble - balance: 1 - address_street: Quiet Road - address_city: Peaceful Town - address_country: Tranquil Land - gps_location: NULL \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/developers.yml b/vendor/rails/activerecord/test/fixtures/developers.yml deleted file mode 100644 index 308bf75d..00000000 --- a/vendor/rails/activerecord/test/fixtures/developers.yml +++ /dev/null @@ -1,21 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - -jamis: - id: 2 - name: Jamis - salary: 150000 - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/developers_projects.yml b/vendor/rails/activerecord/test/fixtures/developers_projects.yml deleted file mode 100644 index 57295870..00000000 --- a/vendor/rails/activerecord/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,17 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 - -poor_jamis_active_record: - developer_id: 11 - project_id: 1 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/edges.yml b/vendor/rails/activerecord/test/fixtures/edges.yml deleted file mode 100644 index c16c70dd..00000000 --- a/vendor/rails/activerecord/test/fixtures/edges.yml +++ /dev/null @@ -1,6 +0,0 @@ -<% (1..4).each do |id| %> -edge_<%= id %>: - id: <%= id %> - source_id: <%= id %> - sink_id: <%= id + 1 %> -<% end %> \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/entrants.yml b/vendor/rails/activerecord/test/fixtures/entrants.yml deleted file mode 100644 index 86f0108e..00000000 --- a/vendor/rails/activerecord/test/fixtures/entrants.yml +++ /dev/null @@ -1,14 +0,0 @@ -first: - id: 1 - course_id: 1 - name: Ruby Developer - -second: - id: 2 - course_id: 1 - name: Ruby Guru - -third: - id: 3 - course_id: 2 - name: Java Lover diff --git a/vendor/rails/activerecord/test/fixtures/faces.yml b/vendor/rails/activerecord/test/fixtures/faces.yml deleted file mode 100644 index c8e4a344..00000000 --- a/vendor/rails/activerecord/test/fixtures/faces.yml +++ /dev/null @@ -1,11 +0,0 @@ -trusting: - description: trusting - man: gordon - -weather_beaten: - description: weather beaten - man: steve - -confused: - description: confused - polymorphic_man: gordon (Man) diff --git a/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml b/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml deleted file mode 100644 index 67d914e1..00000000 --- a/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml +++ /dev/null @@ -1,3 +0,0 @@ -first: - id: 1 - fk_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml b/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml deleted file mode 100644 index c9395218..00000000 --- a/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml +++ /dev/null @@ -1,2 +0,0 @@ -first: - id: 1 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/funny_jokes.yml b/vendor/rails/activerecord/test/fixtures/funny_jokes.yml deleted file mode 100644 index d47c4a6a..00000000 --- a/vendor/rails/activerecord/test/fixtures/funny_jokes.yml +++ /dev/null @@ -1,10 +0,0 @@ -a_joke: - id: 1 - name: Knock knock - -another_joke: - id: 2 - name: | - The \n Aristocrats - Ate the candy - diff --git a/vendor/rails/activerecord/test/fixtures/interests.yml b/vendor/rails/activerecord/test/fixtures/interests.yml deleted file mode 100644 index 9200a19d..00000000 --- a/vendor/rails/activerecord/test/fixtures/interests.yml +++ /dev/null @@ -1,33 +0,0 @@ -trainspotting: - topic: Trainspotting - zine: staying_in - man: gordon - -birdwatching: - topic: Birdwatching - zine: staying_in - man: gordon - -stamp_collecting: - topic: Stamp Collecting - zine: staying_in - man: gordon - -hunting: - topic: Hunting - zine: going_out - man: steve - -woodsmanship: - topic: Woodsmanship - zine: going_out - man: steve - -survival: - topic: Survival - zine: going_out - man: steve - -llama_wrangling: - topic: Llama Wrangling - polymorphic_man: gordon (Man) diff --git a/vendor/rails/activerecord/test/fixtures/items.yml b/vendor/rails/activerecord/test/fixtures/items.yml deleted file mode 100644 index 31fd657d..00000000 --- a/vendor/rails/activerecord/test/fixtures/items.yml +++ /dev/null @@ -1,4 +0,0 @@ -dvd: - id: 1 - name: Godfather - \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/jobs.yml b/vendor/rails/activerecord/test/fixtures/jobs.yml deleted file mode 100644 index f5775d27..00000000 --- a/vendor/rails/activerecord/test/fixtures/jobs.yml +++ /dev/null @@ -1,7 +0,0 @@ -unicyclist: - id: 1 - ideal_reference_id: 2 -clown: - id: 2 -magician: - id: 3 diff --git a/vendor/rails/activerecord/test/fixtures/legacy_things.yml b/vendor/rails/activerecord/test/fixtures/legacy_things.yml deleted file mode 100644 index a6d42aab..00000000 --- a/vendor/rails/activerecord/test/fixtures/legacy_things.yml +++ /dev/null @@ -1,3 +0,0 @@ -obtuse: - id: 1 - tps_report_number: 500 diff --git a/vendor/rails/activerecord/test/fixtures/mateys.yml b/vendor/rails/activerecord/test/fixtures/mateys.yml deleted file mode 100644 index 9ecdd4ec..00000000 --- a/vendor/rails/activerecord/test/fixtures/mateys.yml +++ /dev/null @@ -1,4 +0,0 @@ -blackbeard_to_redbeard: - pirate_id: <%= Fixtures.identify(:blackbeard) %> - target_id: <%= Fixtures.identify(:redbeard) %> - weight: 10 diff --git a/vendor/rails/activerecord/test/fixtures/member_types.yml b/vendor/rails/activerecord/test/fixtures/member_types.yml deleted file mode 100644 index 797a5743..00000000 --- a/vendor/rails/activerecord/test/fixtures/member_types.yml +++ /dev/null @@ -1,6 +0,0 @@ -founding: - id: 1 - name: Founding -provisional: - id: 2 - name: Provisional diff --git a/vendor/rails/activerecord/test/fixtures/members.yml b/vendor/rails/activerecord/test/fixtures/members.yml deleted file mode 100644 index 6db945e6..00000000 --- a/vendor/rails/activerecord/test/fixtures/members.yml +++ /dev/null @@ -1,6 +0,0 @@ -groucho: - name: Groucho Marx - member_type_id: 1 -some_other_guy: - name: Englebert Humperdink - member_type_id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/memberships.yml b/vendor/rails/activerecord/test/fixtures/memberships.yml deleted file mode 100644 index 99fbe46d..00000000 --- a/vendor/rails/activerecord/test/fixtures/memberships.yml +++ /dev/null @@ -1,20 +0,0 @@ -membership_of_boring_club: - joined_on: <%= 3.weeks.ago.to_s(:db) %> - club: boring_club - member: groucho - favourite: false - type: CurrentMembership - -membership_of_favourite_club: - joined_on: <%= 3.weeks.ago.to_s(:db) %> - club: moustache_club - member: groucho - favourite: true - type: Membership - -other_guys_membership: - joined_on: <%= 4.weeks.ago.to_s(:db) %> - club: boring_club - member: some_other_guy - favourite: false - type: CurrentMembership diff --git a/vendor/rails/activerecord/test/fixtures/men.yml b/vendor/rails/activerecord/test/fixtures/men.yml deleted file mode 100644 index c67429f9..00000000 --- a/vendor/rails/activerecord/test/fixtures/men.yml +++ /dev/null @@ -1,5 +0,0 @@ -gordon: - name: Gordon - -steve: - name: Steve diff --git a/vendor/rails/activerecord/test/fixtures/minimalistics.yml b/vendor/rails/activerecord/test/fixtures/minimalistics.yml deleted file mode 100644 index c3ec5462..00000000 --- a/vendor/rails/activerecord/test/fixtures/minimalistics.yml +++ /dev/null @@ -1,2 +0,0 @@ -first: - id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml b/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml deleted file mode 100644 index eecd448f..00000000 --- a/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml +++ /dev/null @@ -1,6 +0,0 @@ -first: - monkeyID: 1 - fleaCount: 42 -second: - monkeyID: 2 - fleaCount: 43 diff --git a/vendor/rails/activerecord/test/fixtures/mixins.yml b/vendor/rails/activerecord/test/fixtures/mixins.yml deleted file mode 100644 index 0f60e92c..00000000 --- a/vendor/rails/activerecord/test/fixtures/mixins.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Nested set mixins - -<% (1..10).each do |counter| %> -set_<%= counter %>: - id: <%= counter+3000 %> -<% end %> - -# Big old set -<% -[[4001, 0, 1, 20], - [4002, 4001, 2, 7], - [4003, 4002, 3, 4], - [4004, 4002, 5, 6], - [4005, 4001, 14, 13], - [4006, 4005, 9, 10], - [4007, 4005, 11, 12], - [4008, 4001, 8, 19], - [4009, 4008, 15, 16], - [4010, 4008, 17, 18]].each do |set| %> -tree_<%= set[0] %>: - id: <%= set[0]%> - parent_id: <%= set[1]%> - type: NestedSetWithStringScope - lft: <%= set[2]%> - rgt: <%= set[3]%> - root_id: 42 - -<% end %> - diff --git a/vendor/rails/activerecord/test/fixtures/movies.yml b/vendor/rails/activerecord/test/fixtures/movies.yml deleted file mode 100644 index 2e9154fd..00000000 --- a/vendor/rails/activerecord/test/fixtures/movies.yml +++ /dev/null @@ -1,7 +0,0 @@ -first: - movieid: 1 - name: Terminator - -second: - movieid: 2 - name: Gladiator diff --git a/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv b/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv deleted file mode 100644 index 8b137891..00000000 --- a/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv +++ /dev/null @@ -1 +0,0 @@ - diff --git a/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml b/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml deleted file mode 100644 index 8b137891..00000000 --- a/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml b/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml deleted file mode 100644 index 2c151c20..00000000 --- a/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml +++ /dev/null @@ -1 +0,0 @@ -# i wonder what will happen here diff --git a/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml b/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml deleted file mode 100644 index 19f0805d..00000000 --- a/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml +++ /dev/null @@ -1 +0,0 @@ -qwerty diff --git a/vendor/rails/activerecord/test/fixtures/organizations.yml b/vendor/rails/activerecord/test/fixtures/organizations.yml deleted file mode 100644 index 25295bff..00000000 --- a/vendor/rails/activerecord/test/fixtures/organizations.yml +++ /dev/null @@ -1,5 +0,0 @@ -nsa: - name: No Such Agency -discordians: - name: Discordians - diff --git a/vendor/rails/activerecord/test/fixtures/owners.yml b/vendor/rails/activerecord/test/fixtures/owners.yml deleted file mode 100644 index d5493a84..00000000 --- a/vendor/rails/activerecord/test/fixtures/owners.yml +++ /dev/null @@ -1,7 +0,0 @@ -blackbeard: - owner_id: 1 - name: blackbeard - -ashley: - owner_id: 2 - name: ashley diff --git a/vendor/rails/activerecord/test/fixtures/parrots.yml b/vendor/rails/activerecord/test/fixtures/parrots.yml deleted file mode 100644 index 8b73b8cd..00000000 --- a/vendor/rails/activerecord/test/fixtures/parrots.yml +++ /dev/null @@ -1,27 +0,0 @@ -george: - name: "Curious George" - treasures: diamond, sapphire - parrot_sti_class: LiveParrot - -louis: - name: "King Louis" - treasures: [diamond, sapphire] - parrot_sti_class: LiveParrot - -frederick: - name: $LABEL - parrot_sti_class: LiveParrot - -polly: - id: 4 - name: $LABEL - killer: blackbeard - treasures: sapphire, ruby - parrot_sti_class: DeadParrot - -DEFAULTS: &DEFAULTS - treasures: sapphire, ruby - parrot_sti_class: LiveParrot - -davey: - <<: *DEFAULTS diff --git a/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml b/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml deleted file mode 100644 index 6b17a37d..00000000 --- a/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml +++ /dev/null @@ -1,7 +0,0 @@ -george_blackbeard: - parrot_id: <%= Fixtures.identify(:george) %> - pirate_id: <%= Fixtures.identify(:blackbeard) %> - -louis_blackbeard: - parrot_id: <%= Fixtures.identify(:louis) %> - pirate_id: <%= Fixtures.identify(:blackbeard) %> diff --git a/vendor/rails/activerecord/test/fixtures/people.yml b/vendor/rails/activerecord/test/fixtures/people.yml deleted file mode 100644 index 3babb1fe..00000000 --- a/vendor/rails/activerecord/test/fixtures/people.yml +++ /dev/null @@ -1,15 +0,0 @@ -michael: - id: 1 - first_name: Michael - primary_contact_id: 2 - gender: M -david: - id: 2 - first_name: David - primary_contact_id: 3 - gender: M -susan: - id: 3 - first_name: Susan - primary_contact_id: 2 - gender: F \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/pets.yml b/vendor/rails/activerecord/test/fixtures/pets.yml deleted file mode 100644 index a1601a53..00000000 --- a/vendor/rails/activerecord/test/fixtures/pets.yml +++ /dev/null @@ -1,14 +0,0 @@ -parrot: - pet_id: 1 - name: parrot - owner_id: 1 - -chew: - pet_id: 2 - name: chew - owner_id: 2 - -mochi: - pet_id: 3 - name: mochi - owner_id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/pirates.yml b/vendor/rails/activerecord/test/fixtures/pirates.yml deleted file mode 100644 index abb91101..00000000 --- a/vendor/rails/activerecord/test/fixtures/pirates.yml +++ /dev/null @@ -1,9 +0,0 @@ -blackbeard: - catchphrase: "Yar." - parrot: george - -redbeard: - catchphrase: "Avast!" - parrot: louis - created_on: <%= 2.weeks.ago.to_s(:db) %> - updated_on: <%= 2.weeks.ago.to_s(:db) %> diff --git a/vendor/rails/activerecord/test/fixtures/polymorphic_designs.yml b/vendor/rails/activerecord/test/fixtures/polymorphic_designs.yml deleted file mode 100644 index ebc481f3..00000000 --- a/vendor/rails/activerecord/test/fixtures/polymorphic_designs.yml +++ /dev/null @@ -1,19 +0,0 @@ -awesome_tee_design: - id: 1 - designable_id: 1 - designable_type: Tee - -sucky_tee_design: - id: 2 - designable_id: 2 - designable_type: Tee - -awesome_hat_design: - id: 3 - designable_id: 1 - designable_type: Tie - -sucky_hat_design: - id: 4 - designable_id: 2 - designable_type: Tie \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/polymorphic_prices.yml b/vendor/rails/activerecord/test/fixtures/polymorphic_prices.yml deleted file mode 100644 index 3aca5fac..00000000 --- a/vendor/rails/activerecord/test/fixtures/polymorphic_prices.yml +++ /dev/null @@ -1,19 +0,0 @@ -awesome_tee_price: - id: 1 - sellable_id: 1 - sellable_type: Tee - -sucky_tee_price: - id: 2 - sellable_id: 2 - sellable_type: Tee - -awesome_hat_price: - id: 3 - sellable_id: 1 - sellable_type: Tie - -sucky_hat_price: - id: 4 - sellable_id: 2 - sellable_type: Tie \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/posts.yml b/vendor/rails/activerecord/test/fixtures/posts.yml deleted file mode 100644 index f8174931..00000000 --- a/vendor/rails/activerecord/test/fixtures/posts.yml +++ /dev/null @@ -1,52 +0,0 @@ -welcome: - id: 1 - author_id: 1 - title: Welcome to the weblog - body: Such a lovely day - comments_count: 2 - taggings_count: 1 - type: Post - -thinking: - id: 2 - author_id: 1 - title: So I was thinking - body: Like I hopefully always am - comments_count: 1 - taggings_count: 1 - type: SpecialPost - -authorless: - id: 3 - author_id: 0 - title: I don't have any comments - body: I just don't want to - type: Post - -sti_comments: - id: 4 - author_id: 1 - title: sti comments - body: hello - type: Post - -sti_post_and_comments: - id: 5 - author_id: 1 - title: sti me - body: hello - type: StiPost - -sti_habtm: - id: 6 - author_id: 1 - title: habtm sti test - body: hello - type: Post - -eager_other: - id: 7 - author_id: 2 - title: eager loading with OR'd conditions - body: hello - type: Post diff --git a/vendor/rails/activerecord/test/fixtures/price_estimates.yml b/vendor/rails/activerecord/test/fixtures/price_estimates.yml deleted file mode 100644 index 1149ab17..00000000 --- a/vendor/rails/activerecord/test/fixtures/price_estimates.yml +++ /dev/null @@ -1,7 +0,0 @@ -saphire_1: - price: 10 - estimate_of: sapphire (Treasure) - -sapphire_2: - price: 20 - estimate_of: sapphire (Treasure) diff --git a/vendor/rails/activerecord/test/fixtures/projects.yml b/vendor/rails/activerecord/test/fixtures/projects.yml deleted file mode 100644 index 02800c78..00000000 --- a/vendor/rails/activerecord/test/fixtures/projects.yml +++ /dev/null @@ -1,7 +0,0 @@ -action_controller: - id: 2 - name: Active Controller - -active_record: - id: 1 - name: Active Record diff --git a/vendor/rails/activerecord/test/fixtures/readers.yml b/vendor/rails/activerecord/test/fixtures/readers.yml deleted file mode 100644 index 8a607665..00000000 --- a/vendor/rails/activerecord/test/fixtures/readers.yml +++ /dev/null @@ -1,9 +0,0 @@ -michael_welcome: - id: 1 - post_id: 1 - person_id: 1 - -michael_authorless: - id: 2 - post_id: 3 - person_id: 1 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/references.yml b/vendor/rails/activerecord/test/fixtures/references.yml deleted file mode 100644 index 8e3953e9..00000000 --- a/vendor/rails/activerecord/test/fixtures/references.yml +++ /dev/null @@ -1,17 +0,0 @@ -michael_magician: - id: 1 - person_id: 1 - job_id: 3 - favourite: false - -michael_unicyclist: - id: 2 - person_id: 1 - job_id: 1 - favourite: true - -david_unicyclist: - id: 3 - person_id: 2 - job_id: 1 - favourite: false diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml deleted file mode 100644 index 0988f89c..00000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml +++ /dev/null @@ -1,5 +0,0 @@ -distinct1: - id: 1 - -distinct2: - id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml deleted file mode 100644 index 90e8c95f..00000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml +++ /dev/null @@ -1,11 +0,0 @@ -distincts_selects1: - distinct_id: 1 - select_id: 1 - -distincts_selects2: - distinct_id: 1 - select_id: 2 - -distincts_selects3: - distinct_id: 2 - select_id: 3 diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml deleted file mode 100644 index 39abea7a..00000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml +++ /dev/null @@ -1,14 +0,0 @@ -group1: - id: 1 - select_id: 1 - order: x - -group2: - id: 2 - select_id: 2 - order: y - -group3: - id: 3 - select_id: 2 - order: z diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml deleted file mode 100644 index a4c35a2b..00000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml +++ /dev/null @@ -1,8 +0,0 @@ -select1: - id: 1 - -select2: - id: 2 - -select3: - id: 3 diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml deleted file mode 100644 index 7d109609..00000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml +++ /dev/null @@ -1,7 +0,0 @@ -values1: - id: 1 - group_id: 2 - -values2: - id: 2 - group_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/ships.yml b/vendor/rails/activerecord/test/fixtures/ships.yml deleted file mode 100644 index 137055aa..00000000 --- a/vendor/rails/activerecord/test/fixtures/ships.yml +++ /dev/null @@ -1,5 +0,0 @@ -black_pearl: - name: "Black Pearl" -interceptor: - id: 2 - name: "Interceptor" diff --git a/vendor/rails/activerecord/test/fixtures/sponsors.yml b/vendor/rails/activerecord/test/fixtures/sponsors.yml deleted file mode 100644 index 42df8957..00000000 --- a/vendor/rails/activerecord/test/fixtures/sponsors.yml +++ /dev/null @@ -1,9 +0,0 @@ -moustache_club_sponsor_for_groucho: - sponsor_club: moustache_club - sponsorable: groucho (Member) -boring_club_sponsor_for_groucho: - sponsor_club: boring_club - sponsorable: some_other_guy (Member) -crazy_club_sponsor_for_groucho: - sponsor_club: crazy_club - sponsorable: some_other_guy (Member) \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/subscribers.yml b/vendor/rails/activerecord/test/fixtures/subscribers.yml deleted file mode 100644 index 9ffb4a15..00000000 --- a/vendor/rails/activerecord/test/fixtures/subscribers.yml +++ /dev/null @@ -1,7 +0,0 @@ -first: - nick: alterself - name: Luke Holden - -second: - nick: webster132 - name: David Heinemeier Hansson diff --git a/vendor/rails/activerecord/test/fixtures/subscriptions.yml b/vendor/rails/activerecord/test/fixtures/subscriptions.yml deleted file mode 100644 index 371bfd34..00000000 --- a/vendor/rails/activerecord/test/fixtures/subscriptions.yml +++ /dev/null @@ -1,12 +0,0 @@ -webster_awdr: - id: 1 - subscriber_id: webster132 - book_id: 1 -webster_rfr: - id: 2 - subscriber_id: webster132 - book_id: 2 -alterself_awdr: - id: 3 - subscriber_id: alterself - book_id: 3 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/taggings.yml b/vendor/rails/activerecord/test/fixtures/taggings.yml deleted file mode 100644 index 1e3d5965..00000000 --- a/vendor/rails/activerecord/test/fixtures/taggings.yml +++ /dev/null @@ -1,28 +0,0 @@ -welcome_general: - id: 1 - tag_id: 1 - super_tag_id: 2 - taggable_id: 1 - taggable_type: Post - -thinking_general: - id: 2 - tag_id: 1 - taggable_id: 2 - taggable_type: Post - -fake: - id: 3 - tag_id: 1 - taggable_id: 1 - taggable_type: FakeModel - -godfather: - id: 4 - tag_id: 1 - taggable_id: 1 - taggable_type: Item - -orphaned: - id: 5 - tag_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/tags.yml b/vendor/rails/activerecord/test/fixtures/tags.yml deleted file mode 100644 index 471b96f3..00000000 --- a/vendor/rails/activerecord/test/fixtures/tags.yml +++ /dev/null @@ -1,7 +0,0 @@ -general: - id: 1 - name: General - -misc: - id: 2 - name: Misc \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/tasks.yml b/vendor/rails/activerecord/test/fixtures/tasks.yml deleted file mode 100644 index 1e6a061a..00000000 --- a/vendor/rails/activerecord/test/fixtures/tasks.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -first_task: - id: 1 - starting: 2005-03-30t06:30:00.00+01:00 - ending: 2005-03-30t08:30:00.00+01:00 -another_task: - id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/tees.yml b/vendor/rails/activerecord/test/fixtures/tees.yml deleted file mode 100644 index d6df60ff..00000000 --- a/vendor/rails/activerecord/test/fixtures/tees.yml +++ /dev/null @@ -1,4 +0,0 @@ -awesome_tee: - id: 1 -sucky_tee: - id: 2 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/ties.yml b/vendor/rails/activerecord/test/fixtures/ties.yml deleted file mode 100644 index f930809c..00000000 --- a/vendor/rails/activerecord/test/fixtures/ties.yml +++ /dev/null @@ -1,4 +0,0 @@ -awesome_tie: - id: 1 -sucky_tie: - id: 2 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/topics.yml b/vendor/rails/activerecord/test/fixtures/topics.yml deleted file mode 100644 index 17691524..00000000 --- a/vendor/rails/activerecord/test/fixtures/topics.yml +++ /dev/null @@ -1,42 +0,0 @@ -first: - id: 1 - title: The First Topic - author_name: David - author_email_address: david@loudthinking.com - written_on: 2003-07-16t15:28:11.2233+01:00 - last_read: 2004-04-15 - bonus_time: 2005-01-30t15:28:00.00+01:00 - content: Have a nice day - approved: false - replies_count: 1 - -second: - id: 2 - title: The Second Topic of the day - author_name: Mary - written_on: 2004-07-15t15:28:00.0099+01:00 - content: Have a nice day - approved: true - replies_count: 0 - parent_id: 1 - type: Reply - -third: - id: 3 - title: The Third Topic of the day - author_name: Nick - written_on: 2005-07-15t15:28:00.0099+01:00 - content: I'm a troll - approved: true - replies_count: 1 - -fourth: - id: 4 - title: The Fourth Topic of the day - author_name: Carl - written_on: 2006-07-15t15:28:00.0099+01:00 - content: Why not? - approved: true - type: Reply - parent_id: 3 - diff --git a/vendor/rails/activerecord/test/fixtures/toys.yml b/vendor/rails/activerecord/test/fixtures/toys.yml deleted file mode 100644 index 037e335e..00000000 --- a/vendor/rails/activerecord/test/fixtures/toys.yml +++ /dev/null @@ -1,4 +0,0 @@ -bone: - toy_id: 1 - name: Bone - pet_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/treasures.yml b/vendor/rails/activerecord/test/fixtures/treasures.yml deleted file mode 100644 index 9db15798..00000000 --- a/vendor/rails/activerecord/test/fixtures/treasures.yml +++ /dev/null @@ -1,10 +0,0 @@ -diamond: - name: $LABEL - -sapphire: - name: $LABEL - looter: redbeard (Pirate) - -ruby: - name: $LABEL - looter: louis (Parrot) diff --git a/vendor/rails/activerecord/test/fixtures/vertices.yml b/vendor/rails/activerecord/test/fixtures/vertices.yml deleted file mode 100644 index 8af0593f..00000000 --- a/vendor/rails/activerecord/test/fixtures/vertices.yml +++ /dev/null @@ -1,4 +0,0 @@ -<% (1..5).each do |id| %> -vertex_<%= id %>: - id: <%= id %> -<% end %> \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/warehouse-things.yml b/vendor/rails/activerecord/test/fixtures/warehouse-things.yml deleted file mode 100644 index 9e07ba7d..00000000 --- a/vendor/rails/activerecord/test/fixtures/warehouse-things.yml +++ /dev/null @@ -1,3 +0,0 @@ -one: - id: 1 - value: 1000 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/zines.yml b/vendor/rails/activerecord/test/fixtures/zines.yml deleted file mode 100644 index 07dce4db..00000000 --- a/vendor/rails/activerecord/test/fixtures/zines.yml +++ /dev/null @@ -1,5 +0,0 @@ -staying_in: - title: Staying in '08 - -going_out: - title: Outdoor Pursuits 2k+8 diff --git a/vendor/rails/activerecord/test/migrations/broken/100_migration_that_raises_exception.rb b/vendor/rails/activerecord/test/migrations/broken/100_migration_that_raises_exception.rb deleted file mode 100644 index ffb224da..00000000 --- a/vendor/rails/activerecord/test/migrations/broken/100_migration_that_raises_exception.rb +++ /dev/null @@ -1,10 +0,0 @@ -class MigrationThatRaisesException < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - raise 'Something broke' - end - - def self.down - remove_column "people", "last_name" - end -end diff --git a/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb b/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb deleted file mode 100644 index 0aed7cbd..00000000 --- a/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb +++ /dev/null @@ -1,15 +0,0 @@ -class GiveMeBigNumbers < ActiveRecord::Migration - def self.up - create_table :big_numbers do |table| - table.column :bank_balance, :decimal, :precision => 10, :scale => 2 - table.column :big_bank_balance, :decimal, :precision => 15, :scale => 2 - table.column :world_population, :decimal, :precision => 10 - table.column :my_house_population, :decimal, :precision => 2 - table.column :value_of_e, :decimal - end - end - - def self.down - drop_table :big_numbers - end -end diff --git a/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb deleted file mode 100644 index 81af5fef..00000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb b/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb deleted file mode 100644 index d5e71ce8..00000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb +++ /dev/null @@ -1,12 +0,0 @@ -class WeNeedReminders < ActiveRecord::Migration - def self.up - create_table("reminders") do |t| - t.column :content, :text - t.column :remind_at, :datetime - end - end - - def self.down - drop_table "reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb b/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb deleted file mode 100644 index 916fe580..00000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Foo < ActiveRecord::Migration - def self.up - end - - def self.down - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca53..00000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb b/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb deleted file mode 100644 index 5fe5089e..00000000 --- a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Chunky < ActiveRecord::Migration - def self.up - end - - def self.down - end -end diff --git a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb b/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb deleted file mode 100644 index 5fe5089e..00000000 --- a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Chunky < ActiveRecord::Migration - def self.up - end - - def self.down - end -end diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca53..00000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb deleted file mode 100644 index 81af5fef..00000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca53..00000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb deleted file mode 100644 index 81af5fef..00000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb deleted file mode 100644 index 9b1ce9f0..00000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +++ /dev/null @@ -1,8 +0,0 @@ -class IRaiseOnDown < ActiveRecord::Migration - def self.up - end - - def self.down - raise - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca53..00000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb b/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb deleted file mode 100644 index 9fd495b9..00000000 --- a/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveMiddleNames < ActiveRecord::Migration - def self.up - add_column "people", "middle_name", :string - end - - def self.down - remove_column "people", "middle_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb deleted file mode 100644 index 81af5fef..00000000 --- a/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb b/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb deleted file mode 100644 index d5e71ce8..00000000 --- a/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb +++ /dev/null @@ -1,12 +0,0 @@ -class WeNeedReminders < ActiveRecord::Migration - def self.up - create_table("reminders") do |t| - t.column :content, :text - t.column :remind_at, :datetime - end - end - - def self.down - drop_table "reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb deleted file mode 100644 index 21c9ca53..00000000 --- a/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb deleted file mode 100644 index 81af5fef..00000000 --- a/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb b/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb deleted file mode 100644 index d5e71ce8..00000000 --- a/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb +++ /dev/null @@ -1,12 +0,0 @@ -class WeNeedReminders < ActiveRecord::Migration - def self.up - create_table("reminders") do |t| - t.column :content, :text - t.column :remind_at, :datetime - end - end - - def self.down - drop_table "reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca53..00000000 --- a/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/author.rb b/vendor/rails/activerecord/test/models/author.rb deleted file mode 100644 index fbbdaea3..00000000 --- a/vendor/rails/activerecord/test/models/author.rb +++ /dev/null @@ -1,151 +0,0 @@ -class Author < ActiveRecord::Base - has_many :posts - has_many :very_special_comments, :through => :posts - has_many :posts_with_comments, :include => :comments, :class_name => "Post" - has_many :popular_grouped_posts, :include => :comments, :class_name => "Post", :group => "type", :having => "SUM(comments_count) > 1", :select => "type" - has_many :posts_with_comments_sorted_by_comment_id, :include => :comments, :class_name => "Post", :order => 'comments.id' - has_many :posts_sorted_by_id_limited, :class_name => "Post", :order => 'posts.id', :limit => 1 - has_many :posts_with_categories, :include => :categories, :class_name => "Post" - has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post" - has_many :posts_containing_the_letter_a, :class_name => "Post" - has_many :posts_with_extension, :class_name => "Post" do #, :extend => ProxyTestExtension - def testing_proxy_owner - proxy_owner - end - def testing_proxy_reflection - proxy_reflection - end - def testing_proxy_target - proxy_target - end - end - has_one :post_about_thinking, :class_name => 'Post', :conditions => "posts.title like '%thinking%'" - has_one :post_about_thinking_with_last_comment, :class_name => 'Post', :conditions => "posts.title like '%thinking%'", :include => :last_comment - has_many :comments, :through => :posts - has_many :comments_containing_the_letter_e, :through => :posts, :source => :comments - has_many :comments_with_order_and_conditions, :through => :posts, :source => :comments, :order => 'comments.body', :conditions => "comments.body like 'Thank%'" - has_many :comments_with_include, :through => :posts, :source => :comments, :include => :post - - has_many :thinking_posts, :class_name => 'Post', :conditions => { :title => 'So I was thinking' }, :dependent => :delete_all - has_many :welcome_posts, :class_name => 'Post', :conditions => { :title => 'Welcome to the weblog' } - - has_many :comments_desc, :through => :posts, :source => :comments, :order => 'comments.id DESC' - has_many :limited_comments, :through => :posts, :source => :comments, :limit => 1 - has_many :funky_comments, :through => :posts, :source => :comments - has_many :ordered_uniq_comments, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id' - has_many :ordered_uniq_comments_desc, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id DESC' - has_many :readonly_comments, :through => :posts, :source => :comments, :readonly => true - - has_many :special_posts - has_many :special_post_comments, :through => :special_posts, :source => :comments - - has_many :sti_posts, :class_name => 'StiPost' - has_many :sti_post_comments, :through => :sti_posts, :source => :comments - - has_many :special_nonexistant_posts, :class_name => "SpecialPost", :conditions => "posts.body = 'nonexistant'" - has_many :special_nonexistant_post_comments, :through => :special_nonexistant_posts, :source => :comments, :conditions => "comments.post_id = 0" - has_many :nonexistant_comments, :through => :posts - - has_many :hello_posts, :class_name => "Post", :conditions => "posts.body = 'hello'" - has_many :hello_post_comments, :through => :hello_posts, :source => :comments - has_many :posts_with_no_comments, :class_name => 'Post', :conditions => 'comments.id is null', :include => :comments - - has_many :hello_posts_with_hash_conditions, :class_name => "Post", -:conditions => {:body => 'hello'} - has_many :hello_post_comments_with_hash_conditions, :through => -:hello_posts_with_hash_conditions, :source => :comments - - has_many :other_posts, :class_name => "Post" - has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding, - :after_add => :log_after_adding, - :before_remove => :log_before_removing, - :after_remove => :log_after_removing - has_many :posts_with_proc_callbacks, :class_name => "Post", - :before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id || '<new>'}"}, - :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id || '<new>'}"}, - :before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"}, - :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"} - has_many :posts_with_multiple_callbacks, :class_name => "Post", - :before_add => [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id || '<new>'}"}], - :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id || '<new>'}"}] - has_many :unchangable_posts, :class_name => "Post", :before_add => :raise_exception, :after_add => :log_after_adding - - has_many :categorizations - has_many :categories, :through => :categorizations - - has_many :categories_like_general, :through => :categorizations, :source => :category, :class_name => 'Category', :conditions => { :name => 'General' } - - has_many :categorized_posts, :through => :categorizations, :source => :post - has_many :unique_categorized_posts, :through => :categorizations, :source => :post, :uniq => true - - has_many :nothings, :through => :kateggorisatons, :class_name => 'Category' - - has_many :author_favorites - has_many :favorite_authors, :through => :author_favorites, :order => 'name' - - has_many :tagging, :through => :posts # through polymorphic has_one - has_many :taggings, :through => :posts, :source => :taggings # through polymorphic has_many - has_many :tags, :through => :posts # through has_many :through - has_many :post_categories, :through => :posts, :source => :categories - - has_many :event_authors - has_many :events, :through => :event_authors - - has_one :essay, :primary_key => :name, :as => :writer - - belongs_to :author_address, :dependent => :destroy - belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress" - - attr_accessor :post_log - - def after_initialize - @post_log = [] - end - - def label - "#{id}-#{name}" - end - - validates_presence_of :name - - private - def log_before_adding(object) - @post_log << "before_adding#{object.id || '<new>'}" - end - - def log_after_adding(object) - @post_log << "after_adding#{object.id}" - end - - def log_before_removing(object) - @post_log << "before_removing#{object.id}" - end - - def log_after_removing(object) - @post_log << "after_removing#{object.id}" - end - - def raise_exception(object) - raise Exception.new("You can't add a post") - end -end - -class AuthorAddress < ActiveRecord::Base - has_one :author - - def self.destroyed_author_address_ids - @destroyed_author_address_ids ||= Hash.new { |h,k| h[k] = [] } - end - - before_destroy do |author_address| - if author_address.author - AuthorAddress.destroyed_author_address_ids[author_address.author.id] << author_address.id - end - true - end -end - -class AuthorFavorite < ActiveRecord::Base - belongs_to :author - belongs_to :favorite_author, :class_name => "Author" -end diff --git a/vendor/rails/activerecord/test/models/auto_id.rb b/vendor/rails/activerecord/test/models/auto_id.rb deleted file mode 100644 index d720e2be..00000000 --- a/vendor/rails/activerecord/test/models/auto_id.rb +++ /dev/null @@ -1,4 +0,0 @@ -class AutoId < ActiveRecord::Base - def self.table_name () "auto_id_tests" end - def self.primary_key () "auto_id" end -end diff --git a/vendor/rails/activerecord/test/models/binary.rb b/vendor/rails/activerecord/test/models/binary.rb deleted file mode 100644 index 950c4591..00000000 --- a/vendor/rails/activerecord/test/models/binary.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Binary < ActiveRecord::Base -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/bird.rb b/vendor/rails/activerecord/test/models/bird.rb deleted file mode 100644 index e61d48e6..00000000 --- a/vendor/rails/activerecord/test/models/bird.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Bird < ActiveRecord::Base - validates_presence_of :name - - attr_accessor :cancel_save_from_callback - before_save :cancel_save_callback_method, :if => :cancel_save_from_callback - def cancel_save_callback_method - false - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/book.rb b/vendor/rails/activerecord/test/models/book.rb deleted file mode 100644 index cfd07abd..00000000 --- a/vendor/rails/activerecord/test/models/book.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Book < ActiveRecord::Base - has_many :citations, :foreign_key => 'book1_id' - has_many :references, :through => :citations, :source => :reference_of, :uniq => true -end diff --git a/vendor/rails/activerecord/test/models/categorization.rb b/vendor/rails/activerecord/test/models/categorization.rb deleted file mode 100644 index 10594323..00000000 --- a/vendor/rails/activerecord/test/models/categorization.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Categorization < ActiveRecord::Base - belongs_to :post - belongs_to :category - belongs_to :author -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/category.rb b/vendor/rails/activerecord/test/models/category.rb deleted file mode 100644 index 5efce6aa..00000000 --- a/vendor/rails/activerecord/test/models/category.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Category < ActiveRecord::Base - has_and_belongs_to_many :posts - has_and_belongs_to_many :special_posts, :class_name => "Post" - has_and_belongs_to_many :other_posts, :class_name => "Post" - has_and_belongs_to_many :posts_with_authors_sorted_by_author_id, :class_name => "Post", :include => :authors, :order => "authors.id" - - has_and_belongs_to_many(:select_testing_posts, - :class_name => 'Post', - :foreign_key => 'category_id', - :association_foreign_key => 'post_id', - :select => 'posts.*, 1 as correctness_marker') - - has_and_belongs_to_many :post_with_conditions, - :class_name => 'Post', - :conditions => { :title => 'Yet Another Testing Title' } - - has_and_belongs_to_many :popular_grouped_posts, :class_name => "Post", :group => "posts.type", :having => "sum(comments.post_id) > 2", :include => :comments - has_and_belongs_to_many :posts_gruoped_by_title, :class_name => "Post", :group => "title", :select => "title" - - def self.what_are_you - 'a category...' - end - - has_many :categorizations - has_many :authors, :through => :categorizations, :select => 'authors.*, categorizations.post_id' -end - -class SpecialCategory < Category - - def self.what_are_you - 'a special category...' - end - -end diff --git a/vendor/rails/activerecord/test/models/citation.rb b/vendor/rails/activerecord/test/models/citation.rb deleted file mode 100644 index 545aa811..00000000 --- a/vendor/rails/activerecord/test/models/citation.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Citation < ActiveRecord::Base - belongs_to :reference_of, :class_name => "Book", :foreign_key => :book2_id - - belongs_to :book1, :class_name => "Book", :foreign_key => :book1_id - belongs_to :book2, :class_name => "Book", :foreign_key => :book2_id -end diff --git a/vendor/rails/activerecord/test/models/club.rb b/vendor/rails/activerecord/test/models/club.rb deleted file mode 100644 index 6e7cdd64..00000000 --- a/vendor/rails/activerecord/test/models/club.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Club < ActiveRecord::Base - has_many :memberships - has_many :members, :through => :memberships - has_many :current_memberships - has_one :sponsor - has_one :sponsored_member, :through => :sponsor, :source => :sponsorable, :source_type => "Member" - - private - - def private_method - "I'm sorry sir, this is a *private* club, not a *pirate* club" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/column_name.rb b/vendor/rails/activerecord/test/models/column_name.rb deleted file mode 100644 index ec07205a..00000000 --- a/vendor/rails/activerecord/test/models/column_name.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ColumnName < ActiveRecord::Base - def self.table_name () "colnametests" end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/comment.rb b/vendor/rails/activerecord/test/models/comment.rb deleted file mode 100644 index 399dea9f..00000000 --- a/vendor/rails/activerecord/test/models/comment.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Comment < ActiveRecord::Base - named_scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'" - named_scope :for_first_post, :conditions => { :post_id => 1 } - named_scope :for_first_author, - :joins => :post, - :conditions => { "posts.author_id" => 1 } - - belongs_to :post, :counter_cache => true - - def self.what_are_you - 'a comment...' - end - - def self.search_by_type(q) - self.find(:all, :conditions => ["#{QUOTED_TYPE} = ?", q]) - end -end - -class SpecialComment < Comment - def self.what_are_you - 'a special comment...' - end -end - -class VerySpecialComment < Comment - def self.what_are_you - 'a very special comment...' - end -end diff --git a/vendor/rails/activerecord/test/models/company.rb b/vendor/rails/activerecord/test/models/company.rb deleted file mode 100644 index ced2faab..00000000 --- a/vendor/rails/activerecord/test/models/company.rb +++ /dev/null @@ -1,173 +0,0 @@ -class AbstractCompany < ActiveRecord::Base - self.abstract_class = true -end - -class Company < AbstractCompany - attr_protected :rating - set_sequence_name :companies_nonstd_seq - - validates_presence_of :name - - has_one :dummy_account, :foreign_key => "firm_id", :class_name => "Account" - has_many :contracts - has_many :developers, :through => :contracts - - named_scope :with_oft_in_name, :conditions => "name LIKE '%oft%'" - - def arbitrary_method - "I am Jack's profound disappointment" - end - - private - - def private_method - "I am Jack's innermost fears and aspirations" - end -end - -module Namespaced - class Company < ::Company - end - - class Firm < ::Company - has_many :clients, :class_name => 'Namespaced::Client' - end - - class Client < ::Company - end -end - -class Firm < Company - has_many :clients, :order => "id", :dependent => :destroy, :counter_sql => - "SELECT COUNT(*) FROM companies WHERE firm_id = 1 " + - "AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )" - has_many :unsorted_clients, :class_name => "Client" - has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC" - has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id" - has_many :unvalidated_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :validate => false - has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :destroy - has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all - has_many :limited_clients, :class_name => "Client", :order => "id", :limit => 1 - has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id" - has_many :clients_with_interpolated_conditions, :class_name => "Client", :conditions => 'rating > #{rating}' - has_many :clients_like_ms_with_hash_conditions, :conditions => { :name => 'Microsoft' }, :class_name => "Client", :order => "id" - has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}' - has_many :clients_using_counter_sql, :class_name => "Client", - :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}', - :counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = #{id}' - has_many :clients_using_zero_counter_sql, :class_name => "Client", - :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}', - :counter_sql => 'SELECT 0 FROM companies WHERE client_of = #{id}' - has_many :no_clients_using_counter_sql, :class_name => "Client", - :finder_sql => 'SELECT * FROM companies WHERE client_of = 1000', - :counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000' - has_many :clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=1' - has_many :plain_clients, :class_name => 'Client' - has_many :readonly_clients, :class_name => 'Client', :readonly => true - has_many :clients_using_primary_key, :class_name => 'Client', - :primary_key => 'name', :foreign_key => 'firm_name' - has_many :clients_using_primary_key_with_delete_all, :class_name => 'Client', - :primary_key => 'name', :foreign_key => 'firm_name', :dependent => :delete_all - has_many :clients_grouped_by_firm_id, :class_name => "Client", :group => "firm_id", :select => "firm_id" - has_many :clients_grouped_by_name, :class_name => "Client", :group => "name", :select => "name" - - has_one :account, :foreign_key => "firm_id", :dependent => :destroy, :validate => true - has_one :unvalidated_account, :foreign_key => "firm_id", :class_name => 'Account', :validate => false - has_one :account_with_select, :foreign_key => "firm_id", :select => "id, firm_id", :class_name=>'Account' - has_one :readonly_account, :foreign_key => "firm_id", :class_name => "Account", :readonly => true - has_one :account_using_primary_key, :primary_key => "firm_id", :class_name => "Account" - has_one :account_using_foreign_and_primary_keys, :foreign_key => "firm_name", :primary_key => "name", :class_name => "Account" - has_one :deletable_account, :foreign_key => "firm_id", :class_name => "Account", :dependent => :delete - - has_one :account_limit_500_with_hash_conditions, :foreign_key => "firm_id", :class_name => "Account", :conditions => { :credit_limit => 500 } - - has_one :unautosaved_account, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false - has_many :accounts - has_many :unautosaved_accounts, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false -end - -class DependentFirm < Company - has_one :account, :foreign_key => "firm_id", :dependent => :nullify - has_many :companies, :foreign_key => 'client_of', :order => "id", :dependent => :nullify -end - -class Client < Company - belongs_to :firm, :foreign_key => "client_of" - belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id" - belongs_to :firm_with_select, :class_name => "Firm", :foreign_key => "firm_id", :select => "id" - belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of" - belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => ["1 = ?", 1] - belongs_to :firm_with_primary_key, :class_name => "Firm", :primary_key => "name", :foreign_key => "firm_name" - belongs_to :readonly_firm, :class_name => "Firm", :foreign_key => "firm_id", :readonly => true - - # Record destruction so we can test whether firm.clients.clear has - # is calling client.destroy, deleting from the database, or setting - # foreign keys to NULL. - def self.destroyed_client_ids - @destroyed_client_ids ||= Hash.new { |h,k| h[k] = [] } - end - - before_destroy do |client| - if client.firm - Client.destroyed_client_ids[client.firm.id] << client.id - end - true - end - - # Used to test that read and question methods are not generated for these attributes - def ruby_type - read_attribute :ruby_type - end - - def rating? - query_attribute :rating - end - - class << self - private - - def private_method - "darkness" - end - end -end - -class ExclusivelyDependentFirm < Company - has_one :account, :foreign_key => "firm_id", :dependent => :delete - has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => "name = 'BigShot Inc.'" - has_many :dependent_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => ["name = ?", 'BigShot Inc.'] - has_many :dependent_hash_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => {:name => 'BigShot Inc.'} -end - -class SpecialClient < Client -end - -class VerySpecialClient < SpecialClient -end - -class Account < ActiveRecord::Base - belongs_to :firm - belongs_to :unautosaved_firm, :foreign_key => "firm_id", :class_name => "Firm", :autosave => false - - def self.destroyed_account_ids - @destroyed_account_ids ||= Hash.new { |h,k| h[k] = [] } - end - - before_destroy do |account| - if account.firm - Account.destroyed_account_ids[account.firm.id] << account.id - end - true - end - - protected - def validate - errors.add_on_empty "credit_limit" - end - - private - - def private_method - "Sir, yes sir!" - end -end diff --git a/vendor/rails/activerecord/test/models/company_in_module.rb b/vendor/rails/activerecord/test/models/company_in_module.rb deleted file mode 100644 index 8cee5831..00000000 --- a/vendor/rails/activerecord/test/models/company_in_module.rb +++ /dev/null @@ -1,78 +0,0 @@ -module MyApplication - module Business - class Company < ActiveRecord::Base - attr_protected :rating - end - - class Firm < Company - has_many :clients, :order => "id", :dependent => :destroy - has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC" - has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id" - has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id" - has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}' - - has_one :account, :class_name => 'MyApplication::Billing::Account', :dependent => :destroy - end - - class Client < Company - belongs_to :firm, :foreign_key => "client_of" - belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of" - - class Contact < ActiveRecord::Base; end - end - - class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects - validates_length_of :name, :within => (3..20) - end - - class Project < ActiveRecord::Base - has_and_belongs_to_many :developers - end - - module Prefixed - def self.table_name_prefix - 'prefixed_' - end - - class Company < ActiveRecord::Base - end - - class Firm < Company - self.table_name = 'companies' - end - - module Nested - class Company < ActiveRecord::Base - end - end - end - end - - module Billing - class Firm < ActiveRecord::Base - self.table_name = 'companies' - end - - module Nested - class Firm < ActiveRecord::Base - self.table_name = 'companies' - end - end - - class Account < ActiveRecord::Base - with_options(:foreign_key => :firm_id) do |i| - i.belongs_to :firm, :class_name => 'MyApplication::Business::Firm' - i.belongs_to :qualified_billing_firm, :class_name => 'MyApplication::Billing::Firm' - i.belongs_to :unqualified_billing_firm, :class_name => 'Firm' - i.belongs_to :nested_qualified_billing_firm, :class_name => 'MyApplication::Billing::Nested::Firm' - i.belongs_to :nested_unqualified_billing_firm, :class_name => 'Nested::Firm' - end - - protected - def validate - errors.add_on_empty "credit_limit" - end - end - end -end diff --git a/vendor/rails/activerecord/test/models/computer.rb b/vendor/rails/activerecord/test/models/computer.rb deleted file mode 100644 index cc8deb1b..00000000 --- a/vendor/rails/activerecord/test/models/computer.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Computer < ActiveRecord::Base - belongs_to :developer, :foreign_key=>'developer' -end diff --git a/vendor/rails/activerecord/test/models/contact.rb b/vendor/rails/activerecord/test/models/contact.rb deleted file mode 100644 index dbfa57bf..00000000 --- a/vendor/rails/activerecord/test/models/contact.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Contact < ActiveRecord::Base - # mock out self.columns so no pesky db is needed for these tests - def self.column(name, sql_type = nil, options = {}) - @columns ||= [] - @columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, options[:default], sql_type.to_s, options[:null]) - end - - column :name, :string - column :age, :integer - column :avatar, :binary - column :created_at, :datetime - column :awesome, :boolean - column :preferences, :string - - serialize :preferences -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/contract.rb b/vendor/rails/activerecord/test/models/contract.rb deleted file mode 100644 index 5235bfa3..00000000 --- a/vendor/rails/activerecord/test/models/contract.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Contract < ActiveRecord::Base - belongs_to :company - belongs_to :developer -end - diff --git a/vendor/rails/activerecord/test/models/course.rb b/vendor/rails/activerecord/test/models/course.rb deleted file mode 100644 index 8a40fa74..00000000 --- a/vendor/rails/activerecord/test/models/course.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Course < ActiveRecord::Base - has_many :entrants -end diff --git a/vendor/rails/activerecord/test/models/customer.rb b/vendor/rails/activerecord/test/models/customer.rb deleted file mode 100644 index e258ccdb..00000000 --- a/vendor/rails/activerecord/test/models/customer.rb +++ /dev/null @@ -1,73 +0,0 @@ -class Customer < ActiveRecord::Base - composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ], :allow_nil => true - composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money } - composed_of :gps_location, :allow_nil => true - composed_of :fullname, :mapping => %w(name to_s), :constructor => Proc.new { |name| Fullname.parse(name) }, :converter => :parse -end - -class Address - attr_reader :street, :city, :country - - def initialize(street, city, country) - @street, @city, @country = street, city, country - end - - def close_to?(other_address) - city == other_address.city && country == other_address.country - end - - def ==(other) - other.is_a?(self.class) && other.street == street && other.city == city && other.country == country - end -end - -class Money - attr_reader :amount, :currency - - EXCHANGE_RATES = { "USD_TO_DKK" => 6, "DKK_TO_USD" => 0.6 } - - def initialize(amount, currency = "USD") - @amount, @currency = amount, currency - end - - def exchange_to(other_currency) - Money.new((amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor, other_currency) - end -end - -class GpsLocation - attr_reader :gps_location - - def initialize(gps_location) - @gps_location = gps_location - end - - def latitude - gps_location.split("x").first - end - - def longitude - gps_location.split("x").last - end - - def ==(other) - self.latitude == other.latitude && self.longitude == other.longitude - end -end - -class Fullname - attr_reader :first, :last - - def self.parse(str) - return nil unless str - new(*str.to_s.split) - end - - def initialize(first, last = nil) - @first, @last = first, last - end - - def to_s - "#{first} #{last.upcase}" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/default.rb b/vendor/rails/activerecord/test/models/default.rb deleted file mode 100644 index 887e9cc9..00000000 --- a/vendor/rails/activerecord/test/models/default.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Default < ActiveRecord::Base -end diff --git a/vendor/rails/activerecord/test/models/developer.rb b/vendor/rails/activerecord/test/models/developer.rb deleted file mode 100644 index 05897033..00000000 --- a/vendor/rails/activerecord/test/models/developer.rb +++ /dev/null @@ -1,101 +0,0 @@ -module DeveloperProjectsAssociationExtension - def find_most_recent - find(:first, :order => "id DESC") - end -end - -module DeveloperProjectsAssociationExtension2 - def find_least_recent - find(:first, :order => "id ASC") - end -end - -class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects do - def find_most_recent - find(:first, :order => "id DESC") - end - end - - has_and_belongs_to_many :projects_extended_by_name, - :class_name => "Project", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :extend => DeveloperProjectsAssociationExtension - - has_and_belongs_to_many :projects_extended_by_name_twice, - :class_name => "Project", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :extend => [DeveloperProjectsAssociationExtension, DeveloperProjectsAssociationExtension2] - - has_and_belongs_to_many :projects_extended_by_name_and_block, - :class_name => "Project", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :extend => DeveloperProjectsAssociationExtension do - def find_least_recent - find(:first, :order => "id ASC") - end - end - - has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id' - - has_many :audit_logs - - named_scope :jamises, :conditions => {:name => 'Jamis'} - - validates_inclusion_of :salary, :in => 50000..200000 - validates_length_of :name, :within => 3..20 - - before_create do |developer| - developer.audit_logs.build :message => "Computer created" - end - - def log=(message) - audit_logs.build :message => message - end -end - -class AuditLog < ActiveRecord::Base - belongs_to :developer, :validate => true - belongs_to :unvalidated_developer, :class_name => 'Developer' -end - -DeveloperSalary = Struct.new(:amount) -class DeveloperWithAggregate < ActiveRecord::Base - self.table_name = 'developers' - composed_of :salary, :class_name => 'DeveloperSalary', :mapping => [%w(salary amount)] -end - -class DeveloperWithBeforeDestroyRaise < ActiveRecord::Base - self.table_name = 'developers' - has_and_belongs_to_many :projects, :join_table => 'developers_projects', :foreign_key => 'developer_id' - before_destroy :raise_if_projects_empty! - - def raise_if_projects_empty! - raise if projects.empty? - end -end - -class DeveloperOrderedBySalary < ActiveRecord::Base - self.table_name = 'developers' - default_scope :order => 'salary DESC' - named_scope :by_name, :order => 'name DESC' - - def self.all_ordered_by_name - with_scope(:find => { :order => 'name DESC' }) do - find(:all) - end - end -end - -class DeveloperCalledDavid < ActiveRecord::Base - self.table_name = 'developers' - default_scope :conditions => "name = 'David'" -end - -class DeveloperCalledJamis < ActiveRecord::Base - self.table_name = 'developers' - default_scope :conditions => { :name => 'Jamis' } -end diff --git a/vendor/rails/activerecord/test/models/edge.rb b/vendor/rails/activerecord/test/models/edge.rb deleted file mode 100644 index 55e0c31f..00000000 --- a/vendor/rails/activerecord/test/models/edge.rb +++ /dev/null @@ -1,5 +0,0 @@ -# This class models an edge in a directed graph. -class Edge < ActiveRecord::Base - belongs_to :source, :class_name => 'Vertex', :foreign_key => 'source_id' - belongs_to :sink, :class_name => 'Vertex', :foreign_key => 'sink_id' -end diff --git a/vendor/rails/activerecord/test/models/entrant.rb b/vendor/rails/activerecord/test/models/entrant.rb deleted file mode 100644 index 4682ce48..00000000 --- a/vendor/rails/activerecord/test/models/entrant.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Entrant < ActiveRecord::Base - belongs_to :course -end diff --git a/vendor/rails/activerecord/test/models/essay.rb b/vendor/rails/activerecord/test/models/essay.rb deleted file mode 100644 index 6c28f5e4..00000000 --- a/vendor/rails/activerecord/test/models/essay.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Essay < ActiveRecord::Base - belongs_to :writer, :primary_key => :name, :polymorphic => true -end diff --git a/vendor/rails/activerecord/test/models/event.rb b/vendor/rails/activerecord/test/models/event.rb deleted file mode 100644 index 99fa0fee..00000000 --- a/vendor/rails/activerecord/test/models/event.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Event < ActiveRecord::Base - validates_uniqueness_of :title -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/event_author.rb b/vendor/rails/activerecord/test/models/event_author.rb deleted file mode 100644 index 560f0f9d..00000000 --- a/vendor/rails/activerecord/test/models/event_author.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'models/author' -require 'models/event' - -class EventAuthor < ActiveRecord::Base - belongs_to :author - belongs_to :event -end - diff --git a/vendor/rails/activerecord/test/models/face.rb b/vendor/rails/activerecord/test/models/face.rb deleted file mode 100644 index edb75d33..00000000 --- a/vendor/rails/activerecord/test/models/face.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Face < ActiveRecord::Base - belongs_to :man, :inverse_of => :face - belongs_to :polymorphic_man, :polymorphic => true, :inverse_of => :polymorphic_face - # These is a "broken" inverse_of for the purposes of testing - belongs_to :horrible_man, :class_name => 'Man', :inverse_of => :horrible_face - belongs_to :horrible_polymorphic_man, :polymorphic => true, :inverse_of => :horrible_polymorphic_face -end diff --git a/vendor/rails/activerecord/test/models/guid.rb b/vendor/rails/activerecord/test/models/guid.rb deleted file mode 100644 index 9208dc28..00000000 --- a/vendor/rails/activerecord/test/models/guid.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Guid < ActiveRecord::Base -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/interest.rb b/vendor/rails/activerecord/test/models/interest.rb deleted file mode 100644 index d5d92262..00000000 --- a/vendor/rails/activerecord/test/models/interest.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Interest < ActiveRecord::Base - belongs_to :man, :inverse_of => :interests - belongs_to :polymorphic_man, :polymorphic => true, :inverse_of => :polymorphic_interests - belongs_to :zine, :inverse_of => :interests -end diff --git a/vendor/rails/activerecord/test/models/invoice.rb b/vendor/rails/activerecord/test/models/invoice.rb deleted file mode 100644 index fc6ef023..00000000 --- a/vendor/rails/activerecord/test/models/invoice.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Invoice < ActiveRecord::Base - has_many :line_items, :autosave => true - before_save {|record| record.balance = record.line_items.map(&:amount).sum } -end diff --git a/vendor/rails/activerecord/test/models/item.rb b/vendor/rails/activerecord/test/models/item.rb deleted file mode 100644 index c2571dd7..00000000 --- a/vendor/rails/activerecord/test/models/item.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AbstractItem < ActiveRecord::Base - self.abstract_class = true - has_one :tagging, :as => :taggable -end - -class Item < AbstractItem -end diff --git a/vendor/rails/activerecord/test/models/job.rb b/vendor/rails/activerecord/test/models/job.rb deleted file mode 100644 index 3333a02e..00000000 --- a/vendor/rails/activerecord/test/models/job.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Job < ActiveRecord::Base - has_many :references - has_many :people, :through => :references - belongs_to :ideal_reference, :class_name => 'Reference' -end diff --git a/vendor/rails/activerecord/test/models/joke.rb b/vendor/rails/activerecord/test/models/joke.rb deleted file mode 100644 index 3978abc2..00000000 --- a/vendor/rails/activerecord/test/models/joke.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Joke < ActiveRecord::Base - set_table_name 'funny_jokes' -end diff --git a/vendor/rails/activerecord/test/models/keyboard.rb b/vendor/rails/activerecord/test/models/keyboard.rb deleted file mode 100644 index 32a4a7fa..00000000 --- a/vendor/rails/activerecord/test/models/keyboard.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Keyboard < ActiveRecord::Base - set_primary_key 'key_number' -end diff --git a/vendor/rails/activerecord/test/models/legacy_thing.rb b/vendor/rails/activerecord/test/models/legacy_thing.rb deleted file mode 100644 index eaeb642d..00000000 --- a/vendor/rails/activerecord/test/models/legacy_thing.rb +++ /dev/null @@ -1,3 +0,0 @@ -class LegacyThing < ActiveRecord::Base - set_locking_column :version -end diff --git a/vendor/rails/activerecord/test/models/line_item.rb b/vendor/rails/activerecord/test/models/line_item.rb deleted file mode 100644 index 0dd921a3..00000000 --- a/vendor/rails/activerecord/test/models/line_item.rb +++ /dev/null @@ -1,3 +0,0 @@ -class LineItem < ActiveRecord::Base - belongs_to :invoice, :touch => true -end diff --git a/vendor/rails/activerecord/test/models/man.rb b/vendor/rails/activerecord/test/models/man.rb deleted file mode 100644 index 4bff92dc..00000000 --- a/vendor/rails/activerecord/test/models/man.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Man < ActiveRecord::Base - has_one :face, :inverse_of => :man - has_one :polymorphic_face, :class_name => 'Face', :as => :polymorphic_man, :inverse_of => :polymorphic_man - has_many :interests, :inverse_of => :man - has_many :polymorphic_interests, :class_name => 'Interest', :as => :polymorphic_man, :inverse_of => :polymorphic_man - # These are "broken" inverse_of associations for the purposes of testing - has_one :dirty_face, :class_name => 'Face', :inverse_of => :dirty_man - has_many :secret_interests, :class_name => 'Interest', :inverse_of => :secret_man -end diff --git a/vendor/rails/activerecord/test/models/matey.rb b/vendor/rails/activerecord/test/models/matey.rb deleted file mode 100644 index 47b0baa9..00000000 --- a/vendor/rails/activerecord/test/models/matey.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Matey < ActiveRecord::Base - belongs_to :pirate - belongs_to :target, :class_name => 'Pirate' -end diff --git a/vendor/rails/activerecord/test/models/member.rb b/vendor/rails/activerecord/test/models/member.rb deleted file mode 100644 index 255fb569..00000000 --- a/vendor/rails/activerecord/test/models/member.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Member < ActiveRecord::Base - has_one :current_membership - has_many :memberships - has_many :fellow_members, :through => :club, :source => :members - has_one :club, :through => :current_membership - has_one :favourite_club, :through => :memberships, :conditions => ["memberships.favourite = ?", true], :source => :club - has_one :sponsor, :as => :sponsorable - has_one :sponsor_club, :through => :sponsor - has_one :member_detail - has_one :organization, :through => :member_detail - belongs_to :member_type -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/member_detail.rb b/vendor/rails/activerecord/test/models/member_detail.rb deleted file mode 100644 index 94f59e57..00000000 --- a/vendor/rails/activerecord/test/models/member_detail.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MemberDetail < ActiveRecord::Base - belongs_to :member - belongs_to :organization - has_one :member_type, :through => :member -end diff --git a/vendor/rails/activerecord/test/models/member_type.rb b/vendor/rails/activerecord/test/models/member_type.rb deleted file mode 100644 index a13561c7..00000000 --- a/vendor/rails/activerecord/test/models/member_type.rb +++ /dev/null @@ -1,3 +0,0 @@ -class MemberType < ActiveRecord::Base - has_many :members -end diff --git a/vendor/rails/activerecord/test/models/membership.rb b/vendor/rails/activerecord/test/models/membership.rb deleted file mode 100644 index 905f948c..00000000 --- a/vendor/rails/activerecord/test/models/membership.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Membership < ActiveRecord::Base - belongs_to :member - belongs_to :club -end - -class CurrentMembership < Membership - belongs_to :member - belongs_to :club -end diff --git a/vendor/rails/activerecord/test/models/minimalistic.rb b/vendor/rails/activerecord/test/models/minimalistic.rb deleted file mode 100644 index 2e3f8e08..00000000 --- a/vendor/rails/activerecord/test/models/minimalistic.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Minimalistic < ActiveRecord::Base -end diff --git a/vendor/rails/activerecord/test/models/mixed_case_monkey.rb b/vendor/rails/activerecord/test/models/mixed_case_monkey.rb deleted file mode 100644 index 853f2682..00000000 --- a/vendor/rails/activerecord/test/models/mixed_case_monkey.rb +++ /dev/null @@ -1,3 +0,0 @@ -class MixedCaseMonkey < ActiveRecord::Base - set_primary_key 'monkeyID' -end diff --git a/vendor/rails/activerecord/test/models/movie.rb b/vendor/rails/activerecord/test/models/movie.rb deleted file mode 100644 index 6384b4c8..00000000 --- a/vendor/rails/activerecord/test/models/movie.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Movie < ActiveRecord::Base - def self.primary_key - "movieid" - end -end diff --git a/vendor/rails/activerecord/test/models/order.rb b/vendor/rails/activerecord/test/models/order.rb deleted file mode 100644 index e838c0b7..00000000 --- a/vendor/rails/activerecord/test/models/order.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Order < ActiveRecord::Base - belongs_to :billing, :class_name => 'Customer', :foreign_key => 'billing_customer_id' - belongs_to :shipping, :class_name => 'Customer', :foreign_key => 'shipping_customer_id' -end diff --git a/vendor/rails/activerecord/test/models/organization.rb b/vendor/rails/activerecord/test/models/organization.rb deleted file mode 100644 index c8572616..00000000 --- a/vendor/rails/activerecord/test/models/organization.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Organization < ActiveRecord::Base - has_many :member_details - has_many :members, :through => :member_details - - named_scope :clubs, { :from => 'clubs' } -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/owner.rb b/vendor/rails/activerecord/test/models/owner.rb deleted file mode 100644 index 5760b991..00000000 --- a/vendor/rails/activerecord/test/models/owner.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Owner < ActiveRecord::Base - set_primary_key :owner_id - has_many :pets - has_many :toys, :through => :pets -end diff --git a/vendor/rails/activerecord/test/models/parrot.rb b/vendor/rails/activerecord/test/models/parrot.rb deleted file mode 100644 index 737ef913..00000000 --- a/vendor/rails/activerecord/test/models/parrot.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Parrot < ActiveRecord::Base - set_inheritance_column :parrot_sti_class - has_and_belongs_to_many :pirates - has_and_belongs_to_many :treasures - has_many :loots, :as => :looter - alias_attribute :title, :name - - validates_presence_of :name - - attr_accessor :cancel_save_from_callback - before_save :cancel_save_callback_method, :if => :cancel_save_from_callback - def cancel_save_callback_method - false - end -end - -class LiveParrot < Parrot -end - -class DeadParrot < Parrot - belongs_to :killer, :class_name => 'Pirate' -end diff --git a/vendor/rails/activerecord/test/models/person.rb b/vendor/rails/activerecord/test/models/person.rb deleted file mode 100644 index ec2f684a..00000000 --- a/vendor/rails/activerecord/test/models/person.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Person < ActiveRecord::Base - has_many :readers - has_many :posts, :through => :readers - has_many :posts_with_no_comments, :through => :readers, :source => :post, :include => :comments, :conditions => 'comments.id is null' - - has_many :references - has_many :jobs, :through => :references - has_one :favourite_reference, :class_name => 'Reference', :conditions => ['favourite=?', true] - has_many :posts_with_comments_sorted_by_comment_id, :through => :readers, :source => :post, :include => :comments, :order => 'comments.id' - - belongs_to :primary_contact, :class_name => 'Person' - has_many :agents, :class_name => 'Person', :foreign_key => 'primary_contact_id' - - named_scope :males, :conditions => { :gender => 'M' } - named_scope :females, :conditions => { :gender => 'F' } -end diff --git a/vendor/rails/activerecord/test/models/pet.rb b/vendor/rails/activerecord/test/models/pet.rb deleted file mode 100644 index a8bf94dd..00000000 --- a/vendor/rails/activerecord/test/models/pet.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Pet < ActiveRecord::Base - set_primary_key :pet_id - belongs_to :owner, :touch => true - has_many :toys -end diff --git a/vendor/rails/activerecord/test/models/pirate.rb b/vendor/rails/activerecord/test/models/pirate.rb deleted file mode 100644 index d89c8cf3..00000000 --- a/vendor/rails/activerecord/test/models/pirate.rb +++ /dev/null @@ -1,80 +0,0 @@ -class Pirate < ActiveRecord::Base - belongs_to :parrot, :validate => true - belongs_to :non_validated_parrot, :class_name => 'Parrot' - has_and_belongs_to_many :parrots, :validate => true, :order => 'parrots.id ASC' - has_and_belongs_to_many :non_validated_parrots, :class_name => 'Parrot' - has_and_belongs_to_many :parrots_with_method_callbacks, :class_name => "Parrot", - :before_add => :log_before_add, - :after_add => :log_after_add, - :before_remove => :log_before_remove, - :after_remove => :log_after_remove - has_and_belongs_to_many :parrots_with_proc_callbacks, :class_name => "Parrot", - :before_add => proc {|p,pa| p.ship_log << "before_adding_proc_parrot_#{pa.id || '<new>'}"}, - :after_add => proc {|p,pa| p.ship_log << "after_adding_proc_parrot_#{pa.id || '<new>'}"}, - :before_remove => proc {|p,pa| p.ship_log << "before_removing_proc_parrot_#{pa.id}"}, - :after_remove => proc {|p,pa| p.ship_log << "after_removing_proc_parrot_#{pa.id}"} - - has_many :treasures, :as => :looter - has_many :treasure_estimates, :through => :treasures, :source => :price_estimates - - # These both have :autosave enabled because accepts_nested_attributes_for is used on them. - has_one :ship - has_one :update_only_ship, :class_name => 'Ship' - has_one :non_validated_ship, :class_name => 'Ship' - has_many :birds, :order => 'birds.id ASC' - has_many :birds_with_method_callbacks, :class_name => "Bird", - :before_add => :log_before_add, - :after_add => :log_after_add, - :before_remove => :log_before_remove, - :after_remove => :log_after_remove - has_many :birds_with_proc_callbacks, :class_name => "Bird", - :before_add => proc {|p,b| p.ship_log << "before_adding_proc_bird_#{b.id || '<new>'}"}, - :after_add => proc {|p,b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}"}, - :before_remove => proc {|p,b| p.ship_log << "before_removing_proc_bird_#{b.id}"}, - :after_remove => proc {|p,b| p.ship_log << "after_removing_proc_bird_#{b.id}"} - has_many :birds_with_reject_all_blank, :class_name => "Bird" - - accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - accepts_nested_attributes_for :update_only_ship, :update_only => true - accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks, - :birds_with_method_callbacks, :birds_with_proc_callbacks, :allow_destroy => true - accepts_nested_attributes_for :birds_with_reject_all_blank, :reject_if => :all_blank - - validates_presence_of :catchphrase - - def ship_log - @ship_log ||= [] - end - - def reject_empty_ships_on_create(attributes) - attributes.delete('_reject_me_if_new').present? && new_record? - end - - attr_accessor :cancel_save_from_callback - before_save :cancel_save_callback_method, :if => :cancel_save_from_callback - def cancel_save_callback_method - false - end - - private - def log_before_add(record) - log(record, "before_adding_method") - end - - def log_after_add(record) - log(record, "after_adding_method") - end - - def log_before_remove(record) - log(record, "before_removing_method") - end - - def log_after_remove(record) - log(record, "after_removing_method") - end - - def log(record, callback) - ship_log << "#{callback}_#{record.class.name.downcase}_#{record.id || '<new>'}" - end -end diff --git a/vendor/rails/activerecord/test/models/polymorphic_design.rb b/vendor/rails/activerecord/test/models/polymorphic_design.rb deleted file mode 100644 index 6748f8fe..00000000 --- a/vendor/rails/activerecord/test/models/polymorphic_design.rb +++ /dev/null @@ -1,3 +0,0 @@ -class PolymorphicDesign < ActiveRecord::Base - belongs_to :designable, :polymorphic => true -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/polymorphic_price.rb b/vendor/rails/activerecord/test/models/polymorphic_price.rb deleted file mode 100644 index bea85661..00000000 --- a/vendor/rails/activerecord/test/models/polymorphic_price.rb +++ /dev/null @@ -1,3 +0,0 @@ -class PolymorphicPrice < ActiveRecord::Base - belongs_to :sellable, :polymorphic => true -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/post.rb b/vendor/rails/activerecord/test/models/post.rb deleted file mode 100644 index cf69d049..00000000 --- a/vendor/rails/activerecord/test/models/post.rb +++ /dev/null @@ -1,102 +0,0 @@ -class Post < ActiveRecord::Base - named_scope :with_type_self, lambda{{:conditions => ["type=?", self.name]}} - named_scope :containing_the_letter_a, :conditions => "body LIKE '%a%'" - named_scope :ranked_by_comments, :order => "comments_count DESC" - named_scope :limit, lambda {|limit| {:limit => limit} } - named_scope :with_authors_at_address, lambda { |address| { - :conditions => [ 'authors.author_address_id = ?', address.id ], - :joins => 'JOIN authors ON authors.id = posts.author_id' - } - } - - belongs_to :author do - def greeting - "hello" - end - end - - belongs_to :author_with_posts, :class_name => "Author", :foreign_key => :author_id, :include => :posts - belongs_to :author_with_address, :class_name => "Author", :foreign_key => :author_id, :include => :author_address - - has_one :last_comment, :class_name => 'Comment', :order => 'id desc' - - named_scope :with_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'SpecialComment'} } - named_scope :with_very_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'VerySpecialComment'} } - named_scope :with_post, lambda {|post_id| - { :joins => :comments, :conditions => {:comments => {:post_id => post_id} } } - } - - has_many :comments, :order => "body" do - def find_most_recent - find(:first, :order => "id DESC") - end - end - - has_many :author_favorites, :through => :author - - has_many :comments_with_interpolated_conditions, :class_name => 'Comment', - :conditions => ['#{"#{aliased_table_name}." rescue ""}body = ?', 'Thank you for the welcome'] - - has_one :very_special_comment - has_one :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post - has_many :special_comments - has_many :nonexistant_comments, :class_name => 'Comment', :conditions => 'comments.id < 0' - - has_and_belongs_to_many :categories - has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id' - - has_many :taggings, :as => :taggable - has_many :tags, :through => :taggings do - def add_joins_and_select - find :all, :select => 'tags.*, authors.id as author_id', :include => false, - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id' - end - end - - has_many :misc_tags, :through => :taggings, :source => :tag, :conditions => "tags.name = 'Misc'" - has_many :funky_tags, :through => :taggings, :source => :tag - has_many :super_tags, :through => :taggings - has_one :tagging, :as => :taggable - - has_many :invalid_taggings, :as => :taggable, :class_name => "Tagging", :conditions => 'taggings.id < 0' - has_many :invalid_tags, :through => :invalid_taggings, :source => :tag - - has_many :categorizations, :foreign_key => :category_id - has_many :authors, :through => :categorizations - - has_many :readers - has_many :people, :through => :readers - has_many :people_with_callbacks, :source=>:person, :through => :readers, - :before_add => lambda {|owner, reader| log(:added, :before, reader.first_name) }, - :after_add => lambda {|owner, reader| log(:added, :after, reader.first_name) }, - :before_remove => lambda {|owner, reader| log(:removed, :before, reader.first_name) }, - :after_remove => lambda {|owner, reader| log(:removed, :after, reader.first_name) } - - def self.top(limit) - ranked_by_comments.limit(limit) - end - - def self.reset_log - @log = [] - end - - def self.log(message=nil, side=nil, new_record=nil) - return @log if message.nil? - @log << [message, side, new_record] - end - - def self.what_are_you - 'a post...' - end -end - -class SpecialPost < Post; end - -class StiPost < Post - self.abstract_class = true - has_one :special_comment, :class_name => "SpecialComment" -end - -class SubStiPost < StiPost - self.table_name = Post.table_name -end diff --git a/vendor/rails/activerecord/test/models/price_estimate.rb b/vendor/rails/activerecord/test/models/price_estimate.rb deleted file mode 100644 index ef3bba36..00000000 --- a/vendor/rails/activerecord/test/models/price_estimate.rb +++ /dev/null @@ -1,3 +0,0 @@ -class PriceEstimate < ActiveRecord::Base - belongs_to :estimate_of, :polymorphic => true -end diff --git a/vendor/rails/activerecord/test/models/project.rb b/vendor/rails/activerecord/test/models/project.rb deleted file mode 100644 index f25b2ddf..00000000 --- a/vendor/rails/activerecord/test/models/project.rb +++ /dev/null @@ -1,30 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true, :order => 'developers.name desc, developers.id desc' - has_and_belongs_to_many :readonly_developers, :class_name => "Developer", :readonly => true - has_and_belongs_to_many :selected_developers, :class_name => "Developer", :select => "developers.*", :uniq => true - has_and_belongs_to_many :non_unique_developers, :order => 'developers.name desc, developers.id desc', :class_name => 'Developer' - has_and_belongs_to_many :limited_developers, :class_name => "Developer", :limit => 1 - has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true - has_and_belongs_to_many :developers_named_david_with_hash_conditions, :class_name => "Developer", :conditions => { :name => 'David' }, :uniq => true - has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0" - has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id} ORDER BY t.id' - has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => "DELETE FROM developers_projects WHERE project_id = \#{id} AND developer_id = \#{record.id}" - has_and_belongs_to_many :developers_with_callbacks, :class_name => "Developer", :before_add => Proc.new {|o, r| o.developers_log << "before_adding#{r.id || '<new>'}"}, - :after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id || '<new>'}"}, - :before_remove => Proc.new {|o, r| o.developers_log << "before_removing#{r.id}"}, - :after_remove => Proc.new {|o, r| o.developers_log << "after_removing#{r.id}"} - has_and_belongs_to_many :well_payed_salary_groups, :class_name => "Developer", :group => "developers.salary", :having => "SUM(salary) > 10000", :select => "SUM(salary) as salary" - - attr_accessor :developers_log - - def after_initialize - @developers_log = [] - end - -end - -class SpecialProject < Project - def hello_world - "hello there!" - end -end diff --git a/vendor/rails/activerecord/test/models/reader.rb b/vendor/rails/activerecord/test/models/reader.rb deleted file mode 100644 index 27527bf5..00000000 --- a/vendor/rails/activerecord/test/models/reader.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Reader < ActiveRecord::Base - belongs_to :post - belongs_to :person -end diff --git a/vendor/rails/activerecord/test/models/reference.rb b/vendor/rails/activerecord/test/models/reference.rb deleted file mode 100644 index 479e8b72..00000000 --- a/vendor/rails/activerecord/test/models/reference.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Reference < ActiveRecord::Base - belongs_to :person - belongs_to :job -end diff --git a/vendor/rails/activerecord/test/models/reply.rb b/vendor/rails/activerecord/test/models/reply.rb deleted file mode 100644 index 4063785f..00000000 --- a/vendor/rails/activerecord/test/models/reply.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'models/topic' - -class Reply < Topic - named_scope :base - - belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true - belongs_to :topic_with_primary_key, :class_name => "Topic", :primary_key => "title", :foreign_key => "parent_title", :counter_cache => "replies_count" - has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id" - - validate :errors_on_empty_content - validate_on_create :title_is_wrong_create - - attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read, :parent_title - - def validate - errors.add("title", "Empty") unless attribute_present? "title" - end - - def errors_on_empty_content - errors.add("content", "Empty") unless attribute_present? "content" - end - - def validate_on_create - if attribute_present?("title") && attribute_present?("content") && content == "Mismatch" - errors.add("title", "is Content Mismatch") - end - end - - def title_is_wrong_create - errors.add("title", "is Wrong Create") if attribute_present?("title") && title == "Wrong Create" - end - - def validate_on_update - errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update" - end -end - -class SillyReply < Reply - belongs_to :reply, :foreign_key => "parent_id", :counter_cache => :replies_count -end - -module Web - class Reply < Web::Topic - belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true, :class_name => 'Web::Topic' - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/ship.rb b/vendor/rails/activerecord/test/models/ship.rb deleted file mode 100644 index 3da03194..00000000 --- a/vendor/rails/activerecord/test/models/ship.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Ship < ActiveRecord::Base - self.record_timestamps = false - - belongs_to :pirate - belongs_to :update_only_pirate, :class_name => 'Pirate' - has_many :parts, :class_name => 'ShipPart' - - accepts_nested_attributes_for :parts, :allow_destroy => true - accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - accepts_nested_attributes_for :update_only_pirate, :update_only => true - - validates_presence_of :name - - attr_accessor :cancel_save_from_callback - before_save :cancel_save_callback_method, :if => :cancel_save_from_callback - def cancel_save_callback_method - false - end -end diff --git a/vendor/rails/activerecord/test/models/ship_part.rb b/vendor/rails/activerecord/test/models/ship_part.rb deleted file mode 100644 index 8e61d700..00000000 --- a/vendor/rails/activerecord/test/models/ship_part.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ShipPart < ActiveRecord::Base - belongs_to :ship - has_many :trinkets, :class_name => "Treasure", :as => :looter - accepts_nested_attributes_for :trinkets, :allow_destroy => true - - validates_presence_of :name -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/sponsor.rb b/vendor/rails/activerecord/test/models/sponsor.rb deleted file mode 100644 index 50c2c2d7..00000000 --- a/vendor/rails/activerecord/test/models/sponsor.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Sponsor < ActiveRecord::Base - belongs_to :sponsor_club, :class_name => "Club", :foreign_key => "club_id" - belongs_to :sponsorable, :polymorphic => true -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/subject.rb b/vendor/rails/activerecord/test/models/subject.rb deleted file mode 100644 index 3502943f..00000000 --- a/vendor/rails/activerecord/test/models/subject.rb +++ /dev/null @@ -1,4 +0,0 @@ -# used for OracleSynonymTest, see test/synonym_test_oci.rb -# -class Subject < ActiveRecord::Base -end diff --git a/vendor/rails/activerecord/test/models/subscriber.rb b/vendor/rails/activerecord/test/models/subscriber.rb deleted file mode 100644 index 5b78014e..00000000 --- a/vendor/rails/activerecord/test/models/subscriber.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Subscriber < ActiveRecord::Base - set_primary_key 'nick' - has_many :subscriptions - has_many :books, :through => :subscriptions -end - -class SpecialSubscriber < Subscriber -end diff --git a/vendor/rails/activerecord/test/models/subscription.rb b/vendor/rails/activerecord/test/models/subscription.rb deleted file mode 100644 index 4bdb36ea..00000000 --- a/vendor/rails/activerecord/test/models/subscription.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Subscription < ActiveRecord::Base - belongs_to :subscriber - belongs_to :book -end diff --git a/vendor/rails/activerecord/test/models/tag.rb b/vendor/rails/activerecord/test/models/tag.rb deleted file mode 100644 index a581b381..00000000 --- a/vendor/rails/activerecord/test/models/tag.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Tag < ActiveRecord::Base - has_many :taggings - has_many :taggables, :through => :taggings - has_one :tagging - - has_many :tagged_posts, :through => :taggings, :source => :taggable, :source_type => 'Post' -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/tagging.rb b/vendor/rails/activerecord/test/models/tagging.rb deleted file mode 100644 index a1fa1a97..00000000 --- a/vendor/rails/activerecord/test/models/tagging.rb +++ /dev/null @@ -1,10 +0,0 @@ -# test that attr_readonly isn't called on the :taggable polymorphic association -module Taggable -end - -class Tagging < ActiveRecord::Base - belongs_to :tag, :include => :tagging - belongs_to :super_tag, :class_name => 'Tag', :foreign_key => 'super_tag_id' - belongs_to :invalid_tag, :class_name => 'Tag', :foreign_key => 'tag_id' - belongs_to :taggable, :polymorphic => true, :counter_cache => true -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/task.rb b/vendor/rails/activerecord/test/models/task.rb deleted file mode 100644 index ee0282c7..00000000 --- a/vendor/rails/activerecord/test/models/task.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Task < ActiveRecord::Base - -end diff --git a/vendor/rails/activerecord/test/models/tee.rb b/vendor/rails/activerecord/test/models/tee.rb deleted file mode 100644 index 63311a74..00000000 --- a/vendor/rails/activerecord/test/models/tee.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Tee < ActiveRecord::Base - has_one :polymorphic_design, :as => :designable - has_one :polymorphic_price, :as => :sellable -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/tie.rb b/vendor/rails/activerecord/test/models/tie.rb deleted file mode 100644 index cdf17407..00000000 --- a/vendor/rails/activerecord/test/models/tie.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Tie < ActiveRecord::Base - has_one :polymorphic_design, :as => :designable - has_one :polymorphic_price, :as => :sellable -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/topic.rb b/vendor/rails/activerecord/test/models/topic.rb deleted file mode 100644 index 9594dc30..00000000 --- a/vendor/rails/activerecord/test/models/topic.rb +++ /dev/null @@ -1,80 +0,0 @@ -class Topic < ActiveRecord::Base - named_scope :base - named_scope :written_before, lambda { |time| - if time - { :conditions => ['written_on < ?', time] } - end - } - named_scope :approved, :conditions => {:approved => true} - named_scope :rejected, :conditions => {:approved => false} - - named_scope :by_lifo, :conditions => {:author_name => 'lifo'} - - named_scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}} - named_scope 'approved_as_string', :conditions => {:approved => true} - named_scope :replied, :conditions => ['replies_count > 0'] - named_scope :anonymous_extension do - def one - 1 - end - end - module NamedExtension - def two - 2 - end - end - module MultipleExtensionOne - def extension_one - 1 - end - end - module MultipleExtensionTwo - def extension_two - 2 - end - end - named_scope :named_extension, :extend => NamedExtension - named_scope :multiple_extensions, :extend => [MultipleExtensionTwo, MultipleExtensionOne] - - has_many :replies, :dependent => :destroy, :foreign_key => "parent_id" - has_many :replies_with_primary_key, :class_name => "Reply", :dependent => :destroy, :primary_key => "title", :foreign_key => "parent_title" - serialize :content - - before_create :default_written_on - before_destroy :destroy_children - - def parent - Topic.find(parent_id) - end - - # trivial method for testing Array#to_xml with :methods - def topic_id - id - end - - protected - def approved=(val) - @custom_approved = val - write_attribute(:approved, val) - end - - def default_written_on - self.written_on = Time.now unless attribute_present?("written_on") - end - - def destroy_children - self.class.delete_all "parent_id = #{id}" - end - - def after_initialize - if self.new_record? - self.author_email_address = 'test@test.com' - end - end -end - -module Web - class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => 'Web::Reply' - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/toy.rb b/vendor/rails/activerecord/test/models/toy.rb deleted file mode 100644 index 0e68ba57..00000000 --- a/vendor/rails/activerecord/test/models/toy.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Toy < ActiveRecord::Base - set_primary_key :toy_id - belongs_to :pet - - named_scope :with_name, lambda { |name| {:conditions => {:name => name}} } -end diff --git a/vendor/rails/activerecord/test/models/treasure.rb b/vendor/rails/activerecord/test/models/treasure.rb deleted file mode 100644 index 2a98e74f..00000000 --- a/vendor/rails/activerecord/test/models/treasure.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Treasure < ActiveRecord::Base - has_and_belongs_to_many :parrots - belongs_to :looter, :polymorphic => true - - has_many :price_estimates, :as => :estimate_of - - accepts_nested_attributes_for :looter -end diff --git a/vendor/rails/activerecord/test/models/vertex.rb b/vendor/rails/activerecord/test/models/vertex.rb deleted file mode 100644 index 48bb851e..00000000 --- a/vendor/rails/activerecord/test/models/vertex.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This class models a vertex in a directed graph. -class Vertex < ActiveRecord::Base - has_many :sink_edges, :class_name => 'Edge', :foreign_key => 'source_id' - has_many :sinks, :through => :sink_edges - - has_and_belongs_to_many :sources, - :class_name => 'Vertex', :join_table => 'edges', - :foreign_key => 'sink_id', :association_foreign_key => 'source_id' -end diff --git a/vendor/rails/activerecord/test/models/warehouse_thing.rb b/vendor/rails/activerecord/test/models/warehouse_thing.rb deleted file mode 100644 index 6ace1183..00000000 --- a/vendor/rails/activerecord/test/models/warehouse_thing.rb +++ /dev/null @@ -1,5 +0,0 @@ -class WarehouseThing < ActiveRecord::Base - set_table_name "warehouse-things" - - validates_uniqueness_of :value -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/zine.rb b/vendor/rails/activerecord/test/models/zine.rb deleted file mode 100644 index c2d0fdaf..00000000 --- a/vendor/rails/activerecord/test/models/zine.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Zine < ActiveRecord::Base - has_many :interests, :inverse_of => :zine -end diff --git a/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb b/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb deleted file mode 100644 index ee749381..00000000 --- a/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb +++ /dev/null @@ -1,31 +0,0 @@ -ActiveRecord::Schema.define do - create_table :binary_fields, :force => true, :options => 'CHARACTER SET latin1' do |t| - t.binary :tiny_blob, :limit => 255 - t.binary :normal_blob, :limit => 65535 - t.binary :medium_blob, :limit => 16777215 - t.binary :long_blob, :limit => 2147483647 - t.text :tiny_text, :limit => 255 - t.text :normal_text, :limit => 65535 - t.text :medium_text, :limit => 16777215 - t.text :long_text, :limit => 2147483647 - end - - ActiveRecord::Base.connection.execute <<-SQL -DROP PROCEDURE IF EXISTS ten; -SQL - - ActiveRecord::Base.connection.execute <<-SQL -CREATE PROCEDURE ten() SQL SECURITY INVOKER -BEGIN - select 10; -END -SQL - - ActiveRecord::Base.connection.execute <<-SQL -CREATE PROCEDURE topics() SQL SECURITY INVOKER -BEGIN - select * from topics limit 1; -END -SQL - -end diff --git a/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb b/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb deleted file mode 100644 index 3d8911bf..00000000 --- a/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +++ /dev/null @@ -1,114 +0,0 @@ -ActiveRecord::Schema.define do - - %w(postgresql_arrays postgresql_moneys postgresql_numbers postgresql_times postgresql_network_addresses postgresql_bit_strings - postgresql_oids postgresql_xml_data_type defaults geometrics).each do |table_name| - execute "DROP TABLE IF EXISTS #{quote_table_name table_name}" - end - - execute 'DROP SEQUENCE IF EXISTS companies_nonstd_seq CASCADE' - execute 'CREATE SEQUENCE companies_nonstd_seq START 101 OWNED BY companies.id' - execute "ALTER TABLE companies ALTER COLUMN id SET DEFAULT nextval('companies_nonstd_seq')" - execute 'DROP SEQUENCE IF EXISTS companies_id_seq' - - %w(accounts_id_seq developers_id_seq projects_id_seq topics_id_seq customers_id_seq orders_id_seq).each do |seq_name| - execute "SELECT setval('#{seq_name}', 100)" - end - - execute <<_SQL - CREATE TABLE defaults ( - id serial primary key, - modified_date date default CURRENT_DATE, - modified_date_function date default now(), - fixed_date date default '2004-01-01', - modified_time timestamp default CURRENT_TIMESTAMP, - modified_time_function timestamp default now(), - fixed_time timestamp default '2004-01-01 00:00:00.000000-00', - char1 char(1) default 'Y', - char2 character varying(50) default 'a varchar field', - char3 text default 'a text field', - positive_integer integer default 1, - negative_integer integer default -1, - decimal_number decimal(3,2) default 2.78, - multiline_default text DEFAULT '--- [] - -'::text -); -_SQL - - execute <<_SQL - CREATE TABLE geometrics ( - id serial primary key, - a_point point, - -- a_line line, (the line type is currently not implemented in postgresql) - a_line_segment lseg, - a_box box, - a_path path, - a_polygon polygon, - a_circle circle - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_arrays ( - id SERIAL PRIMARY KEY, - commission_by_quarter INTEGER[], - nicknames TEXT[] - ); -_SQL - execute <<_SQL - CREATE TABLE postgresql_moneys ( - id SERIAL PRIMARY KEY, - wealth MONEY - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_numbers ( - id SERIAL PRIMARY KEY, - single REAL, - double DOUBLE PRECISION - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_times ( - id SERIAL PRIMARY KEY, - time_interval INTERVAL - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_network_addresses ( - id SERIAL PRIMARY KEY, - cidr_address CIDR, - inet_address INET, - mac_address MACADDR - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_bit_strings ( - id SERIAL PRIMARY KEY, - bit_string BIT(8), - bit_string_varying BIT VARYING(8) - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_oids ( - id SERIAL PRIMARY KEY, - obj_id OID - ); -_SQL - - begin - execute <<_SQL - CREATE TABLE postgresql_xml_data_type ( - id SERIAL PRIMARY KEY, - data xml - ); -_SQL -rescue #This version of PostgreSQL either has no XML support or is was not compiled with XML support: skipping table - end -end - diff --git a/vendor/rails/activerecord/test/schema/schema.rb b/vendor/rails/activerecord/test/schema/schema.rb deleted file mode 100644 index 2e5299ca..00000000 --- a/vendor/rails/activerecord/test/schema/schema.rb +++ /dev/null @@ -1,550 +0,0 @@ - -ActiveRecord::Schema.define do - def except(adapter_names_to_exclude) - unless [adapter_names_to_exclude].flatten.include?(adapter_name) - yield - end - end - - #put adapter specific setup here - case adapter_name - # For Firebird, set the sequence values 10000 when create_table is called; - # this prevents primary key collisions between "normally" created records - # and fixture-based (YAML) records. - when "Firebird" - def create_table(*args, &block) - ActiveRecord::Base.connection.create_table(*args, &block) - ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000" - end - end - - - # Please keep these create table statements in alphabetical order - # unless the ordering matters. In which case, define them below - create_table :accounts, :force => true do |t| - t.integer :firm_id - t.string :firm_name - t.integer :credit_limit - end - - create_table :audit_logs, :force => true do |t| - t.column :message, :string, :null=>false - t.column :developer_id, :integer, :null=>false - end - - create_table :authors, :force => true do |t| - t.string :name, :null => false - t.integer :author_address_id - t.integer :author_address_extra_id - end - - create_table :author_addresses, :force => true do |t| - end - - create_table :author_favorites, :force => true do |t| - t.column :author_id, :integer - t.column :favorite_author_id, :integer - end - - - create_table :auto_id_tests, :force => true, :id => false do |t| - t.primary_key :auto_id - t.integer :value - end - - create_table :binaries, :force => true do |t| - t.binary :data - end - - create_table :birds, :force => true do |t| - t.string :name - t.string :color - t.integer :pirate_id - end - - create_table :books, :force => true do |t| - t.column :name, :string - end - - create_table :booleantests, :force => true do |t| - t.boolean :value - end - - create_table "CamelCase", :force => true do |t| - t.string :name - end - - create_table :categories, :force => true do |t| - t.string :name, :null => false - t.string :type - t.integer :categorizations_count - end - - create_table :categories_posts, :force => true, :id => false do |t| - t.integer :category_id, :null => false - t.integer :post_id, :null => false - end - - create_table :categorizations, :force => true do |t| - t.column :category_id, :integer - t.column :post_id, :integer - t.column :author_id, :integer - end - - create_table :citations, :force => true do |t| - t.column :book1_id, :integer - t.column :book2_id, :integer - end - - create_table :clubs, :force => true do |t| - t.string :name - end - - create_table :colnametests, :force => true do |t| - t.integer :references, :null => false - end - - create_table :comments, :force => true do |t| - t.integer :post_id, :null => false - t.text :body, :null => false - t.string :type - end - - create_table :companies, :force => true do |t| - t.string :type - t.string :ruby_type - t.integer :firm_id - t.string :firm_name - t.string :name - t.integer :client_of - t.integer :rating, :default => 1 - end - - add_index :companies, [:firm_id, :type, :rating, :ruby_type], :name => "company_index" - - create_table :computers, :force => true do |t| - t.integer :developer, :null => false - t.integer :extendedWarranty, :null => false - end - - create_table :contracts, :force => true do |t| - t.integer :developer_id - t.integer :company_id - end - - create_table :customers, :force => true do |t| - t.string :name - t.integer :balance, :default => 0 - t.string :address_street - t.string :address_city - t.string :address_country - t.string :gps_location - end - - create_table :developers, :force => true do |t| - t.string :name - t.integer :salary, :default => 70000 - t.datetime :created_at - t.datetime :updated_at - end - - create_table :developers_projects, :force => true, :id => false do |t| - t.integer :developer_id, :null => false - t.integer :project_id, :null => false - t.date :joined_on - t.integer :access_level, :default => 1 - end - - create_table :edges, :force => true do |t| - t.column :source_id, :integer, :null => false - t.column :sink_id, :integer, :null => false - end - add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index' - - - create_table :entrants, :force => true do |t| - t.string :name, :null => false - t.integer :course_id, :null => false - end - - create_table :essays, :force => true do |t| - t.string :name - t.string :writer_id - t.string :writer_type - end - - create_table :events, :force => true do |t| - t.string :title, :limit => 5 - t.datetime :ends_on - end - - create_table :event_authors, :force => true do |t| - t.integer :event_id - t.integer :author_id - end - - create_table :funny_jokes, :force => true do |t| - t.string :name - end - - create_table :goofy_string_id, :force => true, :id => false do |t| - t.string :id, :null => false - t.string :info - end - - create_table :invoices, :force => true do |t| - t.integer :balance - t.datetime :updated_at - end - - create_table :items, :force => true do |t| - t.column :name, :integer - end - - create_table :inept_wizards, :force => true do |t| - t.column :name, :string, :null => false - t.column :city, :string, :null => false - t.column :type, :string - end - - - create_table :jobs, :force => true do |t| - t.integer :ideal_reference_id - end - - create_table :keyboards, :force => true, :id => false do |t| - t.primary_key :key_number - t.string :name - end - - create_table :legacy_things, :force => true do |t| - t.integer :tps_report_number - t.integer :version, :null => false, :default => 0 - end - - create_table :line_items, :force => true do |t| - t.integer :invoice_id - t.integer :amount - end - - create_table :lock_without_defaults, :force => true do |t| - t.column :lock_version, :integer - end - - create_table :lock_without_defaults_cust, :force => true do |t| - t.column :custom_lock_version, :integer - end - - create_table :mateys, :id => false, :force => true do |t| - t.column :pirate_id, :integer - t.column :target_id, :integer - t.column :weight, :integer - end - - create_table :members, :force => true do |t| - t.string :name - t.integer :member_type_id - end - - create_table :member_details, :force => true do |t| - t.integer :member_id - t.integer :organization_id - t.string :extra_data - end - - create_table :memberships, :force => true do |t| - t.datetime :joined_on - t.integer :club_id, :member_id - t.boolean :favourite, :default => false - t.string :type - end - - create_table :member_types, :force => true do |t| - t.string :name - end - - create_table :references, :force => true do |t| - t.integer :person_id - t.integer :job_id - t.boolean :favourite - t.integer :lock_version, :default => 0 - end - - create_table :minimalistics, :force => true do |t| - end - - create_table :mixed_case_monkeys, :force => true, :id => false do |t| - t.primary_key :monkeyID - t.integer :fleaCount - end - - create_table :mixins, :force => true do |t| - t.integer :parent_id - t.integer :pos - t.datetime :created_at - t.datetime :updated_at - t.integer :lft - t.integer :rgt - t.integer :root_id - t.string :type - end - - create_table :movies, :force => true, :id => false do |t| - t.primary_key :movieid - t.string :name - end - - create_table :numeric_data, :force => true do |t| - t.decimal :bank_balance, :precision => 10, :scale => 2 - t.decimal :big_bank_balance, :precision => 15, :scale => 2 - t.decimal :world_population, :precision => 10, :scale => 0 - t.decimal :my_house_population, :precision => 2, :scale => 0 - t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78 - t.float :temperature - end - - create_table :orders, :force => true do |t| - t.string :name - t.integer :billing_customer_id - t.integer :shipping_customer_id - end - - create_table :organizations, :force => true do |t| - t.string :name - end - - create_table :owners, :primary_key => :owner_id ,:force => true do |t| - t.string :name - t.column :updated_at, :datetime - t.column :happy_at, :datetime - end - - - create_table :paint_colors, :force => true do |t| - t.integer :non_poly_one_id - end - - create_table :paint_textures, :force => true do |t| - t.integer :non_poly_two_id - end - - create_table :parrots, :force => true do |t| - t.column :name, :string - t.column :parrot_sti_class, :string - t.column :killer_id, :integer - t.column :created_at, :datetime - t.column :created_on, :datetime - t.column :updated_at, :datetime - t.column :updated_on, :datetime - end - - create_table :parrots_pirates, :id => false, :force => true do |t| - t.column :parrot_id, :integer - t.column :pirate_id, :integer - end - - create_table :parrots_treasures, :id => false, :force => true do |t| - t.column :parrot_id, :integer - t.column :treasure_id, :integer - end - - create_table :people, :force => true do |t| - t.string :first_name, :null => false - t.references :primary_contact - t.string :gender, :limit => 1 - t.integer :lock_version, :null => false, :default => 0 - end - - create_table :pets, :primary_key => :pet_id ,:force => true do |t| - t.string :name - t.integer :owner_id, :integer - end - - create_table :pirates, :force => true do |t| - t.column :catchphrase, :string - t.column :parrot_id, :integer - t.column :created_on, :datetime - t.column :updated_on, :datetime - end - - create_table :polymorphic_designs, :force => true do |t| - t.integer :designable_id - t.string :designable_type - end - - create_table :polymorphic_prices, :force => true do |t| - t.integer :sellable_id - t.string :sellable_type - end - - create_table :posts, :force => true do |t| - t.integer :author_id - t.string :title, :null => false - t.text :body, :null => false - t.string :type - t.integer :comments_count, :default => 0 - t.integer :taggings_count, :default => 0 - end - - create_table :price_estimates, :force => true do |t| - t.string :estimate_of_type - t.integer :estimate_of_id - t.integer :price - end - - create_table :projects, :force => true do |t| - t.string :name - t.string :type - end - - create_table :readers, :force => true do |t| - t.integer :post_id, :null => false - t.integer :person_id, :null => false - t.boolean :skimmer, :default => false - end - - create_table :shape_expressions, :force => true do |t| - t.string :paint_type - t.integer :paint_id - t.string :shape_type - t.integer :shape_id - end - - create_table :ships, :force => true do |t| - t.string :name - t.integer :pirate_id - t.datetime :created_at - t.datetime :created_on - t.datetime :updated_at - t.datetime :updated_on - end - - create_table :ship_parts, :force => true do |t| - t.string :name - t.integer :ship_id - end - - create_table :sponsors, :force => true do |t| - t.integer :club_id - t.integer :sponsorable_id - t.string :sponsorable_type - end - - create_table :subscribers, :force => true, :id => false do |t| - t.string :nick, :null => false - t.string :name - end - add_index :subscribers, :nick, :unique => true - - create_table :subscriptions, :force => true do |t| - t.string :subscriber_id - t.integer :book_id - end - - create_table :tasks, :force => true do |t| - t.datetime :starting - t.datetime :ending - end - - create_table :ties, :force => true - - create_table :topics, :force => true do |t| - t.string :title - t.string :author_name - t.string :author_email_address - t.datetime :written_on - t.time :bonus_time - t.date :last_read - t.text :content - t.boolean :approved, :default => true - t.integer :replies_count, :default => 0 - t.integer :parent_id - t.string :parent_title - t.string :type - t.string :group - end - - create_table :taggings, :force => true do |t| - t.column :tag_id, :integer - t.column :super_tag_id, :integer - t.column :taggable_type, :string - t.column :taggable_id, :integer - end - - create_table :tags, :force => true do |t| - t.column :name, :string - t.column :taggings_count, :integer, :default => 0 - end - - create_table :tees, :force => true - - create_table :toys, :primary_key => :toy_id ,:force => true do |t| - t.string :name - t.integer :pet_id, :integer - end - - create_table :treasures, :force => true do |t| - t.column :name, :string - t.column :looter_id, :integer - t.column :looter_type, :string - end - - create_table :vertices, :force => true do |t| - t.column :label, :string - end - - create_table 'warehouse-things', :force => true do |t| - t.integer :value - end - - [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t| - create_table(t, :force => true) { } - end - - create_table :guids, :force => true do |t| - t.column :key, :string - end - - create_table :integer_limits, :force => true do |t| - t.integer :"c_int_without_limit" - (1..8).each do |i| - t.integer :"c_int_#{i}", :limit => i - end - end - - # NOTE - the following 4 tables are used by models that have :inverse_of options on the associations - create_table :men, :force => true do |t| - t.string :name - end - - create_table :faces, :force => true do |t| - t.string :description - t.integer :man_id - t.integer :polymorphic_man_id - t.string :polymorphic_man_type - end - - create_table :interests, :force => true do |t| - t.string :topic - t.integer :man_id - t.integer :polymorphic_man_id - t.string :polymorphic_man_type - t.integer :zine_id - end - - create_table :zines, :force => true do |t| - t.string :title - end - - except 'SQLite' do - # fk_test_has_fk should be before fk_test_has_pk - create_table :fk_test_has_fk, :force => true do |t| - t.integer :fk_id, :null => false - end - - create_table :fk_test_has_pk, :force => true do |t| - end - - execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})" - end -end diff --git a/vendor/rails/activerecord/test/schema/schema2.rb b/vendor/rails/activerecord/test/schema/schema2.rb deleted file mode 100644 index 8527f7ba..00000000 --- a/vendor/rails/activerecord/test/schema/schema2.rb +++ /dev/null @@ -1,6 +0,0 @@ -ActiveRecord::Schema.define do - - Course.connection.create_table :courses, :force => true do |t| - t.column :name, :string, :null => false - end -end diff --git a/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb b/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb deleted file mode 100644 index ea05b35f..00000000 --- a/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb +++ /dev/null @@ -1,25 +0,0 @@ -ActiveRecord::Schema.define do - # For sqlite 3.1.0+, make a table with a autoincrement column - if supports_autoincrement? - create_table :table_with_autoincrement, :force => true do |t| - t.column :name, :string - end - end - - execute "DROP TABLE fk_test_has_fk" rescue nil - execute "DROP TABLE fk_test_has_pk" rescue nil - execute <<_SQL - CREATE TABLE 'fk_test_has_pk' ( - 'id' INTEGER NOT NULL PRIMARY KEY - ); -_SQL - - execute <<_SQL - CREATE TABLE 'fk_test_has_fk' ( - 'id' INTEGER NOT NULL PRIMARY KEY, - 'fk_id' INTEGER NOT NULL, - - FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id') - ); -_SQL -end \ No newline at end of file diff --git a/vendor/rails/activeresource/CHANGELOG b/vendor/rails/activeresource/CHANGELOG deleted file mode 100644 index bbd33e6c..00000000 --- a/vendor/rails/activeresource/CHANGELOG +++ /dev/null @@ -1,306 +0,0 @@ -*2.3.11 (February 9, 2011)* -*2.3.10 (October 15, 2010)* -*2.3.9 (September 4, 2010)* -*2.3.8 (May 24, 2010)* -*2.3.7 (May 24, 2010)* - -* Version bump. - - -*2.3.6 (May 23, 2010)* - -* No changes, just a version bump. - - -*2.3.5 (November 25, 2009)* - -* Minor Bug Fixes and deprecation warnings - -* More flexible content type handling when parsing responses. - - Ensures that ARes will handle responses like test/xml, or content types - with charsets included. - -*2.3.4 (September 4, 2009)* - -* Add support for errors in JSON format. #1956 [Fabien Jakimowicz] - -* Recognizes 410 as Resource Gone. #2316 [Jordan Brough, Jatinder Singh] - -* More thorough SSL support. #2370 [Roy Nicholson] - -* HTTP proxy support. #2133 [Marshall Huss, Sébastien Dabet] - - -*2.3.3 (July 12, 2009)* - -* No changes, just a version bump. - - -*2.3.2 [Final] (March 15, 2009)* - -* Nothing new, just included in 2.3.2 - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Fixed that ActiveResource#post would post an empty string when it shouldn't be posting anything #525 [Paolo Angelini] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* Add ActiveResource::Base#to_xml and ActiveResource::Base#to_json. #1011 [Rasik Pandey, Cody Fauser] - -* Add ActiveResource::Base.find(:last). [#754 state:resolved] (Adrian Mugnolo) - -* Fixed problems with the logger used if the logging string included %'s [#840 state:resolved] (Jamis Buck) - -* Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving) - - -*2.1.0 (May 31st, 2008)* - -* Fixed response logging to use length instead of the entire thing (seangeo) [#27] - -* Fixed that to_param should be used and honored instead of hardcoding the id #11406 [gspiers] - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Use HEAD instead of GET in exists? [bscofield] - -* Fix small documentation typo. Closes #10670 [Luca Guidi] - -* find_or_create_resource_for handles module nesting. #10646 [xavier] - -* Allow setting ActiveResource::Base#format before #site. [Rick Olson] - -* Support agnostic formats when calling custom methods. Closes #10635 [joerichsen] - -* Document custom methods. #10589 [Cheah Chu Yeow] - -* Ruby 1.9 compatibility. [Jeremy Kemper] - - -*2.0.2* (December 16th, 2007) - -* Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 [trek] - -* Correct empty response handling. #10445 [seangeo] - - -*2.0.1* (December 7th, 2007) - -* Don't cache net/http object so that ActiveResource is more thread-safe. Closes #10142 [kou] - -* Update XML documentation examples to include explicit type attributes. Closes #9754 [Josh Susser] - -* Added one-off declarations of mock behavior [David Heinemeier Hansson]. Example: - - Before: - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, "<person><name>David</name></person>" - end - - Now: - ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>" - -* Added ActiveResource.format= which defaults to :xml but can also be set to :json [David Heinemeier Hansson]. Example: - - class Person < ActiveResource::Base - self.site = "http://app/" - self.format = :json - end - - person = Person.find(1) # => GET http://app/people/1.json - person.name = "David" - person.save # => PUT http://app/people/1.json {name: "David"} - - Person.format = :xml - person.name = "Mary" - person.save # => PUT http://app/people/1.json <person><name>Mary</name></person> - -* Fix reload error when path prefix is used. #8727 [Ian Warshak] - -* Remove ActiveResource::Struct because it hasn't proven very useful. Creating a new ActiveResource::Base subclass is often less code and always clearer. #8612 [Josh Peek] - -* Fix query methods on resources. [Cody Fauser] - -* pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 [Eloy Duran] - -* Recognize and raise an exception on 405 Method Not Allowed responses. #7692 [Josh Peek] - -* Handle string and symbol param keys when splitting params into prefix params and query params. - - Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 }) - -* Added find-one with symbol [David Heinemeier Hansson]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml - -* BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [David Heinemeier Hansson]. Changes: - - Person.find(:all, :title => "CEO") ...becomes: Person.find(:all, :params => { :title => "CEO" }) - Person.find(:managers) ...becomes: Person.find(:all, :from => :managers) - Person.find("/companies/1/manager.xml") ...becomes: Person.find(:one, :from => "/companies/1/manager.xml") - -* Add support for setting custom headers per Active Resource model [Rick Olson] - - class Project - headers['X-Token'] = 'foo' - end - - # makes the GET request with the custom X-Token header - Project.find(:all) - -* Added find-by-path options to ActiveResource::Base.find [David Heinemeier Hansson]. Examples: - - employees = Person.find(:all, :from => "/companies/1/people.xml") # => GET /companies/1/people.xml - manager = Person.find("/companies/1/manager.xml") # => GET /companies/1/manager.xml - - -* Added support for using classes from within a single nested module [David Heinemeier Hansson]. Example: - - module Highrise - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - end - - assert_kind_of Highrise::Comment, Note.find(1).comments.first - - -* Added load_attributes_from_response as a way of loading attributes from other responses than just create [David Heinemeier Hansson] - - class Highrise::Task < ActiveResource::Base - def complete - load_attributes_from_response(post(:complete)) - end - end - - ...will set "done_at" when complete is called. - - -* Added support for calling custom methods #6979 [rwdaigle] - - Person.find(:managers) # => GET /people/managers.xml - Kase.find(1).post(:close) # => POST /kases/1/close.xml - -* Remove explicit prefix_options parameter for ActiveResource::Base#initialize. [Rick Olson] - ActiveResource splits the prefix_options from it automatically. - -* Allow ActiveResource::Base.delete with custom prefix. [Rick Olson] - -* Add ActiveResource::Base#dup [Rick Olson] - -* Fixed constant warning when fetching the same object multiple times [David Heinemeier Hansson] - -* Added that saves which get a body response (and not just a 201) will use that response to update themselves [David Heinemeier Hansson] - -* Disregard namespaces from the default element name, so Highrise::Person will just try to fetch from "/people", not "/highrise/people" [David Heinemeier Hansson] - -* Allow array and hash query parameters. #7756 [Greg Spurrier] - -* Loading a resource preserves its prefix_options. #7353 [Ryan Daigle] - -* Carry over the convenience of #create from ActiveRecord. Closes #7340. [Ryan Daigle] - -* Increase ActiveResource::Base test coverage. Closes #7173, #7174 [Rich Collins] - -* Interpret 422 Unprocessable Entity as ResourceInvalid. #7097 [dkubb] - -* Mega documentation patches. #7025, #7069 [rwdaigle] - -* Base.exists?(id, options) and Base#exists? check whether the resource is found. #6970 [rwdaigle] - -* Query string support. [untext, Jeremy Kemper] - # GET /forums/1/topics.xml?sort=created_at - Topic.find(:all, :forum_id => 1, :sort => 'created_at') - -* Base#==, eql?, and hash methods. == returns true if its argument is identical to self or if it's an instance of the same class, is not new?, and has the same id. eql? is an alias for ==. hash delegates to id. [Jeremy Kemper] - -* Allow subclassed resources to share the site info [Rick Olson, Jeremy Kemper] -d - class BeastResource < ActiveResource::Base - self.site = 'http://beast.caboo.se' - end - - class Forum < BeastResource - # taken from BeastResource - # self.site = 'http://beast.caboo.se' - end - - class Topic < BeastResource - self.site += '/forums/:forum_id' - end - -* Fix issues with ActiveResource collection handling. Closes #6291. [bmilekic] - -* Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway] - -* Add basic logging support for logging outgoing requests. [Jamis Buck] - -* Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck] - -* Make #save behavior mimic AR::Base#save (true on success, false on failure). [Jamis Buck] - -* Add Basic HTTP Authentication to ActiveResource (closes #6305). [jonathan] - -* Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID. - By default, it extracts from the Location response header. - -* Optimistic locking: raise ActiveResource::ResourceConflict on 409 Conflict response. [Jeremy Kemper] - - # Example controller action - def update - @person.save! - rescue ActiveRecord::StaleObjectError - render :xml => @person.reload.to_xml, :status => '409 Conflict' - end - -* Basic validation support [Rick Olson] - - Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors. - - render :xml => @person.errors.to_xml, :status => '400 Validation Error' - -* Deep hashes are converted into collections of resources. [Jeremy Kemper] - Person.new :name => 'Bob', - :address => { :id => 1, :city => 'Portland' }, - :contacts => [{ :id => 1 }, { :id => 2 }] - Looks for Address and Contact resources and creates them if unavailable. - So clients can fetch a complex resource in a single request if you e.g. - render :xml => @person.to_xml(:include => [:address, :contacts]) - in your controller action. - -* Major updates [Rick Olson] - - * Add full support for find/create/update/destroy - * Add support for specifying prefixes. - * Allow overriding of element_name, collection_name, and primary key - * Provide simpler HTTP mock interface for testing - - # rails routing code - map.resources :posts do |post| - post.resources :comments - end - - # ActiveResources - class Post < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000/" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000/posts/:post_id/" - end - - @post = Post.find 5 - @comments = Comment.find :all, :post_id => @post.id - - @comment = Comment.new({:body => 'hello world'}, {:post_id => @post.id}) - @comment.save - -* Base.site= accepts URIs. 200...400 are valid response codes. PUT and POST request bodies default to ''. [Jeremy Kemper] - -* Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [David Heinemeier Hansson] diff --git a/vendor/rails/activeresource/README b/vendor/rails/activeresource/README deleted file mode 100644 index 924017a6..00000000 --- a/vendor/rails/activeresource/README +++ /dev/null @@ -1,165 +0,0 @@ -= Active Resource - -Active Resource (ARes) connects business objects and Representational State Transfer (REST) -web services. It implements object-relational mapping for REST webservices to provide transparent -proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing -in ActionController::Resources). - -== Philosophy - -Active Resource attempts to provide a coherent wrapper object-relational mapping for REST -web services. It follows the same philosophy as Active Record, in that one of its prime aims -is to reduce the amount of code needed to map to these resources. This is made possible -by relying on a number of code- and protocol-based conventions that make it easy for Active Resource -to infer complex relations and structures. These conventions are outlined in detail in the documentation -for ActiveResource::Base. - -== Overview - -Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database -tables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result -received and serialized into a usable Ruby object. - -=== Configuration and Usage - -Putting ActiveResource to use is very similar to ActiveRecord. It's as simple as creating a model class -that inherits from ActiveResource::Base and providing a <tt>site</tt> class variable to it: - - class Person < ActiveResource::Base - self.site = "http://api.people.com:3000/" - end - -Now the Person class is REST enabled and can invoke REST services very similarly to how ActiveRecord invokes -lifecycle methods that operate against a persistent store. - - # Find a person with id = 1 - ryan = Person.find(1) - Person.exists?(1) #=> true - -As you can see, the methods are quite similar to Active Record's methods for dealing with database -records. But rather than dealing directly with a database record, you're dealing with HTTP resources (which may or may not be database records). - -==== Protocol - -Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing -built into ActionController but will also work with any other REST service that properly implements the protocol. -REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification: - -* GET requests are used for finding and retrieving resources. -* POST requests are used to create new resources. -* PUT requests are used to update existing resources. -* DELETE requests are used to delete resources. - -For more information on how this protocol works with Active Resource, see the ActiveResource::Base documentation; -for more general information on REST web services, see the article here[http://en.wikipedia.org/wiki/Representational_State_Transfer]. - -==== Find - -GET Http requests expect the XML form of whatever resource/resources is/are being requested. So, -for a request for a single element - the XML of that item is expected in response: - - # Expects a response of - # - # <person><id type="integer">1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person> - # - # for GET http://api.people.com:3000/people/1.xml - # - ryan = Person.find(1) - -The XML document that is received is used to build a new object of type Person, with each -XML element becoming an attribute on the object. - - ryan.is_a? Person #=> true - ryan.attribute1 #=> 'value1' - -Any complex element (one that contains other elements) becomes its own object: - - # With this response: - # - # <person><id>1</id><attribute1>value1</attribute1><complex><attribute2>value2</attribute2></complex></person> - # - # for GET http://api.people.com:3000/people/1.xml - # - ryan = Person.find(1) - ryan.complex #=> <Person::Complex::xxxxx> - ryan.complex.attribute2 #=> 'value2' - -Collections can also be requested in a similar fashion - - # Expects a response of - # - # <people type="array"> - # <person><id type="integer">1</id><first>Ryan</first></person> - # <person><id type="integer">2</id><first>Jim</first></person> - # </people> - # - # for GET http://api.people.com:3000/people.xml - # - people = Person.find(:all) - people.first #=> <Person::xxx 'first' => 'Ryan' ...> - people.last #=> <Person::xxx 'first' => 'Jim' ...> - -==== Create - -Creating a new resource submits the xml form of the resource as the body of the request and expects -a 'Location' header in the response with the RESTful URL location of the newly created resource. The -id of the newly created resource is parsed out of the Location response header and automatically set -as the id of the ARes object. - - # <person><first>Ryan</first></person> - # - # is submitted as the body on - # - # POST http://api.people.com:3000/people.xml - # - # when save is called on a new Person object. An empty response is - # is expected with a 'Location' header value: - # - # Response (201): Location: http://api.people.com:3000/people/2 - # - ryan = Person.new(:first => 'Ryan') - ryan.new? #=> true - ryan.save #=> true - ryan.new? #=> false - ryan.id #=> 2 - -==== Update - -'save' is also used to update an existing resource - and follows the same protocol as creating a resource -with the exception that no response headers are needed - just an empty response when the update on the -server side was successful. - - # <person><first>Ryan</first></person> - # - # is submitted as the body on - # - # PUT http://api.people.com:3000/people/1.xml - # - # when save is called on an existing Person object. An empty response is - # is expected with code (204) - # - ryan = Person.find(1) - ryan.first #=> 'Ryan' - ryan.first = 'Rizzle' - ryan.save #=> true - -==== Delete - -Destruction of a resource can be invoked as a class and instance method of the resource. - - # A request is made to - # - # DELETE http://api.people.com:3000/people/1.xml - # - # for both of these forms. An empty response with - # is expected with response code (200) - # - ryan = Person.find(1) - ryan.destroy #=> true - ryan.exists? #=> false - Person.delete(2) #=> true - Person.exists?(2) #=> false - - -You can find more usage information in the ActiveResource::Base documentation. - diff --git a/vendor/rails/activeresource/Rakefile b/vendor/rails/activeresource/Rakefile deleted file mode 100644 index f153513d..00000000 --- a/vendor/rails/activeresource/Rakefile +++ /dev/null @@ -1,137 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rdoc/task' -require 'rake/packagetask' -require 'rubygems/package_task' - -require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version') - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'activeresource' -PKG_VERSION = ActiveResource::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "activerecord" -RUBY_FORGE_USER = "webster132" - -PKG_FILES = FileList[ - "lib/**/*", "test/**/*", "[A-Z]*", "Rakefile" -].exclude(/\bCVS\b|~$/) - -desc "Default Task" -task :default => [ :test ] - -# Run the unit tests - -Rake::TestTask.new { |t| - activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib" - t.libs << activesupport_path if File.directory?(activesupport_path) - t.libs << "test" - t.pattern = 'test/**/*_test.rb' - t.verbose = true - t.warning = true -} - - -# Generate the RDoc documentation - -RDoc::Task.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Active Resource -- Object-oriented REST services" - rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'CHANGELOG') - rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.rdoc_files.exclude('lib/activeresource.rb') -} - - -# Create compressed packages - -dist_dirs = [ "lib", "test", "examples", "dev-utils" ] - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = PKG_NAME - s.version = PKG_VERSION - s.summary = "Think Active Record for web resources." - s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.} - - s.files = [ "Rakefile", "README", "CHANGELOG" ] - dist_dirs.each do |dir| - s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } - end - - s.add_dependency('activesupport', '= 2.3.14' + PKG_BUILD) - - s.require_path = 'lib' - - s.extra_rdoc_files = %w( README ) - s.rdoc_options.concat ['--main', 'README'] - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activeresource" -end - -Gem::PackageTask.new(spec) do |p| - p.gem_spec = spec - p.need_tar = true - p.need_zip = true -end - -task :lines do - lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 - - for file_name in FileList["lib/active_resource/**/*.rb"] - next if file_name =~ /vendor/ - f = File.open(file_name) - - while line = f.gets - lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - codelines += 1 - end - puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" - - total_lines += lines - total_codelines += codelines - - lines, codelines = 0, 0 - end - - puts "Total: Lines #{total_lines}, LOC #{total_codelines}" -end - - -# Publishing ------------------------------------------------------ - -desc "Publish the beta gem" -task :pgem => [:package] do - require 'rake/contrib/sshpublisher' - Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` -end - -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - require 'rake/contrib/sshpublisher' - Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - `rubyforge login` - - for ext in %w( gem tgz zip ) - release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" - puts release_command - system(release_command) - end -end diff --git a/vendor/rails/activeresource/lib/active_resource.rb b/vendor/rails/activeresource/lib/active_resource.rb deleted file mode 100644 index db900706..00000000 --- a/vendor/rails/activeresource/lib/active_resource.rb +++ /dev/null @@ -1,44 +0,0 @@ -#-- -# Copyright (c) 2006 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end - -require 'active_resource/formats' -require 'active_resource/base' -require 'active_resource/validations' -require 'active_resource/custom_methods' - -module ActiveResource - Base.class_eval do - include Validations - include CustomMethods - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/base.rb b/vendor/rails/activeresource/lib/active_resource/base.rb deleted file mode 100644 index 94b2322c..00000000 --- a/vendor/rails/activeresource/lib/active_resource/base.rb +++ /dev/null @@ -1,1166 +0,0 @@ -require 'active_resource/connection' -require 'cgi' -require 'set' - -module ActiveResource - # ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application. - # - # For an outline of what Active Resource is capable of, see link:files/vendor/rails/activeresource/README.html. - # - # == Automated mapping - # - # Active Resource objects represent your RESTful resources as manipulatable Ruby objects. To map resources - # to Ruby objects, Active Resource only needs a class name that corresponds to the resource name (e.g., the class - # Person maps to the resources people, very similarly to Active Record) and a +site+ value, which holds the - # URI of the resources. - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # end - # - # Now the Person class is mapped to RESTful resources located at <tt>http://api.people.com:3000/people/</tt>, and - # you can now use Active Resource's lifecycles methods to manipulate resources. In the case where you already have - # an existing model with the same name as the desired RESTful resource you can set the +element_name+ value. - # - # class PersonResource < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # self.element_name = "person" - # end - # - # - # == Lifecycle methods - # - # Active Resource exposes methods for creating, finding, updating, and deleting resources - # from REST web services. - # - # ryan = Person.new(:first => 'Ryan', :last => 'Daigle') - # ryan.save # => true - # ryan.id # => 2 - # Person.exists?(ryan.id) # => true - # ryan.exists? # => true - # - # ryan = Person.find(1) - # # Resource holding our newly created Person object - # - # ryan.first = 'Rizzle' - # ryan.save # => true - # - # ryan.destroy # => true - # - # As you can see, these are very similar to Active Record's lifecycle methods for database records. - # You can read more about each of these methods in their respective documentation. - # - # === Custom REST methods - # - # Since simple CRUD/lifecycle methods can't accomplish every task, Active Resource also supports - # defining your own custom REST methods. To invoke them, Active Resource provides the <tt>get</tt>, - # <tt>post</tt>, <tt>put</tt> and <tt>\delete</tt> methods where you can specify a custom REST method - # name to invoke. - # - # # POST to the custom 'register' REST method, i.e. POST /people/new/register.xml. - # Person.new(:name => 'Ryan').post(:register) - # # => { :id => 1, :name => 'Ryan', :position => 'Clerk' } - # - # # PUT an update by invoking the 'promote' REST method, i.e. PUT /people/1/promote.xml?position=Manager. - # Person.find(1).put(:promote, :position => 'Manager') - # # => { :id => 1, :name => 'Ryan', :position => 'Manager' } - # - # # GET all the positions available, i.e. GET /people/positions.xml. - # Person.get(:positions) - # # => [{:name => 'Manager'}, {:name => 'Clerk'}] - # - # # DELETE to 'fire' a person, i.e. DELETE /people/1/fire.xml. - # Person.find(1).delete(:fire) - # - # For more information on using custom REST methods, see the - # ActiveResource::CustomMethods documentation. - # - # == Validations - # - # You can validate resources client side by overriding validation methods in the base class. - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # protected - # def validate - # errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/ - # end - # end - # - # See the ActiveResource::Validations documentation for more information. - # - # == Authentication - # - # Many REST APIs will require authentication, usually in the form of basic - # HTTP authentication. Authentication can be specified by: - # - # === HTTP Basic Authentication - # * putting the credentials in the URL for the +site+ variable. - # - # class Person < ActiveResource::Base - # self.site = "http://ryan:password@api.people.com:3000/" - # end - # - # * defining +user+ and/or +password+ variables - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # self.user = "ryan" - # self.password = "password" - # end - # - # For obvious security reasons, it is probably best if such services are available - # over HTTPS. - # - # Note: Some values cannot be provided in the URL passed to site. e.g. email addresses - # as usernames. In those situations you should use the separate user and password option. - # - # === Certificate Authentication - # - # * End point uses an X509 certificate for authentication. <tt>See ssl_options=</tt> for all options. - # - # class Person < ActiveResource::Base - # self.site = "https://secure.api.people.com/" - # self.ssl_options = {:cert => OpenSSL::X509::Certificate.new(File.open(pem_file)) - # :key => OpenSSL::PKey::RSA.new(File.open(pem_file)), - # :ca_path => "/path/to/OpenSSL/formatted/CA_Certs", - # :verify_mode => OpenSSL::SSL::VERIFY_PEER} - # end - # - # == Errors & Validation - # - # Error handling and validation is handled in much the same manner as you're used to seeing in - # Active Record. Both the response code in the HTTP response and the body of the response are used to - # indicate that an error occurred. - # - # === Resource errors - # - # When a GET is requested for a resource that does not exist, the HTTP <tt>404</tt> (Resource Not Found) - # response code will be returned from the server which will raise an ActiveResource::ResourceNotFound - # exception. - # - # # GET http://api.people.com:3000/people/999.xml - # ryan = Person.find(999) # 404, raises ActiveResource::ResourceNotFound - # - # <tt>404</tt> is just one of the HTTP error response codes that Active Resource will handle with its own exception. The - # following HTTP response codes will also result in these exceptions: - # - # * 200..399 - Valid response, no exception (other than 301, 302) - # * 301, 302 - ActiveResource::Redirection - # * 400 - ActiveResource::BadRequest - # * 401 - ActiveResource::UnauthorizedAccess - # * 403 - ActiveResource::ForbiddenAccess - # * 404 - ActiveResource::ResourceNotFound - # * 405 - ActiveResource::MethodNotAllowed - # * 409 - ActiveResource::ResourceConflict - # * 410 - ActiveResource::ResourceGone - # * 422 - ActiveResource::ResourceInvalid (rescued by save as validation errors) - # * 401..499 - ActiveResource::ClientError - # * 500..599 - ActiveResource::ServerError - # * Other - ActiveResource::ConnectionError - # - # These custom exceptions allow you to deal with resource errors more naturally and with more precision - # rather than returning a general HTTP error. For example: - # - # begin - # ryan = Person.find(my_id) - # rescue ActiveResource::ResourceNotFound - # redirect_to :action => 'not_found' - # rescue ActiveResource::ResourceConflict, ActiveResource::ResourceInvalid - # redirect_to :action => 'new' - # end - # - # === Validation errors - # - # Active Resource supports validations on resources and will return errors if any these validations fail - # (e.g., "First name can not be blank" and so on). These types of errors are denoted in the response by - # a response code of <tt>422</tt> and an XML or JSON representation of the validation errors. The save operation will - # then fail (with a <tt>false</tt> return value) and the validation errors can be accessed on the resource in question. - # - # ryan = Person.find(1) - # ryan.first # => '' - # ryan.save # => false - # - # # When - # # PUT http://api.people.com:3000/people/1.xml - # # or - # # PUT http://api.people.com:3000/people/1.json - # # is requested with invalid values, the response is: - # # - # # Response (422): - # # <errors type="array"><error>First cannot be empty</error></errors> - # # or - # # {"errors":["First cannot be empty"]} - # # - # - # ryan.errors.invalid?(:first) # => true - # ryan.errors.full_messages # => ['First cannot be empty'] - # - # Learn more about Active Resource's validation features in the ActiveResource::Validations documentation. - # - # === Timeouts - # - # Active Resource relies on HTTP to access RESTful APIs and as such is inherently susceptible to slow or - # unresponsive servers. In such cases, your Active Resource method calls could \timeout. You can control the - # amount of time before Active Resource times out with the +timeout+ variable. - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # self.timeout = 5 - # end - # - # This sets the +timeout+ to 5 seconds. You can adjust the +timeout+ to a value suitable for the RESTful API - # you are accessing. It is recommended to set this to a reasonably low value to allow your Active Resource - # clients (especially if you are using Active Resource in a Rails application) to fail-fast (see - # http://en.wikipedia.org/wiki/Fail-fast) rather than cause cascading failures that could incapacitate your - # server. - # - # When a \timeout occurs, an ActiveResource::TimeoutError is raised. You should rescue from - # ActiveResource::TimeoutError in your Active Resource method calls. - # - # Internally, Active Resource relies on Ruby's Net::HTTP library to make HTTP requests. Setting +timeout+ - # sets the <tt>read_timeout</tt> of the internal Net::HTTP instance to the same value. The default - # <tt>read_timeout</tt> is 60 seconds on most Ruby implementations. - class Base - ## - # :singleton-method: - # The logger for diagnosing and tracing Active Resource calls. - cattr_accessor :logger - - # Controls the top-level behavior of JSON serialization - cattr_accessor :include_root_in_json, :instance_writer => false - - class << self - # Gets the URI of the REST resources to map for this class. The site variable is required for - # Active Resource's mapping to work. - def site - # Not using superclass_delegating_reader because don't want subclasses to modify superclass instance - # - # With superclass_delegating_reader - # - # Parent.site = 'http://anonymous@test.com' - # Subclass.site # => 'http://anonymous@test.com' - # Subclass.site.user = 'david' - # Parent.site # => 'http://david@test.com' - # - # Without superclass_delegating_reader (expected behaviour) - # - # Parent.site = 'http://anonymous@test.com' - # Subclass.site # => 'http://anonymous@test.com' - # Subclass.site.user = 'david' # => TypeError: can't modify frozen object - # - if defined?(@site) - @site - elsif superclass != Object && superclass.site - superclass.site.dup.freeze - end - end - - # Sets the URI of the REST resources to map for this class to the value in the +site+ argument. - # The site variable is required for Active Resource's mapping to work. - def site=(site) - @connection = nil - if site.nil? - @site = nil - else - @site = create_site_uri_from(site) - @user = URI.decode(@site.user) if @site.user - @password = URI.decode(@site.password) if @site.password - end - end - - # Gets the \proxy variable if a proxy is required - def proxy - # Not using superclass_delegating_reader. See +site+ for explanation - if defined?(@proxy) - @proxy - elsif superclass != Object && superclass.proxy - superclass.proxy.dup.freeze - end - end - - # Sets the URI of the http proxy to the value in the +proxy+ argument. - def proxy=(proxy) - @connection = nil - @proxy = proxy.nil? ? nil : create_proxy_uri_from(proxy) - end - - # Gets the \user for REST HTTP authentication. - def user - # Not using superclass_delegating_reader. See +site+ for explanation - if defined?(@user) - @user - elsif superclass != Object && superclass.user - superclass.user.dup.freeze - end - end - - # Sets the \user for REST HTTP authentication. - def user=(user) - @connection = nil - @user = user - end - - # Gets the \password for REST HTTP authentication. - def password - # Not using superclass_delegating_reader. See +site+ for explanation - if defined?(@password) - @password - elsif superclass != Object && superclass.password - superclass.password.dup.freeze - end - end - - # Sets the \password for REST HTTP authentication. - def password=(password) - @connection = nil - @password = password - end - - # Sets the format that attributes are sent and received in from a mime type reference: - # - # Person.format = :json - # Person.find(1) # => GET /people/1.json - # - # Person.format = ActiveResource::Formats::XmlFormat - # Person.find(1) # => GET /people/1.xml - # - # Default format is <tt>:xml</tt>. - def format=(mime_type_reference_or_format) - format = mime_type_reference_or_format.is_a?(Symbol) ? - ActiveResource::Formats[mime_type_reference_or_format] : mime_type_reference_or_format - - write_inheritable_attribute(:format, format) - connection.format = format if site - end - - # Returns the current format, default is ActiveResource::Formats::XmlFormat. - def format - read_inheritable_attribute(:format) || ActiveResource::Formats[:xml] - end - - # Sets the number of seconds after which requests to the REST API should time out. - def timeout=(timeout) - @connection = nil - @timeout = timeout - end - - # Gets the number of seconds after which requests to the REST API should time out. - def timeout - if defined?(@timeout) - @timeout - elsif superclass != Object && superclass.timeout - superclass.timeout - end - end - - # Options that will get applied to an SSL connection. - # - # * <tt>:key</tt> - An OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. - # * <tt>:cert</tt> - An OpenSSL::X509::Certificate object as client certificate - # * <tt>:ca_file</tt> - Path to a CA certification file in PEM format. The file can contrain several CA certificates. - # * <tt>:ca_path</tt> - Path of a CA certification directory containing certifications in PEM format. - # * <tt>:verify_mode</tt> - Flags for server the certification verification at begining of SSL/TLS session. (OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable) - # * <tt>:verify_callback</tt> - The verify callback for the server certification verification. - # * <tt>:verify_depth</tt> - The maximum depth for the certificate chain verification. - # * <tt>:cert_store</tt> - OpenSSL::X509::Store to verify peer certificate. - # * <tt>:ssl_timeout</tt> -The SSL timeout in seconds. - def ssl_options=(opts={}) - @connection = nil - @ssl_options = opts - end - - # Returns the SSL options hash. - def ssl_options - if defined?(@ssl_options) - @ssl_options - elsif superclass != Object && superclass.ssl_options - superclass.ssl_options - end - end - - # An instance of ActiveResource::Connection that is the base \connection to the remote service. - # The +refresh+ parameter toggles whether or not the \connection is refreshed at every request - # or not (defaults to <tt>false</tt>). - def connection(refresh = false) - if defined?(@connection) || superclass == Object - @connection = Connection.new(site, format) if refresh || @connection.nil? - @connection.proxy = proxy if proxy - @connection.user = user if user - @connection.password = password if password - @connection.timeout = timeout if timeout - @connection.ssl_options = ssl_options if ssl_options - @connection - else - superclass.connection - end - end - - def headers - @headers ||= {} - end - - # Do not include any modules in the default element name. This makes it easier to seclude ARes objects - # in a separate namespace without having to set element_name repeatedly. - attr_accessor_with_default(:element_name) { to_s.split("::").last.underscore } #:nodoc: - - attr_accessor_with_default(:collection_name) { element_name.pluralize } #:nodoc: - attr_accessor_with_default(:primary_key, 'id') #:nodoc: - - # Gets the \prefix for a resource's nested URL (e.g., <tt>prefix/collectionname/1.xml</tt>) - # This method is regenerated at runtime based on what the \prefix is set to. - def prefix(options={}) - default = site.path - default << '/' unless default[-1..-1] == '/' - # generate the actual method based on the current site path - self.prefix = default - prefix(options) - end - - # An attribute reader for the source string for the resource path \prefix. This - # method is regenerated at runtime based on what the \prefix is set to. - def prefix_source - prefix # generate #prefix and #prefix_source methods first - prefix_source - end - - # Sets the \prefix for a resource's nested URL (e.g., <tt>prefix/collectionname/1.xml</tt>). - # Default value is <tt>site.path</tt>. - def prefix=(value = '/') - # Replace :placeholders with '#{embedded options[:lookups]}' - prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" } - - # Clear prefix parameters in case they have been cached - @prefix_parameters = nil - - # Redefine the new methods. - code, line = <<-end_code, __LINE__ + 1 - def prefix_source() "#{value}" end - def prefix(options={}) "#{prefix_call}" end - end_code - silence_warnings { instance_eval code, __FILE__, line } - rescue - logger.error "Couldn't set prefix: #{$!}\n #{code}" - raise - end - - alias_method :set_prefix, :prefix= #:nodoc: - - alias_method :set_element_name, :element_name= #:nodoc: - alias_method :set_collection_name, :collection_name= #:nodoc: - - # Gets the element path for the given ID in +id+. If the +query_options+ parameter is omitted, Rails - # will split from the \prefix options. - # - # ==== Options - # +prefix_options+ - A \hash to add a \prefix to the request for nested URLs (e.g., <tt>:account_id => 19</tt> - # would yield a URL like <tt>/accounts/19/purchases.xml</tt>). - # +query_options+ - A \hash to add items to the query string for the request. - # - # ==== Examples - # Post.element_path(1) - # # => /posts/1.xml - # - # Comment.element_path(1, :post_id => 5) - # # => /posts/5/comments/1.xml - # - # Comment.element_path(1, :post_id => 5, :active => 1) - # # => /posts/5/comments/1.xml?active=1 - # - # Comment.element_path(1, {:post_id => 5}, {:active => 1}) - # # => /posts/5/comments/1.xml?active=1 - # - def element_path(id, prefix_options = {}, query_options = nil) - prefix_options, query_options = split_options(prefix_options) if query_options.nil? - "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}" - end - - # Gets the collection path for the REST resources. If the +query_options+ parameter is omitted, Rails - # will split from the +prefix_options+. - # - # ==== Options - # * +prefix_options+ - A hash to add a prefix to the request for nested URL's (e.g., <tt>:account_id => 19</tt> - # would yield a URL like <tt>/accounts/19/purchases.xml</tt>). - # * +query_options+ - A hash to add items to the query string for the request. - # - # ==== Examples - # Post.collection_path - # # => /posts.xml - # - # Comment.collection_path(:post_id => 5) - # # => /posts/5/comments.xml - # - # Comment.collection_path(:post_id => 5, :active => 1) - # # => /posts/5/comments.xml?active=1 - # - # Comment.collection_path({:post_id => 5}, {:active => 1}) - # # => /posts/5/comments.xml?active=1 - # - def collection_path(prefix_options = {}, query_options = nil) - prefix_options, query_options = split_options(prefix_options) if query_options.nil? - "#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}" - end - - alias_method :set_primary_key, :primary_key= #:nodoc: - - # Creates a new resource instance and makes a request to the remote service - # that it be saved, making it equivalent to the following simultaneous calls: - # - # ryan = Person.new(:first => 'ryan') - # ryan.save - # - # Returns the newly created resource. If a failure has occurred an - # exception will be raised (see <tt>save</tt>). If the resource is invalid and - # has not been saved then <tt>valid?</tt> will return <tt>false</tt>, - # while <tt>new?</tt> will still return <tt>true</tt>. - # - # ==== Examples - # Person.create(:name => 'Jeremy', :email => 'myname@nospam.com', :enabled => true) - # my_person = Person.find(:first) - # my_person.email # => myname@nospam.com - # - # dhh = Person.create(:name => 'David', :email => 'dhh@nospam.com', :enabled => true) - # dhh.valid? # => true - # dhh.new? # => false - # - # # We'll assume that there's a validation that requires the name attribute - # that_guy = Person.create(:name => '', :email => 'thatguy@nospam.com', :enabled => true) - # that_guy.valid? # => false - # that_guy.new? # => true - def create(attributes = {}) - self.new(attributes).tap { |resource| resource.save } - end - - # Core method for finding resources. Used similarly to Active Record's +find+ method. - # - # ==== Arguments - # The first argument is considered to be the scope of the query. That is, how many - # resources are returned from the request. It can be one of the following. - # - # * <tt>:one</tt> - Returns a single resource. - # * <tt>:first</tt> - Returns the first resource found. - # * <tt>:last</tt> - Returns the last resource found. - # * <tt>:all</tt> - Returns every resource that matches the request. - # - # ==== Options - # - # * <tt>:from</tt> - Sets the path or custom method that resources will be fetched from. - # * <tt>:params</tt> - Sets query and \prefix (nested URL) parameters. - # - # ==== Examples - # Person.find(1) - # # => GET /people/1.xml - # - # Person.find(:all) - # # => GET /people.xml - # - # Person.find(:all, :params => { :title => "CEO" }) - # # => GET /people.xml?title=CEO - # - # Person.find(:first, :from => :managers) - # # => GET /people/managers.xml - # - # Person.find(:last, :from => :managers) - # # => GET /people/managers.xml - # - # Person.find(:all, :from => "/companies/1/people.xml") - # # => GET /companies/1/people.xml - # - # Person.find(:one, :from => :leader) - # # => GET /people/leader.xml - # - # Person.find(:all, :from => :developers, :params => { :language => 'ruby' }) - # # => GET /people/developers.xml?language=ruby - # - # Person.find(:one, :from => "/companies/1/manager.xml") - # # => GET /companies/1/manager.xml - # - # StreetAddress.find(1, :params => { :person_id => 1 }) - # # => GET /people/1/street_addresses/1.xml - def find(*arguments) - scope = arguments.slice!(0) - options = arguments.slice!(0) || {} - - case scope - when :all then find_every(options) - when :first then find_every(options).first - when :last then find_every(options).last - when :one then find_one(options) - else find_single(scope, options) - end - end - - # Deletes the resources with the ID in the +id+ parameter. - # - # ==== Options - # All options specify \prefix and query parameters. - # - # ==== Examples - # Event.delete(2) # sends DELETE /events/2 - # - # Event.create(:name => 'Free Concert', :location => 'Community Center') - # my_event = Event.find(:first) # let's assume this is event with ID 7 - # Event.delete(my_event.id) # sends DELETE /events/7 - # - # # Let's assume a request to events/5/cancel.xml - # Event.delete(params[:id]) # sends DELETE /events/5 - def delete(id, options = {}) - connection.delete(element_path(id, options)) - end - - # Asserts the existence of a resource, returning <tt>true</tt> if the resource is found. - # - # ==== Examples - # Note.create(:title => 'Hello, world.', :body => 'Nothing more for now...') - # Note.exists?(1) # => true - # - # Note.exists(1349) # => false - def exists?(id, options = {}) - if id - prefix_options, query_options = split_options(options[:params]) - path = element_path(id, prefix_options, query_options) - response = connection.head(path, headers) - response.code.to_i == 200 - end - # id && !find_single(id, options).nil? - rescue ActiveResource::ResourceNotFound, ActiveResource::ResourceGone - false - end - - private - # Find every resource - def find_every(options) - case from = options[:from] - when Symbol - instantiate_collection(get(from, options[:params])) - when String - path = "#{from}#{query_string(options[:params])}" - instantiate_collection(connection.get(path, headers) || []) - else - prefix_options, query_options = split_options(options[:params]) - path = collection_path(prefix_options, query_options) - instantiate_collection( (connection.get(path, headers) || []), prefix_options ) - end - end - - # Find a single resource from a one-off URL - def find_one(options) - case from = options[:from] - when Symbol - instantiate_record(get(from, options[:params])) - when String - path = "#{from}#{query_string(options[:params])}" - instantiate_record(connection.get(path, headers)) - end - end - - # Find a single resource from the default URL - def find_single(scope, options) - prefix_options, query_options = split_options(options[:params]) - path = element_path(scope, prefix_options, query_options) - instantiate_record(connection.get(path, headers), prefix_options) - end - - def instantiate_collection(collection, prefix_options = {}) - collection.collect! { |record| instantiate_record(record, prefix_options) } - end - - def instantiate_record(record, prefix_options = {}) - new(record).tap do |resource| - resource.prefix_options = prefix_options - end - end - - - # Accepts a URI and creates the site URI from that. - def create_site_uri_from(site) - site.is_a?(URI) ? site.dup : URI.parse(site) - end - - # Accepts a URI and creates the proxy URI from that. - def create_proxy_uri_from(proxy) - proxy.is_a?(URI) ? proxy.dup : URI.parse(proxy) - end - - # contains a set of the current prefix parameters. - def prefix_parameters - @prefix_parameters ||= prefix_source.scan(/:\w+/).map { |key| key[1..-1].to_sym }.to_set - end - - # Builds the query string for the request. - def query_string(options) - "?#{options.to_query}" unless options.nil? || options.empty? - end - - # split an option hash into two hashes, one containing the prefix options, - # and the other containing the leftovers. - def split_options(options = {}) - prefix_options, query_options = {}, {} - - (options || {}).each do |key, value| - next if key.blank? - (prefix_parameters.include?(key.to_sym) ? prefix_options : query_options)[key.to_sym] = value - end - - [ prefix_options, query_options ] - end - end - - attr_accessor :attributes #:nodoc: - attr_accessor :prefix_options #:nodoc: - - # Constructor method for \new resources; the optional +attributes+ parameter takes a \hash - # of attributes for the \new resource. - # - # ==== Examples - # my_course = Course.new - # my_course.name = "Western Civilization" - # my_course.lecturer = "Don Trotter" - # my_course.save - # - # my_other_course = Course.new(:name => "Philosophy: Reason and Being", :lecturer => "Ralph Cling") - # my_other_course.save - def initialize(attributes = {}) - @attributes = {} - @prefix_options = {} - load(attributes) - end - - # Returns a \clone of the resource that hasn't been assigned an +id+ yet and - # is treated as a \new resource. - # - # ryan = Person.find(1) - # not_ryan = ryan.clone - # not_ryan.new? # => true - # - # Any active resource member attributes will NOT be cloned, though all other - # attributes are. This is to prevent the conflict between any +prefix_options+ - # that refer to the original parent resource and the newly cloned parent - # resource that does not exist. - # - # ryan = Person.find(1) - # ryan.address = StreetAddress.find(1, :person_id => ryan.id) - # ryan.hash = {:not => "an ARes instance"} - # - # not_ryan = ryan.clone - # not_ryan.new? # => true - # not_ryan.address # => NoMethodError - # not_ryan.hash # => {:not => "an ARes instance"} - def clone - # Clone all attributes except the pk and any nested ARes - cloned = attributes.reject {|k,v| k == self.class.primary_key || v.is_a?(ActiveResource::Base)}.inject({}) do |attrs, (k, v)| - attrs[k] = v.clone - attrs - end - # Form the new resource - bypass initialize of resource with 'new' as that will call 'load' which - # attempts to convert hashes into member objects and arrays into collections of objects. We want - # the raw objects to be cloned so we bypass load by directly setting the attributes hash. - resource = self.class.new({}) - resource.prefix_options = self.prefix_options - resource.send :instance_variable_set, '@attributes', cloned - resource - end - - - # A method to determine if the resource a \new object (i.e., it has not been POSTed to the remote service yet). - # - # ==== Examples - # not_new = Computer.create(:brand => 'Apple', :make => 'MacBook', :vendor => 'MacMall') - # not_new.new? # => false - # - # is_new = Computer.new(:brand => 'IBM', :make => 'Thinkpad', :vendor => 'IBM') - # is_new.new? # => true - # - # is_new.save - # is_new.new? # => false - # - def new? - id.nil? - end - alias :new_record? :new? - - # Gets the <tt>\id</tt> attribute of the resource. - def id - attributes[self.class.primary_key] - end - - # Sets the <tt>\id</tt> attribute of the resource. - def id=(id) - attributes[self.class.primary_key] = id - end - - # Allows Active Resource objects to be used as parameters in Action Pack URL generation. - def to_param - id && id.to_s - end - - # Test for equality. Resource are equal if and only if +other+ is the same object or - # is an instance of the same class, is not <tt>new?</tt>, and has the same +id+. - # - # ==== Examples - # ryan = Person.create(:name => 'Ryan') - # jamie = Person.create(:name => 'Jamie') - # - # ryan == jamie - # # => false (Different name attribute and id) - # - # ryan_again = Person.new(:name => 'Ryan') - # ryan == ryan_again - # # => false (ryan_again is new?) - # - # ryans_clone = Person.create(:name => 'Ryan') - # ryan == ryans_clone - # # => false (Different id attributes) - # - # ryans_twin = Person.find(ryan.id) - # ryan == ryans_twin - # # => true - # - def ==(other) - other.equal?(self) || (other.instance_of?(self.class) && other.id == id && other.prefix_options == prefix_options) - end - - # Tests for equality (delegates to ==). - def eql?(other) - self == other - end - - # Delegates to id in order to allow two resources of the same type and \id to work with something like: - # [Person.find(1), Person.find(2)] & [Person.find(1), Person.find(4)] # => [Person.find(1)] - def hash - id.hash - end - - # Duplicate the current resource without saving it. - # - # ==== Examples - # my_invoice = Invoice.create(:customer => 'That Company') - # next_invoice = my_invoice.dup - # next_invoice.new? # => true - # - # next_invoice.save - # next_invoice == my_invoice # => false (different id attributes) - # - # my_invoice.customer # => That Company - # next_invoice.customer # => That Company - def dup - self.class.new.tap do |resource| - resource.attributes = @attributes - resource.prefix_options = @prefix_options - end - end - - # A method to \save (+POST+) or \update (+PUT+) a resource. It delegates to +create+ if a \new object, - # +update+ if it is existing. If the response to the \save includes a body, it will be assumed that this body - # is XML for the final object as it looked after the \save (which would include attributes like +created_at+ - # that weren't part of the original submit). - # - # ==== Examples - # my_company = Company.new(:name => 'RoleModel Software', :owner => 'Ken Auer', :size => 2) - # my_company.new? # => true - # my_company.save # sends POST /companies/ (create) - # - # my_company.new? # => false - # my_company.size = 10 - # my_company.save # sends PUT /companies/1 (update) - def save - new? ? create : update - end - - # Deletes the resource from the remote service. - # - # ==== Examples - # my_id = 3 - # my_person = Person.find(my_id) - # my_person.destroy - # Person.find(my_id) # 404 (Resource Not Found) - # - # new_person = Person.create(:name => 'James') - # new_id = new_person.id # => 7 - # new_person.destroy - # Person.find(new_id) # 404 (Resource Not Found) - def destroy - connection.delete(element_path, self.class.headers) - end - - # Evaluates to <tt>true</tt> if this resource is not <tt>new?</tt> and is - # found on the remote service. Using this method, you can check for - # resources that may have been deleted between the object's instantiation - # and actions on it. - # - # ==== Examples - # Person.create(:name => 'Theodore Roosevelt') - # that_guy = Person.find(:first) - # that_guy.exists? # => true - # - # that_lady = Person.new(:name => 'Paul Bean') - # that_lady.exists? # => false - # - # guys_id = that_guy.id - # Person.delete(guys_id) - # that_guy.exists? # => false - def exists? - !new? && self.class.exists?(to_param, :params => prefix_options) - end - - # Converts the resource to an XML string representation. - # - # ==== Options - # The +options+ parameter is handed off to the +to_xml+ method on each - # attribute, so it has the same options as the +to_xml+ methods in - # Active Support. - # - # * <tt>:indent</tt> - Set the indent level for the XML output (default is +2+). - # * <tt>:dasherize</tt> - Boolean option to determine whether or not element names should - # replace underscores with dashes. Default is <tt>true</tt>. The default can be set to <tt>false</tt> - # by setting the module attribute <tt>ActiveSupport.dasherize_xml = false</tt> in an initializer. Because save - # uses this method, and there are no options on save, then you will have to set the default if you don't - # want underscores in element names to become dashes when the resource is saved. This is important when - # integrating with non-Rails applications. - # * <tt>:camelize</tt> - Boolean option to determine whether or not element names should be converted - # to camel case, e.g some_name to SomeName. Default is <tt>false</tt>. Like <tt>:dasherize</tt> you can - # change the default by setting the module attribute <tt>ActiveSupport.camelise_xml = true</tt> in an initializer. - # * <tt>:skip_instruct</tt> - Toggle skipping the +instruct!+ call on the XML builder - # that generates the XML declaration (default is <tt>false</tt>). - # - # ==== Examples - # my_group = SubsidiaryGroup.find(:first) - # my_group.to_xml - # # => <?xml version="1.0" encoding="UTF-8"?> - # # <subsidiary_group> [...] </subsidiary_group> - # - # my_group.to_xml(:dasherize => true) - # # => <?xml version="1.0" encoding="UTF-8"?> - # # <subsidiary-group> [...] </subsidiary-group> - # - # my_group.to_xml(:skip_instruct => true) - # # => <subsidiary_group> [...] </subsidiary_group> - def to_xml(options={}) - attributes.to_xml({:root => self.class.element_name}.merge(options)) - end - - # Coerces to a hash for JSON encoding. - # - # ==== Options - # The +options+ are passed to the +to_json+ method on each - # attribute, so the same options as the +to_json+ methods in - # Active Support. - # - # * <tt>:only</tt> - Only include the specified attribute or list of - # attributes in the serialized output. Attribute names must be specified - # as strings. - # * <tt>:except</tt> - Do not include the specified attribute or list of - # attributes in the serialized output. Attribute names must be specified - # as strings. - # - # ==== Examples - # person = Person.new(:first_name => "Jim", :last_name => "Smith") - # person.to_json - # # => {"first_name": "Jim", "last_name": "Smith"} - # - # person.to_json(:only => ["first_name"]) - # # => {"first_name": "Jim"} - # - # person.to_json(:except => ["first_name"]) - # # => {"last_name": "Smith"} - def as_json(options = nil) - attributes.as_json(options) - end - - # Returns the serialized string representation of the resource in the configured - # serialization format specified in ActiveResource::Base.format. The options - # applicable depend on the configured encoding format. - def encode(options={}) - case self.class.format - when ActiveResource::Formats[:xml] - self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options)) - when ActiveResource::Formats::JsonFormat - if ActiveResource::Base.include_root_in_json - self.class.format.encode({self.class.element_name => attributes}, options) - else - self.class.format.encode(attributes, options) - end - else - self.class.format.encode(attributes, options) - end - end - - # A method to \reload the attributes of this object from the remote web service. - # - # ==== Examples - # my_branch = Branch.find(:first) - # my_branch.name # => "Wislon Raod" - # - # # Another client fixes the typo... - # - # my_branch.name # => "Wislon Raod" - # my_branch.reload - # my_branch.name # => "Wilson Road" - def reload - self.load(self.class.find(to_param, :params => @prefix_options).attributes) - end - - # A method to manually load attributes from a \hash. Recursively loads collections of - # resources. This method is called in +initialize+ and +create+ when a \hash of attributes - # is provided. - # - # ==== Examples - # my_attrs = {:name => 'J&J Textiles', :industry => 'Cloth and textiles'} - # my_attrs = {:name => 'Marty', :colors => ["red", "green", "blue"]} - # - # the_supplier = Supplier.find(:first) - # the_supplier.name # => 'J&M Textiles' - # the_supplier.load(my_attrs) - # the_supplier.name('J&J Textiles') - # - # # These two calls are the same as Supplier.new(my_attrs) - # my_supplier = Supplier.new - # my_supplier.load(my_attrs) - # - # # These three calls are the same as Supplier.create(my_attrs) - # your_supplier = Supplier.new - # your_supplier.load(my_attrs) - # your_supplier.save - def load(attributes) - raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash) - @prefix_options, attributes = split_options(attributes) - attributes.each do |key, value| - @attributes[key.to_s] = - case value - when Array - resource = find_or_create_resource_for_collection(key) - value.map do |attrs| - if attrs.is_a?(String) || attrs.is_a?(Numeric) - attrs.duplicable? ? attrs.dup : attrs - else - resource.new(attrs) - end - end - when Hash - resource = find_or_create_resource_for(key) - resource.new(value) - else - value.dup rescue value - end - end - self - end - - # For checking <tt>respond_to?</tt> without searching the attributes (which is faster). - alias_method :respond_to_without_attributes?, :respond_to? - - # A method to determine if an object responds to a message (e.g., a method call). In Active Resource, a Person object with a - # +name+ attribute can answer <tt>true</tt> to <tt>my_person.respond_to?(:name)</tt>, <tt>my_person.respond_to?(:name=)</tt>, and - # <tt>my_person.respond_to?(:name?)</tt>. - def respond_to?(method, include_priv = false) - method_name = method.to_s - if attributes.nil? - return super - elsif attributes.has_key?(method_name) - return true - elsif ['?','='].include?(method_name.last) && attributes.has_key?(method_name.first(-1)) - return true - end - # super must be called at the end of the method, because the inherited respond_to? - # would return true for generated readers, even if the attribute wasn't present - super - end - - - protected - def connection(refresh = false) - self.class.connection(refresh) - end - - # Update the resource on the remote service. - def update - connection.put(element_path(prefix_options), encode, self.class.headers).tap do |response| - load_attributes_from_response(response) - end - end - - # Create (i.e., \save to the remote service) the \new resource. - def create - connection.post(collection_path, encode, self.class.headers).tap do |response| - self.id = id_from_response(response) - load_attributes_from_response(response) - end - end - - def load_attributes_from_response(response) - if response['Content-Length'] != "0" && response.body.strip.size > 0 - load(self.class.format.decode(response.body)) - end - end - - # Takes a response from a typical create post and pulls the ID out - def id_from_response(response) - response['Location'][/\/([^\/]*?)(\.\w+)?$/, 1] if response['Location'] - end - - def element_path(options = nil) - self.class.element_path(to_param, options || prefix_options) - end - - def collection_path(options = nil) - self.class.collection_path(options || prefix_options) - end - - private - # Tries to find a resource for a given collection name; if it fails, then the resource is created - def find_or_create_resource_for_collection(name) - find_or_create_resource_for(name.to_s.singularize) - end - - # Tries to find a resource in a non empty list of nested modules - # Raises a NameError if it was not found in any of the given nested modules - def find_resource_in_modules(resource_name, module_names) - receiver = Object - namespaces = module_names[0, module_names.size-1].map do |module_name| - receiver = receiver.const_get(module_name) - end - if namespace = namespaces.reverse.detect { |ns| ns.const_defined?(resource_name) } - return namespace.const_get(resource_name) - else - raise NameError - end - end - - # Tries to find a resource for a given name; if it fails, then the resource is created - def find_or_create_resource_for(name) - resource_name = name.to_s.camelize - ancestors = self.class.name.split("::") - if ancestors.size > 1 - find_resource_in_modules(resource_name, ancestors) - else - self.class.const_get(resource_name) - end - rescue NameError - if self.class.const_defined?(resource_name) - resource = self.class.const_get(resource_name) - else - resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base)) - end - resource.prefix = self.class.prefix - resource.site = self.class.site - resource - end - - def split_options(options = {}) - self.class.__send__(:split_options, options) - end - - def method_missing(method_symbol, *arguments) #:nodoc: - method_name = method_symbol.to_s - - case method_name.last - when "=" - attributes[method_name.first(-1)] = arguments.first - when "?" - attributes[method_name.first(-1)] - else - attributes.has_key?(method_name) ? attributes[method_name] : super - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/connection.rb b/vendor/rails/activeresource/lib/active_resource/connection.rb deleted file mode 100644 index 768b8c99..00000000 --- a/vendor/rails/activeresource/lib/active_resource/connection.rb +++ /dev/null @@ -1,283 +0,0 @@ -require 'net/https' -require 'date' -require 'time' -require 'uri' -require 'benchmark' - -module ActiveResource - class ConnectionError < StandardError # :nodoc: - attr_reader :response - - def initialize(response, message = nil) - @response = response - @message = message - end - - def to_s - "Failed with #{response.code} #{response.message if response.respond_to?(:message)}" - end - end - - # Raised when a Timeout::Error occurs. - class TimeoutError < ConnectionError - def initialize(message) - @message = message - end - def to_s; @message ;end - end - - # Raised when a OpenSSL::SSL::SSLError occurs. - class SSLError < ConnectionError - def initialize(message) - @message = message - end - def to_s; @message ;end - end - - # 3xx Redirection - class Redirection < ConnectionError # :nodoc: - def to_s; response['Location'] ? "#{super} => #{response['Location']}" : super; end - end - - # 4xx Client Error - class ClientError < ConnectionError; end # :nodoc: - - # 400 Bad Request - class BadRequest < ClientError; end # :nodoc - - # 401 Unauthorized - class UnauthorizedAccess < ClientError; end # :nodoc - - # 403 Forbidden - class ForbiddenAccess < ClientError; end # :nodoc - - # 404 Not Found - class ResourceNotFound < ClientError; end # :nodoc: - - # 409 Conflict - class ResourceConflict < ClientError; end # :nodoc: - - # 410 Gone - class ResourceGone < ClientError; end # :nodoc: - - # 5xx Server Error - class ServerError < ConnectionError; end # :nodoc: - - # 405 Method Not Allowed - class MethodNotAllowed < ClientError # :nodoc: - def allowed_methods - @response['Allow'].split(',').map { |verb| verb.strip.downcase.to_sym } - end - end - - # Class to handle connections to remote web services. - # This class is used by ActiveResource::Base to interface with REST - # services. - class Connection - - HTTP_FORMAT_HEADER_NAMES = { :get => 'Accept', - :put => 'Content-Type', - :post => 'Content-Type', - :delete => 'Accept', - :head => 'Accept' - } - - attr_reader :site, :user, :password, :timeout, :proxy, :ssl_options - attr_accessor :format - - class << self - def requests - @@requests ||= [] - end - end - - # The +site+ parameter is required and will set the +site+ - # attribute to the URI for the remote resource service. - def initialize(site, format = ActiveResource::Formats[:xml]) - raise ArgumentError, 'Missing site URI' unless site - @user = @password = nil - self.site = site - self.format = format - end - - # Set URI for remote service. - def site=(site) - @site = site.is_a?(URI) ? site : URI.parse(site) - @user = URI.decode(@site.user) if @site.user - @password = URI.decode(@site.password) if @site.password - end - - # Set the proxy for remote service. - def proxy=(proxy) - @proxy = proxy.is_a?(URI) ? proxy : URI.parse(proxy) - end - - # Set the user for remote service. - def user=(user) - @user = user - end - - # Set password for remote service. - def password=(password) - @password = password - end - - # Set the number of seconds after which HTTP requests to the remote service should time out. - def timeout=(timeout) - @timeout = timeout - end - - # Hash of options applied to Net::HTTP instance when +site+ protocol is 'https'. - def ssl_options=(opts={}) - @ssl_options = opts - end - - # Execute a GET request. - # Used to get (find) resources. - def get(path, headers = {}) - format.decode(request(:get, path, build_request_headers(headers, :get)).body) - end - - # Execute a DELETE request (see HTTP protocol documentation if unfamiliar). - # Used to delete resources. - def delete(path, headers = {}) - request(:delete, path, build_request_headers(headers, :delete)) - end - - # Execute a PUT request (see HTTP protocol documentation if unfamiliar). - # Used to update resources. - def put(path, body = '', headers = {}) - request(:put, path, body.to_s, build_request_headers(headers, :put)) - end - - # Execute a POST request. - # Used to create new resources. - def post(path, body = '', headers = {}) - request(:post, path, body.to_s, build_request_headers(headers, :post)) - end - - # Execute a HEAD request. - # Used to obtain meta-information about resources, such as whether they exist and their size (via response headers). - def head(path, headers = {}) - request(:head, path, build_request_headers(headers, :head)) - end - - - private - # Makes request to remote service. - def request(method, path, *arguments) - logger.info "#{method.to_s.upcase} #{site.scheme}://#{site.host}:#{site.port}#{path}" if logger - result = nil - ms = Benchmark.ms { result = http.send(method, path, *arguments) } - logger.info "--> %d %s (%d %.0fms)" % [result.code, result.message, result.body ? result.body.length : 0, ms] if logger - handle_response(result) - rescue Timeout::Error => e - raise TimeoutError.new(e.message) - rescue OpenSSL::SSL::SSLError => e - raise SSLError.new(e.message) - end - - # Handles response and error codes from remote service. - def handle_response(response) - case response.code.to_i - when 301,302 - raise(Redirection.new(response)) - when 200...400 - response - when 400 - raise(BadRequest.new(response)) - when 401 - raise(UnauthorizedAccess.new(response)) - when 403 - raise(ForbiddenAccess.new(response)) - when 404 - raise(ResourceNotFound.new(response)) - when 405 - raise(MethodNotAllowed.new(response)) - when 409 - raise(ResourceConflict.new(response)) - when 410 - raise(ResourceGone.new(response)) - when 422 - raise(ResourceInvalid.new(response)) - when 401...500 - raise(ClientError.new(response)) - when 500...600 - raise(ServerError.new(response)) - else - raise(ConnectionError.new(response, "Unknown response code: #{response.code}")) - end - end - - # Creates new Net::HTTP instance for communication with - # remote service and resources. - def http - configure_http(new_http) - end - - def new_http - if @proxy - Net::HTTP.new(@site.host, @site.port, @proxy.host, @proxy.port, @proxy.user, @proxy.password) - else - Net::HTTP.new(@site.host, @site.port) - end - end - - def configure_http(http) - http = apply_ssl_options(http) - - # Net::HTTP timeouts default to 60 seconds. - if @timeout - http.open_timeout = @timeout - http.read_timeout = @timeout - end - - http - end - - def apply_ssl_options(http) - return http unless @site.is_a?(URI::HTTPS) - - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - return http unless defined?(@ssl_options) - - http.ca_path = @ssl_options[:ca_path] if @ssl_options[:ca_path] - http.ca_file = @ssl_options[:ca_file] if @ssl_options[:ca_file] - - http.cert = @ssl_options[:cert] if @ssl_options[:cert] - http.key = @ssl_options[:key] if @ssl_options[:key] - - http.cert_store = @ssl_options[:cert_store] if @ssl_options[:cert_store] - http.ssl_timeout = @ssl_options[:ssl_timeout] if @ssl_options[:ssl_timeout] - - http.verify_mode = @ssl_options[:verify_mode] if @ssl_options[:verify_mode] - http.verify_callback = @ssl_options[:verify_callback] if @ssl_options[:verify_callback] - http.verify_depth = @ssl_options[:verify_depth] if @ssl_options[:verify_depth] - - http - end - - def default_header - @default_header ||= {} - end - - # Builds headers for request to remote service. - def build_request_headers(headers, http_method=nil) - authorization_header.update(default_header).update(http_format_header(http_method)).update(headers) - end - - # Sets authorization header - def authorization_header - (@user || @password ? { 'Authorization' => 'Basic ' + ["#{@user}:#{ @password}"].pack('m').delete("\r\n") } : {}) - end - - def http_format_header(http_method) - {HTTP_FORMAT_HEADER_NAMES[http_method] => format.mime_type} - end - - def logger #:nodoc: - Base.logger - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/custom_methods.rb b/vendor/rails/activeresource/lib/active_resource/custom_methods.rb deleted file mode 100644 index 4647e834..00000000 --- a/vendor/rails/activeresource/lib/active_resource/custom_methods.rb +++ /dev/null @@ -1,120 +0,0 @@ -module ActiveResource - # A module to support custom REST methods and sub-resources, allowing you to break out - # of the "default" REST methods with your own custom resource requests. For example, - # say you use Rails to expose a REST service and configure your routes with: - # - # map.resources :people, :new => { :register => :post }, - # :member => { :promote => :put, :deactivate => :delete } - # :collection => { :active => :get } - # - # This route set creates routes for the following HTTP requests: - # - # POST /people/new/register.xml # PeopleController.register - # PUT /people/1/promote.xml # PeopleController.promote with :id => 1 - # DELETE /people/1/deactivate.xml # PeopleController.deactivate with :id => 1 - # GET /people/active.xml # PeopleController.active - # - # Using this module, Active Resource can use these custom REST methods just like the - # standard methods. - # - # class Person < ActiveResource::Base - # self.site = "http://37s.sunrise.i:3000" - # end - # - # Person.new(:name => 'Ryan).post(:register) # POST /people/new/register.xml - # # => { :id => 1, :name => 'Ryan' } - # - # Person.find(1).put(:promote, :position => 'Manager') # PUT /people/1/promote.xml - # Person.find(1).delete(:deactivate) # DELETE /people/1/deactivate.xml - # - # Person.get(:active) # GET /people/active.xml - # # => [{:id => 1, :name => 'Ryan'}, {:id => 2, :name => 'Joe'}] - # - module CustomMethods - def self.included(base) - base.class_eval do - extend ActiveResource::CustomMethods::ClassMethods - include ActiveResource::CustomMethods::InstanceMethods - - class << self - alias :orig_delete :delete - - # Invokes a GET to a given custom REST method. For example: - # - # Person.get(:active) # GET /people/active.xml - # # => [{:id => 1, :name => 'Ryan'}, {:id => 2, :name => 'Joe'}] - # - # Person.get(:active, :awesome => true) # GET /people/active.xml?awesome=true - # # => [{:id => 1, :name => 'Ryan'}] - # - # Note: the objects returned from this method are not automatically converted - # into ActiveResource::Base instances - they are ordinary Hashes. If you are expecting - # ActiveResource::Base instances, use the <tt>find</tt> class method with the - # <tt>:from</tt> option. For example: - # - # Person.find(:all, :from => :active) - def get(custom_method_name, options = {}) - connection.get(custom_method_collection_url(custom_method_name, options), headers) - end - - def post(custom_method_name, options = {}, body = '') - connection.post(custom_method_collection_url(custom_method_name, options), body, headers) - end - - def put(custom_method_name, options = {}, body = '') - connection.put(custom_method_collection_url(custom_method_name, options), body, headers) - end - - def delete(custom_method_name, options = {}) - # Need to jump through some hoops to retain the original class 'delete' method - if custom_method_name.is_a?(Symbol) - connection.delete(custom_method_collection_url(custom_method_name, options), headers) - else - orig_delete(custom_method_name, options) - end - end - end - end - end - - module ClassMethods - def custom_method_collection_url(method_name, options = {}) - prefix_options, query_options = split_options(options) - "#{prefix(prefix_options)}#{collection_name}/#{method_name}.#{format.extension}#{query_string(query_options)}" - end - end - - module InstanceMethods - def get(method_name, options = {}) - connection.get(custom_method_element_url(method_name, options), self.class.headers) - end - - def post(method_name, options = {}, body = nil) - request_body = body.blank? ? encode : body - if new? - connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers) - else - connection.post(custom_method_element_url(method_name, options), request_body, self.class.headers) - end - end - - def put(method_name, options = {}, body = '') - connection.put(custom_method_element_url(method_name, options), body, self.class.headers) - end - - def delete(method_name, options = {}) - connection.delete(custom_method_element_url(method_name, options), self.class.headers) - end - - - private - def custom_method_element_url(method_name, options = {}) - "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}" - end - - def custom_method_new_element_url(method_name, options = {}) - "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}" - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/exceptions.rb b/vendor/rails/activeresource/lib/active_resource/exceptions.rb deleted file mode 100644 index 0631cdcf..00000000 --- a/vendor/rails/activeresource/lib/active_resource/exceptions.rb +++ /dev/null @@ -1,66 +0,0 @@ -module ActiveResource - class ConnectionError < StandardError # :nodoc: - attr_reader :response - - def initialize(response, message = nil) - @response = response - @message = message - end - - def to_s - "Failed with #{response.code} #{response.message if response.respond_to?(:message)}" - end - end - - # Raised when a Timeout::Error occurs. - class TimeoutError < ConnectionError - def initialize(message) - @message = message - end - def to_s; @message ;end - end - - # Raised when a OpenSSL::SSL::SSLError occurs. - class SSLError < ConnectionError - def initialize(message) - @message = message - end - def to_s; @message ;end - end - - # 3xx Redirection - class Redirection < ConnectionError # :nodoc: - def to_s; response['Location'] ? "#{super} => #{response['Location']}" : super; end - end - - # 4xx Client Error - class ClientError < ConnectionError; end # :nodoc: - - # 400 Bad Request - class BadRequest < ClientError; end # :nodoc - - # 401 Unauthorized - class UnauthorizedAccess < ClientError; end # :nodoc - - # 403 Forbidden - class ForbiddenAccess < ClientError; end # :nodoc - - # 404 Not Found - class ResourceNotFound < ClientError; end # :nodoc: - - # 409 Conflict - class ResourceConflict < ClientError; end # :nodoc: - - # 410 Gone - class ResourceGone < ClientError; end # :nodoc: - - # 5xx Server Error - class ServerError < ConnectionError; end # :nodoc: - - # 405 Method Not Allowed - class MethodNotAllowed < ClientError # :nodoc: - def allowed_methods - @response['Allow'].split(',').map { |verb| verb.strip.downcase.to_sym } - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/formats.rb b/vendor/rails/activeresource/lib/active_resource/formats.rb deleted file mode 100644 index 28864cf5..00000000 --- a/vendor/rails/activeresource/lib/active_resource/formats.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveResource - module Formats - # Lookup the format class from a mime type reference symbol. Example: - # - # ActiveResource::Formats[:xml] # => ActiveResource::Formats::XmlFormat - # ActiveResource::Formats[:json] # => ActiveResource::Formats::JsonFormat - def self.[](mime_type_reference) - ActiveResource::Formats.const_get(mime_type_reference.to_s.camelize + "Format") - end - end -end - -require 'active_resource/formats/xml_format' -require 'active_resource/formats/json_format' \ No newline at end of file diff --git a/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb b/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb deleted file mode 100644 index 127e8288..00000000 --- a/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveResource - module Formats - module JsonFormat - extend self - - def extension - "json" - end - - def mime_type - "application/json" - end - - def encode(hash, options = nil) - ActiveSupport::JSON.encode(hash, options) - end - - def decode(json) - ActiveSupport::JSON.decode(json) - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb b/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb deleted file mode 100644 index 86c6cec7..00000000 --- a/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb +++ /dev/null @@ -1,34 +0,0 @@ -module ActiveResource - module Formats - module XmlFormat - extend self - - def extension - "xml" - end - - def mime_type - "application/xml" - end - - def encode(hash, options={}) - hash.to_xml(options) - end - - def decode(xml) - from_xml_data(Hash.from_xml(xml)) - end - - private - # Manipulate from_xml Hash, because xml_simple is not exactly what we - # want for Active Resource. - def from_xml_data(data) - if data.is_a?(Hash) && data.keys.size == 1 - data.values.first - else - data - end - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/http_mock.rb b/vendor/rails/activeresource/lib/active_resource/http_mock.rb deleted file mode 100644 index e6a595fb..00000000 --- a/vendor/rails/activeresource/lib/active_resource/http_mock.rb +++ /dev/null @@ -1,302 +0,0 @@ -require 'active_resource/connection' - -module ActiveResource - class InvalidRequestError < StandardError; end #:nodoc: - - # One thing that has always been a pain with remote web services is testing. The HttpMock - # class makes it easy to test your Active Resource models by creating a set of mock responses to specific - # requests. - # - # To test your Active Resource model, you simply call the ActiveResource::HttpMock.respond_to - # method with an attached block. The block declares a set of URIs with expected input, and the output - # each request should return. The passed in block has any number of entries in the following generalized - # format: - # - # mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - # - # * <tt>http_method</tt> - The HTTP method to listen for. This can be +get+, +post+, +put+, +delete+ or - # +head+. - # * <tt>path</tt> - A string, starting with a "/", defining the URI that is expected to be - # called. - # * <tt>request_headers</tt> - Headers that are expected along with the request. This argument uses a - # hash format, such as <tt>{ "Content-Type" => "application/xml" }</tt>. This mock will only trigger - # if your tests sends a request with identical headers. - # * <tt>body</tt> - The data to be returned. This should be a string of Active Resource parseable content, - # such as XML. - # * <tt>status</tt> - The HTTP response code, as an integer, to return with the response. - # * <tt>response_headers</tt> - Headers to be returned with the response. Uses the same hash format as - # <tt>request_headers</tt> listed above. - # - # In order for a mock to deliver its content, the incoming request must match by the <tt>http_method</tt>, - # +path+ and <tt>request_headers</tt>. If no match is found an InvalidRequestError exception - # will be raised showing you what request it could not find a response for and also what requests and response - # pairs have been recorded so you can create a new mock for that request. - # - # ==== Example - # def setup - # @matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - # ActiveResource::HttpMock.respond_to do |mock| - # mock.post "/people.xml", {}, @matz, 201, "Location" => "/people/1.xml" - # mock.get "/people/1.xml", {}, @matz - # mock.put "/people/1.xml", {}, nil, 204 - # mock.delete "/people/1.xml", {}, nil, 200 - # end - # end - # - # def test_get_matz - # person = Person.find(1) - # assert_equal "Matz", person.name - # end - # - class HttpMock - class Responder #:nodoc: - def initialize(responses) - @responses = responses - end - - for method in [ :post, :put, :get, :delete, :head ] - # def post(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - # @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers) - # end - module_eval <<-EOE, __FILE__, __LINE__ + 1 - def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - @responses << [Request.new(:#{method}, path, nil, request_headers), Response.new(body || "", status, response_headers)] - end - EOE - end - end - - class << self - - # Returns an array of all request objects that have been sent to the mock. You can use this to check - # if your model actually sent an HTTP request. - # - # ==== Example - # def setup - # @matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - # ActiveResource::HttpMock.respond_to do |mock| - # mock.get "/people/1.xml", {}, @matz - # end - # end - # - # def test_should_request_remote_service - # person = Person.find(1) # Call the remote service - # - # # This request object has the same HTTP method and path as declared by the mock - # expected_request = ActiveResource::Request.new(:get, "/people/1.xml") - # - # # Assert that the mock received, and responded to, the expected request from the model - # assert ActiveResource::HttpMock.requests.include?(expected_request) - # end - def requests - @@requests ||= [] - end - - # Returns the list of requests and their mocked responses. Look up a - # response for a request using responses.assoc(request). - def responses - @@responses ||= [] - end - - # Accepts a block which declares a set of requests and responses for the HttpMock to respond to in - # the following format: - # - # mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - # - # === Example - # - # @matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - # ActiveResource::HttpMock.respond_to do |mock| - # mock.post "/people.xml", {}, @matz, 201, "Location" => "/people/1.xml" - # mock.get "/people/1.xml", {}, @matz - # mock.put "/people/1.xml", {}, nil, 204 - # mock.delete "/people/1.xml", {}, nil, 200 - # end - # - # Alternatively, accepts a hash of <tt>{Request => Response}</tt> pairs allowing you to generate - # these the following format: - # - # ActiveResource::Request.new(method, path, body, request_headers) - # ActiveResource::Response.new(body, status, response_headers) - # - # === Example - # - # Request.new(:#{method}, path, nil, request_headers) - # - # @matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - # - # create_matz = ActiveResource::Request.new(:post, '/people.xml', @matz, {}) - # created_response = ActiveResource::Response.new("", 201, {"Location" => "/people/1.xml"}) - # get_matz = ActiveResource::Request.new(:get, '/people/1.xml', nil) - # ok_response = ActiveResource::Response.new("", 200, {}) - # - # pairs = {create_matz => created_response, get_matz => ok_response} - # - # ActiveResource::HttpMock.respond_to(pairs) - # - # Note, by default, every time you call +respond_to+, any previous request and response pairs stored - # in HttpMock will be deleted giving you a clean slate to work on. - # - # If you want to override this behaviour, pass in +false+ as the last argument to +respond_to+ - # - # === Example - # - # ActiveResource::HttpMock.respond_to do |mock| - # mock.send(:get, "/people/1", {}, "XML1") - # end - # ActiveResource::HttpMock.responses.length #=> 1 - # - # ActiveResource::HttpMock.respond_to(false) do |mock| - # mock.send(:get, "/people/2", {}, "XML2") - # end - # ActiveResource::HttpMock.responses.length #=> 2 - # - # This also works with passing in generated pairs of requests and responses, again, just pass in false - # as the last argument: - # - # === Example - # - # ActiveResource::HttpMock.respond_to do |mock| - # mock.send(:get, "/people/1", {}, "XML1") - # end - # ActiveResource::HttpMock.responses.length #=> 1 - # - # get_matz = ActiveResource::Request.new(:get, '/people/1.xml', nil) - # ok_response = ActiveResource::Response.new("", 200, {}) - # - # pairs = {get_matz => ok_response} - # - # ActiveResource::HttpMock.respond_to(pairs, false) - # ActiveResource::HttpMock.responses.length #=> 2 - def respond_to(*args) #:yields: mock - pairs = args.first || {} - reset! if args.last.class != FalseClass - responses.concat pairs.to_a - if block_given? - yield Responder.new(responses) - else - Responder.new(responses) - end - end - - # Deletes all logged requests and responses. - def reset! - requests.clear - responses.clear - end - end - - # body? methods - { true => %w(post put), - false => %w(get delete head) }.each do |has_body, methods| - methods.each do |method| - # def post(path, body, headers) - # request = ActiveResource::Request.new(:post, path, body, headers) - # self.class.requests << request - # if response = self.class.responses.assoc(request) - # response[1] - # else - # raise InvalidRequestError.new("Could not find a response recorded for #{request.to_s} - Responses recorded are: - #{inspect_responses}") - # end - # end - module_eval <<-EOE, __FILE__, __LINE__ + 1 - def #{method}(path, #{'body, ' if has_body}headers) - request = ActiveResource::Request.new(:#{method}, path, #{has_body ? 'body, ' : 'nil, '}headers) - self.class.requests << request - if response = self.class.responses.assoc(request) - response[1] - else - raise InvalidRequestError.new("Could not find a response recorded for \#{request.to_s} - Responses recorded are: \#{inspect_responses}") - end - end - EOE - end - end - - def initialize(site) #:nodoc: - @site = site - end - - def inspect_responses #:nodoc: - self.class.responses.map { |r| r[0].to_s }.inspect - end - end - - class Request - attr_accessor :path, :method, :body, :headers - - def initialize(method, path, body = nil, headers = {}) - @method, @path, @body, @headers = method, path, body, headers - end - - def ==(req) - path == req.path && method == req.method && headers_match?(req) - end - - def to_s - "<#{method.to_s.upcase}: #{path} [#{headers}] (#{body})>" - end - - private - - def headers_match?(req) - # Ignore format header on equality if it's not defined - format_header = ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[method] - if headers[format_header].present? || req.headers[format_header].blank? - headers == req.headers - else - headers.dup.merge(format_header => req.headers[format_header]) == req.headers - end - end - - end - - class Response - attr_accessor :body, :message, :code, :headers - - def initialize(body, message = 200, headers = {}) - @body, @message, @headers = body, message.to_s, headers - @code = @message[0,3].to_i - - resp_cls = Net::HTTPResponse::CODE_TO_OBJ[@code.to_s] - if resp_cls && !resp_cls.body_permitted? - @body = nil - end - - if @body.nil? - self['Content-Length'] = "0" - else - self['Content-Length'] = body.size.to_s - end - end - - def success? - (200..299).include?(code) - end - - def [](key) - headers[key] - end - - def []=(key, value) - headers[key] = value - end - - def ==(other) - if (other.is_a?(Response)) - other.body == body && other.message == message && other.headers == headers - else - false - end - end - end - - class Connection - private - silence_warnings do - def http - @http ||= HttpMock.new(@site) - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/validations.rb b/vendor/rails/activeresource/lib/active_resource/validations.rb deleted file mode 100644 index f5aa24f0..00000000 --- a/vendor/rails/activeresource/lib/active_resource/validations.rb +++ /dev/null @@ -1,290 +0,0 @@ -module ActiveResource - class ResourceInvalid < ClientError #:nodoc: - end - - # Active Resource validation is reported to and from this object, which is used by Base#save - # to determine whether the object in a valid state to be saved. See usage example in Validations. - class Errors - include Enumerable - attr_reader :errors - - delegate :empty?, :to => :errors - - def initialize(base) # :nodoc: - @base, @errors = base, {} - end - - # Add an error to the base Active Resource object rather than an attribute. - # - # ==== Examples - # my_folder = Folder.find(1) - # my_folder.errors.add_to_base("You can't edit an existing folder") - # my_folder.errors.on_base - # # => "You can't edit an existing folder" - # - # my_folder.errors.add_to_base("This folder has been tagged as frozen") - # my_folder.valid? - # # => false - # my_folder.errors.on_base - # # => ["You can't edit an existing folder", "This folder has been tagged as frozen"] - # - def add_to_base(msg) - add(:base, msg) - end - - # Adds an error to an Active Resource object's attribute (named for the +attribute+ parameter) - # with the error message in +msg+. - # - # ==== Examples - # my_resource = Node.find(1) - # my_resource.errors.add('name', 'can not be "base"') if my_resource.name == 'base' - # my_resource.errors.on('name') - # # => 'can not be "base"!' - # - # my_resource.errors.add('desc', 'can not be blank') if my_resource.desc == '' - # my_resource.valid? - # # => false - # my_resource.errors.on('desc') - # # => 'can not be blank!' - # - def add(attribute, msg) - @errors[attribute.to_s] = [] if @errors[attribute.to_s].nil? - @errors[attribute.to_s] << msg - end - - # Returns true if the specified +attribute+ has errors associated with it. - # - # ==== Examples - # my_resource = Disk.find(1) - # my_resource.errors.add('location', 'must be Main') unless my_resource.location == 'Main' - # my_resource.errors.on('location') - # # => 'must be Main!' - # - # my_resource.errors.invalid?('location') - # # => true - # my_resource.errors.invalid?('name') - # # => false - def invalid?(attribute) - !@errors[attribute.to_s].nil? - end - - # A method to return the errors associated with +attribute+, which returns nil, if no errors are - # associated with the specified +attribute+, the error message if one error is associated with the specified +attribute+, - # or an array of error messages if more than one error is associated with the specified +attribute+. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # my_person.errors.on('login') - # # => nil - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.on('login') - # # => 'can not be empty' - # - # my_person.errors.add('login', 'can not be longer than 10 characters') if my_person.login.length > 10 - # my_person.errors.on('login') - # # => ['can not be empty', 'can not be longer than 10 characters'] - def on(attribute) - errors = @errors[attribute.to_s] - return nil if errors.nil? - errors.size == 1 ? errors.first : errors - end - - alias :[] :on - - # A method to return errors assigned to +base+ object through add_to_base, which returns nil, if no errors are - # associated with the specified +attribute+, the error message if one error is associated with the specified +attribute+, - # or an array of error messages if more than one error is associated with the specified +attribute+. - # - # ==== Examples - # my_account = Account.find(1) - # my_account.errors.on_base - # # => nil - # - # my_account.errors.add_to_base("This account is frozen") - # my_account.errors.on_base - # # => "This account is frozen" - # - # my_account.errors.add_to_base("This account has been closed") - # my_account.errors.on_base - # # => ["This account is frozen", "This account has been closed"] - # - def on_base - on(:base) - end - - # Yields each attribute and associated message per error added. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # messages = '' - # my_person.errors.each {|attr, msg| messages += attr.humanize + " " + msg + "<br />"} - # messages - # # => "Login can not be empty<br />Password can not be empty<br />" - # - def each - @errors.each_key { |attr| @errors[attr].each { |msg| yield attr, msg } } - end - - # Yields each full error message added. So Person.errors.add("first_name", "can't be empty") will be returned - # through iteration as "First name can't be empty". - # - # ==== Examples - # my_person = Person.new(params[:person]) - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # messages = '' - # my_person.errors.each_full {|msg| messages += msg + "<br/>"} - # messages - # # => "Login can not be empty<br />Password can not be empty<br />" - # - def each_full - full_messages.each { |msg| yield msg } - end - - # Returns all the full error messages in an array. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # messages = '' - # my_person.errors.full_messages.each {|msg| messages += msg + "<br/>"} - # messages - # # => "Login can not be empty<br />Password can not be empty<br />" - # - def full_messages - full_messages = [] - - @errors.each_key do |attr| - @errors[attr].each do |msg| - next if msg.nil? - - if attr == "base" - full_messages << msg - else - full_messages << [attr.humanize, msg].join(' ') - end - end - end - full_messages - end - - def clear - @errors = {} - end - - # Returns the total number of errors added. Two errors added to the same attribute will be counted as such - # with this as well. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # my_person.errors.size - # # => 0 - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # my_person.error.size - # # => 2 - # - def size - @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size } - end - - alias_method :count, :size - alias_method :length, :size - - # Grabs errors from an array of messages (like ActiveRecord::Validations) - def from_array(messages) - clear - humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) } - messages.each do |message| - attr_message = humanized_attributes.keys.detect do |attr_name| - if message[0, attr_name.size + 1] == "#{attr_name} " - add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1] - end - end - - add_to_base message if attr_message.nil? - end - end - - # Grabs errors from the json response. - def from_json(json) - array = ActiveSupport::JSON.decode(json)['errors'] rescue [] - from_array array - end - - # Grabs errors from the XML response. - def from_xml(xml) - array = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue [] - from_array array - end - end - - # Module to support validation and errors with Active Resource objects. The module overrides - # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned - # in the web service response. The module also adds an +errors+ collection that mimics the interface - # of the errors provided by ActiveRecord::Errors. - # - # ==== Example - # - # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a - # <tt>validates_presence_of :first_name, :last_name</tt> declaration in the model: - # - # person = Person.new(:first_name => "Jim", :last_name => "") - # person.save # => false (server returns an HTTP 422 status code and errors) - # person.valid? # => false - # person.errors.empty? # => false - # person.errors.count # => 1 - # person.errors.full_messages # => ["Last name can't be empty"] - # person.errors.on(:last_name) # => "can't be empty" - # person.last_name = "Halpert" - # person.save # => true (and person is now saved to the remote service) - # - module Validations - def self.included(base) # :nodoc: - base.class_eval do - alias_method_chain :save, :validation - end - end - - # Validate a resource and save (POST) it to the remote web service. - def save_with_validation - save_without_validation - true - rescue ResourceInvalid => error - case self.class.format - when ActiveResource::Formats[:xml] - errors.from_xml(error.response.body) - when ActiveResource::Formats[:json] - errors.from_json(error.response.body) - end - false - end - - # Checks for errors on an object (i.e., is resource.errors empty?). - # - # ==== Examples - # my_person = Person.create(params[:person]) - # my_person.valid? - # # => true - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.valid? - # # => false - def valid? - errors.empty? - end - - # Returns the Errors object that holds all information about attribute error messages. - def errors - @errors ||= Errors.new(self) - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/version.rb b/vendor/rails/activeresource/lib/active_resource/version.rb deleted file mode 100644 index d8b34f12..00000000 --- a/vendor/rails/activeresource/lib/active_resource/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveResource - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 14 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/activeresource/lib/activeresource.rb b/vendor/rails/activeresource/lib/activeresource.rb deleted file mode 100644 index 666656cc..00000000 --- a/vendor/rails/activeresource/lib/activeresource.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'active_resource' -ActiveSupport::Deprecation.warn 'require "activeresource" is deprecated and will be removed in Rails 3. Use require "active_resource" instead.' diff --git a/vendor/rails/activeresource/test/abstract_unit.rb b/vendor/rails/activeresource/test/abstract_unit.rb deleted file mode 100644 index c769bf03..00000000 --- a/vendor/rails/activeresource/test/abstract_unit.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rubygems' -require 'test/unit' -require 'active_support/test_case' - -$:.unshift File.expand_path('../../lib', __FILE__) -$:.unshift File.expand_path('../../../activesupport/lib', __FILE__) -require 'active_resource' -require 'active_resource/http_mock' - -$:.unshift "#{File.dirname(__FILE__)}/../test" -require 'setter_trap' - -ActiveResource::Base.logger = Logger.new("#{File.dirname(__FILE__)}/debug.log") - -def uses_gem(gem_name, test_name, version = '> 0') - gem gem_name.to_s, version - require gem_name.to_s - yield -rescue LoadError - $stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again." -end diff --git a/vendor/rails/activeresource/test/authorization_test.rb b/vendor/rails/activeresource/test/authorization_test.rb deleted file mode 100644 index ca25f437..00000000 --- a/vendor/rails/activeresource/test/authorization_test.rb +++ /dev/null @@ -1,122 +0,0 @@ -require 'abstract_unit' - -class AuthorizationTest < Test::Unit::TestCase - Response = Struct.new(:code) - - def setup - @conn = ActiveResource::Connection.new('http://localhost') - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @david = { :id => 2, :name => 'David' }.to_xml(:root => 'person') - @authenticated_conn = ActiveResource::Connection.new("http://david:test123@localhost") - @authorization_request_header = { 'Authorization' => 'Basic ZGF2aWQ6dGVzdDEyMw==' } - - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.xml", @authorization_request_header, @david - mock.put "/people/2.xml", @authorization_request_header, nil, 204 - mock.delete "/people/2.xml", @authorization_request_header, nil, 200 - mock.post "/people/2/addresses.xml", @authorization_request_header, nil, 201, 'Location' => '/people/1/addresses/5' - end - end - - def test_authorization_header - authorization_header = @authenticated_conn.__send__(:authorization_header) - assert_equal @authorization_request_header['Authorization'], authorization_header['Authorization'] - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_with_username_but_no_password - @conn = ActiveResource::Connection.new("http://david:@localhost") - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_with_password_but_no_username - @conn = ActiveResource::Connection.new("http://:test123@localhost") - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_with_decoded_credentials_from_url - @conn = ActiveResource::Connection.new("http://my%40email.com:%31%32%33@localhost") - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["my@email.com", "123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_explicitly_setting_username_and_password - @authenticated_conn = ActiveResource::Connection.new("http://@localhost") - @authenticated_conn.user = 'david' - @authenticated_conn.password = 'test123' - authorization_header = @authenticated_conn.__send__(:authorization_header) - assert_equal @authorization_request_header['Authorization'], authorization_header['Authorization'] - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_explicitly_setting_username_but_no_password - @conn = ActiveResource::Connection.new("http://@localhost") - @conn.user = "david" - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_explicitly_setting_password_but_no_username - @conn = ActiveResource::Connection.new("http://@localhost") - @conn.password = "test123" - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_get - david = @authenticated_conn.get("/people/2.xml") - assert_equal "David", david["name"] - end - - def test_post - response = @authenticated_conn.post("/people/2/addresses.xml") - assert_equal "/people/1/addresses/5", response["Location"] - end - - def test_put - response = @authenticated_conn.put("/people/2.xml") - assert_equal 204, response.code - end - - def test_delete - response = @authenticated_conn.delete("/people/2.xml") - assert_equal 200, response.code - end - - def test_raises_invalid_request_on_unauthorized_requests - assert_raise(ActiveResource::InvalidRequestError) { @conn.post("/people/2.xml") } - assert_raise(ActiveResource::InvalidRequestError) { @conn.post("/people/2/addresses.xml") } - assert_raise(ActiveResource::InvalidRequestError) { @conn.put("/people/2.xml") } - assert_raise(ActiveResource::InvalidRequestError) { @conn.delete("/people/2.xml") } - end - - protected - def assert_response_raises(klass, code) - assert_raise(klass, "Expected response code #{code} to raise #{klass}") do - @conn.__send__(:handle_response, Response.new(code)) - end - end -end diff --git a/vendor/rails/activeresource/test/base/custom_methods_test.rb b/vendor/rails/activeresource/test/base/custom_methods_test.rb deleted file mode 100644 index 61887f4e..00000000 --- a/vendor/rails/activeresource/test/base/custom_methods_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'abstract_unit' -require 'fixtures/person' -require 'fixtures/street_address' - -class CustomMethodsTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @matz_deep = { :id => 1, :name => 'Matz', :other => 'other' }.to_xml(:root => 'person') - @matz_array = [{ :id => 1, :name => 'Matz' }].to_xml(:root => 'people') - @ryan = { :name => 'Ryan' }.to_xml(:root => 'person') - @addy = { :id => 1, :street => '12345 Street' }.to_xml(:root => 'address') - @addy_deep = { :id => 1, :street => '12345 Street', :zip => "27519" }.to_xml(:root => 'address') - - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, @matz - mock.get "/people/1/shallow.xml", {}, @matz - mock.get "/people/1/deep.xml", {}, @matz_deep - mock.get "/people/retrieve.xml?name=Matz", {}, @matz_array - mock.get "/people/managers.xml", {}, @matz_array - mock.post "/people/hire.xml?name=Matz", {}, nil, 201 - mock.put "/people/1/promote.xml?position=Manager", {}, nil, 204 - mock.put "/people/promote.xml?name=Matz", {}, nil, 204, {} - mock.put "/people/sort.xml?by=name", {}, nil, 204 - mock.delete "/people/deactivate.xml?name=Matz", {}, nil, 200 - mock.delete "/people/1/deactivate.xml", {}, nil, 200 - mock.post "/people/new/register.xml", {}, @ryan, 201, 'Location' => '/people/5.xml' - mock.post "/people/1/register.xml", {}, @matz, 201 - mock.get "/people/1/addresses/1.xml", {}, @addy - mock.get "/people/1/addresses/1/deep.xml", {}, @addy_deep - mock.put "/people/1/addresses/1/normalize_phone.xml?locale=US", {}, nil, 204 - mock.put "/people/1/addresses/sort.xml?by=name", {}, nil, 204 - mock.post "/people/1/addresses/new/link.xml", {}, { :street => '12345 Street' }.to_xml(:root => 'address'), 201, 'Location' => '/people/1/addresses/2.xml' - end - - Person.user = nil - Person.password = nil - end - - def teardown - ActiveResource::HttpMock.reset! - end - - def test_custom_collection_method - # GET - assert_equal([{ "id" => 1, "name" => 'Matz' }], Person.get(:retrieve, :name => 'Matz')) - - # POST - assert_equal(ActiveResource::Response.new("", 201, {}), Person.post(:hire, :name => 'Matz')) - - # PUT - assert_equal ActiveResource::Response.new("", 204, {}), - Person.put(:promote, {:name => 'Matz'}, 'atestbody') - assert_equal ActiveResource::Response.new("", 204, {}), Person.put(:sort, :by => 'name') - - # DELETE - Person.delete :deactivate, :name => 'Matz' - - # Nested resource - assert_equal ActiveResource::Response.new("", 204, {}), StreetAddress.put(:sort, :person_id => 1, :by => 'name') - end - - def test_custom_element_method - # Test GET against an element URL - assert_equal Person.find(1).get(:shallow), {"id" => 1, "name" => 'Matz'} - assert_equal Person.find(1).get(:deep), {"id" => 1, "name" => 'Matz', "other" => 'other'} - - # Test PUT against an element URL - assert_equal ActiveResource::Response.new("", 204, {}), Person.find(1).put(:promote, {:position => 'Manager'}, 'body') - - # Test DELETE against an element URL - assert_equal ActiveResource::Response.new("", 200, {}), Person.find(1).delete(:deactivate) - - # With nested resources - assert_equal StreetAddress.find(1, :params => { :person_id => 1 }).get(:deep), - { "id" => 1, "street" => '12345 Street', "zip" => "27519" } - assert_equal ActiveResource::Response.new("", 204, {}), - StreetAddress.find(1, :params => { :person_id => 1 }).put(:normalize_phone, :locale => 'US') - end - - def test_custom_new_element_method - # Test POST against a new element URL - ryan = Person.new(:name => 'Ryan') - assert_equal ActiveResource::Response.new(@ryan, 201, {'Location' => '/people/5.xml'}), ryan.post(:register) - expected_request = ActiveResource::Request.new(:post, '/people/new/register.xml', @ryan) - assert_equal expected_request.body, ActiveResource::HttpMock.requests.first.body - - # Test POST against a nested collection URL - addy = StreetAddress.new(:street => '123 Test Dr.', :person_id => 1) - assert_equal ActiveResource::Response.new({ :street => '12345 Street' }.to_xml(:root => 'address'), - 201, {'Location' => '/people/1/addresses/2.xml'}), - addy.post(:link) - - matz = Person.new(:id => 1, :name => 'Matz') - assert_equal ActiveResource::Response.new(@matz, 201), matz.post(:register) - end - - def test_find_custom_resources - assert_equal 'Matz', Person.find(:all, :from => :managers).first.name - end -end diff --git a/vendor/rails/activeresource/test/base/equality_test.rb b/vendor/rails/activeresource/test/base/equality_test.rb deleted file mode 100644 index 84f1a7b9..00000000 --- a/vendor/rails/activeresource/test/base/equality_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/street_address" - -class BaseEqualityTest < Test::Unit::TestCase - def setup - @new = Person.new - @one = Person.new(:id => 1) - @two = Person.new(:id => 2) - @street = StreetAddress.new(:id => 2) - end - - def test_should_equal_self - assert @new == @new, '@new == @new' - assert @one == @one, '@one == @one' - end - - def test_shouldnt_equal_new_resource - assert @new != @one, '@new != @one' - assert @one != @new, '@one != @new' - end - - def test_shouldnt_equal_different_class - assert @two != @street, 'person != street_address with same id' - assert @street != @two, 'street_address != person with same id' - end - - def test_eql_should_alias_equals_operator - assert_equal @new == @new, @new.eql?(@new) - assert_equal @new == @one, @new.eql?(@one) - - assert_equal @one == @one, @one.eql?(@one) - assert_equal @one == @new, @one.eql?(@new) - - assert_equal @one == @street, @one.eql?(@street) - end - - def test_hash_should_be_id_hash - [@new, @one, @two, @street].each do |resource| - assert_equal resource.id.hash, resource.hash - end - end - - def test_with_prefix_options - assert_equal @one == @one, @one.eql?(@one) - assert_equal @one == @one.dup, @one.eql?(@one.dup) - new_one = @one.dup - new_one.prefix_options = {:foo => 'bar'} - assert_not_equal @one, new_one - end - -end diff --git a/vendor/rails/activeresource/test/base/load_test.rb b/vendor/rails/activeresource/test/base/load_test.rb deleted file mode 100644 index 079ec2c1..00000000 --- a/vendor/rails/activeresource/test/base/load_test.rb +++ /dev/null @@ -1,161 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/street_address" - -module Highrise - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - module Deeply - module Nested - - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - module TestDifferentLevels - - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - end - - end - end - -end - - -class BaseLoadTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' } - - @first_address = { :id => 1, :street => '12345 Street' } - @addresses = [@first_address, { :id => 2, :street => '67890 Street' }] - @addresses_from_xml = { :street_addresses => @addresses } - @addresses_from_xml_single = { :street_addresses => [ @first_address ] } - - @deep = { :id => 1, :street => { - :id => 1, :state => { :id => 1, :name => 'Oregon', - :notable_rivers => [ - { :id => 1, :name => 'Willamette' }, - { :id => 2, :name => 'Columbia', :rafted_by => @matz }], - :postal_codes => [ 97018, 1234567890 ], - :places => [ "Columbia City", "Unknown" ]}}} - - @person = Person.new - end - - def test_load_expects_hash - assert_raise(ArgumentError) { @person.load nil } - assert_raise(ArgumentError) { @person.load '<person id="1"/>' } - end - - def test_load_simple_hash - assert_equal Hash.new, @person.attributes - assert_equal @matz.stringify_keys, @person.load(@matz).attributes - end - - def test_load_one_with_existing_resource - address = @person.load(:street_address => @first_address).street_address - assert_kind_of StreetAddress, address - assert_equal @first_address.stringify_keys, address.attributes - end - - def test_load_one_with_unknown_resource - address = silence_warnings { @person.load(:address => @first_address).address } - assert_kind_of Person::Address, address - assert_equal @first_address.stringify_keys, address.attributes - end - - def test_load_collection_with_existing_resource - addresses = @person.load(@addresses_from_xml).street_addresses - assert_kind_of Array, addresses - addresses.each { |address| assert_kind_of StreetAddress, address } - assert_equal @addresses.map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_load_collection_with_unknown_resource - Person.__send__(:remove_const, :Address) if Person.const_defined?(:Address) - assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated" - addresses = silence_warnings { @person.load(:addresses => @addresses).addresses } - assert Person.const_defined?(:Address), "Address should have been autocreated" - addresses.each { |address| assert_kind_of Person::Address, address } - assert_equal @addresses.map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_load_collection_with_single_existing_resource - addresses = @person.load(@addresses_from_xml_single).street_addresses - assert_kind_of Array, addresses - addresses.each { |address| assert_kind_of StreetAddress, address } - assert_equal [ @first_address ].map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_load_collection_with_single_unknown_resource - Person.__send__(:remove_const, :Address) if Person.const_defined?(:Address) - assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated" - addresses = silence_warnings { @person.load(:addresses => [ @first_address ]).addresses } - assert Person.const_defined?(:Address), "Address should have been autocreated" - addresses.each { |address| assert_kind_of Person::Address, address } - assert_equal [ @first_address ].map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_recursively_loaded_collections - person = @person.load(@deep) - assert_equal @deep[:id], person.id - - street = person.street - assert_kind_of Person::Street, street - assert_equal @deep[:street][:id], street.id - - state = street.state - assert_kind_of Person::Street::State, state - assert_equal @deep[:street][:state][:id], state.id - - rivers = state.notable_rivers - assert_kind_of Array, rivers - assert_kind_of Person::Street::State::NotableRiver, rivers.first - assert_equal @deep[:street][:state][:notable_rivers].first[:id], rivers.first.id - assert_equal @matz[:id], rivers.last.rafted_by.id - - postal_codes = state.postal_codes - assert_kind_of Array, postal_codes - assert_equal 2, postal_codes.size - assert_kind_of Fixnum, postal_codes.first - assert_equal @deep[:street][:state][:postal_codes].first, postal_codes.first - assert_kind_of Numeric, postal_codes.last - assert_equal @deep[:street][:state][:postal_codes].last, postal_codes.last - - places = state.places - assert_kind_of Array, places - assert_kind_of String, places.first - assert_equal @deep[:street][:state][:places].first, places.first - end - - def test_nested_collections_within_the_same_namespace - n = Highrise::Note.new(:comments => [{ :name => "1" }]) - assert_kind_of Highrise::Comment, n.comments.first - end - - def test_nested_collections_within_deeply_nested_namespace - n = Highrise::Deeply::Nested::Note.new(:comments => [{ :name => "1" }]) - assert_kind_of Highrise::Deeply::Nested::Comment, n.comments.first - end - - def test_nested_collections_in_different_levels_of_namespaces - n = Highrise::Deeply::Nested::TestDifferentLevels::Note.new(:comments => [{ :name => "1" }]) - assert_kind_of Highrise::Deeply::Nested::Comment, n.comments.first - end - - -end diff --git a/vendor/rails/activeresource/test/base_errors_test.rb b/vendor/rails/activeresource/test/base_errors_test.rb deleted file mode 100644 index 7183d7af..00000000 --- a/vendor/rails/activeresource/test/base_errors_test.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" - -class BaseErrorsTest < Test::Unit::TestCase - def setup - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml; charset=utf-8'} - mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json; charset=utf-8'} - end - @person = Person.new(:name => '', :age => '') - assert_equal @person.save, false - end - - def test_should_mark_as_invalid - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - assert !@person.valid? - end - end - end - - def test_should_parse_xml_errors - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - assert_kind_of ActiveResource::Errors, @person.errors - assert_equal 4, @person.errors.size - end - end - end - - def test_should_parse_errors_to_individual_attributes - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - assert @person.errors[:name].any? - assert_equal "can't be blank", @person.errors[:age] - assert_equal ["can't be blank", "must start with a letter"], @person.errors[:name] - assert_equal "Person quota full for today.", @person.errors[:base] - end - end - end - - def test_should_iterate_over_errors - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - errors = [] - @person.errors.each { |attribute, message| errors << [attribute, message] } - assert errors.include?(['name', "can't be blank"]) - end - end - end - - def test_should_iterate_over_full_errors - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - errors = [] - @person.errors.to_a.each { |message| errors << message } - assert errors.include?(["name", "can't be blank"]) - end - end - end - - def test_should_format_full_errors - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - full = @person.errors.full_messages - assert full.include?("Age can't be blank") - assert full.include?("Name can't be blank") - assert full.include?("Name must start with a letter") - assert full.include?("Person quota full for today.") - end - end - end - - def test_should_mark_as_invalid_when_content_type_is_unavailable_in_response_header - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {} - mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {} - end - - [ :json, :xml ].each do |format| - invalid_user_using_format(format) do - assert !@person.valid? - end - end - end - - private - def invalid_user_using_format(mime_type_reference) - previous_format = Person.format - Person.format = mime_type_reference - @person = Person.new(:name => '', :age => '') - assert_equal false, @person.save - - yield - ensure - Person.format = previous_format - end -end diff --git a/vendor/rails/activeresource/test/base_test.rb b/vendor/rails/activeresource/test/base_test.rb deleted file mode 100644 index 2a9ca65a..00000000 --- a/vendor/rails/activeresource/test/base_test.rb +++ /dev/null @@ -1,1087 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/customer" -require "fixtures/street_address" -require "fixtures/beast" -require "fixtures/proxy" -require 'active_support/json' - -class BaseTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @david = { :id => 2, :name => 'David' }.to_xml(:root => 'person') - @greg = { :id => 3, :name => 'Greg' }.to_xml(:root => 'person') - @addy = { :id => 1, :street => '12345 Street' }.to_xml(:root => 'address') - @default_request_headers = { 'Content-Type' => 'application/xml' } - @rick = { :name => "Rick", :age => 25 }.to_xml(:root => "person") - @joe = {'person' => { :id => 6, :name => 'Joe' }}.to_json - @people = [{ :id => 1, :name => 'Matz' }, { :id => 2, :name => 'David' }].to_xml(:root => 'people') - @people_david = [{ :id => 2, :name => 'David' }].to_xml(:root => 'people') - @addresses = [{ :id => 1, :street => '12345 Street' }].to_xml(:root => 'addresses') - - # - deep nested resource - - # - Luis (Customer) - # - JK (Customer::Friend) - # - Mateo (Customer::Friend::Brother) - # - Edith (Customer::Friend::Brother::Child) - # - Martha (Customer::Friend::Brother::Child) - # - Felipe (Customer::Friend::Brother) - # - Bryan (Customer::Friend::Brother::Child) - # - Luke (Customer::Friend::Brother::Child) - # - Eduardo (Customer::Friend) - # - Sebas (Customer::Friend::Brother) - # - Andres (Customer::Friend::Brother::Child) - # - Jorge (Customer::Friend::Brother::Child) - # - Elsa (Customer::Friend::Brother) - # - Natacha (Customer::Friend::Brother::Child) - # - Milena (Customer::Friend::Brother) - # - @luis = {:id => 1, :name => 'Luis', - :friends => [{:name => 'JK', - :brothers => [{:name => 'Mateo', - :children => [{:name => 'Edith'},{:name => 'Martha'}]}, - {:name => 'Felipe', - :children => [{:name => 'Bryan'},{:name => 'Luke'}]}]}, - {:name => 'Eduardo', - :brothers => [{:name => 'Sebas', - :children => [{:name => 'Andres'},{:name => 'Jorge'}]}, - {:name => 'Elsa', - :children => [{:name => 'Natacha'}]}, - {:name => 'Milena', - :children => []}]}]}.to_xml(:root => 'customer') - # - resource with yaml array of strings; for ActiveRecords using serialize :bar, Array - @marty = <<-eof.strip - <?xml version=\"1.0\" encoding=\"UTF-8\"?> - <person> - <id type=\"integer\">5</id> - <name>Marty</name> - <colors type=\"yaml\">--- - - \"red\" - - \"green\" - - \"blue\" - </colors> - </person> - eof - - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, @matz - mock.get "/people/2.xml", {}, @david - mock.get "/people/6.json", {}, @joe - mock.get "/people/5.xml", {}, @marty - mock.get "/people/Greg.xml", {}, @greg - mock.get "/people/4.xml", {'key' => 'value'}, nil, 404 - mock.put "/people/1.xml", {}, nil, 204 - mock.delete "/people/1.xml", {}, nil, 200 - mock.delete "/people/2.xml", {}, nil, 400 - mock.get "/people/99.xml", {}, nil, 404 - mock.post "/people.xml", {}, @rick, 201, 'Location' => '/people/5.xml' - mock.get "/people.xml", {}, @people - mock.get "/people/1/addresses.xml", {}, @addresses - mock.get "/people/1/addresses/1.xml", {}, @addy - mock.get "/people/1/addresses/2.xml", {}, nil, 404 - mock.get "/people/2/addresses/1.xml", {}, nil, 404 - mock.get "/people/Greg/addresses/1.xml", {}, @addy - mock.put "/people/1/addresses/1.xml", {}, nil, 204 - mock.delete "/people/1/addresses/1.xml", {}, nil, 200 - mock.post "/people/1/addresses.xml", {}, nil, 201, 'Location' => '/people/1/addresses/5' - mock.get "/people//addresses.xml", {}, nil, 404 - mock.get "/people//addresses/1.xml", {}, nil, 404 - mock.put "/people//addresses/1.xml", {}, nil, 404 - mock.delete "/people//addresses/1.xml", {}, nil, 404 - mock.post "/people//addresses.xml", {}, nil, 404 - mock.head "/people/1.xml", {}, nil, 200 - mock.head "/people/Greg.xml", {}, nil, 200 - mock.head "/people/99.xml", {}, nil, 404 - mock.head "/people/1/addresses/1.xml", {}, nil, 200 - mock.head "/people/1/addresses/2.xml", {}, nil, 404 - mock.head "/people/2/addresses/1.xml", {}, nil, 404 - mock.head "/people/Greg/addresses/1.xml", {}, nil, 200 - # customer - mock.get "/customers/1.xml", {}, @luis - end - - Person.user = nil - Person.password = nil - end - - - def test_site_accessor_accepts_uri_or_string_argument - site = URI.parse('http://localhost') - - assert_nothing_raised { Person.site = 'http://localhost' } - assert_equal site, Person.site - - assert_nothing_raised { Person.site = site } - assert_equal site, Person.site - end - - def test_should_use_site_prefix_and_credentials - assert_equal 'http://foo:bar@beast.caboo.se', Forum.site.to_s - assert_equal 'http://foo:bar@beast.caboo.se/forums/:forum_id', Topic.site.to_s - end - - def test_site_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - assert_nil actor.site - actor.site = 'http://localhost:31337' - actor.site = nil - assert_nil actor.site - end - - def test_proxy_accessor_accepts_uri_or_string_argument - proxy = URI.parse('http://localhost') - - assert_nothing_raised { Person.proxy = 'http://localhost' } - assert_equal proxy, Person.proxy - - assert_nothing_raised { Person.proxy = proxy } - assert_equal proxy, Person.proxy - end - - def test_should_use_proxy_prefix_and_credentials - assert_equal 'http://user:password@proxy.local:3000', ProxyResource.proxy.to_s - end - - def test_proxy_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - assert_nil actor.site - actor.proxy = 'http://localhost:31337' - actor.proxy = nil - assert_nil actor.site - end - - def test_should_accept_setting_user - Forum.user = 'david' - assert_equal('david', Forum.user) - assert_equal('david', Forum.connection.user) - end - - def test_should_accept_setting_password - Forum.password = 'test123' - assert_equal('test123', Forum.password) - assert_equal('test123', Forum.connection.password) - end - - def test_should_accept_setting_timeout - Forum.timeout = 5 - assert_equal(5, Forum.timeout) - assert_equal(5, Forum.connection.timeout) - end - - def test_should_accept_setting_ssl_options - expected = {:verify => 1} - Forum.ssl_options= expected - assert_equal(expected, Forum.ssl_options) - assert_equal(expected, Forum.connection.ssl_options) - end - - def test_user_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'http://cinema' - assert_nil actor.user - actor.user = 'username' - actor.user = nil - assert_nil actor.user - assert_nil actor.connection.user - end - - def test_password_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'http://cinema' - assert_nil actor.password - actor.password = 'username' - actor.password = nil - assert_nil actor.password - assert_nil actor.connection.password - end - - def test_timeout_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'http://cinema' - assert_nil actor.timeout - actor.timeout = 5 - actor.timeout = nil - assert_nil actor.timeout - assert_nil actor.connection.timeout - end - - def test_ssl_options_hash_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'https://cinema' - assert_nil actor.ssl_options - actor.ssl_options = {:foo => 5} - actor.ssl_options = nil - assert_nil actor.ssl_options - assert_nil actor.connection.ssl_options - end - - def test_credentials_from_site_are_decoded - actor = Class.new(ActiveResource::Base) - actor.site = 'http://my%40email.com:%31%32%33@cinema' - assert_equal("my@email.com", actor.user) - assert_equal("123", actor.password) - end - - def test_site_reader_uses_superclass_site_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.site - assert_nil Class.new(ActiveResource::Base).site - - # Subclass uses superclass site. - actor = Class.new(Person) - assert_equal Person.site, actor.site - - # Subclass returns frozen superclass copy. - assert !Person.site.frozen? - assert actor.site.frozen? - - # Changing subclass site doesn't change superclass site. - actor.site = 'http://localhost:31337' - assert_not_equal Person.site, actor.site - - # Changed subclass site is not frozen. - assert !actor.site.frozen? - - # Changing superclass site doesn't overwrite subclass site. - Person.site = 'http://somewhere.else' - assert_not_equal Person.site, actor.site - - # Changing superclass site after subclassing changes subclass site. - jester = Class.new(actor) - actor.site = 'http://nomad' - assert_equal actor.site, jester.site - assert jester.site.frozen? - - # Subclasses are always equal to superclass site when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.site = 'http://market' - assert_equal fruit.site, apple.site, 'subclass did not adopt changes from parent class' - - fruit.site = 'http://supermarket' - assert_equal fruit.site, apple.site, 'subclass did not adopt changes from parent class' - end - - def test_proxy_reader_uses_superclass_site_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.proxy - assert_nil Class.new(ActiveResource::Base).proxy - - # Subclass uses superclass proxy. - actor = Class.new(Person) - assert_equal Person.proxy, actor.proxy - - # Subclass returns frozen superclass copy. - assert !Person.proxy.frozen? - assert actor.proxy.frozen? - - # Changing subclass proxy doesn't change superclass site. - actor.proxy = 'http://localhost:31337' - assert_not_equal Person.proxy, actor.proxy - - # Changed subclass proxy is not frozen. - assert !actor.proxy.frozen? - - # Changing superclass proxy doesn't overwrite subclass site. - Person.proxy = 'http://somewhere.else' - assert_not_equal Person.proxy, actor.proxy - - # Changing superclass proxy after subclassing changes subclass site. - jester = Class.new(actor) - actor.proxy = 'http://nomad' - assert_equal actor.proxy, jester.proxy - assert jester.proxy.frozen? - - # Subclasses are always equal to superclass proxy when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.proxy = 'http://market' - assert_equal fruit.proxy, apple.proxy, 'subclass did not adopt changes from parent class' - - fruit.proxy = 'http://supermarket' - assert_equal fruit.proxy, apple.proxy, 'subclass did not adopt changes from parent class' - end - - def test_user_reader_uses_superclass_user_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.user - assert_nil Class.new(ActiveResource::Base).user - Person.user = 'anonymous' - - # Subclass uses superclass user. - actor = Class.new(Person) - assert_equal Person.user, actor.user - - # Subclass returns frozen superclass copy. - assert !Person.user.frozen? - assert actor.user.frozen? - - # Changing subclass user doesn't change superclass user. - actor.user = 'david' - assert_not_equal Person.user, actor.user - - # Changing superclass user doesn't overwrite subclass user. - Person.user = 'john' - assert_not_equal Person.user, actor.user - - # Changing superclass user after subclassing changes subclass user. - jester = Class.new(actor) - actor.user = 'john.doe' - assert_equal actor.user, jester.user - - # Subclasses are always equal to superclass user when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.user = 'manager' - assert_equal fruit.user, apple.user, 'subclass did not adopt changes from parent class' - - fruit.user = 'client' - assert_equal fruit.user, apple.user, 'subclass did not adopt changes from parent class' - end - - def test_password_reader_uses_superclass_password_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.password - assert_nil Class.new(ActiveResource::Base).password - Person.password = 'my-password' - - # Subclass uses superclass password. - actor = Class.new(Person) - assert_equal Person.password, actor.password - - # Subclass returns frozen superclass copy. - assert !Person.password.frozen? - assert actor.password.frozen? - - # Changing subclass password doesn't change superclass password. - actor.password = 'secret' - assert_not_equal Person.password, actor.password - - # Changing superclass password doesn't overwrite subclass password. - Person.password = 'super-secret' - assert_not_equal Person.password, actor.password - - # Changing superclass password after subclassing changes subclass password. - jester = Class.new(actor) - actor.password = 'even-more-secret' - assert_equal actor.password, jester.password - - # Subclasses are always equal to superclass password when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.password = 'mega-secret' - assert_equal fruit.password, apple.password, 'subclass did not adopt changes from parent class' - - fruit.password = 'ok-password' - assert_equal fruit.password, apple.password, 'subclass did not adopt changes from parent class' - end - - def test_timeout_reader_uses_superclass_timeout_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.timeout - assert_nil Class.new(ActiveResource::Base).timeout - Person.timeout = 5 - - # Subclass uses superclass timeout. - actor = Class.new(Person) - assert_equal Person.timeout, actor.timeout - - # Changing subclass timeout doesn't change superclass timeout. - actor.timeout = 10 - assert_not_equal Person.timeout, actor.timeout - - # Changing superclass timeout doesn't overwrite subclass timeout. - Person.timeout = 15 - assert_not_equal Person.timeout, actor.timeout - - # Changing superclass timeout after subclassing changes subclass timeout. - jester = Class.new(actor) - actor.timeout = 20 - assert_equal actor.timeout, jester.timeout - - # Subclasses are always equal to superclass timeout when not overridden. - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.timeout = 25 - assert_equal fruit.timeout, apple.timeout, 'subclass did not adopt changes from parent class' - - fruit.timeout = 30 - assert_equal fruit.timeout, apple.timeout, 'subclass did not adopt changes from parent class' - end - - def test_ssl_options_reader_uses_superclass_ssl_options_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.ssl_options - assert_nil Class.new(ActiveResource::Base).ssl_options - Person.ssl_options = {:foo => 'bar'} - - # Subclass uses superclass ssl_options. - actor = Class.new(Person) - assert_equal Person.ssl_options, actor.ssl_options - - # Changing subclass ssl_options doesn't change superclass ssl_options. - actor.ssl_options = {:baz => ''} - assert_not_equal Person.ssl_options, actor.ssl_options - - # Changing superclass ssl_options doesn't overwrite subclass ssl_options. - Person.ssl_options = {:color => 'blue'} - assert_not_equal Person.ssl_options, actor.ssl_options - - # Changing superclass ssl_options after subclassing changes subclass ssl_options. - jester = Class.new(actor) - actor.ssl_options = {:color => 'red'} - assert_equal actor.ssl_options, jester.ssl_options - - # Subclasses are always equal to superclass ssl_options when not overridden. - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.ssl_options = {:alpha => 'betas'} - assert_equal fruit.ssl_options, apple.ssl_options, 'subclass did not adopt changes from parent class' - - fruit.ssl_options = {:omega => 'moos'} - assert_equal fruit.ssl_options, apple.ssl_options, 'subclass did not adopt changes from parent class' - end - - def test_updating_baseclass_site_object_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass site when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.site = 'http://market' - assert_equal fruit.connection.site, apple.connection.site - first_connection = apple.connection.object_id - - fruit.site = 'http://supermarket' - assert_equal fruit.connection.site, apple.connection.site - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_updating_baseclass_user_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass user when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - fruit.site = 'http://market' - - fruit.user = 'david' - assert_equal fruit.connection.user, apple.connection.user - first_connection = apple.connection.object_id - - fruit.user = 'john' - assert_equal fruit.connection.user, apple.connection.user - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_updating_baseclass_password_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass password when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - fruit.site = 'http://market' - - fruit.password = 'secret' - assert_equal fruit.connection.password, apple.connection.password - first_connection = apple.connection.object_id - - fruit.password = 'supersecret' - assert_equal fruit.connection.password, apple.connection.password - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_updating_baseclass_timeout_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass timeout when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - fruit.site = 'http://market' - - fruit.timeout = 5 - assert_equal fruit.connection.timeout, apple.connection.timeout - first_connection = apple.connection.object_id - - fruit.timeout = 10 - assert_equal fruit.connection.timeout, apple.connection.timeout - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_collection_name - assert_equal "people", Person.collection_name - end - - def test_collection_path - assert_equal '/people.xml', Person.collection_path - end - - def test_collection_path_with_parameters - assert_equal '/people.xml?gender=male', Person.collection_path(:gender => 'male') - assert_equal '/people.xml?gender=false', Person.collection_path(:gender => false) - assert_equal '/people.xml?gender=', Person.collection_path(:gender => nil) - - assert_equal '/people.xml?gender=male', Person.collection_path('gender' => 'male') - - # Use includes? because ordering of param hash is not guaranteed - assert Person.collection_path(:gender => 'male', :student => true).include?('/people.xml?') - assert Person.collection_path(:gender => 'male', :student => true).include?('gender=male') - assert Person.collection_path(:gender => 'male', :student => true).include?('student=true') - - assert_equal '/people.xml?name%5B%5D=bob&name%5B%5D=your+uncle%2Bme&name%5B%5D=&name%5B%5D=false', Person.collection_path(:name => ['bob', 'your uncle+me', nil, false]) - - assert_equal '/people.xml?struct%5Ba%5D%5B%5D=2&struct%5Ba%5D%5B%5D=1&struct%5Bb%5D=fred', Person.collection_path(:struct => {:a => [2,1], 'b' => 'fred'}) - end - - def test_custom_element_path - assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1) - assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 1) - assert_equal '/people/Greg/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 'Greg') - end - - def test_custom_element_path_with_redefined_to_param - Person.module_eval do - alias_method :original_to_param_element_path, :to_param - def to_param - name - end - end - - # Class method. - assert_equal '/people/Greg.xml', Person.element_path('Greg') - - # Protected Instance method. - assert_equal '/people/Greg.xml', Person.find('Greg').send(:element_path) - - ensure - # revert back to original - Person.module_eval do - # save the 'new' to_param so we don't get a warning about discarding the method - alias_method :element_path_to_param, :to_param - alias_method :to_param, :original_to_param_element_path - end - end - - def test_custom_element_path_with_parameters - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :person_id => 1, :type => 'work') - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, 'person_id' => 1, :type => 'work') - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :type => 'work', :person_id => 1) - assert_equal '/people/1/addresses/1.xml?type%5B%5D=work&type%5B%5D=play+time', StreetAddress.element_path(1, :person_id => 1, :type => ['work', 'play time']) - end - - def test_custom_element_path_with_prefix_and_parameters - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, {:person_id => 1}, {:type => 'work'}) - end - - def test_custom_collection_path - assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1) - assert_equal '/people/1/addresses.xml', StreetAddress.collection_path('person_id' => 1) - end - - def test_custom_collection_path_with_parameters - assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path(:person_id => 1, :type => 'work') - assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path('person_id' => 1, :type => 'work') - end - - def test_custom_collection_path_with_prefix_and_parameters - assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path({:person_id => 1}, {:type => 'work'}) - end - - def test_custom_element_name - assert_equal 'address', StreetAddress.element_name - end - - def test_custom_collection_name - assert_equal 'addresses', StreetAddress.collection_name - end - - def test_prefix - assert_equal "/", Person.prefix - assert_equal Set.new, Person.__send__(:prefix_parameters) - end - - def test_set_prefix - SetterTrap.rollback_sets(Person) do |person_class| - person_class.prefix = "the_prefix" - assert_equal "the_prefix", person_class.prefix - end - end - - def test_set_prefix_with_inline_keys - SetterTrap.rollback_sets(Person) do |person_class| - person_class.prefix = "the_prefix:the_param" - assert_equal "the_prefixthe_param_value", person_class.prefix(:the_param => "the_param_value") - end - end - - def test_set_prefix_twice_should_clear_params - SetterTrap.rollback_sets(Person) do |person_class| - person_class.prefix = "the_prefix/:the_param1" - assert_equal Set.new([:the_param1]), person_class.prefix_parameters - person_class.prefix = "the_prefix/:the_param2" - assert_equal Set.new([:the_param2]), person_class.prefix_parameters - end - end - - def test_set_prefix_with_default_value - SetterTrap.rollback_sets(Person) do |person_class| - person_class.set_prefix - assert_equal "/", person_class.prefix - end - end - - def test_custom_prefix - assert_equal '/people//', StreetAddress.prefix - assert_equal '/people/1/', StreetAddress.prefix(:person_id => 1) - assert_equal [:person_id].to_set, StreetAddress.__send__(:prefix_parameters) - end - - def test_find_by_id - matz = Person.find(1) - assert_kind_of Person, matz - assert_equal "Matz", matz.name - assert matz.name? - end - - def test_respond_to - matz = Person.find(1) - assert matz.respond_to?(:name) - assert matz.respond_to?(:name=) - assert matz.respond_to?(:name?) - assert !matz.respond_to?(:super_scalable_stuff) - end - - def test_find_by_id_with_custom_prefix - addy = StreetAddress.find(1, :params => { :person_id => 1 }) - assert_kind_of StreetAddress, addy - assert_equal '12345 Street', addy.street - end - - def test_find_all - all = Person.find(:all) - assert_equal 2, all.size - assert_kind_of Person, all.first - assert_equal "Matz", all.first.name - assert_equal "David", all.last.name - end - - def test_find_first - matz = Person.find(:first) - assert_kind_of Person, matz - assert_equal "Matz", matz.name - end - - def test_find_last - david = Person.find(:last) - assert_kind_of Person, david - assert_equal 'David', david.name - end - - def test_custom_header - Person.headers['key'] = 'value' - assert_raise(ActiveResource::ResourceNotFound) { Person.find(4) } - ensure - Person.headers.delete('key') - end - - def test_find_by_id_not_found - assert_raise(ActiveResource::ResourceNotFound) { Person.find(99) } - assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1) } - end - - def test_find_all_by_from - ActiveResource::HttpMock.respond_to { |m| m.get "/companies/1/people.xml", {}, @people_david } - - people = Person.find(:all, :from => "/companies/1/people.xml") - assert_equal 1, people.size - assert_equal "David", people.first.name - end - - def test_find_all_by_from_with_options - ActiveResource::HttpMock.respond_to { |m| m.get "/companies/1/people.xml", {}, @people_david } - - people = Person.find(:all, :from => "/companies/1/people.xml") - assert_equal 1, people.size - assert_equal "David", people.first.name - end - - def test_find_all_by_symbol_from - ActiveResource::HttpMock.respond_to { |m| m.get "/people/managers.xml", {}, @people_david } - - people = Person.find(:all, :from => :managers) - assert_equal 1, people.size - assert_equal "David", people.first.name - end - - def test_find_single_by_from - ActiveResource::HttpMock.respond_to { |m| m.get "/companies/1/manager.xml", {}, @david } - - david = Person.find(:one, :from => "/companies/1/manager.xml") - assert_equal "David", david.name - end - - def test_find_single_by_symbol_from - ActiveResource::HttpMock.respond_to { |m| m.get "/people/leader.xml", {}, @david } - - david = Person.find(:one, :from => :leader) - assert_equal "David", david.name - end - - def test_save - rick = Person.new - assert_equal true, rick.save - assert_equal '5', rick.id - end - - def test_id_from_response - p = Person.new - resp = {'Location' => '/foo/bar/1'} - assert_equal '1', p.__send__(:id_from_response, resp) - - resp['Location'] << '.xml' - assert_equal '1', p.__send__(:id_from_response, resp) - end - - def test_id_from_response_without_location - p = Person.new - resp = {} - assert_equal nil, p.__send__(:id_from_response, resp) - end - - def test_create_with_custom_prefix - matzs_house = StreetAddress.new(:person_id => 1) - matzs_house.save - assert_equal '5', matzs_house.id - end - - # Test that loading a resource preserves its prefix_options. - def test_load_preserves_prefix_options - address = StreetAddress.find(1, :params => { :person_id => 1 }) - ryan = Person.new(:id => 1, :name => 'Ryan', :address => address) - assert_equal address.prefix_options, ryan.address.prefix_options - end - - def test_reload_works_with_prefix_options - address = StreetAddress.find(1, :params => { :person_id => 1 }) - assert_equal address, address.reload - end - - def test_reload_with_redefined_to_param - Person.module_eval do - alias_method :original_to_param_reload, :to_param - def to_param - name - end - end - - person = Person.find('Greg') - assert_equal person, person.reload - - ensure - # revert back to original - Person.module_eval do - # save the 'new' to_param so we don't get a warning about discarding the method - alias_method :reload_to_param, :to_param - alias_method :to_param, :original_to_param_reload - end - end - - def test_reload_works_without_prefix_options - person = Person.find(:first) - assert_equal person, person.reload - end - - def test_create - rick = Person.create(:name => 'Rick') - assert rick.valid? - assert !rick.new? - assert_equal '5', rick.id - - # test additional attribute returned on create - assert_equal 25, rick.age - - # Test that save exceptions get bubbled up too - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, nil, 409 - end - assert_raise(ActiveResource::ResourceConflict) { Person.create(:name => 'Rick') } - end - - def test_create_without_location - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, nil, 201 - end - person = Person.create(:name => 'Rick') - assert_equal nil, person.id - end - - def test_clone - matz = Person.find(1) - matz_c = matz.clone - assert matz_c.new? - matz.attributes.each do |k, v| - assert_equal v, matz_c.send(k) if k != Person.primary_key - end - end - - def test_nested_clone - addy = StreetAddress.find(1, :params => {:person_id => 1}) - addy_c = addy.clone - assert addy_c.new? - addy.attributes.each do |k, v| - assert_equal v, addy_c.send(k) if k != StreetAddress.primary_key - end - assert_equal addy.prefix_options, addy_c.prefix_options - end - - def test_complex_clone - matz = Person.find(1) - matz.address = StreetAddress.find(1, :params => {:person_id => matz.id}) - matz.non_ar_hash = {:not => "an ARes instance"} - matz.non_ar_arr = ["not", "ARes"] - matz_c = matz.clone - assert matz_c.new? - assert_raise(NoMethodError) {matz_c.address} - assert_equal matz.non_ar_hash, matz_c.non_ar_hash - assert_equal matz.non_ar_arr, matz_c.non_ar_arr - - # Test that actual copy, not just reference copy - matz.non_ar_hash[:not] = "changed" - assert_not_equal matz.non_ar_hash, matz_c.non_ar_hash - end - - def test_update - matz = Person.find(:first) - matz.name = "David" - assert_kind_of Person, matz - assert_equal "David", matz.name - assert_equal true, matz.save - end - - def test_update_with_custom_prefix_with_specific_id - addy = StreetAddress.find(1, :params => { :person_id => 1 }) - addy.street = "54321 Street" - assert_kind_of StreetAddress, addy - assert_equal "54321 Street", addy.street - addy.save - end - - def test_update_with_custom_prefix_without_specific_id - addy = StreetAddress.find(:first, :params => { :person_id => 1 }) - addy.street = "54321 Lane" - assert_kind_of StreetAddress, addy - assert_equal "54321 Lane", addy.street - addy.save - end - - def test_update_conflict - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.xml", {}, @david - mock.put "/people/2.xml", @default_request_headers, nil, 409 - end - assert_raise(ActiveResource::ResourceConflict) { Person.find(2).save } - end - - def test_destroy - assert Person.find(1).destroy - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { Person.find(1).destroy } - end - - def test_destroy_with_custom_prefix - assert StreetAddress.find(1, :params => { :person_id => 1 }).destroy - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1/addresses/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } - end - - def test_destroy_with_410_gone - assert Person.find(1).destroy - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, nil, 410 - end - assert_raise(ActiveResource::ResourceGone) { Person.find(1).destroy } - end - - def test_delete - assert Person.delete(1) - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { Person.find(1) } - end - - def test_delete_with_custom_prefix - assert StreetAddress.delete(1, :person_id => 1) - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1/addresses/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } - end - - def test_delete_with_410_gone - assert Person.delete(1) - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, nil, 410 - end - assert_raise(ActiveResource::ResourceGone) { Person.find(1) } - end - - def test_exists - # Class method. - assert !Person.exists?(nil) - assert Person.exists?(1) - assert !Person.exists?(99) - - # Instance method. - assert !Person.new.exists? - assert Person.find(1).exists? - assert !Person.new(:id => 99).exists? - - # Nested class method. - assert StreetAddress.exists?(1, :params => { :person_id => 1 }) - assert !StreetAddress.exists?(1, :params => { :person_id => 2 }) - assert !StreetAddress.exists?(2, :params => { :person_id => 1 }) - - # Nested instance method. - assert StreetAddress.find(1, :params => { :person_id => 1 }).exists? - assert !StreetAddress.new({:id => 1, :person_id => 2}).exists? - assert !StreetAddress.new({:id => 2, :person_id => 1}).exists? - end - - def test_exists_with_redefined_to_param - Person.module_eval do - alias_method :original_to_param_exists, :to_param - def to_param - name - end - end - - # Class method. - assert Person.exists?('Greg') - - # Instance method. - assert Person.find('Greg').exists? - - # Nested class method. - assert StreetAddress.exists?(1, :params => { :person_id => Person.find('Greg').to_param }) - - # Nested instance method. - assert StreetAddress.find(1, :params => { :person_id => Person.find('Greg').to_param }).exists? - - ensure - # revert back to original - Person.module_eval do - # save the 'new' to_param so we don't get a warning about discarding the method - alias_method :exists_to_param, :to_param - alias_method :to_param, :original_to_param_exists - end - end - - def test_exists_without_http_mock - http = Net::HTTP.new(Person.site.host, Person.site.port) - ActiveResource::Connection.any_instance.expects(:http).returns(http) - http.expects(:request).returns(ActiveResource::Response.new("")) - - assert Person.exists?('not-mocked') - end - - def test_exists_with_410_gone - ActiveResource::HttpMock.respond_to do |mock| - mock.head "/people/1.xml", {}, nil, 410 - end - - assert !Person.exists?(1) - end - - def test_to_xml - matz = Person.find(1) - xml = matz.encode - assert xml.starts_with?('<?xml version="1.0" encoding="UTF-8"?>') - assert xml.include?('<name>Matz</name>') - assert xml.include?('<id type="integer">1</id>') - end - - def test_to_xml_with_element_name - old_elem_name = Person.element_name - matz = Person.find(1) - Person.element_name = 'ruby_creator' - xml = matz.encode - - assert xml.include?('<?xml version="1.0" encoding="UTF-8"?>') - assert xml.include?('<ruby-creator>') - assert xml.include?('<name>Matz</name>') - assert xml.include?('<id type="integer">1</id>') - assert xml.include?('</ruby-creator>') - ensure - Person.element_name = old_elem_name - end - - def test_to_json_including_root - Person.include_root_in_json = true - Person.format = :json - joe = Person.find(6) - json = joe.encode - assert_match '{"person":{"person":{', json - assert_match '"name":"Joe"', json - assert_match '"id":6', json - ensure - Person.format = :xml - Person.include_root_in_json = false - end - - def test_to_json_with_element_name - old_elem_name = Person.element_name - Person.include_root_in_json = true - Person.format = :json - joe = Person.find(6) - Person.element_name = 'ruby_creator' - json = joe.encode - Person.format = :xml - - assert_match %r{^\{"ruby_creator":\{"person":\{}, json - assert_match %r{"id":6}, json - assert_match %r{"name":"Joe"}, json - assert_match %r{\}\}\}$}, json - ensure - Person.element_name = old_elem_name - Person.include_root_in_json = false - end - - def test_to_param_quacks_like_active_record - new_person = Person.new - assert_nil new_person.to_param - matz = Person.find(1) - assert_equal '1', matz.to_param - end - - def test_parse_deep_nested_resources - luis = Customer.find(1) - assert_kind_of Customer, luis - luis.friends.each do |friend| - assert_kind_of Customer::Friend, friend - friend.brothers.each do |brother| - assert_kind_of Customer::Friend::Brother, brother - brother.children.each do |child| - assert_kind_of Customer::Friend::Brother::Child, child - end - end - end - end - - def test_load_yaml_array - assert_nothing_raised do - marty = Person.find(5) - assert_equal 3, marty.colors.size - marty.colors.each do |color| - assert_kind_of String, color - end - end - end -end diff --git a/vendor/rails/activeresource/test/connection_test.rb b/vendor/rails/activeresource/test/connection_test.rb deleted file mode 100644 index d7466c65..00000000 --- a/vendor/rails/activeresource/test/connection_test.rb +++ /dev/null @@ -1,238 +0,0 @@ -require 'abstract_unit' - -class ConnectionTest < Test::Unit::TestCase - ResponseCodeStub = Struct.new(:code) - - def setup - @conn = ActiveResource::Connection.new('http://localhost') - @matz = { :id => 1, :name => 'Matz' } - @david = { :id => 2, :name => 'David' } - @people = [ @matz, @david ].to_xml(:root => 'people') - @people_single = [ @matz ].to_xml(:root => 'people-single-elements') - @people_empty = [ ].to_xml(:root => 'people-empty-elements') - @matz = @matz.to_xml(:root => 'person') - @david = @david.to_xml(:root => 'person') - @header = {'key' => 'value'}.freeze - - @default_request_headers = { 'Content-Type' => 'application/xml' } - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.xml", @header, @david - mock.get "/people.xml", {}, @people - mock.get "/people_single_elements.xml", {}, @people_single - mock.get "/people_empty_elements.xml", {}, @people_empty - mock.get "/people/1.xml", {}, @matz - mock.put "/people/1.xml", {}, nil, 204 - mock.put "/people/2.xml", {}, @header, 204 - mock.delete "/people/1.xml", {}, nil, 200 - mock.delete "/people/2.xml", @header, nil, 200 - mock.post "/people.xml", {}, nil, 201, 'Location' => '/people/5.xml' - mock.post "/members.xml", {}, @header, 201, 'Location' => '/people/6.xml' - mock.head "/people/1.xml", {}, nil, 200 - end - end - - def test_handle_response - # 2xx and 3xx are valid responses. - [200, 299, 300, 399].each do |code| - expected = ResponseCodeStub.new(code) - assert_equal expected, handle_response(expected) - end - - # 400 is a bad request (e.g. malformed URI or missing request parameter) - assert_response_raises ActiveResource::BadRequest, 400 - - # 401 is an unauthorized request - assert_response_raises ActiveResource::UnauthorizedAccess, 401 - - # 403 is a forbidden requst (and authorizing will not help) - assert_response_raises ActiveResource::ForbiddenAccess, 403 - - # 404 is a missing resource. - assert_response_raises ActiveResource::ResourceNotFound, 404 - - # 405 is a missing not allowed error - assert_response_raises ActiveResource::MethodNotAllowed, 405 - - # 409 is an optimistic locking error - assert_response_raises ActiveResource::ResourceConflict, 409 - - # 410 is a removed resource - assert_response_raises ActiveResource::ResourceGone, 410 - - # 422 is a validation error - assert_response_raises ActiveResource::ResourceInvalid, 422 - - # 4xx are client errors. - [402, 499].each do |code| - assert_response_raises ActiveResource::ClientError, code - end - - # 5xx are server errors. - [500, 599].each do |code| - assert_response_raises ActiveResource::ServerError, code - end - - # Others are unknown. - [199, 600].each do |code| - assert_response_raises ActiveResource::ConnectionError, code - end - end - - ResponseHeaderStub = Struct.new(:code, :message, 'Allow') - def test_should_return_allowed_methods_for_method_no_allowed_exception - begin - handle_response ResponseHeaderStub.new(405, "HTTP Failed...", "GET, POST") - rescue ActiveResource::MethodNotAllowed => e - assert_equal "Failed with 405 HTTP Failed...", e.message - assert_equal [:get, :post], e.allowed_methods - end - end - - def test_initialize_raises_argument_error_on_missing_site - assert_raise(ArgumentError) { ActiveResource::Connection.new(nil) } - end - - def test_site_accessor_accepts_uri_or_string_argument - site = URI.parse("http://localhost") - - assert_raise(URI::InvalidURIError) { @conn.site = nil } - - assert_nothing_raised { @conn.site = "http://localhost" } - assert_equal site, @conn.site - - assert_nothing_raised { @conn.site = site } - assert_equal site, @conn.site - end - - def test_proxy_accessor_accepts_uri_or_string_argument - proxy = URI.parse("http://proxy_user:proxy_password@proxy.local:4242") - - assert_nothing_raised { @conn.proxy = "http://proxy_user:proxy_password@proxy.local:4242" } - assert_equal proxy, @conn.proxy - - assert_nothing_raised { @conn.proxy = proxy } - assert_equal proxy, @conn.proxy - end - - def test_timeout_accessor - @conn.timeout = 5 - assert_equal 5, @conn.timeout - end - - def test_get - matz = @conn.get("/people/1.xml") - assert_equal "Matz", matz["name"] - end - - def test_head - response = @conn.head("/people/1.xml") - assert response.body.blank? - assert_equal 200, response.code - end - - def test_get_with_header - david = @conn.get("/people/2.xml", @header) - assert_equal "David", david["name"] - end - - def test_get_collection - people = @conn.get("/people.xml") - assert_equal "Matz", people[0]["name"] - assert_equal "David", people[1]["name"] - end - - def test_get_collection_single - people = @conn.get("/people_single_elements.xml") - assert_equal "Matz", people[0]["name"] - end - - def test_get_collection_empty - people = @conn.get("/people_empty_elements.xml") - assert_equal [], people - end - - def test_post - response = @conn.post("/people.xml") - assert_equal "/people/5.xml", response["Location"] - end - - def test_post_with_header - response = @conn.post("/members.xml", @header) - assert_equal "/people/6.xml", response["Location"] - end - - def test_put - response = @conn.put("/people/1.xml") - assert_equal 204, response.code - end - - def test_put_with_header - response = @conn.put("/people/2.xml", @header) - assert_equal 204, response.code - end - - def test_delete - response = @conn.delete("/people/1.xml") - assert_equal 200, response.code - end - - def test_delete_with_header - response = @conn.delete("/people/2.xml", @header) - assert_equal 200, response.code - end - - def test_timeout - @http = mock('new Net::HTTP') - @conn.expects(:http).returns(@http) - @http.expects(:get).raises(Timeout::Error, 'execution expired') - assert_raise(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') } - end - - def test_setting_timeout - http = Net::HTTP.new('') - - [10, 20].each do |timeout| - @conn.timeout = timeout - @conn.send(:configure_http, http) - assert_equal timeout, http.open_timeout - assert_equal timeout, http.read_timeout - end - end - - def test_accept_http_header - @http = mock('new Net::HTTP') - @conn.expects(:http).returns(@http) - path = '/people/1.xml' - @http.expects(:get).with(path, {'Accept' => 'application/xhtml+xml'}).returns(ActiveResource::Response.new(@matz, 200, {'Content-Type' => 'text/xhtml'})) - assert_nothing_raised(Mocha::ExpectationError) { @conn.get(path, {'Accept' => 'application/xhtml+xml'}) } - end - - def test_ssl_options_get_applied_to_http - http = Net::HTTP.new('') - @conn.site="https://secure" - @conn.ssl_options={:verify_mode => OpenSSL::SSL::VERIFY_PEER} - @conn.timeout = 10 # prevent warning about uninitialized. - @conn.send(:configure_http, http) - - assert http.use_ssl? - assert_equal http.verify_mode, OpenSSL::SSL::VERIFY_PEER - end - - def test_ssl_error - http = Net::HTTP.new('') - @conn.expects(:http).returns(http) - http.expects(:get).raises(OpenSSL::SSL::SSLError, 'Expired certificate') - assert_raise(ActiveResource::SSLError) { @conn.get('/people/1.xml') } - end - - protected - def assert_response_raises(klass, code) - assert_raise(klass, "Expected response code #{code} to raise #{klass}") do - handle_response ResponseCodeStub.new(code) - end - end - - def handle_response(response) - @conn.__send__(:handle_response, response) - end -end diff --git a/vendor/rails/activeresource/test/fixtures/beast.rb b/vendor/rails/activeresource/test/fixtures/beast.rb deleted file mode 100644 index e31ec583..00000000 --- a/vendor/rails/activeresource/test/fixtures/beast.rb +++ /dev/null @@ -1,14 +0,0 @@ -class BeastResource < ActiveResource::Base - self.site = 'http://beast.caboo.se' - site.user = 'foo' - site.password = 'bar' -end - -class Forum < BeastResource - # taken from BeastResource - # self.site = 'http://beast.caboo.se' -end - -class Topic < BeastResource - self.site += '/forums/:forum_id' -end diff --git a/vendor/rails/activeresource/test/fixtures/customer.rb b/vendor/rails/activeresource/test/fixtures/customer.rb deleted file mode 100644 index 845d5d11..00000000 --- a/vendor/rails/activeresource/test/fixtures/customer.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Customer < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" -end diff --git a/vendor/rails/activeresource/test/fixtures/person.rb b/vendor/rails/activeresource/test/fixtures/person.rb deleted file mode 100644 index e88bb693..00000000 --- a/vendor/rails/activeresource/test/fixtures/person.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Person < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" -end diff --git a/vendor/rails/activeresource/test/fixtures/proxy.rb b/vendor/rails/activeresource/test/fixtures/proxy.rb deleted file mode 100644 index bb8e015d..00000000 --- a/vendor/rails/activeresource/test/fixtures/proxy.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ProxyResource < ActiveResource::Base - self.site = "http://localhost" - self.proxy = "http://user:password@proxy.local:3000" -end \ No newline at end of file diff --git a/vendor/rails/activeresource/test/fixtures/street_address.rb b/vendor/rails/activeresource/test/fixtures/street_address.rb deleted file mode 100644 index 94a86702..00000000 --- a/vendor/rails/activeresource/test/fixtures/street_address.rb +++ /dev/null @@ -1,4 +0,0 @@ -class StreetAddress < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000/people/:person_id/" - self.element_name = 'address' -end diff --git a/vendor/rails/activeresource/test/format_test.rb b/vendor/rails/activeresource/test/format_test.rb deleted file mode 100644 index c3733e13..00000000 --- a/vendor/rails/activeresource/test/format_test.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/street_address" - -class FormatTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' } - @david = { :id => 2, :name => 'David' } - - @programmers = [ @matz, @david ] - end - - def test_http_format_header_name - header_name = ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:get] - assert_equal 'Accept', header_name - - headers_names = [ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:put], ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:post]] - headers_names.each{ |name| assert_equal 'Content-Type', name } - end - - def test_formats_on_single_element - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.get "/people/1.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@david) - assert_equal @david[:name], Person.find(1).name - end - end - end - - def test_formats_on_collection - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.get "/people.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@programmers) - remote_programmers = Person.find(:all) - assert_equal 2, remote_programmers.size - assert remote_programmers.select { |p| p.name == 'David' } - end - end - end - - def test_formats_on_custom_collection_method - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.get "/people/retrieve.#{format}?name=David", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode([@david]) - remote_programmers = Person.get(:retrieve, :name => 'David') - assert_equal 1, remote_programmers.size - assert_equal @david[:id], remote_programmers[0]['id'] - assert_equal @david[:name], remote_programmers[0]['name'] - end - end - end - - def test_formats_on_custom_element_method - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@david) - mock.get "/people/2/shallow.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@david) - end - remote_programmer = Person.find(2).get(:shallow) - assert_equal @david[:id], remote_programmer['id'] - assert_equal @david[:name], remote_programmer['name'] - end - end - - for format in [ :json, :xml ] - ryan = ActiveResource::Formats[format].encode({ :name => 'Ryan' }) - using_format(Person, format) do - remote_ryan = Person.new(:name => 'Ryan') - ActiveResource::HttpMock.respond_to.post "/people.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, ryan, 201, {'Location' => "/people/5.#{format}"} - remote_ryan.save - - remote_ryan = Person.new(:name => 'Ryan') - ActiveResource::HttpMock.respond_to.post "/people/new/register.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, ryan, 201, {'Location' => "/people/5.#{format}"} - assert_equal ActiveResource::Response.new(ryan, 201, {'Location' => "/people/5.#{format}"}), remote_ryan.post(:register) - end - end - end - - def test_setting_format_before_site - resource = Class.new(ActiveResource::Base) - resource.format = :json - resource.site = 'http://37s.sunrise.i:3000' - assert_equal ActiveResource::Formats[:json], resource.connection.format - end - - def test_serialization_of_nested_resource - address = { :street => '12345 Street' } - person = { :name=> 'Rus', :address => address} - - [:json, :xml].each do |format| - encoded_person = ActiveResource::Formats[format].encode(person) - assert_match(/12345 Street/, encoded_person) - remote_person = Person.new(person.update({:address => StreetAddress.new(address)})) - assert_kind_of StreetAddress, remote_person.address - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.post "/people.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, encoded_person, 201, {'Location' => "/people/5.#{format}"} - remote_person.save - end - end - end - - private - def using_format(klass, mime_type_reference) - previous_format = klass.format - klass.format = mime_type_reference - - yield - ensure - klass.format = previous_format - end -end diff --git a/vendor/rails/activeresource/test/http_mock_test.rb b/vendor/rails/activeresource/test/http_mock_test.rb deleted file mode 100644 index 02ef115b..00000000 --- a/vendor/rails/activeresource/test/http_mock_test.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'abstract_unit' - -class HttpMockTest < ActiveSupport::TestCase - def setup - @http = ActiveResource::HttpMock.new("http://example.com") - end - - FORMAT_HEADER = { :get => 'Accept', - :put => 'Content-Type', - :post => 'Content-Type', - :delete => 'Accept', - :head => 'Accept' - } - - [:post, :put, :get, :delete, :head].each do |method| - test "responds to simple #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {FORMAT_HEADER[method] => "application/xml"}, "Response") - end - - assert_equal "Response", request(method, "/people/1", FORMAT_HEADER[method] => "application/xml").body - end - - test "adds format header by default to #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {}, "Response") - end - - assert_equal "Response", request(method, "/people/1", FORMAT_HEADER[method] => "application/xml").body - end - - test "respond only when headers match header by default to #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {"X-Header" => "X"}, "Response") - end - - assert_equal "Response", request(method, "/people/1", "X-Header" => "X").body - assert_raise(ActiveResource::InvalidRequestError) { request(method, "/people/1") } - end - - test "does not overwrite format header to #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {FORMAT_HEADER[method] => "application/json"}, "Response") - end - - assert_equal "Response", request(method, "/people/1", FORMAT_HEADER[method] => "application/json").body - end - - test "ignores format header when there is only one response to same url in a #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {}, "Response") - end - - assert_equal "Response", request(method, "/people/1", FORMAT_HEADER[method] => "application/json").body - assert_equal "Response", request(method, "/people/1", FORMAT_HEADER[method] => "application/xml").body - end - - test "responds correctly when format header is given to #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {FORMAT_HEADER[method] => "application/xml"}, "XML") - mock.send(method, "/people/1", {FORMAT_HEADER[method] => "application/json"}, "Json") - end - - assert_equal "XML", request(method, "/people/1", FORMAT_HEADER[method] => "application/xml").body - assert_equal "Json", request(method, "/people/1", FORMAT_HEADER[method] => "application/json").body - end - - test "raises InvalidRequestError if no response found for the #{method} request" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(method, "/people/1", {FORMAT_HEADER[method] => "application/xml"}, "XML") - end - - assert_raise(::ActiveResource::InvalidRequestError) do - request(method, "/people/1", FORMAT_HEADER[method] => "application/json") - end - end - - end - - test "allows you to send in pairs directly to the respond_to method" do - matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - - create_matz = ActiveResource::Request.new(:post, '/people.xml', matz, {}) - created_response = ActiveResource::Response.new("", 201, {"Location" => "/people/1.xml"}) - get_matz = ActiveResource::Request.new(:get, '/people/1.xml', nil) - ok_response = ActiveResource::Response.new(matz, 200, {}) - - pairs = {create_matz => created_response, get_matz => ok_response} - - ActiveResource::HttpMock.respond_to(pairs) - assert_equal 2, ActiveResource::HttpMock.responses.length - assert_equal "", ActiveResource::HttpMock.responses.assoc(create_matz)[1].body - assert_equal matz, ActiveResource::HttpMock.responses.assoc(get_matz)[1].body - end - - test "resets all mocked responses on each call to respond_to with a block by default" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(:get, "/people/1", {}, "XML1") - end - assert_equal 1, ActiveResource::HttpMock.responses.length - - ActiveResource::HttpMock.respond_to do |mock| - mock.send(:get, "/people/2", {}, "XML2") - end - assert_equal 1, ActiveResource::HttpMock.responses.length - end - - test "resets all mocked responses on each call to respond_to by passing pairs by default" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(:get, "/people/1", {}, "XML1") - end - assert_equal 1, ActiveResource::HttpMock.responses.length - - matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - get_matz = ActiveResource::Request.new(:get, '/people/1.xml', nil) - ok_response = ActiveResource::Response.new(matz, 200, {}) - ActiveResource::HttpMock.respond_to({get_matz => ok_response}) - - assert_equal 1, ActiveResource::HttpMock.responses.length - end - - test "allows you to add new responses to the existing responses by calling a block" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(:get, "/people/1", {}, "XML1") - end - assert_equal 1, ActiveResource::HttpMock.responses.length - - ActiveResource::HttpMock.respond_to(false) do |mock| - mock.send(:get, "/people/2", {}, "XML2") - end - assert_equal 2, ActiveResource::HttpMock.responses.length - end - - test "allows you to add new responses to the existing responses by passing pairs" do - ActiveResource::HttpMock.respond_to do |mock| - mock.send(:get, "/people/1", {}, "XML1") - end - assert_equal 1, ActiveResource::HttpMock.responses.length - - matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - get_matz = ActiveResource::Request.new(:get, '/people/1.xml', nil) - ok_response = ActiveResource::Response.new(matz, 200, {}) - ActiveResource::HttpMock.respond_to({get_matz => ok_response}, false) - - assert_equal 2, ActiveResource::HttpMock.responses.length - end - - def request(method, path, headers = {}, body = nil) - if [:put, :post].include? method - @http.send(method, path, body, headers) - else - @http.send(method, path, headers) - end - end -end diff --git a/vendor/rails/activeresource/test/setter_trap.rb b/vendor/rails/activeresource/test/setter_trap.rb deleted file mode 100644 index 7cfd9ca1..00000000 --- a/vendor/rails/activeresource/test/setter_trap.rb +++ /dev/null @@ -1,26 +0,0 @@ -class SetterTrap < ActiveSupport::BasicObject - class << self - def rollback_sets(obj) - trapped = new(obj) - yield(trapped).tap { trapped.rollback_sets } - end - end - - def initialize(obj) - @cache = {} - @obj = obj - end - - def respond_to?(method) - @obj.respond_to?(method) - end - - def method_missing(method, *args, &proc) - @cache[method] ||= @obj.send($`) if method.to_s =~ /=$/ - @obj.send method, *args, &proc - end - - def rollback_sets - @cache.each { |k, v| @obj.send k, v } - end -end diff --git a/vendor/rails/activesupport/CHANGELOG b/vendor/rails/activesupport/CHANGELOG deleted file mode 100644 index 600b5703..00000000 --- a/vendor/rails/activesupport/CHANGELOG +++ /dev/null @@ -1,1383 +0,0 @@ -*2.3.11 (February 9, 2011)* - -*2.3.10 (October 15, 2010)* - - -*2.3.9 (September 4, 2010)* - -* i18n: bundle i18n 0.4.1 for forward compatibility with Rails 3. Deprecates {{foo}} interpolation syntax in favor of 1.9-native %{foo}. - -* Deprecate Kernel#returning in favor of Object#tap since it's included in Ruby 1.8.7 and later. [Santiago Pastorino] - -* Deprecates ActiveSupport::Dependencies.load_(once_)paths, renamed to autoload_(once_)paths. [fxn] - -* Deprecates Array#random_element, renamed to sample to match Ruby 1.9, thanks to Marc-Andre Lafortune. [fxn] - - -*2.3.8 (May 24, 2010)* - -* Version bump. - - -*2.3.7 (May 24, 2010)* - -* HTML safety: fix compatibility with the optional rails_xss plugin. [Nathan Weizenbaum, Santiago Pastorino] - - -*2.3.6 (May 23, 2010)* - -* 1.9 compat: deprecated last_(month|year) in favor of prev_(month|year). [fxn] - -* Deprecated Array#rand in favor of Array#random_element. [Santiago Pastorino, Rizwan Reza] - -* Added Object#presence that returns the object if it's #present? otherwise returns nil [DHH/Colin Kelley] - -* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan] - -* Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice. [Jeremy Kemper] - -* JSON backend for YAJL. Preferred if available. #2666 [Brian Lopez] - -* Introduce String#html_safe for rails_xss plugin and forward-compatibility with Rails 3. [Michael Koziarski, Santiago Pastorino, José Ignacio Costa] - -* Time#- with a DateTime argument behaves the same as with a Time argument, i.e. returns the difference between self and arg as a Float #3476 [Geoff Buesing] - -* YAML serialization for OrderedHash. #3608 [Gregor Schmidt] - -* Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH] - - -*2.3.5 (November 25, 2009)* - -* Minor Bug Fixes and deprecation warnings - -* Update Edinburgh TimeZone to use "Europe/London" instead of "Europe/Dublin" #3310 [Phil Ross] - -* Fixes for the Nokogiri backend for XmlMini - -* Ruby 1.9 Compatibility - - -*2.3.4 (September 4, 2009)* - -* Introduce ActiveSupport::Multibyte.clean to clean invalid multibyte strings. - -* Bug fixes - - -*2.3.3 (July 12, 2009)* - -* JSON: +Object#to_json+ calls +as_json+ to coerce itself into something natively encodable like +Hash+, +Integer+, or +String+. Override +as_json+ instead of +to_json+ so you're JSON-library-agnostic. [Jeremy Kemper] - -* Allow MemCacheStore to be initialized with a MemCache-like object instead of addresses and options [Bryan Helmkamp] - - -*2.3.2 [Final] (March 15, 2009)* - -* XmlMini supports LibXML and Nokogiri backends. #2084, #2190 [Bart ten Brinke, Aaron Patterson] - Example: XmlMini.backend = 'Nokogiri' - -* Vendorize i18n 0.1.3 gem (fixes issues with incompatible character encodings in Ruby 1.9) #2038 [Akira Matsuda] - -* Update bundled memcache-client from 1.5.0.5 to 1.6.4.99. See http://www.mikeperham.com/2009/02/15/memcache-client-performance/ [Mike Perham] - -* Ruby 1.9.1p0 fix: URI.unescape can decode multibyte chars. #2033 [MOROHASHI Kyosuke] - -* Time#to_s(:rfc822) uses #formatted_offset instead of unreliable and non-standard %z directive #1899 [Zachary Zolton] - -* Make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s #1796 [Levin Alexander] - -* Introduce Array.wrap(foo) to wrap the argument in an array unless it's already an array. Wraps nil as an empty array. Use instead of Array(foo) and foo.to_a since they treat String as Enumerable. [Jeremy Kemper] - -* TimeWithZone#xmlschema accepts optional fraction_digits argument [#1725 state:resolved] [Nicholas Dainty] - -* Object#tap shim for Ruby < 1.8.7. Similar to Object#returning, tap yields self then returns self. [Jeremy Kemper] - array.select { ... }.tap(&:inspect).map { ... } - -* TimeWithZone#- gives correct result with wrapped DateTime, and with DateTime argument [Geoff Buesing] - -* Updated i18n gem to version 0.1.1 #1635 [Yaroslav Markin] - -* Add :allow_nil option to delegate. #1127 [Sergio Gil] - -* Add Benchmark.ms convenience method to benchmark realtime in milliseconds. [Jeremy Kemper] - -* Updated included memcache-client to the 1.5.0.5 version which includes fixes from fiveruns and 37signals to deal with failover and timeouts #1535 [Joshua Sierles] - -* Multibyte: add multibyte-safe Chars#ord rather than falling back to String#ord. #1483 [Jason Cheow] - -* I18n support for Array#to_sentence. Introduces support.array.words_connector, .two_words_connector, and .last_word_connector translation keys. #1397 [Akira Matsuda] - -* Added ActiveSupport::OrderedHash#each_key and ActiveSupport::OrderedHash#each_value #1410 [Christoffer Sawicki] - -* Added ActiveSupport::MessageVerifier and MessageEncryptor to aid users who need to store signed and/or encrypted messages. [Michael Koziarski] - -* Added ActiveSupport::BacktraceCleaner to cut down on backtrace noise according to filters and silencers [David Heinemeier Hansson] - -* Added Object#try. ( Taken from http://ozmm.org/posts/try.html ) [Chris Wanstrath] - -* Added Enumerable#none? to check that none of the elements match the block #1408 [Damian Janowski] - -* TimeZone offset tests: use current_period, to ensure TimeZone#utc_offset is up-to-date [Geoff Buesing] - -* Update bundled TZInfo to 0.3.12 [Geoff Buesing] - -* Added lambda merging to OptionMerger (especially useful with named_scope and with_options) #726 [Paweł Kondzior] - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Increment the version of our altered memcache-client to prevent confusion caused when the 1.5.0 gem is installed. - -* Fixed the option merging in Array#to_xml #1126 [Rudolf Gavlas] - -* Make I18n::Backend::Simple reload its translations in development mode [David Heinemeier Hansson/Sven Fuchs] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* TimeWithZone#freeze: preload instance variables so that we can actually freeze [Geoff Buesing] - -* Fix Brasilia timezone #1180 [Marcus Derencius, Kane] - -* Time#advance recognizes fractional days and weeks. Deprecate Durations of fractional months and years #970 [Tom Lea] - -* Add ActiveSupport::Rescuable module abstracting ActionController::Base rescue_from features. [Norbert Crombach, Pratik Naik] - -* Switch from String#chars to String#mb_chars for the unicode proxy. [Manfred Stienstra] - - This helps with 1.8.7 compatibility and also improves performance for some operations by reducing indirection. - -* TimeWithZone #wday, #yday and #to_date avoid trip through #method_missing [Geoff Buesing] - -* Added Time, Date, DateTime and TimeWithZone #past?, #future? and #today? #720 [Clemens Kofler, Geoff Buesing] - -* Fixed Sri Jayawardenepura time zone to map to Asia/Colombo [Jamis Buck] - -* Added Inflector#parameterize for easy slug generation ("Donald E. Knuth".parameterize => "donald-e-knuth") #713 [Matt Darby] - -* Changed cache benchmarking to be reported in milliseconds [David Heinemeier Hansson] - -* Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved] [Luca Guidi, Geoff Buesing] - -* Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example: - - a = (1..10).to_a - a.in_groups(3) #=> [[1, 2, 3, 4], [5, 6, 7, nil], [8, 9, 10, nil]] - a.in_groups(3, false) #=> [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]] - -* Fix TimeWithZone unmarshaling: coerce unmarshaled Time instances to utc, because Ruby's marshaling of Time instances doesn't respect the zone [Geoff Buesing] - -* Added Memoizable mixin for caching simple lazy loaded attributes [Josh Peek] - -* Move the test related core_ext stuff out of core_ext so it's only loaded by the test helpers. [Michael Koziarski] - -* Add Inflection rules for String#humanize. #535 [Dan Manges] - - ActiveSupport::Inflector.inflections do |inflect| - inflect.human(/_cnt$/i, '\1_count') - end - - 'jargon_cnt'.humanize # => 'Jargon count' - -* TimeWithZone: when crossing DST boundary, treat Durations of days, months or years as variable-length, and all other values as absolute length. A time + 24.hours will advance exactly 24 hours, but a time + 1.day will advance 23-25 hours, depending on the day. Ensure consistent behavior across all advancing methods [Geoff Buesing] - -* Added TimeZone #=~, to support matching zones by regex in time_zone_select. #195 [Ernie Miller] - -* Added Array#second through Array#fifth as aliases for Array#[1] through Array#[4] + Array#forty_two as alias for Array[41] [David Heinemeier Hansson] - -* Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields] - -* Added Object#present? which is equivalent to !Object#blank? [David Heinemeier Hansson] - -* Added Enumberable#many? to encapsulate collection.size > 1 [David Heinemeier Hansson/Damian Janowski] - -* Add more standard Hash methods to ActiveSupport::OrderedHash [Steve Purcell] - -* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek] - -* Added StringInquirer for doing things like StringInquirer.new("production").production? # => true and StringInquirer.new("production").development? # => false [David Heinemeier Hansson] - -* Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger) - - -*2.1.0 (May 31st, 2008)* - -* TimeZone#to_s shows offset as GMT instead of UTC, because GMT will be more familiar to end users (see time zone selects used by Windows OS, google.com and yahoo.com.) Reverts [8370] [Geoff Buesing] - -* Hash.from_xml: datetime xml types overflow to Ruby DateTime class when out of range of Time. Adding tests for utc offsets [Geoff Buesing] - -* TimeWithZone #+ and #- : ensure overflow to DateTime with Numeric arg [Geoff Buesing] - -* Time#to_json: don't convert to utc before encoding. References #175 [Geoff Buesing] - -* Remove unused JSON::RESERVED_WORDS, JSON.valid_identifier? and JSON.reserved_word? methods. Resolves #164. [Cheah Chu Yeow] - -* Adding Date.current, which returns Time.zone.today if config.time_zone is set; otherwise returns Date.today [Geoff Buesing] - -* TimeWithZone: date part getter methods (#year #mon #day etc) are defined on class; no longer relying on method_missing [Geoff Buesing] - -* Time.zone.parse return nil for strings with no date information [Geoff Buesing] - -* Time.zone.parse respects offset information in string. Resolves #105. [Scott Fleckenstein, Geoff Buesing] - -* Added Ruby 1.8 implementation of Process.daemon - -* Duration #since and #ago with no argument (e.g., 5.days.ago) return TimeWithZone when config.time_zone is set. Introducing Time.current, which returns Time.zone.now if config.time_zone is set, otherwise just returns Time.now [Geoff Buesing] - -* Time#since behaves correctly when passed a Duration. Closes #11527 [kemiller] - -* Add #getutc alias for DateTime#utc [Geoff Buesing] - -* Refactor TimeWithZone: don't send #since, #ago, #+, #-, #advance through method_missing [Geoff Buesing] - -* TimeWithZone respects config.active_support.use_standard_json_time_format [Geoff Buesing] - -* Add config.active_support.escape_html_entities_in_json to allow disabling of html entity escaping. [Rick Olson] - -* Improve documentation. [Xavier Noria] - -* Modified ActiveSupport::Callbacks::Callback#call to accept multiple arguments. - -* Time #yesterday and #tomorrow behave correctly crossing DST boundary. Closes #7399 [sblackstone] - -* TimeWithZone: Adding tests for dst and leap day edge cases when advancing time [Geoff Buesing] - -* TimeWithZone#method_missing: send to utc to advance with dst correctness, otherwise send to time. Adding tests for time calculations methods [Geoff Buesing] - -* Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [Rick Olson] - -* TZInfo: Removing unneeded TimezoneProxy class [Geoff Buesing] - -* TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing] - -* Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing] - -* Bundling abbreviated version of TZInfo gem 0.3.8: only the classes and zone definitions required to support Rails time zone features are included. If a recent version of the full TZInfo gem is installed, this will take precedence over the bundled version [Geoff Buesing] - -* TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing] - -* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing] - -* TimeWithZone time conversions don't need to be wrapped in TimeOrDateTime, because TZInfo does this internally [Geoff Buesing] - -* TimeWithZone#usec returns 0 instead of error when DateTime is wrapped [Geoff Buesing] - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [Rick Olson] - -* Ensure correct TimeWithZone#to_date [Geoff Buesing] - -* Make TimeWithZone work with tzinfo 0.2.x: use TZInfo::Timezone#zone_identifier alias for #abbreviation, silence warnings on tests. Raise LoadError when TZInfo version is < 0.2 by sniffing for TZInfo::TimeOrDateTime constant. Move all tzinfo-dependent TimeZone tests into uses_tzinfo block [Geoff Buesing] - -* Time, DateTime and TimeWithZone #in_time_zone defaults to Time.zone. Removing now unneeded #in_current_time_zone [Geoff Buesing] - -* TZInfo caches Timezone instances in its own internal hash cache, so TimeZone::MAPPING doesn't need to cache them as well [Geoff Buesing] - -* Adding TimeZone#parse [Geoff Buesing] - -* Adding TimeZone#at and DateTime#to_f [Geoff Buesing] - -* TimeWithZone responds to Ruby 1.9 weekday-named query methods [Geoff Buesing] - -* TimeWithZone caches TZInfo::TimezonePeriod used for time conversion so that it can be reused, and enforces DST rules correctly when instance is created from a local time [Geoff Buesing] - -* Fixed that BufferedLogger should create its own directory if one doesn't already exist #11285 [lotswholetime] - -* Fix Numeric time tests broken by DST change by anchoring them to fixed times instead of Time.now. Anchor TimeZone#now DST test to time specified with Time.at instead of Time.local to work around platform differences with Time.local and DST representation [Geoff Buesing] - -* Removing unneeded #change_time_zone method from Time, DateTime and TimeWithZone [Geoff Buesing] - -* TimeZone #local and #now correctly enforce DST rules [Geoff Buesing] - -* TimeWithZone instances correctly enforce DST rules. Adding TimeZone#period_for_utc [Geoff Buesing] - -* test_time_with_datetime_fallback expects DateTime.local_offset instead of DateTime.now.offset [Geoff Buesing] - -* Adding TimeWithZone #marshal_dump and #marshal_load [Geoff Buesing] - -* Add OrderedHash#to_hash [Josh Peek] - -* Adding Time#end_of_day, _quarter, _week, and _year. #9312 [Juanjo Bazan, Tarmo Tänav, BigTitus] - -* Adding TimeWithZone#between? [Geoff Buesing] - -* Time.=== returns true for TimeWithZone instances [Geoff Buesing] - -* TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date) [Geoff Buesing] - -* Add String#squish and String#squish! to remove consecutive chunks of whitespace. #11123 [Jordi Bunster, Henrik N] - -* Serialize BigDecimals as Floats when using to_yaml. #8746 [Ernesto Jimenez] - -* Adding TimeWithZone #to_yaml, #to_datetime, #eql? and method aliases for duck-typing compatibility with Time [Geoff Buesing] - -* TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone [Geoff Buesing] - -* Adding TimeWithZone #to_a, #to_f, #to_i, #httpdate, #rfc2822 [Geoff Buesing] - -* Pruning unneeded TimeWithZone#change_time_zone_to_current [Geoff Buesing] - -* Time#zone=, #in_time_zone and #change_time_zone accept a Duration [Geoff Buesing] - -* Time#in_time_zone handles Time.local instances correctly [Geoff Buesing] - -* Pruning unneeded Time#change_time_zone_to_current. Enhanced docs to #change_time_zone to explain the difference between this method and #in_time_zone [Geoff Buesing] - -* TimeZone#new method renamed #local; when used with Time.zone, constructor now reads: Time.zone.local() [Geoff Buesing] - -* Added Base64.encode64s to encode values in base64 without the newlines. This makes the values immediately usable as URL parameters or memcache keys without further processing [David Heinemeier Hansson] - -* Remove :nodoc: entries around the ActiveSupport test/unit assertions. #10946 [dancroak, jamesh] - -* Add Time.zone_default accessor for setting the default time zone. Rails::Configuration.time_zone sets this. #10982 [Geoff Buesing] - -* cache.fetch(key, :force => true) to force a cache miss. [Jeremy Kemper] - -* Support retrieving TimeZones with a Duration. TimeZone[-28800] == TimeZone[-480.minutes]. [Rick Olson] - -* TimeWithZone#- added, so that #- can handle a Time or TimeWithZone argument correctly [Geoff Buesing] - -* with_timezone test helper renamed with_env_tz, to distinguish between setting ENV['TZ'] and setting Time.zone in tests [Geoff Buesing] - -* Time#- coerces TimeWithZone argument to a Time instance so that difference in seconds can be calculated. Closes #10914 [Geoff Buesing, yyyc514] - -* Adding UTC zone to TimeZone; TimeWithZone no longer has to fake UTC zone with nil [Geoff Buesing] - -* Time.get_zone refactored to private method, given that the encapsulated logic is only useful internally [Geoff Buesing] - -* Time.zone uses thread-local variable for thread safety. Adding Time.use_zone, for overriding Time.zone locally inside a block. Removing unneeded Time.zone_reset! [Geoff Buesing] - -* TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. #1689 [Cheah Chu Yeow] - -* Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing] - -* Adding Time and DateTime #compare_with_coercion, which layers behavior on #<=> so that any combination of Time, DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared [Geoff Buesing] - -* TimeZone#now returns an ActiveSupport::TimeWithZone [Geoff Buesing] - -* Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil [Geoff Buesing] - -* Remove unneeded #to_datetime_default_s alias for DateTime#to_s, given that we inherit a #to_default_s from Date that does exactly the same thing [Geoff Buesing] - -* Refactor Time and DateTime #to_formatted_s: use ternary instead of nested if/else [Geoff Buesing] - -* Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset strings with cross-platform consistency [Geoff Buesing] - -* Adding alternate_utc_string option to TimeZone#formatted_offset. Removing unneeded TimeZone#offset. [Geoff Buesing] - -* Introduce ActiveSupport::TimeWithZone, for wrapping Time instances with a TimeZone. Introduce instance methods to Time for creating TimeWithZone instances, and class methods for managing a global time zone. [Geoff Buesing] - -* Replace non-dst-aware TimeZone class with dst-aware class from tzinfo_timezone plugin. TimeZone#adjust and #unadjust are no longer available; tzinfo gem must now be present in order to perform time zone calculations, via #local_to_utc and #utc_to_local methods. [Geoff Buesing] - -* Extract ActiveSupport::Callbacks from Active Record, test case setup and teardown, and ActionController::Dispatcher. #10727 [Josh Peek] - -* Introducing DateTime #utc, #utc? and #utc_offset, for duck-typing compatibility with Time. Closes #10002 [Geoff Buesing] - -* Time#to_json uses Numeric#to_utc_offset_s to output a cross-platform-consistent representation without having to convert to DateTime. References #9750 [Geoff Buesing] - -* Refactor number-to-HH:MM-string conversion logic from TimeZone#formatted_offset to a reusable Numeric#to_utc_offset_s method. [Geoff Buesing] - -* Continue evolution toward ActiveSupport::TestCase. #10679 [Josh Peek] - -* TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper] - -* Added ActiveSupport::Gzip.decompress/compress(source) as an easy wrapper for Zlib [Tobias Lütke] - -* Included MemCache-Client to make the improved ActiveSupport::Cache::MemCacheStore work out of the box [Bob Cottrell, Eric Hodel] - -* Added ActiveSupport::Cache::* framework as an extraction from ActionController::Caching::Fragments::* [David Heinemeier Hansson] - -* Fixed String#titleize to work for strings with 's too #10571 [trek] - -* Changed the implementation of Enumerable#group_by to use a double array approach instead of a hash such that the insert order is honored [David Heinemeier Hansson/Marcel Molina Jr.] - -* remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [Rick Olson] - -* Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee] - -* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10594, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink, Xavier Noria] - -* TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow] - -* Refactor of Hash#symbolize_keys! to use Hash#replace. Closes #10420 [ReinH] - -* Fix HashWithIndifferentAccess#to_options! so it doesn't clear the options hash. Closes #10419 [ReinH] - - -*2.0.1* (December 7th, 2007) - -* Added Array#from and Array#to that behaves just from String#from and String#to [David Heinemeier Hansson] - -* Fix that empty collections should be treated as empty arrays regardless of whitespace for Hash#from_xml #10255 [adamj] - -* Time#time_with_datetime_fallback, Time#to_datetime, Date#to_datetime and String#to_datetime honor Ruby's default calendar reform setting. #10201 [Geoff Buesing] - -* Change Time and DateTime #end_of_month to return last second of month instead of beginning of last day of month. Closes #10200 [Geoff Buesing] - -* Speedup String#blank? [Jeremy Kemper, Michael Koziarski] - -* Add documentation for Hash#diff. Closes #9306 [Tarmo Tänav] - -* Add new superclass_delegating_accessors. Similar to class inheritable attributes but with subtly different semantics. [Michael Koziarski, Tarmo Tänav] - -* Change JSON to encode %w(< > &) as 4 digit hex codes to be in compliance with the JSON spec. Closes #9975 [Josh Peek, Cheah Chu Yeow, Tim Pope] - -* Fix JSON encoding/decoding bugs dealing with /'s. Closes #9990 [Rick Olson, theamazingrando] - -* Introduce a base class for all test cases used by rails applications. ActiveSupport::TestCase [Michael Koziarski] - - The intention is to use this to reduce the amount of monkeypatching / overriding that - is done to test/unit's classes. - -* Document Enumerable and Hash #to_json. #9970 [Cheah Chu Yeow] - -* Hash#to_xml handles symbol values. #9954 [Assaf] - -* Hash#symbolize_keys behaves well with integer keys. #9890 [PotatoSalad] - -* Multibyte: String#slice supports regexp argument. #9646 [yob] - -* object.duplicable? returns true if object.dup is safe. False for nil, true, false, symbols, and numbers; true otherwise. #9333 [sur] - -* Time, Date and DateTime #advance accept :weeks option. #9866 [Geoff Buesing] - -* Fix Time#years_ago and #years_since from leap days. #9865 [Geoff Buesing] - -* Time and DateTime#advance accept :hours, :minutes, and :seconds options. #9825 [Geoff Buesing] - -* Fix Date#years_ago and #years_since from leap days. #9864 [Geoff Buesing] - -* Refactor Time and Date#months_since and #months_ago to use #advance. #9863 [Geoff Buesing] - -* Rebundle Builder 2.1.2 but prefer a newer RubyGem if available. [Jeremy Kemper] - -* Add Range#overlaps?(range), Range#include?(range), and Range#step without a block. [brandon] - -* Correct BufferedLogger#level? checks. #9806 [wildchild, Johan Sorensen] - -* String#to_xs uses Eric Wong's fast_xs extension, if available, for Builder speedup. http://bogomips.org/fast_xs/ [Jeremy Kemper] - -* Introduce BasicObject as Builder::BlankSlate for Ruby 1.9 forward compatibility. [Jeremy Kemper] - -* Unbundle Builder in favor of a gem dependency. [Jeremy Kemper] - -* Disambiguate Time, Date, and DateTime#to_json formatting. #9750 [Geoff Buesing, Cheah Chu Yeow] - -* Hash#to_json takes :only or :except options to specific or omit certain hash keys. Enumerable#to_json passes through its options to each element. #9751 [Cheah Chu Yeow] - -* BufferedLogger#auto_flushing = N flushes the log every N messages. Buffers with an array instead of string. Disabling auto_flushing still flushes when the buffer hits a maximum size, as a failsafe against memory-gobbling. [Jeremy Kemper] - -* Fixed Date#xmlschema for dates outside the range of what can be created with Time #9744 [Geoff Buesing] - -* Fixed that La Paz was included in -25200 and -14400 offsets when it should only be in -14400 #9735 [bermi] - -* Fixed JSON encoding to use quoted keys according to the JSON standard. #8762 [choonkat, Cheah Chu Yeow] - -* Alias Object#send to send! for Ruby 1.9 forward compatibility. [Jeremy Kemper] - -* Backport Object#instance_variable_defined? for Ruby < 1.8.6. [Jeremy Kemper] - -* BufferedLogger#add converts the message to a string. #9702, #9724 [eigentone, DrMark, Tom Ward] - -* Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [David Heinemeier Hansson] - -* Object#instance_exec produces fewer garbage methods. [Mauricio Fernandez] - -* Decode json strings as Dates/Times if they're using a YAML-compatible format. Closes #9614 [Rick Olson] - -* Fixed cache_page to use the request url instead of the routing options when picking a save path. #8614 [Josh Peek] - -* Object.subclasses_of includes anonymous subclasses. [Jeremy Kemper] - -* Fixed that pluralizing an empty string should return the same empty string, not "s". #7720 [Josh Peek] - -* Added call to inspect on non-string classes for the logger #8533 [Coda Hale] - -* Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper] - -* Fix JSON decoder with nested quotes and commas. #9579 [Zach Dennis] - -* Hash#to_xml doesn't double-unescape. #8806 [Ezran] - -* Added Array#rand #9170 [Norbert Crombach]. Examples: - - [].rand # => nil - ['a'].rand # => 'a' - [1,2,3].rand # => 1 or 2 or 3 - -* Deprecation: removed Reloadable. [Jeremy Kemper] - -* Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [Manfred Stienstra] - -* Add ljust, rjust and center to utf8-handler. Closes #9165 [Manfred Stienstra] - -* Fix Time#advance bug when trying to advance a year from leap day. Closes #8655 [Geoff Buesing] - -* Add support for []= on ActiveSupport::Multibyte::Chars. Closes #9142. [ewan, Manfred Stienstra] - -* Added Array#extract_options! to encapsulate the pattern of getting an options hash out of a variable number of parameters. #8759 [Norbert Crombach] - -* Let alias_attribute work with attributes with initial capital letters (legacy columns etc). Closes #8596 [mpalmer] - -* Added Hash#except which is the inverse of Hash#slice -- return the hash except the keys that are specified [David Heinemeier Hansson] - -* Added support for pluralization with a different starting letter than the singular version (cow/kine) #4929 [norri_b/Josh Susser] - -* Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. #8453 [candlerb, Jeremy Kemper] - -* Backport clean_logger changes to support ruby 1.8.2 [Mislav Marohnić] - -* Added proper handling of arrays #8537 [Josh Susser] - - Before: - Hash.from_xml '<images></images>' - # => {:images => nil} - - Hash.from_xml '<images><image>foo.jpg</image></images>' - # => {:images => {:image => "foo.jpg"}} - - Hash.from_xml '<images><image>foo.jpg</image><image>bar.jpg</image></images>' - # => {:images => {:image => ["foo.jpg", "bar.jpg"]}} - - After: - Hash.from_xml '<images type="array"></images>' - # => {:images => []} - - Hash.from_xml '<images type="array"><image>foo.jpg</image></images>' - # => {:images => ["foo.jpg"]} - - Hash.from_xml '<images type="array"><image>foo.jpg</image><image>bar.jpg</image></images>' - # => {:images => ["foo.jpg", "bar.jpg"]} - -* Improve Time and Date test coverage. #8646 [Josh Peek] - -* Add Date#since, ago, beginning_of_day, and end_of_day. Date + seconds works now. #8575 [Geoff Buesing] - -* String#to_time overflows to DateTime. Add String#to_datetime. #8572 [Geoff Buesing] - -* Date.yesterday and .tomorrow. #8571 [Geoff Buesing] - -* Readable Date and DateTime#inspect. #8570 [Geoff Buesing] - -* Move common DateTime calculations to Date. #8536 [Geoff Buesing] - -* Added Date#change (like Time#change) [David Heinemeier Hansson] - -* DateTime#to_time converts to Time unless out of range. #8512 [Geoff Buesing] - -* Date#to_datetime, #to_s(:rfc822). #8512 [Geoff Buesing] - -* Time durations use since instead of + for accuracy. #8513 [Geoff Buesing] - -* escape <'s and >'s in JSON strings. #8371 [Rick Olson] - -* Inflections: MatrixTest -> MatrixTests instead of MatricesTest. #8496 [jbwiv] - -* Multibyte strings respond_to the String methods they proxy so they can be duck-typed. #6549 [Tuxie] - -* Array#to_xml yields the builder just like Hash and ActiveRecord::Base. #8472 [seth] - -* Date, Time, and DateTime support formatting blocks in addition to strftime strings. Introduce :long_ordinal format, e.g. "February 21st, 2005". #8191 [Coda Hale] - -* Document Object#blank?. #6491 [Chris Mear] - -* Date, Time, and DateTime#to_json. #8399 [wycats] - -* Simplify API of assert_difference by passing in an expression that is evaluated before and after the passed in block. See documenation for examples of new API. [Marcel Molina Jr.] - -* Added assert_difference and assert_no_difference to test/unit assertions [Tobias Lütke] - -* Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [David Heinemeier Hansson] - -* Added parsing of file type in Hash.xml_in so you can easily do file uploads with base64 from an API [David Heinemeier Hansson] - - <person> - <name>David</name> - <avatar type="file" name="me.jpg" content_type="image/jpg">R0lGODlhkACZAPUAAM5lcfjrtMQCG=\n</avatar> - </person> - - ...becomes: - - attributes = { :person => { :name => "David", :avatar => #<StringIO> } } - attributes[:person][:avatar].content_type # => "image/jpg" - attributes[:person][:avatar].original_filename # => "me.jpg" - attributes[:person][:avatar].read # => binary data of the file - - Which is duck-type compatible with the files that you get when doing multipart uploads through HTML. - -* Improved multibyte performance by relying less on exception raising #8159 [Blaine] - -* Use XSD-compatible type names for Hash#to_xml and make the converters extendable #8047 [Tim Pope] - -* Added yielding of builder in Hash#to_xml [David Heinemeier Hansson] - -* Hash#with_indifferent_access now also converts hashes kept in arrays to indifferent access (makes it easier to treat HTML and XML parameters the same) [David Heinemeier Hansson] - -* Hash#to_xml supports YAML attributes. #7502 [jonathan] - -* Refactor ActiveSupport::JSON to be less obtuse. Add support for JSON decoding by way of Syck with ActiveSupport::JSON.decode(json_string). Prevent hash keys that are JavaScript reserved words from being unquoted during encoding. [Sam Stephenson] - -* alias_method_chain preserves the original method's visibility. #7854 [Jonathan Viney] - -* Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar] - -* Array#to_query preserves its ordering. #7756 [Greg Spurrier] - -* Out-of-range Time calculations transparently overflow to DateTime. Introduce Time#to_datetime. #7706, #7715 [Geoff Buesing] - -* DateTime calculations analogous to the Date and Time extensions. #7693 [Geoff Buesing] - -* Give DateTime correct .to_s implementations, lets it play nice with ActiveRecord quoting. #7649 [Geoff Buesing] - -* Add File.atomic_write, allows you to write large files in an atomic manner, preventing users from seeing half written files. [Michael Koziarski] - -* Allow users to provide custom formatters to Logger. [Anthony Eden] - -* Hash#to_query CGI-escapes its keys. [Jeremy Kemper] - -* Optimize Class Inheritable Attributes so that unnecessary hashes are not created. Closes #7472 [Bruce Perens] - -* :db format for Date#to_s [Jeremy Kemper] - Date.new(2007, 1, 27).to_s(:db) # => '2007-01-27' - -* Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick Olson] - -* Added Hash#to_query to turn a hash of values into a form-encoded query string [Nicholas Seckar] - -* Increase test coverage for subclasses_of. Closes #7335. [Roman2K, Nicholas Seckar] - -* Remove unused code from Duration#inspect. Closes #7180. [Rich Collins] - -* Added test coverage for Inflector.inflections.clear. Closes #7179. [Rich Collins] - -* ActiveSupport::Multibyte::Handlers::UTF8Handler should raise when a range and an integer are passed in (just like the native implementation). Closes #7176 [Rich Collins] - -* A couple extra tests for #classify. Closes #7273. [Josh Susser] - -* Better docs for Object extensions [zackchandler, Jamis Buck] - -* Fix that Dates couldn't be subtracted from Dates after [5940]. [Sam Stephenson] - -* Add Object#acts_like? and Time#acts_like_time? and Date#acts_like_date? to facilitate duck-typing. [Jamis Buck] - -* Make 1.months and friends accurate by introducing a Duration class. #6835 [eventualbuddha] - - -*1.4.2* (March 12th, 2007) - -* Ruby 1.8.6 and 1.9 define private Time#to_date and #to_datetime; make them -public for compatibility. [Jeremy Kemper] - -* Deprecation: warn on stderr if RAILS_DEFAULT_LOGGER isn't set yet. [Jeremy Kemper] - - -*1.4.1* (February 5th, 2007) - -* Optimize Class Inheritable Attributes so that unnecessary hashes are not created. Closes #7472 [Bruce Perens] - -* Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick Olson] - -* Full test coverage for Inflector. #7228 [Dan Kubb] - - -*1.4.0* (January 16th, 2007) - -* Document Inflector.ordinalize and merge docs from String inflections. #7023 [smeade] - -* Unbundle flexmock. [Jeremy Kemper] - -* Fix Dependencies.autoloaded? to ignore anonymous modules. Closes #6561. [Nicholas Seckar] - -* Update load once paths to prevent nested once constants from being detected and claimed by an external non-once load. [Nicholas Seckar] - -* Deprecation: silence warnings when reporting test errors. [Jeremy Kemper] - -* Hash#slice(*keys) returns a new hash with only the given keys. #slice! replaces the hash with only the given keys. Works with HashWithIndifferentAccess also. [Jeremy Kemper] - -* HashWithIndifferentAccess#to_hash converts to a Hash with String keys and the same default value. [Jeremy Kemper] - -* Fix remove_constant to correctly handle constant names of the form "::A::...". References #6720. [Nicholas Seckar] - -* Fixed Array#to_xml when it contains a series of hashes (each piece would get its own XML declaration) #6610 [thkarcher/cyu] - -* Added Time#to_s(:time) which will just return H:M, like 17:44 [David Heinemeier Hansson] - -* Add Module#attr_accessor_with_default to initialize value of attribute before setting it. Closes #6538. [Stuart Halloway, Marcel Molina Jr.] - -* Hash#to_xml handles keys with the same name as Kernel methods. #6613 [Jonathan del Strother] - -* Added Time#end_of_day to get 23:59:59 of that day [David Heinemeier Hansson] - -* Don't quote hash keys in Hash#to_json if they're valid JavaScript identifiers. Disable this with ActiveSupport::JSON.unquote_hash_key_identifiers = false if you need strict JSON compliance. [Sam Stephenson] - -* Lazily load the Unicode Database in the UTF-8 Handler [Rick Olson] - -* Update dependencies to delete partially loaded constants. [Nicholas Seckar] - -* Fix unicode JSON regexp for Onigurama compatibility. #6494 [whitley] - -* update XmlSimple to 1.0.10. Closes #6532. [Nick Sieger] - -* Update dependencies to allow constants to be defined alongside their siblings. A common case for this is AR model classes with STI; user.rb might define User, Administrator and Guest for example. [Nicholas Seckar] - -* next_week respects DST changes. #6483, #5617, #2353, #2509, #4551 [marclove, Rob Biedenharn, rails@roetzel.de, jsolson@damogran.org, drbrain@segment7.net] - -* Expose methods added to Enumerable in the documentation, such as group_by. Closes #6170. [sergeykojin@gmail.com, Marcel Molina Jr.] - -* Ensure Chars#tidy_bytes only tidies broken bytes. Closes #6397 [Manfred Stienstra] - -* Add 'unloadable', a method used to mark any constant as requiring an unload after each request. [Nicholas Seckar] - -* Make core_ext/string/access.rb multibyte safe. Closes #6388 [Manfred Stienstra] - -* Make String#chars slicing behaviour consistent with String. Closes #6387 [Manfred Stienstra] - -* Pull in latest multibyte patch. Closes #6346 [Manfred Stienstra] - -* Add ActiveSupport::Multibyte. Provides String#chars which lets you deal with strings as a sequence of chars, not of bytes. Closes #6242 [Julian Tarkhanov, Manfred Stienstra, Thijs van der Vossen & Jan Behrens] - -* Fix issue with #class_inheritable_accessor saving updates to the parent class when initialized with an Array or Hash [mojombo] - -* Hash#to_xml supports Bignum and BigDecimal. #6313 [edibiase] - -* Don't undefine #class in OptionMerger [Rick Olson] - -* Hash.create_from_xml has been renamed to Hash.from_xml, alias will exist until Rails 2.0 [David Heinemeier Hansson] - -* alias_method_chain works with accessor= methods also. #6153 [Caio Chassot] - -* Fix loadable_constants_for_path to handle load paths that do not end with a slash. [Nicholas Seckar] - -* Fix logic error in determining what was loaded by a given file. Closes #6039. [Nicholas Seckar] - -* Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar] - -* Add ApplicationController special case to Dependencies. [Nicholas Seckar] - -* Don't pad remaining places with in_groups_of if specified padding value is false. [Marcel Molina Jr.] - -* Fix cases where empty xml nodes weren't being translated to nil in Hash.create_from_xml [Rick Olso n] - - <written-on type="date"></written-on> # => { :type => 'date' } # WRONG - <written-on type="date"></written-on> # => nil # RIGHT - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Inflections: don't singularize -ies plurals. [foamdino@gmail.com, Mark Van Holstyn] - -* Update Initializer to use load_once_paths to avoid plugin reloading. References #5852. [Nicholas Seckar] - -* Use Array#assoc in ActiveSupport::OrderedHash. [Mauricio Fernandez] - -* Greatly increased performance of String.to_json, which speeds up RJS considerably on large pages, fixes #3473 [Shugo Maeda] - -* Detect missing_constants calls from removed modules and fail accordingly. [Nicholas Seckar] - -* Stop using defined? in Dependencies.qualified_const_defined? since defined? may invoke const_missing. [Nicholas Seckar] - -* Dependencies can autoload directories of nested classes. [Jeremy Kemper] - Example: - invoice.rb class Invoice - invoice/lineitem.rb class Invoice::Lineitem - -* Add Deprecation.silence so that Reloadable does not scold itself. [Nicholas Seckar] - -* Add debugging logging to Dependencies. Currently can be enabled with Dependencies.log_activity = true; adding to Initializer and documenting is forthcoming. [Nicholas Seckar] - -* Replace Reloadable with improvements to the Dependencies mechanism. [Nicholas Seckar] - -* DateTime#to_time gives hour/minute/second resolution. #5747 [jon.evans@pobox.com] - -* attr_internal to support namespacing and deprecation. Like attr_* except backed by internally-named instance variable. Set attr_internal_naming_format to change the format from the default '@_%s'. [Jeremy Kemper] - # def foo() @foo__rofl end - # def foo=(v) @foo__rofl = v end - self.attr_internal_naming_format = '@%s__rofl' - attr_internal :foo - -* Raise fully qualified names upon name errors. #5533 [Lars Pind, Nicholas Seckar] - -* Add extention to obtain the missing constant from NameError instances. [Nicholas Seckar] - -* Thoroughly document inflections. #5700 [petermichaux@gmail.com] - -* Added Module#alias_attribute [Jamis/David Heinemeier Hansson]. Example: - - class Content < ActiveRecord::Base - # has a title attribute - end - - class Email < ActiveRecord::Base - alias_attribute :subject, :title - end - - e = Email.find(1) - e.title # => "Superstars" - e.subject # => "Superstars" - e.subject? # => true - e.subject = "Megastars" - e.title # => "Megastars" - -* Deprecation: easier to work with warning behavior as procs; default behaviors for each environment so users needn't update env.rb; and testing pleasure with assert_deprecated, assert_not_deprecated. [Jeremy Kemper] - By default, test prints to $stderr, dev logs, production ignores. - Provide your own per-environment in e.g. config/environments/development.rb: - ActiveSupport::Deprecation.behavior = Proc.new { |message| raise message } - -* First cut of the Rails Deprecation system. [Michael Koziarski] - -* Strip boolean XML content before checking for 'true' [Rick Olson] - -* Customize default BigDecimal formatting. References #5672 [Dave Thomas] - -* Correctly convert <foo nil="true"> to nil when using Hash.create_from_xml. [Rick Olson] - -* Optional identity for Enumerable#sum defaults to zero. #5657 [gensym@mac.com] - -* HashWithIndifferentAccess shouldn't confuse false and nil. #5601 [Shugo Maeda] - -* Fixed HashWithIndifferentAccess#default #5586 [chris@seagul.co.uk] - -* More compatible Hash.create_from_xml. #5523 [nunemaker@gmail.com] - -* Added Enumerable#sum for calculating a sum from the elements [David Heinemeier Hansson, jonathan@daikini.com]. Examples: - - [1, 2, 3].sum - payments.sum { |p| p.price * p.tax_rate } - payments.sum(&:price) - - This is instead of payments.inject(0) { |sum, p| sum + p.price } - -* Correct and clarify Array#to_sentence docs. #5458 [brad@madriska.com] - -* alias_method_chain preserves method punctuation so foo, foo?, and foo! may be chained with the same feature. [Jeremy Kemper] - Example: - alias_method_chain :save!, :validation - is equivalent to - alias_method :save_without_validation!, :save! - alias_method :save!, :save_with_validation! - -* Enhance Symbol#to_proc so it works with list objects, such as multi-dimensional arrays. Closes #5295 [nov@yo.rim.or.jp]. Example: - - {1 => "one", 2 => "two", 3 => "three"}.sort_by(&:first).map(&:last) - #=> ["one", "two", "three"] - -* Added Hash.create_from_xml(string) which will create a hash from a XML string and even typecast if possible [David Heinemeier Hansson]. Example: - - Hash.create_from_xml <<-EOT - <note> - <title>This is a note</title> - <created-at type="date">2004-10-10</created-at> - </note> - EOT - - ...would return: - - { :note => { :title => "This is a note", :created_at => Date.new(2004, 10, 10) } } - -* Added Jim Weirich's excellent FlexMock class to vendor (Copyright 2003, 2004 by Jim Weirich (jim@weriichhouse.org)) -- it's not automatically required, though, so require 'flexmock' is still necessary [David Heinemeier Hansson] - -* Fixed that Module#alias_method_chain should work with both foo? foo! and foo at the same time #4954 [anna@wota.jp] - -* to_xml fixes, features, and speedup: introduce :dasherize option that converts updated_at to updated-at if true (the existing default); binary columns get encoding="base64" attribute; nil values get nil="true" attribute to distinguish empty values; add type information for float columns; allow arbitrarily deep :include; include SQL type information as the type attribute. #4989 [Blair Zajac <blair@orcaware.com>] - -* Add OrderedHash#values. [Sam Stephenson] - -* Added Array#to_s(:db) that'll produce a comma-separated list of ids [David Heinemeier Hansson]. Example: - - Purchase.find(:all, :conditions => "product_id IN (#{shops.products.to_s(:db)})" - -* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.] - -* Strip out leading schema name in classify. References #5139. [Michael Schoen] - -* Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar] - - Enumerable#first_match was like detect, but instead of returning the matching element, the yielded value returned. For example: - - user_xml = adapters(:from => User, :to => Xml).first_match do |adapter| - adapter.adapt @user - end - - But this is just as easily done with: - - user_xml = adapters(:from => User, :to => Xml).each do - break adapter.adapt(@user) - end - -* Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.] - -* Don't destroy a HashWithIndifferentAccess if symbolize_keys! or stringify_keys! is called on it. Closes #5076. [Marcel Molina Jr., guy.naor@famundo.com] - -* Document Module::delegate. #5002 [pergesu@gmail.com] - -* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] - -* Strip out punctuation on predicates or bang methods being aliased with alias_method_chain since target?_without_feature is not a valid method name. Add tests for Module#alias_method_chain. [Marcel Molina Jr.] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de] - -* Added Module#alias_method_chain [Jamis Buck] - -* Updated to Builder 2.0 [David Heinemeier Hansson] - -* Add Array#split for dividing arrays into one or more subarrays by value or block. [Sam Stephenson] - -*1.3.1* (April 6th, 2006) - -* Clean paths inside of exception messages and traces. [Nicholas Seckar] - -* Add Pathname.clean_within for cleaning all the paths inside of a string. [Nicholas Seckar] - -* provide an empty Dependencies::LoadingModule.load which prints deprecation warnings. Lets 1.0 applications function with .13-style environment.rb. - - -*1.3.0* (March 27th, 2006) - -* When possible, avoid incorrectly obtaining constants from parent modules. Fixes #4221. [Nicholas Seckar] - -* Add more tests for dependencies; refactor existing cases. [Nicholas Seckar] - -* Move Module#parent and Module#as_load_path into core_ext. Add Module#parent. [Nicholas Seckar] - -* Add CachingTools::HashCaching to simplify the creation of nested, autofilling hashes. [Nicholas Seckar] - -* Remove a hack intended to avoid unloading the same class twice, but which would not work anyways. [Nicholas Seckar] - -* Update Object.subclasses_of to locate nested classes. This affects Object.remove_subclasses_of in that nested classes will now be unloaded. [Nicholas Seckar] - -* Update Object.remove_subclasses_of to use Class.remove_class, reducing duplication. [Nicholas Seckar] - -* Added Fixnum#seconds for consistency, so you can say 5.minutes + 30.seconds instead of 5.minutes + 30 #4389 [François Beausoleil] - -* Added option to String#camelize to generate lower-cased camel case by passing in :lower, like "super_man".camelize(:lower) # => "superMan" [David Heinemeier Hansson] - -* Added Hash#diff to show the difference between two hashes [Chris McGrath] - -* Added Time#advance to do precise time time calculations for cases where a month being approximated to 30 days won't do #1860 [Rick Olson] - -* Enhance Inflector.underscore to convert '-' into '_' (as the inverse of Inflector.dasherize) [Jamis Buck] - -* Switched to_xml to use the xml schema format for datetimes. This allows the encoding of time zones and should improve operability. [Michael Koziarski] - -* Added a note to the documentation for the Date related Numeric extensions to indicate that they're -approximations and shouldn't be used for critical calculations. [Michael Koziarski] - -* Added Hash#to_xml and Array#to_xml that makes it much easier to produce XML from basic structures [David Heinemeier Hansson]. Examples: - - { :name => "David", :street_name => "Paulina", :age => 26, :moved_on => Date.new(2005, 11, 15) }.to_xml - - ...returns: - - <person> - <street-name>Paulina</street-name> - <name>David</name> - <age type="integer">26</age> - <moved-on type="date">2005-11-15</moved-on> - </person> - -* Moved Jim Weirich's wonderful Builder from Action Pack to Active Support (it's simply too useful to be stuck in AP) [David Heinemeier Hansson] - -* Fixed that Array#to_sentence will return "" on an empty array instead of ", and" #3842, #4031 [rubyonrails@beautifulpixel.com] - -* Add Enumerable#group_by for grouping collections based on the result of some - block. Useful, for example, for grouping records by date. - - ex. - - latest_transcripts.group_by(&:day).each do |day, transcripts| - p "#{day} -> #{transcripts.map(&:class) * ', '}" - end - "2006-03-01 -> Transcript" - "2006-02-28 -> Transcript" - "2006-02-27 -> Transcript, Transcript" - "2006-02-26 -> Transcript, Transcript" - - Add Array#in_groups_of, for iterating over an array in groups of a certain - size. - - ex. - - %w(1 2 3 4 5 6 7).in_groups_of(3) {|g| p g} - ["1", "2", "3"] - ["4", "5", "6"] - ["7", nil, nil] - - [Marcel Molina Jr., Sam Stephenson] - -* Added Kernel#daemonize to turn the current process into a daemon that can be killed with a TERM signal [David Heinemeier Hansson] - -* Add 'around' methods to Logger, to make it easy to log before and after messages for a given block as requested in #3809. [Michael Koziarski] Example: - - logger.around_info("Start rendering component (#{options.inspect}): ", - "\n\nEnd of component rendering") { yield } - -* Added Time#beginning_of_quarter #3607 [cohen.jeff@gmail.com] - -* Fix Object.subclasses_of to only return currently defined objects [Jonathan Viney <jonathan@bluewire.net.nz>] - -* Fix constantize to properly handle names beginning with '::'. [Nicholas Seckar] - -* Make String#last return the string instead of nil when it is shorter than the limit [Scott Barron]. - -* Added delegation support to Module that allows multiple delegations at once (unlike Forwardable in the stdlib) [David Heinemeier Hansson]. Example: - - class Account < ActiveRecord::Base - has_one :subscription - delegate :free?, :paying?, :to => :subscription - delegate :overdue?, :to => "subscription.last_payment" - end - - account.free? # => account.subscription.free? - account.overdue? # => account.subscription.last_payment.overdue? - -* Fix Reloadable to handle the case where a class that has been 'removed' has not yet been garbage collected. [Nicholas Seckar] - -* Don't allow Reloadable to be included into Modules. - -* Remove LoadingModule. [Nicholas Seckar] - -* Add documentation for Reloadable::Subclasses. [Nicholas Seckar] - -* Add Reloadable::Subclasses which handles the common case where a base class should not be reloaded, but its subclasses should be. [Nicholas Seckar] - -* Further improvements to reloading code [Nicholas Seckar, Trevor Squires] - - - All classes/modules which include Reloadable can define reloadable? for fine grained control of reloading - - Class.remove_class uses Module#parent to access the parent module - - Class.remove_class expanded to handle multiple classes in a single call - - LoadingModule.clear! has been removed as it is no longer required - - Module#remove_classes_including has been removed in favor of Reloadable.reloadable_classes - -* Added reusable reloading support through the inclusion of the Relodable module that all subclasses of ActiveRecord::Base, ActiveRecord::Observer, ActiveController::Base, and ActionMailer::Base automatically gets. This means that these classes will be reloaded by the dispatcher when Dependencies.mechanism = :load. You can make your own models reloadable easily: - - class Setting - include Reloadable - end - - Reloading a class is done by removing its constant which will cause it to be loaded again on the next reference. [David Heinemeier Hansson] - -* Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar] - -* Add Object#instance_exec, like instance_eval but passes its arguments to the block. (Active Support will not override the Ruby 1.9 implementation of this method.) [Sam Stephenson] - -* Add Proc#bind(object) for changing a proc or block's self by returning a Method bound to the given object. Based on why the lucky stiff's "cloaker" method. [Sam Stephenson] - -* Fix merge and dup for hashes with indifferent access #3404 [Ken Miller] - -* Fix the requires in option_merger_test to unbreak AS tests. [Sam Stephenson] - -* Make HashWithIndifferentAccess#update behave like Hash#update by returning the hash. #3419, #3425 [asnem@student.ethz.ch, JanPrill@blauton.de, Marcel Molina Jr.] - -* Add ActiveSupport::JSON and Object#to_json for converting Ruby objects to JSON strings. [Sam Stephenson] - -* Add Object#with_options for DRYing up multiple calls to methods having shared options. [Sam Stephenson] Example: - - ActionController::Routing::Routes.draw do |map| - # Account routes - map.with_options(:controller => 'account') do |account| - account.home '', :action => 'dashboard' - account.signup 'signup', :action => 'new' - account.logout 'logout', :action => 'logout' - end - end - -* Introduce Dependencies.warnings_on_first_load setting. If true, enables warnings on first load of a require_dependency. Otherwise, loads without warnings. Disabled (set to false) by default. [Jeremy Kemper] - -* Active Support is warnings-safe. #1792 [Eric Hodel] - -* Introduce enable_warnings counterpart to silence_warnings. Turn warnings on when loading a file for the first time if Dependencies.mechanism == :load. Common mistakes such as redefined methods will print warnings to stderr. [Jeremy Kemper] - -* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.] - -* Added the following methods [Marcel Molina Jr., Sam Stephenson]: - * Object#copy_instance_variables_from(object) to copy instance variables from one object to another - * Object#extended_by to get an instance's included/extended modules - * Object#extend_with_included_modules_from(object) to extend an instance with the modules from another instance - -*1.2.5* (December 13th, 2005) - -* Become part of Rails 1.0 - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -*1.2.3* (November 7th, 2005) - -* Change Inflector#constantize to use eval instead of const_get. [Nicholas Seckar] - -* Fix const_missing handler to ignore the trailing '.rb' on files when comparing paths. [Nicholas Seckar] - -* Define kernel.rb methods in "class Object" instead of "module Kernel" to work around a Windows peculiarity [Sam Stephenson] - -* Fix broken tests caused by incomplete loading of active support. [Nicholas Seckar] - -* Fix status pluralization bug so status_codes doesn't get pluralized as statuses_code. #2758 [keithm@infused.org] - -* Added Kernel#silence_stderr to silence stderr for the duration of the given block [Sam Stephenson] - -* Changed Kernel#` to print a message to stderr (like Unix) instead of raising Errno::ENOENT on Win32 [Sam Stephenson] - -* Changed 0.blank? to false rather than true since it violates everyone's expectation of blankness. #2518, #2705 [rails@jeffcole.net] - -* When loading classes using const_missing, raise a NameError if and only if the file we tried to load was not present. [Nicholas Seckar] - -* Added petabytes and exebytes to numeric extensions #2397 [timct@mac.com] - -* Added Time#end_of_month to accompany Time#beginning_of_month #2514 [Jens-Christian Fischer] - - -*1.2.2* (October 26th, 2005) - -* Set Logger.silencer = false to disable Logger#silence. Useful for debugging fixtures. - -* Add title case method to String to do, e.g., 'action_web_service'.titlecase # => 'Action Web Service'. [Marcel Molina Jr.] - - -*1.2.1* (October 19th, 2005) - -* Classify generated routing code as framework code to avoid appearing in application traces. [Nicholas Seckar] - -* Show all framework frames in the framework trace. [Nicholas Seckar] - - -*1.2.0* (October 16th, 2005) - -* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar] - -* Added Exception extension to provide support for clean backtraces. [Nicholas Seckar] - -* Updated whiny nil to be more concise and useful. [Nicholas Seckar] - -* Added Enumerable#first_match [Nicholas Seckar] - -* Fixed that Time#change should also reset usec when also resetting minutes #2459 [ikeda@dream.big.or.jp] - -* Fix Logger compatibility for distributions that don't keep Ruby and its standard library in sync. - -* Replace '%e' from long and short time formats as Windows does not support it. #2344. [Tom Ward <tom@popdog.net>] - -* Added to_s(:db) to Range, so you can get "BETWEEN '2005-12-10' AND '2005-12-12'" from Date.new(2005, 12, 10)..Date.new(2005, 12, 12) (and likewise with Times) - -* Moved require_library_or_gem into Kernel. #1992 [Michael Schuerig <michael@schuerig.de>] - -* Add :rfc822 as an option for Time#to_s (to get rfc822-formatted times) - -* Chain the const_missing hook to any previously existing hook so rails can play nicely with rake - -* Clean logger is compatible with both 1.8.2 and 1.8.3 Logger. #2263 [Michael Schuerig <michael@schuerig.de>] - -* Added native, faster implementations of .blank? for the core types #2286 [skae] - -* Fixed clean logger to work with Ruby 1.8.3 Logger class #2245 - -* Fixed memory leak with Active Record classes when Dependencies.mechanism = :load #1704 [Chris McGrath] - -* Fixed Inflector.underscore for use with acronyms, so HTML becomes html instead of htm_l #2173 [k@v2studio.com] - -* Fixed dependencies related infinite recursion bug when a controller file does not contain a controller class. Closes #1760. [rcolli2@tampabay.rr.com] - -* Fixed inflections for status, quiz, move #2056 [deirdre@deirdre.net] - -* Added Hash#reverse_merge, Hash#reverse_merge!, and Hash#reverse_update to ease the use of default options - -* Added Array#to_sentence that'll turn ['one', 'two', 'three'] into "one, two, and three" #2157 [Manfred Stienstra] - -* Added Kernel#silence_warnings to turn off warnings temporarily for the passed block - -* Added String#starts_with? and String#ends_with? #2118 [Thijs van der Vossen] - -* Added easy extendability to the inflector through Inflector.inflections (using the Inflector::Inflections singleton class). Examples: - - Inflector.inflections do |inflect| - inflect.plural /^(ox)$/i, '\1\2en' - inflect.singular /^(ox)en/i, '\1' - - inflect.irregular 'octopus', 'octopi' - - inflect.uncountable "equipment" - end - -* Added String#at, String#from, String#to, String#first, String#last in ActiveSupport::CoreExtensions::String::Access to ease access to individual characters and substrings in a string serving basically as human names for range access. - -* Make Time#last_month work when invoked on the 31st of a month. - -* Add Time.days_in_month, and make Time#next_month work when invoked on the 31st of a month - -* Fixed that Time#midnight would have a non-zero usec on some platforms #1836 - -* Fixed inflections of "index/indices" #1766 [damn_pepe@gmail.com] - -* Added stripping of _id to String#humanize, so "employee_id" becomes "Employee" #1574 [Justin French] - -* Factor Fixnum and Bignum extensions into Integer extensions [Nicholas Seckar] - -* Hooked #ordinalize into Fixnum and Bignum classes. [Nicholas Seckar, danp] - -* Added Fixnum#ordinalize to turn 1.ordinalize to "1st", 3.ordinalize to "3rd", and 10.ordinalize to "10th" and so on #1724 [paul@cnt.org] - - -*1.1.1* (11 July, 2005) - -* Added more efficient implementation of the development mode reset of classes #1638 [Chris McGrath] - - -*1.1.0* (6 July, 2005) - -* Fixed conflict with Glue gem #1606 [Rick Olson] - -* Added new rules to the Inflector to deal with more unusual plurals mouse/louse => mice/lice, information => information, ox => oxen, virus => viri, archive => archives #1571, #1583, #1490, #1599, #1608 [foamdino@gmail.com/others] - -* Fixed memory leak with Object#remove_subclasses_of, which inflicted a Rails application running in development mode with a ~20KB leak per request #1289 [Chris McGrath] - -* Made 1.year == 365.25.days to account for leap years. This allows you to do User.find(:all, :conditions => ['birthday > ?', 50.years.ago]) without losing a lot of days. #1488 [tuxie@dekadance.se] - -* Added an exception if calling id on nil to WhinyNil #584 [kevin-temp@writesoon.com] - -* Added Fix/Bignum#multiple_of? which returns true on 14.multiple_of?(7) and false on 16.multiple_of?(7) #1464 [Thomas Fuchs] - -* Added even? and odd? to work with Bignums in addition to Fixnums #1464 [Thomas Fuchs] - -* Fixed Time#at_beginning_of_week returned the next Monday instead of the previous one when called on a Sunday #1403 [jean.helou@gmail.com] - -* Increased the speed of indifferent hash access by using Hash#default. #1436 [Nicholas Seckar] - -* Added that " " is now also blank? (using strip if available) - -* Fixed Dependencies so all modules are able to load missing constants #1173 [Nicholas Seckar] - -* Fixed the Inflector to underscore strings containing numbers, so Area51Controller becomes area51_controller #1176 [Nicholas Seckar] - -* Fixed that HashWithIndifferentAccess stringified all keys including symbols, ints, objects, and arrays #1162 [Nicholas Seckar] - -* Fixed Time#last_year to go back in time, not forward #1278 [fabien@odilat.com] - -* Fixed the pluralization of analysis to analyses #1295 [seattle@rootimage.msu.edu] - -* Fixed that Time.local(2005,12).months_since(1) would raise "ArgumentError: argument out of range" #1311 [jhahn@niveon.com] - -* Added silencing to the default Logger class - - -*1.0.4* (19th April, 2005) - -* Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar] - -* Fixed inflection of perspectives and similar words #1045 [Thijs van der Vossen] - -* Added Fixnum#even? and Fixnum#odd? - -* Fixed problem with classes being required twice. Object#const_missing now uses require_dependency to load files. It used to use require_or_load which would cause models to be loaded twice, which was not good for validations and other class methods #971 [Nicholas Seckar] - - -*1.0.3* (27th March, 2005) - -* Fixed Inflector.pluralize to handle capitalized words #932 [Jeremy Kemper] - -* Added Object#suppress which allows you to make a saner choice around with exceptions to swallow #980. Example: - - suppress(ZeroDivisionError) { 1/0 } - - ...instead of: - - 1/0 rescue nil # BAD, EVIL, DIRTY. - - -*1.0.2* (22th March, 2005) - -* Added Kernel#returning -- a Ruby-ized realization of the K combinator, courtesy of Mikael Brockman. - - def foo - returning values = [] do - values << 'bar' - values << 'baz' - end - end - - foo # => ['bar', 'baz'] - - -*1.0.1* (7th March, 2005) - -* Fixed Hash#indifferent_access to also deal with include? and fetch and nested hashes #726 [Nicholas Seckar] - -* Added Object#blank? -- see http://redhanded.hobix.com/inspect/objectBlank.html #783 [_why the lucky stiff] - -* Added inflection rules for "sh" words, like "wish" and "fish" #755 [phillip@pjbsoftware.com] - -* Fixed an exception when using Ajax based requests from Safari because Safari appends a \000 to the post body. Symbols can't have \000 in them so indifferent access would throw an exception in the constructor. Indifferent hashes now use strings internally instead. #746 [Tobias Lütke] - -* Added String#to_time and String#to_date for wrapping ParseDate - - -*1.0.0* (24th February, 2005) - -* Added TimeZone as the first of a number of value objects that among others Active Record can use rich value objects using composed_of #688 [Jamis Buck] - -* Added Date::Conversions for getting dates in different convenient string representations and other objects - -* Added Time::Conversions for getting times in different convenient string representations and other objects - -* Added Time::Calculations to ask for things like Time.now.tomorrow, Time.now.yesterday, Time.now.months_ago(4) #580 [DP|Flurin]. Examples: - - "Later today" => now.in(3.hours), - "Tomorrow morning" => now.tomorrow.change(:hour => 9), - "Tomorrow afternoon" => now.tomorrow.change(:hour => 14), - "In a couple of days" => now.tomorrow.tomorrow.change(:hour => 9), - "Next monday" => now.next_week.change(:hour => 9), - "In a month" => now.next_month.change(:hour => 9), - "In 6 months" => now.months_since(6).change(:hour => 9), - "In a year" => now.in(1.year).change(:hour => 9) - -* Upgraded to breakpoint 92 which fixes: - - * overload IRB.parse_opts(), fixes #443 - => breakpoints in tests work even when running them via rake - * untaint handlers, might fix an issue discussed on the Rails ML - * added verbose mode to breakpoint_client - * less noise caused by breakpoint_client by default - * ignored TerminateLineInput exception in signal handler - => quiet exit on Ctrl-C - -* Fixed Inflector for words like "news" and "series" that are the same in plural and singular #603 [echion], #615 [marcenuc] - -* Added Hash#stringify_keys and Hash#stringify_keys! - -* Added IndifferentAccess as a way to wrap a hash by a symbol-based store that also can be accessed by string keys - -* Added Inflector.constantize to turn "Admin::User" into a reference for the constant Admin::User - -* Added that Inflector.camelize and Inflector.underscore can deal with modules like turning "Admin::User" into "admin/user" and back - -* Added Inflector.humanize to turn attribute names like employee_salary into "Employee salary". Used by automated error reporting in AR. - -* Added availability of class inheritable attributes to the masses #477 [Jeremy Kemper] - - class Foo - class_inheritable_reader :read_me - class_inheritable_writer :write_me - class_inheritable_accessor :read_and_write_me - class_inheritable_array :read_and_concat_me - class_inheritable_hash :read_and_update_me - end - - # Bar gets a clone of (not a reference to) Foo's attributes. - class Bar < Foo - end - - Bar.read_and_write_me == Foo.read_and_write_me - Bar.read_and_write_me = 'bar' - Bar.read_and_write_me != Foo.read_and_write_me - -* Added Inflections as an extension on String, so Inflector.pluralize(Inflector.classify(name)) becomes name.classify.pluralize #476 [Jeremy Kemper] - -* Added Byte operations to Numeric, so 5.5.megabytes + 200.kilobytes #461 [Marcel Molina Jr.] - -* Fixed that Dependencies.reload can't load the same file twice #420 [Kent Sibilev] - -* Added Fixnum#ago/until, Fixnum#since/from_now #450 [Jeremy Kemper] - -* Added that Inflector now accepts Symbols and Classes by calling .to_s on the word supplied - -* Added time unit extensions to Fixnum that'll return the period in seconds, like 2.days + 4.hours. diff --git a/vendor/rails/activesupport/README b/vendor/rails/activesupport/README deleted file mode 100644 index 9fb9a80c..00000000 --- a/vendor/rails/activesupport/README +++ /dev/null @@ -1,43 +0,0 @@ -= Active Support -- Utility classes and standard library extensions from Rails - -Active Support is a collection of various utility classes and standard library extensions that were found useful -for Rails. All these additions have hence been collected in this bundle as way to gather all that sugar that makes -Ruby sweeter. - - -== Download - -The latest version of Active Support can be found at - -* http://rubyforge.org/project/showfiles.php?group_id=182 - -Documentation can be found at - -* http://as.rubyonrails.com - - -== Installation - -The preferred method of installing Active Support is through its GEM file. You'll need to have -RubyGems[http://rubygems.rubyforge.org/wiki/wiki.pl] installed for that, though. If you have it, -then use: - - % [sudo] gem install activesupport-1.0.0.gem - - -== License - -Active Support is released under the MIT license. - - -== Support - -The Active Support homepage is http://www.rubyonrails.com. You can find the Active Support -RubyForge page at http://rubyforge.org/projects/activesupport. And as Jim from Rake says: - - Feel free to submit commits or feature requests. If you send a patch, - remember to update the corresponding unit tests. If fact, I prefer - new feature to be submitted in the form of new unit tests. - -For other information, feel free to ask on the ruby-talk mailing list -(which is mirrored to comp.lang.ruby) or contact mailto:david@loudthinking.com. diff --git a/vendor/rails/activesupport/lib/active_support.rb b/vendor/rails/activesupport/lib/active_support.rb deleted file mode 100644 index 3d91dc66..00000000 --- a/vendor/rails/activesupport/lib/active_support.rb +++ /dev/null @@ -1,60 +0,0 @@ -#-- -# Copyright (c) 2005 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -module ActiveSupport - def self.load_all! - [Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom, TimeWithZone] - end - - autoload :BacktraceCleaner, 'active_support/backtrace_cleaner' - autoload :Base64, 'active_support/base64' - autoload :BasicObject, 'active_support/basic_object' - autoload :BufferedLogger, 'active_support/buffered_logger' - autoload :Cache, 'active_support/cache' - autoload :Callbacks, 'active_support/callbacks' - autoload :Deprecation, 'active_support/deprecation' - autoload :Duration, 'active_support/duration' - autoload :Gzip, 'active_support/gzip' - autoload :Inflector, 'active_support/inflector' - autoload :Memoizable, 'active_support/memoizable' - autoload :MessageEncryptor, 'active_support/message_encryptor' - autoload :MessageVerifier, 'active_support/message_verifier' - autoload :Multibyte, 'active_support/multibyte' - autoload :OptionMerger, 'active_support/option_merger' - autoload :OrderedHash, 'active_support/ordered_hash' - autoload :OrderedOptions, 'active_support/ordered_options' - autoload :Rescuable, 'active_support/rescuable' - autoload :SafeBuffer, 'active_support/core_ext/string/output_safety' - autoload :SecureRandom, 'active_support/secure_random' - autoload :StringInquirer, 'active_support/string_inquirer' - autoload :TimeWithZone, 'active_support/time_with_zone' - autoload :TimeZone, 'active_support/values/time_zone' - autoload :XmlMini, 'active_support/xml_mini' -end - -require 'active_support/vendor' -require 'active_support/core_ext' -require 'active_support/dependencies' -require 'active_support/json' - -I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml" diff --git a/vendor/rails/activesupport/lib/active_support/all.rb b/vendor/rails/activesupport/lib/active_support/all.rb deleted file mode 100644 index 8a8805ee..00000000 --- a/vendor/rails/activesupport/lib/active_support/all.rb +++ /dev/null @@ -1,8 +0,0 @@ -# For forward compatibility with Rails 3. -# -# require 'active_support' loads a very bare minumum in Rails 3. -# require 'active_support/all' loads the whole suite like Rails 2 did. -# -# To prepare for Rails 3, switch to require 'active_support/all' now. - -require 'active_support' diff --git a/vendor/rails/activesupport/lib/active_support/backtrace_cleaner.rb b/vendor/rails/activesupport/lib/active_support/backtrace_cleaner.rb deleted file mode 100644 index 0e262c00..00000000 --- a/vendor/rails/activesupport/lib/active_support/backtrace_cleaner.rb +++ /dev/null @@ -1,72 +0,0 @@ -module ActiveSupport - # Many backtraces include too much information that's not relevant for the context. This makes it hard to find the signal - # in the backtrace and adds debugging time. With a BacktraceCleaner, you can setup filters and silencers for your particular - # context, so only the relevant lines are included. - # - # If you need to reconfigure an existing BacktraceCleaner, like the one in Rails, to show as much as possible, you can always - # call BacktraceCleaner#remove_silencers! - # - # Example: - # - # bc = BacktraceCleaner.new - # bc.add_filter { |line| line.gsub(Rails.root, '') } - # bc.add_silencer { |line| line =~ /mongrel|rubygems/ } - # bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems - # - # Inspired by the Quiet Backtrace gem by Thoughtbot. - class BacktraceCleaner - def initialize - @filters, @silencers = [], [] - end - - # Returns the backtrace after all filters and silencers has been run against it. Filters run first, then silencers. - def clean(backtrace) - silence(filter(backtrace)) - end - - # Adds a filter from the block provided. Each line in the backtrace will be mapped against this filter. - # - # Example: - # - # # Will turn "/my/rails/root/app/models/person.rb" into "/app/models/person.rb" - # backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') } - def add_filter(&block) - @filters << block - end - - # Adds a silencer from the block provided. If the silencer returns true for a given line, it'll be excluded from the - # clean backtrace. - # - # Example: - # - # # Will reject all lines that include the word "mongrel", like "/gems/mongrel/server.rb" or "/app/my_mongrel_server/rb" - # backtrace_cleaner.add_silencer { |line| line =~ /mongrel/ } - def add_silencer(&block) - @silencers << block - end - - # Will remove all silencers, but leave in the filters. This is useful if your context of debugging suddenly expands as - # you suspect a bug in the libraries you use. - def remove_silencers! - @silencers = [] - end - - - private - def filter(backtrace) - @filters.each do |f| - backtrace = backtrace.map { |line| f.call(line) } - end - - backtrace - end - - def silence(backtrace) - @silencers.each do |s| - backtrace = backtrace.reject { |line| s.call(line) } - end - - backtrace - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/base64.rb b/vendor/rails/activesupport/lib/active_support/base64.rb deleted file mode 100644 index acb8e5a9..00000000 --- a/vendor/rails/activesupport/lib/active_support/base64.rb +++ /dev/null @@ -1,33 +0,0 @@ -begin - require 'base64' -rescue LoadError -end - -module ActiveSupport - if defined? ::Base64 - Base64 = ::Base64 - else - # Base64 provides utility methods for encoding and de-coding binary data - # using a base 64 representation. A base 64 representation of binary data - # consists entirely of printable US-ASCII characters. The Base64 module - # is included in Ruby 1.8, but has been removed in Ruby 1.9. - module Base64 - # Encodes a string to its base 64 representation. Each 60 characters of - # output is separated by a newline character. - # - # ActiveSupport::Base64.encode64("Original unencoded string") - # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n" - def self.encode64(data) - [data].pack("m") - end - - # Decodes a base 64 encoded string to its original representation. - # - # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==") - # # => "Original unencoded string" - def self.decode64(data) - data.unpack("m").first - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/basic_object.rb b/vendor/rails/activesupport/lib/active_support/basic_object.rb deleted file mode 100644 index 3b5277c2..00000000 --- a/vendor/rails/activesupport/lib/active_support/basic_object.rb +++ /dev/null @@ -1,21 +0,0 @@ -module ActiveSupport - if defined? ::BasicObject - # A class with no predefined methods that behaves similarly to Builder's - # BlankSlate. Used for proxy classes. - class BasicObject < ::BasicObject - undef_method :== - undef_method :equal? - - # Let ActiveSupport::BasicObject at least raise exceptions. - def raise(*args) - ::Object.send(:raise, *args) - end - end - else - class BasicObject #:nodoc: - instance_methods.each do |m| - undef_method(m) if m.to_s !~ /(?:^__|^nil\?$|^send$|^object_id$)/ - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/buffered_logger.rb b/vendor/rails/activesupport/lib/active_support/buffered_logger.rb deleted file mode 100644 index 63c61543..00000000 --- a/vendor/rails/activesupport/lib/active_support/buffered_logger.rb +++ /dev/null @@ -1,129 +0,0 @@ -require 'thread' - -module ActiveSupport - # Inspired by the buffered logger idea by Ezra - class BufferedLogger - module Severity - DEBUG = 0 - INFO = 1 - WARN = 2 - ERROR = 3 - FATAL = 4 - UNKNOWN = 5 - end - include Severity - - MAX_BUFFER_SIZE = 1000 - - ## - # :singleton-method: - # Set to false to disable the silencer - cattr_accessor :silencer - self.silencer = true - - # Silences the logger for the duration of the block. - def silence(temporary_level = ERROR) - if silencer - begin - old_logger_level, self.level = level, temporary_level - yield self - ensure - self.level = old_logger_level - end - else - yield self - end - end - - attr_accessor :level - attr_reader :auto_flushing - - def initialize(log, level = DEBUG) - @level = level - @buffer = {} - @auto_flushing = 1 - @guard = Mutex.new - - if log.respond_to?(:write) - @log = log - elsif File.exist?(log) - @log = open(log, (File::WRONLY | File::APPEND)) - @log.sync = true - else - FileUtils.mkdir_p(File.dirname(log)) - @log = open(log, (File::WRONLY | File::APPEND | File::CREAT)) - @log.sync = true - @log.write("# Logfile created on %s" % [Time.now.to_s]) - end - end - - def add(severity, message = nil, progname = nil, &block) - return if @level > severity - message = (message || (block && block.call) || progname).to_s - # If a newline is necessary then create a new message ending with a newline. - # Ensures that the original message is not mutated. - message = "#{message}\n" unless message[-1] == ?\n - buffer << message - auto_flush - message - end - - for severity in Severity.constants - class_eval <<-EOT, __FILE__, __LINE__ + 1 - def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block) - add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block) - end # end - # - def #{severity.downcase}? # def debug? - #{severity} >= @level # DEBUG >= @level - end # end - EOT - end - - # Set the auto-flush period. Set to true to flush after every log message, - # to an integer to flush every N messages, or to false, nil, or zero to - # never auto-flush. If you turn auto-flushing off, be sure to regularly - # flush the log yourself -- it will eat up memory until you do. - def auto_flushing=(period) - @auto_flushing = - case period - when true; 1 - when false, nil, 0; MAX_BUFFER_SIZE - when Integer; period - else raise ArgumentError, "Unrecognized auto_flushing period: #{period.inspect}" - end - end - - def flush - @guard.synchronize do - unless buffer.empty? - old_buffer = buffer - @log.write(old_buffer.join) - end - - # Important to do this even if buffer was empty or else @buffer will - # accumulate empty arrays for each request where nothing was logged. - clear_buffer - end - end - - def close - flush - @log.close if @log.respond_to?(:close) - @log = nil - end - - protected - def auto_flush - flush if buffer.size >= @auto_flushing - end - - def buffer - @buffer[Thread.current] ||= [] - end - - def clear_buffer - @buffer.delete(Thread.current) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache.rb b/vendor/rails/activesupport/lib/active_support/cache.rb deleted file mode 100644 index 070ba129..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache.rb +++ /dev/null @@ -1,248 +0,0 @@ -require 'benchmark' - -module ActiveSupport - # See ActiveSupport::Cache::Store for documentation. - module Cache - autoload :FileStore, 'active_support/cache/file_store' - autoload :MemoryStore, 'active_support/cache/memory_store' - autoload :SynchronizedMemoryStore, 'active_support/cache/synchronized_memory_store' - autoload :DRbStore, 'active_support/cache/drb_store' - autoload :MemCacheStore, 'active_support/cache/mem_cache_store' - autoload :CompressedMemCacheStore, 'active_support/cache/compressed_mem_cache_store' - - module Strategy - autoload :LocalCache, 'active_support/cache/strategy/local_cache' - end - - # Creates a new CacheStore object according to the given options. - # - # If no arguments are passed to this method, then a new - # ActiveSupport::Cache::MemoryStore object will be returned. - # - # If you pass a Symbol as the first argument, then a corresponding cache - # store class under the ActiveSupport::Cache namespace will be created. - # For example: - # - # ActiveSupport::Cache.lookup_store(:memory_store) - # # => returns a new ActiveSupport::Cache::MemoryStore object - # - # ActiveSupport::Cache.lookup_store(:drb_store) - # # => returns a new ActiveSupport::Cache::DRbStore object - # - # Any additional arguments will be passed to the corresponding cache store - # class's constructor: - # - # ActiveSupport::Cache.lookup_store(:file_store, "/tmp/cache") - # # => same as: ActiveSupport::Cache::FileStore.new("/tmp/cache") - # - # If the first argument is not a Symbol, then it will simply be returned: - # - # ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new) - # # => returns MyOwnCacheStore.new - def self.lookup_store(*store_option) - store, *parameters = *([ store_option ].flatten) - - case store - when Symbol - store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize) - store_class = ActiveSupport::Cache.const_get(store_class_name) - store_class.new(*parameters) - when nil - ActiveSupport::Cache::MemoryStore.new - else - store - end - end - - def self.expand_cache_key(key, namespace = nil) - expanded_cache_key = namespace ? "#{namespace}/" : "" - - if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"] - expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/" - end - - expanded_cache_key << case - when key.respond_to?(:cache_key) - key.cache_key - when key.is_a?(Array) - key.collect { |element| expand_cache_key(element) }.to_param - when key - key.to_param - end.to_s - - expanded_cache_key - end - - # An abstract cache store class. There are multiple cache store - # implementations, each having its own additional features. See the classes - # under the ActiveSupport::Cache module, e.g. - # ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most - # popular cache store for large production websites. - # - # ActiveSupport::Cache::Store is meant for caching strings. Some cache - # store implementations, like MemoryStore, are able to cache arbitrary - # Ruby objects, but don't count on every cache store to be able to do that. - # - # cache = ActiveSupport::Cache::MemoryStore.new - # - # cache.read("city") # => nil - # cache.write("city", "Duckburgh") - # cache.read("city") # => "Duckburgh" - class Store - cattr_accessor :logger - - attr_reader :silence, :logger_off - - def silence! - @silence = true - self - end - - alias silence? silence - alias logger_off? logger_off - - def mute - previous_silence, @silence = defined?(@silence) && @silence, true - yield - ensure - @silence = previous_silence - end - - # Fetches data from the cache, using the given key. If there is data in - # the cache with the given key, then that data is returned. - # - # If there is no such data in the cache (a cache miss occurred), then - # then nil will be returned. However, if a block has been passed, then - # that block will be run in the event of a cache miss. The return value - # of the block will be written to the cache under the given cache key, - # and that return value will be returned. - # - # cache.write("today", "Monday") - # cache.fetch("today") # => "Monday" - # - # cache.fetch("city") # => nil - # cache.fetch("city") do - # "Duckburgh" - # end - # cache.fetch("city") # => "Duckburgh" - # - # You may also specify additional options via the +options+ argument. - # Setting <tt>:force => true</tt> will force a cache miss: - # - # cache.write("today", "Monday") - # cache.fetch("today", :force => true) # => nil - # - # Other options will be handled by the specific cache store implementation. - # Internally, #fetch calls #read, and calls #write on a cache miss. - # +options+ will be passed to the #read and #write calls. - # - # For example, MemCacheStore's #write method supports the +:expires_in+ - # option, which tells the memcached server to automatically expire the - # cache item after a certain period. We can use this option with #fetch - # too: - # - # cache = ActiveSupport::Cache::MemCacheStore.new - # cache.fetch("foo", :force => true, :expires_in => 5.seconds) do - # "bar" - # end - # cache.fetch("foo") # => "bar" - # sleep(6) - # cache.fetch("foo") # => nil - def fetch(key, options = {}) - @logger_off = true - if !options[:force] && value = read(key, options) - @logger_off = false - log("hit", key, options) - value - elsif block_given? - @logger_off = false - log("miss", key, options) - - value = nil - ms = Benchmark.ms { value = yield } - - @logger_off = true - write(key, value, options) - @logger_off = false - - log('write (will save %.2fms)' % ms, key, nil) - - value - end - end - - # Fetches data from the cache, using the given key. If there is data in - # the cache with the given key, then that data is returned. Otherwise, - # nil is returned. - # - # You may also specify additional options via the +options+ argument. - # The specific cache store implementation will decide what to do with - # +options+. - def read(key, options = nil) - log("read", key, options) - end - - # Writes the given value to the cache, with the given key. - # - # You may also specify additional options via the +options+ argument. - # The specific cache store implementation will decide what to do with - # +options+. - # - # For example, MemCacheStore supports the +:expires_in+ option, which - # tells the memcached server to automatically expire the cache item after - # a certain period: - # - # cache = ActiveSupport::Cache::MemCacheStore.new - # cache.write("foo", "bar", :expires_in => 5.seconds) - # cache.read("foo") # => "bar" - # sleep(6) - # cache.read("foo") # => nil - def write(key, value, options = nil) - log("write", key, options) - end - - def delete(key, options = nil) - log("delete", key, options) - end - - def delete_matched(matcher, options = nil) - log("delete matched", matcher.inspect, options) - end - - def exist?(key, options = nil) - log("exist?", key, options) - end - - def increment(key, amount = 1) - log("incrementing", key, amount) - if num = read(key) - write(key, num + amount) - else - nil - end - end - - def decrement(key, amount = 1) - log("decrementing", key, amount) - if num = read(key) - write(key, num - amount) - else - nil - end - end - - private - def expires_in(options) - expires_in = options && options[:expires_in] - - raise ":expires_in must be a number" if expires_in && !expires_in.is_a?(Numeric) - - expires_in || 0 - end - - def log(operation, key, options) - logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !silence? && !logger_off? - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb b/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb deleted file mode 100644 index d87eb173..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb +++ /dev/null @@ -1,20 +0,0 @@ -module ActiveSupport - module Cache - class CompressedMemCacheStore < MemCacheStore - def read(name, options = nil) - if value = super(name, (options || {}).merge(:raw => true)) - if raw?(options) - value - else - Marshal.load(ActiveSupport::Gzip.decompress(value)) - end - end - end - - def write(name, value, options = nil) - value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options) - super(name, value, (options || {}).merge(:raw => true)) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb b/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb deleted file mode 100644 index b16ed25a..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveSupport - module Cache - class DRbStore < MemoryStore #:nodoc: - attr_reader :address - - def initialize(address = 'druby://localhost:9192') - require 'drb' unless defined?(DRbObject) - super() - @address = address - @data = DRbObject.new(nil, address) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/file_store.rb b/vendor/rails/activesupport/lib/active_support/cache/file_store.rb deleted file mode 100644 index 7f34cb52..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/file_store.rb +++ /dev/null @@ -1,72 +0,0 @@ -module ActiveSupport - module Cache - # A cache store implementation which stores everything on the filesystem. - class FileStore < Store - attr_reader :cache_path - - def initialize(cache_path) - @cache_path = cache_path - end - - def read(name, options = nil) - super - File.open(real_file_path(name), 'rb') { |f| Marshal.load(f) } rescue nil - end - - def write(name, value, options = nil) - super - ensure_cache_path(File.dirname(real_file_path(name))) - File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) } - value - rescue => e - logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger - end - - def delete(name, options = nil) - super - File.delete(real_file_path(name)) - rescue SystemCallError => e - # If there's no cache, then there's nothing to complain about - end - - def delete_matched(matcher, options = nil) - super - search_dir(@cache_path) do |f| - if f =~ matcher - begin - File.delete(f) - rescue SystemCallError => e - # If there's no cache, then there's nothing to complain about - end - end - end - end - - def exist?(name, options = nil) - super - File.exist?(real_file_path(name)) - end - - private - def real_file_path(name) - '%s/%s.cache' % [@cache_path, name.gsub('?', '.').gsub(':', '.')] - end - - def ensure_cache_path(path) - FileUtils.makedirs(path) unless File.exist?(path) - end - - def search_dir(dir, &callback) - Dir.foreach(dir) do |d| - next if d == "." || d == ".." - name = File.join(dir, d) - if File.directory?(name) - search_dir(name, &callback) - else - callback.call name - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb b/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb deleted file mode 100644 index 17552586..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +++ /dev/null @@ -1,143 +0,0 @@ -require 'memcache' - -module ActiveSupport - module Cache - # A cache store implementation which stores data in Memcached: - # http://www.danga.com/memcached/ - # - # This is currently the most popular cache store for production websites. - # - # Special features: - # - Clustering and load balancing. One can specify multiple memcached servers, - # and MemCacheStore will load balance between all available servers. If a - # server goes down, then MemCacheStore will ignore it until it goes back - # online. - # - Time-based expiry support. See #write and the +:expires_in+ option. - # - Per-request in memory cache for all communication with the MemCache server(s). - class MemCacheStore < Store - module Response # :nodoc: - STORED = "STORED\r\n" - NOT_STORED = "NOT_STORED\r\n" - EXISTS = "EXISTS\r\n" - NOT_FOUND = "NOT_FOUND\r\n" - DELETED = "DELETED\r\n" - end - - def self.build_mem_cache(*addresses) - addresses = addresses.flatten - options = addresses.extract_options! - addresses = ["localhost"] if addresses.empty? - MemCache.new(addresses, options) - end - - # Creates a new MemCacheStore object, with the given memcached server - # addresses. Each address is either a host name, or a host-with-port string - # in the form of "host_name:port". For example: - # - # ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229") - # - # If no addresses are specified, then MemCacheStore will connect to - # localhost port 11211 (the default memcached port). - # - # Instead of addresses one can pass in a MemCache-like object. For example: - # - # require 'memcached' # gem install memcached; uses C bindings to libmemcached - # ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("localhost:11211")) - def initialize(*addresses) - if addresses.first.respond_to?(:get) - @data = addresses.first - else - @data = self.class.build_mem_cache(*addresses) - end - - extend Strategy::LocalCache - end - - # Reads multiple keys from the cache. - def read_multi(*keys) - @data.get_multi keys - end - - def read(key, options = nil) # :nodoc: - super - @data.get(key, raw?(options)) - rescue MemCache::MemCacheError => e - logger.error("MemCacheError (#{e}): #{e.message}") - nil - end - - # Writes a value to the cache. - # - # Possible options: - # - +:unless_exist+ - set to true if you don't want to update the cache - # if the key is already set. - # - +:expires_in+ - the number of seconds that this value may stay in - # the cache. See ActiveSupport::Cache::Store#write for an example. - def write(key, value, options = nil) - super - method = options && options[:unless_exist] ? :add : :set - # memcache-client will break the connection if you send it an integer - # in raw mode, so we convert it to a string to be sure it continues working. - value = value.to_s if raw?(options) - response = @data.send(method, key, value, expires_in(options), raw?(options)) - response == Response::STORED - rescue MemCache::MemCacheError => e - logger.error("MemCacheError (#{e}): #{e.message}") - false - end - - def delete(key, options = nil) # :nodoc: - super - response = @data.delete(key, expires_in(options)) - response == Response::DELETED - rescue MemCache::MemCacheError => e - logger.error("MemCacheError (#{e}): #{e.message}") - false - end - - def exist?(key, options = nil) # :nodoc: - # Doesn't call super, cause exist? in memcache is in fact a read - # But who cares? Reading is very fast anyway - # Local cache is checked first, if it doesn't know then memcache itself is read from - !read(key, options).nil? - end - - def increment(key, amount = 1) # :nodoc: - log("incrementing", key, amount) - - response = @data.incr(key, amount) - response == Response::NOT_FOUND ? nil : response - rescue MemCache::MemCacheError - nil - end - - def decrement(key, amount = 1) # :nodoc: - log("decrement", key, amount) - response = @data.decr(key, amount) - response == Response::NOT_FOUND ? nil : response - rescue MemCache::MemCacheError - nil - end - - def delete_matched(matcher, options = nil) # :nodoc: - # don't do any local caching at present, just pass - # through and let the error happen - super - raise "Not supported by Memcache" - end - - def clear - @data.flush_all - end - - def stats - @data.stats - end - - private - def raw?(options) - options && options[:raw] - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb b/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb deleted file mode 100644 index b4a7438e..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb +++ /dev/null @@ -1,58 +0,0 @@ -module ActiveSupport - module Cache - # A cache store implementation which stores everything into memory in the - # same process. If you're running multiple Ruby on Rails server processes - # (which is the case if you're using mongrel_cluster or Phusion Passenger), - # then this means that your Rails server process instances won't be able - # to share cache data with each other. If your application never performs - # manual cache item expiry (e.g. when you're using generational cache keys), - # then using MemoryStore is ok. Otherwise, consider carefully whether you - # should be using this cache store. - # - # MemoryStore is not only able to store strings, but also arbitrary Ruby - # objects. - # - # MemoryStore is not thread-safe. Use SynchronizedMemoryStore instead - # if you need thread-safety. - class MemoryStore < Store - def initialize - @data = {} - end - - def read_multi(*names) - results = {} - names.each { |n| results[n] = read(n) } - results - end - - def read(name, options = nil) - super - @data[name] - end - - def write(name, value, options = nil) - super - @data[name] = value.freeze - end - - def delete(name, options = nil) - super - @data.delete(name) - end - - def delete_matched(matcher, options = nil) - super - @data.delete_if { |k,v| k =~ matcher } - end - - def exist?(name, options = nil) - super - @data.has_key?(name) - end - - def clear - @data.clear - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb b/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb deleted file mode 100644 index 088ab049..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ /dev/null @@ -1,104 +0,0 @@ -module ActiveSupport - module Cache - module Strategy - module LocalCache - # this allows caching of the fact that there is nothing in the remote cache - NULL = 'remote_cache_store:null' - - def with_local_cache - Thread.current[thread_local_key] = MemoryStore.new - yield - ensure - Thread.current[thread_local_key] = nil - end - - def middleware - @middleware ||= begin - klass = Class.new - klass.class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def initialize(app) - @app = app - end - - def call(env) - Thread.current[:#{thread_local_key}] = MemoryStore.new - @app.call(env) - ensure - Thread.current[:#{thread_local_key}] = nil - end - EOS - klass - end - end - - def read(key, options = nil) - value = local_cache && local_cache.read(key) - if value == NULL - nil - elsif value.nil? - value = super - local_cache.mute { local_cache.write(key, value || NULL) } if local_cache - value.duplicable? ? value.dup : value - else - # forcing the value to be immutable - value.duplicable? ? value.dup : value - end - end - - def write(key, value, options = nil) - value = value.to_s if respond_to?(:raw?) && raw?(options) - local_cache.mute { local_cache.write(key, value || NULL) } if local_cache - super - end - - def delete(key, options = nil) - local_cache.mute { local_cache.write(key, NULL) } if local_cache - super - end - - def exist(key, options = nil) - value = local_cache.read(key) if local_cache - if value == NULL - false - elsif value - true - else - super - end - end - - def increment(key, amount = 1) - if value = super - local_cache.mute { local_cache.write(key, value.to_s) } if local_cache - value - else - nil - end - end - - def decrement(key, amount = 1) - if value = super - local_cache.mute { local_cache.write(key, value.to_s) } if local_cache - value - else - nil - end - end - - def clear - local_cache.clear if local_cache - super - end - - private - def thread_local_key - @thread_local_key ||= "#{self.class.name.underscore}_local_cache".gsub("/", "_").to_sym - end - - def local_cache - Thread.current[thread_local_key] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb b/vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb deleted file mode 100644 index ea03a119..00000000 --- a/vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb +++ /dev/null @@ -1,47 +0,0 @@ -module ActiveSupport - module Cache - # Like MemoryStore, but thread-safe. - class SynchronizedMemoryStore < MemoryStore - def initialize - super - @guard = Monitor.new - end - - def fetch(key, options = {}) - @guard.synchronize { super } - end - - def read(name, options = nil) - @guard.synchronize { super } - end - - def write(name, value, options = nil) - @guard.synchronize { super } - end - - def delete(name, options = nil) - @guard.synchronize { super } - end - - def delete_matched(matcher, options = nil) - @guard.synchronize { super } - end - - def exist?(name,options = nil) - @guard.synchronize { super } - end - - def increment(key, amount = 1) - @guard.synchronize { super } - end - - def decrement(key, amount = 1) - @guard.synchronize { super } - end - - def clear - @guard.synchronize { super } - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/callbacks.rb b/vendor/rails/activesupport/lib/active_support/callbacks.rb deleted file mode 100644 index 86e66e05..00000000 --- a/vendor/rails/activesupport/lib/active_support/callbacks.rb +++ /dev/null @@ -1,279 +0,0 @@ -module ActiveSupport - # Callbacks are hooks into the lifecycle of an object that allow you to trigger logic - # before or after an alteration of the object state. - # - # Mixing in this module allows you to define callbacks in your class. - # - # Example: - # class Storage - # include ActiveSupport::Callbacks - # - # define_callbacks :before_save, :after_save - # end - # - # class ConfigStorage < Storage - # before_save :saving_message - # def saving_message - # puts "saving..." - # end - # - # after_save do |object| - # puts "saved" - # end - # - # def save - # run_callbacks(:before_save) - # puts "- save" - # run_callbacks(:after_save) - # end - # end - # - # config = ConfigStorage.new - # config.save - # - # Output: - # saving... - # - save - # saved - # - # Callbacks from parent classes are inherited. - # - # Example: - # class Storage - # include ActiveSupport::Callbacks - # - # define_callbacks :before_save, :after_save - # - # before_save :prepare - # def prepare - # puts "preparing save" - # end - # end - # - # class ConfigStorage < Storage - # before_save :saving_message - # def saving_message - # puts "saving..." - # end - # - # after_save do |object| - # puts "saved" - # end - # - # def save - # run_callbacks(:before_save) - # puts "- save" - # run_callbacks(:after_save) - # end - # end - # - # config = ConfigStorage.new - # config.save - # - # Output: - # preparing save - # saving... - # - save - # saved - module Callbacks - class CallbackChain < Array - def self.build(kind, *methods, &block) - methods, options = extract_options(*methods, &block) - methods.map! { |method| Callback.new(kind, method, options) } - new(methods) - end - - def run(object, options = {}, &terminator) - enumerator = options[:enumerator] || :each - - unless block_given? - send(enumerator) { |callback| callback.call(object) } - else - send(enumerator) do |callback| - result = callback.call(object) - break result if terminator.call(result, object) - end - end - end - - # TODO: Decompose into more Array like behavior - def replace_or_append!(chain) - if index = index(chain) - self[index] = chain - else - self << chain - end - self - end - - def find(callback, &block) - select { |c| c == callback && (!block_given? || yield(c)) }.first - end - - def delete(callback) - super(callback.is_a?(Callback) ? callback : find(callback)) - end - - private - def self.extract_options(*methods, &block) - methods.flatten! - options = methods.extract_options! - methods << block if block_given? - return methods, options - end - - def extract_options(*methods, &block) - self.class.extract_options(*methods, &block) - end - end - - class Callback - attr_reader :kind, :method, :identifier, :options - - def initialize(kind, method, options = {}) - @kind = kind - @method = method - @identifier = options[:identifier] - @options = options - end - - def ==(other) - case other - when Callback - (self.identifier && self.identifier == other.identifier) || self.method == other.method - else - (self.identifier && self.identifier == other) || self.method == other - end - end - - def eql?(other) - self == other - end - - def dup - self.class.new(@kind, @method, @options.dup) - end - - def hash - if @identifier - @identifier.hash - else - @method.hash - end - end - - def call(*args, &block) - evaluate_method(method, *args, &block) if should_run_callback?(*args) - rescue LocalJumpError - raise ArgumentError, - "Cannot yield from a Proc type filter. The Proc must take two " + - "arguments and execute #call on the second argument." - end - - private - def evaluate_method(method, *args, &block) - case method - when Symbol - object = args.shift - object.send(method, *args, &block) - when String - eval(method, args.first.instance_eval { binding }) - when Proc, Method - method.call(*args, &block) - else - if method.respond_to?(kind) - method.send(kind, *args, &block) - else - raise ArgumentError, - "Callbacks must be a symbol denoting the method to call, a string to be evaluated, " + - "a block to be invoked, or an object responding to the callback method." - end - end - end - - def should_run_callback?(*args) - [options[:if]].flatten.compact.all? { |a| evaluate_method(a, *args) } && - ![options[:unless]].flatten.compact.any? { |a| evaluate_method(a, *args) } - end - end - - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def define_callbacks(*callbacks) - callbacks.each do |callback| - class_eval <<-"end_eval" - def self.#{callback}(*methods, &block) # def self.before_save(*methods, &block) - callbacks = CallbackChain.build(:#{callback}, *methods, &block) # callbacks = CallbackChain.build(:before_save, *methods, &block) - @#{callback}_callbacks ||= CallbackChain.new # @before_save_callbacks ||= CallbackChain.new - @#{callback}_callbacks.concat callbacks # @before_save_callbacks.concat callbacks - end # end - # - def self.#{callback}_callback_chain # def self.before_save_callback_chain - @#{callback}_callbacks ||= CallbackChain.new # @before_save_callbacks ||= CallbackChain.new - # - if superclass.respond_to?(:#{callback}_callback_chain) # if superclass.respond_to?(:before_save_callback_chain) - CallbackChain.new( # CallbackChain.new( - superclass.#{callback}_callback_chain + # superclass.before_save_callback_chain + - @#{callback}_callbacks # @before_save_callbacks - ) # ) - else # else - @#{callback}_callbacks # @before_save_callbacks - end # end - end # end - end_eval - end - end - end - - # Runs all the callbacks defined for the given options. - # - # If a block is given it will be called after each callback receiving as arguments: - # - # * the result from the callback - # * the object which has the callback - # - # If the result from the block evaluates to false, the callback chain is stopped. - # - # Example: - # class Storage - # include ActiveSupport::Callbacks - # - # define_callbacks :before_save, :after_save - # end - # - # class ConfigStorage < Storage - # before_save :pass - # before_save :pass - # before_save :stop - # before_save :pass - # - # def pass - # puts "pass" - # end - # - # def stop - # puts "stop" - # return false - # end - # - # def save - # result = run_callbacks(:before_save) { |result, object| result == false } - # puts "- save" if result - # end - # end - # - # config = ConfigStorage.new - # config.save - # - # Output: - # pass - # pass - # stop - def run_callbacks(kind, options = {}, &block) - self.class.send("#{kind}_callback_chain").run(self, options, &block) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext.rb b/vendor/rails/activesupport/lib/active_support/core_ext.rb deleted file mode 100644 index 6690a0ba..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext.rb +++ /dev/null @@ -1,8 +0,0 @@ -filenames = Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"].sort.map do |path| - File.basename(path, '.rb') -end - -# deprecated -filenames -= %w(blank) - -filenames.each { |filename| require "active_support/core_ext/#{filename}" } diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array.rb deleted file mode 100644 index 82c6b124..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'active_support/core_ext/array/access' -require 'active_support/core_ext/array/conversions' -require 'active_support/core_ext/array/extract_options' -require 'active_support/core_ext/array/grouping' -require 'active_support/core_ext/array/random_access' -require 'active_support/core_ext/array/wrapper' - -class Array #:nodoc: - include ActiveSupport::CoreExtensions::Array::Access - include ActiveSupport::CoreExtensions::Array::Conversions - include ActiveSupport::CoreExtensions::Array::ExtractOptions - include ActiveSupport::CoreExtensions::Array::Grouping - include ActiveSupport::CoreExtensions::Array::RandomAccess - extend ActiveSupport::CoreExtensions::Array::Wrapper -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb deleted file mode 100644 index 6de338bf..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb +++ /dev/null @@ -1,53 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - # Makes it easier to access parts of an array. - module Access - # Returns the tail of the array from +position+. - # - # %w( a b c d ).from(0) # => %w( a b c d ) - # %w( a b c d ).from(2) # => %w( c d ) - # %w( a b c d ).from(10) # => nil - # %w().from(0) # => nil - def from(position) - self[position..-1] - end - - # Returns the beginning of the array up to +position+. - # - # %w( a b c d ).to(0) # => %w( a ) - # %w( a b c d ).to(2) # => %w( a b c ) - # %w( a b c d ).to(10) # => %w( a b c d ) - # %w().to(0) # => %w() - def to(position) - self[0..position] - end - - # Equal to <tt>self[1]</tt>. - def second - self[1] - end - - # Equal to <tt>self[2]</tt>. - def third - self[2] - end - - # Equal to <tt>self[3]</tt>. - def fourth - self[3] - end - - # Equal to <tt>self[4]</tt>. - def fifth - self[4] - end - - # Equal to <tt>self[41]</tt>. Also known as accessing "the reddit". - def forty_two - self[41] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb deleted file mode 100644 index 579b18ce..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +++ /dev/null @@ -1,197 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module Conversions - # Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options: - # * <tt>:words_connector</tt> - The sign or word used to join the elements in arrays with two or more elements (default: ", ") - # * <tt>:two_words_connector</tt> - The sign or word used to join the elements in arrays with two elements (default: " and ") - # * <tt>:last_word_connector</tt> - The sign or word used to join the last element in arrays with three or more elements (default: ", and ") - def to_sentence(options = {}) - default_words_connector = I18n.translate(:'support.array.words_connector', :locale => options[:locale]) - default_two_words_connector = I18n.translate(:'support.array.two_words_connector', :locale => options[:locale]) - default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale]) - - # Try to emulate to_senteces previous to 2.3 - if options.has_key?(:connector) || options.has_key?(:skip_last_comma) - ::ActiveSupport::Deprecation.warn(":connector has been deprecated. Use :words_connector instead", caller) if options.has_key? :connector - ::ActiveSupport::Deprecation.warn(":skip_last_comma has been deprecated. Use :last_word_connector instead", caller) if options.has_key? :skip_last_comma - - skip_last_comma = options.delete :skip_last_comma - if connector = options.delete(:connector) - options[:last_word_connector] ||= skip_last_comma ? connector : ", #{connector}" - else - options[:last_word_connector] ||= skip_last_comma ? default_two_words_connector : default_last_word_connector - end - end - - options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale) - options.reverse_merge! :words_connector => default_words_connector, :two_words_connector => default_two_words_connector, :last_word_connector => default_last_word_connector - - case length - when 0 - "" - when 1 - self[0].to_s - when 2 - "#{self[0]}#{options[:two_words_connector]}#{self[1]}" - else - "#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}" - end - end - - - # Calls <tt>to_param</tt> on all its elements and joins the result with - # slashes. This is used by <tt>url_for</tt> in Action Pack. - def to_param - collect { |e| e.to_param }.join '/' - end - - # Converts an array into a string suitable for use as a URL query string, - # using the given +key+ as the param name. - # - # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding" - def to_query(key) - prefix = "#{key}[]" - collect { |value| value.to_query(prefix) }.join '&' - end - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - end - end - - # Converts a collection of elements into a formatted string by calling - # <tt>to_s</tt> on all elements and joining them: - # - # Blog.find(:all).to_formatted_s # => "First PostSecond PostThird Post" - # - # Adding in the <tt>:db</tt> argument as the format yields a prettier - # output: - # - # Blog.find(:all).to_formatted_s(:db) # => "First Post,Second Post,Third Post" - def to_formatted_s(format = :default) - case format - when :db - if respond_to?(:empty?) && self.empty? - "null" - else - collect { |element| element.id }.join(",") - end - else - to_default_s - end - end - - # Returns a string that represents this array in XML by sending +to_xml+ - # to each element. Active Record collections delegate their representation - # in XML to this method. - # - # All elements are expected to respond to +to_xml+, if any of them does - # not an exception is raised. - # - # The root node reflects the class name of the first element in plural - # if all elements belong to the same type and that's not Hash: - # - # customer.projects.to_xml - # - # <?xml version="1.0" encoding="UTF-8"?> - # <projects type="array"> - # <project> - # <amount type="decimal">20000.0</amount> - # <customer-id type="integer">1567</customer-id> - # <deal-date type="date">2008-04-09</deal-date> - # ... - # </project> - # <project> - # <amount type="decimal">57230.0</amount> - # <customer-id type="integer">1567</customer-id> - # <deal-date type="date">2008-04-15</deal-date> - # ... - # </project> - # </projects> - # - # Otherwise the root element is "records": - # - # [{:foo => 1, :bar => 2}, {:baz => 3}].to_xml - # - # <?xml version="1.0" encoding="UTF-8"?> - # <records type="array"> - # <record> - # <bar type="integer">2</bar> - # <foo type="integer">1</foo> - # </record> - # <record> - # <baz type="integer">3</baz> - # </record> - # </records> - # - # If the collection is empty the root element is "nil-classes" by default: - # - # [].to_xml - # - # <?xml version="1.0" encoding="UTF-8"?> - # <nil-classes type="array"/> - # - # To ensure a meaningful root element use the <tt>:root</tt> option: - # - # customer_with_no_projects.projects.to_xml(:root => "projects") - # - # <?xml version="1.0" encoding="UTF-8"?> - # <projects type="array"/> - # - # By default root children have as node name the one of the root - # singularized. You can change it with the <tt>:children</tt> option. - # - # The +options+ hash is passed downwards: - # - # Message.all.to_xml(:skip_types => true) - # - # <?xml version="1.0" encoding="UTF-8"?> - # <messages> - # <message> - # <created-at>2008-03-07T09:58:18+01:00</created-at> - # <id>1</id> - # <name>1</name> - # <updated-at>2008-03-07T09:58:18+01:00</updated-at> - # <user-id>1</user-id> - # </message> - # </messages> - # - def to_xml(options = {}) - raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml } - require 'builder' unless defined?(Builder) - - options = options.dup - options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize.tr('/', '-') : "records" - options[:children] ||= options[:root].singularize - options[:indent] ||= 2 - options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - - root = options.delete(:root).to_s - children = options.delete(:children) - - if !options.has_key?(:dasherize) || options[:dasherize] - root = root.dasherize - end - - options[:builder].instruct! unless options.delete(:skip_instruct) - - opts = options.merge({ :root => children }) - - xml = options[:builder] - if empty? - xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) - else - xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) { - yield xml if block_given? - each { |e| e.to_xml(opts.merge({ :skip_instruct => true })) } - } - end - end - - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb deleted file mode 100644 index eb917576..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb +++ /dev/null @@ -1,20 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module ExtractOptions - # Extracts options from a set of arguments. Removes and returns the last - # element in the array if it's a hash, otherwise returns a blank hash. - # - # def options(*args) - # args.extract_options! - # end - # - # options(1, 2) # => {} - # options(1, 2, :a => :b) # => {:a=>:b} - def extract_options! - last.is_a?(::Hash) ? pop : {} - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb deleted file mode 100644 index 239e0354..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'enumerator' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module Grouping - # Splits or iterates over the array in groups of size +number+, - # padding any remaining slots with +fill_with+ unless it is +false+. - # - # %w(1 2 3 4 5 6 7).in_groups_of(3) {|group| p group} - # ["1", "2", "3"] - # ["4", "5", "6"] - # ["7", nil, nil] - # - # %w(1 2 3).in_groups_of(2, '&nbsp;') {|group| p group} - # ["1", "2"] - # ["3", "&nbsp;"] - # - # %w(1 2 3).in_groups_of(2, false) {|group| p group} - # ["1", "2"] - # ["3"] - def in_groups_of(number, fill_with = nil) - if fill_with == false - collection = self - else - # size % number gives how many extra we have; - # subtracting from number gives how many to add; - # modulo number ensures we don't add group of just fill. - padding = (number - size % number) % number - collection = dup.concat([fill_with] * padding) - end - - if block_given? - collection.each_slice(number) { |slice| yield(slice) } - else - [].tap do |groups| - collection.each_slice(number) { |group| groups << group } - end - end - end - - # Splits or iterates over the array in +number+ of groups, padding any - # remaining slots with +fill_with+ unless it is +false+. - # - # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group} - # ["1", "2", "3", "4"] - # ["5", "6", "7", nil] - # ["8", "9", "10", nil] - # - # %w(1 2 3 4 5 6 7).in_groups(3, '&nbsp;') {|group| p group} - # ["1", "2", "3"] - # ["4", "5", "&nbsp;"] - # ["6", "7", "&nbsp;"] - # - # %w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group} - # ["1", "2", "3"] - # ["4", "5"] - # ["6", "7"] - def in_groups(number, fill_with = nil) - # size / number gives minor group size; - # size % number gives how many objects need extra accomodation; - # each group hold either division or division + 1 items. - division = size / number - modulo = size % number - - # create a new array avoiding dup - groups = [] - start = 0 - - number.times do |index| - length = division + (modulo > 0 && modulo > index ? 1 : 0) - padding = fill_with != false && - modulo > 0 && length == division ? 1 : 0 - groups << slice(start, length).concat([fill_with] * padding) - start += length - end - - if block_given? - groups.each{|g| yield(g) } - else - groups - end - end - - # Divides the array into one or more subarrays based on a delimiting +value+ - # or the result of an optional block. - # - # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]] - # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]] - def split(value = nil) - using_block = block_given? - - inject([[]]) do |results, element| - if (using_block && yield(element)) || (value == element) - results << [] - else - results.last << element - end - - results - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb deleted file mode 100644 index a0ca89f7..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb +++ /dev/null @@ -1,42 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module RandomAccess - # This method is deprecated because it masks Kernel#rand within the Array class itself, - # which may be used by a 3rd party library extending Array in turn. See - # - # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555 - # - def rand # :nodoc: - ActiveSupport::Deprecation.warn 'Array#rand is deprecated and will be removed in Rails 3. Use Array#sample instead', caller - sample - end - - # Returns a random element from the array. - def random_element # :nodoc: - ActiveSupport::Deprecation.warn 'Array#random_element is deprecated and will be removed in Rails 3. Use Array#sample instead', caller - sample - end - - # Backport of Array#sample based on Marc-Andre Lafortune's http://github.com/marcandre/backports/ - def sample(n=nil) - return self[Kernel.rand(size)] if n.nil? - n = n.to_int - rescue Exception => e - raise TypeError, "Coercion error: #{n.inspect}.to_int => Integer failed:\n(#{e.message})" - else - raise TypeError, "Coercion error: #{n}.to_int did NOT return an Integer (was #{n.class})" unless n.kind_of? ::Integer - raise ArgumentError, "negative array size" if n < 0 - n = size if n > size - result = ::Array.new(self) - n.times do |i| - r = i + Kernel.rand(size - i) - result[i], result[r] = result[r], result[i] - end - result[n..size] = [] - result - end unless method_defined? :sample - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb deleted file mode 100644 index 80b8f055..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module Wrapper - # Wraps the object in an Array unless it's an Array. Converts the - # object to an Array using #to_ary if it implements that. - def wrap(object) - case object - when nil - [] - when self - object - else - if object.respond_to?(:to_ary) - object.to_ary - else - [object] - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb b/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb deleted file mode 100644 index 235e2edf..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'active_support/base64' -require 'active_support/core_ext/base64/encoding' - -ActiveSupport::Base64.extend ActiveSupport::CoreExtensions::Base64::Encoding diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb b/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb deleted file mode 100644 index a9656c13..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb +++ /dev/null @@ -1,16 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Base64 #:nodoc: - module Encoding - # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters - # or memcache keys without further processing. - # - # ActiveSupport::Base64.encode64s("Original unencoded string") - # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==" - def encode64s(value) - encode64(value).gsub(/\n/, '') - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb b/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb deleted file mode 100644 index ae57b152..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'benchmark' - -class << Benchmark - # Earlier Ruby had a slower implementation. - if RUBY_VERSION < '1.8.7' - remove_method :realtime - - def realtime - r0 = Time.now - yield - r1 = Time.now - r1.to_f - r0.to_f - end - end - - def ms - 1000 * realtime { yield } - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb b/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb deleted file mode 100644 index d429078c..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'bigdecimal' -require 'active_support/core_ext/bigdecimal/conversions' - -class BigDecimal#:nodoc: - include ActiveSupport::CoreExtensions::BigDecimal::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb deleted file mode 100644 index bc9d578f..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'yaml' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module BigDecimal #:nodoc: - module Conversions - DEFAULT_STRING_FORMAT = 'F'.freeze - YAML_TAG = 'tag:yaml.org,2002:float'.freeze - YAML_MAPPING = { 'Infinity' => '.Inf', '-Infinity' => '-.Inf', 'NaN' => '.NaN' } - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :_original_to_s, :to_s - alias_method :to_s, :to_formatted_s - - yaml_as YAML_TAG - end - end - - def to_formatted_s(format = DEFAULT_STRING_FORMAT) - _original_to_s(format) - end - - # This emits the number without any scientific notation. - # This is better than self.to_f.to_s since it doesn't lose precision. - # - # Note that reconstituting YAML floats to native floats may lose precision. - def to_yaml(opts = {}) - YAML.quick_emit(nil, opts) do |out| - string = to_s - out.scalar(YAML_TAG, YAML_MAPPING[string] || string, :plain) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb b/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb deleted file mode 100644 index 54e83ba4..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'active_support/core_ext/object/blank' -ActiveSupport::Deprecation.warn 'require "active_support/core_ext/blank" is deprecated and will be removed in Rails 3. Use require "active_support/core_ext/object/blank" instead.' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb b/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb deleted file mode 100644 index db90e5c7..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/cgi/escape_skipping_slashes' - -class CGI #:nodoc: - extend ActiveSupport::CoreExtensions::CGI::EscapeSkippingSlashes -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb deleted file mode 100644 index 1edb3771..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module CGI #:nodoc: - module EscapeSkippingSlashes #:nodoc: - if RUBY_VERSION >= '1.9' - def escape_skipping_slashes(str) - str = str.join('/') if str.respond_to? :join - str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do - "%#{$1.unpack('H2' * $1.bytesize).join('%').upcase}" - end.tr(' ', '+') - end - else - def escape_skipping_slashes(str) - str = str.join('/') if str.respond_to? :join - str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do - "%#{$1.unpack('H2').first.upcase}" - end.tr(' ', '+') - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class.rb deleted file mode 100644 index 2e46507f..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/class/attribute_accessors' -require 'active_support/core_ext/class/inheritable_attributes' -require 'active_support/core_ext/class/removal' -require 'active_support/core_ext/class/delegating_attributes' -require 'active_support/core_ext/class/attribute' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute.rb deleted file mode 100644 index 576366e4..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'active_support/core_ext/kernel/singleton_class' -require 'active_support/core_ext/module/remove_method' - -class Class - # Declare a class-level attribute whose value is inheritable and - # overwritable by subclasses: - # - # class Base - # class_attribute :setting - # end - # - # class Subclass < Base - # end - # - # Base.setting = true - # Subclass.setting # => true - # Subclass.setting = false - # Subclass.setting # => false - # Base.setting # => true - # - # This matches normal Ruby method inheritance: think of writing an attribute - # on a subclass as overriding the reader method. - # - # For convenience, a query method is defined as well: - # - # Subclass.setting? # => false - # - # Instances may overwrite the class value in the same way: - # - # Base.setting = true - # object = Base.new - # object.setting # => true - # object.setting = false - # object.setting # => false - # Base.setting # => true - # - # To opt out of the instance writer method, pass :instance_writer => false. - # - # object.setting = false # => NoMethodError - def class_attribute(*attrs) - instance_writer = !attrs.last.is_a?(Hash) || attrs.pop[:instance_writer] - - attrs.each do |name| - class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def self.#{name}() nil end - def self.#{name}?() !!#{name} end - - def self.#{name}=(val) - singleton_class.class_eval do - remove_possible_method(:#{name}) - define_method(:#{name}) { val } - end - end - - def #{name} - defined?(@#{name}) ? @#{name} : singleton_class.#{name} - end - - def #{name}? - !!#{name} - end - RUBY - - attr_writer name if instance_writer - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb deleted file mode 100644 index 7ccf8b00..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +++ /dev/null @@ -1,61 +0,0 @@ -# Extends the class object with class and instance accessors for class attributes, -# just like the native attr* accessors for instance attributes. -# -# class Person -# cattr_accessor :hair_colors -# end -# -# Person.hair_colors = [:brown, :black, :blonde, :red] -class Class - def cattr_reader(*syms) - options = syms.extract_options! - syms.each do |sym| - next if sym.is_a?(Hash) - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - unless defined? @@#{sym} - @@#{sym} = nil - end - - def self.#{sym} - @@#{sym} - end - EOS - - unless options[:instance_reader] == false - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{sym} - @@#{sym} - end - EOS - end - end - end - - def cattr_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - unless defined? @@#{sym} - @@#{sym} = nil - end - - def self.#{sym}=(obj) - @@#{sym} = obj - end - EOS - - unless options[:instance_writer] == false - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{sym}=(obj) - @@#{sym} = obj - end - EOS - end - end - end - - def cattr_accessor(*syms) - cattr_reader(*syms) - cattr_writer(*syms) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb deleted file mode 100644 index 000ccf4d..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ /dev/null @@ -1,47 +0,0 @@ -# These class attributes behave something like the class -# inheritable accessors. But instead of copying the hash over at -# the time the subclass is first defined, the accessors simply -# delegate to their superclass unless they have been given a -# specific value. This stops the strange situation where values -# set after class definition don't get applied to subclasses. -class Class - def superclass_delegating_reader(*names) - class_name_to_stop_searching_on = self.superclass.name.blank? ? "Object" : self.superclass.name - names.each do |name| - class_eval <<-EOS - def self.#{name} # def self.only_reader - if defined?(@#{name}) # if defined?(@only_reader) - @#{name} # @only_reader - elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object && - superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader) - superclass.#{name} # superclass.only_reader - end # end - end # end - def #{name} # def only_reader - self.class.#{name} # self.class.only_reader - end # end - def self.#{name}? # def self.only_reader? - !!#{name} # !!only_reader - end # end - def #{name}? # def only_reader? - !!#{name} # !!only_reader - end # end - EOS - end - end - - def superclass_delegating_writer(*names) - names.each do |name| - class_eval <<-EOS - def self.#{name}=(value) # def self.only_writer=(value) - @#{name} = value # @only_writer = value - end # end - EOS - end - end - - def superclass_delegating_accessor(*names) - superclass_delegating_reader(*names) - superclass_delegating_writer(*names) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb deleted file mode 100644 index 1794afe7..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +++ /dev/null @@ -1,140 +0,0 @@ -# Retain for backward compatibility. Methods are now included in Class. -module ClassInheritableAttributes # :nodoc: -end - -# Allows attributes to be shared within an inheritance hierarchy, but where each descendant gets a copy of -# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements -# to, for example, an array without those additions being shared with either their parent, siblings, or -# children, which is unlike the regular class-level attributes that are shared across the entire hierarchy. -class Class # :nodoc: - def class_inheritable_reader(*syms) - syms.each do |sym| - next if sym.is_a?(Hash) - class_eval <<-EOS - def self.#{sym} # def self.before_add_for_comments - read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:before_add_for_comments) - end # end - # - def #{sym} # def before_add_for_comments - self.class.#{sym} # self.class.before_add_for_comments - end # end - EOS - end - end - - def class_inheritable_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval <<-EOS - def self.#{sym}=(obj) # def self.color=(obj) - write_inheritable_attribute(:#{sym}, obj) # write_inheritable_attribute(:color, obj) - end # end - # - #{" # - def #{sym}=(obj) # def color=(obj) - self.class.#{sym} = obj # self.class.color = obj - end # end - " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def class_inheritable_array_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval <<-EOS - def self.#{sym}=(obj) # def self.levels=(obj) - write_inheritable_array(:#{sym}, obj) # write_inheritable_array(:levels, obj) - end # end - # - #{" # - def #{sym}=(obj) # def levels=(obj) - self.class.#{sym} = obj # self.class.levels = obj - end # end - " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def class_inheritable_hash_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval <<-EOS - def self.#{sym}=(obj) # def self.nicknames=(obj) - write_inheritable_hash(:#{sym}, obj) # write_inheritable_hash(:nicknames, obj) - end # end - # - #{" # - def #{sym}=(obj) # def nicknames=(obj) - self.class.#{sym} = obj # self.class.nicknames = obj - end # end - " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def class_inheritable_accessor(*syms) - class_inheritable_reader(*syms) - class_inheritable_writer(*syms) - end - - def class_inheritable_array(*syms) - class_inheritable_reader(*syms) - class_inheritable_array_writer(*syms) - end - - def class_inheritable_hash(*syms) - class_inheritable_reader(*syms) - class_inheritable_hash_writer(*syms) - end - - def inheritable_attributes - @inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES - end - - def write_inheritable_attribute(key, value) - if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES) - @inheritable_attributes = {} - end - inheritable_attributes[key] = value - end - - def write_inheritable_array(key, elements) - write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil? - write_inheritable_attribute(key, read_inheritable_attribute(key) + elements) - end - - def write_inheritable_hash(key, hash) - write_inheritable_attribute(key, {}) if read_inheritable_attribute(key).nil? - write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash)) - end - - def read_inheritable_attribute(key) - inheritable_attributes[key] - end - - def reset_inheritable_attributes - @inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES - end - - private - # Prevent this constant from being created multiple times - EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze unless const_defined?(:EMPTY_INHERITABLE_ATTRIBUTES) - - def inherited_with_inheritable_attributes(child) - inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes) - - if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES) - new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES - else - new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)| - memo.update(key => value.duplicable? ? value.dup : value) - end - end - - child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes) - end - - alias inherited_without_inheritable_attributes inherited - alias inherited inherited_with_inheritable_attributes -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb deleted file mode 100644 index 10660edb..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb +++ /dev/null @@ -1,50 +0,0 @@ -class Class #:nodoc: - - # Unassociates the class with its subclasses and removes the subclasses - # themselves. - # - # Integer.remove_subclasses # => [Bignum, Fixnum] - # Fixnum # => NameError: uninitialized constant Fixnum - def remove_subclasses - Object.remove_subclasses_of(self) - end - - # Returns an array with the names of the subclasses of +self+ as strings. - # - # Integer.subclasses # => ["Bignum", "Fixnum"] - def subclasses - Object.subclasses_of(self).map { |o| o.to_s } - end - - # Removes the classes in +klasses+ from their parent module. - # - # Ordinary classes belong to some module via a constant. This method computes - # that constant name from the class name and removes it from the module it - # belongs to. - # - # Object.remove_class(Integer) # => [Integer] - # Integer # => NameError: uninitialized constant Integer - # - # Take into account that in general the class object could be still stored - # somewhere else. - # - # i = Integer # => Integer - # Object.remove_class(Integer) # => [Integer] - # Integer # => NameError: uninitialized constant Integer - # i.subclasses # => ["Bignum", "Fixnum"] - # Fixnum.superclass # => Integer - def remove_class(*klasses) - klasses.flatten.each do |klass| - # Skip this class if there is nothing bound to this name - next unless defined?(klass.name) - - basename = klass.to_s.split("::").last - parent = klass.parent - - # Skip this class if it does not match the current one bound to this name - next unless parent.const_defined?(basename) && klass = parent.const_get(basename) - - parent.instance_eval { remove_const basename } unless parent == klass - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date.rb deleted file mode 100644 index 3f56c560..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'date' -require 'active_support/core_ext/date/behavior' -require 'active_support/core_ext/date/calculations' -require 'active_support/core_ext/date/conversions' - -class Date#:nodoc: - include ActiveSupport::CoreExtensions::Date::Behavior - include ActiveSupport::CoreExtensions::Date::Calculations - include ActiveSupport::CoreExtensions::Date::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb deleted file mode 100644 index bd378eb3..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'date' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Date #:nodoc: - module Behavior - # Enable more predictable duck-typing on Date-like classes. See - # Object#acts_like?. - def acts_like_date? - true - end - - # Date memoizes some instance methods using metaprogramming to wrap - # the methods with one that caches the result in an instance variable. - # - # If a Date is frozen but the memoized method hasn't been called, the - # first call will result in a frozen object error since the memo - # instance variable is uninitialized. - # - # Work around by eagerly memoizing before freezing. - # - # Ruby 1.9 uses a preinitialized instance variable so it's unaffected. - # This hack is as close as we can get to feature detection: - begin - ::Date.today.freeze.jd - rescue => frozen_object_error - if frozen_object_error.message =~ /frozen/ - def freeze #:nodoc: - self.class.private_instance_methods(false).each do |m| - if m.to_s =~ /\A__\d+__\Z/ - instance_variable_set(:"@#{m}", [send(m)]) - end - end - - super - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb deleted file mode 100644 index 4c141b67..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +++ /dev/null @@ -1,241 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Date #:nodoc: - # Enables the use of time calculations within Date itself - module Calculations - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.instance_eval do - alias_method :plus_without_duration, :+ - alias_method :+, :plus_with_duration - - alias_method :minus_without_duration, :- - alias_method :-, :minus_with_duration - end - end - - module ClassMethods - # Returns a new Date representing the date 1 day ago (i.e. yesterday's date). - def yesterday - ::Date.today.yesterday - end - - # Returns a new Date representing the date 1 day after today (i.e. tomorrow's date). - def tomorrow - ::Date.today.tomorrow - end - - # Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today. - def current - ::Time.zone_default ? ::Time.zone.today : ::Date.today - end - end - - # Tells whether the Date object's date lies in the past - def past? - self < ::Date.current - end - - # Tells whether the Date object's date is today - def today? - self.to_date == ::Date.current # we need the to_date because of DateTime - end - - # Tells whether the Date object's date lies in the future - def future? - self > ::Date.current - end - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - # and then subtracts the specified number of seconds - def ago(seconds) - to_time.since(-seconds) - end - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - # and then adds the specified number of seconds - def since(seconds) - to_time.since(seconds) - end - alias :in :since - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - def beginning_of_day - to_time - end - alias :midnight :beginning_of_day - alias :at_midnight :beginning_of_day - alias :at_beginning_of_day :beginning_of_day - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59) - def end_of_day - to_time.end_of_day - end - - def plus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - other.since(self) - else - plus_without_duration(other) - end - end - - def minus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - plus_with_duration(-other) - else - minus_without_duration(other) - end - end - - # Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with - # any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>. - def advance(options) - options = options.dup - d = self - d = d >> options.delete(:years) * 12 if options[:years] - d = d >> options.delete(:months) if options[:months] - d = d + options.delete(:weeks) * 7 if options[:weeks] - d = d + options.delete(:days) if options[:days] - d - end - - # Returns a new Date where one or more of the elements have been changed according to the +options+ parameter. - # - # Examples: - # - # Date.new(2007, 5, 12).change(:day => 1) # => Date.new(2007, 5, 1) - # Date.new(2007, 5, 12).change(:year => 2005, :month => 1) # => Date.new(2005, 1, 12) - def change(options) - ::Date.new( - options[:year] || self.year, - options[:month] || self.month, - options[:day] || self.day - ) - end - - # Returns a new Date/DateTime representing the time a number of specified months ago - def months_ago(months) - advance(:months => -months) - end - - # Returns a new Date/DateTime representing the time a number of specified months in the future - def months_since(months) - advance(:months => months) - end - - # Returns a new Date/DateTime representing the time a number of specified years ago - def years_ago(years) - advance(:years => -years) - end - - # Returns a new Date/DateTime representing the time a number of specified years in the future - def years_since(years) - advance(:years => years) - end - - def last_year # :nodoc: - ActiveSupport::Deprecation.warn("Date#last_year is deprecated and has been removed in Rails 3, please use Date#prev_year instead", caller) - prev_year - end - - # Short-hand for years_ago(1) - def prev_year - years_ago(1) - end unless method_defined?(:prev_year) - - # Short-hand for years_since(1) - def next_year - years_since(1) - end - - def last_month # :nodoc: - ActiveSupport::Deprecation.warn("Date#last_month is deprecated and has been removed in Rails 3, please use Date#prev_month instead", caller) - prev_month - end - - # Short-hand for months_ago(1) - def prev_month - months_ago(1) - end unless method_defined?(:prev_month) - - # Short-hand for months_since(1) - def next_month - months_since(1) - end - - # Returns a new Date/DateTime representing the "start" of this week (i.e, Monday; DateTime objects will have time set to 0:00) - def beginning_of_week - days_to_monday = self.wday!=0 ? self.wday-1 : 6 - result = self - days_to_monday - self.acts_like?(:time) ? result.midnight : result - end - alias :monday :beginning_of_week - alias :at_beginning_of_week :beginning_of_week - - # Returns a new Date/DateTime representing the end of this week (Sunday, DateTime objects will have time set to 23:59:59) - def end_of_week - days_to_sunday = self.wday!=0 ? 7-self.wday : 0 - result = self + days_to_sunday.days - self.acts_like?(:time) ? result.end_of_day : result - end - alias :at_end_of_week :end_of_week - - # Returns a new Date/DateTime representing the start of the given day in next week (default is Monday). - def next_week(day = :monday) - days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6} - result = (self + 7).beginning_of_week + days_into_week[day] - self.acts_like?(:time) ? result.change(:hour => 0) : result - end - - # Returns a new ; DateTime objects will have time set to 0:00DateTime representing the start of the month (1st of the month; DateTime objects will have time set to 0:00) - def beginning_of_month - self.acts_like?(:time) ? change(:day => 1,:hour => 0, :min => 0, :sec => 0) : change(:day => 1) - end - alias :at_beginning_of_month :beginning_of_month - - # Returns a new Date/DateTime representing the end of the month (last day of the month; DateTime objects will have time set to 0:00) - def end_of_month - last_day = ::Time.days_in_month( self.month, self.year ) - self.acts_like?(:time) ? change(:day => last_day, :hour => 23, :min => 59, :sec => 59) : change(:day => last_day) - end - alias :at_end_of_month :end_of_month - - # Returns a new Date/DateTime representing the start of the quarter (1st of january, april, july, october; DateTime objects will have time set to 0:00) - def beginning_of_quarter - beginning_of_month.change(:month => [10, 7, 4, 1].detect { |m| m <= self.month }) - end - alias :at_beginning_of_quarter :beginning_of_quarter - - # Returns a new Date/DateTime representing the end of the quarter (last day of march, june, september, december; DateTime objects will have time set to 23:59:59) - def end_of_quarter - beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month - end - alias :at_end_of_quarter :end_of_quarter - - # Returns a new Date/DateTime representing the start of the year (1st of january; DateTime objects will have time set to 0:00) - def beginning_of_year - self.acts_like?(:time) ? change(:month => 1, :day => 1, :hour => 0, :min => 0, :sec => 0) : change(:month => 1, :day => 1) - end - alias :at_beginning_of_year :beginning_of_year - - # Returns a new Time representing the end of the year (31st of december; DateTime objects will have time set to 23:59:59) - def end_of_year - self.acts_like?(:time) ? change(:month => 12,:day => 31,:hour => 23, :min => 59, :sec => 59) : change(:month => 12, :day => 31) - end - alias :at_end_of_year :end_of_year - - # Convenience method which returns a new Date/DateTime representing the time 1 day ago - def yesterday - self - 1 - end - - # Convenience method which returns a new Date/DateTime representing the time 1 day since the instance time - def tomorrow - self + 1 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb deleted file mode 100644 index 8d9f0233..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb +++ /dev/null @@ -1,107 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Date #:nodoc: - # Converting dates to formatted strings, times, and datetimes. - module Conversions - DATE_FORMATS = { - :short => "%e %b", - :long => "%B %e, %Y", - :db => "%Y-%m-%d", - :number => "%Y%m%d", - :long_ordinal => lambda { |date| date.strftime("%B #{date.day.ordinalize}, %Y") }, # => "April 25th, 2007" - :rfc822 => "%e %b %Y" - } - - def self.included(base) #:nodoc: - base.instance_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - alias_method :default_inspect, :inspect - alias_method :inspect, :readable_inspect - - # Ruby 1.9 has Date#to_time which converts to localtime only. - remove_method :to_time if base.instance_methods.include?(:to_time) - - # Ruby 1.9 has Date#xmlschema which converts to a string without the time component. - remove_method :xmlschema if base.instance_methods.include?(:xmlschema) - end - end - - # Convert to a formatted string. See DATE_FORMATS for predefined formats. - # - # This method is aliased to <tt>to_s</tt>. - # - # ==== Examples - # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 - # - # date.to_formatted_s(:db) # => "2007-11-10" - # date.to_s(:db) # => "2007-11-10" - # - # date.to_formatted_s(:short) # => "10 Nov" - # date.to_formatted_s(:long) # => "November 10, 2007" - # date.to_formatted_s(:long_ordinal) # => "November 10th, 2007" - # date.to_formatted_s(:rfc822) # => "10 Nov 2007" - # - # == Adding your own time formats to to_formatted_s - # You can add your own formats to the Date::DATE_FORMATS hash. - # Use the format name as the hash key and either a strftime string - # or Proc instance that takes a date argument as the value. - # - # # config/initializers/time_formats.rb - # Date::DATE_FORMATS[:month_and_year] = "%B %Y" - # Date::DATE_FORMATS[:short_ordinal] = lambda { |date| date.strftime("%B #{date.day.ordinalize}") } - def to_formatted_s(format = :default) - if formatter = DATE_FORMATS[format] - if formatter.respond_to?(:call) - formatter.call(self).to_s - else - strftime(formatter) - end - else - to_default_s - end - end - - # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005" - def readable_inspect - strftime("%a, %d %b %Y") - end - - # A method to keep Time, Date and DateTime instances interchangeable on conversions. - # In this case, it simply returns +self+. - def to_date - self - end if RUBY_VERSION < '1.9' - - # Converts a Date instance to a Time, where the time is set to the beginning of the day. - # The timezone can be either :local or :utc (default :local). - # - # ==== Examples - # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 - # - # date.to_time # => Sat Nov 10 00:00:00 0800 2007 - # date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007 - # - # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007 - def to_time(form = :local) - ::Time.send("#{form}_time", year, month, day) - end - - # Converts a Date instance to a DateTime, where the time is set to the beginning of the day - # and UTC offset is set to 0. - # - # ==== Examples - # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 - # - # date.to_datetime # => Sat, 10 Nov 2007 00:00:00 0000 - def to_datetime - ::DateTime.civil(year, month, day, 0, 0, 0, 0) - end if RUBY_VERSION < '1.9' - - def xmlschema - to_time.xmlschema - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb deleted file mode 100644 index 66a93eac..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'date' -require 'active_support/core_ext/time/behavior' -require 'active_support/core_ext/time/zones' -require 'active_support/core_ext/date_time/calculations' -require 'active_support/core_ext/date_time/conversions' - -class DateTime - include ActiveSupport::CoreExtensions::Time::Behavior - include ActiveSupport::CoreExtensions::Time::Zones - include ActiveSupport::CoreExtensions::DateTime::Calculations - include ActiveSupport::CoreExtensions::DateTime::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb deleted file mode 100644 index 0099431e..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ /dev/null @@ -1,126 +0,0 @@ -require 'rational' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module DateTime #:nodoc: - # Enables the use of time calculations within DateTime itself - module Calculations - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.class_eval do - alias_method :compare_without_coercion, :<=> - alias_method :<=>, :compare_with_coercion - end - end - - module ClassMethods - # DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone - def local_offset - ::Time.local(2007).utc_offset.to_r / 86400 - end - - def current - ::Time.zone_default ? ::Time.zone.now.to_datetime : ::Time.now.to_datetime - end - end - - # Tells whether the DateTime object's datetime lies in the past - def past? - self < ::DateTime.current - end - - # Tells whether the DateTime object's datetime lies in the future - def future? - self > ::DateTime.current - end - - # Seconds since midnight: DateTime.now.seconds_since_midnight - def seconds_since_midnight - self.sec + (self.min * 60) + (self.hour * 3600) - end - - # Returns a new DateTime where one or more of the elements have been changed according to the +options+ parameter. The time options - # (hour, minute, sec) reset cascadingly, so if only the hour is passed, then minute and sec is set to 0. If the hour and - # minute is passed, then sec is set to 0. - def change(options) - ::DateTime.civil( - options[:year] || self.year, - options[:month] || self.month, - options[:day] || self.day, - options[:hour] || self.hour, - options[:min] || (options[:hour] ? 0 : self.min), - options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec), - options[:offset] || self.offset, - options[:start] || self.start - ) - end - - # Uses Date to provide precise Time calculations for years, months, and days. - # The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>, - # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>, - # <tt>:minutes</tt>, <tt>:seconds</tt>. - def advance(options) - d = to_date.advance(options) - datetime_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day) - seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600 - seconds_to_advance == 0 ? datetime_advanced_by_date : datetime_advanced_by_date.since(seconds_to_advance) - end - - # Returns a new DateTime representing the time a number of seconds ago - # Do not use this method in combination with x.months, use months_ago instead! - def ago(seconds) - self.since(-seconds) - end - - # Returns a new DateTime representing the time a number of seconds since the instance time - # Do not use this method in combination with x.months, use months_since instead! - def since(seconds) - self + Rational(seconds.round, 86400) - end - alias :in :since - - # Returns a new DateTime representing the start of the day (0:00) - def beginning_of_day - change(:hour => 0) - end - alias :midnight :beginning_of_day - alias :at_midnight :beginning_of_day - alias :at_beginning_of_day :beginning_of_day - - # Returns a new DateTime representing the end of the day (23:59:59) - def end_of_day - change(:hour => 23, :min => 59, :sec => 59) - end - - # Adjusts DateTime to UTC by adding its offset value; offset is set to 0 - # - # Example: - # - # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)) # => Mon, 21 Feb 2005 10:11:12 -0600 - # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 +0000 - def utc - new_offset(0) - end - alias_method :getutc, :utc - - # Returns true if offset == 0 - def utc? - offset == 0 - end - - # Returns the offset value in seconds - def utc_offset - (offset * 86400).to_i - end - - # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime - def compare_with_coercion(other) - other = other.comparable_time if other.respond_to?(:comparable_time) - other = other.to_datetime unless other.acts_like?(:date) - compare_without_coercion(other) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb deleted file mode 100644 index a2d620bc..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ /dev/null @@ -1,107 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module DateTime #:nodoc: - # Converting datetimes to formatted strings, dates, and times. - module Conversions - def self.append_features(base) #:nodoc: - base.class_eval do - alias_method :default_inspect, :inspect - alias_method :to_default_s, :to_s unless (instance_methods(false) & [:to_s, 'to_s']).empty? - - # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows - # DateTimes outside the range of what can be created with Time. - remove_method :to_time if instance_methods.include?(:to_time) - end - - super - - base.class_eval do - alias_method :to_s, :to_formatted_s - alias_method :inspect, :readable_inspect - end - end - - # Convert to a formatted string. See Time::DATE_FORMATS for predefined formats. - # - # This method is aliased to <tt>to_s</tt>. - # - # === Examples - # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000 - # - # datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00" - # datetime.to_s(:db) # => "2007-12-04 00:00:00" - # datetime.to_s(:number) # => "20071204000000" - # datetime.to_formatted_s(:short) # => "04 Dec 00:00" - # datetime.to_formatted_s(:long) # => "December 04, 2007 00:00" - # datetime.to_formatted_s(:long_ordinal) # => "December 4th, 2007 00:00" - # datetime.to_formatted_s(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000" - # - # == Adding your own datetime formats to to_formatted_s - # DateTime formats are shared with Time. You can add your own to the - # Time::DATE_FORMATS hash. Use the format name as the hash key and - # either a strftime string or Proc instance that takes a time or - # datetime argument as the value. - # - # # config/initializers/time_formats.rb - # Time::DATE_FORMATS[:month_and_year] = "%B %Y" - # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } - def to_formatted_s(format = :default) - return to_default_s unless formatter = ::Time::DATE_FORMATS[format] - formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) - end - - # Returns the +utc_offset+ as an +HH:MM formatted string. Examples: - # - # datetime = DateTime.civil(2000, 1, 1, 0, 0, 0, Rational(-6, 24)) - # datetime.formatted_offset # => "-06:00" - # datetime.formatted_offset(false) # => "-0600" - def formatted_offset(colon = true, alternate_utc_string = nil) - utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005 14:30:00 +0000" - def readable_inspect - to_s(:rfc822) - end - - # Converts self to a Ruby Date object; time portion is discarded - def to_date - ::Date.new(year, month, day) - end - - # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class - # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time - def to_time - self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec) : self - end - - # To be able to keep Times, Dates and DateTimes interchangeable on conversions - def to_datetime - self - end - - # Converts datetime to an appropriate format for use in XML - def xmlschema - strftime("%Y-%m-%dT%H:%M:%S%Z") - end if RUBY_VERSION < '1.9' - - # Converts self to a floating-point number of seconds since the Unix epoch - def to_f - seconds_since_unix_epoch.to_f - end - - # Converts self to an integer number of seconds since the Unix epoch - def to_i - seconds_since_unix_epoch.to_i - end - - private - - def seconds_since_unix_epoch - seconds_per_day = 86_400 - (self - ::DateTime.civil(1970)) * seconds_per_day - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb b/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb deleted file mode 100644 index 8f49ddfd..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb +++ /dev/null @@ -1,43 +0,0 @@ -class Object - # Can you safely .dup this object? - # False for nil, false, true, symbols, and numbers; true otherwise. - def duplicable? - true - end -end - -class NilClass #:nodoc: - def duplicable? - false - end -end - -class FalseClass #:nodoc: - def duplicable? - false - end -end - -class TrueClass #:nodoc: - def duplicable? - false - end -end - -class Symbol #:nodoc: - def duplicable? - false - end -end - -class Numeric #:nodoc: - def duplicable? - false - end -end - -class Class #:nodoc: - def duplicable? - false - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb b/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb deleted file mode 100644 index 9ae89354..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'active_support/ordered_hash' - -module Enumerable - # Ruby 1.8.7 introduces group_by, but the result isn't ordered. Override it. - remove_method(:group_by) if [].respond_to?(:group_by) && RUBY_VERSION < '1.9' - - # Collect an enumerable into sets, grouped by the result of a block. Useful, - # for example, for grouping records by date. - # - # Example: - # - # latest_transcripts.group_by(&:day).each do |day, transcripts| - # p "#{day} -> #{transcripts.map(&:class).join(', ')}" - # end - # "2006-03-01 -> Transcript" - # "2006-02-28 -> Transcript" - # "2006-02-27 -> Transcript, Transcript" - # "2006-02-26 -> Transcript, Transcript" - # "2006-02-25 -> Transcript" - # "2006-02-24 -> Transcript, Transcript" - # "2006-02-23 -> Transcript" - def group_by - assoc = ActiveSupport::OrderedHash.new - - each do |element| - key = yield(element) - - if assoc.has_key?(key) - assoc[key] << element - else - assoc[key] = [element] - end - end - - assoc - end unless [].respond_to?(:group_by) - - # Calculates a sum from the elements. Examples: - # - # payments.sum { |p| p.price * p.tax_rate } - # payments.sum(&:price) - # - # The latter is a shortcut for: - # - # payments.inject { |sum, p| sum + p.price } - # - # It can also calculate the sum without the use of a block. - # - # [5, 15, 10].sum # => 30 - # ["foo", "bar"].sum # => "foobar" - # [[1, 2], [3, 1, 5]].sum => [1, 2, 3, 1, 5] - # - # The default sum of an empty list is zero. You can override this default: - # - # [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0) - # - def sum(identity = 0, &block) - if block_given? - map(&block).sum(identity) - else - inject { |sum, element| sum + element } || identity - end - end - - # Iterates over a collection, passing the current element *and* the - # +memo+ to the block. Handy for building up hashes or - # reducing collections down to one object. Examples: - # - # %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } #=> {'foo' => 'FOO', 'bar' => 'BAR'} - # - # *Note* that you can't use immutable objects like numbers, true or false as - # the memo. You would think the following returns 120, but since the memo is - # never changed, it does not. - # - # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1 - # - def each_with_object(memo, &block) - memo.tap do |m| - each do |element| - block.call(element, m) - end - end - end unless [].respond_to?(:each_with_object) - - # Convert an enumerable to a hash. Examples: - # - # people.index_by(&:login) - # => { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...} - # people.index_by { |person| "#{person.first_name} #{person.last_name}" } - # => { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...} - # - def index_by - inject({}) do |accum, elem| - accum[yield(elem)] = elem - accum - end - end - - # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1. - # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26. - def many?(&block) - size = block_given? ? select(&block).size : self.size - size > 1 - end - - # Returns true if none of the elements match the given block. - # - # success = responses.none? {|r| r.status / 100 == 5 } - # - # This is a builtin method in Ruby 1.8.7 and later. - def none?(&block) - !any?(&block) - end unless [].respond_to?(:none?) - - - # The negative of the Enumerable#include?. Returns true if the collection does not include the object. - def exclude?(object) - !include?(object) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb b/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb deleted file mode 100644 index cde0df41..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb +++ /dev/null @@ -1,45 +0,0 @@ -module ActiveSupport - if RUBY_VERSION >= '1.9' - FrozenObjectError = RuntimeError - else - FrozenObjectError = TypeError - end -end - -# TODO: Turn all this into using the BacktraceCleaner. -class Exception # :nodoc: - def clean_message - Pathname.clean_within message - end - - TraceSubstitutions = [] - FrameworkStart = /action_controller\/dispatcher\.rb/.freeze - FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/.freeze - - def clean_backtrace - backtrace.collect do |line| - Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)| - result.gsub regexp, sub - end) - end - end - - def application_backtrace - before_framework_frame = nil - before_application_frame = true - - trace = clean_backtrace.reject do |line| - before_framework_frame ||= (line =~ FrameworkStart) - non_app_frame = (line =~ FrameworkRegexp) - before_application_frame = false unless non_app_frame - before_framework_frame || (non_app_frame && !before_application_frame) - end - - # If we didn't find any application frames, return an empty app trace. - before_application_frame ? [] : trace - end - - def framework_backtrace - clean_backtrace.grep FrameworkRegexp - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/file.rb b/vendor/rails/activesupport/lib/active_support/core_ext/file.rb deleted file mode 100644 index e03f8ac4..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/file.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/file/atomic' - -class File #:nodoc: - extend ActiveSupport::CoreExtensions::File::Atomic -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/file/atomic.rb b/vendor/rails/activesupport/lib/active_support/core_ext/file/atomic.rb deleted file mode 100644 index f49d5cb1..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/file/atomic.rb +++ /dev/null @@ -1,47 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module File #:nodoc: - module Atomic - # Write to a file atomically. Useful for situations where you don't - # want other processes or threads to see half-written files. - # - # File.atomic_write("important.file") do |file| - # file.write("hello") - # end - # - # If your temp directory is not on the same filesystem as the file you're - # trying to write, you can provide a different temporary directory. - # - # File.atomic_write("/data/something.important", "/data/tmp") do |f| - # file.write("hello") - # end - def atomic_write(file_name, temp_dir = Dir.tmpdir) - require 'tempfile' unless defined?(Tempfile) - require 'fileutils' unless defined?(FileUtils) - - temp_file = Tempfile.new(basename(file_name), temp_dir) - yield temp_file - temp_file.close - - begin - # Get original file permissions - old_stat = stat(file_name) - rescue Errno::ENOENT - # No old permissions, write a temp file to determine the defaults - check_name = join(dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}") - open(check_name, "w") { } - old_stat = stat(check_name) - unlink(check_name) - end - - # Overwrite original file with temp file - FileUtils.mv(temp_file.path, file_name) - - # Set correct permissions on new file - chown(old_stat.uid, old_stat.gid, file_name) - chmod(old_stat.mode, file_name) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/float.rb b/vendor/rails/activesupport/lib/active_support/core_ext/float.rb deleted file mode 100644 index af166aa6..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/float.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'active_support/core_ext/float/rounding' -require 'active_support/core_ext/float/time' - -class Float #:nodoc: - include ActiveSupport::CoreExtensions::Float::Rounding - include ActiveSupport::CoreExtensions::Float::Time -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb b/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb deleted file mode 100644 index 062d4668..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Float #:nodoc: - module Rounding - def self.included(base) #:nodoc: - base.class_eval do - alias_method :round_without_precision, :round - alias_method :round, :round_with_precision - end - end - - # Rounds the float with the specified precision. - # - # x = 1.337 - # x.round # => 1 - # x.round(1) # => 1.3 - # x.round(2) # => 1.34 - def round_with_precision(precision = nil) - precision.nil? ? round_without_precision : (self * (10 ** precision)).round / (10 ** precision).to_f - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/float/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/float/time.rb deleted file mode 100644 index 13f2e0dd..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/float/time.rb +++ /dev/null @@ -1,27 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Float #:nodoc: - module Time - # Deprication helper methods not available as core_ext is loaded first. - def years - ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:years, "Fractional years are not respected. Convert value to integer before calling #years."), caller) - years_without_deprecation - end - def months - ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:months, "Fractional months are not respected. Convert value to integer before calling #months."), caller) - months_without_deprecation - end - - def months_without_deprecation - ActiveSupport::Duration.new(self * 30.days, [[:months, self]]) - end - alias :month :months - - def years_without_deprecation - ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]]) - end - alias :year :years - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb deleted file mode 100644 index a6065ab4..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb +++ /dev/null @@ -1,14 +0,0 @@ -%w(keys indifferent_access deep_merge reverse_merge conversions diff slice except).each do |ext| - require "active_support/core_ext/hash/#{ext}" -end - -class Hash #:nodoc: - include ActiveSupport::CoreExtensions::Hash::Keys - include ActiveSupport::CoreExtensions::Hash::IndifferentAccess - include ActiveSupport::CoreExtensions::Hash::DeepMerge - include ActiveSupport::CoreExtensions::Hash::ReverseMerge - include ActiveSupport::CoreExtensions::Hash::Conversions - include ActiveSupport::CoreExtensions::Hash::Diff - include ActiveSupport::CoreExtensions::Hash::Slice - include ActiveSupport::CoreExtensions::Hash::Except -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb deleted file mode 100644 index a43763f3..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ /dev/null @@ -1,247 +0,0 @@ -require 'date' -require 'active_support/core_ext/module/attribute_accessors' - -module ActiveSupport #:nodoc: - # these accessors are here because people using ActiveResource and REST to integrate with other systems - # have to be able to control the default behavior of rename_key. dasherize_xml is set to true to emulate - # existing behavior. In a future version it should be set to false by default. - mattr_accessor :dasherize_xml - mattr_accessor :camelize_xml - self.dasherize_xml = true - self.camelize_xml = false - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module Conversions - # This module exists to decorate files deserialized using Hash.from_xml with - # the <tt>original_filename</tt> and <tt>content_type</tt> methods. - module FileLike #:nodoc: - attr_writer :original_filename, :content_type - - def original_filename - @original_filename || 'untitled' - end - - def content_type - @content_type || 'application/octet-stream' - end - end - - XML_TYPE_NAMES = { - "Symbol" => "symbol", - "Fixnum" => "integer", - "Bignum" => "integer", - "BigDecimal" => "decimal", - "Float" => "float", - "TrueClass" => "boolean", - "FalseClass" => "boolean", - "Date" => "date", - "DateTime" => "datetime", - "Time" => "datetime", - "ActiveSupport::TimeWithZone" => "datetime" - } unless defined?(XML_TYPE_NAMES) - - XML_FORMATTING = { - "symbol" => Proc.new { |symbol| symbol.to_s }, - "date" => Proc.new { |date| date.to_s(:db) }, - "datetime" => Proc.new { |time| time.xmlschema }, - "binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) }, - "yaml" => Proc.new { |yaml| yaml.to_yaml } - } unless defined?(XML_FORMATTING) - - # TODO: use Time.xmlschema instead of Time.parse; - # use regexp instead of Date.parse - unless defined?(XML_PARSING) - XML_PARSING = { - "symbol" => Proc.new { |symbol| symbol.to_sym }, - "date" => Proc.new { |date| ::Date.parse(date) }, - "datetime" => Proc.new { |time| ::Time.parse(time).utc rescue ::DateTime.parse(time).utc }, - "integer" => Proc.new { |integer| integer.to_i }, - "float" => Proc.new { |float| float.to_f }, - "decimal" => Proc.new { |number| BigDecimal(number) }, - "boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) }, - "string" => Proc.new { |string| string.to_s }, - "yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml }, - "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) }, - "file" => Proc.new do |file, entity| - f = StringIO.new(ActiveSupport::Base64.decode64(file)) - f.extend(FileLike) - f.original_filename = entity['name'] - f.content_type = entity['content_type'] - f - end - } - - XML_PARSING.update( - "double" => XML_PARSING["float"], - "dateTime" => XML_PARSING["datetime"] - ) - end - - def self.included(klass) - klass.extend(ClassMethods) - end - - # Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be - # passed to enclose the param names (see example below). - # - # ==== Examples - # { :name => 'David', :nationality => 'Danish' }.to_query # => "name=David&nationality=Danish" - # - # { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish" - def to_query(namespace = nil) - collect do |key, value| - value.to_query(namespace ? "#{namespace}[#{key}]" : key) - end.sort * '&' - end - - alias_method :to_param, :to_query - - def to_xml(options = {}) - require 'builder' unless defined?(Builder) - - options = options.dup - options[:indent] ||= 2 - options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]), - :root => "hash" }) - options[:builder].instruct! unless options.delete(:skip_instruct) - root = rename_key(options[:root].to_s, options) - - options[:builder].__send__(:method_missing, root) do - each do |key, value| - case value - when ::Hash - value.to_xml(options.merge({ :root => key, :skip_instruct => true })) - when ::Array - value.to_xml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true})) - when ::Method, ::Proc - # If the Method or Proc takes two arguments, then - # pass the suggested child element name. This is - # used if the Method or Proc will be operating over - # multiple records and needs to create an containing - # element that will contain the objects being - # serialized. - if 1 == value.arity - value.call(options.merge({ :root => key, :skip_instruct => true })) - else - value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize) - end - else - if value.respond_to?(:to_xml) - value.to_xml(options.merge({ :root => key, :skip_instruct => true })) - else - type_name = XML_TYPE_NAMES[value.class.name] - - key = rename_key(key.to_s, options) - - attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name } - if value.nil? - attributes[:nil] = true - end - - options[:builder].tag!(key, - XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value, - attributes - ) - end - end - end - - yield options[:builder] if block_given? - end - - end - - def rename_key(key, options = {}) - camelize = options.has_key?(:camelize) ? options[:camelize] : ActiveSupport.camelize_xml - dasherize = options.has_key?(:dasherize) ? options[:dasherize] : ActiveSupport.dasherize_xml - key = key.camelize if camelize - key = key.dasherize if dasherize - key - end - - module ClassMethods - def from_xml(xml) - typecast_xml_value(unrename_keys(XmlMini.parse(xml))) - end - - private - def typecast_xml_value(value) - case value.class.to_s - when 'Hash' - if value['type'] == 'array' - child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway - if entries.nil? || (c = value['__content__'] && c.blank?) - [] - else - case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a? - when "Array" - entries.collect { |v| typecast_xml_value(v) } - when "Hash" - [typecast_xml_value(entries)] - else - raise "can't typecast #{entries.inspect}" - end - end - elsif value.has_key?("__content__") - content = value["__content__"] - if parser = XML_PARSING[value["type"]] - if parser.arity == 2 - XML_PARSING[value["type"]].call(content, value) - else - XML_PARSING[value["type"]].call(content) - end - else - content - end - elsif value['type'] == 'string' && value['nil'] != 'true' - "" - # blank or nil parsed values are represented by nil - elsif value.blank? || value['nil'] == 'true' - nil - # If the type is the only element which makes it then - # this still makes the value nil, except if type is - # a XML node(where type['value'] is a Hash) - elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash) - nil - else - xml_value = value.inject({}) do |h,(k,v)| - h[k] = typecast_xml_value(v) - h - end - - # Turn { :files => { :file => #<StringIO> } into { :files => #<StringIO> } so it is compatible with - # how multipart uploaded files from HTML appear - xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value - end - when 'Array' - value.map! { |i| typecast_xml_value(i) } - case value.length - when 0 then nil - when 1 then value.first - else value - end - when 'String' - value - else - raise "can't typecast #{value.class.name} - #{value.inspect}" - end - end - - def unrename_keys(params) - case params.class.to_s - when "Hash" - params.inject({}) do |h,(k,v)| - h[k.to_s.tr("-", "_")] = unrename_keys(v) - h - end - when "Array" - params.map { |v| unrename_keys(v) } - else - params - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb deleted file mode 100644 index f8842ba5..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Allows for deep merging - module DeepMerge - # Returns a new hash with +self+ and +other_hash+ merged recursively. - def deep_merge(other_hash) - self.merge(other_hash) do |key, oldval, newval| - oldval = oldval.to_hash if oldval.respond_to?(:to_hash) - newval = newval.to_hash if newval.respond_to?(:to_hash) - oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval - end - end - - # Returns a new hash with +self+ and +other_hash+ merged recursively. - # Modifies the receiver in place. - def deep_merge!(other_hash) - replace(deep_merge(other_hash)) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb deleted file mode 100644 index 6abd6788..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module Diff - # Returns a hash that represents the difference between two hashes. - # - # Examples: - # - # {1 => 2}.diff(1 => 2) # => {} - # {1 => 2}.diff(1 => 3) # => {1 => 2} - # {}.diff(1 => 2) # => {1 => 2} - # {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4} - def diff(h2) - self.dup.delete_if { |k, v| h2[k] == v }.merge(h2.dup.delete_if { |k, v| self.has_key?(k) }) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb deleted file mode 100644 index 949976d7..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'set' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Return a hash that includes everything but the given keys. This is useful for - # limiting a set of parameters to everything but a few known toggles: - # - # @person.update_attributes(params[:person].except(:admin)) - module Except - # Returns a new hash without the given keys. - def except(*keys) - dup.except!(*keys) - end - - # Replaces the hash without the given keys. - def except!(*keys) - keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) - keys.each { |key| delete(key) } - self - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb deleted file mode 100644 index 34ba8a00..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ /dev/null @@ -1,143 +0,0 @@ -# This class has dubious semantics and we only have it so that -# people can write params[:key] instead of params['key'] -# and they get the same value for both keys. - -class HashWithIndifferentAccess < Hash - def initialize(constructor = {}) - if constructor.is_a?(Hash) - super() - update(constructor) - else - super(constructor) - end - end - - def default(key = nil) - if key.is_a?(Symbol) && include?(key = key.to_s) - self[key] - else - super - end - end - - alias_method :regular_writer, :[]= unless method_defined?(:regular_writer) - alias_method :regular_update, :update unless method_defined?(:regular_update) - - # Assigns a new value to the hash: - # - # hash = HashWithIndifferentAccess.new - # hash[:key] = "value" - # - def []=(key, value) - regular_writer(convert_key(key), convert_value(value)) - end - - # Updates the instantized hash with values from the second: - # - # hash_1 = HashWithIndifferentAccess.new - # hash_1[:key] = "value" - # - # hash_2 = HashWithIndifferentAccess.new - # hash_2[:key] = "New Value!" - # - # hash_1.update(hash_2) # => {"key"=>"New Value!"} - # - def update(other_hash) - other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) } - self - end - - alias_method :merge!, :update - - # Checks the hash for a key matching the argument passed in: - # - # hash = HashWithIndifferentAccess.new - # hash["key"] = "value" - # hash.key? :key # => true - # hash.key? "key" # => true - # - def key?(key) - super(convert_key(key)) - end - - alias_method :include?, :key? - alias_method :has_key?, :key? - alias_method :member?, :key? - - # Fetches the value for the specified key, same as doing hash[key] - def fetch(key, *extras) - super(convert_key(key), *extras) - end - - # Returns an array of the values at the specified indices: - # - # hash = HashWithIndifferentAccess.new - # hash[:a] = "x" - # hash[:b] = "y" - # hash.values_at("a", "b") # => ["x", "y"] - # - def values_at(*indices) - indices.collect {|key| self[convert_key(key)]} - end - - # Returns an exact copy of the hash. - def dup - HashWithIndifferentAccess.new(self) - end - - # Merges the instantized and the specified hashes together, giving precedence to the values from the second hash - # Does not overwrite the existing hash. - def merge(hash) - self.dup.update(hash) - end - - # Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. - # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. - def reverse_merge(other_hash) - super other_hash.with_indifferent_access - end - - # Removes a specified key from the hash. - def delete(key) - super(convert_key(key)) - end - - def stringify_keys!; self end - def symbolize_keys!; self end - def to_options!; self end - - # Convert to a Hash with String keys. - def to_hash - Hash.new(default).merge(self) - end - - protected - def convert_key(key) - key.kind_of?(Symbol) ? key.to_s : key - end - - def convert_value(value) - case value - when Hash - value.with_indifferent_access - when Array - value.collect { |e| e.is_a?(Hash) ? e.with_indifferent_access : e } - else - value - end - end -end - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module IndifferentAccess #:nodoc: - def with_indifferent_access - hash = HashWithIndifferentAccess.new(self) - hash.default = self.default - hash - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb deleted file mode 100644 index af9d372d..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb +++ /dev/null @@ -1,52 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module Keys - # Return a new hash with all keys converted to strings. - def stringify_keys - inject({}) do |options, (key, value)| - options[key.to_s] = value - options - end - end - - # Destructively convert all keys to strings. - def stringify_keys! - keys.each do |key| - self[key.to_s] = delete(key) - end - self - end - - # Return a new hash with all keys converted to symbols. - def symbolize_keys - inject({}) do |options, (key, value)| - options[(key.to_sym rescue key) || key] = value - options - end - end - - # Destructively convert all keys to symbols. - def symbolize_keys! - self.replace(self.symbolize_keys) - end - - alias_method :to_options, :symbolize_keys - alias_method :to_options!, :symbolize_keys! - - # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. - # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols - # as keys, this will fail. - # - # ==== Examples - # { :name => "Rob", :years => "28" }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key(s): years" - # { :name => "Rob", :age => "28" }.assert_valid_keys("name", "age") # => raises "ArgumentError: Unknown key(s): name, age" - # { :name => "Rob", :age => "28" }.assert_valid_keys(:name, :age) # => passes, raises nothing - def assert_valid_keys(*valid_keys) - unknown_keys = keys - [valid_keys].flatten - raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty? - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb deleted file mode 100644 index 546e261c..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ /dev/null @@ -1,35 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Allows for reverse merging two hashes where the keys in the calling hash take precedence over those - # in the <tt>other_hash</tt>. This is particularly useful for initializing an option hash with default values: - # - # def setup(options = {}) - # options.reverse_merge! :size => 25, :velocity => 10 - # end - # - # Using <tt>merge</tt>, the above example would look as follows: - # - # def setup(options = {}) - # { :size => 25, :velocity => 10 }.merge(options) - # end - # - # The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already - # have the respective key. - module ReverseMerge - # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. - def reverse_merge(other_hash) - other_hash.merge(self) - end - - # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. - # Modifies the receiver in place. - def reverse_merge!(other_hash) - replace(reverse_merge(other_hash)) - end - - alias_method :reverse_update, :reverse_merge! - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb deleted file mode 100644 index d845a6d8..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb +++ /dev/null @@ -1,40 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Slice a hash to include only the given keys. This is useful for - # limiting an options hash to valid keys before passing to a method: - # - # def search(criteria = {}) - # assert_valid_keys(:mass, :velocity, :time) - # end - # - # search(options.slice(:mass, :velocity, :time)) - # - # If you have an array of keys you want to limit to, you should splat them: - # - # valid_keys = [:mass, :velocity, :time] - # search(options.slice(*valid_keys)) - module Slice - # Returns a new hash with only the given keys. - def slice(*keys) - keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) - hash = self.class.new - keys.each { |k| hash[k] = self[k] if has_key?(k) } - hash - end - - # Replaces the hash with only the given keys. - # Returns a hash contained the removed key/value pairs - # {:a => 1, :b => 2, :c => 3, :d => 4}.slice!(:a, :b) # => {:c => 3, :d =>4} - def slice!(*keys) - keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) - omit = slice(*self.keys - keys) - hash = slice(*keys) - replace(hash) - omit - end - end - end - end -end - diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb deleted file mode 100644 index 18a7a402..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'active_support/core_ext/integer/even_odd' -require 'active_support/core_ext/integer/inflections' -require 'active_support/core_ext/integer/time' - -class Integer #:nodoc: - include ActiveSupport::CoreExtensions::Integer::EvenOdd - include ActiveSupport::CoreExtensions::Integer::Inflections - include ActiveSupport::CoreExtensions::Integer::Time -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb deleted file mode 100644 index b1d1e280..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb +++ /dev/null @@ -1,29 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Integer #:nodoc: - # For checking if a fixnum is even or odd. - # - # 2.even? # => true - # 2.odd? # => false - # 1.even? # => false - # 1.odd? # => true - # 0.even? # => true - # 0.odd? # => false - # -1.even? # => false - # -1.odd? # => true - module EvenOdd - def multiple_of?(number) - self % number == 0 - end - - def even? - multiple_of? 2 - end if RUBY_VERSION < '1.9' - - def odd? - !even? - end if RUBY_VERSION < '1.9' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb deleted file mode 100644 index 804702be..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'active_support/inflector' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Integer #:nodoc: - module Inflections - # Ordinalize turns a number into an ordinal string used to denote the - # position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - # - # 1.ordinalize # => "1st" - # 2.ordinalize # => "2nd" - # 1002.ordinalize # => "1002nd" - # 1003.ordinalize # => "1003rd" - def ordinalize - Inflector.ordinalize(self) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer/time.rb deleted file mode 100644 index 356e145b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer/time.rb +++ /dev/null @@ -1,45 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Integer #:nodoc: - # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. - # - # These methods use Time#advance for precise date calculations when using from_now, ago, etc. - # as well as adding or subtracting their results from a Time object. For example: - # - # # equivalent to Time.now.advance(:months => 1) - # 1.month.from_now - # - # # equivalent to Time.now.advance(:years => 2) - # 2.years.from_now - # - # # equivalent to Time.now.advance(:months => 4, :years => 5) - # (4.months + 5.years).from_now - # - # While these methods provide precise calculation when used as in the examples above, care - # should be taken to note that this is not true if the result of `months', `years', etc is - # converted before use: - # - # # equivalent to 30.days.to_i.from_now - # 1.month.to_i.from_now - # - # # equivalent to 365.25.days.to_f.from_now - # 1.year.to_f.from_now - # - # In such cases, Ruby's core - # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and - # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision - # date and time arithmetic - module Time - def months - ActiveSupport::Duration.new(self * 30.days, [[:months, self]]) - end - alias :month :months - - def years - ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]]) - end - alias :year :years - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb deleted file mode 100644 index 1922d804..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/kernel/daemonizing' -require 'active_support/core_ext/kernel/reporting' -require 'active_support/core_ext/kernel/agnostics' -require 'active_support/core_ext/kernel/requires' -require 'active_support/core_ext/kernel/debugger' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb deleted file mode 100644 index c0cb4fb4..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Object - # Makes backticks behave (somewhat more) similarly on all platforms. - # On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the - # spawned shell prints a message to stderr and sets $?. We emulate - # Unix on the former but not the latter. - def `(command) #:nodoc: - super - rescue Errno::ENOENT => e - STDERR.puts "#$0: #{e}" - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb deleted file mode 100644 index ed9d1f9b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Kernel - # Turns the current script into a daemon process that detaches from the console. - # It can be shut down with a TERM signal. - def daemonize - Process.daemon - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb deleted file mode 100644 index 59e03e3d..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Kernel - unless respond_to?(:debugger) - # Starts a debugging session if ruby-debug has been loaded (call script/server --debugger to do load it). - def debugger - message = "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n" - defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message) - end - end - - undef :breakpoint if respond_to?(:breakpoint) - def breakpoint - message = "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n" - defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message) - debugger - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb deleted file mode 100644 index e2d5186d..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ /dev/null @@ -1,59 +0,0 @@ -module Kernel - # Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards. - # - # silence_warnings do - # value = noisy_call # no warning voiced - # end - # - # noisy_call # warning voiced - def silence_warnings - old_verbose, $VERBOSE = $VERBOSE, nil - yield - ensure - $VERBOSE = old_verbose - end - - # Sets $VERBOSE to true for the duration of the block and back to its original value afterwards. - def enable_warnings - old_verbose, $VERBOSE = $VERBOSE, true - yield - ensure - $VERBOSE = old_verbose - end - - # For compatibility - def silence_stderr #:nodoc: - silence_stream(STDERR) { yield } - end - - # Silences any stream for the duration of the block. - # - # silence_stream(STDOUT) do - # puts 'This will never be seen' - # end - # - # puts 'But this will' - def silence_stream(stream) - old_stream = stream.dup - stream.reopen(RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'NUL:' : '/dev/null') - stream.sync = true - yield - ensure - stream.reopen(old_stream) - end - - # Blocks and ignores any exception passed as argument if raised within the block. - # - # suppress(ZeroDivisionError) do - # 1/0 - # puts "This code is NOT reached" - # end - # - # puts "This code gets executed and nothing related to ZeroDivisionError was seen" - def suppress(*exception_classes) - begin yield - rescue Exception => e - raise unless exception_classes.any? { |cls| e.kind_of?(cls) } - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb deleted file mode 100644 index 323fea49..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Kernel - # Require a library with fallback to RubyGems. Warnings during library - # loading are silenced to increase signal/noise for application warnings. - def require_library_or_gem(library_name) - silence_warnings do - begin - require library_name - rescue LoadError => cannot_require - # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try. - begin - require 'rubygems' - rescue LoadError => rubygems_not_installed - raise cannot_require - end - # 2. Rubygems is installed and loaded. Try to load the library again - begin - require library_name - rescue LoadError => gem_not_installed - raise cannot_require - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb deleted file mode 100644 index 33612155..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Kernel - # Returns the object's singleton class. - def singleton_class - class << self - self - end - end unless respond_to?(:singleton_class) # exists in 1.9.2 - - # class_eval on an object acts like singleton_class.class_eval. - def class_eval(*args, &block) - singleton_class.class_eval(*args, &block) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb b/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb deleted file mode 100644 index 6165e954..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb +++ /dev/null @@ -1,38 +0,0 @@ -class MissingSourceFile < LoadError #:nodoc: - attr_reader :path - def initialize(message, path) - super(message) - @path = path - end - - def is_missing?(path) - path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '') - end - - def self.from_message(message) - REGEXPS.each do |regexp, capture| - match = regexp.match(message) - return MissingSourceFile.new(message, match[capture]) unless match.nil? - end - nil - end - - REGEXPS = [ - [/^no such file to load -- (.+)$/i, 1], - [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2], - [/^Missing API definition file in (.+)$/i, 1] - ] unless defined?(REGEXPS) -end - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module LoadErrorExtensions #:nodoc: - module LoadErrorClassMethods #:nodoc: - def new(*args) - (self == LoadError && MissingSourceFile.from_message(args.first)) || super - end - end - ::LoadError.extend(LoadErrorClassMethods) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb b/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb deleted file mode 100644 index 858da7aa..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb +++ /dev/null @@ -1,145 +0,0 @@ -# Adds the 'around_level' method to Logger. - -class Logger - def self.define_around_helper(level) - module_eval <<-end_eval - def around_#{level}(before_message, after_message, &block) # def around_debug(before_message, after_message, &block) - self.#{level}(before_message) # self.debug(before_message) - return_value = block.call(self) # return_value = block.call(self) - self.#{level}(after_message) # self.debug(after_message) - return return_value # return return_value - end # end - end_eval - end - [:debug, :info, :error, :fatal].each {|level| define_around_helper(level) } -end - - -require 'logger' - -# Extensions to the built in Ruby logger. -# -# If you want to use the default log formatter as defined in the Ruby core, then you -# will need to set the formatter for the logger as in: -# -# logger.formatter = Formatter.new -# -# You can then specify the datetime format, for example: -# -# logger.datetime_format = "%Y-%m-%d" -# -# Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger -class Logger - ## - # :singleton-method: - # Set to false to disable the silencer - cattr_accessor :silencer - self.silencer = true - - # Silences the logger for the duration of the block. - def silence(temporary_level = Logger::ERROR) - if silencer - begin - old_logger_level, self.level = level, temporary_level - yield self - ensure - self.level = old_logger_level - end - else - yield self - end - end - - alias :old_datetime_format= :datetime_format= - # Logging date-time format (string passed to +strftime+). Ignored if the formatter - # does not respond to datetime_format=. - def datetime_format=(datetime_format) - formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=) - end - - alias :old_datetime_format :datetime_format - # Get the logging datetime format. Returns nil if the formatter does not support - # datetime formatting. - def datetime_format - formatter.datetime_format if formatter.respond_to?(:datetime_format) - end - - alias :old_formatter :formatter if method_defined?(:formatter) - # Get the current formatter. The default formatter is a SimpleFormatter which only - # displays the log message - def formatter - @formatter ||= SimpleFormatter.new - end - - unless const_defined? :Formatter - class Formatter - Format = "%s, [%s#%d] %5s -- %s: %s\n" - - attr_accessor :datetime_format - - def initialize - @datetime_format = nil - end - - def call(severity, time, progname, msg) - Format % [severity[0..0], format_datetime(time), $$, severity, progname, - msg2str(msg)] - end - - private - def format_datetime(time) - if @datetime_format.nil? - time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec - else - time.strftime(@datetime_format) - end - end - - def msg2str(msg) - case msg - when ::String - msg - when ::Exception - "#{ msg.message } (#{ msg.class })\n" << - (msg.backtrace || []).join("\n") - else - msg.inspect - end - end - end - end - - # Simple formatter which only displays the message. - class SimpleFormatter < Logger::Formatter - # This method is invoked when a log event occurs - def call(severity, timestamp, progname, msg) - "#{String === msg ? msg : msg.inspect}\n" - end - end - - private - alias old_format_message format_message - - # Ruby 1.8.3 transposed the msg and progname arguments to format_message. - # We can't test RUBY_VERSION because some distributions don't keep Ruby - # and its standard library in sync, leading to installations of Ruby 1.8.2 - # with Logger from 1.8.3 and vice versa. - if method_defined?(:formatter=) - def format_message(severity, timestamp, progname, msg) - formatter.call(severity, timestamp, progname, msg) - end - else - def format_message(severity, timestamp, msg, progname) - formatter.call(severity, timestamp, progname, msg) - end - - attr_writer :formatter - public :formatter= - - alias old_format_datetime format_datetime - def format_datetime(datetime) datetime end - - alias old_msg2str msg2str - def msg2str(msg) msg end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module.rb deleted file mode 100644 index da8d28ec..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'active_support/core_ext/module/inclusion' -require 'active_support/core_ext/module/attribute_accessors' -require 'active_support/core_ext/module/attr_internal' -require 'active_support/core_ext/module/attr_accessor_with_default' -require 'active_support/core_ext/module/delegation' -require 'active_support/core_ext/module/introspection' -require 'active_support/core_ext/module/loading' -require 'active_support/core_ext/module/aliasing' -require 'active_support/core_ext/module/model_naming' -require 'active_support/core_ext/module/synchronization' - -module ActiveSupport - module CoreExtensions - # Various extensions for the Ruby core Module class. - module Module - # Nothing here. Only defined for API documentation purposes. - end - end -end - -class Module - include ActiveSupport::CoreExtensions::Module -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb deleted file mode 100644 index 5dafd065..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb +++ /dev/null @@ -1,74 +0,0 @@ -module ActiveSupport - module CoreExtensions - module Module - # Encapsulates the common pattern of: - # - # alias_method :foo_without_feature, :foo - # alias_method :foo, :foo_with_feature - # - # With this, you simply do: - # - # alias_method_chain :foo, :feature - # - # And both aliases are set up for you. - # - # Query and bang methods (foo?, foo!) keep the same punctuation: - # - # alias_method_chain :foo?, :feature - # - # is equivalent to - # - # alias_method :foo_without_feature?, :foo? - # alias_method :foo?, :foo_with_feature? - # - # so you can safely chain foo, foo?, and foo! with the same feature. - def alias_method_chain(target, feature) - # Strip out punctuation on predicates or bang methods since - # e.g. target?_without_feature is not a valid method name. - aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1 - yield(aliased_target, punctuation) if block_given? - - with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}" - - alias_method without_method, target - alias_method target, with_method - - case - when public_method_defined?(without_method) - public target - when protected_method_defined?(without_method) - protected target - when private_method_defined?(without_method) - private target - end - end - - # Allows you to make aliases for attributes, which includes - # getter, setter, and query methods. - # - # Example: - # - # class Content < ActiveRecord::Base - # # has a title attribute - # end - # - # class Email < Content - # alias_attribute :subject, :title - # end - # - # e = Email.find(1) - # e.title # => "Superstars" - # e.subject # => "Superstars" - # e.subject? # => true - # e.subject = "Megastars" - # e.title # => "Megastars" - def alias_attribute(new_name, old_name) - module_eval <<-STR, __FILE__, __LINE__ + 1 - def #{new_name}; self.#{old_name}; end # def subject; self.title; end - def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end - def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end - STR - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb deleted file mode 100644 index 28ac89da..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb +++ /dev/null @@ -1,31 +0,0 @@ -class Module - # Declare an attribute accessor with an initial default return value. - # - # To give attribute <tt>:age</tt> the initial value <tt>25</tt>: - # - # class Person - # attr_accessor_with_default :age, 25 - # end - # - # some_person.age - # => 25 - # some_person.age = 26 - # some_person.age - # => 26 - # - # To give attribute <tt>:element_name</tt> a dynamic default value, evaluated - # in scope of self: - # - # attr_accessor_with_default(:element_name) { name.underscore } - # - def attr_accessor_with_default(sym, default = nil, &block) - raise 'Default value or block required' unless !default.nil? || block - define_method(sym, block_given? ? block : Proc.new { default }) - module_eval(<<-EVAL, __FILE__, __LINE__ + 1) - def #{sym}=(value) # def age=(value) - class << self; attr_reader :#{sym} end # class << self; attr_reader :age end - @#{sym} = value # @age = value - end # end - EVAL - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb deleted file mode 100644 index b66c0d75..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Module - # Declares an attribute reader backed by an internally-named instance variable. - def attr_internal_reader(*attrs) - attrs.each do |attr| - module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end" - end - end - - # Declares an attribute writer backed by an internally-named instance variable. - def attr_internal_writer(*attrs) - attrs.each do |attr| - module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end" - end - end - - # Declares an attribute reader and writer backed by an internally-named instance - # variable. - def attr_internal_accessor(*attrs) - attr_internal_reader(*attrs) - attr_internal_writer(*attrs) - end - - alias_method :attr_internal, :attr_internal_accessor - - private - mattr_accessor :attr_internal_naming_format - self.attr_internal_naming_format = '@_%s' - - def attr_internal_ivar_name(attr) - attr_internal_naming_format % attr - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb deleted file mode 100644 index 54a29c03..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +++ /dev/null @@ -1,67 +0,0 @@ -require "active_support/core_ext/array" - -# Extends the module object with module and instance accessors for class attributes, -# just like the native attr* accessors for instance attributes. -# -# module AppConfiguration -# mattr_accessor :google_api_key -# self.google_api_key = "123456789" -# -# mattr_accessor :paypal_url -# self.paypal_url = "www.sandbox.paypal.com" -# end -# -# AppConfiguration.google_api_key = "overriding the api key!" -class Module - def mattr_reader(*syms) - options = syms.extract_options! - syms.each do |sym| - next if sym.is_a?(Hash) - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - unless defined? @@#{sym} - @@#{sym} = nil - end - - def self.#{sym} - @@#{sym} - end - EOS - - unless options[:instance_reader] == false - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{sym} - @@#{sym} - end - EOS - end - end - end - - def mattr_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - unless defined? @@#{sym} - @@#{sym} = nil - end - - def self.#{sym}=(obj) - @@#{sym} = obj - end - EOS - - unless options[:instance_writer] == false - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{sym}=(obj) - @@#{sym} = obj - end - EOS - end - end - end - - def mattr_accessor(*syms) - mattr_reader(*syms) - mattr_writer(*syms) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb deleted file mode 100644 index d7796fcd..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +++ /dev/null @@ -1,135 +0,0 @@ -class Module - # Provides a delegate class method to easily expose contained objects' methods - # as your own. Pass one or more methods (specified as symbols or strings) - # and the name of the target object as the final <tt>:to</tt> option (also a symbol - # or string). At least one method and the <tt>:to</tt> option are required. - # - # Delegation is particularly useful with Active Record associations: - # - # class Greeter < ActiveRecord::Base - # def hello() "hello" end - # def goodbye() "goodbye" end - # end - # - # class Foo < ActiveRecord::Base - # belongs_to :greeter - # delegate :hello, :to => :greeter - # end - # - # Foo.new.hello # => "hello" - # Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for #<Foo:0x1af30c> - # - # Multiple delegates to the same target are allowed: - # - # class Foo < ActiveRecord::Base - # belongs_to :greeter - # delegate :hello, :goodbye, :to => :greeter - # end - # - # Foo.new.goodbye # => "goodbye" - # - # Methods can be delegated to instance variables, class variables, or constants - # by providing them as a symbols: - # - # class Foo - # CONSTANT_ARRAY = [0,1,2,3] - # @@class_array = [4,5,6,7] - # - # def initialize - # @instance_array = [8,9,10,11] - # end - # delegate :sum, :to => :CONSTANT_ARRAY - # delegate :min, :to => :@@class_array - # delegate :max, :to => :@instance_array - # end - # - # Foo.new.sum # => 6 - # Foo.new.min # => 4 - # Foo.new.max # => 11 - # - # Delegates can optionally be prefixed using the <tt>:prefix</tt> option. If the value - # is <tt>true</tt>, the delegate methods are prefixed with the name of the object being - # delegated to. - # - # Person = Struct.new(:name, :address) - # - # class Invoice < Struct.new(:client) - # delegate :name, :address, :to => :client, :prefix => true - # end - # - # john_doe = Person.new("John Doe", "Vimmersvej 13") - # invoice = Invoice.new(john_doe) - # invoice.client_name # => "John Doe" - # invoice.client_address # => "Vimmersvej 13" - # - # It is also possible to supply a custom prefix. - # - # class Invoice < Struct.new(:client) - # delegate :name, :address, :to => :client, :prefix => :customer - # end - # - # invoice = Invoice.new(john_doe) - # invoice.customer_name # => "John Doe" - # invoice.customer_address # => "Vimmersvej 13" - # - # If the object to which you delegate can be nil, you may want to use the - # :allow_nil option. In that case, it returns nil instead of raising a - # NoMethodError exception: - # - # class Foo - # attr_accessor :bar - # def initialize(bar = nil) - # @bar = bar - # end - # delegate :zoo, :to => :bar - # end - # - # Foo.new.zoo # raises NoMethodError exception (you called nil.zoo) - # - # class Foo - # attr_accessor :bar - # def initialize(bar = nil) - # @bar = bar - # end - # delegate :zoo, :to => :bar, :allow_nil => true - # end - # - # Foo.new.zoo # returns nil - # - def delegate(*methods) - options = methods.pop - unless options.is_a?(Hash) && to = options[:to] - raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)." - end - - if options[:prefix] == true && options[:to].to_s =~ /^[^a-z_]/ - raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method." - end - - prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_" - - file, line = caller.first.split(':', 2) - line = line.to_i - - methods.each do |method| - on_nil = - if options[:allow_nil] - 'return' - else - %(raise "#{prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}") - end - - module_eval(<<-EOS, file, line) - def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block) - #{to}.__send__(#{method.inspect}, *args, &block) # client.__send__(:name, *args, &block) - rescue NoMethodError # rescue NoMethodError - if #{to}.nil? # if client.nil? - #{on_nil} - else # else - raise # raise - end # end - end # end - EOS - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb deleted file mode 100644 index 4f238416..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb +++ /dev/null @@ -1,30 +0,0 @@ -class Module - # Returns the classes in the current ObjectSpace where this module has been - # mixed in according to Module#included_modules. - # - # module M - # end - # - # module N - # include M - # end - # - # class C - # include M - # end - # - # class D < C - # end - # - # p M.included_in_classes # => [C, D] - # - def included_in_classes - classes = [] - ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) } - - classes.reverse.inject([]) do |unique_classes, klass| - unique_classes << klass unless unique_classes.collect { |k| k.to_s }.include?(klass.to_s) - unique_classes - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb deleted file mode 100644 index 8beaff4b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +++ /dev/null @@ -1,90 +0,0 @@ -module ActiveSupport - module CoreExtensions - module Module - # Returns the name of the module containing this one. - # - # p M::N.parent_name # => "M" - def parent_name - unless defined? @parent_name - @parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil - end - @parent_name - end - - # Returns the module which contains this one according to its name. - # - # module M - # module N - # end - # end - # X = M::N - # - # p M::N.parent # => M - # p X.parent # => M - # - # The parent of top-level and anonymous modules is Object. - # - # p M.parent # => Object - # p Module.new.parent # => Object - # - def parent - parent_name ? parent_name.constantize : Object - end - - # Returns all the parents of this module according to its name, ordered from - # nested outwards. The receiver is not contained within the result. - # - # module M - # module N - # end - # end - # X = M::N - # - # p M.parents # => [Object] - # p M::N.parents # => [M, Object] - # p X.parents # => [M, Object] - # - def parents - parents = [] - if parent_name - parts = parent_name.split('::') - until parts.empty? - parents << (parts * '::').constantize - parts.pop - end - end - parents << Object unless parents.include? Object - parents - end - - if RUBY_VERSION < '1.9' - # Returns the constants that have been defined locally by this object and - # not in an ancestor. This method is exact if running under Ruby 1.9. In - # previous versions it may miss some constants if their definition in some - # ancestor is identical to their definition in the receiver. - def local_constants - inherited = {} - - ancestors.each do |anc| - next if anc == self - anc.constants.each { |const| inherited[const] = anc.const_get(const) } - end - - constants.select do |const| - !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id - end - end - else - def local_constants #:nodoc: - constants(false) - end - end - - # Returns the names of the constants defined locally rather than the - # constants themselves. See <tt>local_constants</tt>. - def local_constant_names - local_constants.map { |c| c.to_s } - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb deleted file mode 100644 index 4b4b110b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Module - # Returns String#underscore applied to the module name minus trailing classes. - # - # ActiveRecord.as_load_path # => "active_record" - # ActiveRecord::Associations.as_load_path # => "active_record/associations" - # ActiveRecord::Base.as_load_path # => "active_record" (Base is a class) - # - # The Kernel module gives an empty string by definition. - # - # Kernel.as_load_path # => "" - # Math.as_load_path # => "math" - def as_load_path - if self == Object || self == Kernel - '' - elsif is_a? Class - parent == self ? '' : parent.as_load_path - else - name.split('::').collect do |word| - word.underscore - end * '/' - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb deleted file mode 100644 index 9686be01..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb +++ /dev/null @@ -1,25 +0,0 @@ -module ActiveSupport - class ModelName < String - attr_reader :singular, :plural, :element, :collection, :partial_path - alias_method :cache_key, :collection - - def initialize(name) - super - @singular = ActiveSupport::Inflector.underscore(self).tr('/', '_').freeze - @plural = ActiveSupport::Inflector.pluralize(@singular).freeze - @element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).freeze - @collection = ActiveSupport::Inflector.tableize(self).freeze - @partial_path = "#{@collection}/#{@element}".freeze - end - end - - module CoreExtensions - module Module - # Returns an ActiveSupport::ModelName object for module. It can be - # used to retrieve all kinds of naming-related information. - def model_name - @model_name ||= ::ActiveSupport::ModelName.new(name) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/remove_method.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/remove_method.rb deleted file mode 100644 index 2714a46b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/remove_method.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Module - def remove_possible_method(method) - remove_method(method) - rescue NameError - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/synchronization.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/synchronization.rb deleted file mode 100644 index f645d8ee..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/synchronization.rb +++ /dev/null @@ -1,39 +0,0 @@ -class Module - # Synchronize access around a method, delegating synchronization to a - # particular mutex. A mutex (either a Mutex, or any object that responds to - # #synchronize and yields to a block) must be provided as a final :with option. - # The :with option should be a symbol or string, and can represent a method, - # constant, or instance or class variable. - # Example: - # class SharedCache - # @@lock = Mutex.new - # def expire - # ... - # end - # synchronize :expire, :with => :@@lock - # end - def synchronize(*methods) - options = methods.extract_options! - unless options.is_a?(Hash) && with = options[:with] - raise ArgumentError, "Synchronization needs a mutex. Supply an options hash with a :with key as the last argument (e.g. synchronize :hello, :with => :@mutex)." - end - - methods.each do |method| - aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 - - if method_defined?("#{aliased_method}_without_synchronization#{punctuation}") - raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported." - end - - module_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block) - #{with}.synchronize do # @@lock.synchronize do - #{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block) - end # end - end # end - EOS - - alias_method_chain method, :synchronization - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb b/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb deleted file mode 100644 index 57621b94..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Add a +missing_name+ method to NameError instances. -class NameError #:nodoc: - # Add a method to obtain the missing name from a NameError. - def missing_name - if /undefined local variable or method/ !~ message - $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message - end - end - - # Was this exception raised because the given name was missing? - def missing_name?(name) - if name.is_a? Symbol - last_name = (missing_name || '').split('::').last - last_name == name.to_s - else - missing_name == name.to_s - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb deleted file mode 100644 index 759b86b8..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'active_support/core_ext/numeric/time' -require 'active_support/core_ext/numeric/bytes' -require 'active_support/core_ext/numeric/conversions' - -class Numeric #:nodoc: - include ActiveSupport::CoreExtensions::Numeric::Time - include ActiveSupport::CoreExtensions::Numeric::Bytes - include ActiveSupport::CoreExtensions::Numeric::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb deleted file mode 100644 index d3ff615e..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +++ /dev/null @@ -1,50 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Numeric #:nodoc: - # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes - module Bytes - KILOBYTE = 1024 - MEGABYTE = KILOBYTE * 1024 - GIGABYTE = MEGABYTE * 1024 - TERABYTE = GIGABYTE * 1024 - PETABYTE = TERABYTE * 1024 - EXABYTE = PETABYTE * 1024 - - def bytes - self - end - alias :byte :bytes - - def kilobytes - self * KILOBYTE - end - alias :kilobyte :kilobytes - - def megabytes - self * MEGABYTE - end - alias :megabyte :megabytes - - def gigabytes - self * GIGABYTE - end - alias :gigabyte :gigabytes - - def terabytes - self * TERABYTE - end - alias :terabyte :terabytes - - def petabytes - self * PETABYTE - end - alias :petabyte :petabytes - - def exabytes - self * EXABYTE - end - alias :exabyte :exabytes - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb deleted file mode 100644 index d9bee2b1..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Numeric #:nodoc: - module Conversions - # Assumes self represents an offset from UTC in seconds (as returned from Time#utc_offset) - # and turns this into an +HH:MM formatted string. Example: - # - # -21_600.to_utc_offset_s # => "-06:00" - def to_utc_offset_s(colon=true) - seconds = self - sign = (seconds < 0 ? '-' : '+') - hours = seconds.abs / 3600 - minutes = (seconds.abs % 3600) / 60 - "%s%02d%s%02d" % [ sign, hours, colon ? ":" : "", minutes ] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb deleted file mode 100644 index bc7f180c..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb +++ /dev/null @@ -1,81 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Numeric #:nodoc: - # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. - # - # These methods use Time#advance for precise date calculations when using from_now, ago, etc. - # as well as adding or subtracting their results from a Time object. For example: - # - # # equivalent to Time.now.advance(:months => 1) - # 1.month.from_now - # - # # equivalent to Time.now.advance(:years => 2) - # 2.years.from_now - # - # # equivalent to Time.now.advance(:months => 4, :years => 5) - # (4.months + 5.years).from_now - # - # While these methods provide precise calculation when used as in the examples above, care - # should be taken to note that this is not true if the result of `months', `years', etc is - # converted before use: - # - # # equivalent to 30.days.to_i.from_now - # 1.month.to_i.from_now - # - # # equivalent to 365.25.days.to_f.from_now - # 1.year.to_f.from_now - # - # In such cases, Ruby's core - # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and - # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision - # date and time arithmetic - module Time - def seconds - ActiveSupport::Duration.new(self, [[:seconds, self]]) - end - alias :second :seconds - - def minutes - ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]]) - end - alias :minute :minutes - - def hours - ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]]) - end - alias :hour :hours - - def days - ActiveSupport::Duration.new(self * 24.hours, [[:days, self]]) - end - alias :day :days - - def weeks - ActiveSupport::Duration.new(self * 7.days, [[:days, self * 7]]) - end - alias :week :weeks - - def fortnights - ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]]) - end - alias :fortnight :fortnights - - # Reads best without arguments: 10.minutes.ago - def ago(time = ::Time.now) - time - self - end - - # Reads best with argument: 10.minutes.until(time) - alias :until :ago - - # Reads best with argument: 10.minutes.since(time) - def since(time = ::Time.now) - time + self - end - - # Reads best without arguments: 10.minutes.from_now - alias :from_now :since - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object.rb deleted file mode 100644 index 65bc222b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'active_support/core_ext/object/blank' -require 'active_support/core_ext/object/conversions' -require 'active_support/core_ext/object/extending' -require 'active_support/core_ext/object/instance_variables' -require 'active_support/core_ext/object/metaclass' -require 'active_support/core_ext/object/singleton_class' -require 'active_support/core_ext/object/misc' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/blank.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/blank.rb deleted file mode 100644 index eb99bb1a..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/blank.rb +++ /dev/null @@ -1,76 +0,0 @@ -class Object - # An object is blank if it's false, empty, or a whitespace string. - # For example, "", " ", +nil+, [], and {} are blank. - # - # This simplifies: - # - # if !address.nil? && !address.empty? - # - # ...to: - # - # if !address.blank? - def blank? - respond_to?(:empty?) ? empty? : !self - end - - # An object is present if it's not blank. - def present? - !blank? - end - - # Returns object if it's #present? otherwise returns nil. - # object.presence is equivalent to object.present? ? object : nil. - # - # This is handy for any representation of objects where blank is the same - # as not present at all. For example, this simplifies a common check for - # HTTP POST/query parameters: - # - # state = params[:state] if params[:state].present? - # country = params[:country] if params[:country].present? - # region = state || country || 'US' - # - # ...becomes: - # - # region = params[:state].presence || params[:country].presence || 'US' - def presence - self if present? - end -end - -class NilClass #:nodoc: - def blank? - true - end -end - -class FalseClass #:nodoc: - def blank? - true - end -end - -class TrueClass #:nodoc: - def blank? - false - end -end - -class Array #:nodoc: - alias_method :blank?, :empty? -end - -class Hash #:nodoc: - alias_method :blank?, :empty? -end - -class String #:nodoc: - def blank? - self !~ /\S/ - end -end - -class Numeric #:nodoc: - def blank? - false - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb deleted file mode 100644 index 278b856c..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Object - # Alias of <tt>to_s</tt>. - def to_param - to_s - end - - # Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the - # param name. - # - # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work. - def to_query(key) - require 'cgi' unless defined?(CGI) && defined?(CGI::escape) - "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}" - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb deleted file mode 100644 index bbf6f856..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb +++ /dev/null @@ -1,80 +0,0 @@ -class Object - def remove_subclasses_of(*superclasses) #:nodoc: - Class.remove_class(*subclasses_of(*superclasses)) - end - - begin - ObjectSpace.each_object(Class.new) {} - - # Exclude this class unless it's a subclass of our supers and is defined. - # We check defined? in case we find a removed class that has yet to be - # garbage collected. This also fails for anonymous classes -- please - # submit a patch if you have a workaround. - def subclasses_of(*superclasses) #:nodoc: - subclasses = [] - - superclasses.each do |sup| - ObjectSpace.each_object(class << sup; self; end) do |k| - if k != sup && (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id")) - subclasses << k - end - end - end - - subclasses - end - rescue RuntimeError - # JRuby and any implementations which cannot handle the objectspace traversal - # above fall back to this implementation - def subclasses_of(*superclasses) #:nodoc: - subclasses = [] - - superclasses.each do |sup| - ObjectSpace.each_object(Class) do |k| - if superclasses.any? { |superclass| k < superclass } && - (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id")) - subclasses << k - end - end - subclasses.uniq! - end - subclasses - end - end - - def extended_by #:nodoc: - ancestors = class << self; ancestors end - ancestors.select { |mod| mod.class == Module } - [ Object, Kernel ] - end - - def extend_with_included_modules_from(object) #:nodoc: - object.extended_by.each { |mod| extend mod } - end - - unless defined? instance_exec # 1.9 - module InstanceExecMethods #:nodoc: - end - include InstanceExecMethods - - # Evaluate the block with the given arguments within the context of - # this object, so self is set to the method receiver. - # - # From Mauricio's http://eigenclass.org/hiki/bounded+space+instance_exec - def instance_exec(*args, &block) - begin - old_critical, Thread.critical = Thread.critical, true - n = 0 - n += 1 while respond_to?(method_name = "__instance_exec#{n}") - InstanceExecMethods.module_eval { define_method(method_name, &block) } - ensure - Thread.critical = old_critical - end - - begin - send(method_name, *args) - ensure - InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb deleted file mode 100644 index 4ecaab3b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb +++ /dev/null @@ -1,74 +0,0 @@ -class Object - # Available in 1.8.6 and later. - unless respond_to?(:instance_variable_defined?) - def instance_variable_defined?(variable) - instance_variables.include?(variable.to_s) - end - end - - # Returns a hash that maps instance variable names without "@" to their - # corresponding values. Keys are strings both in Ruby 1.8 and 1.9. - # - # class C - # def initialize(x, y) - # @x, @y = x, y - # end - # end - # - # C.new(0, 1).instance_values # => {"x" => 0, "y" => 1} - def instance_values #:nodoc: - instance_variables.inject({}) do |values, name| - values[name.to_s[1..-1]] = instance_variable_get(name) - values - end - end - - # Returns an array of instance variable names including "@". They are strings - # both in Ruby 1.8 and 1.9. - # - # class C - # def initialize(x, y) - # @x, @y = x, y - # end - # end - # - # C.new(0, 1).instance_variable_names # => ["@y", "@x"] - if RUBY_VERSION >= '1.9' - def instance_variable_names - instance_variables.map { |var| var.to_s } - end - else - alias_method :instance_variable_names, :instance_variables - end - - # Copies the instance variables of +object+ into +self+. - # - # Instance variable names in the +exclude+ array are ignored. If +object+ - # responds to <tt>protected_instance_variables</tt> the ones returned are - # also ignored. For example, Rails controllers implement that method. - # - # In both cases strings and symbols are understood, and they have to include - # the at sign. - # - # class C - # def initialize(x, y, z) - # @x, @y, @z = x, y, z - # end - # - # def protected_instance_variables - # %w(@z) - # end - # end - # - # a = C.new(0, 1, 2) - # b = C.new(3, 4, 5) - # - # a.copy_instance_variables_from(b, [:@y]) - # # a is now: @x = 3, @y = 1, @z = 2 - def copy_instance_variables_from(object, exclude = []) #:nodoc: - exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables - - vars = object.instance_variables.map(&:to_s) - exclude.map(&:to_s) - vars.each { |name| instance_variable_set(name, object.instance_variable_get(name)) } - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/metaclass.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/metaclass.rb deleted file mode 100644 index 4b36a243..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/metaclass.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'active_support/deprecation' - -class Object - # Get object's meta (ghost, eigenclass, singleton) class. - # - # Deprecated in favor of Object#singleton_class. - def metaclass - class << self - self - end - end - - deprecate :metaclass => :singleton_class -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb deleted file mode 100644 index 554f44ab..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'active_support/deprecation' - -class Object - # Returns +value+ after yielding +value+ to the block. This simplifies the - # process of constructing an object, performing work on the object, and then - # returning the object from a method. It is a Ruby-ized realization of the K - # combinator, courtesy of Mikael Brockman. - # - # ==== Examples - # - # # Without returning - # def foo - # values = [] - # values << "bar" - # values << "baz" - # return values - # end - # - # foo # => ['bar', 'baz'] - # - # # returning with a local variable - # def foo - # returning values = [] do - # values << 'bar' - # values << 'baz' - # end - # end - # - # foo # => ['bar', 'baz'] - # - # # returning with a block argument - # def foo - # returning [] do |values| - # values << 'bar' - # values << 'baz' - # end - # end - # - # foo # => ['bar', 'baz'] - def returning(value) - ActiveSupport::Deprecation.warn('Kernel#returning has been deprecated in favor of Object#tap.', caller) - yield(value) - value - end - - # Yields <code>x</code> to the block, and then returns <code>x</code>. - # The primary purpose of this method is to "tap into" a method chain, - # in order to perform operations on intermediate results within the chain. - # - # (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a. - # tap { |x| puts "array: #{x.inspect}" }. - # select { |x| x%2 == 0 }. - # tap { |x| puts "evens: #{x.inspect}" }. - # map { |x| x*x }. - # tap { |x| puts "squares: #{x.inspect}" } - def tap - yield self - self - end unless Object.respond_to?(:tap) - - # An elegant way to factor duplication out of options passed to a series of - # method calls. Each method called in the block, with the block variable as - # the receiver, will have its options merged with the default +options+ hash - # provided. Each method called on the block variable must take an options - # hash as its final argument. - # - # with_options :order => 'created_at', :class_name => 'Comment' do |post| - # post.has_many :comments, :conditions => ['approved = ?', true], :dependent => :delete_all - # post.has_many :unapproved_comments, :conditions => ['approved = ?', false] - # post.has_many :all_comments - # end - # - # Can also be used with an explicit receiver: - # - # map.with_options :controller => "people" do |people| - # people.connect "/people", :action => "index" - # people.connect "/people/:id", :action => "show" - # end - # - def with_options(options) - yield ActiveSupport::OptionMerger.new(self, options) - end - - # A duck-type assistant method. For example, Active Support extends Date - # to define an acts_like_date? method, and extends Time to define - # acts_like_time?. As a result, we can do "x.acts_like?(:time)" and - # "x.acts_like?(:date)" to do duck-type-safe comparisons, since classes that - # we want to act like Time simply need to define an acts_like_time? method. - def acts_like?(duck) - respond_to? "acts_like_#{duck}?" - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/singleton_class.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/singleton_class.rb deleted file mode 100644 index 8dee54e7..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/singleton_class.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Object - # Returns the object's singleton class. - def singleton_class - class << self - self - end - end unless respond_to?(:singleton_class) - - # class_eval on an object acts like singleton_class_eval. - def class_eval(*args, &block) - singleton_class.class_eval(*args, &block) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb b/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb deleted file mode 100644 index 4c5318ee..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'pathname' -require 'active_support/core_ext/pathname/clean_within' - -class Pathname#:nodoc: - extend ActiveSupport::CoreExtensions::Pathname::CleanWithin -end - diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb b/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb deleted file mode 100644 index ae03e1bc..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Pathname #:nodoc: - module CleanWithin - # Clean the paths contained in the provided string. - def clean_within(string) - string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path| - new(path).cleanpath - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb b/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb deleted file mode 100644 index 2ca23f62..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Proc #:nodoc: - def bind(object) - block, time = self, Time.now - (class << object; self end).class_eval do - method_name = "__bind_#{time.to_i}_#{time.usec}" - define_method(method_name, &block) - method = instance_method(method_name) - remove_method(method_name) - method - end.bind(object) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/process.rb b/vendor/rails/activesupport/lib/active_support/core_ext/process.rb deleted file mode 100644 index 0b0bc6dc..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/process.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_support/core_ext/process/daemon' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb b/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb deleted file mode 100644 index 95ad5f8a..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb +++ /dev/null @@ -1,25 +0,0 @@ -if RUBY_VERSION < "1.9" - module Process - def self.daemon(nochdir = nil, noclose = nil) - exit if fork # Parent exits, child continues. - Process.setsid # Become session leader. - exit if fork # Zap session leader. See [1]. - - unless nochdir - Dir.chdir "/" # Release old working directory. - end - - File.umask 0000 # Ensure sensible umask. Adjust as needed. - - unless noclose - STDIN.reopen "/dev/null" # Free file descriptors and - STDOUT.reopen "/dev/null", "a" # point them somewhere sensible. - STDERR.reopen '/dev/null', 'a' - end - - trap("TERM") { exit } - - return 0 - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range.rb deleted file mode 100644 index 0d2b169e..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'active_support/core_ext/range/conversions' -require 'active_support/core_ext/range/overlaps' -require 'active_support/core_ext/range/include_range' -require 'active_support/core_ext/range/blockless_step' - -class Range #:nodoc: - include ActiveSupport::CoreExtensions::Range::Conversions - include ActiveSupport::CoreExtensions::Range::Overlaps - include ActiveSupport::CoreExtensions::Range::IncludeRange - include ActiveSupport::CoreExtensions::Range::BlocklessStep -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb deleted file mode 100644 index 02d83fe5..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb +++ /dev/null @@ -1,32 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Return an array when step is called without a block. - module BlocklessStep - def self.included(base) #:nodoc: - base.alias_method_chain :step, :blockless - end - - if RUBY_VERSION < '1.9' - def step_with_blockless(value = 1, &block) - if block_given? - step_without_blockless(value, &block) - else - [].tap do |array| - step_without_blockless(value) { |step| array << step } - end - end - end - else - def step_with_blockless(value = 1, &block) - if block_given? - step_without_blockless(value, &block) - else - step_without_blockless(value).to_a - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb deleted file mode 100644 index 45b0826b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb +++ /dev/null @@ -1,27 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Getting ranges in different convenient string representations and other objects - module Conversions - RANGE_FORMATS = { - :db => Proc.new { |start, stop| "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" } - } - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - end - end - # Gives a human readable format of the range. - # - # ==== Example - # - # [1..100].to_formatted_s # => "1..100" - def to_formatted_s(format = :default) - RANGE_FORMATS[format] ? RANGE_FORMATS[format].call(first, last) : to_default_s - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb deleted file mode 100644 index 9a7d2356..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb +++ /dev/null @@ -1,30 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Check if a Range includes another Range. - module IncludeRange - def self.included(base) #:nodoc: - base.alias_method_chain :include?, :range - end - - # Extends the default Range#include? to support range comparisons. - # (1..5).include?(1..5) # => true - # (1..5).include?(2..3) # => true - # (1..5).include?(2..6) # => false - # - # The native Range#include? behavior is untouched. - # ("a".."f").include?("c") # => true - # (5..9).include?(11) # => false - def include_with_range?(value) - if value.is_a?(::Range) - operator = exclude_end? ? :< : :<= - end_value = value.exclude_end? ? last.succ : last - include?(value.first) && (value.last <=> end_value).send(operator, 0) - else - include_without_range?(value) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb deleted file mode 100644 index 43c69453..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb +++ /dev/null @@ -1,15 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Check if Ranges overlap. - module Overlaps - # Compare two ranges and see if they overlap eachother - # (1..5).overlaps?(4..6) # => true - # (1..5).overlaps?(7..9) # => false - def overlaps?(other) - include?(other.first) || other.include?(first) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb b/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb deleted file mode 100644 index b4891a91..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Fixes the rexml vulnerability disclosed at: -# http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/ -# This fix is identical to rexml-expansion-fix version 1.0.1 -require 'rexml/rexml' - -# Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION -unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2" - require 'rexml/document' - - # REXML in 1.8.7 has the patch but didn't update Version from 3.1.7.2. - unless REXML::Document.respond_to?(:entity_expansion_limit=) - require 'rexml/entity' - - module REXML - class Entity < Child - undef_method :unnormalized - def unnormalized - document.record_entity_expansion! if document - v = value() - return nil if v.nil? - @unnormalized = Text::unnormalize(v, parent) - @unnormalized - end - end - class Document < Element - @@entity_expansion_limit = 10_000 - def self.entity_expansion_limit= val - @@entity_expansion_limit = val - end - - def record_entity_expansion! - @number_of_expansions ||= 0 - @number_of_expansions += 1 - if @number_of_expansions > @@entity_expansion_limit - raise "Number of entity expansions exceeded, processing aborted." - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string.rb deleted file mode 100644 index 95aaa8e1..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +++ /dev/null @@ -1,24 +0,0 @@ -# encoding: utf-8 - -require 'active_support/core_ext/string/inflections' -require 'active_support/core_ext/string/bytesize' -require 'active_support/core_ext/string/conversions' -require 'active_support/core_ext/string/access' -require 'active_support/core_ext/string/starts_ends_with' -require 'active_support/core_ext/string/iterators' -require 'active_support/core_ext/string/multibyte' -require 'active_support/core_ext/string/xchar' -require 'active_support/core_ext/string/filters' -require 'active_support/core_ext/string/behavior' -require 'active_support/core_ext/string/output_safety' - -class String #:nodoc: - include ActiveSupport::CoreExtensions::String::Access - include ActiveSupport::CoreExtensions::String::Conversions - include ActiveSupport::CoreExtensions::String::Filters - include ActiveSupport::CoreExtensions::String::Inflections - include ActiveSupport::CoreExtensions::String::StartsEndsWith - include ActiveSupport::CoreExtensions::String::Iterators - include ActiveSupport::CoreExtensions::String::Behavior - include ActiveSupport::CoreExtensions::String::Multibyte -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb deleted file mode 100644 index e806b321..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +++ /dev/null @@ -1,106 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - unless '1.9'.respond_to?(:force_encoding) - # Makes it easier to access parts of a string, such as specific characters and substrings. - module Access - # Returns the character at the +position+ treating the string as an array (where 0 is the first character). - # - # Examples: - # "hello".at(0) # => "h" - # "hello".at(4) # => "o" - # "hello".at(10) # => nil - def at(position) - mb_chars[position, 1].to_s - end - - # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character). - # - # Examples: - # "hello".from(0) # => "hello" - # "hello".from(2) # => "llo" - # "hello".from(10) # => nil - def from(position) - mb_chars[position..-1].to_s - end - - # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character). - # - # Examples: - # "hello".to(0) # => "h" - # "hello".to(2) # => "hel" - # "hello".to(10) # => "hello" - def to(position) - mb_chars[0..position].to_s - end - - # Returns the first character of the string or the first +limit+ characters. - # - # Examples: - # "hello".first # => "h" - # "hello".first(2) # => "he" - # "hello".first(10) # => "hello" - def first(limit = 1) - if limit == 0 - '' - elsif limit >= size - self - else - mb_chars[0...limit].to_s - end - end - - # Returns the last character of the string or the last +limit+ characters. - # - # Examples: - # "hello".last # => "o" - # "hello".last(2) # => "lo" - # "hello".last(10) # => "hello" - def last(limit = 1) - if limit == 0 - '' - elsif limit >= size - self - else - mb_chars[(-limit)..-1].to_s - end - end - end - else - module Access #:nodoc: - def at(position) - self[position] - end - - def from(position) - self[position..-1] - end - - def to(position) - self[0..position] - end - - def first(limit = 1) - if limit == 0 - '' - elsif limit >= size - self - else - to(limit - 1) - end - end - - def last(limit = 1) - if limit == 0 - '' - elsif limit >= size - self - else - from(-limit) - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/behavior.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/behavior.rb deleted file mode 100644 index a93ca302..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/behavior.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - module Behavior - # Enable more predictable duck-typing on String-like classes. See - # Object#acts_like?. - def acts_like_string? - true - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb deleted file mode 100644 index ed051b92..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb +++ /dev/null @@ -1,5 +0,0 @@ -unless '1.9'.respond_to?(:bytesize) - class String - alias :bytesize :size - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb deleted file mode 100644 index d4334dce..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'date' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Converting strings to other objects - module Conversions - # 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility. - def ord - self[0] - end if RUBY_VERSION < '1.9' - - # Form can be either :utc (default) or :local. - def to_time(form = :utc) - ::Time.send("#{form}_time", *::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 }) - end - - def to_date - ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday)) - end - - def to_datetime - ::DateTime.civil(*::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 }) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb deleted file mode 100644 index 0329fbb8..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb +++ /dev/null @@ -1,26 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - module Filters - # Returns the string, first removing all whitespace on both ends of - # the string, and then changing remaining consecutive whitespace - # groups into one space each. - # - # Examples: - # %{ Multi-line - # string }.squish # => "Multi-line string" - # " foo bar \n \t boo".squish # => "foo bar boo" - def squish - dup.squish! - end - - # Performs a destructive squish. See String#squish. - def squish! - strip! - gsub!(/\s+/, ' ') - self - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb deleted file mode 100644 index 48e812aa..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb +++ /dev/null @@ -1,167 +0,0 @@ -require 'active_support/inflector' unless defined?(ActiveSupport::Inflector) - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # String inflections define new methods on the String class to transform names for different purposes. - # For instance, you can figure out the name of a database from the name of a class. - # - # "ScaleScore".tableize # => "scale_scores" - module Inflections - # Returns the plural form of the word in the string. - # - # "post".pluralize # => "posts" - # "octopus".pluralize # => "octopi" - # "sheep".pluralize # => "sheep" - # "words".pluralize # => "words" - # "the blue mailman".pluralize # => "the blue mailmen" - # "CamelOctopus".pluralize # => "CamelOctopi" - def pluralize - Inflector.pluralize(self) - end - - # The reverse of +pluralize+, returns the singular form of a word in a string. - # - # "posts".singularize # => "post" - # "octopi".singularize # => "octopus" - # "sheep".singularize # => "sheep" - # "word".singularize # => "word" - # "the blue mailmen".singularize # => "the blue mailman" - # "CamelOctopi".singularize # => "CamelOctopus" - def singularize - Inflector.singularize(self) - end - - # By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize - # is set to <tt>:lower</tt> then camelize produces lowerCamelCase. - # - # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces. - # - # "active_record".camelize # => "ActiveRecord" - # "active_record".camelize(:lower) # => "activeRecord" - # "active_record/errors".camelize # => "ActiveRecord::Errors" - # "active_record/errors".camelize(:lower) # => "activeRecord::Errors" - def camelize(first_letter = :upper) - case first_letter - when :upper then Inflector.camelize(self, true) - when :lower then Inflector.camelize(self, false) - end - end - alias_method :camelcase, :camelize - - # Capitalizes all the words and replaces some characters in the string to create - # a nicer looking title. +titleize+ is meant for creating pretty output. It is not - # used in the Rails internals. - # - # +titleize+ is also aliased as +titlecase+. - # - # "man from the boondocks".titleize # => "Man From The Boondocks" - # "x-men: the last stand".titleize # => "X Men: The Last Stand" - def titleize - Inflector.titleize(self) - end - alias_method :titlecase, :titleize - - # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string. - # - # +underscore+ will also change '::' to '/' to convert namespaces to paths. - # - # "ActiveRecord".underscore # => "active_record" - # "ActiveRecord::Errors".underscore # => active_record/errors - def underscore - Inflector.underscore(self) - end - - # Replaces underscores with dashes in the string. - # - # "puni_puni" # => "puni-puni" - def dasherize - Inflector.dasherize(self) - end - - # Removes the module part from the constant expression in the string. - # - # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections" - # "Inflections".demodulize # => "Inflections" - def demodulize - Inflector.demodulize(self) - end - - # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. - # - # ==== Examples - # - # class Person - # def to_param - # "#{id}-#{name.parameterize}" - # end - # end - # - # @person = Person.find(1) - # # => #<Person id: 1, name: "Donald E. Knuth"> - # - # <%= link_to(@person.name, person_path %> - # # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a> - def parameterize(sep = '-') - Inflector.parameterize(self, sep) - end - - # Creates the name of a table like Rails does for models to table names. This method - # uses the +pluralize+ method on the last word in the string. - # - # "RawScaledScorer".tableize # => "raw_scaled_scorers" - # "egg_and_ham".tableize # => "egg_and_hams" - # "fancyCategory".tableize # => "fancy_categories" - def tableize - Inflector.tableize(self) - end - - # Create a class name from a plural table name like Rails does for table names to models. - # Note that this returns a string and not a class. (To convert to an actual class - # follow +classify+ with +constantize+.) - # - # "egg_and_hams".classify # => "EggAndHam" - # "posts".classify # => "Post" - # - # Singular names are not handled correctly. - # - # "business".classify # => "Busines" - def classify - Inflector.classify(self) - end - - # Capitalizes the first word, turns underscores into spaces, and strips '_id'. - # Like +titleize+, this is meant for creating pretty output. - # - # "employee_salary" # => "Employee salary" - # "author_id" # => "Author" - def humanize - Inflector.humanize(self) - end - - # Creates a foreign key name from a class name. - # +separate_class_name_and_id_with_underscore+ sets whether - # the method should put '_' between the name and 'id'. - # - # Examples - # "Message".foreign_key # => "message_id" - # "Message".foreign_key(false) # => "messageid" - # "Admin::Post".foreign_key # => "post_id" - def foreign_key(separate_class_name_and_id_with_underscore = true) - Inflector.foreign_key(self, separate_class_name_and_id_with_underscore) - end - - # +constantize+ tries to find a declared constant with the name specified - # in the string. It raises a NameError when the name is not in CamelCase - # or is not initialized. - # - # Examples - # "Module".constantize # => Module - # "Class".constantize # => Class - def constantize - Inflector.constantize(self) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb deleted file mode 100644 index fe17d140..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'strscan' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Custom string iterators - module Iterators - def self.append_features(base) - super unless '1.9'.respond_to?(:each_char) - end - - # Yields a single-character string for each character in the string. - # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately. - def each_char - scanner, char = StringScanner.new(self), /./mu - while c = scanner.scan(char) - yield c - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/multibyte.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/multibyte.rb deleted file mode 100644 index a4caa83b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ /dev/null @@ -1,81 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Implements multibyte methods for easier access to multibyte characters in a String instance. - module Multibyte - unless '1.9'.respond_to?(:force_encoding) - # == Multibyte proxy - # - # +mb_chars+ is a multibyte safe proxy for string methods. - # - # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which - # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy - # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string. - # - # name = 'Claus Müller' - # name.reverse #=> "rell??M sualC" - # name.length #=> 13 - # - # name.mb_chars.reverse.to_s #=> "rellüM sualC" - # name.mb_chars.length #=> 12 - # - # In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that - # it becomes easy to run one version of your code on multiple Ruby versions. - # - # == Method chaining - # - # All the methods on the Chars proxy which normally return a string will return a Chars object. This allows - # method chaining on the result of any of these methods. - # - # name.mb_chars.reverse.length #=> 12 - # - # == Interoperability and configuration - # - # The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between - # String and Char work like expected. The bang! methods change the internal string representation in the Chars - # object. Interoperability problems can be resolved easily with a +to_s+ call. - # - # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For - # information about how to change the default Multibyte behaviour see ActiveSupport::Multibyte. - def mb_chars - if ActiveSupport::Multibyte.proxy_class.wants?(self) - ActiveSupport::Multibyte.proxy_class.new(self) - else - self - end - end - - # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have - # them), returns false otherwise. - def is_utf8? - ActiveSupport::Multibyte::Chars.consumes?(self) - end - - unless '1.8.7 and later'.respond_to?(:chars) - def chars - ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller) - mb_chars - end - end - else - def mb_chars #:nodoc - self - end - - def is_utf8? #:nodoc - case encoding - when Encoding::UTF_8 - valid_encoding? - when Encoding::ASCII_8BIT, Encoding::US_ASCII - dup.force_encoding(Encoding::UTF_8).valid_encoding? - else - false - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb deleted file mode 100644 index 8e68ab0b..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'erb' - -class ERB - module Util - HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' } - JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' } - - # A utility method for escaping HTML tag characters. - # This method is also aliased as <tt>h</tt>. - # - # In your ERb templates, use this method to escape any unsafe content. For example: - # <%=h @person.name %> - # - # ==== Example: - # puts html_escape("is a > 0 & a < 10?") - # # => is a &gt; 0 &amp; a &lt; 10? - def html_escape(s) - s = s.to_s - if s.html_safe? - s - else - s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;").html_safe - end - end - - undef :h - alias h html_escape - - module_function :html_escape - module_function :h - - # A utility method for escaping HTML entities in JSON strings. - # This method is also aliased as <tt>j</tt>. - # - # In your ERb templates, use this method to escape any HTML entities: - # <%=j @person.to_json %> - # - # ==== Example: - # puts json_escape("is a > 0 & a < 10?") - # # => is a \u003E 0 \u0026 a \u003C 10? - def json_escape(s) - s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] } - end - - alias j json_escape - module_function :j - module_function :json_escape - end -end - -class Object - def html_safe? - false - end -end - -class Fixnum - def html_safe? - true - end -end - -module ActiveSupport #:nodoc: - class SafeBuffer < String - def +(other) - dup.concat(other) - end - - def html_safe? - true - end - - def html_safe - self - end - - def to_s - self - end - - def to_yaml(*args) - to_str.to_yaml(*args) - end - end -end - -class String - alias safe_concat concat - - def as_str - self - end - - def html_safe - ActiveSupport::SafeBuffer.new(self) - end - - def html_safe? - false - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb deleted file mode 100644 index 56701fd8..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +++ /dev/null @@ -1,33 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Additional string tests. - module StartsEndsWith - def self.append_features(base) - if '1.8.7 and up'.respond_to?(:start_with?) - base.class_eval do - alias_method :starts_with?, :start_with? - alias_method :ends_with?, :end_with? - end - else - super - base.class_eval do - alias_method :start_with?, :starts_with? - alias_method :end_with?, :ends_with? - end - end - end - - # Does the string start with the specified +prefix+? - def starts_with?(prefix) - prefix.respond_to?(:to_str) && self[0, prefix.length] == prefix - end - - # Does the string end with the specified +suffix+? - def ends_with?(suffix) - suffix.respond_to?(:to_str) && self[-suffix.length, suffix.length] == suffix - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb deleted file mode 100644 index df186e42..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb +++ /dev/null @@ -1,11 +0,0 @@ -begin - # See http://bogomips.org/fast_xs/ by Eric Wong - require 'fast_xs' - - class String - alias_method :original_xs, :to_xs if method_defined?(:to_xs) - alias_method :to_xs, :fast_xs - end -rescue LoadError - # fast_xs extension unavailable. -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb b/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb deleted file mode 100644 index e4ac4438..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb +++ /dev/null @@ -1,14 +0,0 @@ -unless :to_proc.respond_to?(:to_proc) - class Symbol - # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples: - # - # # The same as people.collect { |p| p.name } - # people.collect(&:name) - # - # # The same as people.select { |p| p.manager? }.collect { |p| p.salary } - # people.select(&:manager?).collect(&:salary) - def to_proc - Proc.new { |*args| args.shift.__send__(self, *args) } - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time.rb deleted file mode 100644 index 61e48945..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'date' -require 'time' - -class Time - # Ruby 1.8-cvs and 1.9 define private Time#to_date - %w(to_date to_datetime).each do |method| - public method if private_instance_methods.include?(method) - end - - # Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are - # unmarshaled in the local zone, instead of utc. We're layering behavior on the _dump and _load - # methods so that utc instances can be flagged on dump, and coerced back to utc on load. - if RUBY_VERSION < '1.9' - class << self - alias_method :_original_load, :_load - def _load(marshaled_time) - time = _original_load(marshaled_time) - time.instance_eval do - if defined?(@marshal_with_utc_coercion) - val = remove_instance_variable("@marshal_with_utc_coercion") - end - val ? utc : self - end - end - end - - alias_method :_original_dump, :_dump - def _dump(*args) - obj = dup - obj.instance_variable_set('@marshal_with_utc_coercion', utc?) - obj._original_dump(*args) - end - end -end - -require 'active_support/core_ext/time/behavior' -require 'active_support/core_ext/time/calculations' -require 'active_support/core_ext/time/conversions' -require 'active_support/core_ext/time/zones' - -class Time#:nodoc: - include ActiveSupport::CoreExtensions::Time::Behavior - include ActiveSupport::CoreExtensions::Time::Calculations - include ActiveSupport::CoreExtensions::Time::Conversions - include ActiveSupport::CoreExtensions::Time::Zones -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb deleted file mode 100644 index a5c0baac..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - module Behavior - # Enable more predictable duck-typing on Time-like classes. See - # Object#acts_like?. - def acts_like_time? - true - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb deleted file mode 100644 index a673b558..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +++ /dev/null @@ -1,313 +0,0 @@ -require 'active_support/duration' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - # Enables the use of time calculations within Time itself - module Calculations - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.class_eval do - alias_method :plus_without_duration, :+ - alias_method :+, :plus_with_duration - - alias_method :minus_without_duration, :- - alias_method :-, :minus_with_duration - - alias_method :minus_without_coercion, :- - alias_method :-, :minus_with_coercion - - alias_method :compare_without_coercion, :<=> - alias_method :<=>, :compare_with_coercion - end - end - - COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] - - module ClassMethods - # Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances - def ===(other) - other.is_a?(::Time) - end - - # Return the number of days in the given month. - # If no year is specified, it will use the current year. - def days_in_month(month, year = now.year) - return 29 if month == 2 && ::Date.gregorian_leap?(year) - COMMON_YEAR_DAYS_IN_MONTH[month] - end - - # Returns a new Time if requested year can be accommodated by Ruby's Time class - # (i.e., if year is within either 1970..2038 or 1902..2038, depending on system architecture); - # otherwise returns a DateTime - def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0) - ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec) - rescue - offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0 - ::DateTime.civil(year, month, day, hour, min, sec, offset) - end - - # Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:utc</tt>. - def utc_time(*args) - time_with_datetime_fallback(:utc, *args) - end - - # Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:local</tt>. - def local_time(*args) - time_with_datetime_fallback(:local, *args) - end - end - - # Tells whether the Time object's time lies in the past - def past? - self < ::Time.current - end - - # Tells whether the Time object's time is today - def today? - self.to_date == ::Date.current - end - - # Tells whether the Time object's time lies in the future - def future? - self > ::Time.current - end - - # Seconds since midnight: Time.now.seconds_since_midnight - def seconds_since_midnight - self.to_i - self.change(:hour => 0).to_i + (self.usec/1.0e+6) - end - - # Returns a new Time where one or more of the elements have been changed according to the +options+ parameter. The time options - # (hour, minute, sec, usec) reset cascadingly, so if only the hour is passed, then minute, sec, and usec is set to 0. If the hour and - # minute is passed, then sec and usec is set to 0. - def change(options) - ::Time.send( - self.utc? ? :utc_time : :local_time, - options[:year] || self.year, - options[:month] || self.month, - options[:day] || self.day, - options[:hour] || self.hour, - options[:min] || (options[:hour] ? 0 : self.min), - options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec), - options[:usec] || ((options[:hour] || options[:min] || options[:sec]) ? 0 : self.usec) - ) - end - - # Uses Date to provide precise Time calculations for years, months, and days. - # The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>, - # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>, - # <tt>:minutes</tt>, <tt>:seconds</tt>. - def advance(options) - unless options[:weeks].nil? - options[:weeks], partial_weeks = options[:weeks].divmod(1) - options[:days] = (options[:days] || 0) + 7 * partial_weeks - end - - unless options[:days].nil? - options[:days], partial_days = options[:days].divmod(1) - options[:hours] = (options[:hours] || 0) + 24 * partial_days - end - - d = to_date.advance(options) - time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day) - seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600 - seconds_to_advance == 0 ? time_advanced_by_date : time_advanced_by_date.since(seconds_to_advance) - end - - # Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension - def ago(seconds) - self.since(-seconds) - end - - # Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around - # the Numeric extension. - def since(seconds) - f = seconds.since(self) - if ActiveSupport::Duration === seconds - f - else - initial_dst = self.dst? ? 1 : 0 - final_dst = f.dst? ? 1 : 0 - (seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f - end - rescue - self.to_datetime.since(seconds) - end - alias :in :since - - # Returns a new Time representing the time a number of specified months ago - def months_ago(months) - advance(:months => -months) - end - - # Returns a new Time representing the time a number of specified months in the future - def months_since(months) - advance(:months => months) - end - - # Returns a new Time representing the time a number of specified years ago - def years_ago(years) - advance(:years => -years) - end - - # Returns a new Time representing the time a number of specified years in the future - def years_since(years) - advance(:years => years) - end - - def last_year # :nodoc: - ActiveSupport::Deprecation.warn("Time#last_year is deprecated and has been removed in Rails 3, please use Time#prev_year instead", caller) - prev_year - end - - # Short-hand for years_ago(1) - def prev_year - years_ago(1) - end - - # Short-hand for years_since(1) - def next_year - years_since(1) - end - - def last_month # :nodoc: - ActiveSupport::Deprecation.warn("Time#last_month is deprecated and has been removed in Rails 3, please use Time#prev_month instead", caller) - prev_month - end - - # Short-hand for months_ago(1) - def prev_month - months_ago(1) - end - - # Short-hand for months_since(1) - def next_month - months_since(1) - end - - # Returns a new Time representing the "start" of this week (Monday, 0:00) - def beginning_of_week - days_to_monday = self.wday!=0 ? self.wday-1 : 6 - (self - days_to_monday.days).midnight - end - alias :monday :beginning_of_week - alias :at_beginning_of_week :beginning_of_week - - # Returns a new Time representing the end of this week (Sunday, 23:59:59) - def end_of_week - days_to_sunday = self.wday!=0 ? 7-self.wday : 0 - (self + days_to_sunday.days).end_of_day - end - alias :at_end_of_week :end_of_week - - # Returns a new Time representing the start of the given day in next week (default is Monday). - def next_week(day = :monday) - days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6} - since(1.week).beginning_of_week.since(days_into_week[day].day).change(:hour => 0) - end - - # Returns a new Time representing the start of the day (0:00) - def beginning_of_day - #(self - seconds_since_midnight).change(:usec => 0) - change(:hour => 0, :min => 0, :sec => 0, :usec => 0) - end - alias :midnight :beginning_of_day - alias :at_midnight :beginning_of_day - alias :at_beginning_of_day :beginning_of_day - - # Returns a new Time representing the end of the day, 23:59:59.999999 (.999999999 in ruby1.9) - def end_of_day - change(:hour => 23, :min => 59, :sec => 59, :usec => 999999.999) - end - - # Returns a new Time representing the start of the month (1st of the month, 0:00) - def beginning_of_month - #self - ((self.mday-1).days + self.seconds_since_midnight) - change(:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0) - end - alias :at_beginning_of_month :beginning_of_month - - # Returns a new Time representing the end of the month (end of the last day of the month) - def end_of_month - #self - ((self.mday-1).days + self.seconds_since_midnight) - last_day = ::Time.days_in_month( self.month, self.year ) - change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 999999.999) - end - alias :at_end_of_month :end_of_month - - # Returns a new Time representing the start of the quarter (1st of january, april, july, october, 0:00) - def beginning_of_quarter - beginning_of_month.change(:month => [10, 7, 4, 1].detect { |m| m <= self.month }) - end - alias :at_beginning_of_quarter :beginning_of_quarter - - # Returns a new Time representing the end of the quarter (end of the last day of march, june, september, december) - def end_of_quarter - beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month - end - alias :at_end_of_quarter :end_of_quarter - - # Returns a new Time representing the start of the year (1st of january, 0:00) - def beginning_of_year - change(:month => 1,:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0) - end - alias :at_beginning_of_year :beginning_of_year - - # Returns a new Time representing the end of the year (end of the 31st of december) - def end_of_year - change(:month => 12, :day => 31, :hour => 23, :min => 59, :sec => 59, :usec => 999999.999) - end - alias :at_end_of_year :end_of_year - - # Convenience method which returns a new Time representing the time 1 day ago - def yesterday - advance(:days => -1) - end - - # Convenience method which returns a new Time representing the time 1 day since the instance time - def tomorrow - advance(:days => 1) - end - - def plus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - other.since(self) - else - plus_without_duration(other) - end - end - - def minus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - other.until(self) - else - minus_without_duration(other) - end - end - - # Time#- can also be used to determine the number of seconds between two Time instances. - # We're layering on additional behavior so that ActiveSupport::TimeWithZone instances - # are coerced into values that Time#- will recognize - def minus_with_coercion(other) - other = other.comparable_time if other.respond_to?(:comparable_time) - other.is_a?(::DateTime) ? to_f - other.to_f : minus_without_coercion(other) - end - - # Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances - # can be chronologically compared with a Time - def compare_with_coercion(other) - # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do <=> comparison - other = other.comparable_time if other.respond_to?(:comparable_time) - if other.acts_like?(:date) - # other is a Date/DateTime, so coerce self #to_datetime and hand off to DateTime#<=> - to_datetime.compare_without_coercion(other) - else - compare_without_coercion(other) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb deleted file mode 100644 index e6f91346..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb +++ /dev/null @@ -1,90 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - # Converting times to formatted strings, dates, and datetimes. - module Conversions - DATE_FORMATS = { - :db => "%Y-%m-%d %H:%M:%S", - :number => "%Y%m%d%H%M%S", - :time => "%H:%M", - :short => "%d %b %H:%M", - :long => "%B %d, %Y %H:%M", - :long_ordinal => lambda { |time| time.strftime("%B #{time.day.ordinalize}, %Y %H:%M") }, - :rfc822 => lambda { |time| time.strftime("%a, %d %b %Y %H:%M:%S #{time.formatted_offset(false)}") } - } - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - end - end - - # Converts to a formatted string. See DATE_FORMATS for builtin formats. - # - # This method is aliased to <tt>to_s</tt>. - # - # time = Time.now # => Thu Jan 18 06:10:17 CST 2007 - # - # time.to_formatted_s(:time) # => "06:10:17" - # time.to_s(:time) # => "06:10:17" - # - # time.to_formatted_s(:db) # => "2007-01-18 06:10:17" - # time.to_formatted_s(:number) # => "20070118061017" - # time.to_formatted_s(:short) # => "18 Jan 06:10" - # time.to_formatted_s(:long) # => "January 18, 2007 06:10" - # time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10" - # time.to_formatted_s(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600" - # - # == Adding your own time formats to +to_formatted_s+ - # You can add your own formats to the Time::DATE_FORMATS hash. - # Use the format name as the hash key and either a strftime string - # or Proc instance that takes a time argument as the value. - # - # # config/initializers/time_formats.rb - # Time::DATE_FORMATS[:month_and_year] = "%B %Y" - # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } - def to_formatted_s(format = :default) - return to_default_s unless formatter = DATE_FORMATS[format] - formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) - end - - # Returns the UTC offset as an +HH:MM formatted string. - # - # Time.local(2000).formatted_offset # => "-06:00" - # Time.local(2000).formatted_offset(false) # => "-0600" - def formatted_offset(colon = true, alternate_utc_string = nil) - utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Converts a Time object to a Date, dropping hour, minute, and second precision. - # - # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007 - # my_time.to_date # => Mon, 12 Nov 2007 - # - # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009 - # your_time.to_date # => Tue, 13 Jan 2009 - def to_date - ::Date.new(year, month, day) - end - - # A method to keep Time, Date and DateTime instances interchangeable on conversions. - # In this case, it simply returns +self+. - def to_time - self - end - - # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset. - # - # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007 - # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500 - # - # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009 - # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500 - def to_datetime - ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400)) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb deleted file mode 100644 index 9d8eb739..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb +++ /dev/null @@ -1,86 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - module Zones - def self.included(base) #:nodoc: - base.extend(ClassMethods) if base == ::Time # i.e., don't include class methods in DateTime - end - - module ClassMethods - attr_accessor :zone_default - - # Returns the TimeZone for the current request, if this has been set (via Time.zone=). - # If <tt>Time.zone</tt> has not been set for the current request, returns the TimeZone specified in <tt>config.time_zone</tt>. - def zone - Thread.current[:time_zone] || zone_default - end - - # Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread. - # - # This method accepts any of the following: - # - # * A Rails TimeZone object. - # * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>). - # * A TZInfo::Timezone object. - # * An identifier for a TZInfo::Timezone object (e.g., "America/New_York"). - # - # Here's an example of how you might set <tt>Time.zone</tt> on a per request basis -- <tt>current_user.time_zone</tt> - # just needs to return a string identifying the user's preferred TimeZone: - # - # class ApplicationController < ActionController::Base - # before_filter :set_time_zone - # - # def set_time_zone - # Time.zone = current_user.time_zone - # end - # end - def zone=(time_zone) - Thread.current[:time_zone] = get_zone(time_zone) - end - - # Allows override of <tt>Time.zone</tt> locally inside supplied block; resets <tt>Time.zone</tt> to existing value when done. - def use_zone(time_zone) - old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone) - yield - ensure - ::Time.zone = old_zone - end - - # Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>. - def current - ::Time.zone_default ? ::Time.zone.now : ::Time.now - end - - private - def get_zone(time_zone) - return time_zone if time_zone.nil? || time_zone.is_a?(TimeZone) - # lookup timezone based on identifier (unless we've been passed a TZInfo::Timezone) - unless time_zone.respond_to?(:period_for_local) - time_zone = TimeZone[time_zone] || TZInfo::Timezone.get(time_zone) rescue nil - end - # Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone - if time_zone - time_zone.is_a?(TimeZone) ? time_zone : TimeZone.create(time_zone.name, nil, time_zone) - end - end - end - - # Returns the simultaneous time in <tt>Time.zone</tt>. - # - # Time.zone = 'Hawaii' # => 'Hawaii' - # Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - # - # This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone - # instead of the operating system's time zone. - # - # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument, - # and the conversion will be based on that zone instead of <tt>Time.zone</tt>. - # - # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00 - def in_time_zone(zone = ::Time.zone) - ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.__send__(:get_zone, zone)) - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/try.rb b/vendor/rails/activesupport/lib/active_support/core_ext/try.rb deleted file mode 100644 index 3de198d1..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/try.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Object - # Invokes the method identified by the symbol +method+, passing it any arguments - # and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does. - # - # *Unlike* that method however, a +NoMethodError+ exception will *not* be raised - # and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass. - # - # ==== Examples - # - # Without try - # @person && @person.name - # or - # @person ? @person.name : nil - # - # With try - # @person.try(:name) - # - # +try+ also accepts arguments and/or a block, for the method it is trying - # Person.try(:find, 1) - # @people.try(:collect) {|p| p.name} - #-- - # This method definition below is for rdoc purposes only. The alias_method call - # below overrides it as an optimization since +try+ behaves like +Object#send+, - # unless called on +NilClass+. - def try(method, *args, &block) - send(method, *args, &block) - end - remove_method :try - alias_method :try, :__send__ -end - -class NilClass - def try(*args) - nil - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/uri.rb b/vendor/rails/activesupport/lib/active_support/core_ext/uri.rb deleted file mode 100644 index 9a1c61d9..00000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/uri.rb +++ /dev/null @@ -1,16 +0,0 @@ -if RUBY_VERSION >= '1.9' - require 'uri' - - str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese. - str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding) - - unless str == URI.unescape(URI.escape(str)) - URI::Parser.class_eval do - remove_method :unescape - def unescape(str, escaped = @regexp[:ESCAPED]) - enc = (str.encoding == Encoding::US_ASCII) ? Encoding::UTF_8 : str.encoding - str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(enc) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/dependencies.rb b/vendor/rails/activesupport/lib/active_support/dependencies.rb deleted file mode 100644 index ffb1f231..00000000 --- a/vendor/rails/activesupport/lib/active_support/dependencies.rb +++ /dev/null @@ -1,651 +0,0 @@ -require 'thread' - -module ActiveSupport #:nodoc: - module Dependencies #:nodoc: - extend self - - # Should we turn on Ruby warnings on the first load of dependent files? - mattr_accessor :warnings_on_first_load - self.warnings_on_first_load = false - - # All files ever loaded. - mattr_accessor :history - self.history = Set.new - - # All files currently loaded. - mattr_accessor :loaded - self.loaded = Set.new - - # Should we load files or require them? - mattr_accessor :mechanism - self.mechanism = :load - - # The set of directories from which we may automatically load files. Files - # under these directories will be reloaded on each request in development mode, - # unless the directory also appears in autoload_once_paths. - mattr_accessor :autoload_paths - self.autoload_paths = [] - - # Deprecated, use autoload_paths. - def self.load_paths - ActiveSupport::Deprecation.warn("ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead", caller) - autoload_paths - end - - # Deprecated, use autoload_paths=. - def self.load_paths=(paths) - ActiveSupport::Deprecation.warn("ActiveSupport::Dependencies.load_paths= is deprecated, please use autoload_paths= instead", caller) - self.autoload_paths = paths - end - - # The set of directories from which automatically loaded constants are loaded - # only once. All directories in this set must also be present in +autoload_paths+. - mattr_accessor :autoload_once_paths - self.autoload_once_paths = [] - - # Deprecated, use autoload_once_paths. - def self.load_once_paths - ActiveSupport::Deprecation.warn("ActiveSupport::Dependencies.load_once_paths is deprecated and removed in Rails 3, please use autoload_once_paths instead", caller) - autoload_once_paths - end - - # Deprecated, use autoload_once_paths=. - def self.load_once_paths=(paths) - ActiveSupport::Deprecation.warn("ActiveSupport::Dependencies.load_once_paths= is deprecated and removed in Rails 3, please use autoload_once_paths= instead", caller) - self.autoload_once_paths = paths - end - - # An array of qualified constant names that have been loaded. Adding a name to - # this array will cause it to be unloaded the next time Dependencies are cleared. - mattr_accessor :autoloaded_constants - self.autoloaded_constants = [] - - # An array of constant names that need to be unloaded on every request. Used - # to allow arbitrary constants to be marked for unloading. - mattr_accessor :explicitly_unloadable_constants - self.explicitly_unloadable_constants = [] - - # The logger is used for generating information on the action run-time (including benchmarking) if available. - # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers. - mattr_accessor :logger - - # Set to true to enable logging of const_missing and file loads - mattr_accessor :log_activity - self.log_activity = false - - # An internal stack used to record which constants are loaded by any block. - mattr_accessor :constant_watch_stack - self.constant_watch_stack = [] - - mattr_accessor :constant_watch_stack_mutex - self.constant_watch_stack_mutex = Mutex.new - - # Module includes this module - module ModuleConstMissing #:nodoc: - def self.included(base) #:nodoc: - base.class_eval do - unless defined? const_missing_without_dependencies - alias_method_chain :const_missing, :dependencies - end - end - end - - def self.excluded(base) #:nodoc: - base.class_eval do - if defined? const_missing_without_dependencies - undef_method :const_missing - alias_method :const_missing, :const_missing_without_dependencies - undef_method :const_missing_without_dependencies - end - end - end - - # Use const_missing to autoload associations so we don't have to - # require_association when using single-table inheritance. - def const_missing_with_dependencies(class_id) - ActiveSupport::Dependencies.load_missing_constant self, class_id - end - - def unloadable(const_desc = self) - super(const_desc) - end - end - - # Class includes this module - module ClassConstMissing #:nodoc: - def const_missing(const_name) - if [Object, Kernel].include?(self) || parent == self - super - else - begin - begin - Dependencies.load_missing_constant self, const_name - rescue NameError - parent.send :const_missing, const_name - end - rescue NameError => e - # Make sure that the name we are missing is the one that caused the error - parent_qualified_name = Dependencies.qualified_name_for parent, const_name - raise unless e.missing_name? parent_qualified_name - qualified_name = Dependencies.qualified_name_for self, const_name - raise NameError.new("uninitialized constant #{qualified_name}").copy_blame!(e) - end - end - end - end - - # Object includes this module - module Loadable #:nodoc: - def self.included(base) #:nodoc: - base.class_eval do - unless defined? load_without_new_constant_marking - alias_method_chain :load, :new_constant_marking - end - end - end - - def self.excluded(base) #:nodoc: - base.class_eval do - if defined? load_without_new_constant_marking - undef_method :load - alias_method :load, :load_without_new_constant_marking - undef_method :load_without_new_constant_marking - end - end - end - - def require_or_load(file_name) - Dependencies.require_or_load(file_name) - end - - def require_dependency(file_name) - Dependencies.depend_on(file_name) - end - - def require_association(file_name) - Dependencies.associate_with(file_name) - end - - def load_with_new_constant_marking(file, *extras) #:nodoc: - if Dependencies.load? - Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) } - else - load_without_new_constant_marking(file, *extras) - end - rescue Exception => exception # errors from loading file - exception.blame_file! file - raise - end - - def require(file, *extras) #:nodoc: - if Dependencies.load? - Dependencies.new_constants_in(Object) { super } - else - super - end - rescue Exception => exception # errors from required file - exception.blame_file! file - raise - end - - # Mark the given constant as unloadable. Unloadable constants are removed each - # time dependencies are cleared. - # - # Note that marking a constant for unloading need only be done once. Setup - # or init scripts may list each unloadable constant that may need unloading; - # each constant will be removed for every subsequent clear, as opposed to for - # the first clear. - # - # The provided constant descriptor may be a (non-anonymous) module or class, - # or a qualified constant name as a string or symbol. - # - # Returns true if the constant was not previously marked for unloading, false - # otherwise. - def unloadable(const_desc) - Dependencies.mark_for_unload const_desc - end - end - - # Exception file-blaming - module Blamable #:nodoc: - def blame_file!(file) - (@blamed_files ||= []).unshift file - end - - def blamed_files - @blamed_files ||= [] - end - - def describe_blame - return nil if blamed_files.empty? - "This error occurred while loading the following files:\n #{blamed_files.join "\n "}" - end - - def copy_blame!(exc) - @blamed_files = exc.blamed_files.clone - self - end - end - - def hook! - Object.instance_eval { include Loadable } - Module.instance_eval { include ModuleConstMissing } - Class.instance_eval { include ClassConstMissing } - Exception.instance_eval { include Blamable } - true - end - - def unhook! - ModuleConstMissing.excluded(Module) - Loadable.excluded(Object) - true - end - - def load? - mechanism == :load - end - - def depend_on(file_name, swallow_load_errors = false) - path = search_for_file(file_name) - require_or_load(path || file_name) - rescue LoadError - raise unless swallow_load_errors - end - - def associate_with(file_name) - depend_on(file_name, true) - end - - def clear - log_call - loaded.clear - remove_unloadable_constants! - end - - def require_or_load(file_name, const_path = nil) - log_call file_name, const_path - file_name = $1 if file_name =~ /^(.*)\.rb$/ - expanded = File.expand_path(file_name) - return if loaded.include?(expanded) - - # Record that we've seen this file *before* loading it to avoid an - # infinite loop with mutual dependencies. - loaded << expanded - - begin - if load? - log "loading #{file_name}" - - # Enable warnings iff this file has not been loaded before and - # warnings_on_first_load is set. - load_args = ["#{file_name}.rb"] - load_args << const_path unless const_path.nil? - - if !warnings_on_first_load or history.include?(expanded) - result = load_file(*load_args) - else - enable_warnings { result = load_file(*load_args) } - end - else - log "requiring #{file_name}" - result = require file_name - end - rescue Exception - loaded.delete expanded - raise - end - - # Record history *after* loading so first load gets warnings. - history << expanded - return result - end - - # Is the provided constant path defined? - def qualified_const_defined?(path) - raise NameError, "#{path.inspect} is not a valid constant name!" unless - /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path - - names = path.to_s.split('::') - names.shift if names.first.empty? - - # We can't use defined? because it will invoke const_missing for the parent - # of the name we are checking. - names.inject(Object) do |mod, name| - return false unless uninherited_const_defined?(mod, name) - mod.const_get name - end - return true - end - - if Module.method(:const_defined?).arity == 1 - # Does this module define this constant? - # Wrapper to accomodate changing Module#const_defined? in Ruby 1.9 - def uninherited_const_defined?(mod, const) - mod.const_defined?(const) - end - else - def uninherited_const_defined?(mod, const) #:nodoc: - mod.const_defined?(const, false) - end - end - - # Given +path+, a filesystem path to a ruby file, return an array of constant - # paths which would cause Dependencies to attempt to load this file. - def loadable_constants_for_path(path, bases = autoload_paths) - path = $1 if path =~ /\A(.*)\.rb\Z/ - expanded_path = File.expand_path(path) - - bases.collect do |root| - expanded_root = File.expand_path(root) - next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path - - nesting = expanded_path[(expanded_root.size)..-1] - nesting = nesting[1..-1] if nesting && nesting[0] == ?/ - next if nesting.blank? - nesting_camel = nesting.camelize - begin - qualified_const_defined?(nesting_camel) - rescue NameError - next - end - [ nesting_camel ] - end.flatten.compact.uniq - end - - # Search for a file in autoload_paths matching the provided suffix. - def search_for_file(path_suffix) - path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb' - autoload_paths.each do |root| - path = File.join(root, path_suffix) - return path if File.file? path - end - nil # Gee, I sure wish we had first_match ;-) - end - - # Does the provided path_suffix correspond to an autoloadable module? - # Instead of returning a boolean, the autoload base for this module is returned. - def autoloadable_module?(path_suffix) - autoload_paths.each do |load_path| - return load_path if File.directory? File.join(load_path, path_suffix) - end - nil - end - - def load_once_path?(path) - autoload_once_paths.any? { |base| path.starts_with? base } - end - - # Attempt to autoload the provided module name by searching for a directory - # matching the expect path suffix. If found, the module is created and assigned - # to +into+'s constants with the name +const_name+. Provided that the directory - # was loaded from a reloadable base path, it is added to the set of constants - # that are to be unloaded. - def autoload_module!(into, const_name, qualified_name, path_suffix) - return nil unless base_path = autoloadable_module?(path_suffix) - mod = Module.new - into.const_set const_name, mod - autoloaded_constants << qualified_name unless autoload_once_paths.include?(base_path) - return mod - end - - # Load the file at the provided path. +const_paths+ is a set of qualified - # constant names. When loading the file, Dependencies will watch for the - # addition of these constants. Each that is defined will be marked as - # autoloaded, and will be removed when Dependencies.clear is next called. - # - # If the second parameter is left off, then Dependencies will construct a set - # of names that the file at +path+ may define. See - # +loadable_constants_for_path+ for more details. - def load_file(path, const_paths = loadable_constants_for_path(path)) - log_call path, const_paths - const_paths = [const_paths].compact unless const_paths.is_a? Array - parent_paths = const_paths.collect { |const_path| /(.*)::[^:]+\Z/ =~ const_path ? $1 : :Object } - - result = nil - newly_defined_paths = new_constants_in(*parent_paths) do - result = load_without_new_constant_marking path - end - - autoloaded_constants.concat newly_defined_paths unless load_once_path?(path) - autoloaded_constants.uniq! - log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty? - return result - end - - # Return the constant path for the provided parent and constant name. - def qualified_name_for(mod, name) - mod_name = to_constant_name mod - (%w(Object Kernel).include? mod_name) ? name.to_s : "#{mod_name}::#{name}" - end - - # Load the constant named +const_name+ which is missing from +from_mod+. If - # it is not possible to load the constant into from_mod, try its parent module - # using const_missing. - def load_missing_constant(from_mod, const_name) - log_call from_mod, const_name - if from_mod == Kernel - if ::Object.const_defined?(const_name) - log "Returning Object::#{const_name} for Kernel::#{const_name}" - return ::Object.const_get(const_name) - else - log "Substituting Object for Kernel" - from_mod = Object - end - end - - # If we have an anonymous module, all we can do is attempt to load from Object. - from_mod = Object if from_mod.name.blank? - - unless qualified_const_defined?(from_mod.name) && from_mod.name.constantize.object_id == from_mod.object_id - raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!" - end - - raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name) - - qualified_name = qualified_name_for from_mod, const_name - path_suffix = qualified_name.underscore - name_error = NameError.new("uninitialized constant #{qualified_name}") - - file_path = search_for_file(path_suffix) - if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load - require_or_load file_path - raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless uninherited_const_defined?(from_mod, const_name) - return from_mod.const_get(const_name) - elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix) - return mod - elsif (parent = from_mod.parent) && parent != from_mod && - ! from_mod.parents.any? { |p| uninherited_const_defined?(p, const_name) } - # If our parents do not have a constant named +const_name+ then we are free - # to attempt to load upwards. If they do have such a constant, then this - # const_missing must be due to from_mod::const_name, which should not - # return constants from from_mod's parents. - begin - return parent.const_missing(const_name) - rescue NameError => e - raise unless e.missing_name? qualified_name_for(parent, const_name) - raise name_error - end - else - raise name_error - end - end - - # Remove the constants that have been autoloaded, and those that have been - # marked for unloading. - def remove_unloadable_constants! - autoloaded_constants.each { |const| remove_constant const } - autoloaded_constants.clear - explicitly_unloadable_constants.each { |const| remove_constant const } - end - - # Determine if the given constant has been automatically loaded. - def autoloaded?(desc) - # No name => anonymous module. - return false if desc.is_a?(Module) && desc.name.blank? - name = to_constant_name desc - return false unless qualified_const_defined? name - return autoloaded_constants.include?(name) - end - - # Will the provided constant descriptor be unloaded? - def will_unload?(const_desc) - autoloaded?(const_desc) || - explicitly_unloadable_constants.include?(to_constant_name(const_desc)) - end - - # Mark the provided constant name for unloading. This constant will be - # unloaded on each request, not just the next one. - def mark_for_unload(const_desc) - name = to_constant_name const_desc - if explicitly_unloadable_constants.include? name - return false - else - explicitly_unloadable_constants << name - return true - end - end - - # Run the provided block and detect the new constants that were loaded during - # its execution. Constants may only be regarded as 'new' once -- so if the - # block calls +new_constants_in+ again, then the constants defined within the - # inner call will not be reported in this one. - # - # If the provided block does not run to completion, and instead raises an - # exception, any new constants are regarded as being only partially defined - # and will be removed immediately. - def new_constants_in(*descs) - log_call(*descs) - - # Build the watch frames. Each frame is a tuple of - # [module_name_as_string, constants_defined_elsewhere] - watch_frames = descs.collect do |desc| - if desc.is_a? Module - mod_name = desc.name - initial_constants = desc.local_constant_names - elsif desc.is_a?(String) || desc.is_a?(Symbol) - mod_name = desc.to_s - - # Handle the case where the module has yet to be defined. - initial_constants = if qualified_const_defined?(mod_name) - mod_name.constantize.local_constant_names - else - [] - end - else - raise Argument, "#{desc.inspect} does not describe a module!" - end - - [mod_name, initial_constants] - end - - constant_watch_stack_mutex.synchronize do - constant_watch_stack.concat watch_frames - end - - aborting = true - begin - yield # Now yield to the code that is to define new constants. - aborting = false - ensure - # Find the new constants. - new_constants = watch_frames.collect do |mod_name, prior_constants| - # Module still doesn't exist? Treat it as if it has no constants. - next [] unless qualified_const_defined?(mod_name) - - mod = mod_name.constantize - next [] unless mod.is_a? Module - new_constants = mod.local_constant_names - prior_constants - - # Make sure no other frames takes credit for these constants. - constant_watch_stack_mutex.synchronize do - constant_watch_stack.each do |frame_name, constants| - constants.concat new_constants if frame_name == mod_name - end - end - - new_constants.collect do |suffix| - mod_name == "Object" ? suffix : "#{mod_name}::#{suffix}" - end - end.flatten - - log "New constants: #{new_constants * ', '}" - - if aborting - log "Error during loading, removing partially loaded constants " - new_constants.each { |name| remove_constant name } - new_constants.clear - end - end - - return new_constants - ensure - # Remove the stack frames that we added. - if defined?(watch_frames) && ! watch_frames.blank? - frame_ids = watch_frames.collect { |frame| frame.object_id } - constant_watch_stack_mutex.synchronize do - constant_watch_stack.delete_if do |watch_frame| - frame_ids.include? watch_frame.object_id - end - end - end - end - - class LoadingModule #:nodoc: - # Old style environment.rb referenced this method directly. Please note, it doesn't - # actually *do* anything any more. - def self.root(*args) - if defined?(Rails) && Rails.logger - Rails.logger.warn "Your environment.rb uses the old syntax, it may not continue to work in future releases." - Rails.logger.warn "For upgrade instructions please see: http://manuals.rubyonrails.com/read/book/19" - end - end - end - - # Convert the provided const desc to a qualified constant name (as a string). - # A module, class, symbol, or string may be provided. - def to_constant_name(desc) #:nodoc: - name = case desc - when String then desc.starts_with?('::') ? desc[2..-1] : desc - when Symbol then desc.to_s - when Module - raise ArgumentError, "Anonymous modules have no name to be referenced by" if desc.name.blank? - desc.name - else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" - end - end - - def remove_constant(const) #:nodoc: - return false unless qualified_const_defined? const - - const = $1 if /\A::(.*)\Z/ =~ const.to_s - names = const.to_s.split('::') - if names.size == 1 # It's under Object - parent = Object - else - parent = (names[0..-2] * '::').constantize - end - - log "removing constant #{const}" - parent.instance_eval { remove_const names.last } - return true - end - - protected - def log_call(*args) - if logger && log_activity - arg_str = args.collect { |arg| arg.inspect } * ', ' - /in `([a-z_\?\!]+)'/ =~ caller(1).first - selector = $1 || '<unknown>' - log "called #{selector}(#{arg_str})" - end - end - - def log(msg) - if logger && log_activity - logger.debug "Dependencies: #{msg}" - end - end - end -end - -ActiveSupport::Dependencies.hook! diff --git a/vendor/rails/activesupport/lib/active_support/deprecation.rb b/vendor/rails/activesupport/lib/active_support/deprecation.rb deleted file mode 100644 index 2c86a6fd..00000000 --- a/vendor/rails/activesupport/lib/active_support/deprecation.rb +++ /dev/null @@ -1,204 +0,0 @@ -require 'yaml' - -module ActiveSupport - module Deprecation #:nodoc: - mattr_accessor :debug - self.debug = false - - # Choose the default warn behavior according to RAILS_ENV. - # Ignore deprecation warnings in production. - DEFAULT_BEHAVIORS = { - 'test' => Proc.new { |message, callstack| - $stderr.puts(message) - $stderr.puts callstack.join("\n ") if debug - }, - 'development' => Proc.new { |message, callstack| - logger = (defined?(Rails) && Rails.logger) ? Rails.logger : Logger.new($stderr) - logger.warn message - logger.debug callstack.join("\n ") if debug - } - } - - class << self - def warn(message = nil, callstack = caller) - behavior.call(deprecation_message(callstack, message), callstack) if behavior && !silenced? - end - - def default_behavior - if defined?(RAILS_ENV) - DEFAULT_BEHAVIORS[RAILS_ENV.to_s] - else - DEFAULT_BEHAVIORS['test'] - end - end - - # Have deprecations been silenced? - def silenced? - @silenced = false unless defined?(@silenced) - @silenced - end - - # Silence deprecation warnings within the block. - def silence - old_silenced, @silenced = @silenced, true - yield - ensure - @silenced = old_silenced - end - - attr_writer :silenced - - - private - def deprecation_message(callstack, message = nil) - message ||= "You are using deprecated behavior which will be removed from the next major or minor release." - message += '.' unless message =~ /\.$/ - "DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}" - end - - def deprecation_caller_message(callstack) - file, line, method = extract_callstack(callstack) - if file - if line && method - "(called from #{method} at #{file}:#{line})" - else - "(called from #{file}:#{line})" - end - end - end - - def extract_callstack(callstack) - if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) - md.captures - else - callstack.first - end - end - end - - # Behavior is a block that takes a message argument. - mattr_accessor :behavior - self.behavior = default_behavior - - # Warnings are not silenced by default. - self.silenced = false - - module ClassMethods #:nodoc: - # Declare that a method has been deprecated. - def deprecate(*method_names) - options = method_names.extract_options! - method_names = method_names + options.keys - method_names.each do |method_name| - alias_method_chain(method_name, :deprecation) do |target, punctuation| - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{target}_with_deprecation#{punctuation}(*args, &block) # def generate_secret_with_deprecation(*args, &block) - ::ActiveSupport::Deprecation.warn( # ::ActiveSupport::Deprecation.warn( - self.class.deprecated_method_warning( # self.class.deprecated_method_warning( - :#{method_name}, # :generate_secret, - #{options[method_name].inspect}), # "You should use ActiveSupport::SecureRandom.hex(64)"), - caller # caller - ) # ) - send(:#{target}_without_deprecation#{punctuation}, *args, &block) # send(:generate_secret_without_deprecation, *args, &block) - end # end - EOS - end - end - end - - def deprecated_method_warning(method_name, message=nil) - warning = "#{method_name} is deprecated and will be removed from Rails #{deprecation_horizon}" - case message - when Symbol then "#{warning} (use #{message} instead)" - when String then "#{warning} (#{message})" - else warning - end - end - - def deprecation_horizon - '2.3' - end - end - - class DeprecationProxy #:nodoc: - def self.new(*args, &block) - object = args.first - - return object unless object - super - end - - silence_warnings do - instance_methods.each { |m| undef_method m unless m =~ /^__/ } - end - - # Don't give a deprecation warning on inspect since test/unit and error - # logs rely on it for diagnostics. - def inspect - target.inspect - end - - private - def method_missing(called, *args, &block) - warn caller, called, args - target.__send__(called, *args, &block) - end - end - - class DeprecatedObjectProxy < DeprecationProxy - def initialize(object, message) - @object = object - @message = message - end - - private - def target - @object - end - - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn(@message, callstack) - end - end - - # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc. - # which emits deprecation warnings on any method call (except +inspect+). - class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc: - def initialize(instance, method, var = "@#{method}") - @instance, @method, @var = instance, method, var - end - - private - def target - @instance.__send__(@method) - end - - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) - end - end - - class DeprecatedConstantProxy < DeprecationProxy #:nodoc: - def initialize(old_const, new_const) - @old_const = old_const - @new_const = new_const - end - - def class - target.class - end - - private - def target - @new_const.to_s.constantize - end - - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn("#{@old_const} is deprecated! Use #{@new_const} instead.", callstack) - end - end - end -end - -class Module - include ActiveSupport::Deprecation::ClassMethods -end diff --git a/vendor/rails/activesupport/lib/active_support/duration.rb b/vendor/rails/activesupport/lib/active_support/duration.rb deleted file mode 100644 index aa6d1aa3..00000000 --- a/vendor/rails/activesupport/lib/active_support/duration.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'active_support/basic_object' - -module ActiveSupport - # Provides accurate date and time measurements using Date#advance and - # Time#advance, respectively. It mainly supports the methods on Numeric, - # such as in this example: - # - # 1.month.ago # equivalent to Time.now.advance(:months => -1) - class Duration < BasicObject - attr_accessor :value, :parts - - def initialize(value, parts) #:nodoc: - @value, @parts = value, parts - end - - # Adds another Duration or a Numeric to this Duration. Numeric values - # are treated as seconds. - def +(other) - if Duration === other - Duration.new(value + other.value, @parts + other.parts) - else - Duration.new(value + other, @parts + [[:seconds, other]]) - end - end - - # Subtracts another Duration or a Numeric from this Duration. Numeric - # values are treated as seconds. - def -(other) - self + (-other) - end - - def -@ #:nodoc: - Duration.new(-value, parts.map { |type,number| [type, -number] }) - end - - def is_a?(klass) #:nodoc: - klass == Duration || super - end - - # Returns true if <tt>other</tt> is also a Duration instance with the - # same <tt>value</tt>, or if <tt>other == value</tt>. - def ==(other) - if Duration === other - other.value == value - else - other == value - end - end - - def self.===(other) #:nodoc: - other.is_a?(Duration) rescue super - end - - # Calculates a new Time or Date that is as far in the future - # as this Duration represents. - def since(time = ::Time.current) - sum(1, time) - end - alias :from_now :since - - # Calculates a new Time or Date that is as far in the past - # as this Duration represents. - def ago(time = ::Time.current) - sum(-1, time) - end - alias :until :ago - - def inspect #:nodoc: - consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h } - parts = [:years, :months, :days, :minutes, :seconds].map do |length| - n = consolidated[length] - "#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero? - end.compact - parts = ["0 seconds"] if parts.empty? - parts.to_sentence(:locale => :en) - end - - protected - - def sum(sign, time = ::Time.current) #:nodoc: - parts.inject(time) do |t,(type,number)| - if t.acts_like?(:time) || t.acts_like?(:date) - if type == :seconds - t.since(sign * number) - else - t.advance(type => sign * number) - end - else - raise ::ArgumentError, "expected a time or date, got #{time.inspect}" - end - end - end - - private - - def method_missing(method, *args, &block) #:nodoc: - value.send(method, *args) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/gzip.rb b/vendor/rails/activesupport/lib/active_support/gzip.rb deleted file mode 100644 index 35a50e9a..00000000 --- a/vendor/rails/activesupport/lib/active_support/gzip.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'zlib' -require 'stringio' - -module ActiveSupport - # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip. - module Gzip - class Stream < StringIO - def close; rewind; end - end - - # Decompresses a gzipped string. - def self.decompress(source) - Zlib::GzipReader.new(StringIO.new(source)).read - end - - # Compresses a string using gzip. - def self.compress(source) - output = Stream.new - gz = Zlib::GzipWriter.new(output) - gz.write(source) - gz.close - output.string - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/inflections.rb b/vendor/rails/activesupport/lib/active_support/inflections.rb deleted file mode 100644 index e7b5387e..00000000 --- a/vendor/rails/activesupport/lib/active_support/inflections.rb +++ /dev/null @@ -1,56 +0,0 @@ -module ActiveSupport - Inflector.inflections do |inflect| - inflect.plural(/$/, 's') - inflect.plural(/s$/i, 's') - inflect.plural(/(ax|test)is$/i, '\1es') - inflect.plural(/(octop|vir)us$/i, '\1i') - inflect.plural(/(alias|status)$/i, '\1es') - inflect.plural(/(bu)s$/i, '\1ses') - inflect.plural(/(buffal|tomat)o$/i, '\1oes') - inflect.plural(/([ti])um$/i, '\1a') - inflect.plural(/sis$/i, 'ses') - inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves') - inflect.plural(/(hive)$/i, '\1s') - inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies') - inflect.plural(/(x|ch|ss|sh)$/i, '\1es') - inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices') - inflect.plural(/([m|l])ouse$/i, '\1ice') - inflect.plural(/^(ox)$/i, '\1en') - inflect.plural(/(quiz)$/i, '\1zes') - - inflect.singular(/s$/i, '') - inflect.singular(/(n)ews$/i, '\1ews') - inflect.singular(/([ti])a$/i, '\1um') - inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis') - inflect.singular(/(^analy)ses$/i, '\1sis') - inflect.singular(/([^f])ves$/i, '\1fe') - inflect.singular(/(hive)s$/i, '\1') - inflect.singular(/(tive)s$/i, '\1') - inflect.singular(/([lr])ves$/i, '\1f') - inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y') - inflect.singular(/(s)eries$/i, '\1eries') - inflect.singular(/(m)ovies$/i, '\1ovie') - inflect.singular(/(x|ch|ss|sh)es$/i, '\1') - inflect.singular(/([m|l])ice$/i, '\1ouse') - inflect.singular(/(bus)es$/i, '\1') - inflect.singular(/(o)es$/i, '\1') - inflect.singular(/(shoe)s$/i, '\1') - inflect.singular(/(cris|ax|test)es$/i, '\1is') - inflect.singular(/(octop|vir)i$/i, '\1us') - inflect.singular(/(alias|status)es$/i, '\1') - inflect.singular(/^(ox)en/i, '\1') - inflect.singular(/(vert|ind)ices$/i, '\1ex') - inflect.singular(/(matr)ices$/i, '\1ix') - inflect.singular(/(quiz)zes$/i, '\1') - inflect.singular(/(database)s$/i, '\1') - - inflect.irregular('person', 'people') - inflect.irregular('man', 'men') - inflect.irregular('child', 'children') - inflect.irregular('sex', 'sexes') - inflect.irregular('move', 'moves') - inflect.irregular('cow', 'kine') - - inflect.uncountable(%w(equipment information rice money species series fish sheep jeans)) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/inflector.rb b/vendor/rails/activesupport/lib/active_support/inflector.rb deleted file mode 100644 index f7c352b6..00000000 --- a/vendor/rails/activesupport/lib/active_support/inflector.rb +++ /dev/null @@ -1,409 +0,0 @@ -# encoding: utf-8 -require 'singleton' -require 'iconv' -require 'kconv' - -module ActiveSupport - # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, - # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept - # in inflections.rb. - # - # The Rails core team has stated patches for the inflections library will not be accepted - # in order to avoid breaking legacy applications which may be relying on errant inflections. - # If you discover an incorrect inflection and require it for your application, you'll need - # to correct it yourself (explained below). - module Inflector - extend self - - # A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional - # inflection rules. Examples: - # - # ActiveSupport::Inflector.inflections do |inflect| - # inflect.plural /^(ox)$/i, '\1\2en' - # inflect.singular /^(ox)en/i, '\1' - # - # inflect.irregular 'octopus', 'octopi' - # - # inflect.uncountable "equipment" - # end - # - # New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the - # pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may - # already have been loaded. - class Inflections - include Singleton - - attr_reader :plurals, :singulars, :uncountables, :humans - - def initialize - @plurals, @singulars, @uncountables, @humans = [], [], [], [] - end - - # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression. - # The replacement should always be a string that may include references to the matched data from the rule. - def plural(rule, replacement) - @uncountables.delete(rule) if rule.is_a?(String) - @uncountables.delete(replacement) - @plurals.insert(0, [rule, replacement]) - end - - # Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression. - # The replacement should always be a string that may include references to the matched data from the rule. - def singular(rule, replacement) - @uncountables.delete(rule) if rule.is_a?(String) - @uncountables.delete(replacement) - @singulars.insert(0, [rule, replacement]) - end - - # Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used - # for strings, not regular expressions. You simply pass the irregular in singular and plural form. - # - # Examples: - # irregular 'octopus', 'octopi' - # irregular 'person', 'people' - def irregular(singular, plural) - @uncountables.delete(singular) - @uncountables.delete(plural) - if singular[0,1].upcase == plural[0,1].upcase - plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1]) - singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1]) - else - plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1]) - plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1]) - singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1]) - singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1]) - end - end - - # Add uncountable words that shouldn't be attempted inflected. - # - # Examples: - # uncountable "money" - # uncountable "money", "information" - # uncountable %w( money information rice ) - def uncountable(*words) - (@uncountables << words).flatten! - end - - # Specifies a humanized form of a string by a regular expression rule or by a string mapping. - # When using a regular expression based replacement, the normal humanize formatting is called after the replacement. - # When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name') - # - # Examples: - # human /_cnt$/i, '\1_count' - # human "legacy_col_person_name", "Name" - def human(rule, replacement) - @humans.insert(0, [rule, replacement]) - end - - # Clears the loaded inflections within a given scope (default is <tt>:all</tt>). - # Give the scope as a symbol of the inflection type, the options are: <tt>:plurals</tt>, - # <tt>:singulars</tt>, <tt>:uncountables</tt>, <tt>:humans</tt>. - # - # Examples: - # clear :all - # clear :plurals - def clear(scope = :all) - case scope - when :all - @plurals, @singulars, @uncountables = [], [], [] - else - instance_variable_set "@#{scope}", [] - end - end - end - - # Yields a singleton instance of Inflector::Inflections so you can specify additional - # inflector rules. - # - # Example: - # ActiveSupport::Inflector.inflections do |inflect| - # inflect.uncountable "rails" - # end - def inflections - if block_given? - yield Inflections.instance - else - Inflections.instance - end - end - - # Returns the plural form of the word in the string. - # - # Examples: - # "post".pluralize # => "posts" - # "octopus".pluralize # => "octopi" - # "sheep".pluralize # => "sheep" - # "words".pluralize # => "words" - # "CamelOctopus".pluralize # => "CamelOctopi" - def pluralize(word) - result = word.to_s.dup - - if word.empty? || inflections.uncountables.include?(result.downcase) - result - else - inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } - result - end - end - - # The reverse of +pluralize+, returns the singular form of a word in a string. - # - # Examples: - # "posts".singularize # => "post" - # "octopi".singularize # => "octopus" - # "sheep".singluarize # => "sheep" - # "word".singularize # => "word" - # "CamelOctopi".singularize # => "CamelOctopus" - def singularize(word) - result = word.to_s.dup - - if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\Z/i } - result - else - inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } - result - end - end - - # By default, +camelize+ converts strings to UpperCamelCase. If the argument to +camelize+ - # is set to <tt>:lower</tt> then +camelize+ produces lowerCamelCase. - # - # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces. - # - # Examples: - # "active_record".camelize # => "ActiveRecord" - # "active_record".camelize(:lower) # => "activeRecord" - # "active_record/errors".camelize # => "ActiveRecord::Errors" - # "active_record/errors".camelize(:lower) # => "activeRecord::Errors" - def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) - if first_letter_in_uppercase - lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } - else - lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1] - end - end - - # Capitalizes all the words and replaces some characters in the string to create - # a nicer looking title. +titleize+ is meant for creating pretty output. It is not - # used in the Rails internals. - # - # +titleize+ is also aliased as as +titlecase+. - # - # Examples: - # "man from the boondocks".titleize # => "Man From The Boondocks" - # "x-men: the last stand".titleize # => "X Men: The Last Stand" - def titleize(word) - humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize } - end - - # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string. - # - # Changes '::' to '/' to convert namespaces to paths. - # - # Examples: - # "ActiveRecord".underscore # => "active_record" - # "ActiveRecord::Errors".underscore # => active_record/errors - def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). - downcase - end - - # Replaces underscores with dashes in the string. - # - # Example: - # "puni_puni" # => "puni-puni" - def dasherize(underscored_word) - underscored_word.gsub(/_/, '-') - end - - # Capitalizes the first word and turns underscores into spaces and strips a - # trailing "_id", if any. Like +titleize+, this is meant for creating pretty output. - # - # Examples: - # "employee_salary" # => "Employee salary" - # "author_id" # => "Author" - def humanize(lower_case_and_underscored_word) - result = lower_case_and_underscored_word.to_s.dup - - inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } - result.gsub(/_id$/, "").gsub(/_/, " ").capitalize - end - - # Removes the module part from the expression in the string. - # - # Examples: - # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections" - # "Inflections".demodulize # => "Inflections" - def demodulize(class_name_in_module) - class_name_in_module.to_s.gsub(/^.*::/, '') - end - - # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. - # - # ==== Examples - # - # class Person - # def to_param - # "#{id}-#{name.parameterize}" - # end - # end - # - # @person = Person.find(1) - # # => #<Person id: 1, name: "Donald E. Knuth"> - # - # <%= link_to(@person.name, person_path(@person)) %> - # # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a> - def parameterize(string, sep = '-') - # remove malformed utf8 characters - string = string.toutf8 unless string.is_utf8? - # replace accented chars with ther ascii equivalents - parameterized_string = transliterate(string) - # Turn unwanted chars into the seperator - parameterized_string.gsub!(/[^a-z0-9\-_]+/i, sep) - unless sep.blank? - re_sep = Regexp.escape(sep) - # No more than one of the separator in a row. - parameterized_string.gsub!(/#{re_sep}{2,}/, sep) - # Remove leading/trailing separator. - parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/i, '') - end - parameterized_string.downcase - end - - - # Replaces accented characters with their ascii equivalents. - def transliterate(string) - Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s - end - - if RUBY_VERSION >= '1.9' - undef_method :transliterate - def transliterate(string) - warn "Ruby 1.9 doesn't support Unicode normalization yet" - string.dup - end - - # The iconv transliteration code doesn't function correctly - # on some platforms, but it's very fast where it does function. - elsif "foo" != (Inflector.transliterate("föö") rescue nil) - undef_method :transliterate - def transliterate(string) - string.mb_chars.normalize(:kd). # Decompose accented characters - gsub(/[^\x00-\x7F]+/, '') # Remove anything non-ASCII entirely (e.g. diacritics). - end - end - - # Create the name of a table like Rails does for models to table names. This method - # uses the +pluralize+ method on the last word in the string. - # - # Examples - # "RawScaledScorer".tableize # => "raw_scaled_scorers" - # "egg_and_ham".tableize # => "egg_and_hams" - # "fancyCategory".tableize # => "fancy_categories" - def tableize(class_name) - pluralize(underscore(class_name)) - end - - # Create a class name from a plural table name like Rails does for table names to models. - # Note that this returns a string and not a Class. (To convert to an actual class - # follow +classify+ with +constantize+.) - # - # Examples: - # "egg_and_hams".classify # => "EggAndHam" - # "posts".classify # => "Post" - # - # Singular names are not handled correctly: - # "business".classify # => "Busines" - def classify(table_name) - # strip out any leading schema name - camelize(singularize(table_name.to_s.sub(/.*\./, ''))) - end - - # Creates a foreign key name from a class name. - # +separate_class_name_and_id_with_underscore+ sets whether - # the method should put '_' between the name and 'id'. - # - # Examples: - # "Message".foreign_key # => "message_id" - # "Message".foreign_key(false) # => "messageid" - # "Admin::Post".foreign_key # => "post_id" - def foreign_key(class_name, separate_class_name_and_id_with_underscore = true) - underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id") - end - - # Ruby 1.9 introduces an inherit argument for Module#const_get and - # #const_defined? and changes their default behavior. - if Module.method(:const_get).arity == 1 - # Tries to find a constant with the name specified in the argument string: - # - # "Module".constantize # => Module - # "Test::Unit".constantize # => Test::Unit - # - # The name is assumed to be the one of a top-level constant, no matter whether - # it starts with "::" or not. No lexical context is taken into account: - # - # C = 'outside' - # module M - # C = 'inside' - # C # => 'inside' - # "C".constantize # => 'outside', same as ::C - # end - # - # NameError is raised when the name is not in CamelCase or the constant is - # unknown. - def constantize(camel_cased_word) - names = camel_cased_word.split('::') - names.shift if names.empty? || names.first.empty? - - constant = Object - names.each do |name| - constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) - end - constant - end - else - def constantize(camel_cased_word) #:nodoc: - names = camel_cased_word.split('::') - names.shift if names.empty? || names.first.empty? - - constant = Object - names.each do |name| - constant = constant.const_get(name, false) || constant.const_missing(name) - end - constant - end - end - - # Turns a number into an ordinal string used to denote the position in an - # ordered sequence such as 1st, 2nd, 3rd, 4th. - # - # Examples: - # ordinalize(1) # => "1st" - # ordinalize(2) # => "2nd" - # ordinalize(1002) # => "1002nd" - # ordinalize(1003) # => "1003rd" - def ordinalize(number) - if (11..13).include?(number.to_i % 100) - "#{number}th" - else - case number.to_i % 10 - when 1; "#{number}st" - when 2; "#{number}nd" - when 3; "#{number}rd" - else "#{number}th" - end - end - end - end -end - -# in case active_support/inflector is required without the rest of active_support -require 'active_support/inflections' -require 'active_support/core_ext/string/inflections' -unless String.included_modules.include?(ActiveSupport::CoreExtensions::String::Inflections) - String.send :include, ActiveSupport::CoreExtensions::String::Inflections -end diff --git a/vendor/rails/activesupport/lib/active_support/json.rb b/vendor/rails/activesupport/lib/active_support/json.rb deleted file mode 100644 index 3e1d9b1d..00000000 --- a/vendor/rails/activesupport/lib/active_support/json.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'active_support/json/decoding' -require 'active_support/json/encoding' diff --git a/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb b/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb deleted file mode 100644 index 4076db9d..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'json' unless defined?(JSON) - -module ActiveSupport - module JSON - module Backends - module JSONGem - ParseError = ::JSON::ParserError - extend self - - # Converts a JSON string into a Ruby object. - def decode(json) - data = ::JSON.parse(json) - if ActiveSupport.parse_json_times - convert_dates_from(data) - else - data - end - end - - private - def convert_dates_from(data) - case data - when DATE_REGEX - DateTime.parse(data) - when Array - data.map! { |d| convert_dates_from(d) } - when Hash - data.each do |key, value| - data[key] = convert_dates_from(value) - end - else data - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/backends/yajl.rb b/vendor/rails/activesupport/lib/active_support/json/backends/yajl.rb deleted file mode 100644 index 64e50e0d..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/backends/yajl.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'yajl' unless defined?(Yajl) - -module ActiveSupport - module JSON - module Backends - module Yajl - ParseError = ::Yajl::ParseError - extend self - - # Parses a JSON string or IO and convert it into an object - def decode(json) - data = ::Yajl::Parser.new.parse(json) - if ActiveSupport.parse_json_times - convert_dates_from(data) - else - data - end - end - - private - def convert_dates_from(data) - case data - when nil - nil - when DATE_REGEX - DateTime.parse(data) - when Array - data.map! { |d| convert_dates_from(d) } - when Hash - data.each do |key, value| - data[key] = convert_dates_from(value) - end - else - data - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb b/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb deleted file mode 100644 index 4c410424..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'active_support/core_ext/string/starts_ends_with' - -module ActiveSupport - module JSON - module Backends - module Yaml - ParseError = ::StandardError - extend self - - # Converts a JSON string into a Ruby object. - def decode(json) - YAML.load(convert_json_to_yaml(json)) - rescue ArgumentError => e - raise ParseError, "Invalid JSON string" - end - - protected - # Ensure that ":" and "," are always followed by a space - def convert_json_to_yaml(json) #:nodoc: - require 'strscan' unless defined? ::StringScanner - scanner, quoting, marks, pos, times = ::StringScanner.new(json), false, [], nil, [] - while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/) - case char = scanner[1] - when '"', "'" - if !quoting - quoting = char - pos = scanner.pos - elsif quoting == char - if json[pos..scanner.pos-2] =~ DATE_REGEX - # found a date, track the exact positions of the quotes so we can - # overwrite them with spaces later. - times << pos << scanner.pos - end - quoting = false - end - when ":","," - marks << scanner.pos - 1 unless quoting - when "\\" - scanner.skip(/\\/) - end - end - - if marks.empty? - json.gsub(/\\([\\\/]|u[[:xdigit:]]{4})/) do - ustr = $1 - if ustr.start_with?('u') - [ustr[1..-1].to_i(16)].pack("U") - elsif ustr == '\\' - '\\\\' - else - ustr - end - end - else - left_pos = [-1].push(*marks) - right_pos = marks << scanner.pos + scanner.rest_size - output = [] - left_pos.each_with_index do |left, i| - scanner.pos = left.succ - chunk = scanner.peek(right_pos[i] - scanner.pos + 1) - # overwrite the quotes found around the dates with spaces - while times.size > 0 && times[0] <= right_pos[i] - chunk[times.shift - scanner.pos - 1] = ' ' - end - chunk.gsub!(/\\([\\\/]|u[[:xdigit:]]{4})/) do - ustr = $1 - if ustr.start_with?('u') - [ustr[1..-1].to_i(16)].pack("U") - elsif ustr == '\\' - '\\\\' - else - ustr - end - end - output << chunk - end - output = output * " " - - output.gsub!(/\\\//, '/') - output - end - end - end - end - end -end - diff --git a/vendor/rails/activesupport/lib/active_support/json/decoding.rb b/vendor/rails/activesupport/lib/active_support/json/decoding.rb deleted file mode 100644 index 2182b909..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/decoding.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'active_support/core_ext/module/attribute_accessors' - -module ActiveSupport - # Look for and parse json strings that look like ISO 8601 times. - mattr_accessor :parse_json_times - - module JSON - # Listed in order of preference. - DECODERS = %w(Yajl Yaml) - - class << self - attr_reader :parse_error - delegate :decode, :to => :backend - - def backend - set_default_backend unless defined?(@backend) - @backend - end - - def backend=(name) - if name.is_a?(Module) - @backend = name - else - require "active_support/json/backends/#{name.to_s.downcase}.rb" - @backend = ActiveSupport::JSON::Backends::const_get(name) - end - @parse_error = @backend::ParseError - end - - def with_backend(name) - old_backend, self.backend = backend, name - yield - ensure - self.backend = old_backend - end - - def set_default_backend - DECODERS.find do |name| - begin - self.backend = name - true - rescue LoadError - # Try next decoder. - false - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb deleted file mode 100644 index 0df1b8ed..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Date - # Coerces the date to a string for JSON encoding. - # - # ISO 8601 format is used if ActiveSupport::JSON::Encoding.use_standard_json_time_format is set. - # - # ==== Examples - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true - # Date.new(2005,2,1).to_json - # # => "2005-02-01" - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false - # Date.new(2005,2,1).to_json - # # => "2005/02/01" - def as_json(options = nil) - if ActiveSupport::JSON::Encoding.use_standard_json_time_format - strftime("%Y-%m-%d") - else - strftime("%Y/%m/%d") - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb deleted file mode 100644 index 20c12a76..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +++ /dev/null @@ -1,22 +0,0 @@ -class DateTime - # Coerces the datetime to a string for JSON encoding. - # - # ISO 8601 format is used if ActiveSupport::JSON::Encoding.use_standard_json_time_format is set. - # - # ==== Examples - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true - # DateTime.civil(2005,2,1,15,15,10).to_json - # # => "2005-02-01T15:15:10+00:00" - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false - # DateTime.civil(2005,2,1,15,15,10).to_json - # # => "2005/02/01 15:15:10 +0000" - def as_json(options = nil) - if ActiveSupport::JSON::Encoding.use_standard_json_time_format - xmlschema - else - strftime('%Y/%m/%d %H:%M:%S %z') - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb deleted file mode 100644 index 65924e38..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Enumerable - # Coerces the enumerable to an array for JSON encoding. - def as_json(options = nil) #:nodoc: - to_a - end -end - -class Array - # Returns a JSON string representing the Array. +options+ are passed to each element. - def to_json(options = nil) #:nodoc: - "[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ','}]" - end - - def as_json(options = nil) #:nodoc: - self - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb deleted file mode 100644 index c2bb1ee2..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +++ /dev/null @@ -1,7 +0,0 @@ -class FalseClass - AS_JSON = ActiveSupport::JSON::Variable.new('false').freeze - - def as_json(options = nil) #:nodoc: - AS_JSON - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb deleted file mode 100644 index cfe21e4a..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'active_support/core_ext/array/wrapper' - -class Hash - # Returns a JSON string representing the hash. - # - # Without any +options+, the returned JSON string will include all - # the hash keys. For example: - # - # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json - # # => {"name": "Konata Izumi", "1": 2, "age": 16} - # - # The keys in the JSON string are unordered due to the nature of hashes. - # - # The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the - # attributes included, and will accept 1 or more hash keys to include/exclude. - # - # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:only => [:name, 'age']) - # # => {"name": "Konata Izumi", "age": 16} - # - # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:except => 1) - # # => {"name": "Konata Izumi", "age": 16} - # - # The +options+ also filter down to any hash values. This is particularly - # useful for converting hashes containing ActiveRecord objects or any object - # that responds to options in their <tt>to_json</tt> method. For example: - # - # users = User.find(:all) - # { :users => users, :count => users.size }.to_json(:include => :posts) - # - # would pass the <tt>:include => :posts</tt> option to <tt>users</tt>, - # allowing the posts association in the User model to be converted to JSON - # as well. - def to_json(options = nil) #:nodoc: - hash = as_json(options) - - result = '{' - result << hash.map do |key, value| - "#{ActiveSupport::JSON.encode(key.to_s)}:#{ActiveSupport::JSON.encode(value, options)}" - end * ',' - result << '}' - end - - def as_json(options = nil) #:nodoc: - if options - if attrs = options[:except] - except(*Array.wrap(attrs)) - elsif attrs = options[:only] - slice(*Array.wrap(attrs)) - else - self - end - else - self - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb deleted file mode 100644 index 041c1a26..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +++ /dev/null @@ -1,7 +0,0 @@ -class NilClass - AS_JSON = ActiveSupport::JSON::Variable.new('null').freeze - - def as_json(options = nil) #:nodoc: - AS_JSON - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb deleted file mode 100644 index 6493bd67..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Numeric - def to_json(options = nil) #:nodoc: - to_s - end - - def as_json(options = nil) #:nodoc: - self - end -end - -class Float - def to_json(options = nil) #:nodoc: - to_s - end -end - -class Integer - def to_json(options = nil) #:nodoc: - to_s - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb deleted file mode 100644 index 09941005..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Object - # Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info. - def to_json(options = nil) - ActiveSupport::JSON.encode(as_json(options)) - end - - def as_json(options = nil) - instance_values - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb deleted file mode 100644 index 14fdbf24..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Regexp - def to_json(options = nil) #:nodoc: - inspect - end - - def as_json(options = nil) #:nodoc: - self - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb deleted file mode 100644 index 697658ec..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +++ /dev/null @@ -1,9 +0,0 @@ -class String - def to_json(options = nil) #:nodoc: - ActiveSupport::JSON::Encoding.escape(self) - end - - def as_json(options = nil) #:nodoc: - self - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb deleted file mode 100644 index f7dcd491..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Symbol - def as_json(options = nil) #:nodoc: - to_s - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb deleted file mode 100644 index fa54e9e3..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Time - # Coerces the time to a string for JSON encoding. - # - # ISO 8601 format is used if ActiveSupport::JSON::Encoding.use_standard_json_time_format is set. - # - # ==== Examples - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true - # Time.utc(2005,2,1,15,15,10).to_json - # # => "2005-02-01T15:15:10Z" - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false - # Time.utc(2005,2,1,15,15,10).to_json - # # => "2005/02/01 15:15:10 +0000" - def as_json(options = nil) - if ActiveSupport::JSON::Encoding.use_standard_json_time_format - xmlschema - else - %(#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb deleted file mode 100644 index 4b65dee3..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +++ /dev/null @@ -1,7 +0,0 @@ -class TrueClass - AS_JSON = ActiveSupport::JSON::Variable.new('true').freeze - - def as_json(options = nil) #:nodoc: - AS_JSON - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoding.rb b/vendor/rails/activesupport/lib/active_support/json/encoding.rb deleted file mode 100644 index 0fbf2fe1..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoding.rb +++ /dev/null @@ -1,111 +0,0 @@ -# encoding: utf-8 -require 'active_support/core_ext/module/delegation' -require 'active_support/deprecation' - -module ActiveSupport - class << self - delegate :use_standard_json_time_format, :use_standard_json_time_format=, - :escape_html_entities_in_json, :escape_html_entities_in_json=, - :to => :'ActiveSupport::JSON::Encoding' - end - - module JSON - # matches YAML-formatted dates - DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/ - - class << self - delegate :encode, :to => :'ActiveSupport::JSON::Encoding' - end - - module Encoding #:nodoc: - class CircularReferenceError < StandardError - end - - ESCAPED_CHARS = { - "\x00" => '\u0000', "\x01" => '\u0001', "\x02" => '\u0002', - "\x03" => '\u0003', "\x04" => '\u0004', "\x05" => '\u0005', - "\x06" => '\u0006', "\x07" => '\u0007', "\x0B" => '\u000B', - "\x0E" => '\u000E', "\x0F" => '\u000F', "\x10" => '\u0010', - "\x11" => '\u0011', "\x12" => '\u0012', "\x13" => '\u0013', - "\x14" => '\u0014', "\x15" => '\u0015', "\x16" => '\u0016', - "\x17" => '\u0017', "\x18" => '\u0018', "\x19" => '\u0019', - "\x1A" => '\u001A', "\x1B" => '\u001B', "\x1C" => '\u001C', - "\x1D" => '\u001D', "\x1E" => '\u001E', "\x1F" => '\u001F', - "\010" => '\b', - "\f" => '\f', - "\n" => '\n', - "\r" => '\r', - "\t" => '\t', - '"' => '\"', - '\\' => '\\\\', - '>' => '\u003E', - '<' => '\u003C', - '&' => '\u0026' } - - class << self - # If true, use ISO 8601 format for dates and times. Otherwise, fall back to the Active Support legacy format. - attr_accessor :use_standard_json_time_format - - attr_accessor :escape_regex - attr_reader :escape_html_entities_in_json - - def escape_html_entities_in_json=(value) - self.escape_regex = \ - if @escape_html_entities_in_json = value - /[\x00-\x1F"\\><&]/ - else - /[\x00-\x1F"\\]/ - end - end - - def escape(string) - string = string.dup.force_encoding(::Encoding::BINARY) if string.respond_to?(:force_encoding) - json = string. - gsub(escape_regex) { |s| ESCAPED_CHARS[s] }. - gsub(/([\xC0-\xDF][\x80-\xBF]| - [\xE0-\xEF][\x80-\xBF]{2}| - [\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s| - s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/n, '\\\\u\&') - } - %("#{json}") - end - - # Converts a Ruby object into a JSON string. - def encode(value, options = nil) - options = {} unless Hash === options - seen = (options[:seen] ||= []) - raise CircularReferenceError, 'object references itself' if seen.include?(value) - seen << value - value.to_json(options) - ensure - seen.pop - end - end - - self.escape_html_entities_in_json = true - end - - CircularReferenceError = Deprecation::DeprecatedConstantProxy.new('ActiveSupport::JSON::CircularReferenceError', Encoding::CircularReferenceError) - end -end - -# Hack to load json gem first so we can overwrite its to_json. -begin - require 'json' -rescue LoadError -end - -require 'active_support/json/variable' -require 'active_support/json/encoders/date' -require 'active_support/json/encoders/date_time' -require 'active_support/json/encoders/enumerable' -require 'active_support/json/encoders/false_class' -require 'active_support/json/encoders/hash' -require 'active_support/json/encoders/nil_class' -require 'active_support/json/encoders/numeric' -require 'active_support/json/encoders/object' -require 'active_support/json/encoders/regexp' -require 'active_support/json/encoders/string' -require 'active_support/json/encoders/symbol' -require 'active_support/json/encoders/time' -require 'active_support/json/encoders/true_class' diff --git a/vendor/rails/activesupport/lib/active_support/json/variable.rb b/vendor/rails/activesupport/lib/active_support/json/variable.rb deleted file mode 100644 index 7fd23b0a..00000000 --- a/vendor/rails/activesupport/lib/active_support/json/variable.rb +++ /dev/null @@ -1,10 +0,0 @@ -module ActiveSupport - module JSON - # A string that returns itself as its JSON-encoded form. - class Variable < String - def to_json(options=nil) - self - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/locale/en.yml b/vendor/rails/activesupport/lib/active_support/locale/en.yml deleted file mode 100644 index 49ad192b..00000000 --- a/vendor/rails/activesupport/lib/active_support/locale/en.yml +++ /dev/null @@ -1,36 +0,0 @@ -en: - date: - formats: - # Use the strftime parameters for formats. - # When no format has been given, it uses default. - # You can provide other formats here if you like! - default: "%Y-%m-%d" - short: "%b %d" - long: "%B %d, %Y" - - day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday] - abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat] - - # Don't forget the nil at the beginning; there's no such thing as a 0th month - month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] - abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] - # Used in date_select and datime_select. - order: - - :year - - :month - - :day - - time: - formats: - default: "%a, %d %b %Y %H:%M:%S %z" - short: "%d %b %H:%M" - long: "%B %d, %Y %H:%M" - am: "am" - pm: "pm" - -# Used in array.to_sentence. - support: - array: - words_connector: ", " - two_words_connector: " and " - last_word_connector: ", and " diff --git a/vendor/rails/activesupport/lib/active_support/memoizable.rb b/vendor/rails/activesupport/lib/active_support/memoizable.rb deleted file mode 100644 index 68148a27..00000000 --- a/vendor/rails/activesupport/lib/active_support/memoizable.rb +++ /dev/null @@ -1,102 +0,0 @@ -module ActiveSupport - module Memoizable - def self.memoized_ivar_for(symbol) - "@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym - end - - module InstanceMethods - def self.included(base) - base.class_eval do - unless base.method_defined?(:freeze_without_memoizable) - alias_method_chain :freeze, :memoizable - end - end - end - - def freeze_with_memoizable - memoize_all unless frozen? - freeze_without_memoizable - end - - def memoize_all - prime_cache ".*" - end - - def unmemoize_all - flush_cache ".*" - end - - def prime_cache(*syms) - syms.each do |sym| - methods.each do |m| - if m.to_s =~ /^_unmemoized_(#{sym})/ - if method(m).arity == 0 - __send__($1) - else - ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) - instance_variable_set(ivar, {}) - end - end - end - end - end - - def flush_cache(*syms, &block) - syms.each do |sym| - (methods + private_methods + protected_methods).each do |m| - if m.to_s =~ /^_unmemoized_(#{sym})/ - ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) - instance_variable_get(ivar).clear if instance_variable_defined?(ivar) - end - end - end - end - end - - def memoize(*symbols) - symbols.each do |symbol| - original_method = :"_unmemoized_#{symbol}" - memoized_ivar = ActiveSupport::Memoizable.memoized_ivar_for(symbol) - - class_eval <<-EOS, __FILE__, __LINE__ + 1 - include InstanceMethods # include InstanceMethods - # - if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type) - raise "Already memoized #{symbol}" # raise "Already memoized mime_type" - end # end - alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type - # - if instance_method(:#{symbol}).arity == 0 # if instance_method(:mime_type).arity == 0 - def #{symbol}(reload = false) # def mime_type(reload = false) - if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? # if reload || !defined?(@_memoized_mime_type) || @_memoized_mime_type.empty? - #{memoized_ivar} = [#{original_method}.freeze] # @_memoized_mime_type = [_unmemoized_mime_type.freeze] - end # end - #{memoized_ivar}[0] # @_memoized_mime_type[0] - end # end - else # else - def #{symbol}(*args) # def mime_type(*args) - #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen? - reload = args.pop if args.last == true || args.last == :reload # reload = args.pop if args.last == true || args.last == :reload - # - if defined?(#{memoized_ivar}) && #{memoized_ivar} # if defined?(@_memoized_mime_type) && @_memoized_mime_type - if !reload && #{memoized_ivar}.has_key?(args) # if !reload && @_memoized_mime_type.has_key?(args) - #{memoized_ivar}[args] # @_memoized_mime_type[args] - elsif #{memoized_ivar} # elsif @_memoized_mime_type - #{memoized_ivar}[args] = #{original_method}(*args).freeze # @_memoized_mime_type[args] = _unmemoized_mime_type(*args).freeze - end # end - else # else - #{original_method}(*args) # _unmemoized_mime_type(*args) - end # end - end # end - end # end - # - if private_method_defined?(#{original_method.inspect}) # if private_method_defined?(:_unmemoized_mime_type) - private #{symbol.inspect} # private :mime_type - elsif protected_method_defined?(#{original_method.inspect}) # elsif protected_method_defined?(:_unmemoized_mime_type) - protected #{symbol.inspect} # protected :mime_type - end # end - EOS - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/message_encryptor.rb b/vendor/rails/activesupport/lib/active_support/message_encryptor.rb deleted file mode 100644 index 347af9dc..00000000 --- a/vendor/rails/activesupport/lib/active_support/message_encryptor.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'openssl' - -module ActiveSupport - # MessageEncryptor is a simple way to encrypt values which get stored somewhere - # you don't trust. - # - # The cipher text and initialization vector are base64 encoded and returned to you. - # - # This can be used in situations similar to the MessageVerifier, but where you don't - # want users to be able to determine the value of the payload. - class MessageEncryptor - class InvalidMessage < StandardError; end - OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError - - def initialize(secret, cipher = 'aes-256-cbc') - @secret = secret - @cipher = cipher - end - - def encrypt(value) - cipher = new_cipher - # Rely on OpenSSL for the initialization vector - iv = cipher.random_iv - - cipher.encrypt - cipher.key = @secret - cipher.iv = iv - - encrypted_data = cipher.update(Marshal.dump(value)) - encrypted_data << cipher.final - - [encrypted_data, iv].map {|v| ActiveSupport::Base64.encode64s(v)}.join("--") - end - - def decrypt(encrypted_message) - cipher = new_cipher - encrypted_data, iv = encrypted_message.split("--").map {|v| ActiveSupport::Base64.decode64(v)} - - cipher.decrypt - cipher.key = @secret - cipher.iv = iv - - decrypted_data = cipher.update(encrypted_data) - decrypted_data << cipher.final - - Marshal.load(decrypted_data) - rescue OpenSSLCipherError, TypeError - raise InvalidMessage - end - - def encrypt_and_sign(value) - verifier.generate(encrypt(value)) - end - - def decrypt_and_verify(value) - decrypt(verifier.verify(value)) - end - - - - private - def new_cipher - OpenSSL::Cipher::Cipher.new(@cipher) - end - - def verifier - MessageVerifier.new(@secret) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/message_verifier.rb b/vendor/rails/activesupport/lib/active_support/message_verifier.rb deleted file mode 100644 index 60587b90..00000000 --- a/vendor/rails/activesupport/lib/active_support/message_verifier.rb +++ /dev/null @@ -1,79 +0,0 @@ -module ActiveSupport - # MessageVerifier makes it easy to generate and verify messages which are signed - # to prevent tampering. - # - # This is useful for cases like remember-me tokens and auto-unsubscribe links where the - # session store isn't suitable or available. - # - # Remember Me: - # cookies[:remember_me] = @verifier.generate([@user.id, 2.weeks.from_now]) - # - # In the authentication filter: - # - # id, time = @verifier.verify(cookies[:remember_me]) - # if time < Time.now - # self.current_user = User.find(id) - # end - # - class MessageVerifier - class InvalidSignature < StandardError; end - - def initialize(secret, digest = 'SHA1') - @secret = secret - @digest = digest - end - - def verify(signed_message) - raise InvalidSignature if signed_message.blank? - - data, digest = signed_message.split("--") - if data.present? && digest.present? && secure_compare(digest, generate_digest(data)) - Marshal.load(ActiveSupport::Base64.decode64(data)) - else - raise InvalidSignature - end - end - - def generate(value) - data = ActiveSupport::Base64.encode64s(Marshal.dump(value)) - "#{data}--#{generate_digest(data)}" - end - - private - if "foo".respond_to?(:force_encoding) - # constant-time comparison algorithm to prevent timing attacks - def secure_compare(a, b) - a = a.dup.force_encoding(Encoding::BINARY) - b = b.dup.force_encoding(Encoding::BINARY) - - if a.length == b.length - result = 0 - for i in 0..(a.length - 1) - result |= a[i].ord ^ b[i].ord - end - result == 0 - else - false - end - end - else - # For <= 1.8.6 - def secure_compare(a, b) - if a.length == b.length - result = 0 - for i in 0..(a.length - 1) - result |= a[i] ^ b[i] - end - result == 0 - else - false - end - end - end - - def generate_digest(data) - require 'openssl' unless defined?(OpenSSL) - OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), @secret, data) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/multibyte.rb b/vendor/rails/activesupport/lib/active_support/multibyte.rb deleted file mode 100644 index b6354ee8..00000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte.rb +++ /dev/null @@ -1,57 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte - # A list of all available normalization forms. See http://www.unicode.org/reports/tr15/tr15-29.html for more - # information about normalization. - NORMALIZATION_FORMS = [:c, :kc, :d, :kd] - - # The Unicode version that is supported by the implementation - UNICODE_VERSION = '5.1.0' - - # The default normalization used for operations that require normalization. It can be set to any of the - # normalizations in NORMALIZATION_FORMS. - # - # Example: - # ActiveSupport::Multibyte.default_normalization_form = :c - mattr_accessor :default_normalization_form - self.default_normalization_form = :kc - - # The proxy class returned when calling mb_chars. You can use this accessor to configure your own proxy - # class so you can support other encodings. See the ActiveSupport::Multibyte::Chars implementation for - # an example how to do this. - # - # Example: - # ActiveSupport::Multibyte.proxy_class = CharsForUTF32 - def self.proxy_class=(klass) - @proxy_class = klass - end - - # Returns the currect proxy class - def self.proxy_class - @proxy_class ||= ActiveSupport::Multibyte::Chars - end - - # Regular expressions that describe valid byte sequences for a character - VALID_CHARACTER = { - # Borrowed from the Kconv library by Shinji KONO - (also as seen on the W3C site) - 'UTF-8' => /\A(?: - [\x00-\x7f] | - [\xc2-\xdf] [\x80-\xbf] | - \xe0 [\xa0-\xbf] [\x80-\xbf] | - [\xe1-\xef] [\x80-\xbf] [\x80-\xbf] | - \xf0 [\x90-\xbf] [\x80-\xbf] [\x80-\xbf] | - [\xf1-\xf3] [\x80-\xbf] [\x80-\xbf] [\x80-\xbf] | - \xf4 [\x80-\x8f] [\x80-\xbf] [\x80-\xbf])\z /xn, - # Quick check for valid Shift-JIS characters, disregards the odd-even pairing - 'Shift_JIS' => /\A(?: - [\x00-\x7e \xa1-\xdf] | - [\x81-\x9f \xe0-\xef] [\x40-\x7e \x80-\x9e \x9f-\xfc])\z /xn - } - end -end - -require 'active_support/multibyte/chars' -require 'active_support/multibyte/exceptions' -require 'active_support/multibyte/unicode_database' -require 'active_support/multibyte/utils' diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb b/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb deleted file mode 100644 index 32d97a66..00000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +++ /dev/null @@ -1,707 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - # Chars enables you to work transparently with UTF-8 encoding in the Ruby String class without having extensive - # knowledge about the encoding. A Chars object accepts a string upon initialization and proxies String methods in an - # encoding safe manner. All the normal String methods are also implemented on the proxy. - # - # String methods are proxied through the Chars object, and can be accessed through the +mb_chars+ method. Methods - # which would normally return a String object now return a Chars object so methods can be chained. - # - # "The Perfect String ".mb_chars.downcase.strip.normalize #=> "the perfect string" - # - # Chars objects are perfectly interchangeable with String objects as long as no explicit class checks are made. - # If certain methods do explicitly check the class, call +to_s+ before you pass chars objects to them. - # - # bad.explicit_checking_method "T".mb_chars.downcase.to_s - # - # The default Chars implementation assumes that the encoding of the string is UTF-8, if you want to handle different - # encodings you can write your own multibyte string handler and configure it through - # ActiveSupport::Multibyte.proxy_class. - # - # class CharsForUTF32 - # def size - # @wrapped_string.size / 4 - # end - # - # def self.accepts?(string) - # string.length % 4 == 0 - # end - # end - # - # ActiveSupport::Multibyte.proxy_class = CharsForUTF32 - class Chars - # Hangul character boundaries and properties - HANGUL_SBASE = 0xAC00 - HANGUL_LBASE = 0x1100 - HANGUL_VBASE = 0x1161 - HANGUL_TBASE = 0x11A7 - HANGUL_LCOUNT = 19 - HANGUL_VCOUNT = 21 - HANGUL_TCOUNT = 28 - HANGUL_NCOUNT = HANGUL_VCOUNT * HANGUL_TCOUNT - HANGUL_SCOUNT = 11172 - HANGUL_SLAST = HANGUL_SBASE + HANGUL_SCOUNT - HANGUL_JAMO_FIRST = 0x1100 - HANGUL_JAMO_LAST = 0x11FF - - # All the unicode whitespace - UNICODE_WHITESPACE = [ - (0x0009..0x000D).to_a, # White_Space # Cc [5] <control-0009>..<control-000D> - 0x0020, # White_Space # Zs SPACE - 0x0085, # White_Space # Cc <control-0085> - 0x00A0, # White_Space # Zs NO-BREAK SPACE - 0x1680, # White_Space # Zs OGHAM SPACE MARK - 0x180E, # White_Space # Zs MONGOLIAN VOWEL SEPARATOR - (0x2000..0x200A).to_a, # White_Space # Zs [11] EN QUAD..HAIR SPACE - 0x2028, # White_Space # Zl LINE SEPARATOR - 0x2029, # White_Space # Zp PARAGRAPH SEPARATOR - 0x202F, # White_Space # Zs NARROW NO-BREAK SPACE - 0x205F, # White_Space # Zs MEDIUM MATHEMATICAL SPACE - 0x3000, # White_Space # Zs IDEOGRAPHIC SPACE - ].flatten.freeze - - # BOM (byte order mark) can also be seen as whitespace, it's a non-rendering character used to distinguish - # between little and big endian. This is not an issue in utf-8, so it must be ignored. - UNICODE_LEADERS_AND_TRAILERS = UNICODE_WHITESPACE + [65279] # ZERO-WIDTH NO-BREAK SPACE aka BOM - - # Returns a regular expression pattern that matches the passed Unicode codepoints - def self.codepoints_to_pattern(array_of_codepoints) #:nodoc: - array_of_codepoints.collect{ |e| [e].pack 'U*' }.join('|') - end - UNICODE_TRAILERS_PAT = /(#{codepoints_to_pattern(UNICODE_LEADERS_AND_TRAILERS)})+\Z/ - UNICODE_LEADERS_PAT = /\A(#{codepoints_to_pattern(UNICODE_LEADERS_AND_TRAILERS)})+/ - - UTF8_PAT = ActiveSupport::Multibyte::VALID_CHARACTER['UTF-8'] - - attr_reader :wrapped_string - alias to_s wrapped_string - alias to_str wrapped_string - - if '1.9'.respond_to?(:force_encoding) - # Creates a new Chars instance by wrapping _string_. - def initialize(string) - @wrapped_string = string - @wrapped_string.force_encoding(Encoding::UTF_8) unless @wrapped_string.frozen? - end - else - def initialize(string) #:nodoc: - @wrapped_string = string - end - end - - # Forward all undefined methods to the wrapped string. - def method_missing(method, *args, &block) - if method.to_s =~ /!$/ - @wrapped_string.__send__(method, *args, &block) - self - else - result = @wrapped_string.__send__(method, *args, &block) - result.kind_of?(String) ? chars(result) : result - end - end - - # Returns +true+ if _obj_ responds to the given method. Private methods are included in the search - # only if the optional second parameter evaluates to +true+. - def respond_to?(method, include_private=false) - super || @wrapped_string.respond_to?(method, include_private) || false - end - - # Enable more predictable duck-typing on String-like classes. See Object#acts_like?. - def acts_like_string? - true - end - - # Returns +true+ if the Chars class can and should act as a proxy for the string _string_. Returns - # +false+ otherwise. - def self.wants?(string) - $KCODE == 'UTF8' && consumes?(string) - end - - # Returns +true+ when the proxy class can handle the string. Returns +false+ otherwise. - def self.consumes?(string) - # Unpack is a little bit faster than regular expressions. - string.unpack('U*') - true - rescue ArgumentError - false - end - - include Comparable - - # Returns <tt>-1</tt>, <tt>0</tt> or <tt>+1</tt> depending on whether the Chars object is to be sorted before, - # equal or after the object on the right side of the operation. It accepts any object that implements +to_s+. - # See <tt>String#<=></tt> for more details. - # - # Example: - # 'é'.mb_chars <=> 'ü'.mb_chars #=> -1 - def <=>(other) - @wrapped_string <=> other.to_s - end - - # Returns a new Chars object containing the _other_ object concatenated to the string. - # - # Example: - # ('Café'.mb_chars + ' périferôl').to_s #=> "Café périferôl" - def +(other) - self << other - end - - # Like <tt>String#=~</tt> only it returns the character offset (in codepoints) instead of the byte offset. - # - # Example: - # 'Café périferôl'.mb_chars =~ /ô/ #=> 12 - def =~(other) - translate_offset(@wrapped_string =~ other) - end - - # Works just like <tt>String#split</tt>, with the exception that the items in the resulting list are Chars - # instances instead of String. This makes chaining methods easier. - # - # Example: - # 'Café périferôl'.mb_chars.split(/é/).map { |part| part.upcase.to_s } #=> ["CAF", " P", "RIFERÔL"] - def split(*args) - @wrapped_string.split(*args).map { |i| i.mb_chars } - end - - # Inserts the passed string at specified codepoint offsets. - # - # Example: - # 'Café'.mb_chars.insert(4, ' périferôl').to_s #=> "Café périferôl" - def insert(offset, fragment) - unpacked = self.class.u_unpack(@wrapped_string) - unless offset > unpacked.length - @wrapped_string.replace( - self.class.u_unpack(@wrapped_string).insert(offset, *self.class.u_unpack(fragment)).pack('U*') - ) - else - raise IndexError, "index #{offset} out of string" - end - self - end - - # Returns +true+ if contained string contains _other_. Returns +false+ otherwise. - # - # Example: - # 'Café'.mb_chars.include?('é') #=> true - def include?(other) - # We have to redefine this method because Enumerable defines it. - @wrapped_string.include?(other) - end - - # Returns the position _needle_ in the string, counting in codepoints. Returns +nil+ if _needle_ isn't found. - # - # Example: - # 'Café périferôl'.mb_chars.index('ô') #=> 12 - # 'Café périferôl'.mb_chars.index(/\w/u) #=> 0 - def index(needle, offset=0) - wrapped_offset = self.first(offset).wrapped_string.length - index = @wrapped_string.index(needle, wrapped_offset) - index ? (self.class.u_unpack(@wrapped_string.slice(0...index)).size) : nil - end - - # Returns the position _needle_ in the string, counting in - # codepoints, searching backward from _offset_ or the end of the - # string. Returns +nil+ if _needle_ isn't found. - # - # Example: - # 'Café périferôl'.mb_chars.rindex('é') #=> 6 - # 'Café périferôl'.mb_chars.rindex(/\w/u) #=> 13 - def rindex(needle, offset=nil) - offset ||= length - wrapped_offset = self.first(offset).wrapped_string.length - index = @wrapped_string.rindex(needle, wrapped_offset) - index ? (self.class.u_unpack(@wrapped_string.slice(0...index)).size) : nil - end - - # Like <tt>String#[]=</tt>, except instead of byte offsets you specify character offsets. - # - # Example: - # - # s = "Müller" - # s.mb_chars[2] = "e" # Replace character with offset 2 - # s - # #=> "Müeler" - # - # s = "Müller" - # s.mb_chars[1, 2] = "ö" # Replace 2 characters at character offset 1 - # s - # #=> "Möler" - def []=(*args) - replace_by = args.pop - # Indexed replace with regular expressions already works - if args.first.is_a?(Regexp) - @wrapped_string[*args] = replace_by - else - result = self.class.u_unpack(@wrapped_string) - if args[0].is_a?(Fixnum) - raise IndexError, "index #{args[0]} out of string" if args[0] >= result.length - min = args[0] - max = args[1].nil? ? min : (min + args[1] - 1) - range = Range.new(min, max) - replace_by = [replace_by].pack('U') if replace_by.is_a?(Fixnum) - elsif args.first.is_a?(Range) - raise RangeError, "#{args[0]} out of range" if args[0].min >= result.length - range = args[0] - else - needle = args[0].to_s - min = index(needle) - max = min + self.class.u_unpack(needle).length - 1 - range = Range.new(min, max) - end - result[range] = self.class.u_unpack(replace_by) - @wrapped_string.replace(result.pack('U*')) - end - end - - # Works just like <tt>String#rjust</tt>, only integer specifies characters instead of bytes. - # - # Example: - # - # "¾ cup".mb_chars.rjust(8).to_s - # #=> " ¾ cup" - # - # "¾ cup".mb_chars.rjust(8, " ").to_s # Use non-breaking whitespace - # #=> "   ¾ cup" - def rjust(integer, padstr=' ') - justify(integer, :right, padstr) - end - - # Works just like <tt>String#ljust</tt>, only integer specifies characters instead of bytes. - # - # Example: - # - # "¾ cup".mb_chars.rjust(8).to_s - # #=> "¾ cup " - # - # "¾ cup".mb_chars.rjust(8, " ").to_s # Use non-breaking whitespace - # #=> "¾ cup   " - def ljust(integer, padstr=' ') - justify(integer, :left, padstr) - end - - # Works just like <tt>String#center</tt>, only integer specifies characters instead of bytes. - # - # Example: - # - # "¾ cup".mb_chars.center(8).to_s - # #=> " ¾ cup " - # - # "¾ cup".mb_chars.center(8, " ").to_s # Use non-breaking whitespace - # #=> " ¾ cup  " - def center(integer, padstr=' ') - justify(integer, :center, padstr) - end - - # Strips entire range of Unicode whitespace from the right of the string. - def rstrip - chars(@wrapped_string.gsub(UNICODE_TRAILERS_PAT, '')) - end - - # Strips entire range of Unicode whitespace from the left of the string. - def lstrip - chars(@wrapped_string.gsub(UNICODE_LEADERS_PAT, '')) - end - - # Strips entire range of Unicode whitespace from the right and left of the string. - def strip - rstrip.lstrip - end - - # Returns the number of codepoints in the string - def size - self.class.u_unpack(@wrapped_string).size - end - alias_method :length, :size - - # Reverses all characters in the string. - # - # Example: - # 'Café'.mb_chars.reverse.to_s #=> 'éfaC' - def reverse - chars(self.class.g_unpack(@wrapped_string).reverse.flatten.pack('U*')) - end - - # Implements Unicode-aware slice with codepoints. Slicing on one point returns the codepoints for that - # character. - # - # Example: - # 'こんにちは'.mb_chars.slice(2..3).to_s #=> "にち" - def slice(*args) - if args.size > 2 - raise ArgumentError, "wrong number of arguments (#{args.size} for 1)" # Do as if we were native - elsif (args.size == 2 && !(args.first.is_a?(Numeric) || args.first.is_a?(Regexp))) - raise TypeError, "cannot convert #{args.first.class} into Integer" # Do as if we were native - elsif (args.size == 2 && !args[1].is_a?(Numeric)) - raise TypeError, "cannot convert #{args[1].class} into Integer" # Do as if we were native - elsif args[0].kind_of? Range - cps = self.class.u_unpack(@wrapped_string).slice(*args) - result = cps.nil? ? nil : cps.pack('U*') - elsif args[0].kind_of? Regexp - result = @wrapped_string.slice(*args) - elsif args.size == 1 && args[0].kind_of?(Numeric) - character = self.class.u_unpack(@wrapped_string)[args[0]] - result = character.nil? ? nil : [character].pack('U') - else - result = self.class.u_unpack(@wrapped_string).slice(*args).pack('U*') - end - result.nil? ? nil : chars(result) - end - alias_method :[], :slice - - # Like <tt>String#slice!</tt>, except instead of byte offsets you specify character offsets. - # - # Example: - # s = 'こんにちは' - # s.mb_chars.slice!(2..3).to_s #=> "にち" - # s #=> "こんは" - def slice!(*args) - slice = self[*args] - self[*args] = '' - slice - end - - # Returns the codepoint of the first character in the string. - # - # Example: - # 'こんにちは'.mb_chars.ord #=> 12371 - def ord - self.class.u_unpack(@wrapped_string)[0] - end - - # Convert characters in the string to uppercase. - # - # Example: - # 'Laurent, òu sont les tests?'.mb_chars.upcase.to_s #=> "LAURENT, ÒU SONT LES TESTS?" - def upcase - apply_mapping :uppercase_mapping - end - - # Convert characters in the string to lowercase. - # - # Example: - # 'VĚDA A VÝZKUM'.mb_chars.downcase.to_s #=> "věda a výzkum" - def downcase - apply_mapping :lowercase_mapping - end - - # Converts the first character to uppercase and the remainder to lowercase. - # - # Example: - # 'über'.mb_chars.capitalize.to_s #=> "Über" - def capitalize - (slice(0) || chars('')).upcase + (slice(1..-1) || chars('')).downcase - end - - # Returns the KC normalization of the string by default. NFKC is considered the best normalization form for - # passing strings to databases and validations. - # - # * <tt>str</tt> - The string to perform normalization on. - # * <tt>form</tt> - The form you want to normalize in. Should be one of the following: - # <tt>:c</tt>, <tt>:kc</tt>, <tt>:d</tt>, or <tt>:kd</tt>. Default is - # ActiveSupport::Multibyte.default_normalization_form - def normalize(form=ActiveSupport::Multibyte.default_normalization_form) - # See http://www.unicode.org/reports/tr15, Table 1 - codepoints = self.class.u_unpack(@wrapped_string) - chars(case form - when :d - self.class.reorder_characters(self.class.decompose_codepoints(:canonical, codepoints)) - when :c - self.class.compose_codepoints(self.class.reorder_characters(self.class.decompose_codepoints(:canonical, codepoints))) - when :kd - self.class.reorder_characters(self.class.decompose_codepoints(:compatability, codepoints)) - when :kc - self.class.compose_codepoints(self.class.reorder_characters(self.class.decompose_codepoints(:compatability, codepoints))) - else - raise ArgumentError, "#{form} is not a valid normalization variant", caller - end.pack('U*')) - end - - # Performs canonical decomposition on all the characters. - # - # Example: - # 'é'.length #=> 2 - # 'é'.mb_chars.decompose.to_s.length #=> 3 - def decompose - chars(self.class.decompose_codepoints(:canonical, self.class.u_unpack(@wrapped_string)).pack('U*')) - end - - # Performs composition on all the characters. - # - # Example: - # 'é'.length #=> 3 - # 'é'.mb_chars.compose.to_s.length #=> 2 - def compose - chars(self.class.compose_codepoints(self.class.u_unpack(@wrapped_string)).pack('U*')) - end - - # Returns the number of grapheme clusters in the string. - # - # Example: - # 'क्षि'.mb_chars.length #=> 4 - # 'क्षि'.mb_chars.g_length #=> 3 - def g_length - self.class.g_unpack(@wrapped_string).length - end - - # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string. - def tidy_bytes - chars(self.class.tidy_bytes(@wrapped_string)) - end - - %w(lstrip rstrip strip reverse upcase downcase tidy_bytes capitalize).each do |method| - define_method("#{method}!") do |*args| - unless args.nil? - @wrapped_string = send(method, *args).to_s - else - @wrapped_string = send(method).to_s - end - self - end - end - - class << self - - # Unpack the string at codepoints boundaries. Raises an EncodingError when the encoding of the string isn't - # valid UTF-8. - # - # Example: - # Chars.u_unpack('Café') #=> [67, 97, 102, 233] - def u_unpack(string) - begin - string.unpack 'U*' - rescue ArgumentError - raise EncodingError, 'malformed UTF-8 character' - end - end - - # Detect whether the codepoint is in a certain character class. Returns +true+ when it's in the specified - # character class and +false+ otherwise. Valid character classes are: <tt>:cr</tt>, <tt>:lf</tt>, <tt>:l</tt>, - # <tt>:v</tt>, <tt>:lv</tt>, <tt>:lvt</tt> and <tt>:t</tt>. - # - # Primarily used by the grapheme cluster support. - def in_char_class?(codepoint, classes) - classes.detect { |c| UCD.boundary[c] === codepoint } ? true : false - end - - # Unpack the string at grapheme boundaries. Returns a list of character lists. - # - # Example: - # Chars.g_unpack('क्षि') #=> [[2325, 2381], [2359], [2367]] - # Chars.g_unpack('Café') #=> [[67], [97], [102], [233]] - def g_unpack(string) - codepoints = u_unpack(string) - unpacked = [] - pos = 0 - marker = 0 - eoc = codepoints.length - while(pos < eoc) - pos += 1 - previous = codepoints[pos-1] - current = codepoints[pos] - if ( - # CR X LF - one = ( previous == UCD.boundary[:cr] and current == UCD.boundary[:lf] ) or - # L X (L|V|LV|LVT) - two = ( UCD.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or - # (LV|V) X (V|T) - three = ( in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) ) or - # (LVT|T) X (T) - four = ( in_char_class?(previous, [:lvt,:t]) and UCD.boundary[:t] === current ) or - # X Extend - five = (UCD.boundary[:extend] === current) - ) - else - unpacked << codepoints[marker..pos-1] - marker = pos - end - end - unpacked - end - - # Reverse operation of g_unpack. - # - # Example: - # Chars.g_pack(Chars.g_unpack('क्षि')) #=> 'क्षि' - def g_pack(unpacked) - (unpacked.flatten).pack('U*') - end - - def padding(padsize, padstr=' ') #:nodoc: - if padsize != 0 - new(padstr * ((padsize / u_unpack(padstr).size) + 1)).slice(0, padsize) - else - '' - end - end - - # Re-order codepoints so the string becomes canonical. - def reorder_characters(codepoints) - length = codepoints.length- 1 - pos = 0 - while pos < length do - cp1, cp2 = UCD.codepoints[codepoints[pos]], UCD.codepoints[codepoints[pos+1]] - if (cp1.combining_class > cp2.combining_class) && (cp2.combining_class > 0) - codepoints[pos..pos+1] = cp2.code, cp1.code - pos += (pos > 0 ? -1 : 1) - else - pos += 1 - end - end - codepoints - end - - # Decompose composed characters to the decomposed form. - def decompose_codepoints(type, codepoints) - codepoints.inject([]) do |decomposed, cp| - # if it's a hangul syllable starter character - if HANGUL_SBASE <= cp and cp < HANGUL_SLAST - sindex = cp - HANGUL_SBASE - ncp = [] # new codepoints - ncp << HANGUL_LBASE + sindex / HANGUL_NCOUNT - ncp << HANGUL_VBASE + (sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT - tindex = sindex % HANGUL_TCOUNT - ncp << (HANGUL_TBASE + tindex) unless tindex == 0 - decomposed.concat ncp - # if the codepoint is decomposable in with the current decomposition type - elsif (ncp = UCD.codepoints[cp].decomp_mapping) and (!UCD.codepoints[cp].decomp_type || type == :compatability) - decomposed.concat decompose_codepoints(type, ncp.dup) - else - decomposed << cp - end - end - end - - # Compose decomposed characters to the composed form. - def compose_codepoints(codepoints) - pos = 0 - eoa = codepoints.length - 1 - starter_pos = 0 - starter_char = codepoints[0] - previous_combining_class = -1 - while pos < eoa - pos += 1 - lindex = starter_char - HANGUL_LBASE - # -- Hangul - if 0 <= lindex and lindex < HANGUL_LCOUNT - vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1 - if 0 <= vindex and vindex < HANGUL_VCOUNT - tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1 - if 0 <= tindex and tindex < HANGUL_TCOUNT - j = starter_pos + 2 - eoa -= 2 - else - tindex = 0 - j = starter_pos + 1 - eoa -= 1 - end - codepoints[starter_pos..j] = (lindex * HANGUL_VCOUNT + vindex) * HANGUL_TCOUNT + tindex + HANGUL_SBASE - end - starter_pos += 1 - starter_char = codepoints[starter_pos] - # -- Other characters - else - current_char = codepoints[pos] - current = UCD.codepoints[current_char] - if current.combining_class > previous_combining_class - if ref = UCD.composition_map[starter_char] - composition = ref[current_char] - else - composition = nil - end - unless composition.nil? - codepoints[starter_pos] = composition - starter_char = composition - codepoints.delete_at pos - eoa -= 1 - pos -= 1 - previous_combining_class = -1 - else - previous_combining_class = current.combining_class - end - else - previous_combining_class = current.combining_class - end - if current.combining_class == 0 - starter_pos = pos - starter_char = codepoints[pos] - end - end - end - codepoints - end - - # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string. - def tidy_bytes(string) - string.split(//u).map do |c| - c.force_encoding(Encoding::ASCII) if c.respond_to?(:force_encoding) - - if !ActiveSupport::Multibyte::VALID_CHARACTER['UTF-8'].match(c) - n = c.unpack('C')[0] - n < 128 ? n.chr : - n < 160 ? [UCD.cp1252[n] || n].pack('U') : - n < 192 ? "\xC2" + n.chr : "\xC3" + (n-64).chr - else - c - end - end.join - end - end - - protected - - def translate_offset(byte_offset) #:nodoc: - return nil if byte_offset.nil? - return 0 if @wrapped_string == '' - chunk = @wrapped_string[0..byte_offset] - begin - begin - chunk.unpack('U*').length - 1 - rescue ArgumentError => e - chunk = @wrapped_string[0..(byte_offset+=1)] - # Stop retrying at the end of the string - raise e unless byte_offset < chunk.length - # We damaged a character, retry - retry - end - # Catch the ArgumentError so we can throw our own - rescue ArgumentError - raise EncodingError, 'malformed UTF-8 character' - end - end - - def justify(integer, way, padstr=' ') #:nodoc: - raise ArgumentError, "zero width padding" if padstr.length == 0 - padsize = integer - size - padsize = padsize > 0 ? padsize : 0 - case way - when :right - result = @wrapped_string.dup.insert(0, self.class.padding(padsize, padstr)) - when :left - result = @wrapped_string.dup.insert(-1, self.class.padding(padsize, padstr)) - when :center - lpad = self.class.padding((padsize / 2.0).floor, padstr) - rpad = self.class.padding((padsize / 2.0).ceil, padstr) - result = @wrapped_string.dup.insert(0, lpad).insert(-1, rpad) - end - chars(result) - end - - def apply_mapping(mapping) #:nodoc: - chars(self.class.u_unpack(@wrapped_string).map do |codepoint| - cp = UCD.codepoints[codepoint] - if cp and (ncp = cp.send(mapping)) and ncp > 0 - ncp - else - codepoint - end - end.pack('U*')) - end - - def chars(string) #:nodoc: - self.class.new(string) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/exceptions.rb b/vendor/rails/activesupport/lib/active_support/multibyte/exceptions.rb deleted file mode 100644 index 62066e3c..00000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/exceptions.rb +++ /dev/null @@ -1,8 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - # Raised when a problem with the encoding was found. - class EncodingError < StandardError; end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb b/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb deleted file mode 100644 index e9578b75..00000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb +++ /dev/null @@ -1,71 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - # Holds data about a codepoint in the Unicode database - class Codepoint - attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping - end - - # Holds static data from the Unicode database - class UnicodeDatabase - ATTRIBUTES = :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252 - - attr_writer(*ATTRIBUTES) - - def initialize - @codepoints = Hash.new(Codepoint.new) - @composition_exclusion = [] - @composition_map = {} - @boundary = {} - @cp1252 = {} - end - - # Lazy load the Unicode database so it's only loaded when it's actually used - ATTRIBUTES.each do |attr_name| - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{attr_name} # def codepoints - load # load - @#{attr_name} # @codepoints - end # end - EOS - end - - # Loads the Unicode database and returns all the internal objects of UnicodeDatabase. - def load - begin - @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read } - rescue Exception => e - raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable") - end - - # Redefine the === method so we can write shorter rules for grapheme cluster breaks - @boundary.each do |k,_| - @boundary[k].instance_eval do - def ===(other) - detect { |i| i === other } ? true : false - end - end if @boundary[k].kind_of?(Array) - end - - # define attr_reader methods for the instance variables - class << self - attr_reader(*ATTRIBUTES) - end - end - - # Returns the directory in which the data files are stored - def self.dirname - File.dirname(__FILE__) + '/../values/' - end - - # Returns the filename for the data file for this version - def self.filename - File.expand_path File.join(dirname, "unicode_tables.dat") - end - end - - # UniCode Database - UCD = UnicodeDatabase.new - end -end diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb b/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb deleted file mode 100644 index 94b393ce..00000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb +++ /dev/null @@ -1,60 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - if Kernel.const_defined?(:Encoding) - # Returns a regular expression that matches valid characters in the current encoding - def self.valid_character - VALID_CHARACTER[Encoding.default_external.to_s] - end - else - def self.valid_character - case $KCODE - when 'UTF8' - VALID_CHARACTER['UTF-8'] - when 'SJIS' - VALID_CHARACTER['Shift_JIS'] - end - end - end - - if 'string'.respond_to?(:valid_encoding?) - # Verifies the encoding of a string - def self.verify(string) - string.valid_encoding? - end - else - def self.verify(string) - if expression = valid_character - # Splits the string on character boundaries, which are determined based on $KCODE. - string.split(//).all? { |c| expression =~ c } - else - true - end - end - end - - # Verifies the encoding of the string and raises an exception when it's not valid - def self.verify!(string) - raise EncodingError.new("Found characters with invalid encoding") unless verify(string) - end - - if 'string'.respond_to?(:force_encoding) - # Removes all invalid characters from the string. - # - # Note: this method is a no-op in Ruby 1.9 - def self.clean(string) - string - end - else - def self.clean(string) - if expression = valid_character - # Splits the string on character boundaries, which are determined based on $KCODE. - string.split(//).grep(expression).join - else - string - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/option_merger.rb b/vendor/rails/activesupport/lib/active_support/option_merger.rb deleted file mode 100644 index 63662b75..00000000 --- a/vendor/rails/activesupport/lib/active_support/option_merger.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport - class OptionMerger #:nodoc: - instance_methods.each do |method| - undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/ - end - - def initialize(context, options) - @context, @options = context, options - end - - private - def method_missing(method, *arguments, &block) - if arguments.last.is_a?(Proc) - proc = arguments.pop - arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) } - else - arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup) - end - - @context.__send__(method, *arguments, &block) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/ordered_hash.rb b/vendor/rails/activesupport/lib/active_support/ordered_hash.rb deleted file mode 100644 index 5e48c021..00000000 --- a/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'yaml' - -YAML.add_builtin_type("omap") do |type, val| - ActiveSupport::OrderedHash[val.map(&:to_a).map(&:first)] -end - -# OrderedHash is namespaced to prevent conflicts with other implementations -module ActiveSupport - class OrderedHash < ::Hash #:nodoc: - def to_yaml_type - "!tag:yaml.org,2002:omap" - end - - def to_yaml(opts = {}) - YAML.quick_emit(self, opts) do |out| - out.seq(taguri, to_yaml_style) do |seq| - each do |k, v| - seq.add(k => v) - end - end - end - end - - # Hash is ordered in Ruby 1.9! - if RUBY_VERSION < '1.9' - def initialize(*args, &block) - super - @keys = [] - end - - def self.[](*args) - ordered_hash = new - - if (args.length == 1 && args.first.is_a?(Array)) - args.first.each do |key_value_pair| - next unless (key_value_pair.is_a?(Array)) - ordered_hash[key_value_pair[0]] = key_value_pair[1] - end - - return ordered_hash - end - - unless (args.size % 2 == 0) - raise ArgumentError.new("odd number of arguments for Hash") - end - - args.each_with_index do |val, ind| - next if (ind % 2 != 0) - ordered_hash[val] = args[ind + 1] - end - - ordered_hash - end - - def initialize_copy(other) - super - # make a deep copy of keys - @keys = other.keys - end - - def []=(key, value) - @keys << key if !has_key?(key) - super - end - - def delete(key) - if has_key? key - index = @keys.index(key) - @keys.delete_at index - end - super - end - - def delete_if - super - sync_keys! - self - end - - def reject! - super - sync_keys! - self - end - - def reject(&block) - dup.reject!(&block) - end - - def keys - @keys.dup - end - - def values - @keys.collect { |key| self[key] } - end - - def to_hash - self - end - - def to_a - @keys.map { |key| [ key, self[key] ] } - end - - def each_key - @keys.each { |key| yield key } - end - - def each_value - @keys.each { |key| yield self[key]} - end - - def each - @keys.each {|key| yield [key, self[key]]} - end - - alias_method :each_pair, :each - - def clear - super - @keys.clear - self - end - - def shift - k = @keys.first - v = delete(k) - [k, v] - end - - def merge!(other_hash) - if block_given? - other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v } - else - other_hash.each { |k, v| self[k] = v } - end - self - end - - alias_method :update, :merge! - - def merge(other_hash, &block) - dup.merge!(other_hash, &block) - end - - # When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not. - def replace(other) - super - @keys = other.keys - self - end - - def invert - OrderedHash[self.to_a.map!{|key_value_pair| key_value_pair.reverse}] - end - - def inspect - "#<OrderedHash #{super}>" - end - - private - def sync_keys! - @keys.delete_if {|k| !has_key?(k)} - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/ordered_options.rb b/vendor/rails/activesupport/lib/active_support/ordered_options.rb deleted file mode 100644 index 64204518..00000000 --- a/vendor/rails/activesupport/lib/active_support/ordered_options.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActiveSupport #:nodoc: - class OrderedOptions < OrderedHash #:nodoc: - def []=(key, value) - super(key.to_sym, value) - end - - def [](key) - super(key.to_sym) - end - - def method_missing(name, *args) - if name.to_s =~ /(.*)=$/ - self[$1.to_sym] = args.first - else - self[name] - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/rescuable.rb b/vendor/rails/activesupport/lib/active_support/rescuable.rb deleted file mode 100644 index c27c4ddb..00000000 --- a/vendor/rails/activesupport/lib/active_support/rescuable.rb +++ /dev/null @@ -1,108 +0,0 @@ -module ActiveSupport - # Rescuable module adds support for easier exception handling. - module Rescuable - def self.included(base) # :nodoc: - base.class_inheritable_accessor :rescue_handlers - base.rescue_handlers = [] - - base.extend(ClassMethods) - end - - module ClassMethods - # Rescue exceptions raised in controller actions. - # - # <tt>rescue_from</tt> receives a series of exception classes or class - # names, and a trailing <tt>:with</tt> option with the name of a method - # or a Proc object to be called to handle them. Alternatively a block can - # be given. - # - # Handlers that take one argument will be called with the exception, so - # that the exception can be inspected when dealing with it. - # - # Handlers are inherited. They are searched from right to left, from - # bottom to top, and up the hierarchy. The handler of the first class for - # which <tt>exception.is_a?(klass)</tt> holds true is the one invoked, if - # any. - # - # class ApplicationController < ActionController::Base - # rescue_from User::NotAuthorized, :with => :deny_access # self defined exception - # rescue_from ActiveRecord::RecordInvalid, :with => :show_errors - # - # rescue_from 'MyAppError::Base' do |exception| - # render :xml => exception, :status => 500 - # end - # - # protected - # def deny_access - # ... - # end - # - # def show_errors(exception) - # exception.record.new_record? ? ... - # end - # end - def rescue_from(*klasses, &block) - options = klasses.extract_options! - - unless options.has_key?(:with) - if block_given? - options[:with] = block - else - raise ArgumentError, "Need a handler. Supply an options hash that has a :with key as the last argument." - end - end - - klasses.each do |klass| - key = if klass.is_a?(Class) && klass <= Exception - klass.name - elsif klass.is_a?(String) - klass - else - raise ArgumentError, "#{klass} is neither an Exception nor a String" - end - - # put the new handler at the end because the list is read in reverse - rescue_handlers << [key, options[:with]] - end - end - end - - # Tries to rescue the exception by looking up and calling a registered handler. - def rescue_with_handler(exception) - if handler = handler_for_rescue(exception) - handler.arity != 0 ? handler.call(exception) : handler.call - true # don't rely on the return value of the handler - end - end - - def handler_for_rescue(exception) - # We go from right to left because pairs are pushed onto rescue_handlers - # as rescue_from declarations are found. - _, rescuer = Array(rescue_handlers).reverse.detect do |klass_name, handler| - # The purpose of allowing strings in rescue_from is to support the - # declaration of handler associations for exception classes whose - # definition is yet unknown. - # - # Since this loop needs the constants it would be inconsistent to - # assume they should exist at this point. An early raised exception - # could trigger some other handler and the array could include - # precisely a string whose corresponding constant has not yet been - # seen. This is why we are tolerant to unknown constants. - # - # Note that this tolerance only matters if the exception was given as - # a string, otherwise a NameError will be raised by the interpreter - # itself when rescue_from CONSTANT is executed. - klass = self.class.const_get(klass_name) rescue nil - klass ||= klass_name.constantize rescue nil - exception.is_a?(klass) if klass - end - - case rescuer - when Symbol - method(rescuer) - when Proc - rescuer.bind(self) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/secure_random.rb b/vendor/rails/activesupport/lib/active_support/secure_random.rb deleted file mode 100644 index cfbce4d7..00000000 --- a/vendor/rails/activesupport/lib/active_support/secure_random.rb +++ /dev/null @@ -1,199 +0,0 @@ -begin - require 'securerandom' -rescue LoadError -end - -module ActiveSupport - if defined?(::SecureRandom) - # Use Ruby's SecureRandom library if available. - SecureRandom = ::SecureRandom # :nodoc: - else - # = Secure random number generator interface. - # - # This library is an interface for secure random number generator which is - # suitable for generating session key in HTTP cookies, etc. - # - # It supports following secure random number generators. - # - # * openssl - # * /dev/urandom - # * Win32 - # - # *Note*: This module is based on the SecureRandom library from Ruby 1.9, - # revision 18786, August 23 2008. It's 100% interface-compatible with Ruby 1.9's - # SecureRandom library. - # - # == Example - # - # # random hexadecimal string. - # p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362" - # p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559" - # p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8" - # p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306" - # p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23" - # ... - # - # # random base64 string. - # p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA==" - # p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w==" - # p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg==" - # p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY=" - # p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8" - # p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg==" - # ... - # - # # random binary string. - # p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301" - # p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" - # ... - module SecureRandom - # SecureRandom.random_bytes generates a random binary string. - # - # The argument n specifies the length of the result string. - # - # If n is not specified, 16 is assumed. - # It may be larger in future. - # - # If secure random number generator is not available, - # NotImplementedError is raised. - def self.random_bytes(n=nil) - n ||= 16 - - unless defined? OpenSSL - begin - require 'openssl' - rescue LoadError - end - end - - if defined? OpenSSL::Random - return OpenSSL::Random.random_bytes(n) - end - - if !defined?(@has_urandom) || @has_urandom - flags = File::RDONLY - flags |= File::NONBLOCK if defined? File::NONBLOCK - flags |= File::NOCTTY if defined? File::NOCTTY - flags |= File::NOFOLLOW if defined? File::NOFOLLOW - begin - File.open("/dev/urandom", flags) {|f| - unless f.stat.chardev? - raise Errno::ENOENT - end - @has_urandom = true - ret = f.readpartial(n) - if ret.length != n - raise NotImplementedError, "Unexpected partial read from random device" - end - return ret - } - rescue Errno::ENOENT - @has_urandom = false - end - end - - if !defined?(@has_win32) - begin - require 'Win32API' - - crypt_acquire_context = Win32API.new("advapi32", "CryptAcquireContext", 'PPPII', 'L') - @crypt_gen_random = Win32API.new("advapi32", "CryptGenRandom", 'LIP', 'L') - - hProvStr = " " * 4 - prov_rsa_full = 1 - crypt_verifycontext = 0xF0000000 - - if crypt_acquire_context.call(hProvStr, nil, nil, prov_rsa_full, crypt_verifycontext) == 0 - raise SystemCallError, "CryptAcquireContext failed: #{lastWin32ErrorMessage}" - end - @hProv, = hProvStr.unpack('L') - - @has_win32 = true - rescue LoadError - @has_win32 = false - end - end - if @has_win32 - bytes = " " * n - if @crypt_gen_random.call(@hProv, bytes.size, bytes) == 0 - raise SystemCallError, "CryptGenRandom failed: #{lastWin32ErrorMessage}" - end - return bytes - end - - raise NotImplementedError, "No random device" - end - - # SecureRandom.hex generates a random hex string. - # - # The argument n specifies the length of the random length. - # The length of the result string is twice of n. - # - # If n is not specified, 16 is assumed. - # It may be larger in future. - # - # If secure random number generator is not available, - # NotImplementedError is raised. - def self.hex(n=nil) - random_bytes(n).unpack("H*")[0] - end - - # SecureRandom.base64 generates a random base64 string. - # - # The argument n specifies the length of the random length. - # The length of the result string is about 4/3 of n. - # - # If n is not specified, 16 is assumed. - # It may be larger in future. - # - # If secure random number generator is not available, - # NotImplementedError is raised. - def self.base64(n=nil) - [random_bytes(n)].pack("m*").delete("\n") - end - - # SecureRandom.random_number generates a random number. - # - # If an positive integer is given as n, - # SecureRandom.random_number returns an integer: - # 0 <= SecureRandom.random_number(n) < n. - # - # If 0 is given or an argument is not given, - # SecureRandom.random_number returns an float: - # 0.0 <= SecureRandom.random_number() < 1.0. - def self.random_number(n=0) - if 0 < n - hex = n.to_s(16) - hex = '0' + hex if (hex.length & 1) == 1 - bin = [hex].pack("H*") - mask = bin[0] - mask |= mask >> 1 - mask |= mask >> 2 - mask |= mask >> 4 - begin - rnd = SecureRandom.random_bytes(bin.length) - rnd[0] = rnd[0] & mask - end until rnd < bin - rnd.unpack("H*")[0].hex - else - # assumption: Float::MANT_DIG <= 64 - i64 = SecureRandom.random_bytes(8).unpack("Q")[0] - Math.ldexp(i64 >> (64-Float::MANT_DIG), -Float::MANT_DIG) - end - end - - # Following code is based on David Garamond's GUID library for Ruby. - def self.lastWin32ErrorMessage # :nodoc: - get_last_error = Win32API.new("kernel32", "GetLastError", '', 'L') - format_message = Win32API.new("kernel32", "FormatMessageA", 'LPLLPLPPPPPPPP', 'L') - format_message_ignore_inserts = 0x00000200 - format_message_from_system = 0x00001000 - - code = get_last_error.call - msg = "\0" * 1024 - len = format_message.call(format_message_ignore_inserts + format_message_from_system, 0, code, 0, msg, 1024, nil, nil, nil, nil, nil, nil, nil, nil) - msg[0, len].tr("\r", '').chomp - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/string_inquirer.rb b/vendor/rails/activesupport/lib/active_support/string_inquirer.rb deleted file mode 100644 index e6b1f392..00000000 --- a/vendor/rails/activesupport/lib/active_support/string_inquirer.rb +++ /dev/null @@ -1,21 +0,0 @@ -module ActiveSupport - # Wrapping a string in this class gives you a prettier way to test - # for equality. The value returned by <tt>Rails.env</tt> is wrapped - # in a StringInquirer object so instead of calling this: - # - # Rails.env == "production" - # - # you can call this: - # - # Rails.env.production? - # - class StringInquirer < String - def method_missing(method_name, *arguments) - if method_name.to_s[-1,1] == "?" - self == method_name.to_s[0..-2] - else - super - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/test_case.rb b/vendor/rails/activesupport/lib/active_support/test_case.rb deleted file mode 100644 index bde74faa..00000000 --- a/vendor/rails/activesupport/lib/active_support/test_case.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'test/unit/testcase' -require 'active_support/testing/setup_and_teardown' -require 'active_support/testing/assertions' -require 'active_support/testing/deprecation' -require 'active_support/testing/declarative' - -begin - gem 'mocha', ">= 0.9.7" - require 'mocha' -rescue LoadError - # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh. - Object.const_set :Mocha, Module.new - Mocha.const_set :ExpectationError, Class.new(StandardError) -end - -module ActiveSupport - class TestCase < ::Test::Unit::TestCase - if defined? MiniTest - Assertion = MiniTest::Assertion - alias_method :method_name, :name if method_defined? :name - alias_method :method_name, :__name__ if method_defined? :__name__ - else - # TODO: Figure out how to get the Rails::BacktraceFilter into minitest/unit - if defined?(Rails) && ENV['BACKTRACE'].nil? - require 'rails/backtrace_cleaner' - Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit } - end - - Assertion = Test::Unit::AssertionFailedError - - require 'active_support/testing/default' - include ActiveSupport::Testing::Default - end - - include ActiveSupport::Testing::SetupAndTeardown - include ActiveSupport::Testing::Assertions - include ActiveSupport::Testing::Deprecation - extend ActiveSupport::Testing::Declarative - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/assertions.rb b/vendor/rails/activesupport/lib/active_support/testing/assertions.rb deleted file mode 100644 index aa9dbe85..00000000 --- a/vendor/rails/activesupport/lib/active_support/testing/assertions.rb +++ /dev/null @@ -1,79 +0,0 @@ -module ActiveSupport - module Testing - module Assertions - # Test numeric difference between the return value of an expression as a result of what is evaluated - # in the yielded block. - # - # assert_difference 'Article.count' do - # post :create, :article => {...} - # end - # - # An arbitrary expression is passed in and evaluated. - # - # assert_difference 'assigns(:article).comments(:reload).size' do - # post :create, :comment => {...} - # end - # - # An arbitrary positive or negative difference can be specified. The default is +1. - # - # assert_difference 'Article.count', -1 do - # post :delete, :id => ... - # end - # - # An array of expressions can also be passed in and evaluated. - # - # assert_difference [ 'Article.count', 'Post.count' ], +2 do - # post :create, :article => {...} - # end - # - # A error message can be specified. - # - # assert_difference 'Article.count', -1, "An Article should be destroyed" do - # post :delete, :id => ... - # end - def assert_difference(expression, difference = 1, message = nil, &block) - b = block.send(:binding) - exps = Array.wrap(expression) - before = exps.map { |e| eval(e, b) } - - yield - - exps.each_with_index do |e, i| - error = "#{e.inspect} didn't change by #{difference}" - error = "#{message}.\n#{error}" if message - assert_equal(before[i] + difference, eval(e, b), error) - end - end - - # Assertion that the numeric result of evaluating an expression is not changed before and after - # invoking the passed in block. - # - # assert_no_difference 'Article.count' do - # post :create, :article => invalid_attributes - # end - # - # A error message can be specified. - # - # assert_no_difference 'Article.count', "An Article should not be destroyed" do - # post :create, :article => invalid_attributes - # end - def assert_no_difference(expression, message = nil, &block) - assert_difference expression, 0, message, &block - end - - # Test if an expression is blank. Passes if object.blank? is true. - # - # assert_blank [] # => true - def assert_blank(object) - assert object.blank?, "#{object.inspect} is not blank" - end - - # Test if an expression is not blank. Passes if object.present? is true. - # - # assert_present {:data => 'x' } # => true - def assert_present(object) - assert object.present?, "#{object.inspect} is blank" - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/declarative.rb b/vendor/rails/activesupport/lib/active_support/testing/declarative.rb deleted file mode 100644 index cb6a5844..00000000 --- a/vendor/rails/activesupport/lib/active_support/testing/declarative.rb +++ /dev/null @@ -1,21 +0,0 @@ -module ActiveSupport - module Testing - module Declarative - # test "verify something" do - # ... - # end - def test(name, &block) - test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym - defined = instance_method(test_name) rescue false - raise "#{test_name} is already defined in #{self}" if defined - if block_given? - define_method(test_name, &block) - else - define_method(test_name) do - flunk "No implementation provided for #{name}" - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/default.rb b/vendor/rails/activesupport/lib/active_support/testing/default.rb deleted file mode 100644 index a0bd6303..00000000 --- a/vendor/rails/activesupport/lib/active_support/testing/default.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveSupport - module Testing - module Default #:nodoc: - # Placeholder so test/unit ignores test cases without any tests. - def default_test - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb b/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb deleted file mode 100644 index 2271caf8..00000000 --- a/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb +++ /dev/null @@ -1,57 +0,0 @@ -require "active_support/core_ext/module" - -module ActiveSupport - module Testing - module Deprecation #:nodoc: - def assert_deprecated(match = nil, &block) - result, warnings = collect_deprecations(&block) - assert !warnings.empty?, "Expected a deprecation warning within the block but received none" - if match - match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp) - assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}" - end - result - end - - def assert_not_deprecated(&block) - result, deprecations = collect_deprecations(&block) - assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n #{deprecations * "\n "}" - result - end - - private - def collect_deprecations - old_behavior = ActiveSupport::Deprecation.behavior - deprecations = [] - ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack| - deprecations << message - end - result = yield - [result, deprecations] - ensure - ActiveSupport::Deprecation.behavior = old_behavior - end - end - end -end - -begin - require 'test/unit/error' - - module Test - module Unit - class Error # :nodoc: - # Silence warnings when reporting test errors. - def message_with_silenced_deprecation - ActiveSupport::Deprecation.silence do - message_without_silenced_deprecation - end - end - - alias_method_chain :message, :silenced_deprecation - end - end - end -rescue LoadError - # Using miniunit, ignore. -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/performance.rb b/vendor/rails/activesupport/lib/active_support/testing/performance.rb deleted file mode 100644 index 331ef0e3..00000000 --- a/vendor/rails/activesupport/lib/active_support/testing/performance.rb +++ /dev/null @@ -1,452 +0,0 @@ -require 'rubygems' -gem 'ruby-prof', '>= 0.6.1' -require 'ruby-prof' - -require 'fileutils' -require 'rails/version' - -module ActiveSupport - module Testing - module Performance - DEFAULTS = - if benchmark = ARGV.include?('--benchmark') # HAX for rake test - { :benchmark => true, - :runs => 4, - :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time], - :output => 'tmp/performance' } - else - { :benchmark => false, - :runs => 1, - :min_percent => 0.01, - :metrics => [:process_time, :memory, :objects], - :formats => [:flat, :graph_html, :call_tree], - :output => 'tmp/performance' } - end.freeze - - def self.included(base) - base.class_attribute :profile_options - base.profile_options = DEFAULTS - end - - def full_test_name - "#{self.class.name}##{method_name}" - end - - def run(result) - return if method_name =~ /^default_test$/ - - yield(self.class::STARTED, name) - @_result = result - - run_warmup - if profile_options && metrics = profile_options[:metrics] - metrics.each do |metric_name| - if klass = Metrics[metric_name.to_sym] - run_profile(klass.new) - result.add_run - end - end - end - - yield(self.class::FINISHED, name) - end - - def run_test(metric, mode) - run_callbacks :setup - setup - metric.send(mode) { __send__ @method_name } - rescue ::Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue StandardError, ScriptError - add_error($!) - ensure - begin - teardown - run_callbacks :teardown, :enumerator => :reverse_each - rescue ::Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue StandardError, ScriptError - add_error($!) - end - end - - protected - def run_warmup - GC.start - - time = Metrics::Time.new - run_test(time, :benchmark) - puts "%s (%s warmup)" % [full_test_name, time.format(time.total)] - - GC.start - end - - def run_profile(metric) - klass = profile_options[:benchmark] ? Benchmarker : Profiler - performer = klass.new(self, metric) - - performer.run - puts performer.report - performer.record - end - - class Performer - delegate :run_test, :profile_options, :full_test_name, :to => :@harness - - def initialize(harness, metric) - @harness, @metric = harness, metric - end - - def report - rate = @total / profile_options[:runs] - '%20s: %s' % [@metric.name, @metric.format(rate)] - end - - protected - def output_filename - "#{profile_options[:output]}/#{full_test_name}_#{@metric.name}" - end - end - - class Benchmarker < Performer - def run - profile_options[:runs].to_i.times { run_test(@metric, :benchmark) } - @total = @metric.total - end - - def record - avg = @metric.total / profile_options[:runs].to_i - now = Time.now.utc.xmlschema - with_output_file do |file| - file.puts "#{avg},#{now},#{environment}" - end - end - - def environment - unless defined? @env - app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/ - - rails = Rails::VERSION::STRING - if File.directory?('vendor/rails/.git') - Dir.chdir('vendor/rails') do - rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/ - end - end - - ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' - ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}" - - @env = [app, rails, ruby, RUBY_PLATFORM] * ',' - end - - @env - end - - protected - HEADER = 'measurement,created_at,app,rails,ruby,platform' - - def with_output_file - fname = output_filename - - if new = !File.exist?(fname) - FileUtils.mkdir_p(File.dirname(fname)) - end - - File.open(fname, 'ab') do |file| - file.puts(HEADER) if new - yield file - end - end - - def output_filename - "#{super}.csv" - end - end - - class Profiler < Performer - def initialize(*args) - super - @supported = @metric.measure_mode rescue false - end - - def run - return unless @supported - - RubyProf.measure_mode = @metric.measure_mode - RubyProf.start - RubyProf.pause - profile_options[:runs].to_i.times { run_test(@metric, :profile) } - @data = RubyProf.stop - @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time } - end - - def report - if @supported - super - else - '%20s: unsupported' % @metric.name - end - end - - def record - return unless @supported - - klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact - - klasses.each do |klass| - fname = output_filename(klass) - FileUtils.mkdir_p(File.dirname(fname)) - File.open(fname, 'wb') do |file| - klass.new(@data).print(file, profile_options.slice(:min_percent)) - end - end - end - - protected - def output_filename(printer_class) - suffix = - case printer_class.name.demodulize - when 'FlatPrinter'; 'flat.txt' - when 'GraphPrinter'; 'graph.txt' - when 'GraphHtmlPrinter'; 'graph.html' - when 'CallTreePrinter'; 'tree.txt' - else printer_class.name.sub(/Printer$/, '').underscore - end - - "#{super()}_#{suffix}" - end - end - - module Metrics - def self.[](name) - const_get(name.to_s.camelize) - rescue NameError - nil - end - - class Base - attr_reader :total - - def initialize - @total = 0 - end - - def name - @name ||= self.class.name.demodulize.underscore - end - - def measure_mode - self.class::Mode - end - - def measure - 0 - end - - def benchmark - with_gc_stats do - before = measure - yield - @total += (measure - before) - end - end - - def profile - RubyProf.resume - yield - ensure - RubyProf.pause - end - - protected - if GC.respond_to?(:enable_stats) - def with_gc_stats - GC.enable_stats - yield - ensure - GC.disable_stats - end - elsif defined?(GC::Profiler) - def with_gc_stats - GC.start - GC.disable - GC::Profiler.enable - yield - ensure - GC::Profiler.disable - GC.enable - end - else - def with_gc_stats - yield - end - end - end - - class Time < Base - def measure - ::Time.now.to_f - end - - def format(measurement) - if measurement < 2 - '%d ms' % (measurement * 1000) - else - '%.2f sec' % measurement - end - end - end - - class ProcessTime < Time - Mode = RubyProf::PROCESS_TIME - - def measure - RubyProf.measure_process_time - end - end - - class WallTime < Time - Mode = RubyProf::WALL_TIME - - def measure - RubyProf.measure_wall_time - end - end - - class CpuTime < Time - Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME) - - def initialize(*args) - # FIXME: yeah my CPU is 2.33 GHz - RubyProf.cpu_frequency = 2.33e9 - super - end - - def measure - RubyProf.measure_cpu_time - end - end - - class Memory < Base - Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY) - - # ruby-prof wrapper - if RubyProf.respond_to?(:measure_memory) - def measure - RubyProf.measure_memory / 1024.0 - end - - # Ruby 1.8 + railsbench patch - elsif GC.respond_to?(:allocated_size) - def measure - GC.allocated_size / 1024.0 - end - - # Ruby 1.8 + lloyd patch - elsif GC.respond_to?(:heap_info) - def measure - GC.heap_info['heap_current_memory'] / 1024.0 - end - - # Ruby 1.9 with total_malloc_allocated_size patch - elsif GC.respond_to?(:malloc_total_allocated_size) - def measure - GC.total_malloc_allocated_size / 1024.0 - end - - # Ruby 1.9 unpatched - elsif GC.respond_to?(:malloc_allocated_size) - def measure - GC.malloc_allocated_size / 1024.0 - end - - # Ruby 1.9 + GC profiler patch - elsif defined?(GC::Profiler) - def measure - GC.enable - GC.start - kb = GC::Profiler.data.last[:HEAP_USE_SIZE] / 1024.0 - GC.disable - kb - end - end - - def format(measurement) - '%.2f KB' % measurement - end - end - - class Objects < Base - Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS) - - if RubyProf.respond_to?(:measure_allocations) - def measure - RubyProf.measure_allocations - end - - # Ruby 1.8 + railsbench patch - elsif ObjectSpace.respond_to?(:allocated_objects) - def measure - ObjectSpace.allocated_objects - end - - # Ruby 1.9 + GC profiler patch - elsif defined?(GC::Profiler) - def measure - GC.enable - GC.start - last = GC::Profiler.data.last - count = last[:HEAP_LIVE_OBJECTS] + last[:HEAP_FREE_OBJECTS] - GC.disable - count - end - end - - def format(measurement) - measurement.to_i.to_s - end - end - - class GcRuns < Base - Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS) - - if RubyProf.respond_to?(:measure_gc_runs) - def measure - RubyProf.measure_gc_runs - end - elsif GC.respond_to?(:collections) - def measure - GC.collections - end - elsif GC.respond_to?(:heap_info) - def measure - GC.heap_info['num_gc_passes'] - end - end - - def format(measurement) - measurement.to_i.to_s - end - end - - class GcTime < Base - Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME) - - if RubyProf.respond_to?(:measure_gc_time) - def measure - RubyProf.measure_gc_time - end - elsif GC.respond_to?(:time) - def measure - GC.time - end - end - - def format(measurement) - '%d ms' % (measurement / 1000) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb b/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb deleted file mode 100644 index 25c927dd..00000000 --- a/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'active_support/callbacks' - -module ActiveSupport - module Testing - module SetupAndTeardown - def self.included(base) - base.class_eval do - include ActiveSupport::Callbacks - define_callbacks :setup, :teardown - - if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions - include ForMiniTest - else - include ForClassicTestUnit - end - end - end - - module ForMiniTest - def run(runner) - result = '.' - begin - run_callbacks :setup - result = super - rescue Exception => e - result = runner.puke(self.class, __name__, e) - ensure - begin - run_callbacks :teardown, :enumerator => :reverse_each - rescue Exception => e - result = runner.puke(self.class, __name__, e) - end - end - result - end - end - - module ForClassicTestUnit - # For compatibility with Ruby < 1.8.6 - PASSTHROUGH_EXCEPTIONS = Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS rescue [NoMemoryError, SignalException, Interrupt, SystemExit] - - # This redefinition is unfortunate but test/unit shows us no alternative. - # Doubly unfortunate: hax to support Mocha's hax. - def run(result) - return if @method_name.to_s == "default_test" - - if using_mocha = respond_to?(:mocha_verify) - assertion_counter_klass = if defined?(Mocha::TestCaseAdapter::AssertionCounter) - Mocha::TestCaseAdapter::AssertionCounter - else - Mocha::Integration::TestUnit::AssertionCounter - end - assertion_counter = assertion_counter_klass.new(result) - end - - yield(Test::Unit::TestCase::STARTED, name) - @_result = result - begin - begin - run_callbacks :setup - setup - __send__(@method_name) - mocha_verify(assertion_counter) if using_mocha - rescue Mocha::ExpectationError => e - add_failure(e.message, e.backtrace) - rescue Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue Exception => e - raise if PASSTHROUGH_EXCEPTIONS.include?(e.class) - add_error(e) - ensure - begin - teardown - run_callbacks :teardown, :enumerator => :reverse_each - rescue Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue Exception => e - raise if PASSTHROUGH_EXCEPTIONS.include?(e.class) - add_error(e) - end - end - ensure - mocha_teardown if using_mocha - end - result.add_run - yield(Test::Unit::TestCase::FINISHED, name) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/time_with_zone.rb b/vendor/rails/activesupport/lib/active_support/time_with_zone.rb deleted file mode 100644 index 2e5a2332..00000000 --- a/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +++ /dev/null @@ -1,335 +0,0 @@ -require 'tzinfo' - -module ActiveSupport - # A Time-like class that can represent a time in any time zone. Necessary because standard Ruby Time instances are - # limited to UTC and the system's <tt>ENV['TZ']</tt> zone. - # - # You shouldn't ever need to create a TimeWithZone instance directly via <tt>new</tt> -- instead, Rails provides the methods - # +local+, +parse+, +at+ and +now+ on TimeZone instances, and +in_time_zone+ on Time and DateTime instances, for a more - # user-friendly syntax. Examples: - # - # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' - # Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # Time.zone.parse('2007-02-01 15:30:45') # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # Time.zone.at(1170361845) # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # Time.zone.now # => Sun, 18 May 2008 13:07:55 EDT -04:00 - # Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # - # See TimeZone and ActiveSupport::CoreExtensions::Time::Zones for further documentation for these methods. - # - # TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are interchangable. Examples: - # - # t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00 - # t.hour # => 13 - # t.dst? # => true - # t.utc_offset # => -14400 - # t.zone # => "EDT" - # t.to_s(:rfc822) # => "Sun, 18 May 2008 13:27:25 -0400" - # t + 1.day # => Mon, 19 May 2008 13:27:25 EDT -04:00 - # t.beginning_of_year # => Tue, 01 Jan 2008 00:00:00 EST -05:00 - # t > Time.utc(1999) # => true - # t.is_a?(Time) # => true - # t.is_a?(ActiveSupport::TimeWithZone) # => true - class TimeWithZone - include Comparable - attr_reader :time_zone - - def initialize(utc_time, time_zone, local_time = nil, period = nil) - @utc, @time_zone, @time = utc_time, time_zone, local_time - @period = @utc ? period : get_period_and_ensure_valid_local_time - end - - # Returns a Time or DateTime instance that represents the time in +time_zone+. - def time - @time ||= period.to_local(@utc) - end - - # Returns a Time or DateTime instance that represents the time in UTC. - def utc - @utc ||= period.to_utc(@time) - end - alias_method :comparable_time, :utc - alias_method :getgm, :utc - alias_method :getutc, :utc - alias_method :gmtime, :utc - - # Returns the underlying TZInfo::TimezonePeriod. - def period - @period ||= time_zone.period_for_utc(@utc) - end - - # Returns the simultaneous time in <tt>Time.zone</tt>, or the specified zone. - def in_time_zone(new_zone = ::Time.zone) - return self if time_zone == new_zone - utc.in_time_zone(new_zone) - end - - # Returns a <tt>Time.local()</tt> instance of the simultaneous time in your system's <tt>ENV['TZ']</tt> zone - def localtime - utc.getlocal - end - alias_method :getlocal, :localtime - - def dst? - period.dst? - end - alias_method :isdst, :dst? - - def utc? - time_zone.name == 'UTC' - end - alias_method :gmt?, :utc? - - def utc_offset - period.utc_total_offset - end - alias_method :gmt_offset, :utc_offset - alias_method :gmtoff, :utc_offset - - def formatted_offset(colon = true, alternate_utc_string = nil) - utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Time uses +zone+ to display the time zone abbreviation, so we're duck-typing it. - def zone - period.zone_identifier.to_s - end - - def inspect - "#{time.strftime('%a, %d %b %Y %H:%M:%S')} #{zone} #{formatted_offset}" - end - - def xmlschema(fraction_digits = 0) - fraction = if fraction_digits > 0 - ".%i" % time.usec.to_s[0, fraction_digits] - end - - "#{time.strftime("%Y-%m-%dT%H:%M:%S")}#{fraction}#{formatted_offset(true, 'Z')}" - end - alias_method :iso8601, :xmlschema - - # Coerces the date to a string for JSON encoding. - # - # ISO 8601 format is used if ActiveSupport::JSON::Encoding.use_standard_json_time_format is set. - # - # ==== Examples - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true - # Time.utc(2005,2,1,15,15,10).in_time_zone.to_json - # # => "2005-02-01T15:15:10Z" - # - # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false - # Time.utc(2005,2,1,15,15,10).in_time_zone.to_json - # # => "2005/02/01 15:15:10 +0000" - def as_json(options = nil) - if ActiveSupport::JSON::Encoding.use_standard_json_time_format - xmlschema - else - %(#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}) - end - end - - def to_yaml(options = {}) - if options.kind_of?(YAML::Emitter) - utc.to_yaml(options) - else - time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z')) - end - end - - def httpdate - utc.httpdate - end - - def rfc2822 - to_s(:rfc822) - end - alias_method :rfc822, :rfc2822 - - # <tt>:db</tt> format outputs time in UTC; all others output time in local. - # Uses TimeWithZone's +strftime+, so <tt>%Z</tt> and <tt>%z</tt> work correctly. - def to_s(format = :default) - return utc.to_s(format) if format == :db - if formatter = ::Time::DATE_FORMATS[format] - formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) - else - "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby 1.9 Time#to_s format - end - end - alias_method :to_formatted_s, :to_s - - # Replaces <tt>%Z</tt> and <tt>%z</tt> directives with +zone+ and +formatted_offset+, respectively, before passing to - # Time#strftime, so that zone information is correct - def strftime(format) - format = format.gsub('%Z', zone).gsub('%z', formatted_offset(false)) - time.strftime(format) - end - - # Use the time in UTC for comparisons. - def <=>(other) - utc <=> other - end - - def between?(min, max) - utc.between?(min, max) - end - - def past? - utc.past? - end - - def today? - time.today? - end - - def future? - utc.future? - end - - def eql?(other) - utc == other - end - - def +(other) - # If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time, - # otherwise move forward from #utc, for accuracy when moving across DST boundaries - if duration_of_variable_length?(other) - method_missing(:+, other) - else - result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other) - result.in_time_zone(time_zone) - end - end - - def -(other) - # If we're subtracting a Duration of variable length (i.e., years, months, days), move backwards from #time, - # otherwise move backwards #utc, for accuracy when moving across DST boundaries - if other.acts_like?(:time) - utc.to_f - other.to_f - elsif duration_of_variable_length?(other) - method_missing(:-, other) - else - result = utc.acts_like?(:date) ? utc.ago(other) : utc - other rescue utc.ago(other) - result.in_time_zone(time_zone) - end - end - - def since(other) - # If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time, - # otherwise move forward from #utc, for accuracy when moving across DST boundaries - if duration_of_variable_length?(other) - method_missing(:since, other) - else - utc.since(other).in_time_zone(time_zone) - end - end - - def ago(other) - since(-other) - end - - def advance(options) - # If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time, - # otherwise advance from #utc, for accuracy when moving across DST boundaries - if options.values_at(:years, :weeks, :months, :days).any? - method_missing(:advance, options) - else - utc.advance(options).in_time_zone(time_zone) - end - end - - %w(year mon month day mday wday yday hour min sec to_date).each do |method_name| - class_eval <<-EOV - def #{method_name} # def year - time.#{method_name} # time.year - end # end - EOV - end - - def usec - time.respond_to?(:usec) ? time.usec : 0 - end - - def to_a - [time.sec, time.min, time.hour, time.day, time.mon, time.year, time.wday, time.yday, dst?, zone] - end - - def to_f - utc.to_f - end - - def to_i - utc.to_i - end - alias_method :hash, :to_i - alias_method :tv_sec, :to_i - - # A TimeWithZone acts like a Time, so just return +self+. - def to_time - self - end - - def to_datetime - utc.to_datetime.new_offset(Rational(utc_offset, 86_400)) - end - - # So that +self+ <tt>acts_like?(:time)</tt>. - def acts_like_time? - true - end - - # Say we're a Time to thwart type checking. - def is_a?(klass) - klass == ::Time || super - end - alias_method :kind_of?, :is_a? - - def freeze - period; utc; time # preload instance variables before freezing - super - end - - def marshal_dump - [utc, time_zone.name, time] - end - - def marshal_load(variables) - initialize(variables[0].utc, ::Time.__send__(:get_zone, variables[1]), variables[2].utc) - end - - # Ensure proxy class responds to all methods that underlying time instance responds to. - def respond_to?(sym, include_priv = false) - # consistently respond false to acts_like?(:date), regardless of whether #time is a Time or DateTime - return false if sym.to_s == 'acts_like_date?' - super || time.respond_to?(sym, include_priv) - end - - # Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+. - def method_missing(sym, *args, &block) - result = time.__send__(sym, *args, &block) - result.acts_like?(:time) ? self.class.new(nil, time_zone, result) : result - end - - private - def get_period_and_ensure_valid_local_time - # we don't want a Time.local instance enforcing its own DST rules as well, - # so transfer time values to a utc constructor if necessary - @time = transfer_time_values_to_utc_constructor(@time) unless @time.utc? - begin - @time_zone.period_for_local(@time) - rescue ::TZInfo::PeriodNotFound - # time is in the "spring forward" hour gap, so we're moving the time forward one hour and trying again - @time += 1.hour - retry - end - end - - def transfer_time_values_to_utc_constructor(time) - ::Time.utc_time(time.year, time.month, time.day, time.hour, time.min, time.sec, time.respond_to?(:usec) ? time.usec : 0) - end - - def duration_of_variable_length?(obj) - ActiveSupport::Duration === obj && obj.parts.any? {|p| [:years, :months, :days].include? p[0] } - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/values/time_zone.rb b/vendor/rails/activesupport/lib/active_support/values/time_zone.rb deleted file mode 100644 index ad9ea2ac..00000000 --- a/vendor/rails/activesupport/lib/active_support/values/time_zone.rb +++ /dev/null @@ -1,416 +0,0 @@ -# The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following: -# -# * Limit the set of zones provided by TZInfo to a meaningful subset of 142 zones. -# * Retrieve and display zones with a friendlier name (e.g., "Eastern Time (US & Canada)" instead of "America/New_York"). -# * Lazily load TZInfo::Timezone instances only when they're needed. -# * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+, +parse+, +at+ and +now+ methods. -# -# If you set <tt>config.time_zone</tt> in the Rails Initializer, you can access this TimeZone object via <tt>Time.zone</tt>: -# -# # environment.rb: -# Rails::Initializer.run do |config| -# config.time_zone = "Eastern Time (US & Canada)" -# end -# -# Time.zone # => #<TimeZone:0x514834...> -# Time.zone.name # => "Eastern Time (US & Canada)" -# Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00 -# -# The version of TZInfo bundled with Active Support only includes the definitions necessary to support the zones -# defined by the TimeZone class. If you need to use zones that aren't defined by TimeZone, you'll need to install the TZInfo gem -# (if a recent version of the gem is installed locally, this will be used instead of the bundled version.) -module ActiveSupport - class TimeZone - unless const_defined?(:MAPPING) - # Keys are Rails TimeZone names, values are TZInfo identifiers - MAPPING = { - "International Date Line West" => "Pacific/Midway", - "Midway Island" => "Pacific/Midway", - "Samoa" => "Pacific/Pago_Pago", - "Hawaii" => "Pacific/Honolulu", - "Alaska" => "America/Juneau", - "Pacific Time (US & Canada)" => "America/Los_Angeles", - "Tijuana" => "America/Tijuana", - "Mountain Time (US & Canada)" => "America/Denver", - "Arizona" => "America/Phoenix", - "Chihuahua" => "America/Chihuahua", - "Mazatlan" => "America/Mazatlan", - "Central Time (US & Canada)" => "America/Chicago", - "Saskatchewan" => "America/Regina", - "Guadalajara" => "America/Mexico_City", - "Mexico City" => "America/Mexico_City", - "Monterrey" => "America/Monterrey", - "Central America" => "America/Guatemala", - "Eastern Time (US & Canada)" => "America/New_York", - "Indiana (East)" => "America/Indiana/Indianapolis", - "Bogota" => "America/Bogota", - "Lima" => "America/Lima", - "Quito" => "America/Lima", - "Atlantic Time (Canada)" => "America/Halifax", - "Caracas" => "America/Caracas", - "La Paz" => "America/La_Paz", - "Santiago" => "America/Santiago", - "Newfoundland" => "America/St_Johns", - "Brasilia" => "America/Sao_Paulo", - "Buenos Aires" => "America/Argentina/Buenos_Aires", - "Georgetown" => "America/Argentina/San_Juan", - "Greenland" => "America/Godthab", - "Mid-Atlantic" => "Atlantic/South_Georgia", - "Azores" => "Atlantic/Azores", - "Cape Verde Is." => "Atlantic/Cape_Verde", - "Dublin" => "Europe/Dublin", - "Edinburgh" => "Europe/Dublin", - "Lisbon" => "Europe/Lisbon", - "London" => "Europe/London", - "Casablanca" => "Africa/Casablanca", - "Monrovia" => "Africa/Monrovia", - "UTC" => "Etc/UTC", - "Belgrade" => "Europe/Belgrade", - "Bratislava" => "Europe/Bratislava", - "Budapest" => "Europe/Budapest", - "Ljubljana" => "Europe/Ljubljana", - "Prague" => "Europe/Prague", - "Sarajevo" => "Europe/Sarajevo", - "Skopje" => "Europe/Skopje", - "Warsaw" => "Europe/Warsaw", - "Zagreb" => "Europe/Zagreb", - "Brussels" => "Europe/Brussels", - "Copenhagen" => "Europe/Copenhagen", - "Madrid" => "Europe/Madrid", - "Paris" => "Europe/Paris", - "Amsterdam" => "Europe/Amsterdam", - "Berlin" => "Europe/Berlin", - "Bern" => "Europe/Berlin", - "Rome" => "Europe/Rome", - "Stockholm" => "Europe/Stockholm", - "Vienna" => "Europe/Vienna", - "West Central Africa" => "Africa/Algiers", - "Bucharest" => "Europe/Bucharest", - "Cairo" => "Africa/Cairo", - "Helsinki" => "Europe/Helsinki", - "Kyev" => "Europe/Kiev", - "Riga" => "Europe/Riga", - "Sofia" => "Europe/Sofia", - "Tallinn" => "Europe/Tallinn", - "Vilnius" => "Europe/Vilnius", - "Athens" => "Europe/Athens", - "Istanbul" => "Europe/Istanbul", - "Minsk" => "Europe/Minsk", - "Jerusalem" => "Asia/Jerusalem", - "Harare" => "Africa/Harare", - "Pretoria" => "Africa/Johannesburg", - "Moscow" => "Europe/Moscow", - "St. Petersburg" => "Europe/Moscow", - "Volgograd" => "Europe/Moscow", - "Kuwait" => "Asia/Kuwait", - "Riyadh" => "Asia/Riyadh", - "Nairobi" => "Africa/Nairobi", - "Baghdad" => "Asia/Baghdad", - "Tehran" => "Asia/Tehran", - "Abu Dhabi" => "Asia/Muscat", - "Muscat" => "Asia/Muscat", - "Baku" => "Asia/Baku", - "Tbilisi" => "Asia/Tbilisi", - "Yerevan" => "Asia/Yerevan", - "Kabul" => "Asia/Kabul", - "Ekaterinburg" => "Asia/Yekaterinburg", - "Islamabad" => "Asia/Karachi", - "Karachi" => "Asia/Karachi", - "Tashkent" => "Asia/Tashkent", - "Chennai" => "Asia/Kolkata", - "Kolkata" => "Asia/Kolkata", - "Mumbai" => "Asia/Kolkata", - "New Delhi" => "Asia/Kolkata", - "Kathmandu" => "Asia/Katmandu", - "Astana" => "Asia/Dhaka", - "Dhaka" => "Asia/Dhaka", - "Sri Jayawardenepura" => "Asia/Colombo", - "Almaty" => "Asia/Almaty", - "Novosibirsk" => "Asia/Novosibirsk", - "Rangoon" => "Asia/Rangoon", - "Bangkok" => "Asia/Bangkok", - "Hanoi" => "Asia/Bangkok", - "Jakarta" => "Asia/Jakarta", - "Krasnoyarsk" => "Asia/Krasnoyarsk", - "Beijing" => "Asia/Shanghai", - "Chongqing" => "Asia/Chongqing", - "Hong Kong" => "Asia/Hong_Kong", - "Urumqi" => "Asia/Urumqi", - "Kuala Lumpur" => "Asia/Kuala_Lumpur", - "Singapore" => "Asia/Singapore", - "Taipei" => "Asia/Taipei", - "Perth" => "Australia/Perth", - "Irkutsk" => "Asia/Irkutsk", - "Ulaan Bataar" => "Asia/Ulaanbaatar", - "Seoul" => "Asia/Seoul", - "Osaka" => "Asia/Tokyo", - "Sapporo" => "Asia/Tokyo", - "Tokyo" => "Asia/Tokyo", - "Yakutsk" => "Asia/Yakutsk", - "Darwin" => "Australia/Darwin", - "Adelaide" => "Australia/Adelaide", - "Canberra" => "Australia/Melbourne", - "Melbourne" => "Australia/Melbourne", - "Sydney" => "Australia/Sydney", - "Brisbane" => "Australia/Brisbane", - "Hobart" => "Australia/Hobart", - "Vladivostok" => "Asia/Vladivostok", - "Guam" => "Pacific/Guam", - "Port Moresby" => "Pacific/Port_Moresby", - "Magadan" => "Asia/Magadan", - "Solomon Is." => "Asia/Magadan", - "New Caledonia" => "Pacific/Noumea", - "Fiji" => "Pacific/Fiji", - "Kamchatka" => "Asia/Kamchatka", - "Marshall Is." => "Pacific/Majuro", - "Auckland" => "Pacific/Auckland", - "Wellington" => "Pacific/Auckland", - "Nuku'alofa" => "Pacific/Tongatapu" - }.each { |name, zone| name.freeze; zone.freeze } - MAPPING.freeze - end - - include Comparable - attr_reader :name - attr_reader :tzinfo - - # Create a new TimeZone object with the given name and offset. The - # offset is the number of seconds that this time zone is offset from UTC - # (GMT). Seconds were chosen as the offset unit because that is the unit that - # Ruby uses to represent time zone offsets (see Time#utc_offset). - def initialize(name, utc_offset = nil, tzinfo = nil) - @name = name - @utc_offset = utc_offset - @tzinfo = tzinfo || TimeZone.find_tzinfo(name) - @current_period = nil - end - - def utc_offset - if @utc_offset - @utc_offset - else - @current_period ||= tzinfo.current_period - @current_period.utc_offset - end - end - - # Returns the offset of this time zone as a formatted string, of the - # format "+HH:MM". - def formatted_offset(colon=true, alternate_utc_string = nil) - utc_offset == 0 && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Compare this time zone to the parameter. The two are comapred first on - # their offsets, and then by name. - def <=>(zone) - result = (utc_offset <=> zone.utc_offset) - result = (name <=> zone.name) if result == 0 - result - end - - # Compare #name and TZInfo identifier to a supplied regexp, returning true - # if a match is found. - def =~(re) - return true if name =~ re || MAPPING[name] =~ re - end - - # Returns a textual representation of this time zone. - def to_s - "(GMT#{formatted_offset}) #{name}" - end - - # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values. Example: - # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00 - def local(*args) - time = Time.utc_time(*args) - ActiveSupport::TimeWithZone.new(nil, self, time) - end - - # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from number of seconds since the Unix epoch. Example: - # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.utc(2000).to_f # => 946684800.0 - # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - def at(secs) - utc = Time.at(secs).utc rescue DateTime.civil(1970).since(secs) - utc.in_time_zone(self) - end - - # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string. Example: - # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - # - # If upper components are missing from the string, they are supplied from TimeZone#now: - # - # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 - def parse(str, now=now) - date_parts = Date._parse(str) - return if date_parts.blank? - time = Time.parse(str, now) rescue DateTime.parse(str) - if date_parts[:offset].nil? - ActiveSupport::TimeWithZone.new(nil, self, time) - else - time.in_time_zone(self) - end - end - - # Returns an ActiveSupport::TimeWithZone instance representing the current time - # in the time zone represented by +self+. Example: - # - # Time.zone = 'Hawaii' # => "Hawaii" - # Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00 - def now - Time.now.utc.in_time_zone(self) - end - - # Return the current date in this time zone. - def today - tzinfo.now.to_date - end - - # Adjust the given time to the simultaneous time in the time zone represented by +self+. Returns a - # Time.utc() instance -- if you want an ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead. - def utc_to_local(time) - tzinfo.utc_to_local(time) - end - - # Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance. - def local_to_utc(time, dst=true) - tzinfo.local_to_utc(time, dst) - end - - # Available so that TimeZone instances respond like TZInfo::Timezone instances - def period_for_utc(time) - tzinfo.period_for_utc(time) - end - - # Available so that TimeZone instances respond like TZInfo::Timezone instances - def period_for_local(time, dst=true) - tzinfo.period_for_local(time, dst) - end - - # TODO: Preload instead of lazy load for thread safety - def self.find_tzinfo(name) - require 'tzinfo' unless defined?(TZInfo) - ::TZInfo::Timezone.get(MAPPING[name] || name) - rescue TZInfo::InvalidTimezoneIdentifier - nil - end - - class << self - alias_method :create, :new - - # Return a TimeZone instance with the given name, or +nil+ if no - # such TimeZone instance exists. (This exists to support the use of - # this class with the +composed_of+ macro.) - def new(name) - self[name] - end - - # Return an array of all TimeZone objects. There are multiple - # TimeZone objects per time zone, in many cases, to make it easier - # for users to find their own time zone. - def all - @zones ||= zones_map.values.sort - end - - def zones_map - unless defined?(@zones_map) - @zones_map = {} - [[-39_600, "International Date Line West", "Midway Island", "Samoa" ], - [-36_000, "Hawaii" ], - [-32_400, "Alaska" ], - [-28_800, "Pacific Time (US & Canada)", "Tijuana" ], - [-25_200, "Mountain Time (US & Canada)", "Chihuahua", "Mazatlan", - "Arizona" ], - [-21_600, "Central Time (US & Canada)", "Saskatchewan", "Guadalajara", - "Mexico City", "Monterrey", "Central America" ], - [-18_000, "Eastern Time (US & Canada)", "Indiana (East)", "Bogota", - "Lima", "Quito" ], - [-16_200, "Caracas" ], - [-14_400, "Atlantic Time (Canada)", "La Paz", "Santiago" ], - [-12_600, "Newfoundland" ], - [-10_800, "Brasilia", "Buenos Aires", "Georgetown", "Greenland" ], - [ -7_200, "Mid-Atlantic" ], - [ -3_600, "Azores", "Cape Verde Is." ], - [ 0, "Dublin", "Edinburgh", "Lisbon", "London", "Casablanca", - "Monrovia", "UTC" ], - [ 3_600, "Belgrade", "Bratislava", "Budapest", "Ljubljana", "Prague", - "Sarajevo", "Skopje", "Warsaw", "Zagreb", "Brussels", - "Copenhagen", "Madrid", "Paris", "Amsterdam", "Berlin", - "Bern", "Rome", "Stockholm", "Vienna", - "West Central Africa" ], - [ 7_200, "Bucharest", "Cairo", "Helsinki", "Kyev", "Riga", "Sofia", - "Tallinn", "Vilnius", "Athens", "Istanbul", "Minsk", - "Jerusalem", "Harare", "Pretoria" ], - [ 10_800, "Moscow", "St. Petersburg", "Volgograd", "Kuwait", "Riyadh", - "Nairobi", "Baghdad" ], - [ 12_600, "Tehran" ], - [ 14_400, "Abu Dhabi", "Muscat", "Baku", "Tbilisi", "Yerevan" ], - [ 16_200, "Kabul" ], - [ 18_000, "Ekaterinburg", "Islamabad", "Karachi", "Tashkent" ], - [ 19_800, "Chennai", "Kolkata", "Mumbai", "New Delhi", "Sri Jayawardenepura" ], - [ 20_700, "Kathmandu" ], - [ 21_600, "Astana", "Dhaka", "Almaty", - "Novosibirsk" ], - [ 23_400, "Rangoon" ], - [ 25_200, "Bangkok", "Hanoi", "Jakarta", "Krasnoyarsk" ], - [ 28_800, "Beijing", "Chongqing", "Hong Kong", "Urumqi", - "Kuala Lumpur", "Singapore", "Taipei", "Perth", "Irkutsk", - "Ulaan Bataar" ], - [ 32_400, "Seoul", "Osaka", "Sapporo", "Tokyo", "Yakutsk" ], - [ 34_200, "Darwin", "Adelaide" ], - [ 36_000, "Canberra", "Melbourne", "Sydney", "Brisbane", "Hobart", - "Vladivostok", "Guam", "Port Moresby" ], - [ 39_600, "Magadan", "Solomon Is.", "New Caledonia" ], - [ 43_200, "Fiji", "Kamchatka", "Marshall Is.", "Auckland", - "Wellington" ], - [ 46_800, "Nuku'alofa" ]]. - each do |offset, *places| - places.each do |place| - @zones_map[place] = create(place, offset) - end - end - end - @zones_map - end - - # Locate a specific time zone object. If the argument is a string, it - # is interpreted to mean the name of the timezone to locate. If it is a - # numeric value it is either the hour offset, or the second offset, of the - # timezone to find. (The first one with that offset will be returned.) - # Returns +nil+ if no such time zone is known to the system. - def [](arg) - case arg - when String - if tz = zones_map[arg] - tz - elsif tz = lookup(arg) - zones_map[arg] = tz - end - when Numeric, ActiveSupport::Duration - arg *= 3600 if arg.abs <= 13 - all.find { |z| z.utc_offset == arg.to_i } - else - raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}" - end - end - - # A convenience method for returning a collection of TimeZone objects - # for time zones in the USA. - def us_zones - @us_zones ||= all.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ } - end - - private - - def lookup(name) - (tzinfo = find_tzinfo(name)) && create(tzinfo.name.freeze) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat b/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat deleted file mode 100644 index 74b333d4..00000000 Binary files a/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat and /dev/null differ diff --git a/vendor/rails/activesupport/lib/active_support/vendor.rb b/vendor/rails/activesupport/lib/active_support/vendor.rb deleted file mode 100644 index 62d81fe9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Prefer gems to the bundled libs. -require 'rubygems' - -begin - gem 'builder', '~> 2.1.2' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/builder-2.1.2" -end -require 'builder' - -begin - gem 'memcache-client', '>= 1.7.4' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/memcache-client-1.7.4" -end - -begin - gem 'tzinfo', '~> 0.3.12' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/tzinfo-0.3.12" -end - -begin - gem 'i18n', '>= 0.4.1' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.4.1" -end -require 'i18n' - -module I18n - if !respond_to?(:normalize_translation_keys) && respond_to?(:normalize_keys) - def self.normalize_translation_keys(*args) - normalize_keys(*args) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb deleted file mode 100644 index da6034d9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -###################################################################### -# BlankSlate provides an abstract base class with no predefined -# methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>). -# BlankSlate is useful as a base class when writing classes that -# depend upon <tt>method_missing</tt> (e.g. dynamic proxies). -# -class BlankSlate - class << self - - # Hide the method named +name+ in the BlankSlate class. Don't - # hide +instance_eval+ or any method beginning with "__". - def hide(name) - if instance_methods.include?(name.to_s) and - name !~ /^(__|instance_eval)/ - @hidden_methods ||= {} - @hidden_methods[name.to_sym] = instance_method(name) - undef_method name - end - end - - def find_hidden_method(name) - @hidden_methods ||= {} - @hidden_methods[name] || superclass.find_hidden_method(name) - end - - # Redefine a previously hidden method so that it may be called on a blank - # slate object. - def reveal(name) - bound_method = nil - unbound_method = find_hidden_method(name) - fail "Don't know how to reveal method '#{name}'" unless unbound_method - define_method(name) do |*args| - bound_method ||= unbound_method.bind(self) - bound_method.call(*args) - end - end - end - - instance_methods.each { |m| hide(m) } -end - -###################################################################### -# Since Ruby is very dynamic, methods added to the ancestors of -# BlankSlate <em>after BlankSlate is defined</em> will show up in the -# list of available BlankSlate methods. We handle this by defining a -# hook in the Object and Kernel classes that will hide any method -# defined after BlankSlate has been loaded. -# -module Kernel - class << self - alias_method :blank_slate_method_added, :method_added - - # Detect method additions to Kernel and remove them in the - # BlankSlate class. - def method_added(name) - result = blank_slate_method_added(name) - return result if self != Kernel - BlankSlate.hide(name) - result - end - end -end - -###################################################################### -# Same as above, except in Object. -# -class Object - class << self - alias_method :blank_slate_method_added, :method_added - - # Detect method additions to Object and remove them in the - # BlankSlate class. - def method_added(name) - result = blank_slate_method_added(name) - return result if self != Object - BlankSlate.hide(name) - result - end - - def find_hidden_method(name) - nil - end - end -end - -###################################################################### -# Also, modules included into Object need to be scanned and have their -# instance methods removed from blank slate. In theory, modules -# included into Kernel would have to be removed as well, but a -# "feature" of Ruby prevents late includes into modules from being -# exposed in the first place. -# -class Module - alias blankslate_original_append_features append_features - def append_features(mod) - result = blankslate_original_append_features(mod) - return result if mod != Object - instance_methods.each do |name| - BlankSlate.hide(name) - end - result - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb deleted file mode 100644 index 97192776..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env ruby - -#-- -# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -require 'builder/xmlmarkup' -require 'builder/xmlevents' diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb deleted file mode 100644 index 2935b6f1..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -require 'blankslate' - -###################################################################### -# BlankSlate has been promoted to a top level name and is now -# available as a standalone gem. We make the name available in the -# Builder namespace for compatibility. -# -module Builder - BlankSlate = ::BlankSlate -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb deleted file mode 100644 index e086a1b1..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org). -# Copyright 2005 by Scott Barron (scott@elitists.net). -# All rights reserved. -# -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -# -# Much of this is taken from Jim's work in xmlbase.rb and xmlmarkup.rb. -# Documentation has also been copied and pasted and modified to reflect -# that we're building CSS here instead of XML. Jim is conducting the -# orchestra here and I'm just off in the corner playing a flute. -#++ - -# Provide a flexible and easy to use Builder for creating Cascading -# Style Sheets (CSS). - - -require 'builder/blankslate' - -module Builder - - # Create a Cascading Style Sheet (CSS) using Ruby. - # - # Example usage: - # - # css = Builder::CSS.new - # - # text_color = '#7F7F7F' - # preferred_fonts = 'Helvetica, Arial, sans_serif' - # - # css.comment! 'This is our stylesheet' - # css.body { - # background_color '#FAFAFA' - # font_size 'small' - # font_family preferred_fonts - # color text_color - # } - # - # css.id!('navbar') { - # width '500px' - # } - # - # css.class!('navitem') { - # color 'red' - # } - # - # css.a :hover { - # text_decoration 'underline' - # } - # - # css.div(:id => 'menu') { - # background 'green' - # } - # - # css.div(:class => 'foo') { - # background 'red' - # } - # - # This will yield the following stylesheet: - # - # /* This is our stylesheet */ - # body { - # background_color: #FAFAFA; - # font_size: small; - # font_family: Helvetica, Arial, sans_serif; - # color: #7F7F7F; - # } - # - # #navbar { - # width: 500px; - # } - # - # .navitem { - # color: red; - # } - # - # a:hover { - # text_decoration: underline; - # } - # - # div#menu { - # background: green; - # } - # - # div.foo { - # background: red; - # } - # - class CSS < BlankSlate - - # Create a CSS builder. - # - # out:: Object receiving the markup.1 +out+ must respond to - # <tt><<</tt>. - # indent:: Number of spaces used for indentation (0 implies no - # indentation and no line breaks). - # - def initialize(indent=2) - @indent = indent - @target = [] - @parts = [] - @library = {} - end - - def +(part) - _join_with_op! '+' - self - end - - def >>(part) - _join_with_op! '' - self - end - - def >(part) - _join_with_op! '>' - self - end - - def |(part) - _join_with_op! ',' - self - end - - # Return the target of the builder - def target! - @target * '' - end - - # Create a comment string in the output. - def comment!(comment_text) - @target << "/* #{comment_text} */\n" - end - - def id!(arg, &block) - _start_container('#'+arg.to_s, nil, block_given?) - _css_block(block) if block - _unify_block - self - end - - def class!(arg, &block) - _start_container('.'+arg.to_s, nil, block_given?) - _css_block(block) if block - _unify_block - self - end - - def store!(sym, &block) - @library[sym] = block.to_proc - end - - def group!(*args, &block) - args.each do |arg| - if arg.is_a?(Symbol) - instance_eval(&@library[arg]) - else - instance_eval(&arg) - end - _text ', ' unless arg == args.last - end - if block - _css_block(block) - _unify_block - end - end - - def method_missing(sym, *args, &block) - sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol) - if block - _start_container(sym, args.first) - _css_block(block) - _unify_block - elsif @in_block - _indent - _css_line(sym, *args) - _newline - return self - else - _start_container(sym, args.first, false) - _unify_block - end - self - end - - # "Cargo culted" from Jim who also "cargo culted" it. See xmlbase.rb. - def nil? - false - end - - private - def _unify_block - @target << @parts * '' - @parts = [] - end - - def _join_with_op!(op) - rhs, lhs = @target.pop, @target.pop - @target << "#{lhs} #{op} #{rhs}" - end - - def _text(text) - @parts << text - end - - def _css_block(block) - _newline - _nested_structures(block) - _end_container - _end_block - end - - def _end_block - _newline - _newline - end - - def _newline - _text "\n" - end - - def _indent - _text ' ' * @indent - end - - def _nested_structures(block) - @in_block = true - self.instance_eval(&block) - @in_block = false - end - - def _start_container(sym, atts = {}, with_bracket = true) - selector = sym.to_s - selector << ".#{atts[:class]}" if atts && atts[:class] - selector << '#' + "#{atts[:id]}" if atts && atts[:id] - @parts << "#{selector}#{with_bracket ? ' {' : ''}" - end - - def _end_container - @parts << "}" - end - - def _css_line(sym, *args) - _text("#{sym.to_s.gsub('_','-')}: #{args * ' '};") - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb deleted file mode 100644 index 8bdbd058..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# The XChar library is provided courtesy of Sam Ruby (See -# http://intertwingly.net/stories/2005/09/28/xchar.rb) - -# -------------------------------------------------------------------- - -# If the Builder::XChar module is not currently defined, fail on any -# name clashes in standard library classes. - -module Builder - def self.check_for_name_collision(klass, method_name, defined_constant=nil) - if klass.instance_methods.include?(method_name.to_s) - fail RuntimeError, - "Name Collision: Method '#{method_name}' is already defined in #{klass}" - end - end -end - -if ! defined?(Builder::XChar) - Builder.check_for_name_collision(String, "to_xs") - Builder.check_for_name_collision(Fixnum, "xchr") -end - -###################################################################### -module Builder - - #################################################################### - # XML Character converter, from Sam Ruby: - # (see http://intertwingly.net/stories/2005/09/28/xchar.rb). - # - module XChar # :nodoc: - - # See - # http://intertwingly.net/stories/2004/04/14/i18n.html#CleaningWindows - # for details. - CP1252 = { # :nodoc: - 128 => 8364, # euro sign - 130 => 8218, # single low-9 quotation mark - 131 => 402, # latin small letter f with hook - 132 => 8222, # double low-9 quotation mark - 133 => 8230, # horizontal ellipsis - 134 => 8224, # dagger - 135 => 8225, # double dagger - 136 => 710, # modifier letter circumflex accent - 137 => 8240, # per mille sign - 138 => 352, # latin capital letter s with caron - 139 => 8249, # single left-pointing angle quotation mark - 140 => 338, # latin capital ligature oe - 142 => 381, # latin capital letter z with caron - 145 => 8216, # left single quotation mark - 146 => 8217, # right single quotation mark - 147 => 8220, # left double quotation mark - 148 => 8221, # right double quotation mark - 149 => 8226, # bullet - 150 => 8211, # en dash - 151 => 8212, # em dash - 152 => 732, # small tilde - 153 => 8482, # trade mark sign - 154 => 353, # latin small letter s with caron - 155 => 8250, # single right-pointing angle quotation mark - 156 => 339, # latin small ligature oe - 158 => 382, # latin small letter z with caron - 159 => 376, # latin capital letter y with diaeresis - } - - # See http://www.w3.org/TR/REC-xml/#dt-chardata for details. - PREDEFINED = { - 38 => '&amp;', # ampersand - 60 => '&lt;', # left angle bracket - 62 => '&gt;', # right angle bracket - } - - # See http://www.w3.org/TR/REC-xml/#charsets for details. - VALID = [ - 0x9, 0xA, 0xD, - (0x20..0xD7FF), - (0xE000..0xFFFD), - (0x10000..0x10FFFF) - ] - end - -end - - -###################################################################### -# Enhance the Fixnum class with a XML escaped character conversion. -# -class Fixnum - XChar = Builder::XChar if ! defined?(XChar) - - # XML escaped version of chr - def xchr - n = XChar::CP1252[self] || self - case n when *XChar::VALID - XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};") - else - '*' - end - end -end - - -###################################################################### -# Enhance the String class with a XML escaped character version of -# to_s. -# -class String - # XML escaped version of to_s - def to_xs - unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8 - rescue - unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252 - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb deleted file mode 100644 index ace4b56d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env ruby - -require 'builder/blankslate' - -module Builder - - # Generic error for builder - class IllegalBlockError < RuntimeError; end - - # XmlBase is a base class for building XML builders. See - # Builder::XmlMarkup and Builder::XmlEvents for examples. - class XmlBase < BlankSlate - - # Create an XML markup builder. - # - # out:: Object receiving the markup. +out+ must respond to - # <tt><<</tt>. - # indent:: Number of spaces used for indentation (0 implies no - # indentation and no line breaks). - # initial:: Level of initial indentation. - # - def initialize(indent=0, initial=0) - @indent = indent - @level = initial - end - - # Create a tag named +sym+. Other than the first argument which - # is the tag name, the arguments are the same as the tags - # implemented via <tt>method_missing</tt>. - def tag!(sym, *args, &block) - method_missing(sym.to_sym, *args, &block) - end - - # Create XML markup based on the name of the method. This method - # is never invoked directly, but is called for each markup method - # in the markup block. - def method_missing(sym, *args, &block) - text = nil - attrs = nil - sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol) - args.each do |arg| - case arg - when Hash - attrs ||= {} - attrs.merge!(arg) - else - text ||= '' - text << arg.to_s - end - end - if block - unless text.nil? - raise ArgumentError, "XmlMarkup cannot mix a text argument with a block" - end - _indent - _start_tag(sym, attrs) - _newline - _nested_structures(block) - _indent - _end_tag(sym) - _newline - elsif text.nil? - _indent - _start_tag(sym, attrs, true) - _newline - else - _indent - _start_tag(sym, attrs) - text! text - _end_tag(sym) - _newline - end - @target - end - - # Append text to the output target. Escape any markup. May be - # used within the markup brackets as: - # - # builder.p { |b| b.br; b.text! "HI" } #=> <p><br/>HI</p> - def text!(text) - _text(_escape(text)) - end - - # Append text to the output target without escaping any markup. - # May be used within the markup brackets as: - # - # builder.p { |x| x << "<br/>HI" } #=> <p><br/>HI</p> - # - # This is useful when using non-builder enabled software that - # generates strings. Just insert the string directly into the - # builder without changing the inserted markup. - # - # It is also useful for stacking builder objects. Builders only - # use <tt><<</tt> to append to the target, so by supporting this - # method/operation builders can use other builders as their - # targets. - def <<(text) - _text(text) - end - - # For some reason, nil? is sent to the XmlMarkup object. If nil? - # is not defined and method_missing is invoked, some strange kind - # of recursion happens. Since nil? won't ever be an XML tag, it - # is pretty safe to define it here. (Note: this is an example of - # cargo cult programming, - # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming). - def nil? - false - end - - private - - require 'builder/xchar' - def _escape(text) - text.to_xs - end - - def _escape_quote(text) - _escape(text).gsub(%r{"}, '&quot;') # " WART - end - - def _newline - return if @indent == 0 - text! "\n" - end - - def _indent - return if @indent == 0 || @level == 0 - text!(" " * (@level * @indent)) - end - - def _nested_structures(block) - @level += 1 - block.call(self) - ensure - @level -= 1 - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb deleted file mode 100644 index b373e4da..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env ruby - -#-- -# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -require 'builder/xmlmarkup' - -module Builder - - # Create a series of SAX-like XML events (e.g. start_tag, end_tag) - # from the markup code. XmlEvent objects are used in a way similar - # to XmlMarkup objects, except that a series of events are generated - # and passed to a handler rather than generating character-based - # markup. - # - # Usage: - # xe = Builder::XmlEvents.new(handler) - # xe.title("HI") # Sends start_tag/end_tag/text messages to the handler. - # - # Indentation may also be selected by providing value for the - # indentation size and initial indentation level. - # - # xe = Builder::XmlEvents.new(handler, indent_size, initial_indent_level) - # - # == XML Event Handler - # - # The handler object must expect the following events. - # - # [<tt>start_tag(tag, attrs)</tt>] - # Announces that a new tag has been found. +tag+ is the name of - # the tag and +attrs+ is a hash of attributes for the tag. - # - # [<tt>end_tag(tag)</tt>] - # Announces that an end tag for +tag+ has been found. - # - # [<tt>text(text)</tt>] - # Announces that a string of characters (+text+) has been found. - # A series of characters may be broken up into more than one - # +text+ call, so the client cannot assume that a single - # callback contains all the text data. - # - class XmlEvents < XmlMarkup - def text!(text) - @target.text(text) - end - - def _start_tag(sym, attrs, end_too=false) - @target.start_tag(sym, attrs) - _end_tag(sym) if end_too - end - - def _end_tag(sym) - @target.end_tag(sym) - end - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb deleted file mode 100644 index ec59dddc..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +++ /dev/null @@ -1,328 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -# Provide a flexible and easy to use Builder for creating XML markup. -# See XmlBuilder for usage details. - -require 'builder/xmlbase' - -module Builder - - # Create XML markup easily. All (well, almost all) methods sent to - # an XmlMarkup object will be translated to the equivalent XML - # markup. Any method with a block will be treated as an XML markup - # tag with nested markup in the block. - # - # Examples will demonstrate this easier than words. In the - # following, +xm+ is an +XmlMarkup+ object. - # - # xm.em("emphasized") # => <em>emphasized</em> - # xm.em { xmm.b("emp & bold") } # => <em><b>emph &amp; bold</b></em> - # xm.a("A Link", "href"=>"http://onestepback.org") - # # => <a href="http://onestepback.org">A Link</a> - # xm.div { br } # => <div><br/></div> - # xm.target("name"=>"compile", "option"=>"fast") - # # => <target option="fast" name="compile"\> - # # NOTE: order of attributes is not specified. - # - # xm.instruct! # <?xml version="1.0" encoding="UTF-8"?> - # xm.html { # <html> - # xm.head { # <head> - # xm.title("History") # <title>History</title> - # } # </head> - # xm.body { # <body> - # xm.comment! "HI" # <! -- HI --> - # xm.h1("Header") # <h1>Header</h1> - # xm.p("paragraph") # <p>paragraph</p> - # } # </body> - # } # </html> - # - # == Notes: - # - # * The order that attributes are inserted in markup tags is - # undefined. - # - # * Sometimes you wish to insert text without enclosing tags. Use - # the <tt>text!</tt> method to accomplish this. - # - # Example: - # - # xm.div { # <div> - # xm.text! "line"; xm.br # line<br/> - # xm.text! "another line"; xmbr # another line<br/> - # } # </div> - # - # * The special XML characters <, >, and & are converted to &lt;, - # &gt; and &amp; automatically. Use the <tt><<</tt> operation to - # insert text without modification. - # - # * Sometimes tags use special characters not allowed in ruby - # identifiers. Use the <tt>tag!</tt> method to handle these - # cases. - # - # Example: - # - # xml.tag!("SOAP:Envelope") { ... } - # - # will produce ... - # - # <SOAP:Envelope> ... </SOAP:Envelope>" - # - # <tt>tag!</tt> will also take text and attribute arguments (after - # the tag name) like normal markup methods. (But see the next - # bullet item for a better way to handle XML namespaces). - # - # * Direct support for XML namespaces is now available. If the - # first argument to a tag call is a symbol, it will be joined to - # the tag to produce a namespace:tag combination. It is easier to - # show this than describe it. - # - # xml.SOAP :Envelope do ... end - # - # Just put a space before the colon in a namespace to produce the - # right form for builder (e.g. "<tt>SOAP:Envelope</tt>" => - # "<tt>xml.SOAP :Envelope</tt>") - # - # * XmlMarkup builds the markup in any object (called a _target_) - # that accepts the <tt><<</tt> method. If no target is given, - # then XmlMarkup defaults to a string target. - # - # Examples: - # - # xm = Builder::XmlMarkup.new - # result = xm.title("yada") - # # result is a string containing the markup. - # - # buffer = "" - # xm = Builder::XmlMarkup.new(buffer) - # # The markup is appended to buffer (using <<) - # - # xm = Builder::XmlMarkup.new(STDOUT) - # # The markup is written to STDOUT (using <<) - # - # xm = Builder::XmlMarkup.new - # x2 = Builder::XmlMarkup.new(:target=>xm) - # # Markup written to +x2+ will be send to +xm+. - # - # * Indentation is enabled by providing the number of spaces to - # indent for each level as a second argument to XmlBuilder.new. - # Initial indentation may be specified using a third parameter. - # - # Example: - # - # xm = Builder.new(:indent=>2) - # # xm will produce nicely formatted and indented XML. - # - # xm = Builder.new(:indent=>2, :margin=>4) - # # xm will produce nicely formatted and indented XML with 2 - # # spaces per indent and an over all indentation level of 4. - # - # builder = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2) - # builder.name { |b| b.first("Jim"); b.last("Weirich) } - # # prints: - # # <name> - # # <first>Jim</first> - # # <last>Weirich</last> - # # </name> - # - # * The instance_eval implementation which forces self to refer to - # the message receiver as self is now obsolete. We now use normal - # block calls to execute the markup block. This means that all - # markup methods must now be explicitly send to the xml builder. - # For instance, instead of - # - # xml.div { strong("text") } - # - # you need to write: - # - # xml.div { xml.strong("text") } - # - # Although more verbose, the subtle change in semantics within the - # block was found to be prone to error. To make this change a - # little less cumbersome, the markup block now gets the markup - # object sent as an argument, allowing you to use a shorter alias - # within the block. - # - # For example: - # - # xml_builder = Builder::XmlMarkup.new - # xml_builder.div { |xml| - # xml.stong("text") - # } - # - class XmlMarkup < XmlBase - - # Create an XML markup builder. Parameters are specified by an - # option hash. - # - # :target=><em>target_object</em>:: - # Object receiving the markup. +out+ must respond to the - # <tt><<</tt> operator. The default is a plain string target. - # - # :indent=><em>indentation</em>:: - # Number of spaces used for indentation. The default is no - # indentation and no line breaks. - # - # :margin=><em>initial_indentation_level</em>:: - # Amount of initial indentation (specified in levels, not - # spaces). - # - # :escape_attrs=><b>OBSOLETE</em>:: - # The :escape_attrs option is no longer supported by builder - # (and will be quietly ignored). String attribute values are - # now automatically escaped. If you need unescaped attribute - # values (perhaps you are using entities in the attribute - # values), then give the value as a Symbol. This allows much - # finer control over escaping attribute values. - # - def initialize(options={}) - indent = options[:indent] || 0 - margin = options[:margin] || 0 - super(indent, margin) - @target = options[:target] || "" - end - - # Return the target of the builder. - def target! - @target - end - - def comment!(comment_text) - _ensure_no_block block_given? - _special("<!-- ", " -->", comment_text, nil) - end - - # Insert an XML declaration into the XML markup. - # - # For example: - # - # xml.declare! :ELEMENT, :blah, "yada" - # # => <!ELEMENT blah "yada"> - def declare!(inst, *args, &block) - _indent - @target << "<!#{inst}" - args.each do |arg| - case arg - when String - @target << %{ "#{arg}"} # " WART - when Symbol - @target << " #{arg}" - end - end - if block_given? - @target << " [" - _newline - _nested_structures(block) - @target << "]" - end - @target << ">" - _newline - end - - # Insert a processing instruction into the XML markup. E.g. - # - # For example: - # - # xml.instruct! - # #=> <?xml version="1.0" encoding="UTF-8"?> - # xml.instruct! :aaa, :bbb=>"ccc" - # #=> <?aaa bbb="ccc"?> - # - def instruct!(directive_tag=:xml, attrs={}) - _ensure_no_block block_given? - if directive_tag == :xml - a = { :version=>"1.0", :encoding=>"UTF-8" } - attrs = a.merge attrs - end - _special( - "<?#{directive_tag}", - "?>", - nil, - attrs, - [:version, :encoding, :standalone]) - end - - # Insert a CDATA section into the XML markup. - # - # For example: - # - # xml.cdata!("text to be included in cdata") - # #=> <![CDATA[text to be included in cdata]]> - # - def cdata!(text) - _ensure_no_block block_given? - _special("<![CDATA[", "]]>", text, nil) - end - - private - - # NOTE: All private methods of a builder object are prefixed when - # a "_" character to avoid possible conflict with XML tag names. - - # Insert text directly in to the builder's target. - def _text(text) - @target << text - end - - # Insert special instruction. - def _special(open, close, data=nil, attrs=nil, order=[]) - _indent - @target << open - @target << data if data - _insert_attributes(attrs, order) if attrs - @target << close - _newline - end - - # Start an XML tag. If <tt>end_too</tt> is true, then the start - # tag is also the end tag (e.g. <br/> - def _start_tag(sym, attrs, end_too=false) - @target << "<#{sym}" - _insert_attributes(attrs) - @target << "/" if end_too - @target << ">" - end - - # Insert an ending tag. - def _end_tag(sym) - @target << "</#{sym}>" - end - - # Insert the attributes (given in the hash). - def _insert_attributes(attrs, order=[]) - return if attrs.nil? - order.each do |k| - v = attrs[k] - @target << %{ #{k}="#{_attr_value(v)}"} if v # " WART - end - attrs.each do |k, v| - @target << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k) # " WART - end - end - - def _attr_value(value) - case value - when Symbol - value.to_s - else - _escape_quote(value.to_s) - end - end - - def _ensure_no_block(got_block) - if got_block - fail IllegalBlockError, - "Blocks are not allowed on XML instructions" - end - end - - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n.rb deleted file mode 100755 index 346681e7..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n.rb +++ /dev/null @@ -1,322 +0,0 @@ -# encoding: utf-8 - -# Authors:: Sven Fuchs (http://www.artweb-design.de), -# Joshua Harvey (http://www.workingwithrails.com/person/759-joshua-harvey), -# Stephan Soller (http://www.arkanis-development.de/), -# Saimon Moore (http://saimonmoore.net), -# Matt Aimonetti (http://railsontherun.com/) -# Copyright:: Copyright (c) 2008 The Ruby i18n Team -# License:: MIT -require 'i18n/exceptions' -require 'i18n/core_ext/string/interpolate' - -module I18n - autoload :Backend, 'i18n/backend' - autoload :Config, 'i18n/config' - autoload :Gettext, 'i18n/gettext' - autoload :Locale, 'i18n/locale' - - class << self - # Gets I18n configuration object. - def config - Thread.current[:i18n_config] ||= I18n::Config.new - end - - # Sets I18n configuration object. - def config=(value) - Thread.current[:i18n_config] = value - end - - # Write methods which delegates to the configuration object - %w(locale backend default_locale available_locales default_separator - exception_handler load_path).each do |method| - module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1 - def #{method} - config.#{method} - end - - def #{method}=(value) - config.#{method} = (value) - end - DELEGATORS - end - - # Tells the backend to reload translations. Used in situations like the - # Rails development environment. Backends can implement whatever strategy - # is useful. - def reload! - config.backend.reload! - end - - # Translates, pluralizes and interpolates a given key using a given locale, - # scope, and default, as well as interpolation values. - # - # *LOOKUP* - # - # Translation data is organized as a nested hash using the upper-level keys - # as namespaces. <em>E.g.</em>, ActionView ships with the translation: - # <tt>:date => {:formats => {:short => "%b %d"}}</tt>. - # - # Translations can be looked up at any level of this hash using the key argument - # and the scope option. <em>E.g.</em>, in this example <tt>I18n.t :date</tt> - # returns the whole translations hash <tt>{:formats => {:short => "%b %d"}}</tt>. - # - # Key can be either a single key or a dot-separated key (both Strings and Symbols - # work). <em>E.g.</em>, the short format can be looked up using both: - # I18n.t 'date.formats.short' - # I18n.t :'date.formats.short' - # - # Scope can be either a single key, a dot-separated key or an array of keys - # or dot-separated keys. Keys and scopes can be combined freely. So these - # examples will all look up the same short date format: - # I18n.t 'date.formats.short' - # I18n.t 'formats.short', :scope => 'date' - # I18n.t 'short', :scope => 'date.formats' - # I18n.t 'short', :scope => %w(date formats) - # - # *INTERPOLATION* - # - # Translations can contain interpolation variables which will be replaced by - # values passed to #translate as part of the options hash, with the keys matching - # the interpolation variable names. - # - # <em>E.g.</em>, with a translation <tt>:foo => "foo %{bar}"</tt> the option - # value for the key +bar+ will be interpolated into the translation: - # I18n.t :foo, :bar => 'baz' # => 'foo baz' - # - # *PLURALIZATION* - # - # Translation data can contain pluralized translations. Pluralized translations - # are arrays of singluar/plural versions of translations like <tt>['Foo', 'Foos']</tt>. - # - # Note that <tt>I18n::Backend::Simple</tt> only supports an algorithm for English - # pluralization rules. Other algorithms can be supported by custom backends. - # - # This returns the singular version of a pluralized translation: - # I18n.t :foo, :count => 1 # => 'Foo' - # - # These both return the plural version of a pluralized translation: - # I18n.t :foo, :count => 0 # => 'Foos' - # I18n.t :foo, :count => 2 # => 'Foos' - # - # The <tt>:count</tt> option can be used both for pluralization and interpolation. - # <em>E.g.</em>, with the translation - # <tt>:foo => ['%{count} foo', '%{count} foos']</tt>, count will - # be interpolated to the pluralized translation: - # I18n.t :foo, :count => 1 # => '1 foo' - # - # *DEFAULTS* - # - # This returns the translation for <tt>:foo</tt> or <tt>default</tt> if no translation was found: - # I18n.t :foo, :default => 'default' - # - # This returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> if no - # translation for <tt>:foo</tt> was found: - # I18n.t :foo, :default => :bar - # - # Returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> - # or <tt>default</tt> if no translations for <tt>:foo</tt> and <tt>:bar</tt> were found. - # I18n.t :foo, :default => [:bar, 'default'] - # - # *BULK LOOKUP* - # - # This returns an array with the translations for <tt>:foo</tt> and <tt>:bar</tt>. - # I18n.t [:foo, :bar] - # - # Can be used with dot-separated nested keys: - # I18n.t [:'baz.foo', :'baz.bar'] - # - # Which is the same as using a scope option: - # I18n.t [:foo, :bar], :scope => :baz - # - # *LAMBDAS* - # - # Both translations and defaults can be given as Ruby lambdas. Lambdas will be - # called and passed the key and options. - # - # E.g. assuming the key <tt>:salutation</tt> resolves to: - # lambda { |key, options| options[:gender] == 'm' ? "Mr. %{options[:name]}" : "Mrs. %{options[:name]}" } - # - # Then <tt>I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith". - # - # It is recommended to use/implement lambdas in an "idempotent" way. E.g. when - # a cache layer is put in front of I18n.translate it will generate a cache key - # from the argument values passed to #translate. Therefor your lambdas should - # always return the same translations/values per unique combination of argument - # values. - def translate(*args) - options = args.pop if args.last.is_a?(Hash) - key = args.shift - locale = options && options.delete(:locale) || config.locale - raises = options && options.delete(:raise) - config.backend.translate(locale, key, options || {}) - rescue I18n::ArgumentError => exception - raise exception if raises - handle_exception(exception, locale, key, options) - end - alias :t :translate - - def translate!(key, options = {}) - translate(key, options.merge( :raise => true )) - end - alias :t! :translate! - - # Transliterates UTF-8 characters to ASCII. By default this method will - # transliterate only Latin strings to an ASCII approximation: - # - # I18n.transliterate("Ærøskøbing") - # # => "AEroskobing" - # - # I18n.transliterate("日本語") - # # => "???" - # - # It's also possible to add support for per-locale transliterations. I18n - # expects transliteration rules to be stored at - # <tt>i18n.transliterate.rule</tt>. - # - # Transliteration rules can either be a Hash or a Proc. Procs must accept a - # single string argument. Hash rules inherit the default transliteration - # rules, while Procs do not. - # - # *Examples* - # - # Setting a Hash in <locale>.yml: - # - # i18n: - # transliterate: - # rule: - # ü: "ue" - # ö: "oe" - # - # Setting a Hash using Ruby: - # - # store_translations(:de, :i18n => { - # :transliterate => { - # :rule => { - # "ü" => "ue", - # "ö" => "oe" - # } - # } - # ) - # - # Setting a Proc: - # - # translit = lambda {|string| MyTransliterator.transliterate(string) } - # store_translations(:xx, :i18n => {:transliterate => {:rule => translit}) - # - # Transliterating strings: - # - # I18n.locale = :en - # I18n.transliterate("Jürgen") # => "Jurgen" - # I18n.locale = :de - # I18n.transliterate("Jürgen") # => "Juergen" - # I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen" - # I18n.transliterate("Jürgen", :locale => :de) # => "Juergen" - def transliterate(*args) - options = args.pop if args.last.is_a?(Hash) - key = args.shift - locale = options && options.delete(:locale) || config.locale - raises = options && options.delete(:raise) - replacement = options && options.delete(:replacement) - config.backend.transliterate(locale, key, replacement) - rescue I18n::ArgumentError => exception - raise exception if raises - handle_exception(exception, locale, key, options) - end - - # Localizes certain objects, such as dates and numbers to local formatting. - def localize(object, options = {}) - locale = options.delete(:locale) || config.locale - format = options.delete(:format) || :default - config.backend.localize(locale, object, format, options) - end - alias :l :localize - - # Executes block with given I18n.locale set. - def with_locale(tmp_locale = nil) - if tmp_locale - current_locale = self.locale - self.locale = tmp_locale - end - yield - ensure - self.locale = current_locale if tmp_locale - end - - - # Merges the given locale, key and scope into a single array of keys. - # Splits keys that contain dots into multiple keys. Makes sure all - # keys are Symbols. - def normalize_keys(locale, key, scope, separator = nil) - separator ||= I18n.default_separator - - keys = [] - keys.concat normalize_key(locale, separator) - keys.concat normalize_key(scope, separator) - keys.concat normalize_key(key, separator) - keys - end - - # making these private until Ruby 1.9.2 can send to protected methods again - # see http://redmine.ruby-lang.org/repositories/revision/ruby-19?rev=24280 - private - - # Handles exceptions raised in the backend. All exceptions except for - # MissingTranslationData exceptions are re-raised. When a MissingTranslationData - # was caught and the option :raise is not set the handler returns an error - # message string containing the key/scope. - def default_exception_handler(exception, locale, key, options) - return exception.message if MissingTranslationData === exception - raise exception - end - - # Any exceptions thrown in translate will be sent to the @@exception_handler - # which can be a Symbol, a Proc or any other Object. - # - # If exception_handler is a Symbol then it will simply be sent to I18n as - # a method call. A Proc will simply be called. In any other case the - # method #call will be called on the exception_handler object. - # - # Examples: - # - # I18n.exception_handler = :default_exception_handler # this is the default - # I18n.default_exception_handler(exception, locale, key, options) # will be called like this - # - # I18n.exception_handler = lambda { |*args| ... } # a lambda - # I18n.exception_handler.call(exception, locale, key, options) # will be called like this - # - # I18n.exception_handler = I18nExceptionHandler.new # an object - # I18n.exception_handler.call(exception, locale, key, options) # will be called like this - def handle_exception(exception, locale, key, options) - case config.exception_handler - when Symbol - send(config.exception_handler, exception, locale, key, options) - else - config.exception_handler.call(exception, locale, key, options) - end - end - - # Deprecated. Will raise a warning in future versions and then finally be - # removed. Use I18n.normalize_keys instead. - def normalize_translation_keys(locale, key, scope, separator = nil) - normalize_keys(locale, key, scope, separator) - end - - def normalize_key(key, separator) - normalized_key_cache[separator][key] ||= - case key - when Array - key.map { |k| normalize_key(k, separator) }.flatten - else - keys = key.to_s.split(separator) - keys.delete('') - keys.map!{ |k| k.to_sym } - keys - end - end - - def normalized_key_cache - @normalized_key_cache ||= Hash.new { |h,k| h[k] = {} } - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend.rb deleted file mode 100644 index fe65fb48..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend.rb +++ /dev/null @@ -1,20 +0,0 @@ -module I18n - module Backend - autoload :ActiveRecord, 'i18n/backend/active_record' - autoload :Base, 'i18n/backend/base' - autoload :InterpolationCompiler, 'i18n/backend/interpolation_compiler' - autoload :Cache, 'i18n/backend/cache' - autoload :Cascade, 'i18n/backend/cascade' - autoload :Chain, 'i18n/backend/chain' - autoload :Cldr, 'i18n/backend/cldr' - autoload :Fallbacks, 'i18n/backend/fallbacks' - autoload :Flatten, 'i18n/backend/flatten' - autoload :Gettext, 'i18n/backend/gettext' - autoload :KeyValue, 'i18n/backend/key_value' - autoload :Memoize, 'i18n/backend/memoize' - autoload :Metadata, 'i18n/backend/metadata' - autoload :Pluralization, 'i18n/backend/pluralization' - autoload :Simple, 'i18n/backend/simple' - autoload :Transliterator, 'i18n/backend/transliterator' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record.rb deleted file mode 100644 index b60f138d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'i18n/backend/base' -require 'i18n/backend/active_record/translation' - -module I18n - module Backend - class ActiveRecord - autoload :Missing, 'i18n/backend/active_record/missing' - autoload :StoreProcs, 'i18n/backend/active_record/store_procs' - autoload :Translation, 'i18n/backend/active_record/translation' - - module Implementation - include Base, Flatten - - def available_locales - begin - Translation.available_locales - rescue ::ActiveRecord::StatementInvalid - [] - end - end - - def store_translations(locale, data, options = {}) - escape = options.fetch(:escape, true) - flatten_translations(locale, data, escape, false).each do |key, value| - Translation.locale(locale).lookup(expand_keys(key)).delete_all - Translation.create(:locale => locale.to_s, :key => key.to_s, :value => value) - end - end - - protected - - def lookup(locale, key, scope = [], options = {}) - key = normalize_flat_keys(locale, key, scope, options[:separator]) - result = Translation.locale(locale).lookup(key).all - - if result.empty? - nil - elsif result.first.key == key - result.first.value - else - chop_range = (key.size + FLATTEN_SEPARATOR.size)..-1 - result = result.inject({}) do |hash, r| - hash[r.key.slice(chop_range)] = r.value - hash - end - result.deep_symbolize_keys - end - end - - # For a key :'foo.bar.baz' return ['foo', 'foo.bar', 'foo.bar.baz'] - def expand_keys(key) - key.to_s.split(FLATTEN_SEPARATOR).inject([]) do |keys, key| - keys << [keys.last, key].compact.join(FLATTEN_SEPARATOR) - end - end - end - - include Implementation - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb deleted file mode 100644 index 0eafcb29..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb +++ /dev/null @@ -1,65 +0,0 @@ -# This extension stores translation stub records for missing translations to -# the database. -# -# This is useful if you have a web based translation tool. It will populate -# the database with untranslated keys as the application is being used. A -# translator can then go through these and add missing translations. -# -# Example usage: -# -# I18n::Backend::Chain.send(:include, I18n::Backend::ActiveRecord::Missing) -# I18n.backend = I18nChainBackend.new(I18n::Backend::ActiveRecord.new, I18n::Backend::Simple.new) -# -# Stub records for pluralizations will also be created for each key defined -# in i18n.plural.keys. -# -# For example: -# -# # en.yml -# en: -# i18n: -# plural: -# keys: [:zero, :one, :other] -# -# # pl.yml -# pl: -# i18n: -# plural: -# keys: [:zero, :one, :few, :other] -# -# It will also persist interpolation keys in Translation#interpolations so -# translators will be able to review and use them. -module I18n - module Backend - class ActiveRecord - module Missing - def store_default_translations(locale, key, options = {}) - count, scope, default, separator = options.values_at(:count, *Base::RESERVED_KEYS) - separator ||= I18n.default_separator - - keys = I18n.normalize_keys(locale, key, scope, separator)[1..-1] - key = keys.join(separator || I18n.default_separator) - - unless ActiveRecord::Translation.locale(locale).lookup(key).exists? - interpolations = options.reject { |name, value| Base::RESERVED_KEYS.include?(name) }.keys - keys = count ? I18n.t('i18n.plural.keys', :locale => locale).map { |k| [key, k].join(separator) } : [key] - keys.each { |key| store_default_translation(locale, key, interpolations) } - end - end - - def store_default_translation(locale, key, interpolations) - translation = ActiveRecord::Translation.new :locale => locale.to_s, :key => key - translation.interpolations = interpolations - translation.save - end - - def translate(locale, key, options = {}) - super - rescue I18n::MissingTranslationData => e - self.store_default_translations(locale, key, options) - raise e - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/store_procs.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/store_procs.rb deleted file mode 100644 index 652b1aaa..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/store_procs.rb +++ /dev/null @@ -1,38 +0,0 @@ -# This module is intended to be mixed into the ActiveRecord backend to allow -# storing Ruby Procs as translation values in the database. -# -# I18n.backend = I18n::Backend::ActiveRecord.new -# I18n::Backend::ActiveRecord::Translation.send(:include, I18n::Backend::ActiveRecord::StoreProcs) -# -# The StoreProcs module requires the ParseTree and ruby2ruby gems and therefor -# was extracted from the original backend. -# -# ParseTree is not compatible with Ruby 1.9. - -begin - require 'ruby2ruby' - require 'parse_tree' - require 'parse_tree_extensions' -rescue LoadError => e - puts "can't use StoreProcs because: #{e.message}" -end - -module I18n - module Backend - class ActiveRecord - module StoreProcs - def value=(v) - case v - when Proc - write_attribute(:value, v.to_ruby) - write_attribute(:is_proc, true) - else - write_attribute(:value, v) - end - end - - Translation.send(:include, self) if method(:to_s).respond_to?(:to_ruby) - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/translation.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/translation.rb deleted file mode 100644 index 9e382975..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/translation.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'active_record' - -module I18n - module Backend - # ActiveRecord model used to store actual translations to the database. - # - # This model expects a table like the following to be already set up in - # your the database: - # - # create_table :translations do |t| - # t.string :locale - # t.string :key - # t.text :value - # t.text :interpolations - # t.boolean :is_proc, :default => false - # end - # - # This model supports to named scopes :locale and :lookup. The :locale - # scope simply adds a condition for a given locale: - # - # I18n::Backend::ActiveRecord::Translation.locale(:en).all - # # => all translation records that belong to the :en locale - # - # The :lookup scope adds a condition for looking up all translations - # that either start with the given keys (joined by an optionally given - # separator or I18n.default_separator) or that exactly have this key. - # - # # with translations present for :"foo.bar" and :"foo.baz" - # I18n::Backend::ActiveRecord::Translation.lookup(:foo) - # # => an array with both translation records :"foo.bar" and :"foo.baz" - # - # I18n::Backend::ActiveRecord::Translation.lookup([:foo, :bar]) - # I18n::Backend::ActiveRecord::Translation.lookup(:"foo.bar") - # # => an array with the translation record :"foo.bar" - # - # When the StoreProcs module was mixed into this model then Procs will - # be stored to the database as Ruby code and evaluated when :value is - # called. - # - # Translation = I18n::Backend::ActiveRecord::Translation - # Translation.create \ - # :locale => 'en' - # :key => 'foo' - # :value => lambda { |key, options| 'FOO' } - # Translation.find_by_locale_and_key('en', 'foo').value - # # => 'FOO' - class ActiveRecord - class Translation < ::ActiveRecord::Base - set_table_name 'translations' - attr_protected :is_proc, :interpolations - - serialize :value - serialize :interpolations, Array - - scope_method = ::ActiveRecord::VERSION::MAJOR == 2 ? :named_scope : :scope - - send scope_method, :locale, lambda { |locale| - { :conditions => { :locale => locale.to_s } } - } - - send scope_method, :lookup, lambda { |keys, *separator| - column_name = connection.quote_column_name('key') - keys = Array(keys).map! { |key| key.to_s } - - unless separator.empty? - warn "[DEPRECATION] Giving a separator to Translation.lookup is deprecated. " << - "You can change the internal separator by overwriting FLATTEN_SEPARATOR." - end - - namespace = "#{keys.last}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%" - { :conditions => ["#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace] } - } - - def self.available_locales - Translation.find(:all, :select => 'DISTINCT locale').map { |t| t.locale.to_sym } - end - - def interpolates?(key) - self.interpolations.include?(key) if self.interpolations - end - - def value - if is_proc - Kernel.eval(read_attribute(:value)) - else - value = read_attribute(:value) - value == 'f' ? false : value - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb deleted file mode 100644 index 32725587..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb +++ /dev/null @@ -1,237 +0,0 @@ -# encoding: utf-8 - -require 'yaml' -require 'i18n/core_ext/hash' - -module I18n - module Backend - module Base - include I18n::Backend::Transliterator - - RESERVED_KEYS = [:scope, :default, :separator, :resolve] - RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/ - DEPRECATED_INTERPOLATION_SYNTAX_PATTERN = /(\\)?\{\{([^\}]+)\}\}/ - INTERPOLATION_SYNTAX_PATTERN = /%\{([^\}]+)\}/ - - # Accepts a list of paths to translation files. Loads translations from - # plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml - # for details. - def load_translations(*filenames) - filenames = I18n.load_path.flatten if filenames.empty? - filenames.each { |filename| load_file(filename) } - end - - # This method receives a locale, a data hash and options for storing translations. - # Should be implemented - def store_translations(locale, data, options = {}) - raise NotImplementedError - end - - def translate(locale, key, options = {}) - raise InvalidLocale.new(locale) unless locale - return key.map { |k| translate(locale, k, options) } if key.is_a?(Array) - - entry = key && lookup(locale, key, options[:scope], options) - - if options.empty? - entry = resolve(locale, key, entry, options) - else - count, default = options.values_at(:count, :default) - values = options.except(*RESERVED_KEYS) - entry = entry.nil? && default ? - default(locale, key, default, options) : resolve(locale, key, entry, options) - end - - raise(I18n::MissingTranslationData.new(locale, key, options)) if entry.nil? - entry = entry.dup if entry.is_a?(String) - - entry = pluralize(locale, entry, count) if count - entry = interpolate(locale, entry, values) if values - entry - end - - # Acts the same as +strftime+, but uses a localized version of the - # format string. Takes a key from the date/time formats translations as - # a format argument (<em>e.g.</em>, <tt>:short</tt> in <tt>:'date.formats'</tt>). - def localize(locale, object, format = :default, options = {}) - raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) - - if Symbol === format - key = format - type = object.respond_to?(:sec) ? 'time' : 'date' - format = I18n.t(:"#{type}.formats.#{key}", options.merge(:raise => true, :object => object, :locale => locale)) - end - - # format = resolve(locale, object, format, options) - format = format.to_s.gsub(/%[aAbBp]/) do |match| - case match - when '%a' then I18n.t(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday] - when '%A' then I18n.t(:"date.day_names", :locale => locale, :format => format)[object.wday] - when '%b' then I18n.t(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon] - when '%B' then I18n.t(:"date.month_names", :locale => locale, :format => format)[object.mon] - when '%p' then I18n.t(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format) if object.respond_to? :hour - end - end - - object.strftime(format) - end - - # Returns an array of locales for which translations are available - # ignoring the reserved translation meta data key :i18n. - def available_locales - raise NotImplementedError - end - - def reload! - @skip_syntax_deprecation = false - end - - protected - - # The method which actually looks up for the translation in the store. - def lookup(locale, key, scope = [], options = {}) - raise NotImplementedError - end - - # Evaluates defaults. - # If given subject is an Array, it walks the array and returns the - # first translation that can be resolved. Otherwise it tries to resolve - # the translation directly. - def default(locale, object, subject, options = {}) - options = options.dup.reject { |key, value| key == :default } - case subject - when Array - subject.each do |item| - result = resolve(locale, object, item, options) and return result - end and nil - else - resolve(locale, object, subject, options) - end - end - - # Resolves a translation. - # If the given subject is a Symbol, it will be translated with the - # given options. If it is a Proc then it will be evaluated. All other - # subjects will be returned directly. - def resolve(locale, object, subject, options = nil) - return subject if options[:resolve] == false - case subject - when Symbol - I18n.translate(subject, (options || {}).merge(:locale => locale, :raise => true)) - when Proc - date_or_time = options.delete(:object) || object - resolve(locale, object, subject.call(date_or_time, options), options = {}) - else - subject - end - rescue MissingTranslationData - nil - end - - # Picks a translation from an array according to English pluralization - # rules. It will pick the first translation if count is not equal to 1 - # and the second translation if it is equal to 1. Other backends can - # implement more flexible or complex pluralization rules. - def pluralize(locale, entry, count) - return entry unless entry.is_a?(Hash) && count - - key = :zero if count == 0 && entry.has_key?(:zero) - key ||= count == 1 ? :one : :other - raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) - entry[key] - end - - # Interpolates values into a given string. - # - # interpolate "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X' - # # => "file test.txt opened by %{user}" - # - # Note that you have to double escape the <tt>\\</tt> when you want to escape - # the <tt>{{...}}</tt> key in a string (once for the string and once for the - # interpolation). - def interpolate(locale, string, values = {}) - return string unless string.is_a?(::String) && !values.empty? - original_values = values.dup - - preserve_encoding(string) do - string = string.gsub(DEPRECATED_INTERPOLATION_SYNTAX_PATTERN) do - escaped, key = $1, $2.to_sym - if escaped - "{{#{key}}}" - else - warn_syntax_deprecation! - "%{#{key}}" - end - end - - keys = string.scan(INTERPOLATION_SYNTAX_PATTERN).flatten - return string if keys.empty? - - values.each do |key, value| - if keys.include?(key.to_s) - value = value.call(values) if interpolate_lambda?(value, string, key) - value = value.to_s unless value.is_a?(::String) - values[key] = value - else - values.delete(key) - end - end - - string % values - end - rescue KeyError => e - if string =~ RESERVED_KEYS_PATTERN - raise ReservedInterpolationKey.new($1.to_sym, string) - else - raise MissingInterpolationArgument.new(original_values, string) - end - end - - def preserve_encoding(string) - if string.respond_to?(:encoding) - encoding = string.encoding - result = yield - result.force_encoding(encoding) if result.respond_to?(:force_encoding) - result - else - yield - end - end - - # returns true when the given value responds to :call and the key is - # an interpolation placeholder in the given string - def interpolate_lambda?(object, string, key) - object.respond_to?(:call) && string =~ /%\{#{key}\}|%\<#{key}>.*?\d*\.?\d*[bBdiouxXeEfgGcps]\}/ - end - - # Loads a single translations file by delegating to #load_rb or - # #load_yml depending on the file extension and directly merges the - # data to the existing translations. Raises I18n::UnknownFileType - # for all other file extensions. - def load_file(filename) - type = File.extname(filename).tr('.', '').downcase - raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}") - data = send(:"load_#{type}", filename) # TODO raise a meaningful exception if this does not yield a Hash - data.each { |locale, d| store_translations(locale, d) } - end - - # Loads a plain Ruby translations file. eval'ing the file must yield - # a Hash containing translation data with locales as toplevel keys. - def load_rb(filename) - eval(IO.read(filename), binding, filename) - end - - # Loads a YAML translations file. The data must have locales as - # toplevel keys. - def load_yml(filename) - YAML::load(IO.read(filename)) - end - - def warn_syntax_deprecation! #:nodoc: - return if @skip_syntax_deprecation - warn "The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.\n#{caller.join("\n")}" - @skip_syntax_deprecation = true - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cache.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cache.rb deleted file mode 100644 index 25e6001d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cache.rb +++ /dev/null @@ -1,77 +0,0 @@ -# encoding: utf-8 - -# This module allows you to easily cache all responses from the backend - thus -# speeding up the I18n aspects of your application quite a bit. -# -# To enable caching you can simply include the Cache module to the Simple -# backend - or whatever other backend you are using: -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Cache) -# -# You will also need to set a cache store implementation that you want to use: -# -# I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store) -# -# You can use any cache implementation you want that provides the same API as -# ActiveSupport::Cache (only the methods #fetch and #write are being used). -# -# The cache_key implementation assumes that you only pass values to -# I18n.translate that return a valid key from #hash (see -# http://www.ruby-doc.org/core/classes/Object.html#M000337). -module I18n - class << self - @@cache_store = nil - @@cache_namespace = nil - - def cache_store - @@cache_store - end - - def cache_store=(store) - @@cache_store = store - end - - def cache_namespace - @@cache_namespace - end - - def cache_namespace=(namespace) - @@cache_namespace = namespace - end - - def perform_caching? - !cache_store.nil? - end - end - - module Backend - # TODO Should the cache be cleared if new translations are stored? - module Cache - def translate(*args) - I18n.perform_caching? ? fetch(*args) { super } : super - end - - protected - - def fetch(*args, &block) - result = I18n.cache_store.fetch(cache_key(*args), &block) - raise result if result.is_a?(Exception) - result = result.dup if result.frozen? rescue result - result - rescue MissingTranslationData => exception - I18n.cache_store.write(cache_key(*args), exception) - raise exception - end - - def cache_key(*args) - # This assumes that only simple, native Ruby values are passed to I18n.translate. - # Also, in Ruby < 1.8.7 {}.hash != {}.hash - # (see http://paulbarry.com/articles/2009/09/14/why-rails-3-will-require-ruby-1-8-7) - # If args.inspect does not work for you for some reason, patches are very welcome :) - hash = RUBY_VERSION >= "1.8.7" ? args.hash : args.inspect - keys = ['i18n', I18n.cache_namespace, hash] - keys.compact.join('-') - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cascade.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cascade.rb deleted file mode 100644 index 370fb481..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cascade.rb +++ /dev/null @@ -1,57 +0,0 @@ -# encoding: utf-8 - -# EXPERIMENTAL -# -# The Cascade module adds the ability to do cascading lookups to backends that -# are compatible to the Simple backend. -# -# By cascading lookups we mean that for any key that can not be found the -# Cascade module strips one segment off the scope part of the key and then -# tries to look up the key in that scope. -# -# E.g. when a lookup for the key :"foo.bar.baz" does not yield a result then -# the segment :bar will be stripped off the scope part :"foo.bar" and the new -# scope :foo will be used to look up the key :baz. If that does not succeed -# then the remaining scope segment :foo will be omitted, too, and again the -# key :baz will be looked up (now with no scope). -# -# To enable a cascading lookup one passes the :cascade option: -# -# I18n.t(:'foo.bar.baz', :cascade => true) -# -# This will return the first translation found for :"foo.bar.baz", :"foo.baz" -# or :baz in this order. -# -# The cascading lookup takes precedence over resolving any given defaults. -# I.e. defaults will kick in after the cascading lookups haven't succeeded. -# -# This behavior is useful for libraries like ActiveRecord validations where -# the library wants to give users a bunch of more or less fine-grained options -# of scopes for a particular key. -# -# Thanks to Clemens Kofler for the initial idea and implementation! See -# http://github.com/clemens/i18n-cascading-backend - -module I18n - module Backend - module Cascade - def lookup(locale, key, scope = [], options = {}) - return super unless cascade = options[:cascade] - - separator = options[:separator] || I18n.default_separator - skip_root = cascade.has_key?(:skip_root) ? cascade[:skip_root] : true - step = cascade[:step] - - keys = I18n.normalize_keys(nil, key, nil, separator) - offset = options[:cascade][:offset] || keys.length - scope = I18n.normalize_keys(nil, nil, scope, separator) + keys - key = scope.slice!(-offset, offset).join(separator) - - begin - result = super - return result unless result.nil? - end while !scope.empty? && scope.slice!(-step, step) && (!scope.empty? || !skip_root) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/chain.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/chain.rb deleted file mode 100644 index f73a69f9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/chain.rb +++ /dev/null @@ -1,77 +0,0 @@ -# encoding: utf-8 - -module I18n - module Backend - # Backend that chains multiple other backends and checks each of them when - # a translation needs to be looked up. This is useful when you want to use - # standard translations with a Simple backend but store custom application - # translations in a database or other backends. - # - # To use the Chain backend instantiate it and set it to the I18n module. - # You can add chained backends through the initializer or backends - # accessor: - # - # # preserves the existing Simple backend set to I18n.backend - # I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend) - # - # The implementation assumes that all backends added to the Chain implement - # a lookup method with the same API as Simple backend does. - class Chain - include Base - - attr_accessor :backends - - def initialize(*backends) - self.backends = backends - end - - def reload! - backends.each { |backend| backend.reload! } - end - - def store_translations(locale, data, options = {}) - backends.first.store_translations(locale, data, options = {}) - end - - def available_locales - backends.map { |backend| backend.available_locales }.flatten.uniq - end - - def translate(locale, key, options = {}) - return key.map { |k| translate(locale, k, options) } if key.is_a?(Array) - - default = options.delete(:default) - namespace = {} - backends.each do |backend| - begin - options.update(:default => default) if default and backend == backends.last - translation = backend.translate(locale, key, options) - if namespace_lookup?(translation, options) - namespace.update(translation) - elsif !translation.nil? - return translation - end - rescue MissingTranslationData - end - end - return namespace unless namespace.empty? - raise(I18n::MissingTranslationData.new(locale, key, options)) - end - - def localize(locale, object, format = :default, options = {}) - backends.each do |backend| - begin - result = backend.localize(locale, object, format, options) and return result - rescue MissingTranslationData - end - end - raise(I18n::MissingTranslationData.new(locale, format, options)) - end - - protected - def namespace_lookup?(result, options) - result.is_a?(Hash) and not options.has_key?(:count) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cldr.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cldr.rb deleted file mode 100644 index d702f224..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/cldr.rb +++ /dev/null @@ -1,100 +0,0 @@ -# encoding: utf-8 -require 'cldr' - -module I18n - module Backend - module Cldr - include ::Cldr::Format - - def localize(locale, object, format = :default, options = {}) - options[:as] ||= detect_type(object, options) - send(:"format_#{options[:as]}", locale, object, format, options) - end - - def format_decimal(locale, object, format = :default, options = {}) - formatter(locale, :decimal, format).apply(object, options) - end - - def format_integer(locale, object, format = :default, options = {}) - format_object(number, options.merge(:precision => 0)) - end - - def format_currency(locale, object, format = :default, options = {}) - options.merge!(:currency => lookup_currency(locale, options[:currency], object)) if options[:currency].is_a?(Symbol) - formatter(locale, :currency, format).apply(object, options) - end - - def format_percent(locale, object, format = :default, options = {}) - formatter(locale, :percent, format).apply(object, options) - end - - def format_date(locale, object, format = :default, options = {}) - formatter(locale, :date, format).apply(object, options) - end - - def format_time(locale, object, format = :default, options = {}) - formatter(locale, :time, format).apply(object, options) - end - - def format_datetime(locale, object, format = :default, options = {}) - key = :"calendars.gregorian.formats.datetime.#{format}.pattern" - date = I18n.l(object, :format => options[:date_format] || format, :locale => locale, :as => :date) - time = I18n.l(object, :format => options[:time_format] || format, :locale => locale, :as => :time) - I18n.t(key, :date => date, :time => time, :locale => locale, :raise => true) - end - - protected - - def detect_type(object, options) - options.has_key?(:currency) ? :currency : case object - when ::Numeric - :decimal - when ::Date, ::DateTime, ::Time - object.class.name.downcase.to_sym - else - raise_unspecified_format_type! - end - end - - def formatter(locale, type, format) - (@formatters ||= {})[:"#{locale}.#{type}.#{format}"] ||= begin - format = lookup_format(locale, type, format) - data = lookup_format_data(locale, type) - ::Cldr::Format.const_get(type.to_s.camelize).new(format, data) - end - end - - def lookup_format(locale, type, format) - key = case type - when :date, :time, :datetime - :"calendars.gregorian.formats.#{type}.#{format}.pattern" - else - :"numbers.formats.#{type}.patterns.#{format || :default}" - end - I18n.t(key, :locale => locale, :raise => true) - end - - def lookup_format_data(locale, type) - key = case type - when :date, :time, :datetime - :'calendars.gregorian' - else - :'numbers.symbols' - end - I18n.t(key, :locale => locale, :raise => true) - end - - def lookup_currency(locale, currency, count) - I18n.t(:"currencies.#{currency}", :locale => locale, :count => count) - end - - def raise_unspecified_format_type! - raise ArgumentError.new("You have to specify a format type, e.g. :as => :number.") - end - - def raise_unspecified_currency! - raise ArgumentError.new("You have to specify a currency, e.g. :currency => 'EUR'.") - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/fallbacks.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/fallbacks.rb deleted file mode 100644 index 1e014be7..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/fallbacks.rb +++ /dev/null @@ -1,69 +0,0 @@ -# encoding: utf-8 - -# I18n locale fallbacks are useful when you want your application to use -# translations from other locales when translations for the current locale are -# missing. E.g. you might want to use :en translations when translations in -# your applications main locale :de are missing. -# -# To enable locale fallbacks you can simply include the Fallbacks module to -# the Simple backend - or whatever other backend you are using: -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) -module I18n - @@fallbacks = nil - - class << self - # Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+. - def fallbacks - @@fallbacks ||= I18n::Locale::Fallbacks.new - end - - # Sets the current fallbacks implementation. Use this to set a different fallbacks implementation. - def fallbacks=(fallbacks) - @@fallbacks = fallbacks - end - end - - module Backend - module Fallbacks - # Overwrites the Base backend translate method so that it will try each - # locale given by I18n.fallbacks for the given locale. E.g. for the - # locale :"de-DE" it might try the locales :"de-DE", :de and :en - # (depends on the fallbacks implementation) until it finds a result with - # the given options. If it does not find any result for any of the - # locales it will then raise a MissingTranslationData exception as - # usual. - # - # The default option takes precedence over fallback locales - # only when it's not a String. When default contains String it - # is evaluated after fallback locales. - def translate(locale, key, options = {}) - default = extract_string_default!(options) if options[:default] - - I18n.fallbacks[locale].each do |fallback| - begin - result = super(fallback, key, options) - return result unless result.nil? - rescue I18n::MissingTranslationData - end - end - - return super(locale, nil, options.merge(:default => default)) if default - raise(I18n::MissingTranslationData.new(locale, key, options)) - end - - def extract_string_default!(options) - defaults = Array(options[:default]) - if index = find_first_string_default(defaults) - options[:default] = defaults[0, index] - defaults[index] - end - end - - def find_first_string_default(defaults) - defaults.each_index { |ix| return ix if String === defaults[ix] } - nil - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/flatten.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/flatten.rb deleted file mode 100644 index c23f7c13..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/flatten.rb +++ /dev/null @@ -1,113 +0,0 @@ -module I18n - module Backend - # This module contains several helpers to assist flattening translations. - # You may want to flatten translations for: - # - # 1) speed up lookups, as in the Memoize backend; - # 2) In case you want to store translations in a data store, as in ActiveRecord backend; - # - # You can check both backends above for some examples. - # This module also keeps all links in a hash so they can be properly resolved when flattened. - module Flatten - SEPARATOR_ESCAPE_CHAR = "\001" - FLATTEN_SEPARATOR = "." - - # normalize_keys the flatten way. This method is significantly faster - # and creates way less objects than the one at I18n.normalize_keys. - # It also handles escaping the translation keys. - def self.normalize_flat_keys(locale, key, scope, separator) - keys = [scope, key].flatten.compact - separator ||= I18n.default_separator - - if separator != FLATTEN_SEPARATOR - keys.map! do |k| - k.to_s.tr("#{FLATTEN_SEPARATOR}#{separator}", - "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}") - end - end - - keys.join(".") - end - - # Receives a string and escape the default separator. - def self.escape_default_separator(key) #:nodoc: - key.to_s.tr(FLATTEN_SEPARATOR, SEPARATOR_ESCAPE_CHAR) - end - - # Shortcut to I18n::Backend::Flatten.normalize_flat_keys - # and then resolve_links. - def normalize_flat_keys(locale, key, scope, separator) - key = I18n::Backend::Flatten.normalize_flat_keys(locale, key, scope, separator) - resolve_link(locale, key) - end - - # Store flattened links. - def links - @links ||= Hash.new { |h,k| h[k] = {} } - end - - # Flatten keys for nested Hashes by chaining up keys: - # - # >> { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}.wind - # => { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i" => "j" } - # - def flatten_keys(hash, escape, prev_key=nil, &block) - hash.each_pair do |key, value| - key = escape_default_separator(key) if escape - curr_key = [prev_key, key].compact.join(FLATTEN_SEPARATOR).to_sym - yield curr_key, value - flatten_keys(value, escape, curr_key, &block) if value.is_a?(Hash) - end - end - - # Receives a hash of translations (where the key is a locale and - # the value is another hash) and return a hash with all - # translations flattened. - # - # Nested hashes are included in the flattened hash just if subtree - # is true and Symbols are automatically stored as links. - def flatten_translations(locale, data, escape, subtree) - hash = {} - flatten_keys(data, escape) do |key, value| - if value.is_a?(Hash) - hash[key] = value if subtree - else - store_link(locale, key, value) if value.is_a?(Symbol) - hash[key] = value - end - end - hash - end - - protected - - def store_link(locale, key, link) - links[locale.to_sym][key.to_s] = link.to_s - end - - def resolve_link(locale, key) - key, locale = key.to_s, locale.to_sym - links = self.links[locale] - - if links.key?(key) - links[key] - elsif link = find_link(locale, key) - store_link(locale, key, key.gsub(*link)) - else - key - end - end - - def find_link(locale, key) #:nodoc: - links[locale].each do |from, to| - return [from, to] if key[0, from.length] == from - end && nil - end - - def escape_default_separator(key) #:nodoc: - I18n::Backend::Flatten.escape_default_separator(key) - end - - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/gettext.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/gettext.rb deleted file mode 100644 index 7f8ad22a..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/gettext.rb +++ /dev/null @@ -1,75 +0,0 @@ -# encoding: utf-8 - -require 'i18n/gettext' -require 'i18n/gettext/po_parser' - -# Experimental support for using Gettext po files to store translations. -# -# To use this you can simply include the module to the Simple backend - or -# whatever other backend you are using. -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Gettext) -# -# Now you should be able to include your Gettext translation (*.po) files to -# the I18n.load_path so they're loaded to the backend and you can use them as -# usual: -# -# I18n.load_path += Dir["path/to/locales/*.po"] -# -# Following the Gettext convention this implementation expects that your -# translation files are named by their locales. E.g. the file en.po would -# contain the translations for the English locale. -module I18n - module Backend - module Gettext - class PoData < Hash - def set_comment(msgid_or_sym, comment) - # ignore - end - end - - protected - def load_po(filename) - locale = ::File.basename(filename, '.po').to_sym - data = normalize(locale, parse(filename)) - { locale => data } - end - - def parse(filename) - GetText::PoParser.new.parse(::File.read(filename), PoData.new) - end - - def normalize(locale, data) - data.inject({}) do |result, (key, value)| - unless key.nil? || key.empty? - key, value = normalize_pluralization(locale, key, value) if key.index("\000") - - parts = key.split('|').reverse - normalized = parts.inject({}) do |normalized, part| - normalized = { part => normalized.empty? ? value : normalized } - end - - # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 - merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } - result.merge!(normalized, &merger) - end - result - end - end - - def normalize_pluralization(locale, key, value) - # FIXME po_parser includes \000 chars that can not be turned into Symbols - key = key.gsub("\000", I18n::Gettext::PLURAL_SEPARATOR).split(I18n::Gettext::PLURAL_SEPARATOR).first - - keys = I18n::Gettext.plural_keys(locale) - values = value.split("\000") - raise "invalid number of plurals: #{values.size}, keys: #{keys.inspect}" if values.size != keys.size - - result = {} - values.each_with_index { |value, ix| result[keys[ix]] = value } - [key, result] - end - - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb deleted file mode 100644 index 8c7c9c91..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb +++ /dev/null @@ -1,123 +0,0 @@ -# encoding: utf-8 - -# The InterpolationCompiler module contains optimizations that can tremendously -# speed up the interpolation process on the Simple backend. -# -# It works by defining a pre-compiled method on stored translation Strings that -# already bring all the knowledge about contained interpolation variables etc. -# so that the actual recurring interpolation will be very fast. -# -# To enable pre-compiled interpolations you can simply include the -# InterpolationCompiler module to the Simple backend: -# -# I18n::Backend::Simple.send(:include, I18n::Backend::InterpolationCompiler) -# -# Note that InterpolationCompiler does not yield meaningful results and consequently -# should not be used with Ruby 1.9 (YARV) but improves performance everywhere else -# (jRuby, Rubinius and 1.8.7). -module I18n - module Backend - module InterpolationCompiler - module Compiler - extend self - - TOKENIZER = /(%%\{[^\}]+\}|%\{[^\}]+\})/ - INTERPOLATION_SYNTAX_PATTERN = /(%)?(%\{([^\}]+)\})/ - - def compile_if_an_interpolation(string) - if interpolated_str?(string) - string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ - def i18n_interpolate(v = {}) - "#{compiled_interpolation_body(string)}" - end - RUBY_EVAL - end - - string - end - - def interpolated_str?(str) - str.kind_of?(::String) && str =~ INTERPOLATION_SYNTAX_PATTERN - end - - protected - # tokenize("foo %{bar} baz %%{buz}") # => ["foo ", "%{bar}", " baz ", "%%{buz}"] - def tokenize(str) - str.split(TOKENIZER) - end - - def compiled_interpolation_body(str) - tokenize(str).map do |token| - (matchdata = token.match(INTERPOLATION_SYNTAX_PATTERN)) ? handle_interpolation_token(token, matchdata) : escape_plain_str(token) - end.join - end - - def handle_interpolation_token(interpolation, matchdata) - escaped, pattern, key = matchdata.values_at(1, 2, 3) - escaped ? pattern : compile_interpolation_token(key.to_sym) - end - - def compile_interpolation_token(key) - "\#{#{interpolate_or_raise_missing(key)}}" - end - - def interpolate_or_raise_missing(key) - escaped_key = escape_key_sym(key) - Base::RESERVED_KEYS.include?(key) ? reserved_key(escaped_key) : interpolate_key(escaped_key) - end - - def interpolate_key(key) - [direct_key(key), nil_key(key), missing_key(key)].join('||') - end - - def direct_key(key) - "((t = v[#{key}]) && t.respond_to?(:call) ? t.call : t)" - end - - def nil_key(key) - "(v.has_key?(#{key}) && '')" - end - - def missing_key(key) - "raise(MissingInterpolationArgument.new(#{key}, self))" - end - - def reserved_key(key) - "raise(ReservedInterpolationKey.new(#{key}, self))" - end - - def escape_plain_str(str) - str.gsub(/"|\\|#/) {|x| "\\#{x}"} - end - - def escape_key_sym(key) - # rely on Ruby to do all the hard work :) - key.to_sym.inspect - end - end - - def interpolate(locale, string, values) - if string.respond_to?(:i18n_interpolate) - string.i18n_interpolate(values) - elsif values - super - else - string - end - end - - def store_translations(locale, data, options = {}) - compile_all_strings_in(data) - super - end - - protected - def compile_all_strings_in(data) - data.each_value do |value| - Compiler.compile_if_an_interpolation(value) - compile_all_strings_in(value) if value.kind_of?(Hash) - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/key_value.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/key_value.rb deleted file mode 100644 index d0265abf..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/key_value.rb +++ /dev/null @@ -1,102 +0,0 @@ -# encoding: utf-8 - -require 'i18n/backend/base' -require 'active_support/json' - -module I18n - module Backend - # This is a basic backend for key value stores. It receives on - # initialization the store, which should respond to three methods: - # - # * store#[](key) - Used to get a value - # * store#[]=(key, value) - Used to set a value - # * store#keys - Used to get all keys - # - # Since these stores only supports string, all values are converted - # to JSON before being stored, allowing it to also store booleans, - # hashes and arrays. However, this store does not support Procs. - # - # As the ActiveRecord backend, Symbols are just supported when loading - # translations from the filesystem or through explicit store translations. - # - # Also, avoid calling I18n.available_locales since it's a somehow - # expensive operation in most stores. - # - # == Example - # - # To setup I18n to use TokyoCabinet in memory is quite straightforward: - # - # require 'rufus/tokyo/cabinet' # gem install rufus-tokyo - # I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*')) - # - # == Performance - # - # You may make this backend even faster by including the Memoize module. - # However, notice that you should properly clear the cache if you change - # values directly in the key-store. - # - # == Subtrees - # - # In most backends, you are allowed to retrieve part of a translation tree: - # - # I18n.backend.store_translations :en, :foo => { :bar => :baz } - # I18n.t "foo" #=> { :bar => :baz } - # - # This backend supports this feature by default, but it slows down the storage - # of new data considerably and makes hard to delete entries. That said, you are - # allowed to disable the storage of subtrees on initialization: - # - # I18n::Backend::KeyValue.new(@store, false) - # - # This is useful if you are using a KeyValue backend chained to a Simple backend. - class KeyValue - module Implementation - attr_accessor :store - - include Base, Flatten - - def initialize(store, subtrees=true) - @store, @subtrees = store, subtrees - end - - def store_translations(locale, data, options = {}) - escape = options.fetch(:escape, true) - flatten_translations(locale, data, escape, @subtrees).each do |key, value| - key = "#{locale}.#{key}" - - case value - when Hash - if @subtrees && (old_value = @store[key]) - old_value = ActiveSupport::JSON.decode(old_value) - value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash) - end - when Proc - raise "Key-value stores cannot handle procs" - end - - @store[key] = ActiveSupport::JSON.encode(value) unless value.is_a?(Symbol) - end - end - - def available_locales - locales = @store.keys.map { |k| k =~ /\./; $` } - locales.uniq! - locales.compact! - locales.map! { |k| k.to_sym } - locales - end - - protected - - def lookup(locale, key, scope = [], options = {}) - key = normalize_flat_keys(locale, key, scope, options[:separator]) - value = @store["#{locale}.#{key}"] - value = ActiveSupport::JSON.decode(value) if value - value.is_a?(Hash) ? value.deep_symbolize_keys : value - end - end - - include Implementation - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/memoize.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/memoize.rb deleted file mode 100644 index 6e811d10..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/memoize.rb +++ /dev/null @@ -1,48 +0,0 @@ -# encoding: utf-8 -# -# Memoize module simply memoizes the values returned by lookup using -# a flat hash and can tremendously speed up the lookup process in a backend. -# -# To enable it you can simply include the Memoize module to your backend: -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Memoize) -# -# Notice that it's the responsibility of the backend to define whenever the -# cache should be cleaned. -module I18n - module Backend - module Memoize - def available_locales - @memoized_locales ||= super - end - - def store_translations(locale, data, options = {}) - reset_memoizations!(locale) - super - end - - def reload! - reset_memoizations! - super - end - - protected - - def lookup(locale, key, scope = nil, options = {}) - flat_key = I18n::Backend::Flatten.normalize_flat_keys(locale, - key, scope, options[:separator]).to_sym - flat_hash = memoized_lookup[locale.to_sym] - flat_hash.key?(flat_key) ? flat_hash[flat_key] : (flat_hash[flat_key] = super) - end - - def memoized_lookup - @memoized_lookup ||= Hash.new { |h, k| h[k] = {} } - end - - def reset_memoizations!(locale=nil) - @memoized_locales = nil - (locale ? memoized_lookup[locale.to_sym] : memoized_lookup).clear - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/metadata.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/metadata.rb deleted file mode 100644 index 5237b4d9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/metadata.rb +++ /dev/null @@ -1,65 +0,0 @@ -# I18n translation metadata is useful when you want to access information -# about how a translation was looked up, pluralized or interpolated in -# your application. -# -# msg = I18n.t(:message, :default => 'Hi!', :scope => :foo) -# msg.translation_metadata -# # => { :key => :message, :scope => :foo, :default => 'Hi!' } -# -# If a :count option was passed to #translate it will be set to the metadata. -# Likewise, if any interpolation variables were passed they will also be set. -# -# To enable translation metadata you can simply include the Metadata module -# into the Simple backend class - or whatever other backend you are using: -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Metadata) -# -module I18n - module Backend - module Metadata - class << self - def included(base) - Object.class_eval do - def translation_metadata - @translation_metadata ||= {} - end - - def translation_metadata=(translation_metadata) - @translation_metadata = translation_metadata - end - end unless Object.method_defined?(:translation_metadata) - end - end - - def translate(locale, key, options = {}) - metadata = { - :locale => locale, - :key => key, - :scope => options[:scope], - :default => options[:default], - :separator => options[:separator], - :values => options.reject { |name, value| Base::RESERVED_KEYS.include?(name) } - } - with_metadata(metadata) { super } - end - - def interpolate(locale, entry, values = {}) - metadata = entry.translation_metadata.merge(:original => entry) - with_metadata(metadata) { super } - end - - def pluralize(locale, entry, count) - with_metadata(:count => count) { super } - end - - protected - - def with_metadata(metadata, &block) - result = yield - result.translation_metadata = result.translation_metadata.merge(metadata) if result - result - end - - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/pluralization.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/pluralization.rb deleted file mode 100644 index 33a2aff7..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/pluralization.rb +++ /dev/null @@ -1,57 +0,0 @@ -# encoding: utf-8 - -# I18n locale fallbacks are useful when you want your application to use -# translations from other locales when translations for the current locale are -# missing. E.g. you might want to use :en translations when translations in -# your applications main locale :de are missing. -# -# To enable locale specific pluralizations you can simply include the -# Pluralization module to the Simple backend - or whatever other backend you -# are using. -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) -# -# You also need to make sure to provide pluralization algorithms to the -# backend, i.e. include them to your I18n.load_path accordingly. -module I18n - module Backend - module Pluralization - # Overwrites the Base backend translate method so that it will check the - # translation meta data space (:i18n) for a locale specific pluralization - # rule and use it to pluralize the given entry. I.e. the library expects - # pluralization rules to be stored at I18n.t(:'i18n.plural.rule') - # - # Pluralization rules are expected to respond to #call(entry, count) and - # return a pluralization key. Valid keys depend on the translation data - # hash (entry) but it is generally recommended to follow CLDR's style, - # i.e., return one of the keys :zero, :one, :few, :many, :other. - # - # The :zero key is always picked directly when count equals 0 AND the - # translation data has the key :zero. This way translators are free to - # either pick a special :zero translation even for languages where the - # pluralizer does not return a :zero key. - def pluralize(locale, entry, count) - return entry unless entry.is_a?(Hash) and count - - pluralizer = pluralizer(locale) - if pluralizer.respond_to?(:call) - key = count == 0 && entry.has_key?(:zero) ? :zero : pluralizer.call(count) - raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) - entry[key] - else - super - end - end - - protected - - def pluralizers - @pluralizers ||= {} - end - - def pluralizer(locale) - pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb deleted file mode 100644 index 30e2ac0c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb +++ /dev/null @@ -1,87 +0,0 @@ -# encoding: utf-8 - -module I18n - module Backend - # A simple backend that reads translations from YAML files and stores them in - # an in-memory hash. Relies on the Base backend. - # - # The implementation is provided by a Implementation module allowing to easily - # extend Simple backend's behavior by including modules. E.g.: - # - # module I18n::Backend::Pluralization - # def pluralize(*args) - # # extended pluralization logic - # super - # end - # end - # - # I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) - class Simple - module Implementation - include Base - - def initialized? - @initialized ||= false - end - - # Stores translations for the given locale in memory. - # This uses a deep merge for the translations hash, so existing - # translations will be overwritten by new ones only at the deepest - # level of the hash. - def store_translations(locale, data, options = {}) - locale = locale.to_sym - translations[locale] ||= {} - data = data.deep_symbolize_keys - translations[locale].deep_merge!(data) - end - - # Get available locales from the translations hash - def available_locales - init_translations unless initialized? - translations.inject([]) do |locales, (locale, data)| - locales << locale unless (data.keys - [:i18n]).empty? - locales - end - end - - # Clean up translations hash and set initialized to false on reload! - def reload! - @initialized = false - @translations = nil - super - end - - protected - - def init_translations - load_translations - @initialized = true - end - - def translations - @translations ||= {} - end - - # Looks up a translation from the translations hash. Returns nil if - # eiher key is nil, or locale, scope or key do not exist as a key in the - # nested translations hash. Splits keys or scopes containing dots - # into multiple keys, i.e. <tt>currency.format</tt> is regarded the same as - # <tt>%w(currency format)</tt>. - def lookup(locale, key, scope = [], options = {}) - init_translations unless initialized? - keys = I18n.normalize_keys(locale, key, scope, options[:separator]) - - keys.inject(translations) do |result, key| - key = key.to_sym - return nil unless result.is_a?(Hash) && result.has_key?(key) - result = result[key] - result = resolve(locale, key, result, options.merge(:scope => nil)) if result.is_a?(Symbol) - result - end - end - end - - include Implementation - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/transliterator.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/transliterator.rb deleted file mode 100644 index 2ce2cc82..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/transliterator.rb +++ /dev/null @@ -1,98 +0,0 @@ -# encoding: utf-8 -module I18n - module Backend - module Transliterator - DEFAULT_REPLACEMENT_CHAR = "?" - - # Given a locale and a UTF-8 string, return the locale's ASCII - # approximation for the string. - def transliterate(locale, string, replacement = nil) - @transliterators ||= {} - @transliterators[locale] ||= Transliterator.get I18n.t(:'i18n.transliterate.rule', - :locale => locale, :resolve => false, :default => {}) - @transliterators[locale].transliterate(string, replacement) - end - - # Get a transliterator instance. - def self.get(rule = nil) - if !rule || rule.kind_of?(Hash) - HashTransliterator.new(rule) - elsif rule.kind_of? Proc - ProcTransliterator.new(rule) - else - raise I18n::ArgumentError, "Transliteration rule must be a proc or a hash." - end - end - - # A transliterator which accepts a Proc as its transliteration rule. - class ProcTransliterator - def initialize(rule) - @rule = rule - end - - def transliterate(string, replacement = nil) - @rule.call(string) - end - end - - # A transliterator which accepts a Hash of characters as its translation - # rule. - class HashTransliterator - DEFAULT_APPROXIMATIONS = { - "À"=>"A", "Á"=>"A", "Â"=>"A", "Ã"=>"A", "Ä"=>"A", "Å"=>"A", "Æ"=>"AE", - "Ç"=>"C", "È"=>"E", "É"=>"E", "Ê"=>"E", "Ë"=>"E", "Ì"=>"I", "Í"=>"I", - "Î"=>"I", "Ï"=>"I", "Ð"=>"D", "Ñ"=>"N", "Ò"=>"O", "Ó"=>"O", "Ô"=>"O", - "Õ"=>"O", "Ö"=>"O", "×"=>"x", "Ø"=>"O", "Ù"=>"U", "Ú"=>"U", "Û"=>"U", - "Ü"=>"U", "Ý"=>"Y", "Þ"=>"Th", "ß"=>"ss", "à"=>"a", "á"=>"a", "â"=>"a", - "ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"ae", "ç"=>"c", "è"=>"e", "é"=>"e", - "ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i", "ï"=>"i", "ð"=>"d", - "ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o", "ö"=>"o", "ø"=>"o", - "ù"=>"u", "ú"=>"u", "û"=>"u", "ü"=>"u", "ý"=>"y", "þ"=>"th", "ÿ"=>"y", - "Ā"=>"A", "ā"=>"a", "Ă"=>"A", "ă"=>"a", "Ą"=>"A", "ą"=>"a", "Ć"=>"C", - "ć"=>"c", "Ĉ"=>"C", "ĉ"=>"c", "Ċ"=>"C", "ċ"=>"c", "Č"=>"C", "č"=>"c", - "Ď"=>"D", "ď"=>"d", "Đ"=>"D", "đ"=>"d", "Ē"=>"E", "ē"=>"e", "Ĕ"=>"E", - "ĕ"=>"e", "Ė"=>"E", "ė"=>"e", "Ę"=>"E", "ę"=>"e", "Ě"=>"E", "ě"=>"e", - "Ĝ"=>"G", "ĝ"=>"g", "Ğ"=>"G", "ğ"=>"g", "Ġ"=>"G", "ġ"=>"g", "Ģ"=>"G", - "ģ"=>"g", "Ĥ"=>"H", "ĥ"=>"h", "Ħ"=>"H", "ħ"=>"h", "Ĩ"=>"I", "ĩ"=>"i", - "Ī"=>"I", "ī"=>"i", "Ĭ"=>"I", "ĭ"=>"i", "Į"=>"I", "į"=>"i", "İ"=>"I", - "ı"=>"i", "IJ"=>"IJ", "ij"=>"ij", "Ĵ"=>"J", "ĵ"=>"j", "Ķ"=>"K", "ķ"=>"k", - "ĸ"=>"k", "Ĺ"=>"L", "ĺ"=>"l", "Ļ"=>"L", "ļ"=>"l", "Ľ"=>"L", "ľ"=>"l", - "Ŀ"=>"L", "ŀ"=>"l", "Ł"=>"L", "ł"=>"l", "Ń"=>"N", "ń"=>"n", "Ņ"=>"N", - "ņ"=>"n", "Ň"=>"N", "ň"=>"n", "ʼn"=>"'n", "Ŋ"=>"NG", "ŋ"=>"ng", - "Ō"=>"O", "ō"=>"o", "Ŏ"=>"O", "ŏ"=>"o", "Ő"=>"O", "ő"=>"o", "Œ"=>"OE", - "œ"=>"oe", "Ŕ"=>"R", "ŕ"=>"r", "Ŗ"=>"R", "ŗ"=>"r", "Ř"=>"R", "ř"=>"r", - "Ś"=>"S", "ś"=>"s", "Ŝ"=>"S", "ŝ"=>"s", "Ş"=>"S", "ş"=>"s", "Š"=>"S", - "š"=>"s", "Ţ"=>"T", "ţ"=>"t", "Ť"=>"T", "ť"=>"t", "Ŧ"=>"T", "ŧ"=>"t", - "Ũ"=>"U", "ũ"=>"u", "Ū"=>"U", "ū"=>"u", "Ŭ"=>"U", "ŭ"=>"u", "Ů"=>"U", - "ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W", "ŵ"=>"w", - "Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z", "ż"=>"z", - "Ž"=>"Z", "ž"=>"z" - } - - def initialize(rule = nil) - @rule = rule - add DEFAULT_APPROXIMATIONS - add rule if rule - end - - def transliterate(string, replacement = nil) - string.gsub(/[^\x00-\x7f]/u) do |char| - approximations[char] || replacement || DEFAULT_REPLACEMENT_CHAR - end - end - - private - - def approximations - @approximations ||= {} - end - - # Add transliteration rules to the approximations hash. - def add(hash) - hash.keys.each {|key| hash[key.to_s] = hash.delete(key).to_s} - approximations.merge! hash - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/config.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/config.rb deleted file mode 100644 index ceac1d8f..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/config.rb +++ /dev/null @@ -1,84 +0,0 @@ -module I18n - class Config - # The only configuration value that is not global and scoped to thread is :locale. - # It defaults to the default_locale. - def locale - @locale ||= default_locale - end - - # Sets the current locale pseudo-globally, i.e. in the Thread.current hash. - def locale=(locale) - @locale = locale.to_sym rescue nil - end - - # Returns the current backend. Defaults to +Backend::Simple+. - def backend - @@backend ||= Backend::Simple.new - end - - # Sets the current backend. Used to set a custom backend. - def backend=(backend) - @@backend = backend - end - - # Returns the current default locale. Defaults to :'en' - def default_locale - @@default_locale ||= :en - end - - # Sets the current default locale. Used to set a custom default locale. - def default_locale=(locale) - @@default_locale = locale.to_sym rescue nil - end - - # Returns an array of locales for which translations are available. - # Unless you explicitely set the these through I18n.available_locales= - # the call will be delegated to the backend and memoized on the I18n module. - def available_locales - @@available_locales ||= backend.available_locales - end - - # Sets the available locales. - def available_locales=(locales) - @@available_locales = locales - end - - # Returns the current default scope separator. Defaults to '.' - def default_separator - @@default_separator ||= '.' - end - - # Sets the current default scope separator. - def default_separator=(separator) - @@default_separator = separator - end - - # Return the current exception handler. Defaults to :default_exception_handler. - def exception_handler - @@exception_handler ||= :default_exception_handler - end - - # Sets the exception handler. - def exception_handler=(exception_handler) - @@exception_handler = exception_handler - end - - # Allow clients to register paths providing translation data sources. The - # backend defines acceptable sources. - # - # E.g. the provided SimpleBackend accepts a list of paths to translation - # files which are either named *.rb and contain plain Ruby Hashes or are - # named *.yml and contain YAML data. So for the SimpleBackend clients may - # register translation files like this: - # I18n.load_path << 'path/to/locale/en.yml' - def load_path - @@load_path ||= [] - end - - # Sets the load path instance. Custom implementations are expected to - # behave like a Ruby Array. - def load_path=(load_path) - @@load_path = load_path - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/core_ext/hash.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/core_ext/hash.rb deleted file mode 100644 index f2a2422b..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/core_ext/hash.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Hash - def slice(*keep_keys) - h = {} - keep_keys.each { |key| h[key] = fetch(key) } - h - end unless Hash.method_defined?(:slice) - - def except(*less_keys) - slice(*keys - less_keys) - end unless Hash.method_defined?(:except) - - def deep_symbolize_keys - inject({}) { |result, (key, value)| - value = value.deep_symbolize_keys if value.is_a?(Hash) - result[(key.to_sym rescue key) || key] = value - result - } - end unless Hash.method_defined?(:deep_symbolize_keys) - - # deep_merge_hash! by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 - MERGER = proc do |key, v1, v2| - Hash === v1 && Hash === v2 ? v1.merge(v2, &MERGER) : v2 - end - - def deep_merge!(data) - merge!(data, &MERGER) - end unless Hash.method_defined?(:deep_merge!) -end - diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/core_ext/string/interpolate.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/core_ext/string/interpolate.rb deleted file mode 100644 index 585af6fb..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/core_ext/string/interpolate.rb +++ /dev/null @@ -1,98 +0,0 @@ -# encoding: utf-8 - -=begin - heavily based on Masao Mutoh's gettext String interpolation extension - http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb - Copyright (C) 2005-2009 Masao Mutoh - You may redistribute it and/or modify it under the same license terms as Ruby. -=end - -begin - raise ArgumentError if ("a %{x}" % {:x=>'b'}) != 'a b' -rescue ArgumentError - # KeyError is raised by String#% when the string contains a named placeholder - # that is not contained in the given arguments hash. Ruby 1.9 includes and - # raises this exception natively. We define it to mimic Ruby 1.9's behaviour - # in Ruby 1.8.x - class KeyError < IndexError - def initialize(message = nil) - super(message || "key not found") - end - end unless defined?(KeyError) - - # Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError. - # - # String#% method which accept "named argument". The translator can know - # the meaning of the msgids using "named argument" instead of %s/%d style. - class String - # For older ruby versions, such as ruby-1.8.5 - alias :bytesize :size unless instance_methods.find {|m| m.to_s == 'bytesize'} - alias :interpolate_without_ruby_19_syntax :% # :nodoc: - - INTERPOLATION_PATTERN = Regexp.union( - /%\{(\w+)\}/, # matches placeholders like "%{foo}" - /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d" - ) - - INTERPOLATION_PATTERN_WITH_ESCAPE = Regexp.union( - /%%/, - INTERPOLATION_PATTERN - ) - - # % uses self (i.e. the String) as a format specification and returns the - # result of applying it to the given arguments. In other words it interpolates - # the given arguments to the string according to the formats the string - # defines. - # - # There are three ways to use it: - # - # * Using a single argument or Array of arguments. - # - # This is the default behaviour of the String class. See Kernel#sprintf for - # more details about the format string. - # - # Example: - # - # "%d %s" % [1, "message"] - # # => "1 message" - # - # * Using a Hash as an argument and unformatted, named placeholders. - # - # When you pass a Hash as an argument and specify placeholders with %{foo} - # it will interpret the hash values as named arguments. - # - # Example: - # - # "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"} - # # => "Masao Mutoh" - # - # * Using a Hash as an argument and formatted, named placeholders. - # - # When you pass a Hash as an argument and specify placeholders with %<foo>d - # it will interpret the hash values as named arguments and format the value - # according to the formatting instruction appended to the closing >. - # - # Example: - # - # "%<integer>d, %<float>.1f" % { :integer => 10, :float => 43.4 } - # # => "10, 43.3" - def %(args) - if args.kind_of?(Hash) - dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match| - if match == '%%' - '%' - else - key = ($1 || $2).to_sym - raise KeyError unless args.has_key?(key) - $3 ? sprintf("%#{$3}", args[key]) : args[key] - end - end - elsif self =~ INTERPOLATION_PATTERN - raise ArgumentError.new('one hash required') - else - result = gsub(/%([{<])/, '%%\1') - result.send :'interpolate_without_ruby_19_syntax', args - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/exceptions.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/exceptions.rb deleted file mode 100644 index 766a1717..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/exceptions.rb +++ /dev/null @@ -1,61 +0,0 @@ -# encoding: utf-8 - -class KeyError < IndexError - def initialize(message = nil) - super(message || "key not found") - end -end unless defined?(KeyError) - -module I18n - class ArgumentError < ::ArgumentError; end - - class InvalidLocale < ArgumentError - attr_reader :locale - def initialize(locale) - @locale = locale - super "#{locale.inspect} is not a valid locale" - end - end - - class MissingTranslationData < ArgumentError - attr_reader :locale, :key, :options - def initialize(locale, key, opts = nil) - @key, @locale, @options = key, locale, opts || {} - keys = I18n.normalize_keys(locale, key, options[:scope]) - keys << 'no key' if keys.size < 2 - super "translation missing: #{keys.join(', ')}" - end - end - - class InvalidPluralizationData < ArgumentError - attr_reader :entry, :count - def initialize(entry, count) - @entry, @count = entry, count - super "translation data #{entry.inspect} can not be used with :count => #{count}" - end - end - - class MissingInterpolationArgument < ArgumentError - attr_reader :values, :string - def initialize(values, string) - @values, @string = values, string - super "missing interpolation argument in #{string.inspect} (#{values.inspect} given)" - end - end - - class ReservedInterpolationKey < ArgumentError - attr_reader :key, :string - def initialize(key, string) - @key, @string = key, string - super "reserved key #{key.inspect} used in #{string.inspect}" - end - end - - class UnknownFileType < ArgumentError - attr_reader :type, :filename - def initialize(type, filename) - @type, @filename = type, filename - super "can not load translations from #{filename}, the file type #{type} is not known" - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext.rb deleted file mode 100644 index a824aa5a..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext.rb +++ /dev/null @@ -1,27 +0,0 @@ -# encoding: utf-8 - -module I18n - module Gettext - PLURAL_SEPARATOR = "\001" - CONTEXT_SEPARATOR = "\004" - - autoload :Helpers, 'i18n/gettext/helpers' - - @@plural_keys = { :en => [:one, :other] } - - class << self - # returns an array of plural keys for the given locale so that we can - # convert from gettext's integer-index based style - # TODO move this information to the pluralization module - def plural_keys(locale) - @@plural_keys[locale] || @@plural_keys[:en] - end - - def extract_scope(msgid, separator) - scope = msgid.to_s.split(separator) - msgid = scope.pop - [scope, msgid] - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext/helpers.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext/helpers.rb deleted file mode 100644 index 17841639..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext/helpers.rb +++ /dev/null @@ -1,65 +0,0 @@ -# encoding: utf-8 -require 'i18n/gettext' - -module I18n - module Gettext - # Implements classical Gettext style accessors. To use this include the - # module to the global namespace or wherever you want to use it. - # - # include I18n::Helpers::Gettext - module Helpers - def gettext(msgid, options = {}) - I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options)) - end - alias _ gettext - - def sgettext(msgid, separator = '|') - scope, msgid = I18n::Gettext.extract_scope(msgid, separator) - I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator) - end - alias s_ sgettext - - def pgettext(msgctxt, msgid) - separator = I18n::Gettext::CONTEXT_SEPARATOR - sgettext([msgctxt, msgid].join(separator), separator) - end - alias p_ pgettext - - def ngettext(msgid, msgid_plural, n = 1) - nsgettext(msgid, msgid_plural, n) - end - alias n_ ngettext - - # Method signatures: - # nsgettext('Fruits|apple', 'apples', 2) - # nsgettext(['Fruits|apple', 'apples'], 2) - def nsgettext(msgid, msgid_plural, n = 1, separator = '|') - if msgid.is_a?(Array) - msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n - separator = '|' unless separator.is_a?(::String) - end - - scope, msgid = I18n::Gettext.extract_scope(msgid, separator) - default = { :one => msgid, :other => msgid_plural } - I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator) - end - alias ns_ nsgettext - - # Method signatures: - # npgettext('Fruits', 'apple', 'apples', 2) - # npgettext('Fruits', ['apple', 'apples'], 2) - def npgettext(msgctxt, msgid, msgid_plural, n = 1) - separator = I18n::Gettext::CONTEXT_SEPARATOR - - if msgid.is_a?(Array) - msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural - else - msgid = [msgctxt, msgid].join(separator) - end - - nsgettext(msgid, msgid_plural, n, separator) - end - alias np_ npgettext - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext/po_parser.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext/po_parser.rb deleted file mode 100644 index 547df6a5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/gettext/po_parser.rb +++ /dev/null @@ -1,329 +0,0 @@ -=begin - poparser.rb - Generate a .mo - - Copyright (C) 2003-2009 Masao Mutoh <mutoh at highway.ne.jp> - - You may redistribute it and/or modify it under the same - license terms as Ruby. -=end - -#MODIFIED -# removed include GetText etc -# added stub translation method _(x) -require 'racc/parser' - -module GetText - - class PoParser < Racc::Parser - - def _(x) - x - end - -module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108 - def unescape(orig) - ret = orig.gsub(/\\n/, "\n") - ret.gsub!(/\\t/, "\t") - ret.gsub!(/\\r/, "\r") - ret.gsub!(/\\"/, "\"") - ret - end - - def parse(str, data, ignore_fuzzy = true) - @comments = [] - @data = data - @fuzzy = false - @msgctxt = "" - $ignore_fuzzy = ignore_fuzzy - - str.strip! - @q = [] - until str.empty? do - case str - when /\A\s+/ - str = $' - when /\Amsgctxt/ - @q.push [:MSGCTXT, $&] - str = $' - when /\Amsgid_plural/ - @q.push [:MSGID_PLURAL, $&] - str = $' - when /\Amsgid/ - @q.push [:MSGID, $&] - str = $' - when /\Amsgstr/ - @q.push [:MSGSTR, $&] - str = $' - when /\A\[(\d+)\]/ - @q.push [:PLURAL_NUM, $1] - str = $' - when /\A\#~(.*)/ - $stderr.print _("Warning: obsolete msgid exists.\n") - $stderr.print " #{$&}\n" - @q.push [:COMMENT, $&] - str = $' - when /\A\#(.*)/ - @q.push [:COMMENT, $&] - str = $' - when /\A\"(.*)\"/ - @q.push [:STRING, $1] - str = $' - else - #c = str[0,1] - #@q.push [:STRING, c] - str = str[1..-1] - end - end - @q.push [false, '$end'] - if $DEBUG - @q.each do |a,b| - puts "[#{a}, #{b}]" - end - end - @yydebug = true if $DEBUG - do_parse - - if @comments.size > 0 - @data.set_comment(:last, @comments.join("\n")) - end - @data - end - - def next_token - @q.shift - end - - def on_message(msgid, msgstr) - if msgstr.size > 0 - @data[msgid] = msgstr - @data.set_comment(msgid, @comments.join("\n")) - end - @comments.clear - @msgctxt = "" - end - - def on_comment(comment) - @fuzzy = true if (/fuzzy/ =~ comment) - @comments << comment - end - - -..end src/poparser.ry modeval..id7a99570e05 - -##### racc 1.4.5 generates ### - -racc_reduce_table = [ - 0, 0, :racc_error, - 0, 10, :_reduce_none, - 2, 10, :_reduce_none, - 2, 10, :_reduce_none, - 2, 10, :_reduce_none, - 2, 12, :_reduce_5, - 1, 13, :_reduce_none, - 1, 13, :_reduce_none, - 4, 15, :_reduce_8, - 5, 16, :_reduce_9, - 2, 17, :_reduce_10, - 1, 17, :_reduce_none, - 3, 18, :_reduce_12, - 1, 11, :_reduce_13, - 2, 14, :_reduce_14, - 1, 14, :_reduce_15 ] - -racc_reduce_n = 16 - -racc_shift_n = 26 - -racc_action_table = [ - 3, 13, 5, 7, 9, 15, 16, 17, 20, 17, - 13, 17, 13, 13, 11, 17, 23, 20, 13, 17 ] - -racc_action_check = [ - 1, 16, 1, 1, 1, 12, 12, 12, 18, 18, - 7, 14, 15, 9, 3, 19, 20, 21, 23, 25 ] - -racc_action_pointer = [ - nil, 0, nil, 14, nil, nil, nil, 3, nil, 6, - nil, nil, 0, nil, 4, 5, -6, nil, 2, 8, - 8, 11, nil, 11, nil, 12 ] - -racc_action_default = [ - -1, -16, -2, -16, -3, -13, -4, -16, -6, -16, - -7, 26, -16, -15, -5, -16, -16, -14, -16, -8, - -16, -9, -11, -16, -10, -12 ] - -racc_goto_table = [ - 12, 22, 14, 4, 24, 6, 2, 8, 18, 19, - 10, 21, 1, nil, nil, nil, 25 ] - -racc_goto_check = [ - 5, 9, 5, 3, 9, 4, 2, 6, 5, 5, - 7, 8, 1, nil, nil, nil, 5 ] - -racc_goto_pointer = [ - nil, 12, 5, 2, 4, -7, 6, 9, -7, -17 ] - -racc_goto_default = [ - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ] - -racc_token_table = { - false => 0, - Object.new => 1, - :COMMENT => 2, - :MSGID => 3, - :MSGCTXT => 4, - :MSGID_PLURAL => 5, - :MSGSTR => 6, - :STRING => 7, - :PLURAL_NUM => 8 } - -racc_use_result_var = true - -racc_nt_base = 9 - -Racc_arg = [ - racc_action_table, - racc_action_check, - racc_action_default, - racc_action_pointer, - racc_goto_table, - racc_goto_check, - racc_goto_default, - racc_goto_pointer, - racc_nt_base, - racc_reduce_table, - racc_token_table, - racc_shift_n, - racc_reduce_n, - racc_use_result_var ] - -Racc_token_to_s_table = [ -'$end', -'error', -'COMMENT', -'MSGID', -'MSGCTXT', -'MSGID_PLURAL', -'MSGSTR', -'STRING', -'PLURAL_NUM', -'$start', -'msgfmt', -'comment', -'msgctxt', -'message', -'string_list', -'single_message', -'plural_message', -'msgstr_plural', -'msgstr_plural_line'] - -Racc_debug_parser = true - -##### racc system variables end ##### - - # reduce 0 omitted - - # reduce 1 omitted - - # reduce 2 omitted - - # reduce 3 omitted - - # reduce 4 omitted - -module_eval <<'.,.,', 'src/poparser.ry', 25 - def _reduce_5( val, _values, result ) - @msgctxt = unescape(val[1]) + "\004" - result - end -.,., - - # reduce 6 omitted - - # reduce 7 omitted - -module_eval <<'.,.,', 'src/poparser.ry', 48 - def _reduce_8( val, _values, result ) - if @fuzzy and $ignore_fuzzy - if val[1] != "" - $stderr.print _("Warning: fuzzy message was ignored.\n") - $stderr.print " msgid '#{val[1]}'\n" - else - on_message('', unescape(val[3])) - end - @fuzzy = false - else - on_message(@msgctxt + unescape(val[1]), unescape(val[3])) - end - result = "" - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 65 - def _reduce_9( val, _values, result ) - if @fuzzy and $ignore_fuzzy - if val[1] != "" - $stderr.print _("Warning: fuzzy message was ignored.\n") - $stderr.print "msgid = '#{val[1]}\n" - else - on_message('', unescape(val[3])) - end - @fuzzy = false - else - on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4])) - end - result = "" - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 76 - def _reduce_10( val, _values, result ) - if val[0].size > 0 - result = val[0] + "\000" + val[1] - else - result = "" - end - result - end -.,., - - # reduce 11 omitted - -module_eval <<'.,.,', 'src/poparser.ry', 84 - def _reduce_12( val, _values, result ) - result = val[2] - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 91 - def _reduce_13( val, _values, result ) - on_comment(val[0]) - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 99 - def _reduce_14( val, _values, result ) - result = val.delete_if{|item| item == ""}.join - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 103 - def _reduce_15( val, _values, result ) - result = val[0] - result - end -.,., - - def _reduce_none( val, _values, result ) - result - end - - end # class PoParser - -end # module GetText diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale.rb deleted file mode 100644 index 4f9d0266..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale.rb +++ /dev/null @@ -1,6 +0,0 @@ -module I18n - module Locale - autoload :Fallbacks, 'i18n/locale/fallbacks' - autoload :Tag, 'i18n/locale/tag' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb deleted file mode 100644 index 11dcf8c2..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb +++ /dev/null @@ -1,98 +0,0 @@ -# encoding: utf-8 - -# Locale Fallbacks -# -# Extends the I18n module to hold a fallbacks instance which is set to an -# instance of I18n::Locale::Fallbacks by default but can be swapped with a -# different implementation. -# -# Locale fallbacks will compute a number of fallback locales for a given locale. -# For example: -# -# <pre><code> -# I18n.fallbacks[:"es-MX"] # => [:"es-MX", :es, :en] </code></pre> -# -# Locale fallbacks always fall back to -# -# * all parent locales of a given locale (e.g. :es for :"es-MX") first, -# * the current default locales and all of their parents second -# -# The default locales are set to [I18n.default_locale] by default but can be -# set to something else. -# -# One can additionally add any number of additional fallback locales manually. -# These will be added before the default locales to the fallback chain. For -# example: -# -# # using the default locale as default fallback locale -# -# I18n.default_locale = :"en-US" -# I18n.fallbacks = I18n::Fallbacks.new(:"de-AT" => :"de-DE") -# I18n.fallbacks[:"de-AT"] # => [:"de-AT", :"de-DE", :de, :"en-US", :en] -# -# # using a custom locale as default fallback locale -# -# I18n.fallbacks = I18n::Fallbacks.new(:"en-GB", :"de-AT" => :de, :"de-CH" => :de) -# I18n.fallbacks[:"de-AT"] # => [:"de-AT", :de, :"en-GB", :en] -# I18n.fallbacks[:"de-CH"] # => [:"de-CH", :de, :"en-GB", :en] -# -# # mapping fallbacks to an existing instance -# -# # people speaking Catalan also speak Spanish as spoken in Spain -# fallbacks = I18n.fallbacks -# fallbacks.map(:ca => :"es-ES") -# fallbacks[:ca] # => [:ca, :"es-ES", :es, :"en-US", :en] -# -# # people speaking Arabian as spoken in Palestine also speak Hebrew as spoken in Israel -# fallbacks.map(:"ar-PS" => :"he-IL") -# fallbacks[:"ar-PS"] # => [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en] -# fallbacks[:"ar-EG"] # => [:"ar-EG", :ar, :"en-US", :en] -# -# # people speaking Sami as spoken in Finnland also speak Swedish and Finnish as spoken in Finnland -# fallbacks.map(:sms => [:"se-FI", :"fi-FI"]) -# fallbacks[:sms] # => [:sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en] - -module I18n - module Locale - class Fallbacks < Hash - def initialize(*mappings) - @map = {} - map(mappings.pop) if mappings.last.is_a?(Hash) - self.defaults = mappings.empty? ? [I18n.default_locale.to_sym] : mappings - end - - def defaults=(defaults) - @defaults = defaults.map { |default| compute(default, false) }.flatten - end - attr_reader :defaults - - def [](locale) - raise InvalidLocale.new(locale) if locale.nil? - locale = locale.to_sym - super || store(locale, compute(locale)) - end - - def map(mappings) - mappings.each do |from, to| - from, to = from.to_sym, Array(to) - to.each do |to| - @map[from] ||= [] - @map[from] << to.to_sym - end - end - end - - protected - - def compute(tags, include_defaults = true) - result = Array(tags).collect do |tag| - tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym } - tags.each { |tag| tags += compute(@map[tag]) if @map[tag] } - tags - end.flatten - result.push(*defaults) if include_defaults - result.uniq - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag.rb deleted file mode 100644 index a640b446..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag.rb +++ /dev/null @@ -1,28 +0,0 @@ -# encoding: utf-8 - -module I18n - module Locale - module Tag - autoload :Parents, 'i18n/locale/tag/parents' - autoload :Rfc4646, 'i18n/locale/tag/rfc4646' - autoload :Simple, 'i18n/locale/tag/simple' - - class << self - # Returns the current locale tag implementation. Defaults to +I18n::Locale::Tag::Simple+. - def implementation - @@implementation ||= Simple - end - - # Sets the current locale tag implementation. Use this to set a different locale tag implementation. - def implementation=(implementation) - @@implementation = implementation - end - - # Factory method for locale tags. Delegates to the current locale tag implementation. - def tag(tag) - implementation.tag(tag) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/parents.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/parents.rb deleted file mode 100644 index a0944683..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/parents.rb +++ /dev/null @@ -1,24 +0,0 @@ -# encoding: utf-8 - -module I18n - module Locale - module Tag - module Parents - def parent - @parent ||= begin - segs = to_a.compact - segs.length > 1 ? self.class.tag(*segs[0..(segs.length-2)].join('-')) : nil - end - end - - def self_and_parents - @self_and_parents ||= [self] + parents - end - - def parents - @parents ||= ([parent] + (parent ? parent.parents : [])).compact - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/rfc4646.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/rfc4646.rb deleted file mode 100644 index c20d35ae..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/rfc4646.rb +++ /dev/null @@ -1,76 +0,0 @@ -# encoding: utf-8 - -# RFC 4646/47 compliant Locale tag implementation that parses locale tags to -# subtags such as language, script, region, variant etc. -# -# For more information see by http://en.wikipedia.org/wiki/IETF_language_tag -# -# Rfc4646::Parser does not implement grandfathered tags. - -module I18n - module Locale - module Tag - RFC4646_SUBTAGS = [ :language, :script, :region, :variant, :extension, :privateuse, :grandfathered ] - RFC4646_FORMATS = { :language => :downcase, :script => :capitalize, :region => :upcase, :variant => :downcase } - - class Rfc4646 < Struct.new(*RFC4646_SUBTAGS) - class << self - # Parses the given tag and returns a Tag instance if it is valid. - # Returns false if the given tag is not valid according to RFC 4646. - def tag(tag) - matches = parser.match(tag) - new(*matches) if matches - end - - def parser - @@parser ||= Rfc4646::Parser - end - - def parser=(parser) - @@parser = parser - end - end - - include Parents - - RFC4646_FORMATS.each do |name, format| - define_method(name) { self[name].send(format) unless self[name].nil? } - end - - def to_sym - to_s.to_sym - end - - def to_s - @tag ||= to_a.compact.join("-") - end - - def to_a - members.collect { |attr| self.send(attr) } - end - - module Parser - PATTERN = %r{\A(?: - ([a-z]{2,3}(?:(?:-[a-z]{3}){0,3})?|[a-z]{4}|[a-z]{5,8}) # language - (?:-([a-z]{4}))? # script - (?:-([a-z]{2}|\d{3}))? # region - (?:-([0-9a-z]{5,8}|\d[0-9a-z]{3}))* # variant - (?:-([0-9a-wyz](?:-[0-9a-z]{2,8})+))* # extension - (?:-(x(?:-[0-9a-z]{1,8})+))?| # privateuse subtag - (x(?:-[0-9a-z]{1,8})+)| # privateuse tag - /* ([a-z]{1,3}(?:-[0-9a-z]{2,8}){1,2}) */ # grandfathered - )\z}xi - - class << self - def match(tag) - c = PATTERN.match(tag.to_s).captures - c[0..4] << (c[5].nil? ? c[6] : c[5]) << c[7] # TODO c[7] is grandfathered, throw a NotImplemented exception here? - rescue - false - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/simple.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/simple.rb deleted file mode 100644 index 0fddb366..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/simple.rb +++ /dev/null @@ -1,41 +0,0 @@ -# encoding: utf-8 - -# Simple Locale tag implementation that computes subtags by simply splitting -# the locale tag at '-' occurences. -module I18n - module Locale - module Tag - class Simple - class << self - def tag(tag) - new(tag) - end - end - - include Parents - - attr_reader :tag - - def initialize(*tag) - @tag = tag.join('-').to_sym - end - - def subtags - @subtags = tag.to_s.split('-').map { |subtag| subtag.to_s } - end - - def to_sym - tag - end - - def to_s - tag.to_s - end - - def to_a - subtags - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/version.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/version.rb deleted file mode 100644 index e1186c28..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module I18n - VERSION = "0.4.1" -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb b/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb deleted file mode 100644 index f249da79..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb +++ /dev/null @@ -1,1107 +0,0 @@ -$TESTING = defined?($TESTING) && $TESTING - -require 'socket' -require 'thread' -require 'zlib' -require 'digest/sha1' -require 'net/protocol' - -## -# A Ruby client library for memcached. -# - -class MemCache - - ## - # The version of MemCache you are using. - - VERSION = '1.7.4' - - ## - # Default options for the cache object. - - DEFAULT_OPTIONS = { - :namespace => nil, - :readonly => false, - :multithread => true, - :failover => true, - :timeout => 0.5, - :logger => nil, - :no_reply => false, - } - - ## - # Default memcached port. - - DEFAULT_PORT = 11211 - - ## - # Default memcached server weight. - - DEFAULT_WEIGHT = 1 - - ## - # The namespace for this instance - - attr_reader :namespace - - ## - # The multithread setting for this instance - - attr_reader :multithread - - ## - # The servers this client talks to. Play at your own peril. - - attr_reader :servers - - ## - # Socket timeout limit with this client, defaults to 0.5 sec. - # Set to nil to disable timeouts. - - attr_reader :timeout - - ## - # Should the client try to failover to another server if the - # first server is down? Defaults to true. - - attr_reader :failover - - ## - # Log debug/info/warn/error to the given Logger, defaults to nil. - - attr_reader :logger - - ## - # Don't send or look for a reply from the memcached server for write operations. - # Please note this feature only works in memcached 1.2.5 and later. Earlier - # versions will reply with "ERROR". - attr_reader :no_reply - - ## - # Accepts a list of +servers+ and a list of +opts+. +servers+ may be - # omitted. See +servers=+ for acceptable server list arguments. - # - # Valid options for +opts+ are: - # - # [:namespace] Prepends this value to all keys added or retrieved. - # [:readonly] Raises an exception on cache writes when true. - # [:multithread] Wraps cache access in a Mutex for thread safety. Defaults to true. - # [:failover] Should the client try to failover to another server if the - # first server is down? Defaults to true. - # [:timeout] Time to use as the socket read timeout. Defaults to 0.5 sec, - # set to nil to disable timeouts (this is a major performance penalty in Ruby 1.8, - # "gem install SystemTimer' to remove most of the penalty). - # [:logger] Logger to use for info/debug output, defaults to nil - # [:no_reply] Don't bother looking for a reply for write operations (i.e. they - # become 'fire and forget'), memcached 1.2.5 and later only, speeds up - # set/add/delete/incr/decr significantly. - # - # Other options are ignored. - - def initialize(*args) - servers = [] - opts = {} - - case args.length - when 0 then # NOP - when 1 then - arg = args.shift - case arg - when Hash then opts = arg - when Array then servers = arg - when String then servers = [arg] - else raise ArgumentError, 'first argument must be Array, Hash or String' - end - when 2 then - servers, opts = args - else - raise ArgumentError, "wrong number of arguments (#{args.length} for 2)" - end - - opts = DEFAULT_OPTIONS.merge opts - @namespace = opts[:namespace] - @readonly = opts[:readonly] - @multithread = opts[:multithread] - @timeout = opts[:timeout] - @failover = opts[:failover] - @logger = opts[:logger] - @no_reply = opts[:no_reply] - @mutex = Mutex.new if @multithread - - logger.info { "memcache-client #{VERSION} #{Array(servers).inspect}" } if logger - - Thread.current[:memcache_client] = self.object_id if !@multithread - - self.servers = servers - end - - ## - # Returns a string representation of the cache object. - - def inspect - "<MemCache: %d servers, ns: %p, ro: %p>" % - [@servers.length, @namespace, @readonly] - end - - ## - # Returns whether there is at least one active server for the object. - - def active? - not @servers.empty? - end - - ## - # Returns whether or not the cache object was created read only. - - def readonly? - @readonly - end - - ## - # Set the servers that the requests will be distributed between. Entries - # can be either strings of the form "hostname:port" or - # "hostname:port:weight" or MemCache::Server objects. - # - def servers=(servers) - # Create the server objects. - @servers = Array(servers).collect do |server| - case server - when String - host, port, weight = server.split ':', 3 - port ||= DEFAULT_PORT - weight ||= DEFAULT_WEIGHT - Server.new self, host, port, weight - else - server - end - end - - logger.debug { "Servers now: #{@servers.inspect}" } if logger - - # There's no point in doing this if there's only one server - @continuum = create_continuum_for(@servers) if @servers.size > 1 - - @servers - end - - ## - # Decrements the value for +key+ by +amount+ and returns the new value. - # +key+ must already exist. If +key+ is not an integer, it is assumed to be - # 0. +key+ can not be decremented below 0. - - def decr(key, amount = 1) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - cache_decr server, cache_key, amount - end - rescue TypeError => err - handle_error nil, err - end - - ## - # Retrieves +key+ from memcache. If +raw+ is false, the value will be - # unmarshalled. - - def get(key, raw = false) - with_server(key) do |server, cache_key| - logger.debug { "get #{key} from #{server.inspect}" } if logger - value = cache_get server, cache_key - return nil if value.nil? - value = Marshal.load value unless raw - return value - end - rescue TypeError => err - handle_error nil, err - end - - ## - # Performs a +get+ with the given +key+. If - # the value does not exist and a block was given, - # the block will be called and the result saved via +add+. - # - # If you do not provide a block, using this - # method is the same as using +get+. - # - def fetch(key, expiry = 0, raw = false) - value = get(key, raw) - - if value.nil? && block_given? - value = yield - add(key, value, expiry, raw) - end - - value - end - - ## - # Retrieves multiple values from memcached in parallel, if possible. - # - # The memcached protocol supports the ability to retrieve multiple - # keys in a single request. Pass in an array of keys to this method - # and it will: - # - # 1. map the key to the appropriate memcached server - # 2. send a single request to each server that has one or more key values - # - # Returns a hash of values. - # - # cache["a"] = 1 - # cache["b"] = 2 - # cache.get_multi "a", "b" # => { "a" => 1, "b" => 2 } - # - # Note that get_multi assumes the values are marshalled. - - def get_multi(*keys) - raise MemCacheError, 'No active servers' unless active? - - keys.flatten! - key_count = keys.length - cache_keys = {} - server_keys = Hash.new { |h,k| h[k] = [] } - - # map keys to servers - keys.each do |key| - server, cache_key = request_setup key - cache_keys[cache_key] = key - server_keys[server] << cache_key - end - - results = {} - - server_keys.each do |server, keys_for_server| - keys_for_server_str = keys_for_server.join ' ' - begin - values = cache_get_multi server, keys_for_server_str - values.each do |key, value| - results[cache_keys[key]] = Marshal.load value - end - rescue IndexError => e - # Ignore this server and try the others - logger.warn { "Unable to retrieve #{keys_for_server.size} elements from #{server.inspect}: #{e.message}"} if logger - end - end - - return results - rescue TypeError => err - handle_error nil, err - end - - ## - # Increments the value for +key+ by +amount+ and returns the new value. - # +key+ must already exist. If +key+ is not an integer, it is assumed to be - # 0. - - def incr(key, amount = 1) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - cache_incr server, cache_key, amount - end - rescue TypeError => err - handle_error nil, err - end - - ## - # Add +key+ to the cache with value +value+ that expires in +expiry+ - # seconds. If +raw+ is true, +value+ will not be Marshalled. - # - # Warning: Readers should not call this method in the event of a cache miss; - # see MemCache#add. - - ONE_MB = 1024 * 1024 - - def set(key, value, expiry = 0, raw = false) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - - value = Marshal.dump value unless raw - logger.debug { "set #{key} to #{server.inspect}: #{value.to_s.size}" } if logger - - raise MemCacheError, "Value too large, memcached can only store 1MB of data per key" if value.to_s.size > ONE_MB - - command = "set #{cache_key} 0 #{expiry} #{value.to_s.size}#{noreply}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - - if result.nil? - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" - end - - result - end - end - end - - ## - # "cas" is a check and set operation which means "store this data but - # only if no one else has updated since I last fetched it." This can - # be used as a form of optimistic locking. - # - # Works in block form like so: - # cache.cas('some-key') do |value| - # value + 1 - # end - # - # Returns: - # +nil+ if the value was not found on the memcached server. - # +STORED+ if the value was updated successfully - # +EXISTS+ if the value was updated by someone else since last fetch - - def cas(key, expiry=0, raw=false) - raise MemCacheError, "Update of readonly cache" if @readonly - raise MemCacheError, "A block is required" unless block_given? - - (value, token) = gets(key, raw) - return nil unless value - updated = yield value - - with_server(key) do |server, cache_key| - - value = Marshal.dump updated unless raw - logger.debug { "cas #{key} to #{server.inspect}: #{value.to_s.size}" } if logger - command = "cas #{cache_key} 0 #{expiry} #{value.to_s.size} #{token}#{noreply}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - - if result.nil? - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" - end - - result - end - end - end - - ## - # Add +key+ to the cache with value +value+ that expires in +expiry+ - # seconds, but only if +key+ does not already exist in the cache. - # If +raw+ is true, +value+ will not be Marshalled. - # - # Readers should call this method in the event of a cache miss, not - # MemCache#set. - - def add(key, value, expiry = 0, raw = false) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - value = Marshal.dump value unless raw - logger.debug { "add #{key} to #{server}: #{value ? value.to_s.size : 'nil'}" } if logger - command = "add #{cache_key} 0 #{expiry} #{value.to_s.size}#{noreply}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Add +key+ to the cache with value +value+ that expires in +expiry+ - # seconds, but only if +key+ already exists in the cache. - # If +raw+ is true, +value+ will not be Marshalled. - def replace(key, value, expiry = 0, raw = false) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - value = Marshal.dump value unless raw - logger.debug { "replace #{key} to #{server}: #{value ? value.to_s.size : 'nil'}" } if logger - command = "replace #{cache_key} 0 #{expiry} #{value.to_s.size}#{noreply}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Append - 'add this data to an existing key after existing data' - # Please note the value is always passed to memcached as raw since it - # doesn't make a lot of sense to concatenate marshalled data together. - def append(key, value) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - logger.debug { "append #{key} to #{server}: #{value ? value.to_s.size : 'nil'}" } if logger - command = "append #{cache_key} 0 0 #{value.to_s.size}#{noreply}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Prepend - 'add this data to an existing key before existing data' - # Please note the value is always passed to memcached as raw since it - # doesn't make a lot of sense to concatenate marshalled data together. - def prepend(key, value) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - logger.debug { "prepend #{key} to #{server}: #{value ? value.to_s.size : 'nil'}" } if logger - command = "prepend #{cache_key} 0 0 #{value.to_s.size}#{noreply}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Removes +key+ from the cache in +expiry+ seconds. - - def delete(key, expiry = 0) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - with_socket_management(server) do |socket| - logger.debug { "delete #{cache_key} on #{server}" } if logger - socket.write "delete #{cache_key} #{expiry}#{noreply}\r\n" - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Flush the cache from all memcache servers. - # A non-zero value for +delay+ will ensure that the flush - # is propogated slowly through your memcached server farm. - # The Nth server will be flushed N*delay seconds from now, - # asynchronously so this method returns quickly. - # This prevents a huge database spike due to a total - # flush all at once. - - def flush_all(delay=0) - raise MemCacheError, 'No active servers' unless active? - raise MemCacheError, "Update of readonly cache" if @readonly - - begin - delay_time = 0 - @servers.each do |server| - with_socket_management(server) do |socket| - logger.debug { "flush_all #{delay_time} on #{server}" } if logger - if delay == 0 # older versions of memcached will fail silently otherwise - socket.write "flush_all#{noreply}\r\n" - else - socket.write "flush_all #{delay_time}#{noreply}\r\n" - end - break nil if @no_reply - result = socket.gets - raise_on_error_response! result - result - end - delay_time += delay - end - rescue IndexError => err - handle_error nil, err - end - end - - ## - # Reset the connection to all memcache servers. This should be called if - # there is a problem with a cache lookup that might have left the connection - # in a corrupted state. - - def reset - @servers.each { |server| server.close } - end - - ## - # Returns statistics for each memcached server. An explanation of the - # statistics can be found in the memcached docs: - # - # http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt - # - # Example: - # - # >> pp CACHE.stats - # {"localhost:11211"=> - # {"bytes"=>4718, - # "pid"=>20188, - # "connection_structures"=>4, - # "time"=>1162278121, - # "pointer_size"=>32, - # "limit_maxbytes"=>67108864, - # "cmd_get"=>14532, - # "version"=>"1.2.0", - # "bytes_written"=>432583, - # "cmd_set"=>32, - # "get_misses"=>0, - # "total_connections"=>19, - # "curr_connections"=>3, - # "curr_items"=>4, - # "uptime"=>1557, - # "get_hits"=>14532, - # "total_items"=>32, - # "rusage_system"=>0.313952, - # "rusage_user"=>0.119981, - # "bytes_read"=>190619}} - # => nil - - def stats - raise MemCacheError, "No active servers" unless active? - server_stats = {} - - @servers.each do |server| - next unless server.alive? - - with_socket_management(server) do |socket| - value = nil - socket.write "stats\r\n" - stats = {} - while line = socket.gets do - raise_on_error_response! line - break if line == "END\r\n" - if line =~ /\ASTAT ([\S]+) ([\w\.\:]+)/ then - name, value = $1, $2 - stats[name] = case name - when 'version' - value - when 'rusage_user', 'rusage_system' then - seconds, microseconds = value.split(/:/, 2) - microseconds ||= 0 - Float(seconds) + (Float(microseconds) / 1_000_000) - else - if value =~ /\A\d+\Z/ then - value.to_i - else - value - end - end - end - end - server_stats["#{server.host}:#{server.port}"] = stats - end - end - - raise MemCacheError, "No active servers" if server_stats.empty? - server_stats - end - - ## - # Shortcut to get a value from the cache. - - alias [] get - - ## - # Shortcut to save a value in the cache. This method does not set an - # expiration on the entry. Use set to specify an explicit expiry. - - def []=(key, value) - set key, value - end - - protected unless $TESTING - - ## - # Create a key for the cache, incorporating the namespace qualifier if - # requested. - - def make_cache_key(key) - if namespace.nil? then - key - else - "#{@namespace}:#{key}" - end - end - - ## - # Returns an interoperable hash value for +key+. (I think, docs are - # sketchy for down servers). - - def hash_for(key) - Zlib.crc32(key) - end - - ## - # Pick a server to handle the request based on a hash of the key. - - def get_server_for_key(key, options = {}) - raise ArgumentError, "illegal character in key #{key.inspect}" if - key =~ /\s/ - raise ArgumentError, "key too long #{key.inspect}" if key.length > 250 - raise MemCacheError, "No servers available" if @servers.empty? - return @servers.first if @servers.length == 1 - - hkey = hash_for(key) - - 20.times do |try| - entryidx = Continuum.binary_search(@continuum, hkey) - server = @continuum[entryidx].server - return server if server.alive? - break unless failover - hkey = hash_for "#{try}#{key}" - end - - raise MemCacheError, "No servers available" - end - - ## - # Performs a raw decr for +cache_key+ from +server+. Returns nil if not - # found. - - def cache_decr(server, cache_key, amount) - with_socket_management(server) do |socket| - socket.write "decr #{cache_key} #{amount}#{noreply}\r\n" - break nil if @no_reply - text = socket.gets - raise_on_error_response! text - return nil if text == "NOT_FOUND\r\n" - return text.to_i - end - end - - ## - # Fetches the raw data for +cache_key+ from +server+. Returns nil on cache - # miss. - - def cache_get(server, cache_key) - with_socket_management(server) do |socket| - socket.write "get #{cache_key}\r\n" - keyline = socket.gets # "VALUE <key> <flags> <bytes>\r\n" - - if keyline.nil? then - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" - end - - raise_on_error_response! keyline - return nil if keyline == "END\r\n" - - unless keyline =~ /(\d+)\r/ then - server.close - raise MemCacheError, "unexpected response #{keyline.inspect}" - end - value = socket.read $1.to_i - socket.read 2 # "\r\n" - socket.gets # "END\r\n" - return value - end - end - - def gets(key, raw = false) - with_server(key) do |server, cache_key| - logger.debug { "gets #{key} from #{server.inspect}" } if logger - result = with_socket_management(server) do |socket| - socket.write "gets #{cache_key}\r\n" - keyline = socket.gets # "VALUE <key> <flags> <bytes> <cas token>\r\n" - - if keyline.nil? then - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" - end - - raise_on_error_response! keyline - return nil if keyline == "END\r\n" - - unless keyline =~ /(\d+) (\w+)\r/ then - server.close - raise MemCacheError, "unexpected response #{keyline.inspect}" - end - value = socket.read $1.to_i - socket.read 2 # "\r\n" - socket.gets # "END\r\n" - [value, $2] - end - result[0] = Marshal.load result[0] unless raw - result - end - rescue TypeError => err - handle_error nil, err - end - - - ## - # Fetches +cache_keys+ from +server+ using a multi-get. - - def cache_get_multi(server, cache_keys) - with_socket_management(server) do |socket| - values = {} - socket.write "get #{cache_keys}\r\n" - - while keyline = socket.gets do - return values if keyline == "END\r\n" - raise_on_error_response! keyline - - unless keyline =~ /\AVALUE (.+) (.+) (.+)/ then - server.close - raise MemCacheError, "unexpected response #{keyline.inspect}" - end - - key, data_length = $1, $3 - values[$1] = socket.read data_length.to_i - socket.read(2) # "\r\n" - end - - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" # TODO: retry here too - end - end - - ## - # Performs a raw incr for +cache_key+ from +server+. Returns nil if not - # found. - - def cache_incr(server, cache_key, amount) - with_socket_management(server) do |socket| - socket.write "incr #{cache_key} #{amount}#{noreply}\r\n" - break nil if @no_reply - text = socket.gets - raise_on_error_response! text - return nil if text == "NOT_FOUND\r\n" - return text.to_i - end - end - - ## - # Gets or creates a socket connected to the given server, and yields it - # to the block, wrapped in a mutex synchronization if @multithread is true. - # - # If a socket error (SocketError, SystemCallError, IOError) or protocol error - # (MemCacheError) is raised by the block, closes the socket, attempts to - # connect again, and retries the block (once). If an error is again raised, - # reraises it as MemCacheError. - # - # If unable to connect to the server (or if in the reconnect wait period), - # raises MemCacheError. Note that the socket connect code marks a server - # dead for a timeout period, so retrying does not apply to connection attempt - # failures (but does still apply to unexpectedly lost connections etc.). - - def with_socket_management(server, &block) - check_multithread_status! - - @mutex.lock if @multithread - retried = false - - begin - socket = server.socket - - # Raise an IndexError to show this server is out of whack. If were inside - # a with_server block, we'll catch it and attempt to restart the operation. - - raise IndexError, "No connection to server (#{server.status})" if socket.nil? - - block.call(socket) - - rescue SocketError, Errno::EAGAIN, Timeout::Error => err - logger.warn { "Socket failure: #{err.message}" } if logger - server.mark_dead(err) - handle_error(server, err) - - rescue MemCacheError, SystemCallError, IOError => err - logger.warn { "Generic failure: #{err.class.name}: #{err.message}" } if logger - handle_error(server, err) if retried || socket.nil? - retried = true - retry - end - ensure - @mutex.unlock if @multithread - end - - def with_server(key) - retried = false - begin - server, cache_key = request_setup(key) - yield server, cache_key - rescue IndexError => e - logger.warn { "Server failed: #{e.class.name}: #{e.message}" } if logger - if !retried && @servers.size > 1 - logger.info { "Connection to server #{server.inspect} DIED! Retrying operation..." } if logger - retried = true - retry - end - handle_error(nil, e) - end - end - - ## - # Handles +error+ from +server+. - - def handle_error(server, error) - raise error if error.is_a?(MemCacheError) - server.close if server - new_error = MemCacheError.new error.message - new_error.set_backtrace error.backtrace - raise new_error - end - - def noreply - @no_reply ? ' noreply' : '' - end - - ## - # Performs setup for making a request with +key+ from memcached. Returns - # the server to fetch the key from and the complete key to use. - - def request_setup(key) - raise MemCacheError, 'No active servers' unless active? - cache_key = make_cache_key key - server = get_server_for_key cache_key - return server, cache_key - end - - def raise_on_error_response!(response) - if response =~ /\A(?:CLIENT_|SERVER_)?ERROR(.*)/ - raise MemCacheError, $1.strip - end - end - - def create_continuum_for(servers) - total_weight = servers.inject(0) { |memo, srv| memo + srv.weight } - continuum = [] - - servers.each do |server| - entry_count_for(server, servers.size, total_weight).times do |idx| - hash = Digest::SHA1.hexdigest("#{server.host}:#{server.port}:#{idx}") - value = Integer("0x#{hash[0..7]}") - continuum << Continuum::Entry.new(value, server) - end - end - - continuum.sort { |a, b| a.value <=> b.value } - end - - def entry_count_for(server, total_servers, total_weight) - ((total_servers * Continuum::POINTS_PER_SERVER * server.weight) / Float(total_weight)).floor - end - - def check_multithread_status! - return if @multithread - - if Thread.current[:memcache_client] != self.object_id - raise MemCacheError, <<-EOM - You are accessing this memcache-client instance from multiple threads but have not enabled multithread support. - Normally: MemCache.new(['localhost:11211'], :multithread => true) - In Rails: config.cache_store = [:mem_cache_store, 'localhost:11211', { :multithread => true }] - EOM - end - end - - ## - # This class represents a memcached server instance. - - class Server - - ## - # The amount of time to wait before attempting to re-establish a - # connection with a server that is marked dead. - - RETRY_DELAY = 30.0 - - ## - # The host the memcached server is running on. - - attr_reader :host - - ## - # The port the memcached server is listening on. - - attr_reader :port - - ## - # The weight given to the server. - - attr_reader :weight - - ## - # The time of next retry if the connection is dead. - - attr_reader :retry - - ## - # A text status string describing the state of the server. - - attr_reader :status - - attr_reader :logger - - ## - # Create a new MemCache::Server object for the memcached instance - # listening on the given host and port, weighted by the given weight. - - def initialize(memcache, host, port = DEFAULT_PORT, weight = DEFAULT_WEIGHT) - raise ArgumentError, "No host specified" if host.nil? or host.empty? - raise ArgumentError, "No port specified" if port.nil? or port.to_i.zero? - - @host = host - @port = port.to_i - @weight = weight.to_i - - @sock = nil - @retry = nil - @status = 'NOT CONNECTED' - @timeout = memcache.timeout - @logger = memcache.logger - end - - ## - # Return a string representation of the server object. - - def inspect - "<MemCache::Server: %s:%d [%d] (%s)>" % [@host, @port, @weight, @status] - end - - ## - # Check whether the server connection is alive. This will cause the - # socket to attempt to connect if it isn't already connected and or if - # the server was previously marked as down and the retry time has - # been exceeded. - - def alive? - !!socket - end - - ## - # Try to connect to the memcached server targeted by this object. - # Returns the connected socket object on success or nil on failure. - - def socket - return @sock if @sock and not @sock.closed? - - @sock = nil - - # If the host was dead, don't retry for a while. - return if @retry and @retry > Time.now - - # Attempt to connect if not already connected. - begin - @sock = connect_to(@host, @port, @timeout) - @sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1 - @retry = nil - @status = 'CONNECTED' - rescue SocketError, SystemCallError, IOError => err - logger.warn { "Unable to open socket: #{err.class.name}, #{err.message}" } if logger - mark_dead err - end - - return @sock - end - - def connect_to(host, port, timeout=nil) - io = MemCache::BufferedIO.new(TCPSocket.new(host, port)) - io.read_timeout = timeout - io - end - - ## - # Close the connection to the memcached server targeted by this - # object. The server is not considered dead. - - def close - @sock.close if @sock && !@sock.closed? - @sock = nil - @retry = nil - @status = "NOT CONNECTED" - end - - ## - # Mark the server as dead and close its socket. - - def mark_dead(error) - @sock.close if @sock && !@sock.closed? - @sock = nil - @retry = Time.now + RETRY_DELAY - - reason = "#{error.class.name}: #{error.message}" - @status = sprintf "%s:%s DEAD (%s), will retry at %s", @host, @port, reason, @retry - @logger.info { @status } if @logger - end - - end - - ## - # Base MemCache exception class. - - class MemCacheError < RuntimeError; end - - class BufferedIO < Net::BufferedIO # :nodoc: - BUFSIZE = 1024 * 16 - - # An implementation similar to this is in *trunk* for 1.9. When it - # gets released, this method can be removed when using 1.9 - def rbuf_fill - begin - @rbuf << @io.read_nonblock(BUFSIZE) - rescue Errno::EWOULDBLOCK - retry unless @read_timeout - if IO.select([@io], nil, nil, @read_timeout) - retry - else - raise Timeout::Error, 'IO timeout' - end - end - end - - def setsockopt *args - @io.setsockopt *args - end - - def gets - readuntil("\n") - end - end - -end - -module Continuum - POINTS_PER_SERVER = 160 # this is the default in libmemcached - - # Find the closest index in Continuum with value <= the given value - def self.binary_search(ary, value, &block) - upper = ary.size - 1 - lower = 0 - idx = 0 - - while(lower <= upper) do - idx = (lower + upper) / 2 - comp = ary[idx].value <=> value - - if comp == 0 - return idx - elsif comp > 0 - upper = idx - 1 - else - lower = idx + 1 - end - end - return upper - end - - class Entry - attr_reader :value - attr_reader :server - - def initialize(val, srv) - @value = val - @server = srv - end - - def inspect - "<#{value}, #{server.host}:#{server.port}>" - end - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb deleted file mode 100644 index c8bdbeec..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +++ /dev/null @@ -1,33 +0,0 @@ -#-- -# Copyright (c) 2005-2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -# Add the directory containing this file to the start of the load path if it -# isn't there already. -$:.unshift(File.dirname(__FILE__)) unless - $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) - -require 'tzinfo/timezone' -# require 'tzinfo/country' -# require 'tzinfo/tzdataparser' -# require 'tzinfo/timezone_proxy' -require 'tzinfo/data_timezone' -require 'tzinfo/linked_timezone' \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb deleted file mode 100644 index 5eccbdf0..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +++ /dev/null @@ -1,47 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/info_timezone' - -module TZInfo - - # A Timezone based on a DataTimezoneInfo. - class DataTimezone < InfoTimezone #:nodoc: - - # Returns the TimezonePeriod for the given UTC time. utc can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in utc is ignored (it is treated as a UTC time). - # - # If no TimezonePeriod could be found, PeriodNotFound is raised. - def period_for_utc(utc) - info.period_for_utc(utc) - end - - # Returns the set of TimezonePeriod instances that are valid for the given - # local time as an array. If you just want a single period, use - # period_for_local instead and specify how abiguities should be resolved. - # Raises PeriodNotFound if no periods are found for the given time. - def periods_for_local(local) - info.periods_for_local(local) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb deleted file mode 100644 index a45d9455..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +++ /dev/null @@ -1,228 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/time_or_datetime' -require 'tzinfo/timezone_info' -require 'tzinfo/timezone_offset_info' -require 'tzinfo/timezone_period' -require 'tzinfo/timezone_transition_info' - -module TZInfo - # Thrown if no offsets have been defined when calling period_for_utc or - # periods_for_local. Indicates an error in the timezone data. - class NoOffsetsDefined < StandardError - end - - # Represents a (non-linked) timezone defined in a data module. - class DataTimezoneInfo < TimezoneInfo #:nodoc: - - # Constructs a new TimezoneInfo with its identifier. - def initialize(identifier) - super(identifier) - @offsets = {} - @transitions = [] - @previous_offset = nil - @transitions_index = nil - end - - # Defines a offset. The id uniquely identifies this offset within the - # timezone. utc_offset and std_offset define the offset in seconds of - # standard time from UTC and daylight savings from standard time - # respectively. abbreviation describes the timezone offset (e.g. GMT, BST, - # EST or EDT). - # - # The first offset to be defined is treated as the offset that applies - # until the first transition. This will usually be in Local Mean Time (LMT). - # - # ArgumentError will be raised if the id is already defined. - def offset(id, utc_offset, std_offset, abbreviation) - raise ArgumentError, 'Offset already defined' if @offsets.has_key?(id) - - offset = TimezoneOffsetInfo.new(utc_offset, std_offset, abbreviation) - @offsets[id] = offset - @previous_offset = offset unless @previous_offset - end - - # Defines a transition. Transitions must be defined in chronological order. - # ArgumentError will be raised if a transition is added out of order. - # offset_id refers to an id defined with offset. ArgumentError will be - # raised if the offset_id cannot be found. numerator_or_time and - # denomiator specify the time the transition occurs as. See - # TimezoneTransitionInfo for more detail about specifying times. - def transition(year, month, offset_id, numerator_or_time, denominator = nil) - offset = @offsets[offset_id] - raise ArgumentError, 'Offset not found' unless offset - - if @transitions_index - if year < @last_year || (year == @last_year && month < @last_month) - raise ArgumentError, 'Transitions must be increasing date order' - end - - # Record the position of the first transition with this index. - index = transition_index(year, month) - @transitions_index[index] ||= @transitions.length - - # Fill in any gaps - (index - 1).downto(0) do |i| - break if @transitions_index[i] - @transitions_index[i] = @transitions.length - end - else - @transitions_index = [@transitions.length] - @start_year = year - @start_month = month - end - - @transitions << TimezoneTransitionInfo.new(offset, @previous_offset, - numerator_or_time, denominator) - @last_year = year - @last_month = month - @previous_offset = offset - end - - # Returns the TimezonePeriod for the given UTC time. - # Raises NoOffsetsDefined if no offsets have been defined. - def period_for_utc(utc) - unless @transitions.empty? - utc = TimeOrDateTime.wrap(utc) - index = transition_index(utc.year, utc.mon) - - start_transition = nil - start = transition_before_end(index) - if start - start.downto(0) do |i| - if @transitions[i].at <= utc - start_transition = @transitions[i] - break - end - end - end - - end_transition = nil - start = transition_after_start(index) - if start - start.upto(@transitions.length - 1) do |i| - if @transitions[i].at > utc - end_transition = @transitions[i] - break - end - end - end - - if start_transition || end_transition - TimezonePeriod.new(start_transition, end_transition) - else - # Won't happen since there are transitions. Must always find one - # transition that is either >= or < the specified time. - raise 'No transitions found in search' - end - else - raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset - TimezonePeriod.new(nil, nil, @previous_offset) - end - end - - # Returns the set of TimezonePeriods for the given local time as an array. - # Results returned are ordered by increasing UTC start date. - # Returns an empty array if no periods are found for the given time. - # Raises NoOffsetsDefined if no offsets have been defined. - def periods_for_local(local) - unless @transitions.empty? - local = TimeOrDateTime.wrap(local) - index = transition_index(local.year, local.mon) - - result = [] - - start_index = transition_after_start(index - 1) - if start_index && @transitions[start_index].local_end > local - if start_index > 0 - if @transitions[start_index - 1].local_start <= local - result << TimezonePeriod.new(@transitions[start_index - 1], @transitions[start_index]) - end - else - result << TimezonePeriod.new(nil, @transitions[start_index]) - end - end - - end_index = transition_before_end(index + 1) - - if end_index - start_index = end_index unless start_index - - start_index.upto(transition_before_end(index + 1)) do |i| - if @transitions[i].local_start <= local - if i + 1 < @transitions.length - if @transitions[i + 1].local_end > local - result << TimezonePeriod.new(@transitions[i], @transitions[i + 1]) - end - else - result << TimezonePeriod.new(@transitions[i], nil) - end - end - end - end - - result - else - raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset - [TimezonePeriod.new(nil, nil, @previous_offset)] - end - end - - private - # Returns the index into the @transitions_index array for a given year - # and month. - def transition_index(year, month) - index = (year - @start_year) * 2 - index += 1 if month > 6 - index -= 1 if @start_month > 6 - index - end - - # Returns the index into @transitions of the first transition that occurs - # on or after the start of the given index into @transitions_index. - # Returns nil if there are no such transitions. - def transition_after_start(index) - if index >= @transitions_index.length - nil - else - index = 0 if index < 0 - @transitions_index[index] - end - end - - # Returns the index into @transitions of the first transition that occurs - # before the end of the given index into @transitions_index. - # Returns nil if there are no such transitions. - def transition_before_end(index) - index = index + 1 - - if index <= 0 - nil - elsif index >= @transitions_index.length - @transitions.length - 1 - else - @transitions_index[index] - 1 - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb deleted file mode 100644 index 8c5f2557..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Algiers - include TimezoneDefinition - - timezone 'Africa/Algiers' do |tz| - tz.offset :o0, 732, 0, :LMT - tz.offset :o1, 561, 0, :PMT - tz.offset :o2, 0, 0, :WET - tz.offset :o3, 0, 3600, :WEST - tz.offset :o4, 3600, 0, :CET - tz.offset :o5, 3600, 3600, :CEST - - tz.transition 1891, 3, :o1, 2170625843, 900 - tz.transition 1911, 3, :o2, 69670267013, 28800 - tz.transition 1916, 6, :o3, 58104707, 24 - tz.transition 1916, 10, :o2, 58107323, 24 - tz.transition 1917, 3, :o3, 58111499, 24 - tz.transition 1917, 10, :o2, 58116227, 24 - tz.transition 1918, 3, :o3, 58119899, 24 - tz.transition 1918, 10, :o2, 58124963, 24 - tz.transition 1919, 3, :o3, 58128467, 24 - tz.transition 1919, 10, :o2, 58133699, 24 - tz.transition 1920, 2, :o3, 58136867, 24 - tz.transition 1920, 10, :o2, 58142915, 24 - tz.transition 1921, 3, :o3, 58146323, 24 - tz.transition 1921, 6, :o2, 58148699, 24 - tz.transition 1939, 9, :o3, 58308443, 24 - tz.transition 1939, 11, :o2, 4859173, 2 - tz.transition 1940, 2, :o4, 29156215, 12 - tz.transition 1944, 4, :o5, 58348405, 24 - tz.transition 1944, 10, :o4, 4862743, 2 - tz.transition 1945, 4, :o5, 58357141, 24 - tz.transition 1945, 9, :o4, 58361147, 24 - tz.transition 1946, 10, :o2, 58370411, 24 - tz.transition 1956, 1, :o4, 4871003, 2 - tz.transition 1963, 4, :o2, 58515203, 24 - tz.transition 1971, 4, :o3, 41468400 - tz.transition 1971, 9, :o2, 54774000 - tz.transition 1977, 5, :o3, 231724800 - tz.transition 1977, 10, :o4, 246236400 - tz.transition 1978, 3, :o5, 259545600 - tz.transition 1978, 9, :o4, 275274000 - tz.transition 1979, 10, :o2, 309740400 - tz.transition 1980, 4, :o3, 325468800 - tz.transition 1980, 10, :o2, 341802000 - tz.transition 1981, 5, :o4, 357523200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb deleted file mode 100644 index 6e6daf35..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +++ /dev/null @@ -1,219 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Cairo - include TimezoneDefinition - - timezone 'Africa/Cairo' do |tz| - tz.offset :o0, 7500, 0, :LMT - tz.offset :o1, 7200, 0, :EET - tz.offset :o2, 7200, 3600, :EEST - - tz.transition 1900, 9, :o1, 695604503, 288 - tz.transition 1940, 7, :o2, 29157905, 12 - tz.transition 1940, 9, :o1, 19439227, 8 - tz.transition 1941, 4, :o2, 29161193, 12 - tz.transition 1941, 9, :o1, 19442027, 8 - tz.transition 1942, 3, :o2, 29165405, 12 - tz.transition 1942, 10, :o1, 19445275, 8 - tz.transition 1943, 3, :o2, 29169785, 12 - tz.transition 1943, 10, :o1, 19448235, 8 - tz.transition 1944, 3, :o2, 29174177, 12 - tz.transition 1944, 10, :o1, 19451163, 8 - tz.transition 1945, 4, :o2, 29178737, 12 - tz.transition 1945, 10, :o1, 19454083, 8 - tz.transition 1957, 5, :o2, 29231621, 12 - tz.transition 1957, 9, :o1, 19488899, 8 - tz.transition 1958, 4, :o2, 29235893, 12 - tz.transition 1958, 9, :o1, 19491819, 8 - tz.transition 1959, 4, :o2, 58480547, 24 - tz.transition 1959, 9, :o1, 4873683, 2 - tz.transition 1960, 4, :o2, 58489331, 24 - tz.transition 1960, 9, :o1, 4874415, 2 - tz.transition 1961, 4, :o2, 58498091, 24 - tz.transition 1961, 9, :o1, 4875145, 2 - tz.transition 1962, 4, :o2, 58506851, 24 - tz.transition 1962, 9, :o1, 4875875, 2 - tz.transition 1963, 4, :o2, 58515611, 24 - tz.transition 1963, 9, :o1, 4876605, 2 - tz.transition 1964, 4, :o2, 58524395, 24 - tz.transition 1964, 9, :o1, 4877337, 2 - tz.transition 1965, 4, :o2, 58533155, 24 - tz.transition 1965, 9, :o1, 4878067, 2 - tz.transition 1966, 4, :o2, 58541915, 24 - tz.transition 1966, 10, :o1, 4878799, 2 - tz.transition 1967, 4, :o2, 58550675, 24 - tz.transition 1967, 10, :o1, 4879529, 2 - tz.transition 1968, 4, :o2, 58559459, 24 - tz.transition 1968, 10, :o1, 4880261, 2 - tz.transition 1969, 4, :o2, 58568219, 24 - tz.transition 1969, 10, :o1, 4880991, 2 - tz.transition 1970, 4, :o2, 10364400 - tz.transition 1970, 10, :o1, 23587200 - tz.transition 1971, 4, :o2, 41900400 - tz.transition 1971, 10, :o1, 55123200 - tz.transition 1972, 4, :o2, 73522800 - tz.transition 1972, 10, :o1, 86745600 - tz.transition 1973, 4, :o2, 105058800 - tz.transition 1973, 10, :o1, 118281600 - tz.transition 1974, 4, :o2, 136594800 - tz.transition 1974, 10, :o1, 149817600 - tz.transition 1975, 4, :o2, 168130800 - tz.transition 1975, 10, :o1, 181353600 - tz.transition 1976, 4, :o2, 199753200 - tz.transition 1976, 10, :o1, 212976000 - tz.transition 1977, 4, :o2, 231289200 - tz.transition 1977, 10, :o1, 244512000 - tz.transition 1978, 4, :o2, 262825200 - tz.transition 1978, 10, :o1, 276048000 - tz.transition 1979, 4, :o2, 294361200 - tz.transition 1979, 10, :o1, 307584000 - tz.transition 1980, 4, :o2, 325983600 - tz.transition 1980, 10, :o1, 339206400 - tz.transition 1981, 4, :o2, 357519600 - tz.transition 1981, 10, :o1, 370742400 - tz.transition 1982, 7, :o2, 396399600 - tz.transition 1982, 10, :o1, 402278400 - tz.transition 1983, 7, :o2, 426812400 - tz.transition 1983, 10, :o1, 433814400 - tz.transition 1984, 4, :o2, 452214000 - tz.transition 1984, 10, :o1, 465436800 - tz.transition 1985, 4, :o2, 483750000 - tz.transition 1985, 10, :o1, 496972800 - tz.transition 1986, 4, :o2, 515286000 - tz.transition 1986, 10, :o1, 528508800 - tz.transition 1987, 4, :o2, 546822000 - tz.transition 1987, 10, :o1, 560044800 - tz.transition 1988, 4, :o2, 578444400 - tz.transition 1988, 10, :o1, 591667200 - tz.transition 1989, 5, :o2, 610412400 - tz.transition 1989, 10, :o1, 623203200 - tz.transition 1990, 4, :o2, 641516400 - tz.transition 1990, 10, :o1, 654739200 - tz.transition 1991, 4, :o2, 673052400 - tz.transition 1991, 10, :o1, 686275200 - tz.transition 1992, 4, :o2, 704674800 - tz.transition 1992, 10, :o1, 717897600 - tz.transition 1993, 4, :o2, 736210800 - tz.transition 1993, 10, :o1, 749433600 - tz.transition 1994, 4, :o2, 767746800 - tz.transition 1994, 10, :o1, 780969600 - tz.transition 1995, 4, :o2, 799020000 - tz.transition 1995, 9, :o1, 812322000 - tz.transition 1996, 4, :o2, 830469600 - tz.transition 1996, 9, :o1, 843771600 - tz.transition 1997, 4, :o2, 861919200 - tz.transition 1997, 9, :o1, 875221200 - tz.transition 1998, 4, :o2, 893368800 - tz.transition 1998, 9, :o1, 906670800 - tz.transition 1999, 4, :o2, 925423200 - tz.transition 1999, 9, :o1, 938725200 - tz.transition 2000, 4, :o2, 956872800 - tz.transition 2000, 9, :o1, 970174800 - tz.transition 2001, 4, :o2, 988322400 - tz.transition 2001, 9, :o1, 1001624400 - tz.transition 2002, 4, :o2, 1019772000 - tz.transition 2002, 9, :o1, 1033074000 - tz.transition 2003, 4, :o2, 1051221600 - tz.transition 2003, 9, :o1, 1064523600 - tz.transition 2004, 4, :o2, 1083276000 - tz.transition 2004, 9, :o1, 1096578000 - tz.transition 2005, 4, :o2, 1114725600 - tz.transition 2005, 9, :o1, 1128027600 - tz.transition 2006, 4, :o2, 1146175200 - tz.transition 2006, 9, :o1, 1158872400 - tz.transition 2007, 4, :o2, 1177624800 - tz.transition 2007, 9, :o1, 1189112400 - tz.transition 2008, 4, :o2, 1209074400 - tz.transition 2008, 8, :o1, 1219957200 - tz.transition 2009, 4, :o2, 1240524000 - tz.transition 2009, 8, :o1, 1251406800 - tz.transition 2010, 4, :o2, 1272578400 - tz.transition 2010, 8, :o1, 1282856400 - tz.transition 2011, 4, :o2, 1304028000 - tz.transition 2011, 8, :o1, 1314306000 - tz.transition 2012, 4, :o2, 1335477600 - tz.transition 2012, 8, :o1, 1346360400 - tz.transition 2013, 4, :o2, 1366927200 - tz.transition 2013, 8, :o1, 1377810000 - tz.transition 2014, 4, :o2, 1398376800 - tz.transition 2014, 8, :o1, 1409259600 - tz.transition 2015, 4, :o2, 1429826400 - tz.transition 2015, 8, :o1, 1440709200 - tz.transition 2016, 4, :o2, 1461880800 - tz.transition 2016, 8, :o1, 1472158800 - tz.transition 2017, 4, :o2, 1493330400 - tz.transition 2017, 8, :o1, 1504213200 - tz.transition 2018, 4, :o2, 1524780000 - tz.transition 2018, 8, :o1, 1535662800 - tz.transition 2019, 4, :o2, 1556229600 - tz.transition 2019, 8, :o1, 1567112400 - tz.transition 2020, 4, :o2, 1587679200 - tz.transition 2020, 8, :o1, 1598562000 - tz.transition 2021, 4, :o2, 1619733600 - tz.transition 2021, 8, :o1, 1630011600 - tz.transition 2022, 4, :o2, 1651183200 - tz.transition 2022, 8, :o1, 1661461200 - tz.transition 2023, 4, :o2, 1682632800 - tz.transition 2023, 8, :o1, 1693515600 - tz.transition 2024, 4, :o2, 1714082400 - tz.transition 2024, 8, :o1, 1724965200 - tz.transition 2025, 4, :o2, 1745532000 - tz.transition 2025, 8, :o1, 1756414800 - tz.transition 2026, 4, :o2, 1776981600 - tz.transition 2026, 8, :o1, 1787864400 - tz.transition 2027, 4, :o2, 1809036000 - tz.transition 2027, 8, :o1, 1819314000 - tz.transition 2028, 4, :o2, 1840485600 - tz.transition 2028, 8, :o1, 1851368400 - tz.transition 2029, 4, :o2, 1871935200 - tz.transition 2029, 8, :o1, 1882818000 - tz.transition 2030, 4, :o2, 1903384800 - tz.transition 2030, 8, :o1, 1914267600 - tz.transition 2031, 4, :o2, 1934834400 - tz.transition 2031, 8, :o1, 1945717200 - tz.transition 2032, 4, :o2, 1966888800 - tz.transition 2032, 8, :o1, 1977166800 - tz.transition 2033, 4, :o2, 1998338400 - tz.transition 2033, 8, :o1, 2008616400 - tz.transition 2034, 4, :o2, 2029788000 - tz.transition 2034, 8, :o1, 2040670800 - tz.transition 2035, 4, :o2, 2061237600 - tz.transition 2035, 8, :o1, 2072120400 - tz.transition 2036, 4, :o2, 2092687200 - tz.transition 2036, 8, :o1, 2103570000 - tz.transition 2037, 4, :o2, 2124136800 - tz.transition 2037, 8, :o1, 2135019600 - tz.transition 2038, 4, :o2, 29586521, 12 - tz.transition 2038, 8, :o1, 19725299, 8 - tz.transition 2039, 4, :o2, 29590889, 12 - tz.transition 2039, 8, :o1, 19728211, 8 - tz.transition 2040, 4, :o2, 29595257, 12 - tz.transition 2040, 8, :o1, 19731179, 8 - tz.transition 2041, 4, :o2, 29599625, 12 - tz.transition 2041, 8, :o1, 19734091, 8 - tz.transition 2042, 4, :o2, 29603993, 12 - tz.transition 2042, 8, :o1, 19737003, 8 - tz.transition 2043, 4, :o2, 29608361, 12 - tz.transition 2043, 8, :o1, 19739915, 8 - tz.transition 2044, 4, :o2, 29612813, 12 - tz.transition 2044, 8, :o1, 19742827, 8 - tz.transition 2045, 4, :o2, 29617181, 12 - tz.transition 2045, 8, :o1, 19745795, 8 - tz.transition 2046, 4, :o2, 29621549, 12 - tz.transition 2046, 8, :o1, 19748707, 8 - tz.transition 2047, 4, :o2, 29625917, 12 - tz.transition 2047, 8, :o1, 19751619, 8 - tz.transition 2048, 4, :o2, 29630285, 12 - tz.transition 2048, 8, :o1, 19754531, 8 - tz.transition 2049, 4, :o2, 29634737, 12 - tz.transition 2049, 8, :o1, 19757443, 8 - tz.transition 2050, 4, :o2, 29639105, 12 - tz.transition 2050, 8, :o1, 19760355, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb deleted file mode 100644 index d1eb5c57..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Casablanca - include TimezoneDefinition - - timezone 'Africa/Casablanca' do |tz| - tz.offset :o0, -1820, 0, :LMT - tz.offset :o1, 0, 0, :WET - tz.offset :o2, 0, 3600, :WEST - tz.offset :o3, 3600, 0, :CET - - tz.transition 1913, 10, :o1, 10454687371, 4320 - tz.transition 1939, 9, :o2, 4859037, 2 - tz.transition 1939, 11, :o1, 58310075, 24 - tz.transition 1940, 2, :o2, 4859369, 2 - tz.transition 1945, 11, :o1, 58362659, 24 - tz.transition 1950, 6, :o2, 4866887, 2 - tz.transition 1950, 10, :o1, 58406003, 24 - tz.transition 1967, 6, :o2, 2439645, 1 - tz.transition 1967, 9, :o1, 58554347, 24 - tz.transition 1974, 6, :o2, 141264000 - tz.transition 1974, 8, :o1, 147222000 - tz.transition 1976, 5, :o2, 199756800 - tz.transition 1976, 7, :o1, 207702000 - tz.transition 1977, 5, :o2, 231292800 - tz.transition 1977, 9, :o1, 244249200 - tz.transition 1978, 6, :o2, 265507200 - tz.transition 1978, 8, :o1, 271033200 - tz.transition 1984, 3, :o3, 448243200 - tz.transition 1985, 12, :o1, 504918000 - tz.transition 2008, 6, :o2, 1212278400 - tz.transition 2008, 8, :o1, 1220223600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb deleted file mode 100644 index 070c95ae..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Harare - include TimezoneDefinition - - timezone 'Africa/Harare' do |tz| - tz.offset :o0, 7452, 0, :LMT - tz.offset :o1, 7200, 0, :CAT - - tz.transition 1903, 2, :o1, 1932939531, 800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb deleted file mode 100644 index f0af0d8e..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Johannesburg - include TimezoneDefinition - - timezone 'Africa/Johannesburg' do |tz| - tz.offset :o0, 6720, 0, :LMT - tz.offset :o1, 5400, 0, :SAST - tz.offset :o2, 7200, 0, :SAST - tz.offset :o3, 7200, 3600, :SAST - - tz.transition 1892, 2, :o1, 108546139, 45 - tz.transition 1903, 2, :o2, 38658791, 16 - tz.transition 1942, 9, :o3, 4861245, 2 - tz.transition 1943, 3, :o2, 58339307, 24 - tz.transition 1943, 9, :o3, 4861973, 2 - tz.transition 1944, 3, :o2, 58348043, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb deleted file mode 100644 index 40e711fa..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Monrovia - include TimezoneDefinition - - timezone 'Africa/Monrovia' do |tz| - tz.offset :o0, -2588, 0, :LMT - tz.offset :o1, -2588, 0, :MMT - tz.offset :o2, -2670, 0, :LRT - tz.offset :o3, 0, 0, :GMT - - tz.transition 1882, 1, :o1, 52022445047, 21600 - tz.transition 1919, 3, :o2, 52315600247, 21600 - tz.transition 1972, 5, :o3, 73529070 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb deleted file mode 100644 index 7b0a2f43..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Nairobi - include TimezoneDefinition - - timezone 'Africa/Nairobi' do |tz| - tz.offset :o0, 8836, 0, :LMT - tz.offset :o1, 10800, 0, :EAT - tz.offset :o2, 9000, 0, :BEAT - tz.offset :o3, 9885, 0, :BEAUT - - tz.transition 1928, 6, :o1, 52389253391, 21600 - tz.transition 1929, 12, :o2, 19407819, 8 - tz.transition 1939, 12, :o3, 116622211, 48 - tz.transition 1959, 12, :o1, 14036742061, 5760 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb deleted file mode 100644 index 8f4dd31d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +++ /dev/null @@ -1,166 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Argentina - module Buenos_Aires - include TimezoneDefinition - - timezone 'America/Argentina/Buenos_Aires' do |tz| - tz.offset :o0, -14028, 0, :LMT - tz.offset :o1, -15408, 0, :CMT - tz.offset :o2, -14400, 0, :ART - tz.offset :o3, -14400, 3600, :ARST - tz.offset :o4, -10800, 0, :ART - tz.offset :o5, -10800, 3600, :ARST - - tz.transition 1894, 10, :o1, 17374555169, 7200 - tz.transition 1920, 5, :o2, 1453467407, 600 - tz.transition 1930, 12, :o3, 7278935, 3 - tz.transition 1931, 4, :o2, 19411461, 8 - tz.transition 1931, 10, :o3, 7279889, 3 - tz.transition 1932, 3, :o2, 19414141, 8 - tz.transition 1932, 11, :o3, 7281038, 3 - tz.transition 1933, 3, :o2, 19417061, 8 - tz.transition 1933, 11, :o3, 7282133, 3 - tz.transition 1934, 3, :o2, 19419981, 8 - tz.transition 1934, 11, :o3, 7283228, 3 - tz.transition 1935, 3, :o2, 19422901, 8 - tz.transition 1935, 11, :o3, 7284323, 3 - tz.transition 1936, 3, :o2, 19425829, 8 - tz.transition 1936, 11, :o3, 7285421, 3 - tz.transition 1937, 3, :o2, 19428749, 8 - tz.transition 1937, 11, :o3, 7286516, 3 - tz.transition 1938, 3, :o2, 19431669, 8 - tz.transition 1938, 11, :o3, 7287611, 3 - tz.transition 1939, 3, :o2, 19434589, 8 - tz.transition 1939, 11, :o3, 7288706, 3 - tz.transition 1940, 3, :o2, 19437517, 8 - tz.transition 1940, 7, :o3, 7289435, 3 - tz.transition 1941, 6, :o2, 19441285, 8 - tz.transition 1941, 10, :o3, 7290848, 3 - tz.transition 1943, 8, :o2, 19447501, 8 - tz.transition 1943, 10, :o3, 7293038, 3 - tz.transition 1946, 3, :o2, 19455045, 8 - tz.transition 1946, 10, :o3, 7296284, 3 - tz.transition 1963, 10, :o2, 19506429, 8 - tz.transition 1963, 12, :o3, 7315136, 3 - tz.transition 1964, 3, :o2, 19507645, 8 - tz.transition 1964, 10, :o3, 7316051, 3 - tz.transition 1965, 3, :o2, 19510565, 8 - tz.transition 1965, 10, :o3, 7317146, 3 - tz.transition 1966, 3, :o2, 19513485, 8 - tz.transition 1966, 10, :o3, 7318241, 3 - tz.transition 1967, 4, :o2, 19516661, 8 - tz.transition 1967, 10, :o3, 7319294, 3 - tz.transition 1968, 4, :o2, 19519629, 8 - tz.transition 1968, 10, :o3, 7320407, 3 - tz.transition 1969, 4, :o2, 19522541, 8 - tz.transition 1969, 10, :o4, 7321499, 3 - tz.transition 1974, 1, :o5, 128142000 - tz.transition 1974, 5, :o4, 136605600 - tz.transition 1988, 12, :o5, 596948400 - tz.transition 1989, 3, :o4, 605066400 - tz.transition 1989, 10, :o5, 624423600 - tz.transition 1990, 3, :o4, 636516000 - tz.transition 1990, 10, :o5, 656478000 - tz.transition 1991, 3, :o4, 667965600 - tz.transition 1991, 10, :o5, 687927600 - tz.transition 1992, 3, :o4, 699415200 - tz.transition 1992, 10, :o5, 719377200 - tz.transition 1993, 3, :o4, 731469600 - tz.transition 1999, 10, :o3, 938919600 - tz.transition 2000, 3, :o4, 952052400 - tz.transition 2007, 12, :o5, 1198983600 - tz.transition 2008, 3, :o4, 1205632800 - tz.transition 2008, 10, :o5, 1224385200 - tz.transition 2009, 3, :o4, 1237082400 - tz.transition 2009, 10, :o5, 1255834800 - tz.transition 2010, 3, :o4, 1269136800 - tz.transition 2010, 10, :o5, 1287284400 - tz.transition 2011, 3, :o4, 1300586400 - tz.transition 2011, 10, :o5, 1318734000 - tz.transition 2012, 3, :o4, 1332036000 - tz.transition 2012, 10, :o5, 1350788400 - tz.transition 2013, 3, :o4, 1363485600 - tz.transition 2013, 10, :o5, 1382238000 - tz.transition 2014, 3, :o4, 1394935200 - tz.transition 2014, 10, :o5, 1413687600 - tz.transition 2015, 3, :o4, 1426384800 - tz.transition 2015, 10, :o5, 1445137200 - tz.transition 2016, 3, :o4, 1458439200 - tz.transition 2016, 10, :o5, 1476586800 - tz.transition 2017, 3, :o4, 1489888800 - tz.transition 2017, 10, :o5, 1508036400 - tz.transition 2018, 3, :o4, 1521338400 - tz.transition 2018, 10, :o5, 1540090800 - tz.transition 2019, 3, :o4, 1552788000 - tz.transition 2019, 10, :o5, 1571540400 - tz.transition 2020, 3, :o4, 1584237600 - tz.transition 2020, 10, :o5, 1602990000 - tz.transition 2021, 3, :o4, 1616292000 - tz.transition 2021, 10, :o5, 1634439600 - tz.transition 2022, 3, :o4, 1647741600 - tz.transition 2022, 10, :o5, 1665889200 - tz.transition 2023, 3, :o4, 1679191200 - tz.transition 2023, 10, :o5, 1697338800 - tz.transition 2024, 3, :o4, 1710640800 - tz.transition 2024, 10, :o5, 1729393200 - tz.transition 2025, 3, :o4, 1742090400 - tz.transition 2025, 10, :o5, 1760842800 - tz.transition 2026, 3, :o4, 1773540000 - tz.transition 2026, 10, :o5, 1792292400 - tz.transition 2027, 3, :o4, 1805594400 - tz.transition 2027, 10, :o5, 1823742000 - tz.transition 2028, 3, :o4, 1837044000 - tz.transition 2028, 10, :o5, 1855191600 - tz.transition 2029, 3, :o4, 1868493600 - tz.transition 2029, 10, :o5, 1887246000 - tz.transition 2030, 3, :o4, 1899943200 - tz.transition 2030, 10, :o5, 1918695600 - tz.transition 2031, 3, :o4, 1931392800 - tz.transition 2031, 10, :o5, 1950145200 - tz.transition 2032, 3, :o4, 1963447200 - tz.transition 2032, 10, :o5, 1981594800 - tz.transition 2033, 3, :o4, 1994896800 - tz.transition 2033, 10, :o5, 2013044400 - tz.transition 2034, 3, :o4, 2026346400 - tz.transition 2034, 10, :o5, 2044494000 - tz.transition 2035, 3, :o4, 2057796000 - tz.transition 2035, 10, :o5, 2076548400 - tz.transition 2036, 3, :o4, 2089245600 - tz.transition 2036, 10, :o5, 2107998000 - tz.transition 2037, 3, :o4, 2120695200 - tz.transition 2037, 10, :o5, 2139447600 - tz.transition 2038, 3, :o4, 29586043, 12 - tz.transition 2038, 10, :o5, 19725709, 8 - tz.transition 2039, 3, :o4, 29590411, 12 - tz.transition 2039, 10, :o5, 19728621, 8 - tz.transition 2040, 3, :o4, 29594779, 12 - tz.transition 2040, 10, :o5, 19731589, 8 - tz.transition 2041, 3, :o4, 29599147, 12 - tz.transition 2041, 10, :o5, 19734501, 8 - tz.transition 2042, 3, :o4, 29603515, 12 - tz.transition 2042, 10, :o5, 19737413, 8 - tz.transition 2043, 3, :o4, 29607883, 12 - tz.transition 2043, 10, :o5, 19740325, 8 - tz.transition 2044, 3, :o4, 29612335, 12 - tz.transition 2044, 10, :o5, 19743237, 8 - tz.transition 2045, 3, :o4, 29616703, 12 - tz.transition 2045, 10, :o5, 19746149, 8 - tz.transition 2046, 3, :o4, 29621071, 12 - tz.transition 2046, 10, :o5, 19749117, 8 - tz.transition 2047, 3, :o4, 29625439, 12 - tz.transition 2047, 10, :o5, 19752029, 8 - tz.transition 2048, 3, :o4, 29629807, 12 - tz.transition 2048, 10, :o5, 19754941, 8 - tz.transition 2049, 3, :o4, 29634259, 12 - tz.transition 2049, 10, :o5, 19757853, 8 - tz.transition 2050, 3, :o4, 29638627, 12 - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb deleted file mode 100644 index ba8be470..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Argentina - module San_Juan - include TimezoneDefinition - - timezone 'America/Argentina/San_Juan' do |tz| - tz.offset :o0, -16444, 0, :LMT - tz.offset :o1, -15408, 0, :CMT - tz.offset :o2, -14400, 0, :ART - tz.offset :o3, -14400, 3600, :ARST - tz.offset :o4, -10800, 0, :ART - tz.offset :o5, -10800, 3600, :ARST - tz.offset :o6, -14400, 0, :WART - - tz.transition 1894, 10, :o1, 52123666111, 21600 - tz.transition 1920, 5, :o2, 1453467407, 600 - tz.transition 1930, 12, :o3, 7278935, 3 - tz.transition 1931, 4, :o2, 19411461, 8 - tz.transition 1931, 10, :o3, 7279889, 3 - tz.transition 1932, 3, :o2, 19414141, 8 - tz.transition 1932, 11, :o3, 7281038, 3 - tz.transition 1933, 3, :o2, 19417061, 8 - tz.transition 1933, 11, :o3, 7282133, 3 - tz.transition 1934, 3, :o2, 19419981, 8 - tz.transition 1934, 11, :o3, 7283228, 3 - tz.transition 1935, 3, :o2, 19422901, 8 - tz.transition 1935, 11, :o3, 7284323, 3 - tz.transition 1936, 3, :o2, 19425829, 8 - tz.transition 1936, 11, :o3, 7285421, 3 - tz.transition 1937, 3, :o2, 19428749, 8 - tz.transition 1937, 11, :o3, 7286516, 3 - tz.transition 1938, 3, :o2, 19431669, 8 - tz.transition 1938, 11, :o3, 7287611, 3 - tz.transition 1939, 3, :o2, 19434589, 8 - tz.transition 1939, 11, :o3, 7288706, 3 - tz.transition 1940, 3, :o2, 19437517, 8 - tz.transition 1940, 7, :o3, 7289435, 3 - tz.transition 1941, 6, :o2, 19441285, 8 - tz.transition 1941, 10, :o3, 7290848, 3 - tz.transition 1943, 8, :o2, 19447501, 8 - tz.transition 1943, 10, :o3, 7293038, 3 - tz.transition 1946, 3, :o2, 19455045, 8 - tz.transition 1946, 10, :o3, 7296284, 3 - tz.transition 1963, 10, :o2, 19506429, 8 - tz.transition 1963, 12, :o3, 7315136, 3 - tz.transition 1964, 3, :o2, 19507645, 8 - tz.transition 1964, 10, :o3, 7316051, 3 - tz.transition 1965, 3, :o2, 19510565, 8 - tz.transition 1965, 10, :o3, 7317146, 3 - tz.transition 1966, 3, :o2, 19513485, 8 - tz.transition 1966, 10, :o3, 7318241, 3 - tz.transition 1967, 4, :o2, 19516661, 8 - tz.transition 1967, 10, :o3, 7319294, 3 - tz.transition 1968, 4, :o2, 19519629, 8 - tz.transition 1968, 10, :o3, 7320407, 3 - tz.transition 1969, 4, :o2, 19522541, 8 - tz.transition 1969, 10, :o4, 7321499, 3 - tz.transition 1974, 1, :o5, 128142000 - tz.transition 1974, 5, :o4, 136605600 - tz.transition 1988, 12, :o5, 596948400 - tz.transition 1989, 3, :o4, 605066400 - tz.transition 1989, 10, :o5, 624423600 - tz.transition 1990, 3, :o4, 636516000 - tz.transition 1990, 10, :o5, 656478000 - tz.transition 1991, 3, :o6, 667792800 - tz.transition 1991, 5, :o4, 673588800 - tz.transition 1991, 10, :o5, 687927600 - tz.transition 1992, 3, :o4, 699415200 - tz.transition 1992, 10, :o5, 719377200 - tz.transition 1993, 3, :o4, 731469600 - tz.transition 1999, 10, :o3, 938919600 - tz.transition 2000, 3, :o4, 952052400 - tz.transition 2004, 5, :o6, 1085972400 - tz.transition 2004, 7, :o4, 1090728000 - tz.transition 2007, 12, :o5, 1198983600 - tz.transition 2008, 3, :o4, 1205632800 - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb deleted file mode 100644 index ef96435c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Bogota - include TimezoneDefinition - - timezone 'America/Bogota' do |tz| - tz.offset :o0, -17780, 0, :LMT - tz.offset :o1, -17780, 0, :BMT - tz.offset :o2, -18000, 0, :COT - tz.offset :o3, -18000, 3600, :COST - - tz.transition 1884, 3, :o1, 10407954409, 4320 - tz.transition 1914, 11, :o2, 10456385929, 4320 - tz.transition 1992, 5, :o3, 704869200 - tz.transition 1993, 4, :o2, 733896000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb deleted file mode 100644 index 27392a54..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Caracas - include TimezoneDefinition - - timezone 'America/Caracas' do |tz| - tz.offset :o0, -16064, 0, :LMT - tz.offset :o1, -16060, 0, :CMT - tz.offset :o2, -16200, 0, :VET - tz.offset :o3, -14400, 0, :VET - - tz.transition 1890, 1, :o1, 1627673863, 675 - tz.transition 1912, 2, :o2, 10452001043, 4320 - tz.transition 1965, 1, :o3, 39020187, 16 - tz.transition 2007, 12, :o2, 1197183600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb deleted file mode 100644 index 0996857c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +++ /dev/null @@ -1,283 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Chicago - include TimezoneDefinition - - timezone 'America/Chicago' do |tz| - tz.offset :o0, -21036, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - tz.offset :o3, -18000, 0, :EST - tz.offset :o4, -21600, 3600, :CWT - tz.offset :o5, -21600, 3600, :CPT - - tz.transition 1883, 11, :o1, 9636533, 4 - tz.transition 1918, 3, :o2, 14530103, 6 - tz.transition 1918, 10, :o1, 58125451, 24 - tz.transition 1919, 3, :o2, 14532287, 6 - tz.transition 1919, 10, :o1, 58134187, 24 - tz.transition 1920, 6, :o2, 14534933, 6 - tz.transition 1920, 10, :o1, 58143091, 24 - tz.transition 1921, 3, :o2, 14536655, 6 - tz.transition 1921, 10, :o1, 58151827, 24 - tz.transition 1922, 4, :o2, 14539049, 6 - tz.transition 1922, 9, :o1, 58159723, 24 - tz.transition 1923, 4, :o2, 14541233, 6 - tz.transition 1923, 9, :o1, 58168627, 24 - tz.transition 1924, 4, :o2, 14543417, 6 - tz.transition 1924, 9, :o1, 58177363, 24 - tz.transition 1925, 4, :o2, 14545601, 6 - tz.transition 1925, 9, :o1, 58186099, 24 - tz.transition 1926, 4, :o2, 14547785, 6 - tz.transition 1926, 9, :o1, 58194835, 24 - tz.transition 1927, 4, :o2, 14549969, 6 - tz.transition 1927, 9, :o1, 58203571, 24 - tz.transition 1928, 4, :o2, 14552195, 6 - tz.transition 1928, 9, :o1, 58212475, 24 - tz.transition 1929, 4, :o2, 14554379, 6 - tz.transition 1929, 9, :o1, 58221211, 24 - tz.transition 1930, 4, :o2, 14556563, 6 - tz.transition 1930, 9, :o1, 58229947, 24 - tz.transition 1931, 4, :o2, 14558747, 6 - tz.transition 1931, 9, :o1, 58238683, 24 - tz.transition 1932, 4, :o2, 14560931, 6 - tz.transition 1932, 9, :o1, 58247419, 24 - tz.transition 1933, 4, :o2, 14563157, 6 - tz.transition 1933, 9, :o1, 58256155, 24 - tz.transition 1934, 4, :o2, 14565341, 6 - tz.transition 1934, 9, :o1, 58265059, 24 - tz.transition 1935, 4, :o2, 14567525, 6 - tz.transition 1935, 9, :o1, 58273795, 24 - tz.transition 1936, 3, :o3, 14569373, 6 - tz.transition 1936, 11, :o1, 58283707, 24 - tz.transition 1937, 4, :o2, 14571893, 6 - tz.transition 1937, 9, :o1, 58291267, 24 - tz.transition 1938, 4, :o2, 14574077, 6 - tz.transition 1938, 9, :o1, 58300003, 24 - tz.transition 1939, 4, :o2, 14576303, 6 - tz.transition 1939, 9, :o1, 58308739, 24 - tz.transition 1940, 4, :o2, 14578487, 6 - tz.transition 1940, 9, :o1, 58317643, 24 - tz.transition 1941, 4, :o2, 14580671, 6 - tz.transition 1941, 9, :o1, 58326379, 24 - tz.transition 1942, 2, :o4, 14582399, 6 - tz.transition 1945, 8, :o5, 58360379, 24 - tz.transition 1945, 9, :o1, 58361491, 24 - tz.transition 1946, 4, :o2, 14591633, 6 - tz.transition 1946, 9, :o1, 58370227, 24 - tz.transition 1947, 4, :o2, 14593817, 6 - tz.transition 1947, 9, :o1, 58378963, 24 - tz.transition 1948, 4, :o2, 14596001, 6 - tz.transition 1948, 9, :o1, 58387699, 24 - tz.transition 1949, 4, :o2, 14598185, 6 - tz.transition 1949, 9, :o1, 58396435, 24 - tz.transition 1950, 4, :o2, 14600411, 6 - tz.transition 1950, 9, :o1, 58405171, 24 - tz.transition 1951, 4, :o2, 14602595, 6 - tz.transition 1951, 9, :o1, 58414075, 24 - tz.transition 1952, 4, :o2, 14604779, 6 - tz.transition 1952, 9, :o1, 58422811, 24 - tz.transition 1953, 4, :o2, 14606963, 6 - tz.transition 1953, 9, :o1, 58431547, 24 - tz.transition 1954, 4, :o2, 14609147, 6 - tz.transition 1954, 9, :o1, 58440283, 24 - tz.transition 1955, 4, :o2, 14611331, 6 - tz.transition 1955, 10, :o1, 58449859, 24 - tz.transition 1956, 4, :o2, 14613557, 6 - tz.transition 1956, 10, :o1, 58458595, 24 - tz.transition 1957, 4, :o2, 14615741, 6 - tz.transition 1957, 10, :o1, 58467331, 24 - tz.transition 1958, 4, :o2, 14617925, 6 - tz.transition 1958, 10, :o1, 58476067, 24 - tz.transition 1959, 4, :o2, 14620109, 6 - tz.transition 1959, 10, :o1, 58484803, 24 - tz.transition 1960, 4, :o2, 14622293, 6 - tz.transition 1960, 10, :o1, 58493707, 24 - tz.transition 1961, 4, :o2, 14624519, 6 - tz.transition 1961, 10, :o1, 58502443, 24 - tz.transition 1962, 4, :o2, 14626703, 6 - tz.transition 1962, 10, :o1, 58511179, 24 - tz.transition 1963, 4, :o2, 14628887, 6 - tz.transition 1963, 10, :o1, 58519915, 24 - tz.transition 1964, 4, :o2, 14631071, 6 - tz.transition 1964, 10, :o1, 58528651, 24 - tz.transition 1965, 4, :o2, 14633255, 6 - tz.transition 1965, 10, :o1, 58537555, 24 - tz.transition 1966, 4, :o2, 14635439, 6 - tz.transition 1966, 10, :o1, 58546291, 24 - tz.transition 1967, 4, :o2, 14637665, 6 - tz.transition 1967, 10, :o1, 58555027, 24 - tz.transition 1968, 4, :o2, 14639849, 6 - tz.transition 1968, 10, :o1, 58563763, 24 - tz.transition 1969, 4, :o2, 14642033, 6 - tz.transition 1969, 10, :o1, 58572499, 24 - tz.transition 1970, 4, :o2, 9964800 - tz.transition 1970, 10, :o1, 25686000 - tz.transition 1971, 4, :o2, 41414400 - tz.transition 1971, 10, :o1, 57740400 - tz.transition 1972, 4, :o2, 73468800 - tz.transition 1972, 10, :o1, 89190000 - tz.transition 1973, 4, :o2, 104918400 - tz.transition 1973, 10, :o1, 120639600 - tz.transition 1974, 1, :o2, 126691200 - tz.transition 1974, 10, :o1, 152089200 - tz.transition 1975, 2, :o2, 162374400 - tz.transition 1975, 10, :o1, 183538800 - tz.transition 1976, 4, :o2, 199267200 - tz.transition 1976, 10, :o1, 215593200 - tz.transition 1977, 4, :o2, 230716800 - tz.transition 1977, 10, :o1, 247042800 - tz.transition 1978, 4, :o2, 262771200 - tz.transition 1978, 10, :o1, 278492400 - tz.transition 1979, 4, :o2, 294220800 - tz.transition 1979, 10, :o1, 309942000 - tz.transition 1980, 4, :o2, 325670400 - tz.transition 1980, 10, :o1, 341391600 - tz.transition 1981, 4, :o2, 357120000 - tz.transition 1981, 10, :o1, 372841200 - tz.transition 1982, 4, :o2, 388569600 - tz.transition 1982, 10, :o1, 404895600 - tz.transition 1983, 4, :o2, 420019200 - tz.transition 1983, 10, :o1, 436345200 - tz.transition 1984, 4, :o2, 452073600 - tz.transition 1984, 10, :o1, 467794800 - tz.transition 1985, 4, :o2, 483523200 - tz.transition 1985, 10, :o1, 499244400 - tz.transition 1986, 4, :o2, 514972800 - tz.transition 1986, 10, :o1, 530694000 - tz.transition 1987, 4, :o2, 544608000 - tz.transition 1987, 10, :o1, 562143600 - tz.transition 1988, 4, :o2, 576057600 - tz.transition 1988, 10, :o1, 594198000 - tz.transition 1989, 4, :o2, 607507200 - tz.transition 1989, 10, :o1, 625647600 - tz.transition 1990, 4, :o2, 638956800 - tz.transition 1990, 10, :o1, 657097200 - tz.transition 1991, 4, :o2, 671011200 - tz.transition 1991, 10, :o1, 688546800 - tz.transition 1992, 4, :o2, 702460800 - tz.transition 1992, 10, :o1, 719996400 - tz.transition 1993, 4, :o2, 733910400 - tz.transition 1993, 10, :o1, 752050800 - tz.transition 1994, 4, :o2, 765360000 - tz.transition 1994, 10, :o1, 783500400 - tz.transition 1995, 4, :o2, 796809600 - tz.transition 1995, 10, :o1, 814950000 - tz.transition 1996, 4, :o2, 828864000 - tz.transition 1996, 10, :o1, 846399600 - tz.transition 1997, 4, :o2, 860313600 - tz.transition 1997, 10, :o1, 877849200 - tz.transition 1998, 4, :o2, 891763200 - tz.transition 1998, 10, :o1, 909298800 - tz.transition 1999, 4, :o2, 923212800 - tz.transition 1999, 10, :o1, 941353200 - tz.transition 2000, 4, :o2, 954662400 - tz.transition 2000, 10, :o1, 972802800 - tz.transition 2001, 4, :o2, 986112000 - tz.transition 2001, 10, :o1, 1004252400 - tz.transition 2002, 4, :o2, 1018166400 - tz.transition 2002, 10, :o1, 1035702000 - tz.transition 2003, 4, :o2, 1049616000 - tz.transition 2003, 10, :o1, 1067151600 - tz.transition 2004, 4, :o2, 1081065600 - tz.transition 2004, 10, :o1, 1099206000 - tz.transition 2005, 4, :o2, 1112515200 - tz.transition 2005, 10, :o1, 1130655600 - tz.transition 2006, 4, :o2, 1143964800 - tz.transition 2006, 10, :o1, 1162105200 - tz.transition 2007, 3, :o2, 1173600000 - tz.transition 2007, 11, :o1, 1194159600 - tz.transition 2008, 3, :o2, 1205049600 - tz.transition 2008, 11, :o1, 1225609200 - tz.transition 2009, 3, :o2, 1236499200 - tz.transition 2009, 11, :o1, 1257058800 - tz.transition 2010, 3, :o2, 1268553600 - tz.transition 2010, 11, :o1, 1289113200 - tz.transition 2011, 3, :o2, 1300003200 - tz.transition 2011, 11, :o1, 1320562800 - tz.transition 2012, 3, :o2, 1331452800 - tz.transition 2012, 11, :o1, 1352012400 - tz.transition 2013, 3, :o2, 1362902400 - tz.transition 2013, 11, :o1, 1383462000 - tz.transition 2014, 3, :o2, 1394352000 - tz.transition 2014, 11, :o1, 1414911600 - tz.transition 2015, 3, :o2, 1425801600 - tz.transition 2015, 11, :o1, 1446361200 - tz.transition 2016, 3, :o2, 1457856000 - tz.transition 2016, 11, :o1, 1478415600 - tz.transition 2017, 3, :o2, 1489305600 - tz.transition 2017, 11, :o1, 1509865200 - tz.transition 2018, 3, :o2, 1520755200 - tz.transition 2018, 11, :o1, 1541314800 - tz.transition 2019, 3, :o2, 1552204800 - tz.transition 2019, 11, :o1, 1572764400 - tz.transition 2020, 3, :o2, 1583654400 - tz.transition 2020, 11, :o1, 1604214000 - tz.transition 2021, 3, :o2, 1615708800 - tz.transition 2021, 11, :o1, 1636268400 - tz.transition 2022, 3, :o2, 1647158400 - tz.transition 2022, 11, :o1, 1667718000 - tz.transition 2023, 3, :o2, 1678608000 - tz.transition 2023, 11, :o1, 1699167600 - tz.transition 2024, 3, :o2, 1710057600 - tz.transition 2024, 11, :o1, 1730617200 - tz.transition 2025, 3, :o2, 1741507200 - tz.transition 2025, 11, :o1, 1762066800 - tz.transition 2026, 3, :o2, 1772956800 - tz.transition 2026, 11, :o1, 1793516400 - tz.transition 2027, 3, :o2, 1805011200 - tz.transition 2027, 11, :o1, 1825570800 - tz.transition 2028, 3, :o2, 1836460800 - tz.transition 2028, 11, :o1, 1857020400 - tz.transition 2029, 3, :o2, 1867910400 - tz.transition 2029, 11, :o1, 1888470000 - tz.transition 2030, 3, :o2, 1899360000 - tz.transition 2030, 11, :o1, 1919919600 - tz.transition 2031, 3, :o2, 1930809600 - tz.transition 2031, 11, :o1, 1951369200 - tz.transition 2032, 3, :o2, 1962864000 - tz.transition 2032, 11, :o1, 1983423600 - tz.transition 2033, 3, :o2, 1994313600 - tz.transition 2033, 11, :o1, 2014873200 - tz.transition 2034, 3, :o2, 2025763200 - tz.transition 2034, 11, :o1, 2046322800 - tz.transition 2035, 3, :o2, 2057212800 - tz.transition 2035, 11, :o1, 2077772400 - tz.transition 2036, 3, :o2, 2088662400 - tz.transition 2036, 11, :o1, 2109222000 - tz.transition 2037, 3, :o2, 2120112000 - tz.transition 2037, 11, :o1, 2140671600 - tz.transition 2038, 3, :o2, 14792981, 6 - tz.transition 2038, 11, :o1, 59177635, 24 - tz.transition 2039, 3, :o2, 14795165, 6 - tz.transition 2039, 11, :o1, 59186371, 24 - tz.transition 2040, 3, :o2, 14797349, 6 - tz.transition 2040, 11, :o1, 59195107, 24 - tz.transition 2041, 3, :o2, 14799533, 6 - tz.transition 2041, 11, :o1, 59203843, 24 - tz.transition 2042, 3, :o2, 14801717, 6 - tz.transition 2042, 11, :o1, 59212579, 24 - tz.transition 2043, 3, :o2, 14803901, 6 - tz.transition 2043, 11, :o1, 59221315, 24 - tz.transition 2044, 3, :o2, 14806127, 6 - tz.transition 2044, 11, :o1, 59230219, 24 - tz.transition 2045, 3, :o2, 14808311, 6 - tz.transition 2045, 11, :o1, 59238955, 24 - tz.transition 2046, 3, :o2, 14810495, 6 - tz.transition 2046, 11, :o1, 59247691, 24 - tz.transition 2047, 3, :o2, 14812679, 6 - tz.transition 2047, 11, :o1, 59256427, 24 - tz.transition 2048, 3, :o2, 14814863, 6 - tz.transition 2048, 11, :o1, 59265163, 24 - tz.transition 2049, 3, :o2, 14817089, 6 - tz.transition 2049, 11, :o1, 59274067, 24 - tz.transition 2050, 3, :o2, 14819273, 6 - tz.transition 2050, 11, :o1, 59282803, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb deleted file mode 100644 index 1710b57c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +++ /dev/null @@ -1,136 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Chihuahua - include TimezoneDefinition - - timezone 'America/Chihuahua' do |tz| - tz.offset :o0, -25460, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -21600, 0, :CST - tz.offset :o3, -21600, 3600, :CDT - tz.offset :o4, -25200, 3600, :MDT - - tz.transition 1922, 1, :o1, 58153339, 24 - tz.transition 1927, 6, :o2, 9700171, 4 - tz.transition 1930, 11, :o1, 9705183, 4 - tz.transition 1931, 5, :o2, 9705855, 4 - tz.transition 1931, 10, :o1, 9706463, 4 - tz.transition 1932, 4, :o2, 58243171, 24 - tz.transition 1996, 4, :o3, 828864000 - tz.transition 1996, 10, :o2, 846399600 - tz.transition 1997, 4, :o3, 860313600 - tz.transition 1997, 10, :o2, 877849200 - tz.transition 1998, 4, :o4, 891766800 - tz.transition 1998, 10, :o1, 909302400 - tz.transition 1999, 4, :o4, 923216400 - tz.transition 1999, 10, :o1, 941356800 - tz.transition 2000, 4, :o4, 954666000 - tz.transition 2000, 10, :o1, 972806400 - tz.transition 2001, 5, :o4, 989139600 - tz.transition 2001, 9, :o1, 1001836800 - tz.transition 2002, 4, :o4, 1018170000 - tz.transition 2002, 10, :o1, 1035705600 - tz.transition 2003, 4, :o4, 1049619600 - tz.transition 2003, 10, :o1, 1067155200 - tz.transition 2004, 4, :o4, 1081069200 - tz.transition 2004, 10, :o1, 1099209600 - tz.transition 2005, 4, :o4, 1112518800 - tz.transition 2005, 10, :o1, 1130659200 - tz.transition 2006, 4, :o4, 1143968400 - tz.transition 2006, 10, :o1, 1162108800 - tz.transition 2007, 4, :o4, 1175418000 - tz.transition 2007, 10, :o1, 1193558400 - tz.transition 2008, 4, :o4, 1207472400 - tz.transition 2008, 10, :o1, 1225008000 - tz.transition 2009, 4, :o4, 1238922000 - tz.transition 2009, 10, :o1, 1256457600 - tz.transition 2010, 4, :o4, 1270371600 - tz.transition 2010, 10, :o1, 1288512000 - tz.transition 2011, 4, :o4, 1301821200 - tz.transition 2011, 10, :o1, 1319961600 - tz.transition 2012, 4, :o4, 1333270800 - tz.transition 2012, 10, :o1, 1351411200 - tz.transition 2013, 4, :o4, 1365325200 - tz.transition 2013, 10, :o1, 1382860800 - tz.transition 2014, 4, :o4, 1396774800 - tz.transition 2014, 10, :o1, 1414310400 - tz.transition 2015, 4, :o4, 1428224400 - tz.transition 2015, 10, :o1, 1445760000 - tz.transition 2016, 4, :o4, 1459674000 - tz.transition 2016, 10, :o1, 1477814400 - tz.transition 2017, 4, :o4, 1491123600 - tz.transition 2017, 10, :o1, 1509264000 - tz.transition 2018, 4, :o4, 1522573200 - tz.transition 2018, 10, :o1, 1540713600 - tz.transition 2019, 4, :o4, 1554627600 - tz.transition 2019, 10, :o1, 1572163200 - tz.transition 2020, 4, :o4, 1586077200 - tz.transition 2020, 10, :o1, 1603612800 - tz.transition 2021, 4, :o4, 1617526800 - tz.transition 2021, 10, :o1, 1635667200 - tz.transition 2022, 4, :o4, 1648976400 - tz.transition 2022, 10, :o1, 1667116800 - tz.transition 2023, 4, :o4, 1680426000 - tz.transition 2023, 10, :o1, 1698566400 - tz.transition 2024, 4, :o4, 1712480400 - tz.transition 2024, 10, :o1, 1730016000 - tz.transition 2025, 4, :o4, 1743930000 - tz.transition 2025, 10, :o1, 1761465600 - tz.transition 2026, 4, :o4, 1775379600 - tz.transition 2026, 10, :o1, 1792915200 - tz.transition 2027, 4, :o4, 1806829200 - tz.transition 2027, 10, :o1, 1824969600 - tz.transition 2028, 4, :o4, 1838278800 - tz.transition 2028, 10, :o1, 1856419200 - tz.transition 2029, 4, :o4, 1869728400 - tz.transition 2029, 10, :o1, 1887868800 - tz.transition 2030, 4, :o4, 1901782800 - tz.transition 2030, 10, :o1, 1919318400 - tz.transition 2031, 4, :o4, 1933232400 - tz.transition 2031, 10, :o1, 1950768000 - tz.transition 2032, 4, :o4, 1964682000 - tz.transition 2032, 10, :o1, 1982822400 - tz.transition 2033, 4, :o4, 1996131600 - tz.transition 2033, 10, :o1, 2014272000 - tz.transition 2034, 4, :o4, 2027581200 - tz.transition 2034, 10, :o1, 2045721600 - tz.transition 2035, 4, :o4, 2059030800 - tz.transition 2035, 10, :o1, 2077171200 - tz.transition 2036, 4, :o4, 2091085200 - tz.transition 2036, 10, :o1, 2108620800 - tz.transition 2037, 4, :o4, 2122534800 - tz.transition 2037, 10, :o1, 2140070400 - tz.transition 2038, 4, :o4, 19724143, 8 - tz.transition 2038, 10, :o1, 14794367, 6 - tz.transition 2039, 4, :o4, 19727055, 8 - tz.transition 2039, 10, :o1, 14796551, 6 - tz.transition 2040, 4, :o4, 19729967, 8 - tz.transition 2040, 10, :o1, 14798735, 6 - tz.transition 2041, 4, :o4, 19732935, 8 - tz.transition 2041, 10, :o1, 14800919, 6 - tz.transition 2042, 4, :o4, 19735847, 8 - tz.transition 2042, 10, :o1, 14803103, 6 - tz.transition 2043, 4, :o4, 19738759, 8 - tz.transition 2043, 10, :o1, 14805287, 6 - tz.transition 2044, 4, :o4, 19741671, 8 - tz.transition 2044, 10, :o1, 14807513, 6 - tz.transition 2045, 4, :o4, 19744583, 8 - tz.transition 2045, 10, :o1, 14809697, 6 - tz.transition 2046, 4, :o4, 19747495, 8 - tz.transition 2046, 10, :o1, 14811881, 6 - tz.transition 2047, 4, :o4, 19750463, 8 - tz.transition 2047, 10, :o1, 14814065, 6 - tz.transition 2048, 4, :o4, 19753375, 8 - tz.transition 2048, 10, :o1, 14816249, 6 - tz.transition 2049, 4, :o4, 19756287, 8 - tz.transition 2049, 10, :o1, 14818475, 6 - tz.transition 2050, 4, :o4, 19759199, 8 - tz.transition 2050, 10, :o1, 14820659, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb deleted file mode 100644 index 1c1efb5f..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +++ /dev/null @@ -1,204 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Denver - include TimezoneDefinition - - timezone 'America/Denver' do |tz| - tz.offset :o0, -25196, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -25200, 3600, :MDT - tz.offset :o3, -25200, 3600, :MWT - tz.offset :o4, -25200, 3600, :MPT - - tz.transition 1883, 11, :o1, 57819199, 24 - tz.transition 1918, 3, :o2, 19373471, 8 - tz.transition 1918, 10, :o1, 14531363, 6 - tz.transition 1919, 3, :o2, 19376383, 8 - tz.transition 1919, 10, :o1, 14533547, 6 - tz.transition 1920, 3, :o2, 19379295, 8 - tz.transition 1920, 10, :o1, 14535773, 6 - tz.transition 1921, 3, :o2, 19382207, 8 - tz.transition 1921, 5, :o1, 14536991, 6 - tz.transition 1942, 2, :o3, 19443199, 8 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 14590373, 6 - tz.transition 1965, 4, :o2, 19511007, 8 - tz.transition 1965, 10, :o1, 14634389, 6 - tz.transition 1966, 4, :o2, 19513919, 8 - tz.transition 1966, 10, :o1, 14636573, 6 - tz.transition 1967, 4, :o2, 19516887, 8 - tz.transition 1967, 10, :o1, 14638757, 6 - tz.transition 1968, 4, :o2, 19519799, 8 - tz.transition 1968, 10, :o1, 14640941, 6 - tz.transition 1969, 4, :o2, 19522711, 8 - tz.transition 1969, 10, :o1, 14643125, 6 - tz.transition 1970, 4, :o2, 9968400 - tz.transition 1970, 10, :o1, 25689600 - tz.transition 1971, 4, :o2, 41418000 - tz.transition 1971, 10, :o1, 57744000 - tz.transition 1972, 4, :o2, 73472400 - tz.transition 1972, 10, :o1, 89193600 - tz.transition 1973, 4, :o2, 104922000 - tz.transition 1973, 10, :o1, 120643200 - tz.transition 1974, 1, :o2, 126694800 - tz.transition 1974, 10, :o1, 152092800 - tz.transition 1975, 2, :o2, 162378000 - tz.transition 1975, 10, :o1, 183542400 - tz.transition 1976, 4, :o2, 199270800 - tz.transition 1976, 10, :o1, 215596800 - tz.transition 1977, 4, :o2, 230720400 - tz.transition 1977, 10, :o1, 247046400 - tz.transition 1978, 4, :o2, 262774800 - tz.transition 1978, 10, :o1, 278496000 - tz.transition 1979, 4, :o2, 294224400 - tz.transition 1979, 10, :o1, 309945600 - tz.transition 1980, 4, :o2, 325674000 - tz.transition 1980, 10, :o1, 341395200 - tz.transition 1981, 4, :o2, 357123600 - tz.transition 1981, 10, :o1, 372844800 - tz.transition 1982, 4, :o2, 388573200 - tz.transition 1982, 10, :o1, 404899200 - tz.transition 1983, 4, :o2, 420022800 - tz.transition 1983, 10, :o1, 436348800 - tz.transition 1984, 4, :o2, 452077200 - tz.transition 1984, 10, :o1, 467798400 - tz.transition 1985, 4, :o2, 483526800 - tz.transition 1985, 10, :o1, 499248000 - tz.transition 1986, 4, :o2, 514976400 - tz.transition 1986, 10, :o1, 530697600 - tz.transition 1987, 4, :o2, 544611600 - tz.transition 1987, 10, :o1, 562147200 - tz.transition 1988, 4, :o2, 576061200 - tz.transition 1988, 10, :o1, 594201600 - tz.transition 1989, 4, :o2, 607510800 - tz.transition 1989, 10, :o1, 625651200 - tz.transition 1990, 4, :o2, 638960400 - tz.transition 1990, 10, :o1, 657100800 - tz.transition 1991, 4, :o2, 671014800 - tz.transition 1991, 10, :o1, 688550400 - tz.transition 1992, 4, :o2, 702464400 - tz.transition 1992, 10, :o1, 720000000 - tz.transition 1993, 4, :o2, 733914000 - tz.transition 1993, 10, :o1, 752054400 - tz.transition 1994, 4, :o2, 765363600 - tz.transition 1994, 10, :o1, 783504000 - tz.transition 1995, 4, :o2, 796813200 - tz.transition 1995, 10, :o1, 814953600 - tz.transition 1996, 4, :o2, 828867600 - tz.transition 1996, 10, :o1, 846403200 - tz.transition 1997, 4, :o2, 860317200 - tz.transition 1997, 10, :o1, 877852800 - tz.transition 1998, 4, :o2, 891766800 - tz.transition 1998, 10, :o1, 909302400 - tz.transition 1999, 4, :o2, 923216400 - tz.transition 1999, 10, :o1, 941356800 - tz.transition 2000, 4, :o2, 954666000 - tz.transition 2000, 10, :o1, 972806400 - tz.transition 2001, 4, :o2, 986115600 - tz.transition 2001, 10, :o1, 1004256000 - tz.transition 2002, 4, :o2, 1018170000 - tz.transition 2002, 10, :o1, 1035705600 - tz.transition 2003, 4, :o2, 1049619600 - tz.transition 2003, 10, :o1, 1067155200 - tz.transition 2004, 4, :o2, 1081069200 - tz.transition 2004, 10, :o1, 1099209600 - tz.transition 2005, 4, :o2, 1112518800 - tz.transition 2005, 10, :o1, 1130659200 - tz.transition 2006, 4, :o2, 1143968400 - tz.transition 2006, 10, :o1, 1162108800 - tz.transition 2007, 3, :o2, 1173603600 - tz.transition 2007, 11, :o1, 1194163200 - tz.transition 2008, 3, :o2, 1205053200 - tz.transition 2008, 11, :o1, 1225612800 - tz.transition 2009, 3, :o2, 1236502800 - tz.transition 2009, 11, :o1, 1257062400 - tz.transition 2010, 3, :o2, 1268557200 - tz.transition 2010, 11, :o1, 1289116800 - tz.transition 2011, 3, :o2, 1300006800 - tz.transition 2011, 11, :o1, 1320566400 - tz.transition 2012, 3, :o2, 1331456400 - tz.transition 2012, 11, :o1, 1352016000 - tz.transition 2013, 3, :o2, 1362906000 - tz.transition 2013, 11, :o1, 1383465600 - tz.transition 2014, 3, :o2, 1394355600 - tz.transition 2014, 11, :o1, 1414915200 - tz.transition 2015, 3, :o2, 1425805200 - tz.transition 2015, 11, :o1, 1446364800 - tz.transition 2016, 3, :o2, 1457859600 - tz.transition 2016, 11, :o1, 1478419200 - tz.transition 2017, 3, :o2, 1489309200 - tz.transition 2017, 11, :o1, 1509868800 - tz.transition 2018, 3, :o2, 1520758800 - tz.transition 2018, 11, :o1, 1541318400 - tz.transition 2019, 3, :o2, 1552208400 - tz.transition 2019, 11, :o1, 1572768000 - tz.transition 2020, 3, :o2, 1583658000 - tz.transition 2020, 11, :o1, 1604217600 - tz.transition 2021, 3, :o2, 1615712400 - tz.transition 2021, 11, :o1, 1636272000 - tz.transition 2022, 3, :o2, 1647162000 - tz.transition 2022, 11, :o1, 1667721600 - tz.transition 2023, 3, :o2, 1678611600 - tz.transition 2023, 11, :o1, 1699171200 - tz.transition 2024, 3, :o2, 1710061200 - tz.transition 2024, 11, :o1, 1730620800 - tz.transition 2025, 3, :o2, 1741510800 - tz.transition 2025, 11, :o1, 1762070400 - tz.transition 2026, 3, :o2, 1772960400 - tz.transition 2026, 11, :o1, 1793520000 - tz.transition 2027, 3, :o2, 1805014800 - tz.transition 2027, 11, :o1, 1825574400 - tz.transition 2028, 3, :o2, 1836464400 - tz.transition 2028, 11, :o1, 1857024000 - tz.transition 2029, 3, :o2, 1867914000 - tz.transition 2029, 11, :o1, 1888473600 - tz.transition 2030, 3, :o2, 1899363600 - tz.transition 2030, 11, :o1, 1919923200 - tz.transition 2031, 3, :o2, 1930813200 - tz.transition 2031, 11, :o1, 1951372800 - tz.transition 2032, 3, :o2, 1962867600 - tz.transition 2032, 11, :o1, 1983427200 - tz.transition 2033, 3, :o2, 1994317200 - tz.transition 2033, 11, :o1, 2014876800 - tz.transition 2034, 3, :o2, 2025766800 - tz.transition 2034, 11, :o1, 2046326400 - tz.transition 2035, 3, :o2, 2057216400 - tz.transition 2035, 11, :o1, 2077776000 - tz.transition 2036, 3, :o2, 2088666000 - tz.transition 2036, 11, :o1, 2109225600 - tz.transition 2037, 3, :o2, 2120115600 - tz.transition 2037, 11, :o1, 2140675200 - tz.transition 2038, 3, :o2, 19723975, 8 - tz.transition 2038, 11, :o1, 14794409, 6 - tz.transition 2039, 3, :o2, 19726887, 8 - tz.transition 2039, 11, :o1, 14796593, 6 - tz.transition 2040, 3, :o2, 19729799, 8 - tz.transition 2040, 11, :o1, 14798777, 6 - tz.transition 2041, 3, :o2, 19732711, 8 - tz.transition 2041, 11, :o1, 14800961, 6 - tz.transition 2042, 3, :o2, 19735623, 8 - tz.transition 2042, 11, :o1, 14803145, 6 - tz.transition 2043, 3, :o2, 19738535, 8 - tz.transition 2043, 11, :o1, 14805329, 6 - tz.transition 2044, 3, :o2, 19741503, 8 - tz.transition 2044, 11, :o1, 14807555, 6 - tz.transition 2045, 3, :o2, 19744415, 8 - tz.transition 2045, 11, :o1, 14809739, 6 - tz.transition 2046, 3, :o2, 19747327, 8 - tz.transition 2046, 11, :o1, 14811923, 6 - tz.transition 2047, 3, :o2, 19750239, 8 - tz.transition 2047, 11, :o1, 14814107, 6 - tz.transition 2048, 3, :o2, 19753151, 8 - tz.transition 2048, 11, :o1, 14816291, 6 - tz.transition 2049, 3, :o2, 19756119, 8 - tz.transition 2049, 11, :o1, 14818517, 6 - tz.transition 2050, 3, :o2, 19759031, 8 - tz.transition 2050, 11, :o1, 14820701, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb deleted file mode 100644 index 1e05518b..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +++ /dev/null @@ -1,161 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Godthab - include TimezoneDefinition - - timezone 'America/Godthab' do |tz| - tz.offset :o0, -12416, 0, :LMT - tz.offset :o1, -10800, 0, :WGT - tz.offset :o2, -10800, 3600, :WGST - - tz.transition 1916, 7, :o1, 3268448069, 1350 - tz.transition 1980, 4, :o2, 323845200 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb deleted file mode 100644 index a2bf7340..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Guatemala - include TimezoneDefinition - - timezone 'America/Guatemala' do |tz| - tz.offset :o0, -21724, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - - tz.transition 1918, 10, :o1, 52312429831, 21600 - tz.transition 1973, 11, :o2, 123055200 - tz.transition 1974, 2, :o1, 130914000 - tz.transition 1983, 5, :o2, 422344800 - tz.transition 1983, 9, :o1, 433054800 - tz.transition 1991, 3, :o2, 669708000 - tz.transition 1991, 9, :o1, 684219600 - tz.transition 2006, 4, :o2, 1146376800 - tz.transition 2006, 10, :o1, 1159678800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb deleted file mode 100644 index d25ae775..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +++ /dev/null @@ -1,274 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Halifax - include TimezoneDefinition - - timezone 'America/Halifax' do |tz| - tz.offset :o0, -15264, 0, :LMT - tz.offset :o1, -14400, 0, :AST - tz.offset :o2, -14400, 3600, :ADT - tz.offset :o3, -14400, 3600, :AWT - tz.offset :o4, -14400, 3600, :APT - - tz.transition 1902, 6, :o1, 724774703, 300 - tz.transition 1916, 4, :o2, 7262864, 3 - tz.transition 1916, 10, :o1, 19369101, 8 - tz.transition 1918, 4, :o2, 9686791, 4 - tz.transition 1918, 10, :o1, 58125545, 24 - tz.transition 1920, 5, :o2, 7267361, 3 - tz.transition 1920, 8, :o1, 19380525, 8 - tz.transition 1921, 5, :o2, 7268447, 3 - tz.transition 1921, 9, :o1, 19383501, 8 - tz.transition 1922, 4, :o2, 7269524, 3 - tz.transition 1922, 9, :o1, 19386421, 8 - tz.transition 1923, 5, :o2, 7270637, 3 - tz.transition 1923, 9, :o1, 19389333, 8 - tz.transition 1924, 5, :o2, 7271729, 3 - tz.transition 1924, 9, :o1, 19392349, 8 - tz.transition 1925, 5, :o2, 7272821, 3 - tz.transition 1925, 9, :o1, 19395373, 8 - tz.transition 1926, 5, :o2, 7273955, 3 - tz.transition 1926, 9, :o1, 19398173, 8 - tz.transition 1927, 5, :o2, 7275005, 3 - tz.transition 1927, 9, :o1, 19401197, 8 - tz.transition 1928, 5, :o2, 7276139, 3 - tz.transition 1928, 9, :o1, 19403989, 8 - tz.transition 1929, 5, :o2, 7277231, 3 - tz.transition 1929, 9, :o1, 19406861, 8 - tz.transition 1930, 5, :o2, 7278323, 3 - tz.transition 1930, 9, :o1, 19409877, 8 - tz.transition 1931, 5, :o2, 7279415, 3 - tz.transition 1931, 9, :o1, 19412901, 8 - tz.transition 1932, 5, :o2, 7280486, 3 - tz.transition 1932, 9, :o1, 19415813, 8 - tz.transition 1933, 4, :o2, 7281578, 3 - tz.transition 1933, 10, :o1, 19418781, 8 - tz.transition 1934, 5, :o2, 7282733, 3 - tz.transition 1934, 9, :o1, 19421573, 8 - tz.transition 1935, 6, :o2, 7283867, 3 - tz.transition 1935, 9, :o1, 19424605, 8 - tz.transition 1936, 6, :o2, 7284962, 3 - tz.transition 1936, 9, :o1, 19427405, 8 - tz.transition 1937, 5, :o2, 7285967, 3 - tz.transition 1937, 9, :o1, 19430429, 8 - tz.transition 1938, 5, :o2, 7287059, 3 - tz.transition 1938, 9, :o1, 19433341, 8 - tz.transition 1939, 5, :o2, 7288235, 3 - tz.transition 1939, 9, :o1, 19436253, 8 - tz.transition 1940, 5, :o2, 7289264, 3 - tz.transition 1940, 9, :o1, 19439221, 8 - tz.transition 1941, 5, :o2, 7290356, 3 - tz.transition 1941, 9, :o1, 19442133, 8 - tz.transition 1942, 2, :o3, 9721599, 4 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 58361489, 24 - tz.transition 1946, 4, :o2, 9727755, 4 - tz.transition 1946, 9, :o1, 58370225, 24 - tz.transition 1947, 4, :o2, 9729211, 4 - tz.transition 1947, 9, :o1, 58378961, 24 - tz.transition 1948, 4, :o2, 9730667, 4 - tz.transition 1948, 9, :o1, 58387697, 24 - tz.transition 1949, 4, :o2, 9732123, 4 - tz.transition 1949, 9, :o1, 58396433, 24 - tz.transition 1951, 4, :o2, 9735063, 4 - tz.transition 1951, 9, :o1, 58414073, 24 - tz.transition 1952, 4, :o2, 9736519, 4 - tz.transition 1952, 9, :o1, 58422809, 24 - tz.transition 1953, 4, :o2, 9737975, 4 - tz.transition 1953, 9, :o1, 58431545, 24 - tz.transition 1954, 4, :o2, 9739431, 4 - tz.transition 1954, 9, :o1, 58440281, 24 - tz.transition 1956, 4, :o2, 9742371, 4 - tz.transition 1956, 9, :o1, 58457921, 24 - tz.transition 1957, 4, :o2, 9743827, 4 - tz.transition 1957, 9, :o1, 58466657, 24 - tz.transition 1958, 4, :o2, 9745283, 4 - tz.transition 1958, 9, :o1, 58475393, 24 - tz.transition 1959, 4, :o2, 9746739, 4 - tz.transition 1959, 9, :o1, 58484129, 24 - tz.transition 1962, 4, :o2, 9751135, 4 - tz.transition 1962, 10, :o1, 58511177, 24 - tz.transition 1963, 4, :o2, 9752591, 4 - tz.transition 1963, 10, :o1, 58519913, 24 - tz.transition 1964, 4, :o2, 9754047, 4 - tz.transition 1964, 10, :o1, 58528649, 24 - tz.transition 1965, 4, :o2, 9755503, 4 - tz.transition 1965, 10, :o1, 58537553, 24 - tz.transition 1966, 4, :o2, 9756959, 4 - tz.transition 1966, 10, :o1, 58546289, 24 - tz.transition 1967, 4, :o2, 9758443, 4 - tz.transition 1967, 10, :o1, 58555025, 24 - tz.transition 1968, 4, :o2, 9759899, 4 - tz.transition 1968, 10, :o1, 58563761, 24 - tz.transition 1969, 4, :o2, 9761355, 4 - tz.transition 1969, 10, :o1, 58572497, 24 - tz.transition 1970, 4, :o2, 9957600 - tz.transition 1970, 10, :o1, 25678800 - tz.transition 1971, 4, :o2, 41407200 - tz.transition 1971, 10, :o1, 57733200 - tz.transition 1972, 4, :o2, 73461600 - tz.transition 1972, 10, :o1, 89182800 - tz.transition 1973, 4, :o2, 104911200 - tz.transition 1973, 10, :o1, 120632400 - tz.transition 1974, 4, :o2, 136360800 - tz.transition 1974, 10, :o1, 152082000 - tz.transition 1975, 4, :o2, 167810400 - tz.transition 1975, 10, :o1, 183531600 - tz.transition 1976, 4, :o2, 199260000 - tz.transition 1976, 10, :o1, 215586000 - tz.transition 1977, 4, :o2, 230709600 - tz.transition 1977, 10, :o1, 247035600 - tz.transition 1978, 4, :o2, 262764000 - tz.transition 1978, 10, :o1, 278485200 - tz.transition 1979, 4, :o2, 294213600 - tz.transition 1979, 10, :o1, 309934800 - tz.transition 1980, 4, :o2, 325663200 - tz.transition 1980, 10, :o1, 341384400 - tz.transition 1981, 4, :o2, 357112800 - tz.transition 1981, 10, :o1, 372834000 - tz.transition 1982, 4, :o2, 388562400 - tz.transition 1982, 10, :o1, 404888400 - tz.transition 1983, 4, :o2, 420012000 - tz.transition 1983, 10, :o1, 436338000 - tz.transition 1984, 4, :o2, 452066400 - tz.transition 1984, 10, :o1, 467787600 - tz.transition 1985, 4, :o2, 483516000 - tz.transition 1985, 10, :o1, 499237200 - tz.transition 1986, 4, :o2, 514965600 - tz.transition 1986, 10, :o1, 530686800 - tz.transition 1987, 4, :o2, 544600800 - tz.transition 1987, 10, :o1, 562136400 - tz.transition 1988, 4, :o2, 576050400 - tz.transition 1988, 10, :o1, 594190800 - tz.transition 1989, 4, :o2, 607500000 - tz.transition 1989, 10, :o1, 625640400 - tz.transition 1990, 4, :o2, 638949600 - tz.transition 1990, 10, :o1, 657090000 - tz.transition 1991, 4, :o2, 671004000 - tz.transition 1991, 10, :o1, 688539600 - tz.transition 1992, 4, :o2, 702453600 - tz.transition 1992, 10, :o1, 719989200 - tz.transition 1993, 4, :o2, 733903200 - tz.transition 1993, 10, :o1, 752043600 - tz.transition 1994, 4, :o2, 765352800 - tz.transition 1994, 10, :o1, 783493200 - tz.transition 1995, 4, :o2, 796802400 - tz.transition 1995, 10, :o1, 814942800 - tz.transition 1996, 4, :o2, 828856800 - tz.transition 1996, 10, :o1, 846392400 - tz.transition 1997, 4, :o2, 860306400 - tz.transition 1997, 10, :o1, 877842000 - tz.transition 1998, 4, :o2, 891756000 - tz.transition 1998, 10, :o1, 909291600 - tz.transition 1999, 4, :o2, 923205600 - tz.transition 1999, 10, :o1, 941346000 - tz.transition 2000, 4, :o2, 954655200 - tz.transition 2000, 10, :o1, 972795600 - tz.transition 2001, 4, :o2, 986104800 - tz.transition 2001, 10, :o1, 1004245200 - tz.transition 2002, 4, :o2, 1018159200 - tz.transition 2002, 10, :o1, 1035694800 - tz.transition 2003, 4, :o2, 1049608800 - tz.transition 2003, 10, :o1, 1067144400 - tz.transition 2004, 4, :o2, 1081058400 - tz.transition 2004, 10, :o1, 1099198800 - tz.transition 2005, 4, :o2, 1112508000 - tz.transition 2005, 10, :o1, 1130648400 - tz.transition 2006, 4, :o2, 1143957600 - tz.transition 2006, 10, :o1, 1162098000 - tz.transition 2007, 3, :o2, 1173592800 - tz.transition 2007, 11, :o1, 1194152400 - tz.transition 2008, 3, :o2, 1205042400 - tz.transition 2008, 11, :o1, 1225602000 - tz.transition 2009, 3, :o2, 1236492000 - tz.transition 2009, 11, :o1, 1257051600 - tz.transition 2010, 3, :o2, 1268546400 - tz.transition 2010, 11, :o1, 1289106000 - tz.transition 2011, 3, :o2, 1299996000 - tz.transition 2011, 11, :o1, 1320555600 - tz.transition 2012, 3, :o2, 1331445600 - tz.transition 2012, 11, :o1, 1352005200 - tz.transition 2013, 3, :o2, 1362895200 - tz.transition 2013, 11, :o1, 1383454800 - tz.transition 2014, 3, :o2, 1394344800 - tz.transition 2014, 11, :o1, 1414904400 - tz.transition 2015, 3, :o2, 1425794400 - tz.transition 2015, 11, :o1, 1446354000 - tz.transition 2016, 3, :o2, 1457848800 - tz.transition 2016, 11, :o1, 1478408400 - tz.transition 2017, 3, :o2, 1489298400 - tz.transition 2017, 11, :o1, 1509858000 - tz.transition 2018, 3, :o2, 1520748000 - tz.transition 2018, 11, :o1, 1541307600 - tz.transition 2019, 3, :o2, 1552197600 - tz.transition 2019, 11, :o1, 1572757200 - tz.transition 2020, 3, :o2, 1583647200 - tz.transition 2020, 11, :o1, 1604206800 - tz.transition 2021, 3, :o2, 1615701600 - tz.transition 2021, 11, :o1, 1636261200 - tz.transition 2022, 3, :o2, 1647151200 - tz.transition 2022, 11, :o1, 1667710800 - tz.transition 2023, 3, :o2, 1678600800 - tz.transition 2023, 11, :o1, 1699160400 - tz.transition 2024, 3, :o2, 1710050400 - tz.transition 2024, 11, :o1, 1730610000 - tz.transition 2025, 3, :o2, 1741500000 - tz.transition 2025, 11, :o1, 1762059600 - tz.transition 2026, 3, :o2, 1772949600 - tz.transition 2026, 11, :o1, 1793509200 - tz.transition 2027, 3, :o2, 1805004000 - tz.transition 2027, 11, :o1, 1825563600 - tz.transition 2028, 3, :o2, 1836453600 - tz.transition 2028, 11, :o1, 1857013200 - tz.transition 2029, 3, :o2, 1867903200 - tz.transition 2029, 11, :o1, 1888462800 - tz.transition 2030, 3, :o2, 1899352800 - tz.transition 2030, 11, :o1, 1919912400 - tz.transition 2031, 3, :o2, 1930802400 - tz.transition 2031, 11, :o1, 1951362000 - tz.transition 2032, 3, :o2, 1962856800 - tz.transition 2032, 11, :o1, 1983416400 - tz.transition 2033, 3, :o2, 1994306400 - tz.transition 2033, 11, :o1, 2014866000 - tz.transition 2034, 3, :o2, 2025756000 - tz.transition 2034, 11, :o1, 2046315600 - tz.transition 2035, 3, :o2, 2057205600 - tz.transition 2035, 11, :o1, 2077765200 - tz.transition 2036, 3, :o2, 2088655200 - tz.transition 2036, 11, :o1, 2109214800 - tz.transition 2037, 3, :o2, 2120104800 - tz.transition 2037, 11, :o1, 2140664400 - tz.transition 2038, 3, :o2, 9861987, 4 - tz.transition 2038, 11, :o1, 59177633, 24 - tz.transition 2039, 3, :o2, 9863443, 4 - tz.transition 2039, 11, :o1, 59186369, 24 - tz.transition 2040, 3, :o2, 9864899, 4 - tz.transition 2040, 11, :o1, 59195105, 24 - tz.transition 2041, 3, :o2, 9866355, 4 - tz.transition 2041, 11, :o1, 59203841, 24 - tz.transition 2042, 3, :o2, 9867811, 4 - tz.transition 2042, 11, :o1, 59212577, 24 - tz.transition 2043, 3, :o2, 9869267, 4 - tz.transition 2043, 11, :o1, 59221313, 24 - tz.transition 2044, 3, :o2, 9870751, 4 - tz.transition 2044, 11, :o1, 59230217, 24 - tz.transition 2045, 3, :o2, 9872207, 4 - tz.transition 2045, 11, :o1, 59238953, 24 - tz.transition 2046, 3, :o2, 9873663, 4 - tz.transition 2046, 11, :o1, 59247689, 24 - tz.transition 2047, 3, :o2, 9875119, 4 - tz.transition 2047, 11, :o1, 59256425, 24 - tz.transition 2048, 3, :o2, 9876575, 4 - tz.transition 2048, 11, :o1, 59265161, 24 - tz.transition 2049, 3, :o2, 9878059, 4 - tz.transition 2049, 11, :o1, 59274065, 24 - tz.transition 2050, 3, :o2, 9879515, 4 - tz.transition 2050, 11, :o1, 59282801, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb deleted file mode 100644 index f1430f6c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +++ /dev/null @@ -1,149 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Indiana - module Indianapolis - include TimezoneDefinition - - timezone 'America/Indiana/Indianapolis' do |tz| - tz.offset :o0, -20678, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - tz.offset :o3, -21600, 3600, :CWT - tz.offset :o4, -21600, 3600, :CPT - tz.offset :o5, -18000, 0, :EST - tz.offset :o6, -18000, 3600, :EDT - - tz.transition 1883, 11, :o1, 9636533, 4 - tz.transition 1918, 3, :o2, 14530103, 6 - tz.transition 1918, 10, :o1, 58125451, 24 - tz.transition 1919, 3, :o2, 14532287, 6 - tz.transition 1919, 10, :o1, 58134187, 24 - tz.transition 1941, 6, :o2, 14581007, 6 - tz.transition 1941, 9, :o1, 58326379, 24 - tz.transition 1942, 2, :o3, 14582399, 6 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 58361491, 24 - tz.transition 1946, 4, :o2, 14591633, 6 - tz.transition 1946, 9, :o1, 58370227, 24 - tz.transition 1947, 4, :o2, 14593817, 6 - tz.transition 1947, 9, :o1, 58378963, 24 - tz.transition 1948, 4, :o2, 14596001, 6 - tz.transition 1948, 9, :o1, 58387699, 24 - tz.transition 1949, 4, :o2, 14598185, 6 - tz.transition 1949, 9, :o1, 58396435, 24 - tz.transition 1950, 4, :o2, 14600411, 6 - tz.transition 1950, 9, :o1, 58405171, 24 - tz.transition 1951, 4, :o2, 14602595, 6 - tz.transition 1951, 9, :o1, 58414075, 24 - tz.transition 1952, 4, :o2, 14604779, 6 - tz.transition 1952, 9, :o1, 58422811, 24 - tz.transition 1953, 4, :o2, 14606963, 6 - tz.transition 1953, 9, :o1, 58431547, 24 - tz.transition 1954, 4, :o2, 14609147, 6 - tz.transition 1954, 9, :o1, 58440283, 24 - tz.transition 1955, 4, :o5, 14611331, 6 - tz.transition 1957, 9, :o1, 58466659, 24 - tz.transition 1958, 4, :o5, 14617925, 6 - tz.transition 1969, 4, :o6, 58568131, 24 - tz.transition 1969, 10, :o5, 9762083, 4 - tz.transition 1970, 4, :o6, 9961200 - tz.transition 1970, 10, :o5, 25682400 - tz.transition 2006, 4, :o6, 1143961200 - tz.transition 2006, 10, :o5, 1162101600 - tz.transition 2007, 3, :o6, 1173596400 - tz.transition 2007, 11, :o5, 1194156000 - tz.transition 2008, 3, :o6, 1205046000 - tz.transition 2008, 11, :o5, 1225605600 - tz.transition 2009, 3, :o6, 1236495600 - tz.transition 2009, 11, :o5, 1257055200 - tz.transition 2010, 3, :o6, 1268550000 - tz.transition 2010, 11, :o5, 1289109600 - tz.transition 2011, 3, :o6, 1299999600 - tz.transition 2011, 11, :o5, 1320559200 - tz.transition 2012, 3, :o6, 1331449200 - tz.transition 2012, 11, :o5, 1352008800 - tz.transition 2013, 3, :o6, 1362898800 - tz.transition 2013, 11, :o5, 1383458400 - tz.transition 2014, 3, :o6, 1394348400 - tz.transition 2014, 11, :o5, 1414908000 - tz.transition 2015, 3, :o6, 1425798000 - tz.transition 2015, 11, :o5, 1446357600 - tz.transition 2016, 3, :o6, 1457852400 - tz.transition 2016, 11, :o5, 1478412000 - tz.transition 2017, 3, :o6, 1489302000 - tz.transition 2017, 11, :o5, 1509861600 - tz.transition 2018, 3, :o6, 1520751600 - tz.transition 2018, 11, :o5, 1541311200 - tz.transition 2019, 3, :o6, 1552201200 - tz.transition 2019, 11, :o5, 1572760800 - tz.transition 2020, 3, :o6, 1583650800 - tz.transition 2020, 11, :o5, 1604210400 - tz.transition 2021, 3, :o6, 1615705200 - tz.transition 2021, 11, :o5, 1636264800 - tz.transition 2022, 3, :o6, 1647154800 - tz.transition 2022, 11, :o5, 1667714400 - tz.transition 2023, 3, :o6, 1678604400 - tz.transition 2023, 11, :o5, 1699164000 - tz.transition 2024, 3, :o6, 1710054000 - tz.transition 2024, 11, :o5, 1730613600 - tz.transition 2025, 3, :o6, 1741503600 - tz.transition 2025, 11, :o5, 1762063200 - tz.transition 2026, 3, :o6, 1772953200 - tz.transition 2026, 11, :o5, 1793512800 - tz.transition 2027, 3, :o6, 1805007600 - tz.transition 2027, 11, :o5, 1825567200 - tz.transition 2028, 3, :o6, 1836457200 - tz.transition 2028, 11, :o5, 1857016800 - tz.transition 2029, 3, :o6, 1867906800 - tz.transition 2029, 11, :o5, 1888466400 - tz.transition 2030, 3, :o6, 1899356400 - tz.transition 2030, 11, :o5, 1919916000 - tz.transition 2031, 3, :o6, 1930806000 - tz.transition 2031, 11, :o5, 1951365600 - tz.transition 2032, 3, :o6, 1962860400 - tz.transition 2032, 11, :o5, 1983420000 - tz.transition 2033, 3, :o6, 1994310000 - tz.transition 2033, 11, :o5, 2014869600 - tz.transition 2034, 3, :o6, 2025759600 - tz.transition 2034, 11, :o5, 2046319200 - tz.transition 2035, 3, :o6, 2057209200 - tz.transition 2035, 11, :o5, 2077768800 - tz.transition 2036, 3, :o6, 2088658800 - tz.transition 2036, 11, :o5, 2109218400 - tz.transition 2037, 3, :o6, 2120108400 - tz.transition 2037, 11, :o5, 2140668000 - tz.transition 2038, 3, :o6, 59171923, 24 - tz.transition 2038, 11, :o5, 9862939, 4 - tz.transition 2039, 3, :o6, 59180659, 24 - tz.transition 2039, 11, :o5, 9864395, 4 - tz.transition 2040, 3, :o6, 59189395, 24 - tz.transition 2040, 11, :o5, 9865851, 4 - tz.transition 2041, 3, :o6, 59198131, 24 - tz.transition 2041, 11, :o5, 9867307, 4 - tz.transition 2042, 3, :o6, 59206867, 24 - tz.transition 2042, 11, :o5, 9868763, 4 - tz.transition 2043, 3, :o6, 59215603, 24 - tz.transition 2043, 11, :o5, 9870219, 4 - tz.transition 2044, 3, :o6, 59224507, 24 - tz.transition 2044, 11, :o5, 9871703, 4 - tz.transition 2045, 3, :o6, 59233243, 24 - tz.transition 2045, 11, :o5, 9873159, 4 - tz.transition 2046, 3, :o6, 59241979, 24 - tz.transition 2046, 11, :o5, 9874615, 4 - tz.transition 2047, 3, :o6, 59250715, 24 - tz.transition 2047, 11, :o5, 9876071, 4 - tz.transition 2048, 3, :o6, 59259451, 24 - tz.transition 2048, 11, :o5, 9877527, 4 - tz.transition 2049, 3, :o6, 59268355, 24 - tz.transition 2049, 11, :o5, 9879011, 4 - tz.transition 2050, 3, :o6, 59277091, 24 - tz.transition 2050, 11, :o5, 9880467, 4 - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb deleted file mode 100644 index f646f3f5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +++ /dev/null @@ -1,194 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Juneau - include TimezoneDefinition - - timezone 'America/Juneau' do |tz| - tz.offset :o0, 54139, 0, :LMT - tz.offset :o1, -32261, 0, :LMT - tz.offset :o2, -28800, 0, :PST - tz.offset :o3, -28800, 3600, :PWT - tz.offset :o4, -28800, 3600, :PPT - tz.offset :o5, -28800, 3600, :PDT - tz.offset :o6, -32400, 0, :YST - tz.offset :o7, -32400, 0, :AKST - tz.offset :o8, -32400, 3600, :AKDT - - tz.transition 1867, 10, :o1, 207641393861, 86400 - tz.transition 1900, 8, :o2, 208677805061, 86400 - tz.transition 1942, 2, :o3, 29164799, 12 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o2, 19453831, 8 - tz.transition 1969, 4, :o5, 29284067, 12 - tz.transition 1969, 10, :o2, 19524167, 8 - tz.transition 1970, 4, :o5, 9972000 - tz.transition 1970, 10, :o2, 25693200 - tz.transition 1971, 4, :o5, 41421600 - tz.transition 1971, 10, :o2, 57747600 - tz.transition 1972, 4, :o5, 73476000 - tz.transition 1972, 10, :o2, 89197200 - tz.transition 1973, 4, :o5, 104925600 - tz.transition 1973, 10, :o2, 120646800 - tz.transition 1974, 1, :o5, 126698400 - tz.transition 1974, 10, :o2, 152096400 - tz.transition 1975, 2, :o5, 162381600 - tz.transition 1975, 10, :o2, 183546000 - tz.transition 1976, 4, :o5, 199274400 - tz.transition 1976, 10, :o2, 215600400 - tz.transition 1977, 4, :o5, 230724000 - tz.transition 1977, 10, :o2, 247050000 - tz.transition 1978, 4, :o5, 262778400 - tz.transition 1978, 10, :o2, 278499600 - tz.transition 1979, 4, :o5, 294228000 - tz.transition 1979, 10, :o2, 309949200 - tz.transition 1980, 4, :o5, 325677600 - tz.transition 1980, 10, :o2, 341398800 - tz.transition 1981, 4, :o5, 357127200 - tz.transition 1981, 10, :o2, 372848400 - tz.transition 1982, 4, :o5, 388576800 - tz.transition 1982, 10, :o2, 404902800 - tz.transition 1983, 4, :o5, 420026400 - tz.transition 1983, 10, :o6, 436352400 - tz.transition 1983, 11, :o7, 439030800 - tz.transition 1984, 4, :o8, 452084400 - tz.transition 1984, 10, :o7, 467805600 - tz.transition 1985, 4, :o8, 483534000 - tz.transition 1985, 10, :o7, 499255200 - tz.transition 1986, 4, :o8, 514983600 - tz.transition 1986, 10, :o7, 530704800 - tz.transition 1987, 4, :o8, 544618800 - tz.transition 1987, 10, :o7, 562154400 - tz.transition 1988, 4, :o8, 576068400 - tz.transition 1988, 10, :o7, 594208800 - tz.transition 1989, 4, :o8, 607518000 - tz.transition 1989, 10, :o7, 625658400 - tz.transition 1990, 4, :o8, 638967600 - tz.transition 1990, 10, :o7, 657108000 - tz.transition 1991, 4, :o8, 671022000 - tz.transition 1991, 10, :o7, 688557600 - tz.transition 1992, 4, :o8, 702471600 - tz.transition 1992, 10, :o7, 720007200 - tz.transition 1993, 4, :o8, 733921200 - tz.transition 1993, 10, :o7, 752061600 - tz.transition 1994, 4, :o8, 765370800 - tz.transition 1994, 10, :o7, 783511200 - tz.transition 1995, 4, :o8, 796820400 - tz.transition 1995, 10, :o7, 814960800 - tz.transition 1996, 4, :o8, 828874800 - tz.transition 1996, 10, :o7, 846410400 - tz.transition 1997, 4, :o8, 860324400 - tz.transition 1997, 10, :o7, 877860000 - tz.transition 1998, 4, :o8, 891774000 - tz.transition 1998, 10, :o7, 909309600 - tz.transition 1999, 4, :o8, 923223600 - tz.transition 1999, 10, :o7, 941364000 - tz.transition 2000, 4, :o8, 954673200 - tz.transition 2000, 10, :o7, 972813600 - tz.transition 2001, 4, :o8, 986122800 - tz.transition 2001, 10, :o7, 1004263200 - tz.transition 2002, 4, :o8, 1018177200 - tz.transition 2002, 10, :o7, 1035712800 - tz.transition 2003, 4, :o8, 1049626800 - tz.transition 2003, 10, :o7, 1067162400 - tz.transition 2004, 4, :o8, 1081076400 - tz.transition 2004, 10, :o7, 1099216800 - tz.transition 2005, 4, :o8, 1112526000 - tz.transition 2005, 10, :o7, 1130666400 - tz.transition 2006, 4, :o8, 1143975600 - tz.transition 2006, 10, :o7, 1162116000 - tz.transition 2007, 3, :o8, 1173610800 - tz.transition 2007, 11, :o7, 1194170400 - tz.transition 2008, 3, :o8, 1205060400 - tz.transition 2008, 11, :o7, 1225620000 - tz.transition 2009, 3, :o8, 1236510000 - tz.transition 2009, 11, :o7, 1257069600 - tz.transition 2010, 3, :o8, 1268564400 - tz.transition 2010, 11, :o7, 1289124000 - tz.transition 2011, 3, :o8, 1300014000 - tz.transition 2011, 11, :o7, 1320573600 - tz.transition 2012, 3, :o8, 1331463600 - tz.transition 2012, 11, :o7, 1352023200 - tz.transition 2013, 3, :o8, 1362913200 - tz.transition 2013, 11, :o7, 1383472800 - tz.transition 2014, 3, :o8, 1394362800 - tz.transition 2014, 11, :o7, 1414922400 - tz.transition 2015, 3, :o8, 1425812400 - tz.transition 2015, 11, :o7, 1446372000 - tz.transition 2016, 3, :o8, 1457866800 - tz.transition 2016, 11, :o7, 1478426400 - tz.transition 2017, 3, :o8, 1489316400 - tz.transition 2017, 11, :o7, 1509876000 - tz.transition 2018, 3, :o8, 1520766000 - tz.transition 2018, 11, :o7, 1541325600 - tz.transition 2019, 3, :o8, 1552215600 - tz.transition 2019, 11, :o7, 1572775200 - tz.transition 2020, 3, :o8, 1583665200 - tz.transition 2020, 11, :o7, 1604224800 - tz.transition 2021, 3, :o8, 1615719600 - tz.transition 2021, 11, :o7, 1636279200 - tz.transition 2022, 3, :o8, 1647169200 - tz.transition 2022, 11, :o7, 1667728800 - tz.transition 2023, 3, :o8, 1678618800 - tz.transition 2023, 11, :o7, 1699178400 - tz.transition 2024, 3, :o8, 1710068400 - tz.transition 2024, 11, :o7, 1730628000 - tz.transition 2025, 3, :o8, 1741518000 - tz.transition 2025, 11, :o7, 1762077600 - tz.transition 2026, 3, :o8, 1772967600 - tz.transition 2026, 11, :o7, 1793527200 - tz.transition 2027, 3, :o8, 1805022000 - tz.transition 2027, 11, :o7, 1825581600 - tz.transition 2028, 3, :o8, 1836471600 - tz.transition 2028, 11, :o7, 1857031200 - tz.transition 2029, 3, :o8, 1867921200 - tz.transition 2029, 11, :o7, 1888480800 - tz.transition 2030, 3, :o8, 1899370800 - tz.transition 2030, 11, :o7, 1919930400 - tz.transition 2031, 3, :o8, 1930820400 - tz.transition 2031, 11, :o7, 1951380000 - tz.transition 2032, 3, :o8, 1962874800 - tz.transition 2032, 11, :o7, 1983434400 - tz.transition 2033, 3, :o8, 1994324400 - tz.transition 2033, 11, :o7, 2014884000 - tz.transition 2034, 3, :o8, 2025774000 - tz.transition 2034, 11, :o7, 2046333600 - tz.transition 2035, 3, :o8, 2057223600 - tz.transition 2035, 11, :o7, 2077783200 - tz.transition 2036, 3, :o8, 2088673200 - tz.transition 2036, 11, :o7, 2109232800 - tz.transition 2037, 3, :o8, 2120122800 - tz.transition 2037, 11, :o7, 2140682400 - tz.transition 2038, 3, :o8, 59171927, 24 - tz.transition 2038, 11, :o7, 29588819, 12 - tz.transition 2039, 3, :o8, 59180663, 24 - tz.transition 2039, 11, :o7, 29593187, 12 - tz.transition 2040, 3, :o8, 59189399, 24 - tz.transition 2040, 11, :o7, 29597555, 12 - tz.transition 2041, 3, :o8, 59198135, 24 - tz.transition 2041, 11, :o7, 29601923, 12 - tz.transition 2042, 3, :o8, 59206871, 24 - tz.transition 2042, 11, :o7, 29606291, 12 - tz.transition 2043, 3, :o8, 59215607, 24 - tz.transition 2043, 11, :o7, 29610659, 12 - tz.transition 2044, 3, :o8, 59224511, 24 - tz.transition 2044, 11, :o7, 29615111, 12 - tz.transition 2045, 3, :o8, 59233247, 24 - tz.transition 2045, 11, :o7, 29619479, 12 - tz.transition 2046, 3, :o8, 59241983, 24 - tz.transition 2046, 11, :o7, 29623847, 12 - tz.transition 2047, 3, :o8, 59250719, 24 - tz.transition 2047, 11, :o7, 29628215, 12 - tz.transition 2048, 3, :o8, 59259455, 24 - tz.transition 2048, 11, :o7, 29632583, 12 - tz.transition 2049, 3, :o8, 59268359, 24 - tz.transition 2049, 11, :o7, 29637035, 12 - tz.transition 2050, 3, :o8, 59277095, 24 - tz.transition 2050, 11, :o7, 29641403, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb deleted file mode 100644 index 45c90789..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module La_Paz - include TimezoneDefinition - - timezone 'America/La_Paz' do |tz| - tz.offset :o0, -16356, 0, :LMT - tz.offset :o1, -16356, 0, :CMT - tz.offset :o2, -16356, 3600, :BOST - tz.offset :o3, -14400, 0, :BOT - - tz.transition 1890, 1, :o1, 17361854563, 7200 - tz.transition 1931, 10, :o2, 17471733763, 7200 - tz.transition 1932, 3, :o3, 17472871063, 7200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb deleted file mode 100644 index af68ac29..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Lima - include TimezoneDefinition - - timezone 'America/Lima' do |tz| - tz.offset :o0, -18492, 0, :LMT - tz.offset :o1, -18516, 0, :LMT - tz.offset :o2, -18000, 0, :PET - tz.offset :o3, -18000, 3600, :PEST - - tz.transition 1890, 1, :o1, 17361854741, 7200 - tz.transition 1908, 7, :o2, 17410685143, 7200 - tz.transition 1938, 1, :o3, 58293593, 24 - tz.transition 1938, 4, :o2, 7286969, 3 - tz.transition 1938, 9, :o3, 58300001, 24 - tz.transition 1939, 3, :o2, 7288046, 3 - tz.transition 1939, 9, :o3, 58308737, 24 - tz.transition 1940, 3, :o2, 7289138, 3 - tz.transition 1986, 1, :o3, 504939600 - tz.transition 1986, 4, :o2, 512712000 - tz.transition 1987, 1, :o3, 536475600 - tz.transition 1987, 4, :o2, 544248000 - tz.transition 1990, 1, :o3, 631170000 - tz.transition 1990, 4, :o2, 638942400 - tz.transition 1994, 1, :o3, 757400400 - tz.transition 1994, 4, :o2, 765172800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb deleted file mode 100644 index 16007fd6..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Los_Angeles - include TimezoneDefinition - - timezone 'America/Los_Angeles' do |tz| - tz.offset :o0, -28378, 0, :LMT - tz.offset :o1, -28800, 0, :PST - tz.offset :o2, -28800, 3600, :PDT - tz.offset :o3, -28800, 3600, :PWT - tz.offset :o4, -28800, 3600, :PPT - - tz.transition 1883, 11, :o1, 7227400, 3 - tz.transition 1918, 3, :o2, 29060207, 12 - tz.transition 1918, 10, :o1, 19375151, 8 - tz.transition 1919, 3, :o2, 29064575, 12 - tz.transition 1919, 10, :o1, 19378063, 8 - tz.transition 1942, 2, :o3, 29164799, 12 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 19453831, 8 - tz.transition 1948, 3, :o2, 29191499, 12 - tz.transition 1949, 1, :o1, 19463343, 8 - tz.transition 1950, 4, :o2, 29200823, 12 - tz.transition 1950, 9, :o1, 19468391, 8 - tz.transition 1951, 4, :o2, 29205191, 12 - tz.transition 1951, 9, :o1, 19471359, 8 - tz.transition 1952, 4, :o2, 29209559, 12 - tz.transition 1952, 9, :o1, 19474271, 8 - tz.transition 1953, 4, :o2, 29213927, 12 - tz.transition 1953, 9, :o1, 19477183, 8 - tz.transition 1954, 4, :o2, 29218295, 12 - tz.transition 1954, 9, :o1, 19480095, 8 - tz.transition 1955, 4, :o2, 29222663, 12 - tz.transition 1955, 9, :o1, 19483007, 8 - tz.transition 1956, 4, :o2, 29227115, 12 - tz.transition 1956, 9, :o1, 19485975, 8 - tz.transition 1957, 4, :o2, 29231483, 12 - tz.transition 1957, 9, :o1, 19488887, 8 - tz.transition 1958, 4, :o2, 29235851, 12 - tz.transition 1958, 9, :o1, 19491799, 8 - tz.transition 1959, 4, :o2, 29240219, 12 - tz.transition 1959, 9, :o1, 19494711, 8 - tz.transition 1960, 4, :o2, 29244587, 12 - tz.transition 1960, 9, :o1, 19497623, 8 - tz.transition 1961, 4, :o2, 29249039, 12 - tz.transition 1961, 9, :o1, 19500535, 8 - tz.transition 1962, 4, :o2, 29253407, 12 - tz.transition 1962, 10, :o1, 19503727, 8 - tz.transition 1963, 4, :o2, 29257775, 12 - tz.transition 1963, 10, :o1, 19506639, 8 - tz.transition 1964, 4, :o2, 29262143, 12 - tz.transition 1964, 10, :o1, 19509551, 8 - tz.transition 1965, 4, :o2, 29266511, 12 - tz.transition 1965, 10, :o1, 19512519, 8 - tz.transition 1966, 4, :o2, 29270879, 12 - tz.transition 1966, 10, :o1, 19515431, 8 - tz.transition 1967, 4, :o2, 29275331, 12 - tz.transition 1967, 10, :o1, 19518343, 8 - tz.transition 1968, 4, :o2, 29279699, 12 - tz.transition 1968, 10, :o1, 19521255, 8 - tz.transition 1969, 4, :o2, 29284067, 12 - tz.transition 1969, 10, :o1, 19524167, 8 - tz.transition 1970, 4, :o2, 9972000 - tz.transition 1970, 10, :o1, 25693200 - tz.transition 1971, 4, :o2, 41421600 - tz.transition 1971, 10, :o1, 57747600 - tz.transition 1972, 4, :o2, 73476000 - tz.transition 1972, 10, :o1, 89197200 - tz.transition 1973, 4, :o2, 104925600 - tz.transition 1973, 10, :o1, 120646800 - tz.transition 1974, 1, :o2, 126698400 - tz.transition 1974, 10, :o1, 152096400 - tz.transition 1975, 2, :o2, 162381600 - tz.transition 1975, 10, :o1, 183546000 - tz.transition 1976, 4, :o2, 199274400 - tz.transition 1976, 10, :o1, 215600400 - tz.transition 1977, 4, :o2, 230724000 - tz.transition 1977, 10, :o1, 247050000 - tz.transition 1978, 4, :o2, 262778400 - tz.transition 1978, 10, :o1, 278499600 - tz.transition 1979, 4, :o2, 294228000 - tz.transition 1979, 10, :o1, 309949200 - tz.transition 1980, 4, :o2, 325677600 - tz.transition 1980, 10, :o1, 341398800 - tz.transition 1981, 4, :o2, 357127200 - tz.transition 1981, 10, :o1, 372848400 - tz.transition 1982, 4, :o2, 388576800 - tz.transition 1982, 10, :o1, 404902800 - tz.transition 1983, 4, :o2, 420026400 - tz.transition 1983, 10, :o1, 436352400 - tz.transition 1984, 4, :o2, 452080800 - tz.transition 1984, 10, :o1, 467802000 - tz.transition 1985, 4, :o2, 483530400 - tz.transition 1985, 10, :o1, 499251600 - tz.transition 1986, 4, :o2, 514980000 - tz.transition 1986, 10, :o1, 530701200 - tz.transition 1987, 4, :o2, 544615200 - tz.transition 1987, 10, :o1, 562150800 - tz.transition 1988, 4, :o2, 576064800 - tz.transition 1988, 10, :o1, 594205200 - tz.transition 1989, 4, :o2, 607514400 - tz.transition 1989, 10, :o1, 625654800 - tz.transition 1990, 4, :o2, 638964000 - tz.transition 1990, 10, :o1, 657104400 - tz.transition 1991, 4, :o2, 671018400 - tz.transition 1991, 10, :o1, 688554000 - tz.transition 1992, 4, :o2, 702468000 - tz.transition 1992, 10, :o1, 720003600 - tz.transition 1993, 4, :o2, 733917600 - tz.transition 1993, 10, :o1, 752058000 - tz.transition 1994, 4, :o2, 765367200 - tz.transition 1994, 10, :o1, 783507600 - tz.transition 1995, 4, :o2, 796816800 - tz.transition 1995, 10, :o1, 814957200 - tz.transition 1996, 4, :o2, 828871200 - tz.transition 1996, 10, :o1, 846406800 - tz.transition 1997, 4, :o2, 860320800 - tz.transition 1997, 10, :o1, 877856400 - tz.transition 1998, 4, :o2, 891770400 - tz.transition 1998, 10, :o1, 909306000 - tz.transition 1999, 4, :o2, 923220000 - tz.transition 1999, 10, :o1, 941360400 - tz.transition 2000, 4, :o2, 954669600 - tz.transition 2000, 10, :o1, 972810000 - tz.transition 2001, 4, :o2, 986119200 - tz.transition 2001, 10, :o1, 1004259600 - tz.transition 2002, 4, :o2, 1018173600 - tz.transition 2002, 10, :o1, 1035709200 - tz.transition 2003, 4, :o2, 1049623200 - tz.transition 2003, 10, :o1, 1067158800 - tz.transition 2004, 4, :o2, 1081072800 - tz.transition 2004, 10, :o1, 1099213200 - tz.transition 2005, 4, :o2, 1112522400 - tz.transition 2005, 10, :o1, 1130662800 - tz.transition 2006, 4, :o2, 1143972000 - tz.transition 2006, 10, :o1, 1162112400 - tz.transition 2007, 3, :o2, 1173607200 - tz.transition 2007, 11, :o1, 1194166800 - tz.transition 2008, 3, :o2, 1205056800 - tz.transition 2008, 11, :o1, 1225616400 - tz.transition 2009, 3, :o2, 1236506400 - tz.transition 2009, 11, :o1, 1257066000 - tz.transition 2010, 3, :o2, 1268560800 - tz.transition 2010, 11, :o1, 1289120400 - tz.transition 2011, 3, :o2, 1300010400 - tz.transition 2011, 11, :o1, 1320570000 - tz.transition 2012, 3, :o2, 1331460000 - tz.transition 2012, 11, :o1, 1352019600 - tz.transition 2013, 3, :o2, 1362909600 - tz.transition 2013, 11, :o1, 1383469200 - tz.transition 2014, 3, :o2, 1394359200 - tz.transition 2014, 11, :o1, 1414918800 - tz.transition 2015, 3, :o2, 1425808800 - tz.transition 2015, 11, :o1, 1446368400 - tz.transition 2016, 3, :o2, 1457863200 - tz.transition 2016, 11, :o1, 1478422800 - tz.transition 2017, 3, :o2, 1489312800 - tz.transition 2017, 11, :o1, 1509872400 - tz.transition 2018, 3, :o2, 1520762400 - tz.transition 2018, 11, :o1, 1541322000 - tz.transition 2019, 3, :o2, 1552212000 - tz.transition 2019, 11, :o1, 1572771600 - tz.transition 2020, 3, :o2, 1583661600 - tz.transition 2020, 11, :o1, 1604221200 - tz.transition 2021, 3, :o2, 1615716000 - tz.transition 2021, 11, :o1, 1636275600 - tz.transition 2022, 3, :o2, 1647165600 - tz.transition 2022, 11, :o1, 1667725200 - tz.transition 2023, 3, :o2, 1678615200 - tz.transition 2023, 11, :o1, 1699174800 - tz.transition 2024, 3, :o2, 1710064800 - tz.transition 2024, 11, :o1, 1730624400 - tz.transition 2025, 3, :o2, 1741514400 - tz.transition 2025, 11, :o1, 1762074000 - tz.transition 2026, 3, :o2, 1772964000 - tz.transition 2026, 11, :o1, 1793523600 - tz.transition 2027, 3, :o2, 1805018400 - tz.transition 2027, 11, :o1, 1825578000 - tz.transition 2028, 3, :o2, 1836468000 - tz.transition 2028, 11, :o1, 1857027600 - tz.transition 2029, 3, :o2, 1867917600 - tz.transition 2029, 11, :o1, 1888477200 - tz.transition 2030, 3, :o2, 1899367200 - tz.transition 2030, 11, :o1, 1919926800 - tz.transition 2031, 3, :o2, 1930816800 - tz.transition 2031, 11, :o1, 1951376400 - tz.transition 2032, 3, :o2, 1962871200 - tz.transition 2032, 11, :o1, 1983430800 - tz.transition 2033, 3, :o2, 1994320800 - tz.transition 2033, 11, :o1, 2014880400 - tz.transition 2034, 3, :o2, 2025770400 - tz.transition 2034, 11, :o1, 2046330000 - tz.transition 2035, 3, :o2, 2057220000 - tz.transition 2035, 11, :o1, 2077779600 - tz.transition 2036, 3, :o2, 2088669600 - tz.transition 2036, 11, :o1, 2109229200 - tz.transition 2037, 3, :o2, 2120119200 - tz.transition 2037, 11, :o1, 2140678800 - tz.transition 2038, 3, :o2, 29585963, 12 - tz.transition 2038, 11, :o1, 19725879, 8 - tz.transition 2039, 3, :o2, 29590331, 12 - tz.transition 2039, 11, :o1, 19728791, 8 - tz.transition 2040, 3, :o2, 29594699, 12 - tz.transition 2040, 11, :o1, 19731703, 8 - tz.transition 2041, 3, :o2, 29599067, 12 - tz.transition 2041, 11, :o1, 19734615, 8 - tz.transition 2042, 3, :o2, 29603435, 12 - tz.transition 2042, 11, :o1, 19737527, 8 - tz.transition 2043, 3, :o2, 29607803, 12 - tz.transition 2043, 11, :o1, 19740439, 8 - tz.transition 2044, 3, :o2, 29612255, 12 - tz.transition 2044, 11, :o1, 19743407, 8 - tz.transition 2045, 3, :o2, 29616623, 12 - tz.transition 2045, 11, :o1, 19746319, 8 - tz.transition 2046, 3, :o2, 29620991, 12 - tz.transition 2046, 11, :o1, 19749231, 8 - tz.transition 2047, 3, :o2, 29625359, 12 - tz.transition 2047, 11, :o1, 19752143, 8 - tz.transition 2048, 3, :o2, 29629727, 12 - tz.transition 2048, 11, :o1, 19755055, 8 - tz.transition 2049, 3, :o2, 29634179, 12 - tz.transition 2049, 11, :o1, 19758023, 8 - tz.transition 2050, 3, :o2, 29638547, 12 - tz.transition 2050, 11, :o1, 19760935, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb deleted file mode 100644 index ba9e6efc..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +++ /dev/null @@ -1,139 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Mazatlan - include TimezoneDefinition - - timezone 'America/Mazatlan' do |tz| - tz.offset :o0, -25540, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -21600, 0, :CST - tz.offset :o3, -28800, 0, :PST - tz.offset :o4, -25200, 3600, :MDT - - tz.transition 1922, 1, :o1, 58153339, 24 - tz.transition 1927, 6, :o2, 9700171, 4 - tz.transition 1930, 11, :o1, 9705183, 4 - tz.transition 1931, 5, :o2, 9705855, 4 - tz.transition 1931, 10, :o1, 9706463, 4 - tz.transition 1932, 4, :o2, 58243171, 24 - tz.transition 1942, 4, :o1, 9721895, 4 - tz.transition 1949, 1, :o3, 58390339, 24 - tz.transition 1970, 1, :o1, 28800 - tz.transition 1996, 4, :o4, 828867600 - tz.transition 1996, 10, :o1, 846403200 - tz.transition 1997, 4, :o4, 860317200 - tz.transition 1997, 10, :o1, 877852800 - tz.transition 1998, 4, :o4, 891766800 - tz.transition 1998, 10, :o1, 909302400 - tz.transition 1999, 4, :o4, 923216400 - tz.transition 1999, 10, :o1, 941356800 - tz.transition 2000, 4, :o4, 954666000 - tz.transition 2000, 10, :o1, 972806400 - tz.transition 2001, 5, :o4, 989139600 - tz.transition 2001, 9, :o1, 1001836800 - tz.transition 2002, 4, :o4, 1018170000 - tz.transition 2002, 10, :o1, 1035705600 - tz.transition 2003, 4, :o4, 1049619600 - tz.transition 2003, 10, :o1, 1067155200 - tz.transition 2004, 4, :o4, 1081069200 - tz.transition 2004, 10, :o1, 1099209600 - tz.transition 2005, 4, :o4, 1112518800 - tz.transition 2005, 10, :o1, 1130659200 - tz.transition 2006, 4, :o4, 1143968400 - tz.transition 2006, 10, :o1, 1162108800 - tz.transition 2007, 4, :o4, 1175418000 - tz.transition 2007, 10, :o1, 1193558400 - tz.transition 2008, 4, :o4, 1207472400 - tz.transition 2008, 10, :o1, 1225008000 - tz.transition 2009, 4, :o4, 1238922000 - tz.transition 2009, 10, :o1, 1256457600 - tz.transition 2010, 4, :o4, 1270371600 - tz.transition 2010, 10, :o1, 1288512000 - tz.transition 2011, 4, :o4, 1301821200 - tz.transition 2011, 10, :o1, 1319961600 - tz.transition 2012, 4, :o4, 1333270800 - tz.transition 2012, 10, :o1, 1351411200 - tz.transition 2013, 4, :o4, 1365325200 - tz.transition 2013, 10, :o1, 1382860800 - tz.transition 2014, 4, :o4, 1396774800 - tz.transition 2014, 10, :o1, 1414310400 - tz.transition 2015, 4, :o4, 1428224400 - tz.transition 2015, 10, :o1, 1445760000 - tz.transition 2016, 4, :o4, 1459674000 - tz.transition 2016, 10, :o1, 1477814400 - tz.transition 2017, 4, :o4, 1491123600 - tz.transition 2017, 10, :o1, 1509264000 - tz.transition 2018, 4, :o4, 1522573200 - tz.transition 2018, 10, :o1, 1540713600 - tz.transition 2019, 4, :o4, 1554627600 - tz.transition 2019, 10, :o1, 1572163200 - tz.transition 2020, 4, :o4, 1586077200 - tz.transition 2020, 10, :o1, 1603612800 - tz.transition 2021, 4, :o4, 1617526800 - tz.transition 2021, 10, :o1, 1635667200 - tz.transition 2022, 4, :o4, 1648976400 - tz.transition 2022, 10, :o1, 1667116800 - tz.transition 2023, 4, :o4, 1680426000 - tz.transition 2023, 10, :o1, 1698566400 - tz.transition 2024, 4, :o4, 1712480400 - tz.transition 2024, 10, :o1, 1730016000 - tz.transition 2025, 4, :o4, 1743930000 - tz.transition 2025, 10, :o1, 1761465600 - tz.transition 2026, 4, :o4, 1775379600 - tz.transition 2026, 10, :o1, 1792915200 - tz.transition 2027, 4, :o4, 1806829200 - tz.transition 2027, 10, :o1, 1824969600 - tz.transition 2028, 4, :o4, 1838278800 - tz.transition 2028, 10, :o1, 1856419200 - tz.transition 2029, 4, :o4, 1869728400 - tz.transition 2029, 10, :o1, 1887868800 - tz.transition 2030, 4, :o4, 1901782800 - tz.transition 2030, 10, :o1, 1919318400 - tz.transition 2031, 4, :o4, 1933232400 - tz.transition 2031, 10, :o1, 1950768000 - tz.transition 2032, 4, :o4, 1964682000 - tz.transition 2032, 10, :o1, 1982822400 - tz.transition 2033, 4, :o4, 1996131600 - tz.transition 2033, 10, :o1, 2014272000 - tz.transition 2034, 4, :o4, 2027581200 - tz.transition 2034, 10, :o1, 2045721600 - tz.transition 2035, 4, :o4, 2059030800 - tz.transition 2035, 10, :o1, 2077171200 - tz.transition 2036, 4, :o4, 2091085200 - tz.transition 2036, 10, :o1, 2108620800 - tz.transition 2037, 4, :o4, 2122534800 - tz.transition 2037, 10, :o1, 2140070400 - tz.transition 2038, 4, :o4, 19724143, 8 - tz.transition 2038, 10, :o1, 14794367, 6 - tz.transition 2039, 4, :o4, 19727055, 8 - tz.transition 2039, 10, :o1, 14796551, 6 - tz.transition 2040, 4, :o4, 19729967, 8 - tz.transition 2040, 10, :o1, 14798735, 6 - tz.transition 2041, 4, :o4, 19732935, 8 - tz.transition 2041, 10, :o1, 14800919, 6 - tz.transition 2042, 4, :o4, 19735847, 8 - tz.transition 2042, 10, :o1, 14803103, 6 - tz.transition 2043, 4, :o4, 19738759, 8 - tz.transition 2043, 10, :o1, 14805287, 6 - tz.transition 2044, 4, :o4, 19741671, 8 - tz.transition 2044, 10, :o1, 14807513, 6 - tz.transition 2045, 4, :o4, 19744583, 8 - tz.transition 2045, 10, :o1, 14809697, 6 - tz.transition 2046, 4, :o4, 19747495, 8 - tz.transition 2046, 10, :o1, 14811881, 6 - tz.transition 2047, 4, :o4, 19750463, 8 - tz.transition 2047, 10, :o1, 14814065, 6 - tz.transition 2048, 4, :o4, 19753375, 8 - tz.transition 2048, 10, :o1, 14816249, 6 - tz.transition 2049, 4, :o4, 19756287, 8 - tz.transition 2049, 10, :o1, 14818475, 6 - tz.transition 2050, 4, :o4, 19759199, 8 - tz.transition 2050, 10, :o1, 14820659, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb deleted file mode 100644 index 2347fce6..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +++ /dev/null @@ -1,144 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Mexico_City - include TimezoneDefinition - - timezone 'America/Mexico_City' do |tz| - tz.offset :o0, -23796, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -21600, 0, :CST - tz.offset :o3, -21600, 3600, :CDT - tz.offset :o4, -21600, 3600, :CWT - - tz.transition 1922, 1, :o1, 58153339, 24 - tz.transition 1927, 6, :o2, 9700171, 4 - tz.transition 1930, 11, :o1, 9705183, 4 - tz.transition 1931, 5, :o2, 9705855, 4 - tz.transition 1931, 10, :o1, 9706463, 4 - tz.transition 1932, 4, :o2, 58243171, 24 - tz.transition 1939, 2, :o3, 9717199, 4 - tz.transition 1939, 6, :o2, 58306553, 24 - tz.transition 1940, 12, :o3, 9719891, 4 - tz.transition 1941, 4, :o2, 58322057, 24 - tz.transition 1943, 12, :o4, 9724299, 4 - tz.transition 1944, 5, :o2, 58349081, 24 - tz.transition 1950, 2, :o3, 9733299, 4 - tz.transition 1950, 7, :o2, 58403825, 24 - tz.transition 1996, 4, :o3, 828864000 - tz.transition 1996, 10, :o2, 846399600 - tz.transition 1997, 4, :o3, 860313600 - tz.transition 1997, 10, :o2, 877849200 - tz.transition 1998, 4, :o3, 891763200 - tz.transition 1998, 10, :o2, 909298800 - tz.transition 1999, 4, :o3, 923212800 - tz.transition 1999, 10, :o2, 941353200 - tz.transition 2000, 4, :o3, 954662400 - tz.transition 2000, 10, :o2, 972802800 - tz.transition 2001, 5, :o3, 989136000 - tz.transition 2001, 9, :o2, 1001833200 - tz.transition 2002, 4, :o3, 1018166400 - tz.transition 2002, 10, :o2, 1035702000 - tz.transition 2003, 4, :o3, 1049616000 - tz.transition 2003, 10, :o2, 1067151600 - tz.transition 2004, 4, :o3, 1081065600 - tz.transition 2004, 10, :o2, 1099206000 - tz.transition 2005, 4, :o3, 1112515200 - tz.transition 2005, 10, :o2, 1130655600 - tz.transition 2006, 4, :o3, 1143964800 - tz.transition 2006, 10, :o2, 1162105200 - tz.transition 2007, 4, :o3, 1175414400 - tz.transition 2007, 10, :o2, 1193554800 - tz.transition 2008, 4, :o3, 1207468800 - tz.transition 2008, 10, :o2, 1225004400 - tz.transition 2009, 4, :o3, 1238918400 - tz.transition 2009, 10, :o2, 1256454000 - tz.transition 2010, 4, :o3, 1270368000 - tz.transition 2010, 10, :o2, 1288508400 - tz.transition 2011, 4, :o3, 1301817600 - tz.transition 2011, 10, :o2, 1319958000 - tz.transition 2012, 4, :o3, 1333267200 - tz.transition 2012, 10, :o2, 1351407600 - tz.transition 2013, 4, :o3, 1365321600 - tz.transition 2013, 10, :o2, 1382857200 - tz.transition 2014, 4, :o3, 1396771200 - tz.transition 2014, 10, :o2, 1414306800 - tz.transition 2015, 4, :o3, 1428220800 - tz.transition 2015, 10, :o2, 1445756400 - tz.transition 2016, 4, :o3, 1459670400 - tz.transition 2016, 10, :o2, 1477810800 - tz.transition 2017, 4, :o3, 1491120000 - tz.transition 2017, 10, :o2, 1509260400 - tz.transition 2018, 4, :o3, 1522569600 - tz.transition 2018, 10, :o2, 1540710000 - tz.transition 2019, 4, :o3, 1554624000 - tz.transition 2019, 10, :o2, 1572159600 - tz.transition 2020, 4, :o3, 1586073600 - tz.transition 2020, 10, :o2, 1603609200 - tz.transition 2021, 4, :o3, 1617523200 - tz.transition 2021, 10, :o2, 1635663600 - tz.transition 2022, 4, :o3, 1648972800 - tz.transition 2022, 10, :o2, 1667113200 - tz.transition 2023, 4, :o3, 1680422400 - tz.transition 2023, 10, :o2, 1698562800 - tz.transition 2024, 4, :o3, 1712476800 - tz.transition 2024, 10, :o2, 1730012400 - tz.transition 2025, 4, :o3, 1743926400 - tz.transition 2025, 10, :o2, 1761462000 - tz.transition 2026, 4, :o3, 1775376000 - tz.transition 2026, 10, :o2, 1792911600 - tz.transition 2027, 4, :o3, 1806825600 - tz.transition 2027, 10, :o2, 1824966000 - tz.transition 2028, 4, :o3, 1838275200 - tz.transition 2028, 10, :o2, 1856415600 - tz.transition 2029, 4, :o3, 1869724800 - tz.transition 2029, 10, :o2, 1887865200 - tz.transition 2030, 4, :o3, 1901779200 - tz.transition 2030, 10, :o2, 1919314800 - tz.transition 2031, 4, :o3, 1933228800 - tz.transition 2031, 10, :o2, 1950764400 - tz.transition 2032, 4, :o3, 1964678400 - tz.transition 2032, 10, :o2, 1982818800 - tz.transition 2033, 4, :o3, 1996128000 - tz.transition 2033, 10, :o2, 2014268400 - tz.transition 2034, 4, :o3, 2027577600 - tz.transition 2034, 10, :o2, 2045718000 - tz.transition 2035, 4, :o3, 2059027200 - tz.transition 2035, 10, :o2, 2077167600 - tz.transition 2036, 4, :o3, 2091081600 - tz.transition 2036, 10, :o2, 2108617200 - tz.transition 2037, 4, :o3, 2122531200 - tz.transition 2037, 10, :o2, 2140066800 - tz.transition 2038, 4, :o3, 14793107, 6 - tz.transition 2038, 10, :o2, 59177467, 24 - tz.transition 2039, 4, :o3, 14795291, 6 - tz.transition 2039, 10, :o2, 59186203, 24 - tz.transition 2040, 4, :o3, 14797475, 6 - tz.transition 2040, 10, :o2, 59194939, 24 - tz.transition 2041, 4, :o3, 14799701, 6 - tz.transition 2041, 10, :o2, 59203675, 24 - tz.transition 2042, 4, :o3, 14801885, 6 - tz.transition 2042, 10, :o2, 59212411, 24 - tz.transition 2043, 4, :o3, 14804069, 6 - tz.transition 2043, 10, :o2, 59221147, 24 - tz.transition 2044, 4, :o3, 14806253, 6 - tz.transition 2044, 10, :o2, 59230051, 24 - tz.transition 2045, 4, :o3, 14808437, 6 - tz.transition 2045, 10, :o2, 59238787, 24 - tz.transition 2046, 4, :o3, 14810621, 6 - tz.transition 2046, 10, :o2, 59247523, 24 - tz.transition 2047, 4, :o3, 14812847, 6 - tz.transition 2047, 10, :o2, 59256259, 24 - tz.transition 2048, 4, :o3, 14815031, 6 - tz.transition 2048, 10, :o2, 59264995, 24 - tz.transition 2049, 4, :o3, 14817215, 6 - tz.transition 2049, 10, :o2, 59273899, 24 - tz.transition 2050, 4, :o3, 14819399, 6 - tz.transition 2050, 10, :o2, 59282635, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb deleted file mode 100644 index 5816a9ea..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Monterrey - include TimezoneDefinition - - timezone 'America/Monterrey' do |tz| - tz.offset :o0, -24076, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - - tz.transition 1922, 1, :o1, 9692223, 4 - tz.transition 1988, 4, :o2, 576057600 - tz.transition 1988, 10, :o1, 594198000 - tz.transition 1996, 4, :o2, 828864000 - tz.transition 1996, 10, :o1, 846399600 - tz.transition 1997, 4, :o2, 860313600 - tz.transition 1997, 10, :o1, 877849200 - tz.transition 1998, 4, :o2, 891763200 - tz.transition 1998, 10, :o1, 909298800 - tz.transition 1999, 4, :o2, 923212800 - tz.transition 1999, 10, :o1, 941353200 - tz.transition 2000, 4, :o2, 954662400 - tz.transition 2000, 10, :o1, 972802800 - tz.transition 2001, 5, :o2, 989136000 - tz.transition 2001, 9, :o1, 1001833200 - tz.transition 2002, 4, :o2, 1018166400 - tz.transition 2002, 10, :o1, 1035702000 - tz.transition 2003, 4, :o2, 1049616000 - tz.transition 2003, 10, :o1, 1067151600 - tz.transition 2004, 4, :o2, 1081065600 - tz.transition 2004, 10, :o1, 1099206000 - tz.transition 2005, 4, :o2, 1112515200 - tz.transition 2005, 10, :o1, 1130655600 - tz.transition 2006, 4, :o2, 1143964800 - tz.transition 2006, 10, :o1, 1162105200 - tz.transition 2007, 4, :o2, 1175414400 - tz.transition 2007, 10, :o1, 1193554800 - tz.transition 2008, 4, :o2, 1207468800 - tz.transition 2008, 10, :o1, 1225004400 - tz.transition 2009, 4, :o2, 1238918400 - tz.transition 2009, 10, :o1, 1256454000 - tz.transition 2010, 4, :o2, 1270368000 - tz.transition 2010, 10, :o1, 1288508400 - tz.transition 2011, 4, :o2, 1301817600 - tz.transition 2011, 10, :o1, 1319958000 - tz.transition 2012, 4, :o2, 1333267200 - tz.transition 2012, 10, :o1, 1351407600 - tz.transition 2013, 4, :o2, 1365321600 - tz.transition 2013, 10, :o1, 1382857200 - tz.transition 2014, 4, :o2, 1396771200 - tz.transition 2014, 10, :o1, 1414306800 - tz.transition 2015, 4, :o2, 1428220800 - tz.transition 2015, 10, :o1, 1445756400 - tz.transition 2016, 4, :o2, 1459670400 - tz.transition 2016, 10, :o1, 1477810800 - tz.transition 2017, 4, :o2, 1491120000 - tz.transition 2017, 10, :o1, 1509260400 - tz.transition 2018, 4, :o2, 1522569600 - tz.transition 2018, 10, :o1, 1540710000 - tz.transition 2019, 4, :o2, 1554624000 - tz.transition 2019, 10, :o1, 1572159600 - tz.transition 2020, 4, :o2, 1586073600 - tz.transition 2020, 10, :o1, 1603609200 - tz.transition 2021, 4, :o2, 1617523200 - tz.transition 2021, 10, :o1, 1635663600 - tz.transition 2022, 4, :o2, 1648972800 - tz.transition 2022, 10, :o1, 1667113200 - tz.transition 2023, 4, :o2, 1680422400 - tz.transition 2023, 10, :o1, 1698562800 - tz.transition 2024, 4, :o2, 1712476800 - tz.transition 2024, 10, :o1, 1730012400 - tz.transition 2025, 4, :o2, 1743926400 - tz.transition 2025, 10, :o1, 1761462000 - tz.transition 2026, 4, :o2, 1775376000 - tz.transition 2026, 10, :o1, 1792911600 - tz.transition 2027, 4, :o2, 1806825600 - tz.transition 2027, 10, :o1, 1824966000 - tz.transition 2028, 4, :o2, 1838275200 - tz.transition 2028, 10, :o1, 1856415600 - tz.transition 2029, 4, :o2, 1869724800 - tz.transition 2029, 10, :o1, 1887865200 - tz.transition 2030, 4, :o2, 1901779200 - tz.transition 2030, 10, :o1, 1919314800 - tz.transition 2031, 4, :o2, 1933228800 - tz.transition 2031, 10, :o1, 1950764400 - tz.transition 2032, 4, :o2, 1964678400 - tz.transition 2032, 10, :o1, 1982818800 - tz.transition 2033, 4, :o2, 1996128000 - tz.transition 2033, 10, :o1, 2014268400 - tz.transition 2034, 4, :o2, 2027577600 - tz.transition 2034, 10, :o1, 2045718000 - tz.transition 2035, 4, :o2, 2059027200 - tz.transition 2035, 10, :o1, 2077167600 - tz.transition 2036, 4, :o2, 2091081600 - tz.transition 2036, 10, :o1, 2108617200 - tz.transition 2037, 4, :o2, 2122531200 - tz.transition 2037, 10, :o1, 2140066800 - tz.transition 2038, 4, :o2, 14793107, 6 - tz.transition 2038, 10, :o1, 59177467, 24 - tz.transition 2039, 4, :o2, 14795291, 6 - tz.transition 2039, 10, :o1, 59186203, 24 - tz.transition 2040, 4, :o2, 14797475, 6 - tz.transition 2040, 10, :o1, 59194939, 24 - tz.transition 2041, 4, :o2, 14799701, 6 - tz.transition 2041, 10, :o1, 59203675, 24 - tz.transition 2042, 4, :o2, 14801885, 6 - tz.transition 2042, 10, :o1, 59212411, 24 - tz.transition 2043, 4, :o2, 14804069, 6 - tz.transition 2043, 10, :o1, 59221147, 24 - tz.transition 2044, 4, :o2, 14806253, 6 - tz.transition 2044, 10, :o1, 59230051, 24 - tz.transition 2045, 4, :o2, 14808437, 6 - tz.transition 2045, 10, :o1, 59238787, 24 - tz.transition 2046, 4, :o2, 14810621, 6 - tz.transition 2046, 10, :o1, 59247523, 24 - tz.transition 2047, 4, :o2, 14812847, 6 - tz.transition 2047, 10, :o1, 59256259, 24 - tz.transition 2048, 4, :o2, 14815031, 6 - tz.transition 2048, 10, :o1, 59264995, 24 - tz.transition 2049, 4, :o2, 14817215, 6 - tz.transition 2049, 10, :o1, 59273899, 24 - tz.transition 2050, 4, :o2, 14819399, 6 - tz.transition 2050, 10, :o1, 59282635, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb deleted file mode 100644 index 7d802bd2..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +++ /dev/null @@ -1,282 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module New_York - include TimezoneDefinition - - timezone 'America/New_York' do |tz| - tz.offset :o0, -17762, 0, :LMT - tz.offset :o1, -18000, 0, :EST - tz.offset :o2, -18000, 3600, :EDT - tz.offset :o3, -18000, 3600, :EWT - tz.offset :o4, -18000, 3600, :EPT - - tz.transition 1883, 11, :o1, 57819197, 24 - tz.transition 1918, 3, :o2, 58120411, 24 - tz.transition 1918, 10, :o1, 9687575, 4 - tz.transition 1919, 3, :o2, 58129147, 24 - tz.transition 1919, 10, :o1, 9689031, 4 - tz.transition 1920, 3, :o2, 58137883, 24 - tz.transition 1920, 10, :o1, 9690515, 4 - tz.transition 1921, 4, :o2, 58147291, 24 - tz.transition 1921, 9, :o1, 9691831, 4 - tz.transition 1922, 4, :o2, 58156195, 24 - tz.transition 1922, 9, :o1, 9693287, 4 - tz.transition 1923, 4, :o2, 58164931, 24 - tz.transition 1923, 9, :o1, 9694771, 4 - tz.transition 1924, 4, :o2, 58173667, 24 - tz.transition 1924, 9, :o1, 9696227, 4 - tz.transition 1925, 4, :o2, 58182403, 24 - tz.transition 1925, 9, :o1, 9697683, 4 - tz.transition 1926, 4, :o2, 58191139, 24 - tz.transition 1926, 9, :o1, 9699139, 4 - tz.transition 1927, 4, :o2, 58199875, 24 - tz.transition 1927, 9, :o1, 9700595, 4 - tz.transition 1928, 4, :o2, 58208779, 24 - tz.transition 1928, 9, :o1, 9702079, 4 - tz.transition 1929, 4, :o2, 58217515, 24 - tz.transition 1929, 9, :o1, 9703535, 4 - tz.transition 1930, 4, :o2, 58226251, 24 - tz.transition 1930, 9, :o1, 9704991, 4 - tz.transition 1931, 4, :o2, 58234987, 24 - tz.transition 1931, 9, :o1, 9706447, 4 - tz.transition 1932, 4, :o2, 58243723, 24 - tz.transition 1932, 9, :o1, 9707903, 4 - tz.transition 1933, 4, :o2, 58252627, 24 - tz.transition 1933, 9, :o1, 9709359, 4 - tz.transition 1934, 4, :o2, 58261363, 24 - tz.transition 1934, 9, :o1, 9710843, 4 - tz.transition 1935, 4, :o2, 58270099, 24 - tz.transition 1935, 9, :o1, 9712299, 4 - tz.transition 1936, 4, :o2, 58278835, 24 - tz.transition 1936, 9, :o1, 9713755, 4 - tz.transition 1937, 4, :o2, 58287571, 24 - tz.transition 1937, 9, :o1, 9715211, 4 - tz.transition 1938, 4, :o2, 58296307, 24 - tz.transition 1938, 9, :o1, 9716667, 4 - tz.transition 1939, 4, :o2, 58305211, 24 - tz.transition 1939, 9, :o1, 9718123, 4 - tz.transition 1940, 4, :o2, 58313947, 24 - tz.transition 1940, 9, :o1, 9719607, 4 - tz.transition 1941, 4, :o2, 58322683, 24 - tz.transition 1941, 9, :o1, 9721063, 4 - tz.transition 1942, 2, :o3, 58329595, 24 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 9726915, 4 - tz.transition 1946, 4, :o2, 58366531, 24 - tz.transition 1946, 9, :o1, 9728371, 4 - tz.transition 1947, 4, :o2, 58375267, 24 - tz.transition 1947, 9, :o1, 9729827, 4 - tz.transition 1948, 4, :o2, 58384003, 24 - tz.transition 1948, 9, :o1, 9731283, 4 - tz.transition 1949, 4, :o2, 58392739, 24 - tz.transition 1949, 9, :o1, 9732739, 4 - tz.transition 1950, 4, :o2, 58401643, 24 - tz.transition 1950, 9, :o1, 9734195, 4 - tz.transition 1951, 4, :o2, 58410379, 24 - tz.transition 1951, 9, :o1, 9735679, 4 - tz.transition 1952, 4, :o2, 58419115, 24 - tz.transition 1952, 9, :o1, 9737135, 4 - tz.transition 1953, 4, :o2, 58427851, 24 - tz.transition 1953, 9, :o1, 9738591, 4 - tz.transition 1954, 4, :o2, 58436587, 24 - tz.transition 1954, 9, :o1, 9740047, 4 - tz.transition 1955, 4, :o2, 58445323, 24 - tz.transition 1955, 10, :o1, 9741643, 4 - tz.transition 1956, 4, :o2, 58454227, 24 - tz.transition 1956, 10, :o1, 9743099, 4 - tz.transition 1957, 4, :o2, 58462963, 24 - tz.transition 1957, 10, :o1, 9744555, 4 - tz.transition 1958, 4, :o2, 58471699, 24 - tz.transition 1958, 10, :o1, 9746011, 4 - tz.transition 1959, 4, :o2, 58480435, 24 - tz.transition 1959, 10, :o1, 9747467, 4 - tz.transition 1960, 4, :o2, 58489171, 24 - tz.transition 1960, 10, :o1, 9748951, 4 - tz.transition 1961, 4, :o2, 58498075, 24 - tz.transition 1961, 10, :o1, 9750407, 4 - tz.transition 1962, 4, :o2, 58506811, 24 - tz.transition 1962, 10, :o1, 9751863, 4 - tz.transition 1963, 4, :o2, 58515547, 24 - tz.transition 1963, 10, :o1, 9753319, 4 - tz.transition 1964, 4, :o2, 58524283, 24 - tz.transition 1964, 10, :o1, 9754775, 4 - tz.transition 1965, 4, :o2, 58533019, 24 - tz.transition 1965, 10, :o1, 9756259, 4 - tz.transition 1966, 4, :o2, 58541755, 24 - tz.transition 1966, 10, :o1, 9757715, 4 - tz.transition 1967, 4, :o2, 58550659, 24 - tz.transition 1967, 10, :o1, 9759171, 4 - tz.transition 1968, 4, :o2, 58559395, 24 - tz.transition 1968, 10, :o1, 9760627, 4 - tz.transition 1969, 4, :o2, 58568131, 24 - tz.transition 1969, 10, :o1, 9762083, 4 - tz.transition 1970, 4, :o2, 9961200 - tz.transition 1970, 10, :o1, 25682400 - tz.transition 1971, 4, :o2, 41410800 - tz.transition 1971, 10, :o1, 57736800 - tz.transition 1972, 4, :o2, 73465200 - tz.transition 1972, 10, :o1, 89186400 - tz.transition 1973, 4, :o2, 104914800 - tz.transition 1973, 10, :o1, 120636000 - tz.transition 1974, 1, :o2, 126687600 - tz.transition 1974, 10, :o1, 152085600 - tz.transition 1975, 2, :o2, 162370800 - tz.transition 1975, 10, :o1, 183535200 - tz.transition 1976, 4, :o2, 199263600 - tz.transition 1976, 10, :o1, 215589600 - tz.transition 1977, 4, :o2, 230713200 - tz.transition 1977, 10, :o1, 247039200 - tz.transition 1978, 4, :o2, 262767600 - tz.transition 1978, 10, :o1, 278488800 - tz.transition 1979, 4, :o2, 294217200 - tz.transition 1979, 10, :o1, 309938400 - tz.transition 1980, 4, :o2, 325666800 - tz.transition 1980, 10, :o1, 341388000 - tz.transition 1981, 4, :o2, 357116400 - tz.transition 1981, 10, :o1, 372837600 - tz.transition 1982, 4, :o2, 388566000 - tz.transition 1982, 10, :o1, 404892000 - tz.transition 1983, 4, :o2, 420015600 - tz.transition 1983, 10, :o1, 436341600 - tz.transition 1984, 4, :o2, 452070000 - tz.transition 1984, 10, :o1, 467791200 - tz.transition 1985, 4, :o2, 483519600 - tz.transition 1985, 10, :o1, 499240800 - tz.transition 1986, 4, :o2, 514969200 - tz.transition 1986, 10, :o1, 530690400 - tz.transition 1987, 4, :o2, 544604400 - tz.transition 1987, 10, :o1, 562140000 - tz.transition 1988, 4, :o2, 576054000 - tz.transition 1988, 10, :o1, 594194400 - tz.transition 1989, 4, :o2, 607503600 - tz.transition 1989, 10, :o1, 625644000 - tz.transition 1990, 4, :o2, 638953200 - tz.transition 1990, 10, :o1, 657093600 - tz.transition 1991, 4, :o2, 671007600 - tz.transition 1991, 10, :o1, 688543200 - tz.transition 1992, 4, :o2, 702457200 - tz.transition 1992, 10, :o1, 719992800 - tz.transition 1993, 4, :o2, 733906800 - tz.transition 1993, 10, :o1, 752047200 - tz.transition 1994, 4, :o2, 765356400 - tz.transition 1994, 10, :o1, 783496800 - tz.transition 1995, 4, :o2, 796806000 - tz.transition 1995, 10, :o1, 814946400 - tz.transition 1996, 4, :o2, 828860400 - tz.transition 1996, 10, :o1, 846396000 - tz.transition 1997, 4, :o2, 860310000 - tz.transition 1997, 10, :o1, 877845600 - tz.transition 1998, 4, :o2, 891759600 - tz.transition 1998, 10, :o1, 909295200 - tz.transition 1999, 4, :o2, 923209200 - tz.transition 1999, 10, :o1, 941349600 - tz.transition 2000, 4, :o2, 954658800 - tz.transition 2000, 10, :o1, 972799200 - tz.transition 2001, 4, :o2, 986108400 - tz.transition 2001, 10, :o1, 1004248800 - tz.transition 2002, 4, :o2, 1018162800 - tz.transition 2002, 10, :o1, 1035698400 - tz.transition 2003, 4, :o2, 1049612400 - tz.transition 2003, 10, :o1, 1067148000 - tz.transition 2004, 4, :o2, 1081062000 - tz.transition 2004, 10, :o1, 1099202400 - tz.transition 2005, 4, :o2, 1112511600 - tz.transition 2005, 10, :o1, 1130652000 - tz.transition 2006, 4, :o2, 1143961200 - tz.transition 2006, 10, :o1, 1162101600 - tz.transition 2007, 3, :o2, 1173596400 - tz.transition 2007, 11, :o1, 1194156000 - tz.transition 2008, 3, :o2, 1205046000 - tz.transition 2008, 11, :o1, 1225605600 - tz.transition 2009, 3, :o2, 1236495600 - tz.transition 2009, 11, :o1, 1257055200 - tz.transition 2010, 3, :o2, 1268550000 - tz.transition 2010, 11, :o1, 1289109600 - tz.transition 2011, 3, :o2, 1299999600 - tz.transition 2011, 11, :o1, 1320559200 - tz.transition 2012, 3, :o2, 1331449200 - tz.transition 2012, 11, :o1, 1352008800 - tz.transition 2013, 3, :o2, 1362898800 - tz.transition 2013, 11, :o1, 1383458400 - tz.transition 2014, 3, :o2, 1394348400 - tz.transition 2014, 11, :o1, 1414908000 - tz.transition 2015, 3, :o2, 1425798000 - tz.transition 2015, 11, :o1, 1446357600 - tz.transition 2016, 3, :o2, 1457852400 - tz.transition 2016, 11, :o1, 1478412000 - tz.transition 2017, 3, :o2, 1489302000 - tz.transition 2017, 11, :o1, 1509861600 - tz.transition 2018, 3, :o2, 1520751600 - tz.transition 2018, 11, :o1, 1541311200 - tz.transition 2019, 3, :o2, 1552201200 - tz.transition 2019, 11, :o1, 1572760800 - tz.transition 2020, 3, :o2, 1583650800 - tz.transition 2020, 11, :o1, 1604210400 - tz.transition 2021, 3, :o2, 1615705200 - tz.transition 2021, 11, :o1, 1636264800 - tz.transition 2022, 3, :o2, 1647154800 - tz.transition 2022, 11, :o1, 1667714400 - tz.transition 2023, 3, :o2, 1678604400 - tz.transition 2023, 11, :o1, 1699164000 - tz.transition 2024, 3, :o2, 1710054000 - tz.transition 2024, 11, :o1, 1730613600 - tz.transition 2025, 3, :o2, 1741503600 - tz.transition 2025, 11, :o1, 1762063200 - tz.transition 2026, 3, :o2, 1772953200 - tz.transition 2026, 11, :o1, 1793512800 - tz.transition 2027, 3, :o2, 1805007600 - tz.transition 2027, 11, :o1, 1825567200 - tz.transition 2028, 3, :o2, 1836457200 - tz.transition 2028, 11, :o1, 1857016800 - tz.transition 2029, 3, :o2, 1867906800 - tz.transition 2029, 11, :o1, 1888466400 - tz.transition 2030, 3, :o2, 1899356400 - tz.transition 2030, 11, :o1, 1919916000 - tz.transition 2031, 3, :o2, 1930806000 - tz.transition 2031, 11, :o1, 1951365600 - tz.transition 2032, 3, :o2, 1962860400 - tz.transition 2032, 11, :o1, 1983420000 - tz.transition 2033, 3, :o2, 1994310000 - tz.transition 2033, 11, :o1, 2014869600 - tz.transition 2034, 3, :o2, 2025759600 - tz.transition 2034, 11, :o1, 2046319200 - tz.transition 2035, 3, :o2, 2057209200 - tz.transition 2035, 11, :o1, 2077768800 - tz.transition 2036, 3, :o2, 2088658800 - tz.transition 2036, 11, :o1, 2109218400 - tz.transition 2037, 3, :o2, 2120108400 - tz.transition 2037, 11, :o1, 2140668000 - tz.transition 2038, 3, :o2, 59171923, 24 - tz.transition 2038, 11, :o1, 9862939, 4 - tz.transition 2039, 3, :o2, 59180659, 24 - tz.transition 2039, 11, :o1, 9864395, 4 - tz.transition 2040, 3, :o2, 59189395, 24 - tz.transition 2040, 11, :o1, 9865851, 4 - tz.transition 2041, 3, :o2, 59198131, 24 - tz.transition 2041, 11, :o1, 9867307, 4 - tz.transition 2042, 3, :o2, 59206867, 24 - tz.transition 2042, 11, :o1, 9868763, 4 - tz.transition 2043, 3, :o2, 59215603, 24 - tz.transition 2043, 11, :o1, 9870219, 4 - tz.transition 2044, 3, :o2, 59224507, 24 - tz.transition 2044, 11, :o1, 9871703, 4 - tz.transition 2045, 3, :o2, 59233243, 24 - tz.transition 2045, 11, :o1, 9873159, 4 - tz.transition 2046, 3, :o2, 59241979, 24 - tz.transition 2046, 11, :o1, 9874615, 4 - tz.transition 2047, 3, :o2, 59250715, 24 - tz.transition 2047, 11, :o1, 9876071, 4 - tz.transition 2048, 3, :o2, 59259451, 24 - tz.transition 2048, 11, :o1, 9877527, 4 - tz.transition 2049, 3, :o2, 59268355, 24 - tz.transition 2049, 11, :o1, 9879011, 4 - tz.transition 2050, 3, :o2, 59277091, 24 - tz.transition 2050, 11, :o1, 9880467, 4 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb deleted file mode 100644 index b514e0c0..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Phoenix - include TimezoneDefinition - - timezone 'America/Phoenix' do |tz| - tz.offset :o0, -26898, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -25200, 3600, :MDT - tz.offset :o3, -25200, 3600, :MWT - - tz.transition 1883, 11, :o1, 57819199, 24 - tz.transition 1918, 3, :o2, 19373471, 8 - tz.transition 1918, 10, :o1, 14531363, 6 - tz.transition 1919, 3, :o2, 19376383, 8 - tz.transition 1919, 10, :o1, 14533547, 6 - tz.transition 1942, 2, :o3, 19443199, 8 - tz.transition 1944, 1, :o1, 3500770681, 1440 - tz.transition 1944, 4, :o3, 3500901781, 1440 - tz.transition 1944, 10, :o1, 3501165241, 1440 - tz.transition 1967, 4, :o2, 19516887, 8 - tz.transition 1967, 10, :o1, 14638757, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb deleted file mode 100644 index ebdb6881..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Regina - include TimezoneDefinition - - timezone 'America/Regina' do |tz| - tz.offset :o0, -25116, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -25200, 3600, :MDT - tz.offset :o3, -25200, 3600, :MWT - tz.offset :o4, -25200, 3600, :MPT - tz.offset :o5, -21600, 0, :CST - - tz.transition 1905, 9, :o1, 17403046493, 7200 - tz.transition 1918, 4, :o2, 19373583, 8 - tz.transition 1918, 10, :o1, 14531387, 6 - tz.transition 1930, 5, :o2, 58226419, 24 - tz.transition 1930, 10, :o1, 9705019, 4 - tz.transition 1931, 5, :o2, 58235155, 24 - tz.transition 1931, 10, :o1, 9706475, 4 - tz.transition 1932, 5, :o2, 58243891, 24 - tz.transition 1932, 10, :o1, 9707931, 4 - tz.transition 1933, 5, :o2, 58252795, 24 - tz.transition 1933, 10, :o1, 9709387, 4 - tz.transition 1934, 5, :o2, 58261531, 24 - tz.transition 1934, 10, :o1, 9710871, 4 - tz.transition 1937, 4, :o2, 58287235, 24 - tz.transition 1937, 10, :o1, 9715267, 4 - tz.transition 1938, 4, :o2, 58295971, 24 - tz.transition 1938, 10, :o1, 9716695, 4 - tz.transition 1939, 4, :o2, 58304707, 24 - tz.transition 1939, 10, :o1, 9718179, 4 - tz.transition 1940, 4, :o2, 58313611, 24 - tz.transition 1940, 10, :o1, 9719663, 4 - tz.transition 1941, 4, :o2, 58322347, 24 - tz.transition 1941, 10, :o1, 9721119, 4 - tz.transition 1942, 2, :o3, 19443199, 8 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 14590373, 6 - tz.transition 1946, 4, :o2, 19455399, 8 - tz.transition 1946, 10, :o1, 14592641, 6 - tz.transition 1947, 4, :o2, 19458423, 8 - tz.transition 1947, 9, :o1, 14594741, 6 - tz.transition 1948, 4, :o2, 19461335, 8 - tz.transition 1948, 9, :o1, 14596925, 6 - tz.transition 1949, 4, :o2, 19464247, 8 - tz.transition 1949, 9, :o1, 14599109, 6 - tz.transition 1950, 4, :o2, 19467215, 8 - tz.transition 1950, 9, :o1, 14601293, 6 - tz.transition 1951, 4, :o2, 19470127, 8 - tz.transition 1951, 9, :o1, 14603519, 6 - tz.transition 1952, 4, :o2, 19473039, 8 - tz.transition 1952, 9, :o1, 14605703, 6 - tz.transition 1953, 4, :o2, 19475951, 8 - tz.transition 1953, 9, :o1, 14607887, 6 - tz.transition 1954, 4, :o2, 19478863, 8 - tz.transition 1954, 9, :o1, 14610071, 6 - tz.transition 1955, 4, :o2, 19481775, 8 - tz.transition 1955, 9, :o1, 14612255, 6 - tz.transition 1956, 4, :o2, 19484743, 8 - tz.transition 1956, 9, :o1, 14614481, 6 - tz.transition 1957, 4, :o2, 19487655, 8 - tz.transition 1957, 9, :o1, 14616665, 6 - tz.transition 1959, 4, :o2, 19493479, 8 - tz.transition 1959, 10, :o1, 14621201, 6 - tz.transition 1960, 4, :o5, 19496391, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb deleted file mode 100644 index 0287c9eb..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +++ /dev/null @@ -1,205 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Santiago - include TimezoneDefinition - - timezone 'America/Santiago' do |tz| - tz.offset :o0, -16966, 0, :LMT - tz.offset :o1, -16966, 0, :SMT - tz.offset :o2, -18000, 0, :CLT - tz.offset :o3, -14400, 0, :CLT - tz.offset :o4, -18000, 3600, :CLST - tz.offset :o5, -14400, 3600, :CLST - - tz.transition 1890, 1, :o1, 104171127683, 43200 - tz.transition 1910, 1, :o2, 104486660483, 43200 - tz.transition 1916, 7, :o1, 58105097, 24 - tz.transition 1918, 9, :o3, 104623388483, 43200 - tz.transition 1919, 7, :o1, 7266422, 3 - tz.transition 1927, 9, :o4, 104765386883, 43200 - tz.transition 1928, 4, :o2, 7276013, 3 - tz.transition 1928, 9, :o4, 58211777, 24 - tz.transition 1929, 4, :o2, 7277108, 3 - tz.transition 1929, 9, :o4, 58220537, 24 - tz.transition 1930, 4, :o2, 7278203, 3 - tz.transition 1930, 9, :o4, 58229297, 24 - tz.transition 1931, 4, :o2, 7279298, 3 - tz.transition 1931, 9, :o4, 58238057, 24 - tz.transition 1932, 4, :o2, 7280396, 3 - tz.transition 1932, 9, :o4, 58246841, 24 - tz.transition 1942, 6, :o2, 7291535, 3 - tz.transition 1942, 8, :o4, 58333745, 24 - tz.transition 1946, 9, :o2, 19456517, 8 - tz.transition 1947, 5, :o3, 58375865, 24 - tz.transition 1968, 11, :o5, 7320491, 3 - tz.transition 1969, 3, :o3, 19522485, 8 - tz.transition 1969, 11, :o5, 7321646, 3 - tz.transition 1970, 3, :o3, 7527600 - tz.transition 1970, 10, :o5, 24465600 - tz.transition 1971, 3, :o3, 37767600 - tz.transition 1971, 10, :o5, 55915200 - tz.transition 1972, 3, :o3, 69217200 - tz.transition 1972, 10, :o5, 87969600 - tz.transition 1973, 3, :o3, 100666800 - tz.transition 1973, 9, :o5, 118209600 - tz.transition 1974, 3, :o3, 132116400 - tz.transition 1974, 10, :o5, 150868800 - tz.transition 1975, 3, :o3, 163566000 - tz.transition 1975, 10, :o5, 182318400 - tz.transition 1976, 3, :o3, 195620400 - tz.transition 1976, 10, :o5, 213768000 - tz.transition 1977, 3, :o3, 227070000 - tz.transition 1977, 10, :o5, 245217600 - tz.transition 1978, 3, :o3, 258519600 - tz.transition 1978, 10, :o5, 277272000 - tz.transition 1979, 3, :o3, 289969200 - tz.transition 1979, 10, :o5, 308721600 - tz.transition 1980, 3, :o3, 321418800 - tz.transition 1980, 10, :o5, 340171200 - tz.transition 1981, 3, :o3, 353473200 - tz.transition 1981, 10, :o5, 371620800 - tz.transition 1982, 3, :o3, 384922800 - tz.transition 1982, 10, :o5, 403070400 - tz.transition 1983, 3, :o3, 416372400 - tz.transition 1983, 10, :o5, 434520000 - tz.transition 1984, 3, :o3, 447822000 - tz.transition 1984, 10, :o5, 466574400 - tz.transition 1985, 3, :o3, 479271600 - tz.transition 1985, 10, :o5, 498024000 - tz.transition 1986, 3, :o3, 510721200 - tz.transition 1986, 10, :o5, 529473600 - tz.transition 1987, 4, :o3, 545194800 - tz.transition 1987, 10, :o5, 560923200 - tz.transition 1988, 3, :o3, 574225200 - tz.transition 1988, 10, :o5, 591768000 - tz.transition 1989, 3, :o3, 605674800 - tz.transition 1989, 10, :o5, 624427200 - tz.transition 1990, 3, :o3, 637729200 - tz.transition 1990, 9, :o5, 653457600 - tz.transition 1991, 3, :o3, 668574000 - tz.transition 1991, 10, :o5, 687326400 - tz.transition 1992, 3, :o3, 700628400 - tz.transition 1992, 10, :o5, 718776000 - tz.transition 1993, 3, :o3, 732078000 - tz.transition 1993, 10, :o5, 750225600 - tz.transition 1994, 3, :o3, 763527600 - tz.transition 1994, 10, :o5, 781675200 - tz.transition 1995, 3, :o3, 794977200 - tz.transition 1995, 10, :o5, 813729600 - tz.transition 1996, 3, :o3, 826426800 - tz.transition 1996, 10, :o5, 845179200 - tz.transition 1997, 3, :o3, 859690800 - tz.transition 1997, 10, :o5, 876628800 - tz.transition 1998, 3, :o3, 889930800 - tz.transition 1998, 9, :o5, 906868800 - tz.transition 1999, 4, :o3, 923194800 - tz.transition 1999, 10, :o5, 939528000 - tz.transition 2000, 3, :o3, 952830000 - tz.transition 2000, 10, :o5, 971582400 - tz.transition 2001, 3, :o3, 984279600 - tz.transition 2001, 10, :o5, 1003032000 - tz.transition 2002, 3, :o3, 1015729200 - tz.transition 2002, 10, :o5, 1034481600 - tz.transition 2003, 3, :o3, 1047178800 - tz.transition 2003, 10, :o5, 1065931200 - tz.transition 2004, 3, :o3, 1079233200 - tz.transition 2004, 10, :o5, 1097380800 - tz.transition 2005, 3, :o3, 1110682800 - tz.transition 2005, 10, :o5, 1128830400 - tz.transition 2006, 3, :o3, 1142132400 - tz.transition 2006, 10, :o5, 1160884800 - tz.transition 2007, 3, :o3, 1173582000 - tz.transition 2007, 10, :o5, 1192334400 - tz.transition 2008, 3, :o3, 1206846000 - tz.transition 2008, 10, :o5, 1223784000 - tz.transition 2009, 3, :o3, 1237086000 - tz.transition 2009, 10, :o5, 1255233600 - tz.transition 2010, 3, :o3, 1268535600 - tz.transition 2010, 10, :o5, 1286683200 - tz.transition 2011, 3, :o3, 1299985200 - tz.transition 2011, 10, :o5, 1318132800 - tz.transition 2012, 3, :o3, 1331434800 - tz.transition 2012, 10, :o5, 1350187200 - tz.transition 2013, 3, :o3, 1362884400 - tz.transition 2013, 10, :o5, 1381636800 - tz.transition 2014, 3, :o3, 1394334000 - tz.transition 2014, 10, :o5, 1413086400 - tz.transition 2015, 3, :o3, 1426388400 - tz.transition 2015, 10, :o5, 1444536000 - tz.transition 2016, 3, :o3, 1457838000 - tz.transition 2016, 10, :o5, 1475985600 - tz.transition 2017, 3, :o3, 1489287600 - tz.transition 2017, 10, :o5, 1508040000 - tz.transition 2018, 3, :o3, 1520737200 - tz.transition 2018, 10, :o5, 1539489600 - tz.transition 2019, 3, :o3, 1552186800 - tz.transition 2019, 10, :o5, 1570939200 - tz.transition 2020, 3, :o3, 1584241200 - tz.transition 2020, 10, :o5, 1602388800 - tz.transition 2021, 3, :o3, 1615690800 - tz.transition 2021, 10, :o5, 1633838400 - tz.transition 2022, 3, :o3, 1647140400 - tz.transition 2022, 10, :o5, 1665288000 - tz.transition 2023, 3, :o3, 1678590000 - tz.transition 2023, 10, :o5, 1697342400 - tz.transition 2024, 3, :o3, 1710039600 - tz.transition 2024, 10, :o5, 1728792000 - tz.transition 2025, 3, :o3, 1741489200 - tz.transition 2025, 10, :o5, 1760241600 - tz.transition 2026, 3, :o3, 1773543600 - tz.transition 2026, 10, :o5, 1791691200 - tz.transition 2027, 3, :o3, 1804993200 - tz.transition 2027, 10, :o5, 1823140800 - tz.transition 2028, 3, :o3, 1836442800 - tz.transition 2028, 10, :o5, 1855195200 - tz.transition 2029, 3, :o3, 1867892400 - tz.transition 2029, 10, :o5, 1886644800 - tz.transition 2030, 3, :o3, 1899342000 - tz.transition 2030, 10, :o5, 1918094400 - tz.transition 2031, 3, :o3, 1930791600 - tz.transition 2031, 10, :o5, 1949544000 - tz.transition 2032, 3, :o3, 1962846000 - tz.transition 2032, 10, :o5, 1980993600 - tz.transition 2033, 3, :o3, 1994295600 - tz.transition 2033, 10, :o5, 2012443200 - tz.transition 2034, 3, :o3, 2025745200 - tz.transition 2034, 10, :o5, 2044497600 - tz.transition 2035, 3, :o3, 2057194800 - tz.transition 2035, 10, :o5, 2075947200 - tz.transition 2036, 3, :o3, 2088644400 - tz.transition 2036, 10, :o5, 2107396800 - tz.transition 2037, 3, :o3, 2120698800 - tz.transition 2037, 10, :o5, 2138846400 - tz.transition 2038, 3, :o3, 19723973, 8 - tz.transition 2038, 10, :o5, 7397120, 3 - tz.transition 2039, 3, :o3, 19726885, 8 - tz.transition 2039, 10, :o5, 7398212, 3 - tz.transition 2040, 3, :o3, 19729797, 8 - tz.transition 2040, 10, :o5, 7399325, 3 - tz.transition 2041, 3, :o3, 19732709, 8 - tz.transition 2041, 10, :o5, 7400417, 3 - tz.transition 2042, 3, :o3, 19735621, 8 - tz.transition 2042, 10, :o5, 7401509, 3 - tz.transition 2043, 3, :o3, 19738589, 8 - tz.transition 2043, 10, :o5, 7402601, 3 - tz.transition 2044, 3, :o3, 19741501, 8 - tz.transition 2044, 10, :o5, 7403693, 3 - tz.transition 2045, 3, :o3, 19744413, 8 - tz.transition 2045, 10, :o5, 7404806, 3 - tz.transition 2046, 3, :o3, 19747325, 8 - tz.transition 2046, 10, :o5, 7405898, 3 - tz.transition 2047, 3, :o3, 19750237, 8 - tz.transition 2047, 10, :o5, 7406990, 3 - tz.transition 2048, 3, :o3, 19753205, 8 - tz.transition 2048, 10, :o5, 7408082, 3 - tz.transition 2049, 3, :o3, 19756117, 8 - tz.transition 2049, 10, :o5, 7409174, 3 - tz.transition 2050, 3, :o3, 19759029, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb deleted file mode 100644 index 0524f81c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +++ /dev/null @@ -1,171 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Sao_Paulo - include TimezoneDefinition - - timezone 'America/Sao_Paulo' do |tz| - tz.offset :o0, -11188, 0, :LMT - tz.offset :o1, -10800, 0, :BRT - tz.offset :o2, -10800, 3600, :BRST - - tz.transition 1914, 1, :o1, 52274886397, 21600 - tz.transition 1931, 10, :o2, 29119417, 12 - tz.transition 1932, 4, :o1, 29121583, 12 - tz.transition 1932, 10, :o2, 19415869, 8 - tz.transition 1933, 4, :o1, 29125963, 12 - tz.transition 1949, 12, :o2, 19466013, 8 - tz.transition 1950, 4, :o1, 19467101, 8 - tz.transition 1950, 12, :o2, 19468933, 8 - tz.transition 1951, 4, :o1, 29204851, 12 - tz.transition 1951, 12, :o2, 19471853, 8 - tz.transition 1952, 4, :o1, 29209243, 12 - tz.transition 1952, 12, :o2, 19474781, 8 - tz.transition 1953, 3, :o1, 29213251, 12 - tz.transition 1963, 10, :o2, 19506605, 8 - tz.transition 1964, 3, :o1, 29261467, 12 - tz.transition 1965, 1, :o2, 19510333, 8 - tz.transition 1965, 3, :o1, 29266207, 12 - tz.transition 1965, 12, :o2, 19512765, 8 - tz.transition 1966, 3, :o1, 29270227, 12 - tz.transition 1966, 11, :o2, 19515445, 8 - tz.transition 1967, 3, :o1, 29274607, 12 - tz.transition 1967, 11, :o2, 19518365, 8 - tz.transition 1968, 3, :o1, 29278999, 12 - tz.transition 1985, 11, :o2, 499748400 - tz.transition 1986, 3, :o1, 511236000 - tz.transition 1986, 10, :o2, 530593200 - tz.transition 1987, 2, :o1, 540266400 - tz.transition 1987, 10, :o2, 562129200 - tz.transition 1988, 2, :o1, 571197600 - tz.transition 1988, 10, :o2, 592974000 - tz.transition 1989, 1, :o1, 602042400 - tz.transition 1989, 10, :o2, 624423600 - tz.transition 1990, 2, :o1, 634701600 - tz.transition 1990, 10, :o2, 656478000 - tz.transition 1991, 2, :o1, 666756000 - tz.transition 1991, 10, :o2, 687927600 - tz.transition 1992, 2, :o1, 697600800 - tz.transition 1992, 10, :o2, 719982000 - tz.transition 1993, 1, :o1, 728445600 - tz.transition 1993, 10, :o2, 750826800 - tz.transition 1994, 2, :o1, 761709600 - tz.transition 1994, 10, :o2, 782276400 - tz.transition 1995, 2, :o1, 793159200 - tz.transition 1995, 10, :o2, 813726000 - tz.transition 1996, 2, :o1, 824004000 - tz.transition 1996, 10, :o2, 844570800 - tz.transition 1997, 2, :o1, 856058400 - tz.transition 1997, 10, :o2, 876106800 - tz.transition 1998, 3, :o1, 888717600 - tz.transition 1998, 10, :o2, 908074800 - tz.transition 1999, 2, :o1, 919562400 - tz.transition 1999, 10, :o2, 938919600 - tz.transition 2000, 2, :o1, 951616800 - tz.transition 2000, 10, :o2, 970974000 - tz.transition 2001, 2, :o1, 982461600 - tz.transition 2001, 10, :o2, 1003028400 - tz.transition 2002, 2, :o1, 1013911200 - tz.transition 2002, 11, :o2, 1036292400 - tz.transition 2003, 2, :o1, 1045360800 - tz.transition 2003, 10, :o2, 1066532400 - tz.transition 2004, 2, :o1, 1076810400 - tz.transition 2004, 11, :o2, 1099364400 - tz.transition 2005, 2, :o1, 1108864800 - tz.transition 2005, 10, :o2, 1129431600 - tz.transition 2006, 2, :o1, 1140314400 - tz.transition 2006, 11, :o2, 1162695600 - tz.transition 2007, 2, :o1, 1172368800 - tz.transition 2007, 10, :o2, 1192330800 - tz.transition 2008, 2, :o1, 1203213600 - tz.transition 2008, 10, :o2, 1224385200 - tz.transition 2009, 2, :o1, 1234663200 - tz.transition 2009, 10, :o2, 1255834800 - tz.transition 2010, 2, :o1, 1266717600 - tz.transition 2010, 10, :o2, 1287284400 - tz.transition 2011, 2, :o1, 1298167200 - tz.transition 2011, 10, :o2, 1318734000 - tz.transition 2012, 2, :o1, 1330221600 - tz.transition 2012, 10, :o2, 1350788400 - tz.transition 2013, 2, :o1, 1361066400 - tz.transition 2013, 10, :o2, 1382238000 - tz.transition 2014, 2, :o1, 1392516000 - tz.transition 2014, 10, :o2, 1413687600 - tz.transition 2015, 2, :o1, 1424570400 - tz.transition 2015, 10, :o2, 1445137200 - tz.transition 2016, 2, :o1, 1456020000 - tz.transition 2016, 10, :o2, 1476586800 - tz.transition 2017, 2, :o1, 1487469600 - tz.transition 2017, 10, :o2, 1508036400 - tz.transition 2018, 2, :o1, 1518919200 - tz.transition 2018, 10, :o2, 1540090800 - tz.transition 2019, 2, :o1, 1550368800 - tz.transition 2019, 10, :o2, 1571540400 - tz.transition 2020, 2, :o1, 1581818400 - tz.transition 2020, 10, :o2, 1602990000 - tz.transition 2021, 2, :o1, 1613872800 - tz.transition 2021, 10, :o2, 1634439600 - tz.transition 2022, 2, :o1, 1645322400 - tz.transition 2022, 10, :o2, 1665889200 - tz.transition 2023, 2, :o1, 1677376800 - tz.transition 2023, 10, :o2, 1697338800 - tz.transition 2024, 2, :o1, 1708221600 - tz.transition 2024, 10, :o2, 1729393200 - tz.transition 2025, 2, :o1, 1739671200 - tz.transition 2025, 10, :o2, 1760842800 - tz.transition 2026, 2, :o1, 1771725600 - tz.transition 2026, 10, :o2, 1792292400 - tz.transition 2027, 2, :o1, 1803175200 - tz.transition 2027, 10, :o2, 1823742000 - tz.transition 2028, 2, :o1, 1834624800 - tz.transition 2028, 10, :o2, 1855191600 - tz.transition 2029, 2, :o1, 1866074400 - tz.transition 2029, 10, :o2, 1887246000 - tz.transition 2030, 2, :o1, 1897524000 - tz.transition 2030, 10, :o2, 1918695600 - tz.transition 2031, 2, :o1, 1928973600 - tz.transition 2031, 10, :o2, 1950145200 - tz.transition 2032, 2, :o1, 1960423200 - tz.transition 2032, 10, :o2, 1981594800 - tz.transition 2033, 2, :o1, 1992477600 - tz.transition 2033, 10, :o2, 2013044400 - tz.transition 2034, 2, :o1, 2024532000 - tz.transition 2034, 10, :o2, 2044494000 - tz.transition 2035, 2, :o1, 2055376800 - tz.transition 2035, 10, :o2, 2076548400 - tz.transition 2036, 2, :o1, 2086826400 - tz.transition 2036, 10, :o2, 2107998000 - tz.transition 2037, 2, :o1, 2118880800 - tz.transition 2037, 10, :o2, 2139447600 - tz.transition 2038, 2, :o1, 29585707, 12 - tz.transition 2038, 10, :o2, 19725709, 8 - tz.transition 2039, 2, :o1, 29590075, 12 - tz.transition 2039, 10, :o2, 19728621, 8 - tz.transition 2040, 2, :o1, 29594443, 12 - tz.transition 2040, 10, :o2, 19731589, 8 - tz.transition 2041, 2, :o1, 29598811, 12 - tz.transition 2041, 10, :o2, 19734501, 8 - tz.transition 2042, 2, :o1, 29603179, 12 - tz.transition 2042, 10, :o2, 19737413, 8 - tz.transition 2043, 2, :o1, 29607547, 12 - tz.transition 2043, 10, :o2, 19740325, 8 - tz.transition 2044, 2, :o1, 29611999, 12 - tz.transition 2044, 10, :o2, 19743237, 8 - tz.transition 2045, 2, :o1, 29616367, 12 - tz.transition 2045, 10, :o2, 19746149, 8 - tz.transition 2046, 2, :o1, 29620735, 12 - tz.transition 2046, 10, :o2, 19749117, 8 - tz.transition 2047, 2, :o1, 29625103, 12 - tz.transition 2047, 10, :o2, 19752029, 8 - tz.transition 2048, 2, :o1, 29629471, 12 - tz.transition 2048, 10, :o2, 19754941, 8 - tz.transition 2049, 2, :o1, 29633923, 12 - tz.transition 2049, 10, :o2, 19757853, 8 - tz.transition 2050, 2, :o1, 29638291, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb deleted file mode 100644 index e4a3599d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +++ /dev/null @@ -1,288 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module St_Johns - include TimezoneDefinition - - timezone 'America/St_Johns' do |tz| - tz.offset :o0, -12652, 0, :LMT - tz.offset :o1, -12652, 0, :NST - tz.offset :o2, -12652, 3600, :NDT - tz.offset :o3, -12600, 0, :NST - tz.offset :o4, -12600, 3600, :NDT - tz.offset :o5, -12600, 3600, :NWT - tz.offset :o6, -12600, 3600, :NPT - tz.offset :o7, -12600, 7200, :NDDT - - tz.transition 1884, 1, :o1, 52038215563, 21600 - tz.transition 1917, 4, :o2, 52300657363, 21600 - tz.transition 1917, 9, :o1, 52304155663, 21600 - tz.transition 1918, 4, :o2, 52308670963, 21600 - tz.transition 1918, 10, :o1, 52312990063, 21600 - tz.transition 1919, 5, :o2, 52317027463, 21600 - tz.transition 1919, 8, :o1, 52319164963, 21600 - tz.transition 1920, 5, :o2, 52324868263, 21600 - tz.transition 1920, 11, :o1, 52328798563, 21600 - tz.transition 1921, 5, :o2, 52332730663, 21600 - tz.transition 1921, 10, :o1, 52336660963, 21600 - tz.transition 1922, 5, :o2, 52340744263, 21600 - tz.transition 1922, 10, :o1, 52344523363, 21600 - tz.transition 1923, 5, :o2, 52348606663, 21600 - tz.transition 1923, 10, :o1, 52352385763, 21600 - tz.transition 1924, 5, :o2, 52356469063, 21600 - tz.transition 1924, 10, :o1, 52360248163, 21600 - tz.transition 1925, 5, :o2, 52364331463, 21600 - tz.transition 1925, 10, :o1, 52368110563, 21600 - tz.transition 1926, 5, :o2, 52372193863, 21600 - tz.transition 1926, 11, :o1, 52376124163, 21600 - tz.transition 1927, 5, :o2, 52380056263, 21600 - tz.transition 1927, 10, :o1, 52383986563, 21600 - tz.transition 1928, 5, :o2, 52388069863, 21600 - tz.transition 1928, 10, :o1, 52391848963, 21600 - tz.transition 1929, 5, :o2, 52395932263, 21600 - tz.transition 1929, 10, :o1, 52399711363, 21600 - tz.transition 1930, 5, :o2, 52403794663, 21600 - tz.transition 1930, 10, :o1, 52407573763, 21600 - tz.transition 1931, 5, :o2, 52411657063, 21600 - tz.transition 1931, 10, :o1, 52415436163, 21600 - tz.transition 1932, 5, :o2, 52419519463, 21600 - tz.transition 1932, 10, :o1, 52423449763, 21600 - tz.transition 1933, 5, :o2, 52427533063, 21600 - tz.transition 1933, 10, :o1, 52431312163, 21600 - tz.transition 1934, 5, :o2, 52435395463, 21600 - tz.transition 1934, 10, :o1, 52439174563, 21600 - tz.transition 1935, 3, :o3, 52442459563, 21600 - tz.transition 1935, 5, :o4, 116540573, 48 - tz.transition 1935, 10, :o3, 38849657, 16 - tz.transition 1936, 5, :o4, 116558383, 48 - tz.transition 1936, 10, :o3, 116565437, 48 - tz.transition 1937, 5, :o4, 116575855, 48 - tz.transition 1937, 10, :o3, 116582909, 48 - tz.transition 1938, 5, :o4, 116593327, 48 - tz.transition 1938, 10, :o3, 116600381, 48 - tz.transition 1939, 5, :o4, 116611135, 48 - tz.transition 1939, 10, :o3, 116617853, 48 - tz.transition 1940, 5, :o4, 116628607, 48 - tz.transition 1940, 10, :o3, 116635661, 48 - tz.transition 1941, 5, :o4, 116646079, 48 - tz.transition 1941, 10, :o3, 116653133, 48 - tz.transition 1942, 5, :o5, 116663551, 48 - tz.transition 1945, 8, :o6, 58360379, 24 - tz.transition 1945, 9, :o3, 38907659, 16 - tz.transition 1946, 5, :o4, 116733731, 48 - tz.transition 1946, 10, :o3, 38913595, 16 - tz.transition 1947, 5, :o4, 116751203, 48 - tz.transition 1947, 10, :o3, 38919419, 16 - tz.transition 1948, 5, :o4, 116768675, 48 - tz.transition 1948, 10, :o3, 38925243, 16 - tz.transition 1949, 5, :o4, 116786147, 48 - tz.transition 1949, 10, :o3, 38931067, 16 - tz.transition 1950, 5, :o4, 116803955, 48 - tz.transition 1950, 10, :o3, 38937003, 16 - tz.transition 1951, 4, :o4, 116820755, 48 - tz.transition 1951, 9, :o3, 38942715, 16 - tz.transition 1952, 4, :o4, 116838227, 48 - tz.transition 1952, 9, :o3, 38948539, 16 - tz.transition 1953, 4, :o4, 116855699, 48 - tz.transition 1953, 9, :o3, 38954363, 16 - tz.transition 1954, 4, :o4, 116873171, 48 - tz.transition 1954, 9, :o3, 38960187, 16 - tz.transition 1955, 4, :o4, 116890643, 48 - tz.transition 1955, 9, :o3, 38966011, 16 - tz.transition 1956, 4, :o4, 116908451, 48 - tz.transition 1956, 9, :o3, 38971947, 16 - tz.transition 1957, 4, :o4, 116925923, 48 - tz.transition 1957, 9, :o3, 38977771, 16 - tz.transition 1958, 4, :o4, 116943395, 48 - tz.transition 1958, 9, :o3, 38983595, 16 - tz.transition 1959, 4, :o4, 116960867, 48 - tz.transition 1959, 9, :o3, 38989419, 16 - tz.transition 1960, 4, :o4, 116978339, 48 - tz.transition 1960, 10, :o3, 38995803, 16 - tz.transition 1961, 4, :o4, 116996147, 48 - tz.transition 1961, 10, :o3, 39001627, 16 - tz.transition 1962, 4, :o4, 117013619, 48 - tz.transition 1962, 10, :o3, 39007451, 16 - tz.transition 1963, 4, :o4, 117031091, 48 - tz.transition 1963, 10, :o3, 39013275, 16 - tz.transition 1964, 4, :o4, 117048563, 48 - tz.transition 1964, 10, :o3, 39019099, 16 - tz.transition 1965, 4, :o4, 117066035, 48 - tz.transition 1965, 10, :o3, 39025035, 16 - tz.transition 1966, 4, :o4, 117083507, 48 - tz.transition 1966, 10, :o3, 39030859, 16 - tz.transition 1967, 4, :o4, 117101315, 48 - tz.transition 1967, 10, :o3, 39036683, 16 - tz.transition 1968, 4, :o4, 117118787, 48 - tz.transition 1968, 10, :o3, 39042507, 16 - tz.transition 1969, 4, :o4, 117136259, 48 - tz.transition 1969, 10, :o3, 39048331, 16 - tz.transition 1970, 4, :o4, 9955800 - tz.transition 1970, 10, :o3, 25677000 - tz.transition 1971, 4, :o4, 41405400 - tz.transition 1971, 10, :o3, 57731400 - tz.transition 1972, 4, :o4, 73459800 - tz.transition 1972, 10, :o3, 89181000 - tz.transition 1973, 4, :o4, 104909400 - tz.transition 1973, 10, :o3, 120630600 - tz.transition 1974, 4, :o4, 136359000 - tz.transition 1974, 10, :o3, 152080200 - tz.transition 1975, 4, :o4, 167808600 - tz.transition 1975, 10, :o3, 183529800 - tz.transition 1976, 4, :o4, 199258200 - tz.transition 1976, 10, :o3, 215584200 - tz.transition 1977, 4, :o4, 230707800 - tz.transition 1977, 10, :o3, 247033800 - tz.transition 1978, 4, :o4, 262762200 - tz.transition 1978, 10, :o3, 278483400 - tz.transition 1979, 4, :o4, 294211800 - tz.transition 1979, 10, :o3, 309933000 - tz.transition 1980, 4, :o4, 325661400 - tz.transition 1980, 10, :o3, 341382600 - tz.transition 1981, 4, :o4, 357111000 - tz.transition 1981, 10, :o3, 372832200 - tz.transition 1982, 4, :o4, 388560600 - tz.transition 1982, 10, :o3, 404886600 - tz.transition 1983, 4, :o4, 420010200 - tz.transition 1983, 10, :o3, 436336200 - tz.transition 1984, 4, :o4, 452064600 - tz.transition 1984, 10, :o3, 467785800 - tz.transition 1985, 4, :o4, 483514200 - tz.transition 1985, 10, :o3, 499235400 - tz.transition 1986, 4, :o4, 514963800 - tz.transition 1986, 10, :o3, 530685000 - tz.transition 1987, 4, :o4, 544591860 - tz.transition 1987, 10, :o3, 562127460 - tz.transition 1988, 4, :o7, 576041460 - tz.transition 1988, 10, :o3, 594178260 - tz.transition 1989, 4, :o4, 607491060 - tz.transition 1989, 10, :o3, 625631460 - tz.transition 1990, 4, :o4, 638940660 - tz.transition 1990, 10, :o3, 657081060 - tz.transition 1991, 4, :o4, 670995060 - tz.transition 1991, 10, :o3, 688530660 - tz.transition 1992, 4, :o4, 702444660 - tz.transition 1992, 10, :o3, 719980260 - tz.transition 1993, 4, :o4, 733894260 - tz.transition 1993, 10, :o3, 752034660 - tz.transition 1994, 4, :o4, 765343860 - tz.transition 1994, 10, :o3, 783484260 - tz.transition 1995, 4, :o4, 796793460 - tz.transition 1995, 10, :o3, 814933860 - tz.transition 1996, 4, :o4, 828847860 - tz.transition 1996, 10, :o3, 846383460 - tz.transition 1997, 4, :o4, 860297460 - tz.transition 1997, 10, :o3, 877833060 - tz.transition 1998, 4, :o4, 891747060 - tz.transition 1998, 10, :o3, 909282660 - tz.transition 1999, 4, :o4, 923196660 - tz.transition 1999, 10, :o3, 941337060 - tz.transition 2000, 4, :o4, 954646260 - tz.transition 2000, 10, :o3, 972786660 - tz.transition 2001, 4, :o4, 986095860 - tz.transition 2001, 10, :o3, 1004236260 - tz.transition 2002, 4, :o4, 1018150260 - tz.transition 2002, 10, :o3, 1035685860 - tz.transition 2003, 4, :o4, 1049599860 - tz.transition 2003, 10, :o3, 1067135460 - tz.transition 2004, 4, :o4, 1081049460 - tz.transition 2004, 10, :o3, 1099189860 - tz.transition 2005, 4, :o4, 1112499060 - tz.transition 2005, 10, :o3, 1130639460 - tz.transition 2006, 4, :o4, 1143948660 - tz.transition 2006, 10, :o3, 1162089060 - tz.transition 2007, 3, :o4, 1173583860 - tz.transition 2007, 11, :o3, 1194143460 - tz.transition 2008, 3, :o4, 1205033460 - tz.transition 2008, 11, :o3, 1225593060 - tz.transition 2009, 3, :o4, 1236483060 - tz.transition 2009, 11, :o3, 1257042660 - tz.transition 2010, 3, :o4, 1268537460 - tz.transition 2010, 11, :o3, 1289097060 - tz.transition 2011, 3, :o4, 1299987060 - tz.transition 2011, 11, :o3, 1320546660 - tz.transition 2012, 3, :o4, 1331436660 - tz.transition 2012, 11, :o3, 1351996260 - tz.transition 2013, 3, :o4, 1362886260 - tz.transition 2013, 11, :o3, 1383445860 - tz.transition 2014, 3, :o4, 1394335860 - tz.transition 2014, 11, :o3, 1414895460 - tz.transition 2015, 3, :o4, 1425785460 - tz.transition 2015, 11, :o3, 1446345060 - tz.transition 2016, 3, :o4, 1457839860 - tz.transition 2016, 11, :o3, 1478399460 - tz.transition 2017, 3, :o4, 1489289460 - tz.transition 2017, 11, :o3, 1509849060 - tz.transition 2018, 3, :o4, 1520739060 - tz.transition 2018, 11, :o3, 1541298660 - tz.transition 2019, 3, :o4, 1552188660 - tz.transition 2019, 11, :o3, 1572748260 - tz.transition 2020, 3, :o4, 1583638260 - tz.transition 2020, 11, :o3, 1604197860 - tz.transition 2021, 3, :o4, 1615692660 - tz.transition 2021, 11, :o3, 1636252260 - tz.transition 2022, 3, :o4, 1647142260 - tz.transition 2022, 11, :o3, 1667701860 - tz.transition 2023, 3, :o4, 1678591860 - tz.transition 2023, 11, :o3, 1699151460 - tz.transition 2024, 3, :o4, 1710041460 - tz.transition 2024, 11, :o3, 1730601060 - tz.transition 2025, 3, :o4, 1741491060 - tz.transition 2025, 11, :o3, 1762050660 - tz.transition 2026, 3, :o4, 1772940660 - tz.transition 2026, 11, :o3, 1793500260 - tz.transition 2027, 3, :o4, 1804995060 - tz.transition 2027, 11, :o3, 1825554660 - tz.transition 2028, 3, :o4, 1836444660 - tz.transition 2028, 11, :o3, 1857004260 - tz.transition 2029, 3, :o4, 1867894260 - tz.transition 2029, 11, :o3, 1888453860 - tz.transition 2030, 3, :o4, 1899343860 - tz.transition 2030, 11, :o3, 1919903460 - tz.transition 2031, 3, :o4, 1930793460 - tz.transition 2031, 11, :o3, 1951353060 - tz.transition 2032, 3, :o4, 1962847860 - tz.transition 2032, 11, :o3, 1983407460 - tz.transition 2033, 3, :o4, 1994297460 - tz.transition 2033, 11, :o3, 2014857060 - tz.transition 2034, 3, :o4, 2025747060 - tz.transition 2034, 11, :o3, 2046306660 - tz.transition 2035, 3, :o4, 2057196660 - tz.transition 2035, 11, :o3, 2077756260 - tz.transition 2036, 3, :o4, 2088646260 - tz.transition 2036, 11, :o3, 2109205860 - tz.transition 2037, 3, :o4, 2120095860 - tz.transition 2037, 11, :o3, 2140655460 - tz.transition 2038, 3, :o4, 3550315171, 1440 - tz.transition 2038, 11, :o3, 3550657831, 1440 - tz.transition 2039, 3, :o4, 3550839331, 1440 - tz.transition 2039, 11, :o3, 3551181991, 1440 - tz.transition 2040, 3, :o4, 3551363491, 1440 - tz.transition 2040, 11, :o3, 3551706151, 1440 - tz.transition 2041, 3, :o4, 3551887651, 1440 - tz.transition 2041, 11, :o3, 3552230311, 1440 - tz.transition 2042, 3, :o4, 3552411811, 1440 - tz.transition 2042, 11, :o3, 3552754471, 1440 - tz.transition 2043, 3, :o4, 3552935971, 1440 - tz.transition 2043, 11, :o3, 3553278631, 1440 - tz.transition 2044, 3, :o4, 3553470211, 1440 - tz.transition 2044, 11, :o3, 3553812871, 1440 - tz.transition 2045, 3, :o4, 3553994371, 1440 - tz.transition 2045, 11, :o3, 3554337031, 1440 - tz.transition 2046, 3, :o4, 3554518531, 1440 - tz.transition 2046, 11, :o3, 3554861191, 1440 - tz.transition 2047, 3, :o4, 3555042691, 1440 - tz.transition 2047, 11, :o3, 3555385351, 1440 - tz.transition 2048, 3, :o4, 3555566851, 1440 - tz.transition 2048, 11, :o3, 3555909511, 1440 - tz.transition 2049, 3, :o4, 3556101091, 1440 - tz.transition 2049, 11, :o3, 3556443751, 1440 - tz.transition 2050, 3, :o4, 3556625251, 1440 - tz.transition 2050, 11, :o3, 3556967911, 1440 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb deleted file mode 100644 index 423059da..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +++ /dev/null @@ -1,196 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Tijuana - include TimezoneDefinition - - timezone 'America/Tijuana' do |tz| - tz.offset :o0, -28084, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -28800, 0, :PST - tz.offset :o3, -28800, 3600, :PDT - tz.offset :o4, -28800, 3600, :PWT - tz.offset :o5, -28800, 3600, :PPT - - tz.transition 1922, 1, :o1, 14538335, 6 - tz.transition 1924, 1, :o2, 58170859, 24 - tz.transition 1927, 6, :o1, 58201027, 24 - tz.transition 1930, 11, :o2, 58231099, 24 - tz.transition 1931, 4, :o3, 14558597, 6 - tz.transition 1931, 9, :o2, 58238755, 24 - tz.transition 1942, 4, :o4, 14582843, 6 - tz.transition 1945, 8, :o5, 58360379, 24 - tz.transition 1945, 11, :o2, 58362523, 24 - tz.transition 1948, 4, :o3, 14595881, 6 - tz.transition 1949, 1, :o2, 58390339, 24 - tz.transition 1954, 4, :o3, 29218295, 12 - tz.transition 1954, 9, :o2, 19480095, 8 - tz.transition 1955, 4, :o3, 29222663, 12 - tz.transition 1955, 9, :o2, 19483007, 8 - tz.transition 1956, 4, :o3, 29227115, 12 - tz.transition 1956, 9, :o2, 19485975, 8 - tz.transition 1957, 4, :o3, 29231483, 12 - tz.transition 1957, 9, :o2, 19488887, 8 - tz.transition 1958, 4, :o3, 29235851, 12 - tz.transition 1958, 9, :o2, 19491799, 8 - tz.transition 1959, 4, :o3, 29240219, 12 - tz.transition 1959, 9, :o2, 19494711, 8 - tz.transition 1960, 4, :o3, 29244587, 12 - tz.transition 1960, 9, :o2, 19497623, 8 - tz.transition 1976, 4, :o3, 199274400 - tz.transition 1976, 10, :o2, 215600400 - tz.transition 1977, 4, :o3, 230724000 - tz.transition 1977, 10, :o2, 247050000 - tz.transition 1978, 4, :o3, 262778400 - tz.transition 1978, 10, :o2, 278499600 - tz.transition 1979, 4, :o3, 294228000 - tz.transition 1979, 10, :o2, 309949200 - tz.transition 1980, 4, :o3, 325677600 - tz.transition 1980, 10, :o2, 341398800 - tz.transition 1981, 4, :o3, 357127200 - tz.transition 1981, 10, :o2, 372848400 - tz.transition 1982, 4, :o3, 388576800 - tz.transition 1982, 10, :o2, 404902800 - tz.transition 1983, 4, :o3, 420026400 - tz.transition 1983, 10, :o2, 436352400 - tz.transition 1984, 4, :o3, 452080800 - tz.transition 1984, 10, :o2, 467802000 - tz.transition 1985, 4, :o3, 483530400 - tz.transition 1985, 10, :o2, 499251600 - tz.transition 1986, 4, :o3, 514980000 - tz.transition 1986, 10, :o2, 530701200 - tz.transition 1987, 4, :o3, 544615200 - tz.transition 1987, 10, :o2, 562150800 - tz.transition 1988, 4, :o3, 576064800 - tz.transition 1988, 10, :o2, 594205200 - tz.transition 1989, 4, :o3, 607514400 - tz.transition 1989, 10, :o2, 625654800 - tz.transition 1990, 4, :o3, 638964000 - tz.transition 1990, 10, :o2, 657104400 - tz.transition 1991, 4, :o3, 671018400 - tz.transition 1991, 10, :o2, 688554000 - tz.transition 1992, 4, :o3, 702468000 - tz.transition 1992, 10, :o2, 720003600 - tz.transition 1993, 4, :o3, 733917600 - tz.transition 1993, 10, :o2, 752058000 - tz.transition 1994, 4, :o3, 765367200 - tz.transition 1994, 10, :o2, 783507600 - tz.transition 1995, 4, :o3, 796816800 - tz.transition 1995, 10, :o2, 814957200 - tz.transition 1996, 4, :o3, 828871200 - tz.transition 1996, 10, :o2, 846406800 - tz.transition 1997, 4, :o3, 860320800 - tz.transition 1997, 10, :o2, 877856400 - tz.transition 1998, 4, :o3, 891770400 - tz.transition 1998, 10, :o2, 909306000 - tz.transition 1999, 4, :o3, 923220000 - tz.transition 1999, 10, :o2, 941360400 - tz.transition 2000, 4, :o3, 954669600 - tz.transition 2000, 10, :o2, 972810000 - tz.transition 2001, 4, :o3, 986119200 - tz.transition 2001, 10, :o2, 1004259600 - tz.transition 2002, 4, :o3, 1018173600 - tz.transition 2002, 10, :o2, 1035709200 - tz.transition 2003, 4, :o3, 1049623200 - tz.transition 2003, 10, :o2, 1067158800 - tz.transition 2004, 4, :o3, 1081072800 - tz.transition 2004, 10, :o2, 1099213200 - tz.transition 2005, 4, :o3, 1112522400 - tz.transition 2005, 10, :o2, 1130662800 - tz.transition 2006, 4, :o3, 1143972000 - tz.transition 2006, 10, :o2, 1162112400 - tz.transition 2007, 4, :o3, 1175421600 - tz.transition 2007, 10, :o2, 1193562000 - tz.transition 2008, 4, :o3, 1207476000 - tz.transition 2008, 10, :o2, 1225011600 - tz.transition 2009, 4, :o3, 1238925600 - tz.transition 2009, 10, :o2, 1256461200 - tz.transition 2010, 4, :o3, 1270375200 - tz.transition 2010, 10, :o2, 1288515600 - tz.transition 2011, 4, :o3, 1301824800 - tz.transition 2011, 10, :o2, 1319965200 - tz.transition 2012, 4, :o3, 1333274400 - tz.transition 2012, 10, :o2, 1351414800 - tz.transition 2013, 4, :o3, 1365328800 - tz.transition 2013, 10, :o2, 1382864400 - tz.transition 2014, 4, :o3, 1396778400 - tz.transition 2014, 10, :o2, 1414314000 - tz.transition 2015, 4, :o3, 1428228000 - tz.transition 2015, 10, :o2, 1445763600 - tz.transition 2016, 4, :o3, 1459677600 - tz.transition 2016, 10, :o2, 1477818000 - tz.transition 2017, 4, :o3, 1491127200 - tz.transition 2017, 10, :o2, 1509267600 - tz.transition 2018, 4, :o3, 1522576800 - tz.transition 2018, 10, :o2, 1540717200 - tz.transition 2019, 4, :o3, 1554631200 - tz.transition 2019, 10, :o2, 1572166800 - tz.transition 2020, 4, :o3, 1586080800 - tz.transition 2020, 10, :o2, 1603616400 - tz.transition 2021, 4, :o3, 1617530400 - tz.transition 2021, 10, :o2, 1635670800 - tz.transition 2022, 4, :o3, 1648980000 - tz.transition 2022, 10, :o2, 1667120400 - tz.transition 2023, 4, :o3, 1680429600 - tz.transition 2023, 10, :o2, 1698570000 - tz.transition 2024, 4, :o3, 1712484000 - tz.transition 2024, 10, :o2, 1730019600 - tz.transition 2025, 4, :o3, 1743933600 - tz.transition 2025, 10, :o2, 1761469200 - tz.transition 2026, 4, :o3, 1775383200 - tz.transition 2026, 10, :o2, 1792918800 - tz.transition 2027, 4, :o3, 1806832800 - tz.transition 2027, 10, :o2, 1824973200 - tz.transition 2028, 4, :o3, 1838282400 - tz.transition 2028, 10, :o2, 1856422800 - tz.transition 2029, 4, :o3, 1869732000 - tz.transition 2029, 10, :o2, 1887872400 - tz.transition 2030, 4, :o3, 1901786400 - tz.transition 2030, 10, :o2, 1919322000 - tz.transition 2031, 4, :o3, 1933236000 - tz.transition 2031, 10, :o2, 1950771600 - tz.transition 2032, 4, :o3, 1964685600 - tz.transition 2032, 10, :o2, 1982826000 - tz.transition 2033, 4, :o3, 1996135200 - tz.transition 2033, 10, :o2, 2014275600 - tz.transition 2034, 4, :o3, 2027584800 - tz.transition 2034, 10, :o2, 2045725200 - tz.transition 2035, 4, :o3, 2059034400 - tz.transition 2035, 10, :o2, 2077174800 - tz.transition 2036, 4, :o3, 2091088800 - tz.transition 2036, 10, :o2, 2108624400 - tz.transition 2037, 4, :o3, 2122538400 - tz.transition 2037, 10, :o2, 2140074000 - tz.transition 2038, 4, :o3, 29586215, 12 - tz.transition 2038, 10, :o2, 19725823, 8 - tz.transition 2039, 4, :o3, 29590583, 12 - tz.transition 2039, 10, :o2, 19728735, 8 - tz.transition 2040, 4, :o3, 29594951, 12 - tz.transition 2040, 10, :o2, 19731647, 8 - tz.transition 2041, 4, :o3, 29599403, 12 - tz.transition 2041, 10, :o2, 19734559, 8 - tz.transition 2042, 4, :o3, 29603771, 12 - tz.transition 2042, 10, :o2, 19737471, 8 - tz.transition 2043, 4, :o3, 29608139, 12 - tz.transition 2043, 10, :o2, 19740383, 8 - tz.transition 2044, 4, :o3, 29612507, 12 - tz.transition 2044, 10, :o2, 19743351, 8 - tz.transition 2045, 4, :o3, 29616875, 12 - tz.transition 2045, 10, :o2, 19746263, 8 - tz.transition 2046, 4, :o3, 29621243, 12 - tz.transition 2046, 10, :o2, 19749175, 8 - tz.transition 2047, 4, :o3, 29625695, 12 - tz.transition 2047, 10, :o2, 19752087, 8 - tz.transition 2048, 4, :o3, 29630063, 12 - tz.transition 2048, 10, :o2, 19754999, 8 - tz.transition 2049, 4, :o3, 29634431, 12 - tz.transition 2049, 10, :o2, 19757967, 8 - tz.transition 2050, 4, :o3, 29638799, 12 - tz.transition 2050, 10, :o2, 19760879, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb deleted file mode 100644 index 9ee18970..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Almaty - include TimezoneDefinition - - timezone 'Asia/Almaty' do |tz| - tz.offset :o0, 18468, 0, :LMT - tz.offset :o1, 18000, 0, :ALMT - tz.offset :o2, 21600, 0, :ALMT - tz.offset :o3, 21600, 3600, :ALMST - - tz.transition 1924, 5, :o1, 1939125829, 800 - tz.transition 1930, 6, :o2, 58227559, 24 - tz.transition 1981, 3, :o3, 354909600 - tz.transition 1981, 9, :o2, 370717200 - tz.transition 1982, 3, :o3, 386445600 - tz.transition 1982, 9, :o2, 402253200 - tz.transition 1983, 3, :o3, 417981600 - tz.transition 1983, 9, :o2, 433789200 - tz.transition 1984, 3, :o3, 449604000 - tz.transition 1984, 9, :o2, 465336000 - tz.transition 1985, 3, :o3, 481060800 - tz.transition 1985, 9, :o2, 496785600 - tz.transition 1986, 3, :o3, 512510400 - tz.transition 1986, 9, :o2, 528235200 - tz.transition 1987, 3, :o3, 543960000 - tz.transition 1987, 9, :o2, 559684800 - tz.transition 1988, 3, :o3, 575409600 - tz.transition 1988, 9, :o2, 591134400 - tz.transition 1989, 3, :o3, 606859200 - tz.transition 1989, 9, :o2, 622584000 - tz.transition 1990, 3, :o3, 638308800 - tz.transition 1990, 9, :o2, 654638400 - tz.transition 1992, 3, :o3, 701802000 - tz.transition 1992, 9, :o2, 717523200 - tz.transition 1993, 3, :o3, 733262400 - tz.transition 1993, 9, :o2, 748987200 - tz.transition 1994, 3, :o3, 764712000 - tz.transition 1994, 9, :o2, 780436800 - tz.transition 1995, 3, :o3, 796161600 - tz.transition 1995, 9, :o2, 811886400 - tz.transition 1996, 3, :o3, 828216000 - tz.transition 1996, 10, :o2, 846360000 - tz.transition 1997, 3, :o3, 859665600 - tz.transition 1997, 10, :o2, 877809600 - tz.transition 1998, 3, :o3, 891115200 - tz.transition 1998, 10, :o2, 909259200 - tz.transition 1999, 3, :o3, 922564800 - tz.transition 1999, 10, :o2, 941313600 - tz.transition 2000, 3, :o3, 954014400 - tz.transition 2000, 10, :o2, 972763200 - tz.transition 2001, 3, :o3, 985464000 - tz.transition 2001, 10, :o2, 1004212800 - tz.transition 2002, 3, :o3, 1017518400 - tz.transition 2002, 10, :o2, 1035662400 - tz.transition 2003, 3, :o3, 1048968000 - tz.transition 2003, 10, :o2, 1067112000 - tz.transition 2004, 3, :o3, 1080417600 - tz.transition 2004, 10, :o2, 1099166400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb deleted file mode 100644 index 774dca15..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Baghdad - include TimezoneDefinition - - timezone 'Asia/Baghdad' do |tz| - tz.offset :o0, 10660, 0, :LMT - tz.offset :o1, 10656, 0, :BMT - tz.offset :o2, 10800, 0, :AST - tz.offset :o3, 10800, 3600, :ADT - - tz.transition 1889, 12, :o1, 10417111387, 4320 - tz.transition 1917, 12, :o2, 726478313, 300 - tz.transition 1982, 4, :o3, 389048400 - tz.transition 1982, 9, :o2, 402264000 - tz.transition 1983, 3, :o3, 417906000 - tz.transition 1983, 9, :o2, 433800000 - tz.transition 1984, 3, :o3, 449614800 - tz.transition 1984, 9, :o2, 465422400 - tz.transition 1985, 3, :o3, 481150800 - tz.transition 1985, 9, :o2, 496792800 - tz.transition 1986, 3, :o3, 512517600 - tz.transition 1986, 9, :o2, 528242400 - tz.transition 1987, 3, :o3, 543967200 - tz.transition 1987, 9, :o2, 559692000 - tz.transition 1988, 3, :o3, 575416800 - tz.transition 1988, 9, :o2, 591141600 - tz.transition 1989, 3, :o3, 606866400 - tz.transition 1989, 9, :o2, 622591200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 9, :o2, 654645600 - tz.transition 1991, 4, :o3, 670464000 - tz.transition 1991, 10, :o2, 686275200 - tz.transition 1992, 4, :o3, 702086400 - tz.transition 1992, 10, :o2, 717897600 - tz.transition 1993, 4, :o3, 733622400 - tz.transition 1993, 10, :o2, 749433600 - tz.transition 1994, 4, :o3, 765158400 - tz.transition 1994, 10, :o2, 780969600 - tz.transition 1995, 4, :o3, 796694400 - tz.transition 1995, 10, :o2, 812505600 - tz.transition 1996, 4, :o3, 828316800 - tz.transition 1996, 10, :o2, 844128000 - tz.transition 1997, 4, :o3, 859852800 - tz.transition 1997, 10, :o2, 875664000 - tz.transition 1998, 4, :o3, 891388800 - tz.transition 1998, 10, :o2, 907200000 - tz.transition 1999, 4, :o3, 922924800 - tz.transition 1999, 10, :o2, 938736000 - tz.transition 2000, 4, :o3, 954547200 - tz.transition 2000, 10, :o2, 970358400 - tz.transition 2001, 4, :o3, 986083200 - tz.transition 2001, 10, :o2, 1001894400 - tz.transition 2002, 4, :o3, 1017619200 - tz.transition 2002, 10, :o2, 1033430400 - tz.transition 2003, 4, :o3, 1049155200 - tz.transition 2003, 10, :o2, 1064966400 - tz.transition 2004, 4, :o3, 1080777600 - tz.transition 2004, 10, :o2, 1096588800 - tz.transition 2005, 4, :o3, 1112313600 - tz.transition 2005, 10, :o2, 1128124800 - tz.transition 2006, 4, :o3, 1143849600 - tz.transition 2006, 10, :o2, 1159660800 - tz.transition 2007, 4, :o3, 1175385600 - tz.transition 2007, 10, :o2, 1191196800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb deleted file mode 100644 index e86340eb..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +++ /dev/null @@ -1,161 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Baku - include TimezoneDefinition - - timezone 'Asia/Baku' do |tz| - tz.offset :o0, 11964, 0, :LMT - tz.offset :o1, 10800, 0, :BAKT - tz.offset :o2, 14400, 0, :BAKT - tz.offset :o3, 14400, 3600, :BAKST - tz.offset :o4, 10800, 3600, :BAKST - tz.offset :o5, 10800, 3600, :AZST - tz.offset :o6, 10800, 0, :AZT - tz.offset :o7, 14400, 0, :AZT - tz.offset :o8, 14400, 3600, :AZST - - tz.transition 1924, 5, :o1, 17452133003, 7200 - tz.transition 1957, 2, :o2, 19487187, 8 - tz.transition 1981, 3, :o3, 354916800 - tz.transition 1981, 9, :o2, 370724400 - tz.transition 1982, 3, :o3, 386452800 - tz.transition 1982, 9, :o2, 402260400 - tz.transition 1983, 3, :o3, 417988800 - tz.transition 1983, 9, :o2, 433796400 - tz.transition 1984, 3, :o3, 449611200 - tz.transition 1984, 9, :o2, 465343200 - tz.transition 1985, 3, :o3, 481068000 - tz.transition 1985, 9, :o2, 496792800 - tz.transition 1986, 3, :o3, 512517600 - tz.transition 1986, 9, :o2, 528242400 - tz.transition 1987, 3, :o3, 543967200 - tz.transition 1987, 9, :o2, 559692000 - tz.transition 1988, 3, :o3, 575416800 - tz.transition 1988, 9, :o2, 591141600 - tz.transition 1989, 3, :o3, 606866400 - tz.transition 1989, 9, :o2, 622591200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 9, :o2, 654645600 - tz.transition 1991, 3, :o4, 670370400 - tz.transition 1991, 8, :o5, 683496000 - tz.transition 1991, 9, :o6, 686098800 - tz.transition 1992, 3, :o5, 701812800 - tz.transition 1992, 9, :o7, 717534000 - tz.transition 1996, 3, :o8, 828234000 - tz.transition 1996, 10, :o7, 846378000 - tz.transition 1997, 3, :o8, 859680000 - tz.transition 1997, 10, :o7, 877824000 - tz.transition 1998, 3, :o8, 891129600 - tz.transition 1998, 10, :o7, 909273600 - tz.transition 1999, 3, :o8, 922579200 - tz.transition 1999, 10, :o7, 941328000 - tz.transition 2000, 3, :o8, 954028800 - tz.transition 2000, 10, :o7, 972777600 - tz.transition 2001, 3, :o8, 985478400 - tz.transition 2001, 10, :o7, 1004227200 - tz.transition 2002, 3, :o8, 1017532800 - tz.transition 2002, 10, :o7, 1035676800 - tz.transition 2003, 3, :o8, 1048982400 - tz.transition 2003, 10, :o7, 1067126400 - tz.transition 2004, 3, :o8, 1080432000 - tz.transition 2004, 10, :o7, 1099180800 - tz.transition 2005, 3, :o8, 1111881600 - tz.transition 2005, 10, :o7, 1130630400 - tz.transition 2006, 3, :o8, 1143331200 - tz.transition 2006, 10, :o7, 1162080000 - tz.transition 2007, 3, :o8, 1174780800 - tz.transition 2007, 10, :o7, 1193529600 - tz.transition 2008, 3, :o8, 1206835200 - tz.transition 2008, 10, :o7, 1224979200 - tz.transition 2009, 3, :o8, 1238284800 - tz.transition 2009, 10, :o7, 1256428800 - tz.transition 2010, 3, :o8, 1269734400 - tz.transition 2010, 10, :o7, 1288483200 - tz.transition 2011, 3, :o8, 1301184000 - tz.transition 2011, 10, :o7, 1319932800 - tz.transition 2012, 3, :o8, 1332633600 - tz.transition 2012, 10, :o7, 1351382400 - tz.transition 2013, 3, :o8, 1364688000 - tz.transition 2013, 10, :o7, 1382832000 - tz.transition 2014, 3, :o8, 1396137600 - tz.transition 2014, 10, :o7, 1414281600 - tz.transition 2015, 3, :o8, 1427587200 - tz.transition 2015, 10, :o7, 1445731200 - tz.transition 2016, 3, :o8, 1459036800 - tz.transition 2016, 10, :o7, 1477785600 - tz.transition 2017, 3, :o8, 1490486400 - tz.transition 2017, 10, :o7, 1509235200 - tz.transition 2018, 3, :o8, 1521936000 - tz.transition 2018, 10, :o7, 1540684800 - tz.transition 2019, 3, :o8, 1553990400 - tz.transition 2019, 10, :o7, 1572134400 - tz.transition 2020, 3, :o8, 1585440000 - tz.transition 2020, 10, :o7, 1603584000 - tz.transition 2021, 3, :o8, 1616889600 - tz.transition 2021, 10, :o7, 1635638400 - tz.transition 2022, 3, :o8, 1648339200 - tz.transition 2022, 10, :o7, 1667088000 - tz.transition 2023, 3, :o8, 1679788800 - tz.transition 2023, 10, :o7, 1698537600 - tz.transition 2024, 3, :o8, 1711843200 - tz.transition 2024, 10, :o7, 1729987200 - tz.transition 2025, 3, :o8, 1743292800 - tz.transition 2025, 10, :o7, 1761436800 - tz.transition 2026, 3, :o8, 1774742400 - tz.transition 2026, 10, :o7, 1792886400 - tz.transition 2027, 3, :o8, 1806192000 - tz.transition 2027, 10, :o7, 1824940800 - tz.transition 2028, 3, :o8, 1837641600 - tz.transition 2028, 10, :o7, 1856390400 - tz.transition 2029, 3, :o8, 1869091200 - tz.transition 2029, 10, :o7, 1887840000 - tz.transition 2030, 3, :o8, 1901145600 - tz.transition 2030, 10, :o7, 1919289600 - tz.transition 2031, 3, :o8, 1932595200 - tz.transition 2031, 10, :o7, 1950739200 - tz.transition 2032, 3, :o8, 1964044800 - tz.transition 2032, 10, :o7, 1982793600 - tz.transition 2033, 3, :o8, 1995494400 - tz.transition 2033, 10, :o7, 2014243200 - tz.transition 2034, 3, :o8, 2026944000 - tz.transition 2034, 10, :o7, 2045692800 - tz.transition 2035, 3, :o8, 2058393600 - tz.transition 2035, 10, :o7, 2077142400 - tz.transition 2036, 3, :o8, 2090448000 - tz.transition 2036, 10, :o7, 2108592000 - tz.transition 2037, 3, :o8, 2121897600 - tz.transition 2037, 10, :o7, 2140041600 - tz.transition 2038, 3, :o8, 4931021, 2 - tz.transition 2038, 10, :o7, 4931455, 2 - tz.transition 2039, 3, :o8, 4931749, 2 - tz.transition 2039, 10, :o7, 4932183, 2 - tz.transition 2040, 3, :o8, 4932477, 2 - tz.transition 2040, 10, :o7, 4932911, 2 - tz.transition 2041, 3, :o8, 4933219, 2 - tz.transition 2041, 10, :o7, 4933639, 2 - tz.transition 2042, 3, :o8, 4933947, 2 - tz.transition 2042, 10, :o7, 4934367, 2 - tz.transition 2043, 3, :o8, 4934675, 2 - tz.transition 2043, 10, :o7, 4935095, 2 - tz.transition 2044, 3, :o8, 4935403, 2 - tz.transition 2044, 10, :o7, 4935837, 2 - tz.transition 2045, 3, :o8, 4936131, 2 - tz.transition 2045, 10, :o7, 4936565, 2 - tz.transition 2046, 3, :o8, 4936859, 2 - tz.transition 2046, 10, :o7, 4937293, 2 - tz.transition 2047, 3, :o8, 4937601, 2 - tz.transition 2047, 10, :o7, 4938021, 2 - tz.transition 2048, 3, :o8, 4938329, 2 - tz.transition 2048, 10, :o7, 4938749, 2 - tz.transition 2049, 3, :o8, 4939057, 2 - tz.transition 2049, 10, :o7, 4939491, 2 - tz.transition 2050, 3, :o8, 4939785, 2 - tz.transition 2050, 10, :o7, 4940219, 2 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb deleted file mode 100644 index 139194e5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Bangkok - include TimezoneDefinition - - timezone 'Asia/Bangkok' do |tz| - tz.offset :o0, 24124, 0, :LMT - tz.offset :o1, 24124, 0, :BMT - tz.offset :o2, 25200, 0, :ICT - - tz.transition 1879, 12, :o1, 52006648769, 21600 - tz.transition 1920, 3, :o2, 52324168769, 21600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb deleted file mode 100644 index 8c94b4ba..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Chongqing - include TimezoneDefinition - - timezone 'Asia/Chongqing' do |tz| - tz.offset :o0, 25580, 0, :LMT - tz.offset :o1, 25200, 0, :LONT - tz.offset :o2, 28800, 0, :CST - tz.offset :o3, 28800, 3600, :CDT - - tz.transition 1927, 12, :o1, 10477063601, 4320 - tz.transition 1980, 4, :o2, 325962000 - tz.transition 1986, 5, :o3, 515520000 - tz.transition 1986, 9, :o2, 527007600 - tz.transition 1987, 4, :o3, 545155200 - tz.transition 1987, 9, :o2, 558457200 - tz.transition 1988, 4, :o3, 576604800 - tz.transition 1988, 9, :o2, 589906800 - tz.transition 1989, 4, :o3, 608659200 - tz.transition 1989, 9, :o2, 621961200 - tz.transition 1990, 4, :o3, 640108800 - tz.transition 1990, 9, :o2, 653410800 - tz.transition 1991, 4, :o3, 671558400 - tz.transition 1991, 9, :o2, 684860400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb deleted file mode 100644 index f6531fa8..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Colombo - include TimezoneDefinition - - timezone 'Asia/Colombo' do |tz| - tz.offset :o0, 19164, 0, :LMT - tz.offset :o1, 19172, 0, :MMT - tz.offset :o2, 19800, 0, :IST - tz.offset :o3, 19800, 1800, :IHST - tz.offset :o4, 19800, 3600, :IST - tz.offset :o5, 23400, 0, :LKT - tz.offset :o6, 21600, 0, :LKT - - tz.transition 1879, 12, :o1, 17335550003, 7200 - tz.transition 1905, 12, :o2, 52211763607, 21600 - tz.transition 1942, 1, :o3, 116657485, 48 - tz.transition 1942, 8, :o4, 9722413, 4 - tz.transition 1945, 10, :o2, 38907909, 16 - tz.transition 1996, 5, :o5, 832962600 - tz.transition 1996, 10, :o6, 846266400 - tz.transition 2006, 4, :o2, 1145039400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb deleted file mode 100644 index ccd02655..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Dhaka - include TimezoneDefinition - - timezone 'Asia/Dhaka' do |tz| - tz.offset :o0, 21700, 0, :LMT - tz.offset :o1, 21200, 0, :HMT - tz.offset :o2, 23400, 0, :BURT - tz.offset :o3, 19800, 0, :IST - tz.offset :o4, 21600, 0, :DACT - tz.offset :o5, 21600, 0, :BDT - - tz.transition 1889, 12, :o1, 2083422167, 864 - tz.transition 1941, 9, :o2, 524937943, 216 - tz.transition 1942, 5, :o3, 116663723, 48 - tz.transition 1942, 8, :o2, 116668957, 48 - tz.transition 1951, 9, :o4, 116828123, 48 - tz.transition 1971, 3, :o5, 38772000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb deleted file mode 100644 index f1edd75a..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Hong_Kong - include TimezoneDefinition - - timezone 'Asia/Hong_Kong' do |tz| - tz.offset :o0, 27396, 0, :LMT - tz.offset :o1, 28800, 0, :HKT - tz.offset :o2, 28800, 3600, :HKST - - tz.transition 1904, 10, :o1, 5800279639, 2400 - tz.transition 1946, 4, :o2, 38910885, 16 - tz.transition 1946, 11, :o1, 116743453, 48 - tz.transition 1947, 4, :o2, 38916613, 16 - tz.transition 1947, 12, :o1, 116762365, 48 - tz.transition 1948, 5, :o2, 38922773, 16 - tz.transition 1948, 10, :o1, 116777053, 48 - tz.transition 1949, 4, :o2, 38928149, 16 - tz.transition 1949, 10, :o1, 116794525, 48 - tz.transition 1950, 4, :o2, 38933973, 16 - tz.transition 1950, 10, :o1, 116811997, 48 - tz.transition 1951, 3, :o2, 38939797, 16 - tz.transition 1951, 10, :o1, 116829469, 48 - tz.transition 1952, 4, :o2, 38945733, 16 - tz.transition 1952, 10, :o1, 116846941, 48 - tz.transition 1953, 4, :o2, 38951557, 16 - tz.transition 1953, 10, :o1, 116864749, 48 - tz.transition 1954, 3, :o2, 38957157, 16 - tz.transition 1954, 10, :o1, 116882221, 48 - tz.transition 1955, 3, :o2, 38962981, 16 - tz.transition 1955, 11, :o1, 116900029, 48 - tz.transition 1956, 3, :o2, 38968805, 16 - tz.transition 1956, 11, :o1, 116917501, 48 - tz.transition 1957, 3, :o2, 38974741, 16 - tz.transition 1957, 11, :o1, 116934973, 48 - tz.transition 1958, 3, :o2, 38980565, 16 - tz.transition 1958, 11, :o1, 116952445, 48 - tz.transition 1959, 3, :o2, 38986389, 16 - tz.transition 1959, 10, :o1, 116969917, 48 - tz.transition 1960, 3, :o2, 38992213, 16 - tz.transition 1960, 11, :o1, 116987725, 48 - tz.transition 1961, 3, :o2, 38998037, 16 - tz.transition 1961, 11, :o1, 117005197, 48 - tz.transition 1962, 3, :o2, 39003861, 16 - tz.transition 1962, 11, :o1, 117022669, 48 - tz.transition 1963, 3, :o2, 39009797, 16 - tz.transition 1963, 11, :o1, 117040141, 48 - tz.transition 1964, 3, :o2, 39015621, 16 - tz.transition 1964, 10, :o1, 117057613, 48 - tz.transition 1965, 4, :o2, 39021893, 16 - tz.transition 1965, 10, :o1, 117074413, 48 - tz.transition 1966, 4, :o2, 39027717, 16 - tz.transition 1966, 10, :o1, 117091885, 48 - tz.transition 1967, 4, :o2, 39033541, 16 - tz.transition 1967, 10, :o1, 117109693, 48 - tz.transition 1968, 4, :o2, 39039477, 16 - tz.transition 1968, 10, :o1, 117127165, 48 - tz.transition 1969, 4, :o2, 39045301, 16 - tz.transition 1969, 10, :o1, 117144637, 48 - tz.transition 1970, 4, :o2, 9315000 - tz.transition 1970, 10, :o1, 25036200 - tz.transition 1971, 4, :o2, 40764600 - tz.transition 1971, 10, :o1, 56485800 - tz.transition 1972, 4, :o2, 72214200 - tz.transition 1972, 10, :o1, 88540200 - tz.transition 1973, 4, :o2, 104268600 - tz.transition 1973, 10, :o1, 119989800 - tz.transition 1974, 4, :o2, 135718200 - tz.transition 1974, 10, :o1, 151439400 - tz.transition 1975, 4, :o2, 167167800 - tz.transition 1975, 10, :o1, 182889000 - tz.transition 1976, 4, :o2, 198617400 - tz.transition 1976, 10, :o1, 214338600 - tz.transition 1977, 4, :o2, 230067000 - tz.transition 1977, 10, :o1, 245788200 - tz.transition 1979, 5, :o2, 295385400 - tz.transition 1979, 10, :o1, 309292200 - tz.transition 1980, 5, :o2, 326835000 - tz.transition 1980, 10, :o1, 340741800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb deleted file mode 100644 index 2d47d958..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Irkutsk - include TimezoneDefinition - - timezone 'Asia/Irkutsk' do |tz| - tz.offset :o0, 25040, 0, :LMT - tz.offset :o1, 25040, 0, :IMT - tz.offset :o2, 25200, 0, :IRKT - tz.offset :o3, 28800, 0, :IRKT - tz.offset :o4, 28800, 3600, :IRKST - tz.offset :o5, 25200, 3600, :IRKST - - tz.transition 1879, 12, :o1, 2600332427, 1080 - tz.transition 1920, 1, :o2, 2616136067, 1080 - tz.transition 1930, 6, :o3, 58227557, 24 - tz.transition 1981, 3, :o4, 354902400 - tz.transition 1981, 9, :o3, 370710000 - tz.transition 1982, 3, :o4, 386438400 - tz.transition 1982, 9, :o3, 402246000 - tz.transition 1983, 3, :o4, 417974400 - tz.transition 1983, 9, :o3, 433782000 - tz.transition 1984, 3, :o4, 449596800 - tz.transition 1984, 9, :o3, 465328800 - tz.transition 1985, 3, :o4, 481053600 - tz.transition 1985, 9, :o3, 496778400 - tz.transition 1986, 3, :o4, 512503200 - tz.transition 1986, 9, :o3, 528228000 - tz.transition 1987, 3, :o4, 543952800 - tz.transition 1987, 9, :o3, 559677600 - tz.transition 1988, 3, :o4, 575402400 - tz.transition 1988, 9, :o3, 591127200 - tz.transition 1989, 3, :o4, 606852000 - tz.transition 1989, 9, :o3, 622576800 - tz.transition 1990, 3, :o4, 638301600 - tz.transition 1990, 9, :o3, 654631200 - tz.transition 1991, 3, :o5, 670356000 - tz.transition 1991, 9, :o2, 686084400 - tz.transition 1992, 1, :o3, 695761200 - tz.transition 1992, 3, :o4, 701794800 - tz.transition 1992, 9, :o3, 717516000 - tz.transition 1993, 3, :o4, 733255200 - tz.transition 1993, 9, :o3, 748980000 - tz.transition 1994, 3, :o4, 764704800 - tz.transition 1994, 9, :o3, 780429600 - tz.transition 1995, 3, :o4, 796154400 - tz.transition 1995, 9, :o3, 811879200 - tz.transition 1996, 3, :o4, 828208800 - tz.transition 1996, 10, :o3, 846352800 - tz.transition 1997, 3, :o4, 859658400 - tz.transition 1997, 10, :o3, 877802400 - tz.transition 1998, 3, :o4, 891108000 - tz.transition 1998, 10, :o3, 909252000 - tz.transition 1999, 3, :o4, 922557600 - tz.transition 1999, 10, :o3, 941306400 - tz.transition 2000, 3, :o4, 954007200 - tz.transition 2000, 10, :o3, 972756000 - tz.transition 2001, 3, :o4, 985456800 - tz.transition 2001, 10, :o3, 1004205600 - tz.transition 2002, 3, :o4, 1017511200 - tz.transition 2002, 10, :o3, 1035655200 - tz.transition 2003, 3, :o4, 1048960800 - tz.transition 2003, 10, :o3, 1067104800 - tz.transition 2004, 3, :o4, 1080410400 - tz.transition 2004, 10, :o3, 1099159200 - tz.transition 2005, 3, :o4, 1111860000 - tz.transition 2005, 10, :o3, 1130608800 - tz.transition 2006, 3, :o4, 1143309600 - tz.transition 2006, 10, :o3, 1162058400 - tz.transition 2007, 3, :o4, 1174759200 - tz.transition 2007, 10, :o3, 1193508000 - tz.transition 2008, 3, :o4, 1206813600 - tz.transition 2008, 10, :o3, 1224957600 - tz.transition 2009, 3, :o4, 1238263200 - tz.transition 2009, 10, :o3, 1256407200 - tz.transition 2010, 3, :o4, 1269712800 - tz.transition 2010, 10, :o3, 1288461600 - tz.transition 2011, 3, :o4, 1301162400 - tz.transition 2011, 10, :o3, 1319911200 - tz.transition 2012, 3, :o4, 1332612000 - tz.transition 2012, 10, :o3, 1351360800 - tz.transition 2013, 3, :o4, 1364666400 - tz.transition 2013, 10, :o3, 1382810400 - tz.transition 2014, 3, :o4, 1396116000 - tz.transition 2014, 10, :o3, 1414260000 - tz.transition 2015, 3, :o4, 1427565600 - tz.transition 2015, 10, :o3, 1445709600 - tz.transition 2016, 3, :o4, 1459015200 - tz.transition 2016, 10, :o3, 1477764000 - tz.transition 2017, 3, :o4, 1490464800 - tz.transition 2017, 10, :o3, 1509213600 - tz.transition 2018, 3, :o4, 1521914400 - tz.transition 2018, 10, :o3, 1540663200 - tz.transition 2019, 3, :o4, 1553968800 - tz.transition 2019, 10, :o3, 1572112800 - tz.transition 2020, 3, :o4, 1585418400 - tz.transition 2020, 10, :o3, 1603562400 - tz.transition 2021, 3, :o4, 1616868000 - tz.transition 2021, 10, :o3, 1635616800 - tz.transition 2022, 3, :o4, 1648317600 - tz.transition 2022, 10, :o3, 1667066400 - tz.transition 2023, 3, :o4, 1679767200 - tz.transition 2023, 10, :o3, 1698516000 - tz.transition 2024, 3, :o4, 1711821600 - tz.transition 2024, 10, :o3, 1729965600 - tz.transition 2025, 3, :o4, 1743271200 - tz.transition 2025, 10, :o3, 1761415200 - tz.transition 2026, 3, :o4, 1774720800 - tz.transition 2026, 10, :o3, 1792864800 - tz.transition 2027, 3, :o4, 1806170400 - tz.transition 2027, 10, :o3, 1824919200 - tz.transition 2028, 3, :o4, 1837620000 - tz.transition 2028, 10, :o3, 1856368800 - tz.transition 2029, 3, :o4, 1869069600 - tz.transition 2029, 10, :o3, 1887818400 - tz.transition 2030, 3, :o4, 1901124000 - tz.transition 2030, 10, :o3, 1919268000 - tz.transition 2031, 3, :o4, 1932573600 - tz.transition 2031, 10, :o3, 1950717600 - tz.transition 2032, 3, :o4, 1964023200 - tz.transition 2032, 10, :o3, 1982772000 - tz.transition 2033, 3, :o4, 1995472800 - tz.transition 2033, 10, :o3, 2014221600 - tz.transition 2034, 3, :o4, 2026922400 - tz.transition 2034, 10, :o3, 2045671200 - tz.transition 2035, 3, :o4, 2058372000 - tz.transition 2035, 10, :o3, 2077120800 - tz.transition 2036, 3, :o4, 2090426400 - tz.transition 2036, 10, :o3, 2108570400 - tz.transition 2037, 3, :o4, 2121876000 - tz.transition 2037, 10, :o3, 2140020000 - tz.transition 2038, 3, :o4, 9862041, 4 - tz.transition 2038, 10, :o3, 9862909, 4 - tz.transition 2039, 3, :o4, 9863497, 4 - tz.transition 2039, 10, :o3, 9864365, 4 - tz.transition 2040, 3, :o4, 9864953, 4 - tz.transition 2040, 10, :o3, 9865821, 4 - tz.transition 2041, 3, :o4, 9866437, 4 - tz.transition 2041, 10, :o3, 9867277, 4 - tz.transition 2042, 3, :o4, 9867893, 4 - tz.transition 2042, 10, :o3, 9868733, 4 - tz.transition 2043, 3, :o4, 9869349, 4 - tz.transition 2043, 10, :o3, 9870189, 4 - tz.transition 2044, 3, :o4, 9870805, 4 - tz.transition 2044, 10, :o3, 9871673, 4 - tz.transition 2045, 3, :o4, 9872261, 4 - tz.transition 2045, 10, :o3, 9873129, 4 - tz.transition 2046, 3, :o4, 9873717, 4 - tz.transition 2046, 10, :o3, 9874585, 4 - tz.transition 2047, 3, :o4, 9875201, 4 - tz.transition 2047, 10, :o3, 9876041, 4 - tz.transition 2048, 3, :o4, 9876657, 4 - tz.transition 2048, 10, :o3, 9877497, 4 - tz.transition 2049, 3, :o4, 9878113, 4 - tz.transition 2049, 10, :o3, 9878981, 4 - tz.transition 2050, 3, :o4, 9879569, 4 - tz.transition 2050, 10, :o3, 9880437, 4 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb deleted file mode 100644 index cc58fa17..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Jakarta - include TimezoneDefinition - - timezone 'Asia/Jakarta' do |tz| - tz.offset :o0, 25632, 0, :LMT - tz.offset :o1, 25632, 0, :JMT - tz.offset :o2, 26400, 0, :JAVT - tz.offset :o3, 27000, 0, :WIT - tz.offset :o4, 32400, 0, :JST - tz.offset :o5, 28800, 0, :WIT - tz.offset :o6, 25200, 0, :WIT - - tz.transition 1867, 8, :o1, 720956461, 300 - tz.transition 1923, 12, :o2, 87256267, 36 - tz.transition 1932, 10, :o3, 87372439, 36 - tz.transition 1942, 3, :o4, 38887059, 16 - tz.transition 1945, 9, :o3, 19453769, 8 - tz.transition 1948, 4, :o5, 38922755, 16 - tz.transition 1950, 4, :o3, 14600413, 6 - tz.transition 1963, 12, :o6, 39014323, 16 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb deleted file mode 100644 index 9b737b89..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Jerusalem - include TimezoneDefinition - - timezone 'Asia/Jerusalem' do |tz| - tz.offset :o0, 8456, 0, :LMT - tz.offset :o1, 8440, 0, :JMT - tz.offset :o2, 7200, 0, :IST - tz.offset :o3, 7200, 3600, :IDT - tz.offset :o4, 7200, 7200, :IDDT - - tz.transition 1879, 12, :o1, 26003326343, 10800 - tz.transition 1917, 12, :o2, 5230643909, 2160 - tz.transition 1940, 5, :o3, 29157377, 12 - tz.transition 1942, 10, :o2, 19445315, 8 - tz.transition 1943, 4, :o3, 4861631, 2 - tz.transition 1943, 10, :o2, 19448235, 8 - tz.transition 1944, 3, :o3, 29174177, 12 - tz.transition 1944, 10, :o2, 19451163, 8 - tz.transition 1945, 4, :o3, 29178737, 12 - tz.transition 1945, 10, :o2, 58362251, 24 - tz.transition 1946, 4, :o3, 4863853, 2 - tz.transition 1946, 10, :o2, 19457003, 8 - tz.transition 1948, 5, :o4, 29192333, 12 - tz.transition 1948, 8, :o3, 7298386, 3 - tz.transition 1948, 10, :o2, 58388555, 24 - tz.transition 1949, 4, :o3, 29196449, 12 - tz.transition 1949, 10, :o2, 58397315, 24 - tz.transition 1950, 4, :o3, 29200649, 12 - tz.transition 1950, 9, :o2, 4867079, 2 - tz.transition 1951, 3, :o3, 29204849, 12 - tz.transition 1951, 11, :o2, 4867923, 2 - tz.transition 1952, 4, :o3, 4868245, 2 - tz.transition 1952, 10, :o2, 4868609, 2 - tz.transition 1953, 4, :o3, 4868959, 2 - tz.transition 1953, 9, :o2, 4869267, 2 - tz.transition 1954, 6, :o3, 29218877, 12 - tz.transition 1954, 9, :o2, 19479979, 8 - tz.transition 1955, 6, :o3, 4870539, 2 - tz.transition 1955, 9, :o2, 19482891, 8 - tz.transition 1956, 6, :o3, 29227529, 12 - tz.transition 1956, 9, :o2, 4871493, 2 - tz.transition 1957, 4, :o3, 4871915, 2 - tz.transition 1957, 9, :o2, 19488827, 8 - tz.transition 1974, 7, :o3, 142380000 - tz.transition 1974, 10, :o2, 150843600 - tz.transition 1975, 4, :o3, 167176800 - tz.transition 1975, 8, :o2, 178664400 - tz.transition 1985, 4, :o3, 482277600 - tz.transition 1985, 9, :o2, 495579600 - tz.transition 1986, 5, :o3, 516751200 - tz.transition 1986, 9, :o2, 526424400 - tz.transition 1987, 4, :o3, 545436000 - tz.transition 1987, 9, :o2, 558478800 - tz.transition 1988, 4, :o3, 576540000 - tz.transition 1988, 9, :o2, 589237200 - tz.transition 1989, 4, :o3, 609890400 - tz.transition 1989, 9, :o2, 620773200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 8, :o2, 651618000 - tz.transition 1991, 3, :o3, 669765600 - tz.transition 1991, 8, :o2, 683672400 - tz.transition 1992, 3, :o3, 701820000 - tz.transition 1992, 9, :o2, 715726800 - tz.transition 1993, 4, :o3, 733701600 - tz.transition 1993, 9, :o2, 747176400 - tz.transition 1994, 3, :o3, 765151200 - tz.transition 1994, 8, :o2, 778021200 - tz.transition 1995, 3, :o3, 796600800 - tz.transition 1995, 9, :o2, 810075600 - tz.transition 1996, 3, :o3, 826840800 - tz.transition 1996, 9, :o2, 842821200 - tz.transition 1997, 3, :o3, 858895200 - tz.transition 1997, 9, :o2, 874184400 - tz.transition 1998, 3, :o3, 890344800 - tz.transition 1998, 9, :o2, 905029200 - tz.transition 1999, 4, :o3, 923011200 - tz.transition 1999, 9, :o2, 936313200 - tz.transition 2000, 4, :o3, 955670400 - tz.transition 2000, 10, :o2, 970783200 - tz.transition 2001, 4, :o3, 986770800 - tz.transition 2001, 9, :o2, 1001282400 - tz.transition 2002, 3, :o3, 1017356400 - tz.transition 2002, 10, :o2, 1033941600 - tz.transition 2003, 3, :o3, 1048806000 - tz.transition 2003, 10, :o2, 1065132000 - tz.transition 2004, 4, :o3, 1081292400 - tz.transition 2004, 9, :o2, 1095804000 - tz.transition 2005, 4, :o3, 1112313600 - tz.transition 2005, 10, :o2, 1128812400 - tz.transition 2006, 3, :o3, 1143763200 - tz.transition 2006, 9, :o2, 1159657200 - tz.transition 2007, 3, :o3, 1175212800 - tz.transition 2007, 9, :o2, 1189897200 - tz.transition 2008, 3, :o3, 1206662400 - tz.transition 2008, 10, :o2, 1223161200 - tz.transition 2009, 3, :o3, 1238112000 - tz.transition 2009, 9, :o2, 1254006000 - tz.transition 2010, 3, :o3, 1269561600 - tz.transition 2010, 9, :o2, 1284246000 - tz.transition 2011, 4, :o3, 1301616000 - tz.transition 2011, 10, :o2, 1317510000 - tz.transition 2012, 3, :o3, 1333065600 - tz.transition 2012, 9, :o2, 1348354800 - tz.transition 2013, 3, :o3, 1364515200 - tz.transition 2013, 9, :o2, 1378594800 - tz.transition 2014, 3, :o3, 1395964800 - tz.transition 2014, 9, :o2, 1411858800 - tz.transition 2015, 3, :o3, 1427414400 - tz.transition 2015, 9, :o2, 1442703600 - tz.transition 2016, 4, :o3, 1459468800 - tz.transition 2016, 10, :o2, 1475967600 - tz.transition 2017, 3, :o3, 1490918400 - tz.transition 2017, 9, :o2, 1506207600 - tz.transition 2018, 3, :o3, 1522368000 - tz.transition 2018, 9, :o2, 1537052400 - tz.transition 2019, 3, :o3, 1553817600 - tz.transition 2019, 10, :o2, 1570316400 - tz.transition 2020, 3, :o3, 1585267200 - tz.transition 2020, 9, :o2, 1601161200 - tz.transition 2021, 3, :o3, 1616716800 - tz.transition 2021, 9, :o2, 1631401200 - tz.transition 2022, 4, :o3, 1648771200 - tz.transition 2022, 10, :o2, 1664665200 - tz.transition 2023, 3, :o3, 1680220800 - tz.transition 2023, 9, :o2, 1695510000 - tz.transition 2024, 3, :o3, 1711670400 - tz.transition 2024, 10, :o2, 1728169200 - tz.transition 2025, 3, :o3, 1743120000 - tz.transition 2025, 9, :o2, 1759014000 - tz.transition 2026, 3, :o3, 1774569600 - tz.transition 2026, 9, :o2, 1789858800 - tz.transition 2027, 3, :o3, 1806019200 - tz.transition 2027, 10, :o2, 1823122800 - tz.transition 2028, 3, :o3, 1838073600 - tz.transition 2028, 9, :o2, 1853362800 - tz.transition 2029, 3, :o3, 1869523200 - tz.transition 2029, 9, :o2, 1884207600 - tz.transition 2030, 3, :o3, 1900972800 - tz.transition 2030, 10, :o2, 1917471600 - tz.transition 2031, 3, :o3, 1932422400 - tz.transition 2031, 9, :o2, 1947711600 - tz.transition 2032, 3, :o3, 1963872000 - tz.transition 2032, 9, :o2, 1978556400 - tz.transition 2033, 4, :o3, 1995926400 - tz.transition 2033, 10, :o2, 2011820400 - tz.transition 2034, 3, :o3, 2027376000 - tz.transition 2034, 9, :o2, 2042060400 - tz.transition 2035, 3, :o3, 2058825600 - tz.transition 2035, 10, :o2, 2075324400 - tz.transition 2036, 3, :o3, 2090275200 - tz.transition 2036, 9, :o2, 2106169200 - tz.transition 2037, 3, :o3, 2121724800 - tz.transition 2037, 9, :o2, 2136409200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb deleted file mode 100644 index 669c0979..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kabul - include TimezoneDefinition - - timezone 'Asia/Kabul' do |tz| - tz.offset :o0, 16608, 0, :LMT - tz.offset :o1, 14400, 0, :AFT - tz.offset :o2, 16200, 0, :AFT - - tz.transition 1889, 12, :o1, 2170231477, 900 - tz.transition 1944, 12, :o2, 7294369, 3 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb deleted file mode 100644 index 2f1690b3..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kamchatka - include TimezoneDefinition - - timezone 'Asia/Kamchatka' do |tz| - tz.offset :o0, 38076, 0, :LMT - tz.offset :o1, 39600, 0, :PETT - tz.offset :o2, 43200, 0, :PETT - tz.offset :o3, 43200, 3600, :PETST - tz.offset :o4, 39600, 3600, :PETST - - tz.transition 1922, 11, :o1, 17448250027, 7200 - tz.transition 1930, 6, :o2, 58227553, 24 - tz.transition 1981, 3, :o3, 354888000 - tz.transition 1981, 9, :o2, 370695600 - tz.transition 1982, 3, :o3, 386424000 - tz.transition 1982, 9, :o2, 402231600 - tz.transition 1983, 3, :o3, 417960000 - tz.transition 1983, 9, :o2, 433767600 - tz.transition 1984, 3, :o3, 449582400 - tz.transition 1984, 9, :o2, 465314400 - tz.transition 1985, 3, :o3, 481039200 - tz.transition 1985, 9, :o2, 496764000 - tz.transition 1986, 3, :o3, 512488800 - tz.transition 1986, 9, :o2, 528213600 - tz.transition 1987, 3, :o3, 543938400 - tz.transition 1987, 9, :o2, 559663200 - tz.transition 1988, 3, :o3, 575388000 - tz.transition 1988, 9, :o2, 591112800 - tz.transition 1989, 3, :o3, 606837600 - tz.transition 1989, 9, :o2, 622562400 - tz.transition 1990, 3, :o3, 638287200 - tz.transition 1990, 9, :o2, 654616800 - tz.transition 1991, 3, :o4, 670341600 - tz.transition 1991, 9, :o1, 686070000 - tz.transition 1992, 1, :o2, 695746800 - tz.transition 1992, 3, :o3, 701780400 - tz.transition 1992, 9, :o2, 717501600 - tz.transition 1993, 3, :o3, 733240800 - tz.transition 1993, 9, :o2, 748965600 - tz.transition 1994, 3, :o3, 764690400 - tz.transition 1994, 9, :o2, 780415200 - tz.transition 1995, 3, :o3, 796140000 - tz.transition 1995, 9, :o2, 811864800 - tz.transition 1996, 3, :o3, 828194400 - tz.transition 1996, 10, :o2, 846338400 - tz.transition 1997, 3, :o3, 859644000 - tz.transition 1997, 10, :o2, 877788000 - tz.transition 1998, 3, :o3, 891093600 - tz.transition 1998, 10, :o2, 909237600 - tz.transition 1999, 3, :o3, 922543200 - tz.transition 1999, 10, :o2, 941292000 - tz.transition 2000, 3, :o3, 953992800 - tz.transition 2000, 10, :o2, 972741600 - tz.transition 2001, 3, :o3, 985442400 - tz.transition 2001, 10, :o2, 1004191200 - tz.transition 2002, 3, :o3, 1017496800 - tz.transition 2002, 10, :o2, 1035640800 - tz.transition 2003, 3, :o3, 1048946400 - tz.transition 2003, 10, :o2, 1067090400 - tz.transition 2004, 3, :o3, 1080396000 - tz.transition 2004, 10, :o2, 1099144800 - tz.transition 2005, 3, :o3, 1111845600 - tz.transition 2005, 10, :o2, 1130594400 - tz.transition 2006, 3, :o3, 1143295200 - tz.transition 2006, 10, :o2, 1162044000 - tz.transition 2007, 3, :o3, 1174744800 - tz.transition 2007, 10, :o2, 1193493600 - tz.transition 2008, 3, :o3, 1206799200 - tz.transition 2008, 10, :o2, 1224943200 - tz.transition 2009, 3, :o3, 1238248800 - tz.transition 2009, 10, :o2, 1256392800 - tz.transition 2010, 3, :o3, 1269698400 - tz.transition 2010, 10, :o2, 1288447200 - tz.transition 2011, 3, :o3, 1301148000 - tz.transition 2011, 10, :o2, 1319896800 - tz.transition 2012, 3, :o3, 1332597600 - tz.transition 2012, 10, :o2, 1351346400 - tz.transition 2013, 3, :o3, 1364652000 - tz.transition 2013, 10, :o2, 1382796000 - tz.transition 2014, 3, :o3, 1396101600 - tz.transition 2014, 10, :o2, 1414245600 - tz.transition 2015, 3, :o3, 1427551200 - tz.transition 2015, 10, :o2, 1445695200 - tz.transition 2016, 3, :o3, 1459000800 - tz.transition 2016, 10, :o2, 1477749600 - tz.transition 2017, 3, :o3, 1490450400 - tz.transition 2017, 10, :o2, 1509199200 - tz.transition 2018, 3, :o3, 1521900000 - tz.transition 2018, 10, :o2, 1540648800 - tz.transition 2019, 3, :o3, 1553954400 - tz.transition 2019, 10, :o2, 1572098400 - tz.transition 2020, 3, :o3, 1585404000 - tz.transition 2020, 10, :o2, 1603548000 - tz.transition 2021, 3, :o3, 1616853600 - tz.transition 2021, 10, :o2, 1635602400 - tz.transition 2022, 3, :o3, 1648303200 - tz.transition 2022, 10, :o2, 1667052000 - tz.transition 2023, 3, :o3, 1679752800 - tz.transition 2023, 10, :o2, 1698501600 - tz.transition 2024, 3, :o3, 1711807200 - tz.transition 2024, 10, :o2, 1729951200 - tz.transition 2025, 3, :o3, 1743256800 - tz.transition 2025, 10, :o2, 1761400800 - tz.transition 2026, 3, :o3, 1774706400 - tz.transition 2026, 10, :o2, 1792850400 - tz.transition 2027, 3, :o3, 1806156000 - tz.transition 2027, 10, :o2, 1824904800 - tz.transition 2028, 3, :o3, 1837605600 - tz.transition 2028, 10, :o2, 1856354400 - tz.transition 2029, 3, :o3, 1869055200 - tz.transition 2029, 10, :o2, 1887804000 - tz.transition 2030, 3, :o3, 1901109600 - tz.transition 2030, 10, :o2, 1919253600 - tz.transition 2031, 3, :o3, 1932559200 - tz.transition 2031, 10, :o2, 1950703200 - tz.transition 2032, 3, :o3, 1964008800 - tz.transition 2032, 10, :o2, 1982757600 - tz.transition 2033, 3, :o3, 1995458400 - tz.transition 2033, 10, :o2, 2014207200 - tz.transition 2034, 3, :o3, 2026908000 - tz.transition 2034, 10, :o2, 2045656800 - tz.transition 2035, 3, :o3, 2058357600 - tz.transition 2035, 10, :o2, 2077106400 - tz.transition 2036, 3, :o3, 2090412000 - tz.transition 2036, 10, :o2, 2108556000 - tz.transition 2037, 3, :o3, 2121861600 - tz.transition 2037, 10, :o2, 2140005600 - tz.transition 2038, 3, :o3, 29586121, 12 - tz.transition 2038, 10, :o2, 29588725, 12 - tz.transition 2039, 3, :o3, 29590489, 12 - tz.transition 2039, 10, :o2, 29593093, 12 - tz.transition 2040, 3, :o3, 29594857, 12 - tz.transition 2040, 10, :o2, 29597461, 12 - tz.transition 2041, 3, :o3, 29599309, 12 - tz.transition 2041, 10, :o2, 29601829, 12 - tz.transition 2042, 3, :o3, 29603677, 12 - tz.transition 2042, 10, :o2, 29606197, 12 - tz.transition 2043, 3, :o3, 29608045, 12 - tz.transition 2043, 10, :o2, 29610565, 12 - tz.transition 2044, 3, :o3, 29612413, 12 - tz.transition 2044, 10, :o2, 29615017, 12 - tz.transition 2045, 3, :o3, 29616781, 12 - tz.transition 2045, 10, :o2, 29619385, 12 - tz.transition 2046, 3, :o3, 29621149, 12 - tz.transition 2046, 10, :o2, 29623753, 12 - tz.transition 2047, 3, :o3, 29625601, 12 - tz.transition 2047, 10, :o2, 29628121, 12 - tz.transition 2048, 3, :o3, 29629969, 12 - tz.transition 2048, 10, :o2, 29632489, 12 - tz.transition 2049, 3, :o3, 29634337, 12 - tz.transition 2049, 10, :o2, 29636941, 12 - tz.transition 2050, 3, :o3, 29638705, 12 - tz.transition 2050, 10, :o2, 29641309, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb deleted file mode 100644 index b906cc98..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Karachi - include TimezoneDefinition - - timezone 'Asia/Karachi' do |tz| - tz.offset :o0, 16092, 0, :LMT - tz.offset :o1, 19800, 0, :IST - tz.offset :o2, 19800, 3600, :IST - tz.offset :o3, 18000, 0, :KART - tz.offset :o4, 18000, 0, :PKT - tz.offset :o5, 18000, 3600, :PKST - - tz.transition 1906, 12, :o1, 1934061051, 800 - tz.transition 1942, 8, :o2, 116668957, 48 - tz.transition 1945, 10, :o1, 116723675, 48 - tz.transition 1951, 9, :o3, 116828125, 48 - tz.transition 1971, 3, :o4, 38775600 - tz.transition 2002, 4, :o5, 1018119660 - tz.transition 2002, 10, :o4, 1033840860 - tz.transition 2008, 5, :o5, 1212260400 - tz.transition 2008, 10, :o4, 1225476000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb deleted file mode 100644 index 37dbea1f..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Katmandu - include TimezoneDefinition - - timezone 'Asia/Katmandu' do |tz| - tz.offset :o0, 20476, 0, :LMT - tz.offset :o1, 19800, 0, :IST - tz.offset :o2, 20700, 0, :NPT - - tz.transition 1919, 12, :o1, 52322204081, 21600 - tz.transition 1985, 12, :o2, 504901800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb deleted file mode 100644 index 1b6ffbd5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kolkata - include TimezoneDefinition - - timezone 'Asia/Kolkata' do |tz| - tz.offset :o0, 21208, 0, :LMT - tz.offset :o1, 21200, 0, :HMT - tz.offset :o2, 23400, 0, :BURT - tz.offset :o3, 19800, 0, :IST - tz.offset :o4, 19800, 3600, :IST - - tz.transition 1879, 12, :o1, 26003324749, 10800 - tz.transition 1941, 9, :o2, 524937943, 216 - tz.transition 1942, 5, :o3, 116663723, 48 - tz.transition 1942, 8, :o4, 116668957, 48 - tz.transition 1945, 10, :o3, 116723675, 48 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb deleted file mode 100644 index d6c503c1..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Krasnoyarsk - include TimezoneDefinition - - timezone 'Asia/Krasnoyarsk' do |tz| - tz.offset :o0, 22280, 0, :LMT - tz.offset :o1, 21600, 0, :KRAT - tz.offset :o2, 25200, 0, :KRAT - tz.offset :o3, 25200, 3600, :KRAST - tz.offset :o4, 21600, 3600, :KRAST - - tz.transition 1920, 1, :o1, 5232231163, 2160 - tz.transition 1930, 6, :o2, 9704593, 4 - tz.transition 1981, 3, :o3, 354906000 - tz.transition 1981, 9, :o2, 370713600 - tz.transition 1982, 3, :o3, 386442000 - tz.transition 1982, 9, :o2, 402249600 - tz.transition 1983, 3, :o3, 417978000 - tz.transition 1983, 9, :o2, 433785600 - tz.transition 1984, 3, :o3, 449600400 - tz.transition 1984, 9, :o2, 465332400 - tz.transition 1985, 3, :o3, 481057200 - tz.transition 1985, 9, :o2, 496782000 - tz.transition 1986, 3, :o3, 512506800 - tz.transition 1986, 9, :o2, 528231600 - tz.transition 1987, 3, :o3, 543956400 - tz.transition 1987, 9, :o2, 559681200 - tz.transition 1988, 3, :o3, 575406000 - tz.transition 1988, 9, :o2, 591130800 - tz.transition 1989, 3, :o3, 606855600 - tz.transition 1989, 9, :o2, 622580400 - tz.transition 1990, 3, :o3, 638305200 - tz.transition 1990, 9, :o2, 654634800 - tz.transition 1991, 3, :o4, 670359600 - tz.transition 1991, 9, :o1, 686088000 - tz.transition 1992, 1, :o2, 695764800 - tz.transition 1992, 3, :o3, 701798400 - tz.transition 1992, 9, :o2, 717519600 - tz.transition 1993, 3, :o3, 733258800 - tz.transition 1993, 9, :o2, 748983600 - tz.transition 1994, 3, :o3, 764708400 - tz.transition 1994, 9, :o2, 780433200 - tz.transition 1995, 3, :o3, 796158000 - tz.transition 1995, 9, :o2, 811882800 - tz.transition 1996, 3, :o3, 828212400 - tz.transition 1996, 10, :o2, 846356400 - tz.transition 1997, 3, :o3, 859662000 - tz.transition 1997, 10, :o2, 877806000 - tz.transition 1998, 3, :o3, 891111600 - tz.transition 1998, 10, :o2, 909255600 - tz.transition 1999, 3, :o3, 922561200 - tz.transition 1999, 10, :o2, 941310000 - tz.transition 2000, 3, :o3, 954010800 - tz.transition 2000, 10, :o2, 972759600 - tz.transition 2001, 3, :o3, 985460400 - tz.transition 2001, 10, :o2, 1004209200 - tz.transition 2002, 3, :o3, 1017514800 - tz.transition 2002, 10, :o2, 1035658800 - tz.transition 2003, 3, :o3, 1048964400 - tz.transition 2003, 10, :o2, 1067108400 - tz.transition 2004, 3, :o3, 1080414000 - tz.transition 2004, 10, :o2, 1099162800 - tz.transition 2005, 3, :o3, 1111863600 - tz.transition 2005, 10, :o2, 1130612400 - tz.transition 2006, 3, :o3, 1143313200 - tz.transition 2006, 10, :o2, 1162062000 - tz.transition 2007, 3, :o3, 1174762800 - tz.transition 2007, 10, :o2, 1193511600 - tz.transition 2008, 3, :o3, 1206817200 - tz.transition 2008, 10, :o2, 1224961200 - tz.transition 2009, 3, :o3, 1238266800 - tz.transition 2009, 10, :o2, 1256410800 - tz.transition 2010, 3, :o3, 1269716400 - tz.transition 2010, 10, :o2, 1288465200 - tz.transition 2011, 3, :o3, 1301166000 - tz.transition 2011, 10, :o2, 1319914800 - tz.transition 2012, 3, :o3, 1332615600 - tz.transition 2012, 10, :o2, 1351364400 - tz.transition 2013, 3, :o3, 1364670000 - tz.transition 2013, 10, :o2, 1382814000 - tz.transition 2014, 3, :o3, 1396119600 - tz.transition 2014, 10, :o2, 1414263600 - tz.transition 2015, 3, :o3, 1427569200 - tz.transition 2015, 10, :o2, 1445713200 - tz.transition 2016, 3, :o3, 1459018800 - tz.transition 2016, 10, :o2, 1477767600 - tz.transition 2017, 3, :o3, 1490468400 - tz.transition 2017, 10, :o2, 1509217200 - tz.transition 2018, 3, :o3, 1521918000 - tz.transition 2018, 10, :o2, 1540666800 - tz.transition 2019, 3, :o3, 1553972400 - tz.transition 2019, 10, :o2, 1572116400 - tz.transition 2020, 3, :o3, 1585422000 - tz.transition 2020, 10, :o2, 1603566000 - tz.transition 2021, 3, :o3, 1616871600 - tz.transition 2021, 10, :o2, 1635620400 - tz.transition 2022, 3, :o3, 1648321200 - tz.transition 2022, 10, :o2, 1667070000 - tz.transition 2023, 3, :o3, 1679770800 - tz.transition 2023, 10, :o2, 1698519600 - tz.transition 2024, 3, :o3, 1711825200 - tz.transition 2024, 10, :o2, 1729969200 - tz.transition 2025, 3, :o3, 1743274800 - tz.transition 2025, 10, :o2, 1761418800 - tz.transition 2026, 3, :o3, 1774724400 - tz.transition 2026, 10, :o2, 1792868400 - tz.transition 2027, 3, :o3, 1806174000 - tz.transition 2027, 10, :o2, 1824922800 - tz.transition 2028, 3, :o3, 1837623600 - tz.transition 2028, 10, :o2, 1856372400 - tz.transition 2029, 3, :o3, 1869073200 - tz.transition 2029, 10, :o2, 1887822000 - tz.transition 2030, 3, :o3, 1901127600 - tz.transition 2030, 10, :o2, 1919271600 - tz.transition 2031, 3, :o3, 1932577200 - tz.transition 2031, 10, :o2, 1950721200 - tz.transition 2032, 3, :o3, 1964026800 - tz.transition 2032, 10, :o2, 1982775600 - tz.transition 2033, 3, :o3, 1995476400 - tz.transition 2033, 10, :o2, 2014225200 - tz.transition 2034, 3, :o3, 2026926000 - tz.transition 2034, 10, :o2, 2045674800 - tz.transition 2035, 3, :o3, 2058375600 - tz.transition 2035, 10, :o2, 2077124400 - tz.transition 2036, 3, :o3, 2090430000 - tz.transition 2036, 10, :o2, 2108574000 - tz.transition 2037, 3, :o3, 2121879600 - tz.transition 2037, 10, :o2, 2140023600 - tz.transition 2038, 3, :o3, 59172247, 24 - tz.transition 2038, 10, :o2, 59177455, 24 - tz.transition 2039, 3, :o3, 59180983, 24 - tz.transition 2039, 10, :o2, 59186191, 24 - tz.transition 2040, 3, :o3, 59189719, 24 - tz.transition 2040, 10, :o2, 59194927, 24 - tz.transition 2041, 3, :o3, 59198623, 24 - tz.transition 2041, 10, :o2, 59203663, 24 - tz.transition 2042, 3, :o3, 59207359, 24 - tz.transition 2042, 10, :o2, 59212399, 24 - tz.transition 2043, 3, :o3, 59216095, 24 - tz.transition 2043, 10, :o2, 59221135, 24 - tz.transition 2044, 3, :o3, 59224831, 24 - tz.transition 2044, 10, :o2, 59230039, 24 - tz.transition 2045, 3, :o3, 59233567, 24 - tz.transition 2045, 10, :o2, 59238775, 24 - tz.transition 2046, 3, :o3, 59242303, 24 - tz.transition 2046, 10, :o2, 59247511, 24 - tz.transition 2047, 3, :o3, 59251207, 24 - tz.transition 2047, 10, :o2, 59256247, 24 - tz.transition 2048, 3, :o3, 59259943, 24 - tz.transition 2048, 10, :o2, 59264983, 24 - tz.transition 2049, 3, :o3, 59268679, 24 - tz.transition 2049, 10, :o2, 59273887, 24 - tz.transition 2050, 3, :o3, 59277415, 24 - tz.transition 2050, 10, :o2, 59282623, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb deleted file mode 100644 index 77a0c206..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kuala_Lumpur - include TimezoneDefinition - - timezone 'Asia/Kuala_Lumpur' do |tz| - tz.offset :o0, 24406, 0, :LMT - tz.offset :o1, 24925, 0, :SMT - tz.offset :o2, 25200, 0, :MALT - tz.offset :o3, 25200, 1200, :MALST - tz.offset :o4, 26400, 0, :MALT - tz.offset :o5, 27000, 0, :MALT - tz.offset :o6, 32400, 0, :JST - tz.offset :o7, 28800, 0, :MYT - - tz.transition 1900, 12, :o1, 104344641397, 43200 - tz.transition 1905, 5, :o2, 8353142363, 3456 - tz.transition 1932, 12, :o3, 58249757, 24 - tz.transition 1935, 12, :o4, 87414055, 36 - tz.transition 1941, 8, :o5, 87488575, 36 - tz.transition 1942, 2, :o6, 38886499, 16 - tz.transition 1945, 9, :o5, 19453681, 8 - tz.transition 1981, 12, :o7, 378664200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb deleted file mode 100644 index 5bd52831..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kuwait - include TimezoneDefinition - - timezone 'Asia/Kuwait' do |tz| - tz.offset :o0, 11516, 0, :LMT - tz.offset :o1, 10800, 0, :AST - - tz.transition 1949, 12, :o1, 52558899121, 21600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb deleted file mode 100644 index 30209369..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Magadan - include TimezoneDefinition - - timezone 'Asia/Magadan' do |tz| - tz.offset :o0, 36192, 0, :LMT - tz.offset :o1, 36000, 0, :MAGT - tz.offset :o2, 39600, 0, :MAGT - tz.offset :o3, 39600, 3600, :MAGST - tz.offset :o4, 36000, 3600, :MAGST - - tz.transition 1924, 5, :o1, 2181516373, 900 - tz.transition 1930, 6, :o2, 29113777, 12 - tz.transition 1981, 3, :o3, 354891600 - tz.transition 1981, 9, :o2, 370699200 - tz.transition 1982, 3, :o3, 386427600 - tz.transition 1982, 9, :o2, 402235200 - tz.transition 1983, 3, :o3, 417963600 - tz.transition 1983, 9, :o2, 433771200 - tz.transition 1984, 3, :o3, 449586000 - tz.transition 1984, 9, :o2, 465318000 - tz.transition 1985, 3, :o3, 481042800 - tz.transition 1985, 9, :o2, 496767600 - tz.transition 1986, 3, :o3, 512492400 - tz.transition 1986, 9, :o2, 528217200 - tz.transition 1987, 3, :o3, 543942000 - tz.transition 1987, 9, :o2, 559666800 - tz.transition 1988, 3, :o3, 575391600 - tz.transition 1988, 9, :o2, 591116400 - tz.transition 1989, 3, :o3, 606841200 - tz.transition 1989, 9, :o2, 622566000 - tz.transition 1990, 3, :o3, 638290800 - tz.transition 1990, 9, :o2, 654620400 - tz.transition 1991, 3, :o4, 670345200 - tz.transition 1991, 9, :o1, 686073600 - tz.transition 1992, 1, :o2, 695750400 - tz.transition 1992, 3, :o3, 701784000 - tz.transition 1992, 9, :o2, 717505200 - tz.transition 1993, 3, :o3, 733244400 - tz.transition 1993, 9, :o2, 748969200 - tz.transition 1994, 3, :o3, 764694000 - tz.transition 1994, 9, :o2, 780418800 - tz.transition 1995, 3, :o3, 796143600 - tz.transition 1995, 9, :o2, 811868400 - tz.transition 1996, 3, :o3, 828198000 - tz.transition 1996, 10, :o2, 846342000 - tz.transition 1997, 3, :o3, 859647600 - tz.transition 1997, 10, :o2, 877791600 - tz.transition 1998, 3, :o3, 891097200 - tz.transition 1998, 10, :o2, 909241200 - tz.transition 1999, 3, :o3, 922546800 - tz.transition 1999, 10, :o2, 941295600 - tz.transition 2000, 3, :o3, 953996400 - tz.transition 2000, 10, :o2, 972745200 - tz.transition 2001, 3, :o3, 985446000 - tz.transition 2001, 10, :o2, 1004194800 - tz.transition 2002, 3, :o3, 1017500400 - tz.transition 2002, 10, :o2, 1035644400 - tz.transition 2003, 3, :o3, 1048950000 - tz.transition 2003, 10, :o2, 1067094000 - tz.transition 2004, 3, :o3, 1080399600 - tz.transition 2004, 10, :o2, 1099148400 - tz.transition 2005, 3, :o3, 1111849200 - tz.transition 2005, 10, :o2, 1130598000 - tz.transition 2006, 3, :o3, 1143298800 - tz.transition 2006, 10, :o2, 1162047600 - tz.transition 2007, 3, :o3, 1174748400 - tz.transition 2007, 10, :o2, 1193497200 - tz.transition 2008, 3, :o3, 1206802800 - tz.transition 2008, 10, :o2, 1224946800 - tz.transition 2009, 3, :o3, 1238252400 - tz.transition 2009, 10, :o2, 1256396400 - tz.transition 2010, 3, :o3, 1269702000 - tz.transition 2010, 10, :o2, 1288450800 - tz.transition 2011, 3, :o3, 1301151600 - tz.transition 2011, 10, :o2, 1319900400 - tz.transition 2012, 3, :o3, 1332601200 - tz.transition 2012, 10, :o2, 1351350000 - tz.transition 2013, 3, :o3, 1364655600 - tz.transition 2013, 10, :o2, 1382799600 - tz.transition 2014, 3, :o3, 1396105200 - tz.transition 2014, 10, :o2, 1414249200 - tz.transition 2015, 3, :o3, 1427554800 - tz.transition 2015, 10, :o2, 1445698800 - tz.transition 2016, 3, :o3, 1459004400 - tz.transition 2016, 10, :o2, 1477753200 - tz.transition 2017, 3, :o3, 1490454000 - tz.transition 2017, 10, :o2, 1509202800 - tz.transition 2018, 3, :o3, 1521903600 - tz.transition 2018, 10, :o2, 1540652400 - tz.transition 2019, 3, :o3, 1553958000 - tz.transition 2019, 10, :o2, 1572102000 - tz.transition 2020, 3, :o3, 1585407600 - tz.transition 2020, 10, :o2, 1603551600 - tz.transition 2021, 3, :o3, 1616857200 - tz.transition 2021, 10, :o2, 1635606000 - tz.transition 2022, 3, :o3, 1648306800 - tz.transition 2022, 10, :o2, 1667055600 - tz.transition 2023, 3, :o3, 1679756400 - tz.transition 2023, 10, :o2, 1698505200 - tz.transition 2024, 3, :o3, 1711810800 - tz.transition 2024, 10, :o2, 1729954800 - tz.transition 2025, 3, :o3, 1743260400 - tz.transition 2025, 10, :o2, 1761404400 - tz.transition 2026, 3, :o3, 1774710000 - tz.transition 2026, 10, :o2, 1792854000 - tz.transition 2027, 3, :o3, 1806159600 - tz.transition 2027, 10, :o2, 1824908400 - tz.transition 2028, 3, :o3, 1837609200 - tz.transition 2028, 10, :o2, 1856358000 - tz.transition 2029, 3, :o3, 1869058800 - tz.transition 2029, 10, :o2, 1887807600 - tz.transition 2030, 3, :o3, 1901113200 - tz.transition 2030, 10, :o2, 1919257200 - tz.transition 2031, 3, :o3, 1932562800 - tz.transition 2031, 10, :o2, 1950706800 - tz.transition 2032, 3, :o3, 1964012400 - tz.transition 2032, 10, :o2, 1982761200 - tz.transition 2033, 3, :o3, 1995462000 - tz.transition 2033, 10, :o2, 2014210800 - tz.transition 2034, 3, :o3, 2026911600 - tz.transition 2034, 10, :o2, 2045660400 - tz.transition 2035, 3, :o3, 2058361200 - tz.transition 2035, 10, :o2, 2077110000 - tz.transition 2036, 3, :o3, 2090415600 - tz.transition 2036, 10, :o2, 2108559600 - tz.transition 2037, 3, :o3, 2121865200 - tz.transition 2037, 10, :o2, 2140009200 - tz.transition 2038, 3, :o3, 19724081, 8 - tz.transition 2038, 10, :o2, 19725817, 8 - tz.transition 2039, 3, :o3, 19726993, 8 - tz.transition 2039, 10, :o2, 19728729, 8 - tz.transition 2040, 3, :o3, 19729905, 8 - tz.transition 2040, 10, :o2, 19731641, 8 - tz.transition 2041, 3, :o3, 19732873, 8 - tz.transition 2041, 10, :o2, 19734553, 8 - tz.transition 2042, 3, :o3, 19735785, 8 - tz.transition 2042, 10, :o2, 19737465, 8 - tz.transition 2043, 3, :o3, 19738697, 8 - tz.transition 2043, 10, :o2, 19740377, 8 - tz.transition 2044, 3, :o3, 19741609, 8 - tz.transition 2044, 10, :o2, 19743345, 8 - tz.transition 2045, 3, :o3, 19744521, 8 - tz.transition 2045, 10, :o2, 19746257, 8 - tz.transition 2046, 3, :o3, 19747433, 8 - tz.transition 2046, 10, :o2, 19749169, 8 - tz.transition 2047, 3, :o3, 19750401, 8 - tz.transition 2047, 10, :o2, 19752081, 8 - tz.transition 2048, 3, :o3, 19753313, 8 - tz.transition 2048, 10, :o2, 19754993, 8 - tz.transition 2049, 3, :o3, 19756225, 8 - tz.transition 2049, 10, :o2, 19757961, 8 - tz.transition 2050, 3, :o3, 19759137, 8 - tz.transition 2050, 10, :o2, 19760873, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb deleted file mode 100644 index 604f651d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Muscat - include TimezoneDefinition - - timezone 'Asia/Muscat' do |tz| - tz.offset :o0, 14060, 0, :LMT - tz.offset :o1, 14400, 0, :GST - - tz.transition 1919, 12, :o1, 10464441137, 4320 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb deleted file mode 100644 index a4e7796e..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +++ /dev/null @@ -1,164 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Novosibirsk - include TimezoneDefinition - - timezone 'Asia/Novosibirsk' do |tz| - tz.offset :o0, 19900, 0, :LMT - tz.offset :o1, 21600, 0, :NOVT - tz.offset :o2, 25200, 0, :NOVT - tz.offset :o3, 25200, 3600, :NOVST - tz.offset :o4, 21600, 3600, :NOVST - - tz.transition 1919, 12, :o1, 2092872833, 864 - tz.transition 1930, 6, :o2, 9704593, 4 - tz.transition 1981, 3, :o3, 354906000 - tz.transition 1981, 9, :o2, 370713600 - tz.transition 1982, 3, :o3, 386442000 - tz.transition 1982, 9, :o2, 402249600 - tz.transition 1983, 3, :o3, 417978000 - tz.transition 1983, 9, :o2, 433785600 - tz.transition 1984, 3, :o3, 449600400 - tz.transition 1984, 9, :o2, 465332400 - tz.transition 1985, 3, :o3, 481057200 - tz.transition 1985, 9, :o2, 496782000 - tz.transition 1986, 3, :o3, 512506800 - tz.transition 1986, 9, :o2, 528231600 - tz.transition 1987, 3, :o3, 543956400 - tz.transition 1987, 9, :o2, 559681200 - tz.transition 1988, 3, :o3, 575406000 - tz.transition 1988, 9, :o2, 591130800 - tz.transition 1989, 3, :o3, 606855600 - tz.transition 1989, 9, :o2, 622580400 - tz.transition 1990, 3, :o3, 638305200 - tz.transition 1990, 9, :o2, 654634800 - tz.transition 1991, 3, :o4, 670359600 - tz.transition 1991, 9, :o1, 686088000 - tz.transition 1992, 1, :o2, 695764800 - tz.transition 1992, 3, :o3, 701798400 - tz.transition 1992, 9, :o2, 717519600 - tz.transition 1993, 3, :o3, 733258800 - tz.transition 1993, 5, :o4, 738086400 - tz.transition 1993, 9, :o1, 748987200 - tz.transition 1994, 3, :o4, 764712000 - tz.transition 1994, 9, :o1, 780436800 - tz.transition 1995, 3, :o4, 796161600 - tz.transition 1995, 9, :o1, 811886400 - tz.transition 1996, 3, :o4, 828216000 - tz.transition 1996, 10, :o1, 846360000 - tz.transition 1997, 3, :o4, 859665600 - tz.transition 1997, 10, :o1, 877809600 - tz.transition 1998, 3, :o4, 891115200 - tz.transition 1998, 10, :o1, 909259200 - tz.transition 1999, 3, :o4, 922564800 - tz.transition 1999, 10, :o1, 941313600 - tz.transition 2000, 3, :o4, 954014400 - tz.transition 2000, 10, :o1, 972763200 - tz.transition 2001, 3, :o4, 985464000 - tz.transition 2001, 10, :o1, 1004212800 - tz.transition 2002, 3, :o4, 1017518400 - tz.transition 2002, 10, :o1, 1035662400 - tz.transition 2003, 3, :o4, 1048968000 - tz.transition 2003, 10, :o1, 1067112000 - tz.transition 2004, 3, :o4, 1080417600 - tz.transition 2004, 10, :o1, 1099166400 - tz.transition 2005, 3, :o4, 1111867200 - tz.transition 2005, 10, :o1, 1130616000 - tz.transition 2006, 3, :o4, 1143316800 - tz.transition 2006, 10, :o1, 1162065600 - tz.transition 2007, 3, :o4, 1174766400 - tz.transition 2007, 10, :o1, 1193515200 - tz.transition 2008, 3, :o4, 1206820800 - tz.transition 2008, 10, :o1, 1224964800 - tz.transition 2009, 3, :o4, 1238270400 - tz.transition 2009, 10, :o1, 1256414400 - tz.transition 2010, 3, :o4, 1269720000 - tz.transition 2010, 10, :o1, 1288468800 - tz.transition 2011, 3, :o4, 1301169600 - tz.transition 2011, 10, :o1, 1319918400 - tz.transition 2012, 3, :o4, 1332619200 - tz.transition 2012, 10, :o1, 1351368000 - tz.transition 2013, 3, :o4, 1364673600 - tz.transition 2013, 10, :o1, 1382817600 - tz.transition 2014, 3, :o4, 1396123200 - tz.transition 2014, 10, :o1, 1414267200 - tz.transition 2015, 3, :o4, 1427572800 - tz.transition 2015, 10, :o1, 1445716800 - tz.transition 2016, 3, :o4, 1459022400 - tz.transition 2016, 10, :o1, 1477771200 - tz.transition 2017, 3, :o4, 1490472000 - tz.transition 2017, 10, :o1, 1509220800 - tz.transition 2018, 3, :o4, 1521921600 - tz.transition 2018, 10, :o1, 1540670400 - tz.transition 2019, 3, :o4, 1553976000 - tz.transition 2019, 10, :o1, 1572120000 - tz.transition 2020, 3, :o4, 1585425600 - tz.transition 2020, 10, :o1, 1603569600 - tz.transition 2021, 3, :o4, 1616875200 - tz.transition 2021, 10, :o1, 1635624000 - tz.transition 2022, 3, :o4, 1648324800 - tz.transition 2022, 10, :o1, 1667073600 - tz.transition 2023, 3, :o4, 1679774400 - tz.transition 2023, 10, :o1, 1698523200 - tz.transition 2024, 3, :o4, 1711828800 - tz.transition 2024, 10, :o1, 1729972800 - tz.transition 2025, 3, :o4, 1743278400 - tz.transition 2025, 10, :o1, 1761422400 - tz.transition 2026, 3, :o4, 1774728000 - tz.transition 2026, 10, :o1, 1792872000 - tz.transition 2027, 3, :o4, 1806177600 - tz.transition 2027, 10, :o1, 1824926400 - tz.transition 2028, 3, :o4, 1837627200 - tz.transition 2028, 10, :o1, 1856376000 - tz.transition 2029, 3, :o4, 1869076800 - tz.transition 2029, 10, :o1, 1887825600 - tz.transition 2030, 3, :o4, 1901131200 - tz.transition 2030, 10, :o1, 1919275200 - tz.transition 2031, 3, :o4, 1932580800 - tz.transition 2031, 10, :o1, 1950724800 - tz.transition 2032, 3, :o4, 1964030400 - tz.transition 2032, 10, :o1, 1982779200 - tz.transition 2033, 3, :o4, 1995480000 - tz.transition 2033, 10, :o1, 2014228800 - tz.transition 2034, 3, :o4, 2026929600 - tz.transition 2034, 10, :o1, 2045678400 - tz.transition 2035, 3, :o4, 2058379200 - tz.transition 2035, 10, :o1, 2077128000 - tz.transition 2036, 3, :o4, 2090433600 - tz.transition 2036, 10, :o1, 2108577600 - tz.transition 2037, 3, :o4, 2121883200 - tz.transition 2037, 10, :o1, 2140027200 - tz.transition 2038, 3, :o4, 7396531, 3 - tz.transition 2038, 10, :o1, 7397182, 3 - tz.transition 2039, 3, :o4, 7397623, 3 - tz.transition 2039, 10, :o1, 7398274, 3 - tz.transition 2040, 3, :o4, 7398715, 3 - tz.transition 2040, 10, :o1, 7399366, 3 - tz.transition 2041, 3, :o4, 7399828, 3 - tz.transition 2041, 10, :o1, 7400458, 3 - tz.transition 2042, 3, :o4, 7400920, 3 - tz.transition 2042, 10, :o1, 7401550, 3 - tz.transition 2043, 3, :o4, 7402012, 3 - tz.transition 2043, 10, :o1, 7402642, 3 - tz.transition 2044, 3, :o4, 7403104, 3 - tz.transition 2044, 10, :o1, 7403755, 3 - tz.transition 2045, 3, :o4, 7404196, 3 - tz.transition 2045, 10, :o1, 7404847, 3 - tz.transition 2046, 3, :o4, 7405288, 3 - tz.transition 2046, 10, :o1, 7405939, 3 - tz.transition 2047, 3, :o4, 7406401, 3 - tz.transition 2047, 10, :o1, 7407031, 3 - tz.transition 2048, 3, :o4, 7407493, 3 - tz.transition 2048, 10, :o1, 7408123, 3 - tz.transition 2049, 3, :o4, 7408585, 3 - tz.transition 2049, 10, :o1, 7409236, 3 - tz.transition 2050, 3, :o4, 7409677, 3 - tz.transition 2050, 10, :o1, 7410328, 3 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb deleted file mode 100644 index 759b82d7..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Rangoon - include TimezoneDefinition - - timezone 'Asia/Rangoon' do |tz| - tz.offset :o0, 23080, 0, :LMT - tz.offset :o1, 23076, 0, :RMT - tz.offset :o2, 23400, 0, :BURT - tz.offset :o3, 32400, 0, :JST - tz.offset :o4, 23400, 0, :MMT - - tz.transition 1879, 12, :o1, 5200664903, 2160 - tz.transition 1919, 12, :o2, 5813578159, 2400 - tz.transition 1942, 4, :o3, 116663051, 48 - tz.transition 1945, 5, :o4, 19452625, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb deleted file mode 100644 index 7add4106..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Riyadh - include TimezoneDefinition - - timezone 'Asia/Riyadh' do |tz| - tz.offset :o0, 11212, 0, :LMT - tz.offset :o1, 10800, 0, :AST - - tz.transition 1949, 12, :o1, 52558899197, 21600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb deleted file mode 100644 index 795d2a75..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Seoul - include TimezoneDefinition - - timezone 'Asia/Seoul' do |tz| - tz.offset :o0, 30472, 0, :LMT - tz.offset :o1, 30600, 0, :KST - tz.offset :o2, 32400, 0, :KST - tz.offset :o3, 28800, 0, :KST - tz.offset :o4, 28800, 3600, :KDT - tz.offset :o5, 32400, 3600, :KDT - - tz.transition 1889, 12, :o1, 26042775991, 10800 - tz.transition 1904, 11, :o2, 116007127, 48 - tz.transition 1927, 12, :o1, 19401969, 8 - tz.transition 1931, 12, :o2, 116481943, 48 - tz.transition 1954, 3, :o3, 19478577, 8 - tz.transition 1960, 5, :o4, 14622415, 6 - tz.transition 1960, 9, :o3, 19497521, 8 - tz.transition 1961, 8, :o1, 14625127, 6 - tz.transition 1968, 9, :o2, 117126247, 48 - tz.transition 1987, 5, :o5, 547570800 - tz.transition 1987, 10, :o2, 560872800 - tz.transition 1988, 5, :o5, 579020400 - tz.transition 1988, 10, :o2, 592322400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb deleted file mode 100644 index 34b13d59..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Shanghai - include TimezoneDefinition - - timezone 'Asia/Shanghai' do |tz| - tz.offset :o0, 29152, 0, :LMT - tz.offset :o1, 28800, 0, :CST - tz.offset :o2, 28800, 3600, :CDT - - tz.transition 1927, 12, :o1, 6548164639, 2700 - tz.transition 1940, 6, :o2, 14578699, 6 - tz.transition 1940, 9, :o1, 19439225, 8 - tz.transition 1941, 3, :o2, 14580415, 6 - tz.transition 1941, 9, :o1, 19442145, 8 - tz.transition 1986, 5, :o2, 515520000 - tz.transition 1986, 9, :o1, 527007600 - tz.transition 1987, 4, :o2, 545155200 - tz.transition 1987, 9, :o1, 558457200 - tz.transition 1988, 4, :o2, 576604800 - tz.transition 1988, 9, :o1, 589906800 - tz.transition 1989, 4, :o2, 608659200 - tz.transition 1989, 9, :o1, 621961200 - tz.transition 1990, 4, :o2, 640108800 - tz.transition 1990, 9, :o1, 653410800 - tz.transition 1991, 4, :o2, 671558400 - tz.transition 1991, 9, :o1, 684860400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb deleted file mode 100644 index b323a78f..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Singapore - include TimezoneDefinition - - timezone 'Asia/Singapore' do |tz| - tz.offset :o0, 24925, 0, :LMT - tz.offset :o1, 24925, 0, :SMT - tz.offset :o2, 25200, 0, :MALT - tz.offset :o3, 25200, 1200, :MALST - tz.offset :o4, 26400, 0, :MALT - tz.offset :o5, 27000, 0, :MALT - tz.offset :o6, 32400, 0, :JST - tz.offset :o7, 27000, 0, :SGT - tz.offset :o8, 28800, 0, :SGT - - tz.transition 1900, 12, :o1, 8347571291, 3456 - tz.transition 1905, 5, :o2, 8353142363, 3456 - tz.transition 1932, 12, :o3, 58249757, 24 - tz.transition 1935, 12, :o4, 87414055, 36 - tz.transition 1941, 8, :o5, 87488575, 36 - tz.transition 1942, 2, :o6, 38886499, 16 - tz.transition 1945, 9, :o5, 19453681, 8 - tz.transition 1965, 8, :o7, 39023699, 16 - tz.transition 1981, 12, :o8, 378664200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb deleted file mode 100644 index 3ba12108..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Taipei - include TimezoneDefinition - - timezone 'Asia/Taipei' do |tz| - tz.offset :o0, 29160, 0, :LMT - tz.offset :o1, 28800, 0, :CST - tz.offset :o2, 28800, 3600, :CDT - - tz.transition 1895, 12, :o1, 193084733, 80 - tz.transition 1945, 4, :o2, 14589457, 6 - tz.transition 1945, 9, :o1, 19453833, 8 - tz.transition 1946, 4, :o2, 14591647, 6 - tz.transition 1946, 9, :o1, 19456753, 8 - tz.transition 1947, 4, :o2, 14593837, 6 - tz.transition 1947, 9, :o1, 19459673, 8 - tz.transition 1948, 4, :o2, 14596033, 6 - tz.transition 1948, 9, :o1, 19462601, 8 - tz.transition 1949, 4, :o2, 14598223, 6 - tz.transition 1949, 9, :o1, 19465521, 8 - tz.transition 1950, 4, :o2, 14600413, 6 - tz.transition 1950, 9, :o1, 19468441, 8 - tz.transition 1951, 4, :o2, 14602603, 6 - tz.transition 1951, 9, :o1, 19471361, 8 - tz.transition 1952, 2, :o2, 14604433, 6 - tz.transition 1952, 10, :o1, 19474537, 8 - tz.transition 1953, 3, :o2, 14606809, 6 - tz.transition 1953, 10, :o1, 19477457, 8 - tz.transition 1954, 3, :o2, 14608999, 6 - tz.transition 1954, 10, :o1, 19480377, 8 - tz.transition 1955, 3, :o2, 14611189, 6 - tz.transition 1955, 9, :o1, 19483049, 8 - tz.transition 1956, 3, :o2, 14613385, 6 - tz.transition 1956, 9, :o1, 19485977, 8 - tz.transition 1957, 3, :o2, 14615575, 6 - tz.transition 1957, 9, :o1, 19488897, 8 - tz.transition 1958, 3, :o2, 14617765, 6 - tz.transition 1958, 9, :o1, 19491817, 8 - tz.transition 1959, 3, :o2, 14619955, 6 - tz.transition 1959, 9, :o1, 19494737, 8 - tz.transition 1960, 5, :o2, 14622517, 6 - tz.transition 1960, 9, :o1, 19497665, 8 - tz.transition 1961, 5, :o2, 14624707, 6 - tz.transition 1961, 9, :o1, 19500585, 8 - tz.transition 1974, 3, :o2, 133977600 - tz.transition 1974, 9, :o1, 149785200 - tz.transition 1975, 3, :o2, 165513600 - tz.transition 1975, 9, :o1, 181321200 - tz.transition 1980, 6, :o2, 331142400 - tz.transition 1980, 9, :o1, 339087600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb deleted file mode 100644 index c205c793..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tashkent - include TimezoneDefinition - - timezone 'Asia/Tashkent' do |tz| - tz.offset :o0, 16632, 0, :LMT - tz.offset :o1, 18000, 0, :TAST - tz.offset :o2, 21600, 0, :TAST - tz.offset :o3, 21600, 3600, :TASST - tz.offset :o4, 18000, 3600, :TASST - tz.offset :o5, 18000, 3600, :UZST - tz.offset :o6, 18000, 0, :UZT - - tz.transition 1924, 5, :o1, 969562923, 400 - tz.transition 1930, 6, :o2, 58227559, 24 - tz.transition 1981, 3, :o3, 354909600 - tz.transition 1981, 9, :o2, 370717200 - tz.transition 1982, 3, :o3, 386445600 - tz.transition 1982, 9, :o2, 402253200 - tz.transition 1983, 3, :o3, 417981600 - tz.transition 1983, 9, :o2, 433789200 - tz.transition 1984, 3, :o3, 449604000 - tz.transition 1984, 9, :o2, 465336000 - tz.transition 1985, 3, :o3, 481060800 - tz.transition 1985, 9, :o2, 496785600 - tz.transition 1986, 3, :o3, 512510400 - tz.transition 1986, 9, :o2, 528235200 - tz.transition 1987, 3, :o3, 543960000 - tz.transition 1987, 9, :o2, 559684800 - tz.transition 1988, 3, :o3, 575409600 - tz.transition 1988, 9, :o2, 591134400 - tz.transition 1989, 3, :o3, 606859200 - tz.transition 1989, 9, :o2, 622584000 - tz.transition 1990, 3, :o3, 638308800 - tz.transition 1990, 9, :o2, 654638400 - tz.transition 1991, 3, :o4, 670363200 - tz.transition 1991, 8, :o5, 683661600 - tz.transition 1991, 9, :o6, 686091600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb deleted file mode 100644 index 15792a56..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tbilisi - include TimezoneDefinition - - timezone 'Asia/Tbilisi' do |tz| - tz.offset :o0, 10756, 0, :LMT - tz.offset :o1, 10756, 0, :TBMT - tz.offset :o2, 10800, 0, :TBIT - tz.offset :o3, 14400, 0, :TBIT - tz.offset :o4, 14400, 3600, :TBIST - tz.offset :o5, 10800, 3600, :TBIST - tz.offset :o6, 10800, 3600, :GEST - tz.offset :o7, 10800, 0, :GET - tz.offset :o8, 14400, 0, :GET - tz.offset :o9, 14400, 3600, :GEST - - tz.transition 1879, 12, :o1, 52006652111, 21600 - tz.transition 1924, 5, :o2, 52356399311, 21600 - tz.transition 1957, 2, :o3, 19487187, 8 - tz.transition 1981, 3, :o4, 354916800 - tz.transition 1981, 9, :o3, 370724400 - tz.transition 1982, 3, :o4, 386452800 - tz.transition 1982, 9, :o3, 402260400 - tz.transition 1983, 3, :o4, 417988800 - tz.transition 1983, 9, :o3, 433796400 - tz.transition 1984, 3, :o4, 449611200 - tz.transition 1984, 9, :o3, 465343200 - tz.transition 1985, 3, :o4, 481068000 - tz.transition 1985, 9, :o3, 496792800 - tz.transition 1986, 3, :o4, 512517600 - tz.transition 1986, 9, :o3, 528242400 - tz.transition 1987, 3, :o4, 543967200 - tz.transition 1987, 9, :o3, 559692000 - tz.transition 1988, 3, :o4, 575416800 - tz.transition 1988, 9, :o3, 591141600 - tz.transition 1989, 3, :o4, 606866400 - tz.transition 1989, 9, :o3, 622591200 - tz.transition 1990, 3, :o4, 638316000 - tz.transition 1990, 9, :o3, 654645600 - tz.transition 1991, 3, :o5, 670370400 - tz.transition 1991, 4, :o6, 671140800 - tz.transition 1991, 9, :o7, 686098800 - tz.transition 1992, 3, :o6, 701816400 - tz.transition 1992, 9, :o7, 717537600 - tz.transition 1993, 3, :o6, 733266000 - tz.transition 1993, 9, :o7, 748987200 - tz.transition 1994, 3, :o6, 764715600 - tz.transition 1994, 9, :o8, 780436800 - tz.transition 1995, 3, :o9, 796161600 - tz.transition 1995, 9, :o8, 811882800 - tz.transition 1996, 3, :o9, 828216000 - tz.transition 1997, 3, :o9, 859662000 - tz.transition 1997, 10, :o8, 877806000 - tz.transition 1998, 3, :o9, 891115200 - tz.transition 1998, 10, :o8, 909255600 - tz.transition 1999, 3, :o9, 922564800 - tz.transition 1999, 10, :o8, 941310000 - tz.transition 2000, 3, :o9, 954014400 - tz.transition 2000, 10, :o8, 972759600 - tz.transition 2001, 3, :o9, 985464000 - tz.transition 2001, 10, :o8, 1004209200 - tz.transition 2002, 3, :o9, 1017518400 - tz.transition 2002, 10, :o8, 1035658800 - tz.transition 2003, 3, :o9, 1048968000 - tz.transition 2003, 10, :o8, 1067108400 - tz.transition 2004, 3, :o9, 1080417600 - tz.transition 2004, 6, :o6, 1088276400 - tz.transition 2004, 10, :o7, 1099177200 - tz.transition 2005, 3, :o8, 1111878000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb deleted file mode 100644 index d8df964a..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +++ /dev/null @@ -1,121 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tehran - include TimezoneDefinition - - timezone 'Asia/Tehran' do |tz| - tz.offset :o0, 12344, 0, :LMT - tz.offset :o1, 12344, 0, :TMT - tz.offset :o2, 12600, 0, :IRST - tz.offset :o3, 14400, 0, :IRST - tz.offset :o4, 14400, 3600, :IRDT - tz.offset :o5, 12600, 3600, :IRDT - - tz.transition 1915, 12, :o1, 26145324257, 10800 - tz.transition 1945, 12, :o2, 26263670657, 10800 - tz.transition 1977, 10, :o3, 247177800 - tz.transition 1978, 3, :o4, 259272000 - tz.transition 1978, 10, :o3, 277758000 - tz.transition 1978, 12, :o2, 283982400 - tz.transition 1979, 3, :o5, 290809800 - tz.transition 1979, 9, :o2, 306531000 - tz.transition 1980, 3, :o5, 322432200 - tz.transition 1980, 9, :o2, 338499000 - tz.transition 1991, 5, :o5, 673216200 - tz.transition 1991, 9, :o2, 685481400 - tz.transition 1992, 3, :o5, 701209800 - tz.transition 1992, 9, :o2, 717103800 - tz.transition 1993, 3, :o5, 732745800 - tz.transition 1993, 9, :o2, 748639800 - tz.transition 1994, 3, :o5, 764281800 - tz.transition 1994, 9, :o2, 780175800 - tz.transition 1995, 3, :o5, 795817800 - tz.transition 1995, 9, :o2, 811711800 - tz.transition 1996, 3, :o5, 827353800 - tz.transition 1996, 9, :o2, 843247800 - tz.transition 1997, 3, :o5, 858976200 - tz.transition 1997, 9, :o2, 874870200 - tz.transition 1998, 3, :o5, 890512200 - tz.transition 1998, 9, :o2, 906406200 - tz.transition 1999, 3, :o5, 922048200 - tz.transition 1999, 9, :o2, 937942200 - tz.transition 2000, 3, :o5, 953584200 - tz.transition 2000, 9, :o2, 969478200 - tz.transition 2001, 3, :o5, 985206600 - tz.transition 2001, 9, :o2, 1001100600 - tz.transition 2002, 3, :o5, 1016742600 - tz.transition 2002, 9, :o2, 1032636600 - tz.transition 2003, 3, :o5, 1048278600 - tz.transition 2003, 9, :o2, 1064172600 - tz.transition 2004, 3, :o5, 1079814600 - tz.transition 2004, 9, :o2, 1095708600 - tz.transition 2005, 3, :o5, 1111437000 - tz.transition 2005, 9, :o2, 1127331000 - tz.transition 2008, 3, :o5, 1206045000 - tz.transition 2008, 9, :o2, 1221939000 - tz.transition 2009, 3, :o5, 1237667400 - tz.transition 2009, 9, :o2, 1253561400 - tz.transition 2010, 3, :o5, 1269203400 - tz.transition 2010, 9, :o2, 1285097400 - tz.transition 2011, 3, :o5, 1300739400 - tz.transition 2011, 9, :o2, 1316633400 - tz.transition 2012, 3, :o5, 1332275400 - tz.transition 2012, 9, :o2, 1348169400 - tz.transition 2013, 3, :o5, 1363897800 - tz.transition 2013, 9, :o2, 1379791800 - tz.transition 2014, 3, :o5, 1395433800 - tz.transition 2014, 9, :o2, 1411327800 - tz.transition 2015, 3, :o5, 1426969800 - tz.transition 2015, 9, :o2, 1442863800 - tz.transition 2016, 3, :o5, 1458505800 - tz.transition 2016, 9, :o2, 1474399800 - tz.transition 2017, 3, :o5, 1490128200 - tz.transition 2017, 9, :o2, 1506022200 - tz.transition 2018, 3, :o5, 1521664200 - tz.transition 2018, 9, :o2, 1537558200 - tz.transition 2019, 3, :o5, 1553200200 - tz.transition 2019, 9, :o2, 1569094200 - tz.transition 2020, 3, :o5, 1584736200 - tz.transition 2020, 9, :o2, 1600630200 - tz.transition 2021, 3, :o5, 1616358600 - tz.transition 2021, 9, :o2, 1632252600 - tz.transition 2022, 3, :o5, 1647894600 - tz.transition 2022, 9, :o2, 1663788600 - tz.transition 2023, 3, :o5, 1679430600 - tz.transition 2023, 9, :o2, 1695324600 - tz.transition 2024, 3, :o5, 1710966600 - tz.transition 2024, 9, :o2, 1726860600 - tz.transition 2025, 3, :o5, 1742589000 - tz.transition 2025, 9, :o2, 1758483000 - tz.transition 2026, 3, :o5, 1774125000 - tz.transition 2026, 9, :o2, 1790019000 - tz.transition 2027, 3, :o5, 1805661000 - tz.transition 2027, 9, :o2, 1821555000 - tz.transition 2028, 3, :o5, 1837197000 - tz.transition 2028, 9, :o2, 1853091000 - tz.transition 2029, 3, :o5, 1868733000 - tz.transition 2029, 9, :o2, 1884627000 - tz.transition 2030, 3, :o5, 1900355400 - tz.transition 2030, 9, :o2, 1916249400 - tz.transition 2031, 3, :o5, 1931891400 - tz.transition 2031, 9, :o2, 1947785400 - tz.transition 2032, 3, :o5, 1963427400 - tz.transition 2032, 9, :o2, 1979321400 - tz.transition 2033, 3, :o5, 1994963400 - tz.transition 2033, 9, :o2, 2010857400 - tz.transition 2034, 3, :o5, 2026585800 - tz.transition 2034, 9, :o2, 2042479800 - tz.transition 2035, 3, :o5, 2058121800 - tz.transition 2035, 9, :o2, 2074015800 - tz.transition 2036, 3, :o5, 2089657800 - tz.transition 2036, 9, :o2, 2105551800 - tz.transition 2037, 3, :o5, 2121193800 - tz.transition 2037, 9, :o2, 2137087800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb deleted file mode 100644 index 51c9e164..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tokyo - include TimezoneDefinition - - timezone 'Asia/Tokyo' do |tz| - tz.offset :o0, 33539, 0, :LMT - tz.offset :o1, 32400, 0, :JST - tz.offset :o2, 32400, 0, :CJT - tz.offset :o3, 32400, 3600, :JDT - - tz.transition 1887, 12, :o1, 19285097, 8 - tz.transition 1895, 12, :o2, 19308473, 8 - tz.transition 1937, 12, :o1, 19431193, 8 - tz.transition 1948, 5, :o3, 58384157, 24 - tz.transition 1948, 9, :o1, 14596831, 6 - tz.transition 1949, 4, :o3, 58392221, 24 - tz.transition 1949, 9, :o1, 14599015, 6 - tz.transition 1950, 5, :o3, 58401797, 24 - tz.transition 1950, 9, :o1, 14601199, 6 - tz.transition 1951, 5, :o3, 58410533, 24 - tz.transition 1951, 9, :o1, 14603383, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb deleted file mode 100644 index 2854f5c5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Ulaanbaatar - include TimezoneDefinition - - timezone 'Asia/Ulaanbaatar' do |tz| - tz.offset :o0, 25652, 0, :LMT - tz.offset :o1, 25200, 0, :ULAT - tz.offset :o2, 28800, 0, :ULAT - tz.offset :o3, 28800, 3600, :ULAST - - tz.transition 1905, 7, :o1, 52208457187, 21600 - tz.transition 1977, 12, :o2, 252435600 - tz.transition 1983, 3, :o3, 417974400 - tz.transition 1983, 9, :o2, 433782000 - tz.transition 1984, 3, :o3, 449596800 - tz.transition 1984, 9, :o2, 465318000 - tz.transition 1985, 3, :o3, 481046400 - tz.transition 1985, 9, :o2, 496767600 - tz.transition 1986, 3, :o3, 512496000 - tz.transition 1986, 9, :o2, 528217200 - tz.transition 1987, 3, :o3, 543945600 - tz.transition 1987, 9, :o2, 559666800 - tz.transition 1988, 3, :o3, 575395200 - tz.transition 1988, 9, :o2, 591116400 - tz.transition 1989, 3, :o3, 606844800 - tz.transition 1989, 9, :o2, 622566000 - tz.transition 1990, 3, :o3, 638294400 - tz.transition 1990, 9, :o2, 654620400 - tz.transition 1991, 3, :o3, 670348800 - tz.transition 1991, 9, :o2, 686070000 - tz.transition 1992, 3, :o3, 701798400 - tz.transition 1992, 9, :o2, 717519600 - tz.transition 1993, 3, :o3, 733248000 - tz.transition 1993, 9, :o2, 748969200 - tz.transition 1994, 3, :o3, 764697600 - tz.transition 1994, 9, :o2, 780418800 - tz.transition 1995, 3, :o3, 796147200 - tz.transition 1995, 9, :o2, 811868400 - tz.transition 1996, 3, :o3, 828201600 - tz.transition 1996, 9, :o2, 843922800 - tz.transition 1997, 3, :o3, 859651200 - tz.transition 1997, 9, :o2, 875372400 - tz.transition 1998, 3, :o3, 891100800 - tz.transition 1998, 9, :o2, 906822000 - tz.transition 2001, 4, :o3, 988394400 - tz.transition 2001, 9, :o2, 1001696400 - tz.transition 2002, 3, :o3, 1017424800 - tz.transition 2002, 9, :o2, 1033146000 - tz.transition 2003, 3, :o3, 1048874400 - tz.transition 2003, 9, :o2, 1064595600 - tz.transition 2004, 3, :o3, 1080324000 - tz.transition 2004, 9, :o2, 1096045200 - tz.transition 2005, 3, :o3, 1111773600 - tz.transition 2005, 9, :o2, 1127494800 - tz.transition 2006, 3, :o3, 1143223200 - tz.transition 2006, 9, :o2, 1159549200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb deleted file mode 100644 index d793ff13..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Urumqi - include TimezoneDefinition - - timezone 'Asia/Urumqi' do |tz| - tz.offset :o0, 21020, 0, :LMT - tz.offset :o1, 21600, 0, :URUT - tz.offset :o2, 28800, 0, :CST - tz.offset :o3, 28800, 3600, :CDT - - tz.transition 1927, 12, :o1, 10477063829, 4320 - tz.transition 1980, 4, :o2, 325965600 - tz.transition 1986, 5, :o3, 515520000 - tz.transition 1986, 9, :o2, 527007600 - tz.transition 1987, 4, :o3, 545155200 - tz.transition 1987, 9, :o2, 558457200 - tz.transition 1988, 4, :o3, 576604800 - tz.transition 1988, 9, :o2, 589906800 - tz.transition 1989, 4, :o3, 608659200 - tz.transition 1989, 9, :o2, 621961200 - tz.transition 1990, 4, :o3, 640108800 - tz.transition 1990, 9, :o2, 653410800 - tz.transition 1991, 4, :o3, 671558400 - tz.transition 1991, 9, :o2, 684860400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb deleted file mode 100644 index bd9e3d60..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +++ /dev/null @@ -1,164 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Vladivostok - include TimezoneDefinition - - timezone 'Asia/Vladivostok' do |tz| - tz.offset :o0, 31664, 0, :LMT - tz.offset :o1, 32400, 0, :VLAT - tz.offset :o2, 36000, 0, :VLAT - tz.offset :o3, 36000, 3600, :VLAST - tz.offset :o4, 32400, 3600, :VLASST - tz.offset :o5, 32400, 0, :VLAST - - tz.transition 1922, 11, :o1, 13086214921, 5400 - tz.transition 1930, 6, :o2, 19409185, 8 - tz.transition 1981, 3, :o3, 354895200 - tz.transition 1981, 9, :o2, 370702800 - tz.transition 1982, 3, :o3, 386431200 - tz.transition 1982, 9, :o2, 402238800 - tz.transition 1983, 3, :o3, 417967200 - tz.transition 1983, 9, :o2, 433774800 - tz.transition 1984, 3, :o3, 449589600 - tz.transition 1984, 9, :o2, 465321600 - tz.transition 1985, 3, :o3, 481046400 - tz.transition 1985, 9, :o2, 496771200 - tz.transition 1986, 3, :o3, 512496000 - tz.transition 1986, 9, :o2, 528220800 - tz.transition 1987, 3, :o3, 543945600 - tz.transition 1987, 9, :o2, 559670400 - tz.transition 1988, 3, :o3, 575395200 - tz.transition 1988, 9, :o2, 591120000 - tz.transition 1989, 3, :o3, 606844800 - tz.transition 1989, 9, :o2, 622569600 - tz.transition 1990, 3, :o3, 638294400 - tz.transition 1990, 9, :o2, 654624000 - tz.transition 1991, 3, :o4, 670348800 - tz.transition 1991, 9, :o5, 686077200 - tz.transition 1992, 1, :o2, 695754000 - tz.transition 1992, 3, :o3, 701787600 - tz.transition 1992, 9, :o2, 717508800 - tz.transition 1993, 3, :o3, 733248000 - tz.transition 1993, 9, :o2, 748972800 - tz.transition 1994, 3, :o3, 764697600 - tz.transition 1994, 9, :o2, 780422400 - tz.transition 1995, 3, :o3, 796147200 - tz.transition 1995, 9, :o2, 811872000 - tz.transition 1996, 3, :o3, 828201600 - tz.transition 1996, 10, :o2, 846345600 - tz.transition 1997, 3, :o3, 859651200 - tz.transition 1997, 10, :o2, 877795200 - tz.transition 1998, 3, :o3, 891100800 - tz.transition 1998, 10, :o2, 909244800 - tz.transition 1999, 3, :o3, 922550400 - tz.transition 1999, 10, :o2, 941299200 - tz.transition 2000, 3, :o3, 954000000 - tz.transition 2000, 10, :o2, 972748800 - tz.transition 2001, 3, :o3, 985449600 - tz.transition 2001, 10, :o2, 1004198400 - tz.transition 2002, 3, :o3, 1017504000 - tz.transition 2002, 10, :o2, 1035648000 - tz.transition 2003, 3, :o3, 1048953600 - tz.transition 2003, 10, :o2, 1067097600 - tz.transition 2004, 3, :o3, 1080403200 - tz.transition 2004, 10, :o2, 1099152000 - tz.transition 2005, 3, :o3, 1111852800 - tz.transition 2005, 10, :o2, 1130601600 - tz.transition 2006, 3, :o3, 1143302400 - tz.transition 2006, 10, :o2, 1162051200 - tz.transition 2007, 3, :o3, 1174752000 - tz.transition 2007, 10, :o2, 1193500800 - tz.transition 2008, 3, :o3, 1206806400 - tz.transition 2008, 10, :o2, 1224950400 - tz.transition 2009, 3, :o3, 1238256000 - tz.transition 2009, 10, :o2, 1256400000 - tz.transition 2010, 3, :o3, 1269705600 - tz.transition 2010, 10, :o2, 1288454400 - tz.transition 2011, 3, :o3, 1301155200 - tz.transition 2011, 10, :o2, 1319904000 - tz.transition 2012, 3, :o3, 1332604800 - tz.transition 2012, 10, :o2, 1351353600 - tz.transition 2013, 3, :o3, 1364659200 - tz.transition 2013, 10, :o2, 1382803200 - tz.transition 2014, 3, :o3, 1396108800 - tz.transition 2014, 10, :o2, 1414252800 - tz.transition 2015, 3, :o3, 1427558400 - tz.transition 2015, 10, :o2, 1445702400 - tz.transition 2016, 3, :o3, 1459008000 - tz.transition 2016, 10, :o2, 1477756800 - tz.transition 2017, 3, :o3, 1490457600 - tz.transition 2017, 10, :o2, 1509206400 - tz.transition 2018, 3, :o3, 1521907200 - tz.transition 2018, 10, :o2, 1540656000 - tz.transition 2019, 3, :o3, 1553961600 - tz.transition 2019, 10, :o2, 1572105600 - tz.transition 2020, 3, :o3, 1585411200 - tz.transition 2020, 10, :o2, 1603555200 - tz.transition 2021, 3, :o3, 1616860800 - tz.transition 2021, 10, :o2, 1635609600 - tz.transition 2022, 3, :o3, 1648310400 - tz.transition 2022, 10, :o2, 1667059200 - tz.transition 2023, 3, :o3, 1679760000 - tz.transition 2023, 10, :o2, 1698508800 - tz.transition 2024, 3, :o3, 1711814400 - tz.transition 2024, 10, :o2, 1729958400 - tz.transition 2025, 3, :o3, 1743264000 - tz.transition 2025, 10, :o2, 1761408000 - tz.transition 2026, 3, :o3, 1774713600 - tz.transition 2026, 10, :o2, 1792857600 - tz.transition 2027, 3, :o3, 1806163200 - tz.transition 2027, 10, :o2, 1824912000 - tz.transition 2028, 3, :o3, 1837612800 - tz.transition 2028, 10, :o2, 1856361600 - tz.transition 2029, 3, :o3, 1869062400 - tz.transition 2029, 10, :o2, 1887811200 - tz.transition 2030, 3, :o3, 1901116800 - tz.transition 2030, 10, :o2, 1919260800 - tz.transition 2031, 3, :o3, 1932566400 - tz.transition 2031, 10, :o2, 1950710400 - tz.transition 2032, 3, :o3, 1964016000 - tz.transition 2032, 10, :o2, 1982764800 - tz.transition 2033, 3, :o3, 1995465600 - tz.transition 2033, 10, :o2, 2014214400 - tz.transition 2034, 3, :o3, 2026915200 - tz.transition 2034, 10, :o2, 2045664000 - tz.transition 2035, 3, :o3, 2058364800 - tz.transition 2035, 10, :o2, 2077113600 - tz.transition 2036, 3, :o3, 2090419200 - tz.transition 2036, 10, :o2, 2108563200 - tz.transition 2037, 3, :o3, 2121868800 - tz.transition 2037, 10, :o2, 2140012800 - tz.transition 2038, 3, :o3, 14793061, 6 - tz.transition 2038, 10, :o2, 14794363, 6 - tz.transition 2039, 3, :o3, 14795245, 6 - tz.transition 2039, 10, :o2, 14796547, 6 - tz.transition 2040, 3, :o3, 14797429, 6 - tz.transition 2040, 10, :o2, 14798731, 6 - tz.transition 2041, 3, :o3, 14799655, 6 - tz.transition 2041, 10, :o2, 14800915, 6 - tz.transition 2042, 3, :o3, 14801839, 6 - tz.transition 2042, 10, :o2, 14803099, 6 - tz.transition 2043, 3, :o3, 14804023, 6 - tz.transition 2043, 10, :o2, 14805283, 6 - tz.transition 2044, 3, :o3, 14806207, 6 - tz.transition 2044, 10, :o2, 14807509, 6 - tz.transition 2045, 3, :o3, 14808391, 6 - tz.transition 2045, 10, :o2, 14809693, 6 - tz.transition 2046, 3, :o3, 14810575, 6 - tz.transition 2046, 10, :o2, 14811877, 6 - tz.transition 2047, 3, :o3, 14812801, 6 - tz.transition 2047, 10, :o2, 14814061, 6 - tz.transition 2048, 3, :o3, 14814985, 6 - tz.transition 2048, 10, :o2, 14816245, 6 - tz.transition 2049, 3, :o3, 14817169, 6 - tz.transition 2049, 10, :o2, 14818471, 6 - tz.transition 2050, 3, :o3, 14819353, 6 - tz.transition 2050, 10, :o2, 14820655, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb deleted file mode 100644 index 56435a78..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Yakutsk - include TimezoneDefinition - - timezone 'Asia/Yakutsk' do |tz| - tz.offset :o0, 31120, 0, :LMT - tz.offset :o1, 28800, 0, :YAKT - tz.offset :o2, 32400, 0, :YAKT - tz.offset :o3, 32400, 3600, :YAKST - tz.offset :o4, 28800, 3600, :YAKST - - tz.transition 1919, 12, :o1, 2616091711, 1080 - tz.transition 1930, 6, :o2, 14556889, 6 - tz.transition 1981, 3, :o3, 354898800 - tz.transition 1981, 9, :o2, 370706400 - tz.transition 1982, 3, :o3, 386434800 - tz.transition 1982, 9, :o2, 402242400 - tz.transition 1983, 3, :o3, 417970800 - tz.transition 1983, 9, :o2, 433778400 - tz.transition 1984, 3, :o3, 449593200 - tz.transition 1984, 9, :o2, 465325200 - tz.transition 1985, 3, :o3, 481050000 - tz.transition 1985, 9, :o2, 496774800 - tz.transition 1986, 3, :o3, 512499600 - tz.transition 1986, 9, :o2, 528224400 - tz.transition 1987, 3, :o3, 543949200 - tz.transition 1987, 9, :o2, 559674000 - tz.transition 1988, 3, :o3, 575398800 - tz.transition 1988, 9, :o2, 591123600 - tz.transition 1989, 3, :o3, 606848400 - tz.transition 1989, 9, :o2, 622573200 - tz.transition 1990, 3, :o3, 638298000 - tz.transition 1990, 9, :o2, 654627600 - tz.transition 1991, 3, :o4, 670352400 - tz.transition 1991, 9, :o1, 686080800 - tz.transition 1992, 1, :o2, 695757600 - tz.transition 1992, 3, :o3, 701791200 - tz.transition 1992, 9, :o2, 717512400 - tz.transition 1993, 3, :o3, 733251600 - tz.transition 1993, 9, :o2, 748976400 - tz.transition 1994, 3, :o3, 764701200 - tz.transition 1994, 9, :o2, 780426000 - tz.transition 1995, 3, :o3, 796150800 - tz.transition 1995, 9, :o2, 811875600 - tz.transition 1996, 3, :o3, 828205200 - tz.transition 1996, 10, :o2, 846349200 - tz.transition 1997, 3, :o3, 859654800 - tz.transition 1997, 10, :o2, 877798800 - tz.transition 1998, 3, :o3, 891104400 - tz.transition 1998, 10, :o2, 909248400 - tz.transition 1999, 3, :o3, 922554000 - tz.transition 1999, 10, :o2, 941302800 - tz.transition 2000, 3, :o3, 954003600 - tz.transition 2000, 10, :o2, 972752400 - tz.transition 2001, 3, :o3, 985453200 - tz.transition 2001, 10, :o2, 1004202000 - tz.transition 2002, 3, :o3, 1017507600 - tz.transition 2002, 10, :o2, 1035651600 - tz.transition 2003, 3, :o3, 1048957200 - tz.transition 2003, 10, :o2, 1067101200 - tz.transition 2004, 3, :o3, 1080406800 - tz.transition 2004, 10, :o2, 1099155600 - tz.transition 2005, 3, :o3, 1111856400 - tz.transition 2005, 10, :o2, 1130605200 - tz.transition 2006, 3, :o3, 1143306000 - tz.transition 2006, 10, :o2, 1162054800 - tz.transition 2007, 3, :o3, 1174755600 - tz.transition 2007, 10, :o2, 1193504400 - tz.transition 2008, 3, :o3, 1206810000 - tz.transition 2008, 10, :o2, 1224954000 - tz.transition 2009, 3, :o3, 1238259600 - tz.transition 2009, 10, :o2, 1256403600 - tz.transition 2010, 3, :o3, 1269709200 - tz.transition 2010, 10, :o2, 1288458000 - tz.transition 2011, 3, :o3, 1301158800 - tz.transition 2011, 10, :o2, 1319907600 - tz.transition 2012, 3, :o3, 1332608400 - tz.transition 2012, 10, :o2, 1351357200 - tz.transition 2013, 3, :o3, 1364662800 - tz.transition 2013, 10, :o2, 1382806800 - tz.transition 2014, 3, :o3, 1396112400 - tz.transition 2014, 10, :o2, 1414256400 - tz.transition 2015, 3, :o3, 1427562000 - tz.transition 2015, 10, :o2, 1445706000 - tz.transition 2016, 3, :o3, 1459011600 - tz.transition 2016, 10, :o2, 1477760400 - tz.transition 2017, 3, :o3, 1490461200 - tz.transition 2017, 10, :o2, 1509210000 - tz.transition 2018, 3, :o3, 1521910800 - tz.transition 2018, 10, :o2, 1540659600 - tz.transition 2019, 3, :o3, 1553965200 - tz.transition 2019, 10, :o2, 1572109200 - tz.transition 2020, 3, :o3, 1585414800 - tz.transition 2020, 10, :o2, 1603558800 - tz.transition 2021, 3, :o3, 1616864400 - tz.transition 2021, 10, :o2, 1635613200 - tz.transition 2022, 3, :o3, 1648314000 - tz.transition 2022, 10, :o2, 1667062800 - tz.transition 2023, 3, :o3, 1679763600 - tz.transition 2023, 10, :o2, 1698512400 - tz.transition 2024, 3, :o3, 1711818000 - tz.transition 2024, 10, :o2, 1729962000 - tz.transition 2025, 3, :o3, 1743267600 - tz.transition 2025, 10, :o2, 1761411600 - tz.transition 2026, 3, :o3, 1774717200 - tz.transition 2026, 10, :o2, 1792861200 - tz.transition 2027, 3, :o3, 1806166800 - tz.transition 2027, 10, :o2, 1824915600 - tz.transition 2028, 3, :o3, 1837616400 - tz.transition 2028, 10, :o2, 1856365200 - tz.transition 2029, 3, :o3, 1869066000 - tz.transition 2029, 10, :o2, 1887814800 - tz.transition 2030, 3, :o3, 1901120400 - tz.transition 2030, 10, :o2, 1919264400 - tz.transition 2031, 3, :o3, 1932570000 - tz.transition 2031, 10, :o2, 1950714000 - tz.transition 2032, 3, :o3, 1964019600 - tz.transition 2032, 10, :o2, 1982768400 - tz.transition 2033, 3, :o3, 1995469200 - tz.transition 2033, 10, :o2, 2014218000 - tz.transition 2034, 3, :o3, 2026918800 - tz.transition 2034, 10, :o2, 2045667600 - tz.transition 2035, 3, :o3, 2058368400 - tz.transition 2035, 10, :o2, 2077117200 - tz.transition 2036, 3, :o3, 2090422800 - tz.transition 2036, 10, :o2, 2108566800 - tz.transition 2037, 3, :o3, 2121872400 - tz.transition 2037, 10, :o2, 2140016400 - tz.transition 2038, 3, :o3, 59172245, 24 - tz.transition 2038, 10, :o2, 59177453, 24 - tz.transition 2039, 3, :o3, 59180981, 24 - tz.transition 2039, 10, :o2, 59186189, 24 - tz.transition 2040, 3, :o3, 59189717, 24 - tz.transition 2040, 10, :o2, 59194925, 24 - tz.transition 2041, 3, :o3, 59198621, 24 - tz.transition 2041, 10, :o2, 59203661, 24 - tz.transition 2042, 3, :o3, 59207357, 24 - tz.transition 2042, 10, :o2, 59212397, 24 - tz.transition 2043, 3, :o3, 59216093, 24 - tz.transition 2043, 10, :o2, 59221133, 24 - tz.transition 2044, 3, :o3, 59224829, 24 - tz.transition 2044, 10, :o2, 59230037, 24 - tz.transition 2045, 3, :o3, 59233565, 24 - tz.transition 2045, 10, :o2, 59238773, 24 - tz.transition 2046, 3, :o3, 59242301, 24 - tz.transition 2046, 10, :o2, 59247509, 24 - tz.transition 2047, 3, :o3, 59251205, 24 - tz.transition 2047, 10, :o2, 59256245, 24 - tz.transition 2048, 3, :o3, 59259941, 24 - tz.transition 2048, 10, :o2, 59264981, 24 - tz.transition 2049, 3, :o3, 59268677, 24 - tz.transition 2049, 10, :o2, 59273885, 24 - tz.transition 2050, 3, :o3, 59277413, 24 - tz.transition 2050, 10, :o2, 59282621, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb deleted file mode 100644 index 8ef8df4a..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Yekaterinburg - include TimezoneDefinition - - timezone 'Asia/Yekaterinburg' do |tz| - tz.offset :o0, 14544, 0, :LMT - tz.offset :o1, 14400, 0, :SVET - tz.offset :o2, 18000, 0, :SVET - tz.offset :o3, 18000, 3600, :SVEST - tz.offset :o4, 14400, 3600, :SVEST - tz.offset :o5, 18000, 0, :YEKT - tz.offset :o6, 18000, 3600, :YEKST - - tz.transition 1919, 7, :o1, 1453292699, 600 - tz.transition 1930, 6, :o2, 7278445, 3 - tz.transition 1981, 3, :o3, 354913200 - tz.transition 1981, 9, :o2, 370720800 - tz.transition 1982, 3, :o3, 386449200 - tz.transition 1982, 9, :o2, 402256800 - tz.transition 1983, 3, :o3, 417985200 - tz.transition 1983, 9, :o2, 433792800 - tz.transition 1984, 3, :o3, 449607600 - tz.transition 1984, 9, :o2, 465339600 - tz.transition 1985, 3, :o3, 481064400 - tz.transition 1985, 9, :o2, 496789200 - tz.transition 1986, 3, :o3, 512514000 - tz.transition 1986, 9, :o2, 528238800 - tz.transition 1987, 3, :o3, 543963600 - tz.transition 1987, 9, :o2, 559688400 - tz.transition 1988, 3, :o3, 575413200 - tz.transition 1988, 9, :o2, 591138000 - tz.transition 1989, 3, :o3, 606862800 - tz.transition 1989, 9, :o2, 622587600 - tz.transition 1990, 3, :o3, 638312400 - tz.transition 1990, 9, :o2, 654642000 - tz.transition 1991, 3, :o4, 670366800 - tz.transition 1991, 9, :o1, 686095200 - tz.transition 1992, 1, :o5, 695772000 - tz.transition 1992, 3, :o6, 701805600 - tz.transition 1992, 9, :o5, 717526800 - tz.transition 1993, 3, :o6, 733266000 - tz.transition 1993, 9, :o5, 748990800 - tz.transition 1994, 3, :o6, 764715600 - tz.transition 1994, 9, :o5, 780440400 - tz.transition 1995, 3, :o6, 796165200 - tz.transition 1995, 9, :o5, 811890000 - tz.transition 1996, 3, :o6, 828219600 - tz.transition 1996, 10, :o5, 846363600 - tz.transition 1997, 3, :o6, 859669200 - tz.transition 1997, 10, :o5, 877813200 - tz.transition 1998, 3, :o6, 891118800 - tz.transition 1998, 10, :o5, 909262800 - tz.transition 1999, 3, :o6, 922568400 - tz.transition 1999, 10, :o5, 941317200 - tz.transition 2000, 3, :o6, 954018000 - tz.transition 2000, 10, :o5, 972766800 - tz.transition 2001, 3, :o6, 985467600 - tz.transition 2001, 10, :o5, 1004216400 - tz.transition 2002, 3, :o6, 1017522000 - tz.transition 2002, 10, :o5, 1035666000 - tz.transition 2003, 3, :o6, 1048971600 - tz.transition 2003, 10, :o5, 1067115600 - tz.transition 2004, 3, :o6, 1080421200 - tz.transition 2004, 10, :o5, 1099170000 - tz.transition 2005, 3, :o6, 1111870800 - tz.transition 2005, 10, :o5, 1130619600 - tz.transition 2006, 3, :o6, 1143320400 - tz.transition 2006, 10, :o5, 1162069200 - tz.transition 2007, 3, :o6, 1174770000 - tz.transition 2007, 10, :o5, 1193518800 - tz.transition 2008, 3, :o6, 1206824400 - tz.transition 2008, 10, :o5, 1224968400 - tz.transition 2009, 3, :o6, 1238274000 - tz.transition 2009, 10, :o5, 1256418000 - tz.transition 2010, 3, :o6, 1269723600 - tz.transition 2010, 10, :o5, 1288472400 - tz.transition 2011, 3, :o6, 1301173200 - tz.transition 2011, 10, :o5, 1319922000 - tz.transition 2012, 3, :o6, 1332622800 - tz.transition 2012, 10, :o5, 1351371600 - tz.transition 2013, 3, :o6, 1364677200 - tz.transition 2013, 10, :o5, 1382821200 - tz.transition 2014, 3, :o6, 1396126800 - tz.transition 2014, 10, :o5, 1414270800 - tz.transition 2015, 3, :o6, 1427576400 - tz.transition 2015, 10, :o5, 1445720400 - tz.transition 2016, 3, :o6, 1459026000 - tz.transition 2016, 10, :o5, 1477774800 - tz.transition 2017, 3, :o6, 1490475600 - tz.transition 2017, 10, :o5, 1509224400 - tz.transition 2018, 3, :o6, 1521925200 - tz.transition 2018, 10, :o5, 1540674000 - tz.transition 2019, 3, :o6, 1553979600 - tz.transition 2019, 10, :o5, 1572123600 - tz.transition 2020, 3, :o6, 1585429200 - tz.transition 2020, 10, :o5, 1603573200 - tz.transition 2021, 3, :o6, 1616878800 - tz.transition 2021, 10, :o5, 1635627600 - tz.transition 2022, 3, :o6, 1648328400 - tz.transition 2022, 10, :o5, 1667077200 - tz.transition 2023, 3, :o6, 1679778000 - tz.transition 2023, 10, :o5, 1698526800 - tz.transition 2024, 3, :o6, 1711832400 - tz.transition 2024, 10, :o5, 1729976400 - tz.transition 2025, 3, :o6, 1743282000 - tz.transition 2025, 10, :o5, 1761426000 - tz.transition 2026, 3, :o6, 1774731600 - tz.transition 2026, 10, :o5, 1792875600 - tz.transition 2027, 3, :o6, 1806181200 - tz.transition 2027, 10, :o5, 1824930000 - tz.transition 2028, 3, :o6, 1837630800 - tz.transition 2028, 10, :o5, 1856379600 - tz.transition 2029, 3, :o6, 1869080400 - tz.transition 2029, 10, :o5, 1887829200 - tz.transition 2030, 3, :o6, 1901134800 - tz.transition 2030, 10, :o5, 1919278800 - tz.transition 2031, 3, :o6, 1932584400 - tz.transition 2031, 10, :o5, 1950728400 - tz.transition 2032, 3, :o6, 1964034000 - tz.transition 2032, 10, :o5, 1982782800 - tz.transition 2033, 3, :o6, 1995483600 - tz.transition 2033, 10, :o5, 2014232400 - tz.transition 2034, 3, :o6, 2026933200 - tz.transition 2034, 10, :o5, 2045682000 - tz.transition 2035, 3, :o6, 2058382800 - tz.transition 2035, 10, :o5, 2077131600 - tz.transition 2036, 3, :o6, 2090437200 - tz.transition 2036, 10, :o5, 2108581200 - tz.transition 2037, 3, :o6, 2121886800 - tz.transition 2037, 10, :o5, 2140030800 - tz.transition 2038, 3, :o6, 19724083, 8 - tz.transition 2038, 10, :o5, 19725819, 8 - tz.transition 2039, 3, :o6, 19726995, 8 - tz.transition 2039, 10, :o5, 19728731, 8 - tz.transition 2040, 3, :o6, 19729907, 8 - tz.transition 2040, 10, :o5, 19731643, 8 - tz.transition 2041, 3, :o6, 19732875, 8 - tz.transition 2041, 10, :o5, 19734555, 8 - tz.transition 2042, 3, :o6, 19735787, 8 - tz.transition 2042, 10, :o5, 19737467, 8 - tz.transition 2043, 3, :o6, 19738699, 8 - tz.transition 2043, 10, :o5, 19740379, 8 - tz.transition 2044, 3, :o6, 19741611, 8 - tz.transition 2044, 10, :o5, 19743347, 8 - tz.transition 2045, 3, :o6, 19744523, 8 - tz.transition 2045, 10, :o5, 19746259, 8 - tz.transition 2046, 3, :o6, 19747435, 8 - tz.transition 2046, 10, :o5, 19749171, 8 - tz.transition 2047, 3, :o6, 19750403, 8 - tz.transition 2047, 10, :o5, 19752083, 8 - tz.transition 2048, 3, :o6, 19753315, 8 - tz.transition 2048, 10, :o5, 19754995, 8 - tz.transition 2049, 3, :o6, 19756227, 8 - tz.transition 2049, 10, :o5, 19757963, 8 - tz.transition 2050, 3, :o6, 19759139, 8 - tz.transition 2050, 10, :o5, 19760875, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb deleted file mode 100644 index e7f16086..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Yerevan - include TimezoneDefinition - - timezone 'Asia/Yerevan' do |tz| - tz.offset :o0, 10680, 0, :LMT - tz.offset :o1, 10800, 0, :YERT - tz.offset :o2, 14400, 0, :YERT - tz.offset :o3, 14400, 3600, :YERST - tz.offset :o4, 10800, 3600, :YERST - tz.offset :o5, 10800, 3600, :AMST - tz.offset :o6, 10800, 0, :AMT - tz.offset :o7, 14400, 0, :AMT - tz.offset :o8, 14400, 3600, :AMST - - tz.transition 1924, 5, :o1, 1745213311, 720 - tz.transition 1957, 2, :o2, 19487187, 8 - tz.transition 1981, 3, :o3, 354916800 - tz.transition 1981, 9, :o2, 370724400 - tz.transition 1982, 3, :o3, 386452800 - tz.transition 1982, 9, :o2, 402260400 - tz.transition 1983, 3, :o3, 417988800 - tz.transition 1983, 9, :o2, 433796400 - tz.transition 1984, 3, :o3, 449611200 - tz.transition 1984, 9, :o2, 465343200 - tz.transition 1985, 3, :o3, 481068000 - tz.transition 1985, 9, :o2, 496792800 - tz.transition 1986, 3, :o3, 512517600 - tz.transition 1986, 9, :o2, 528242400 - tz.transition 1987, 3, :o3, 543967200 - tz.transition 1987, 9, :o2, 559692000 - tz.transition 1988, 3, :o3, 575416800 - tz.transition 1988, 9, :o2, 591141600 - tz.transition 1989, 3, :o3, 606866400 - tz.transition 1989, 9, :o2, 622591200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 9, :o2, 654645600 - tz.transition 1991, 3, :o4, 670370400 - tz.transition 1991, 9, :o5, 685569600 - tz.transition 1991, 9, :o6, 686098800 - tz.transition 1992, 3, :o5, 701812800 - tz.transition 1992, 9, :o6, 717534000 - tz.transition 1993, 3, :o5, 733273200 - tz.transition 1993, 9, :o6, 748998000 - tz.transition 1994, 3, :o5, 764722800 - tz.transition 1994, 9, :o6, 780447600 - tz.transition 1995, 3, :o5, 796172400 - tz.transition 1995, 9, :o7, 811897200 - tz.transition 1997, 3, :o8, 859672800 - tz.transition 1997, 10, :o7, 877816800 - tz.transition 1998, 3, :o8, 891122400 - tz.transition 1998, 10, :o7, 909266400 - tz.transition 1999, 3, :o8, 922572000 - tz.transition 1999, 10, :o7, 941320800 - tz.transition 2000, 3, :o8, 954021600 - tz.transition 2000, 10, :o7, 972770400 - tz.transition 2001, 3, :o8, 985471200 - tz.transition 2001, 10, :o7, 1004220000 - tz.transition 2002, 3, :o8, 1017525600 - tz.transition 2002, 10, :o7, 1035669600 - tz.transition 2003, 3, :o8, 1048975200 - tz.transition 2003, 10, :o7, 1067119200 - tz.transition 2004, 3, :o8, 1080424800 - tz.transition 2004, 10, :o7, 1099173600 - tz.transition 2005, 3, :o8, 1111874400 - tz.transition 2005, 10, :o7, 1130623200 - tz.transition 2006, 3, :o8, 1143324000 - tz.transition 2006, 10, :o7, 1162072800 - tz.transition 2007, 3, :o8, 1174773600 - tz.transition 2007, 10, :o7, 1193522400 - tz.transition 2008, 3, :o8, 1206828000 - tz.transition 2008, 10, :o7, 1224972000 - tz.transition 2009, 3, :o8, 1238277600 - tz.transition 2009, 10, :o7, 1256421600 - tz.transition 2010, 3, :o8, 1269727200 - tz.transition 2010, 10, :o7, 1288476000 - tz.transition 2011, 3, :o8, 1301176800 - tz.transition 2011, 10, :o7, 1319925600 - tz.transition 2012, 3, :o8, 1332626400 - tz.transition 2012, 10, :o7, 1351375200 - tz.transition 2013, 3, :o8, 1364680800 - tz.transition 2013, 10, :o7, 1382824800 - tz.transition 2014, 3, :o8, 1396130400 - tz.transition 2014, 10, :o7, 1414274400 - tz.transition 2015, 3, :o8, 1427580000 - tz.transition 2015, 10, :o7, 1445724000 - tz.transition 2016, 3, :o8, 1459029600 - tz.transition 2016, 10, :o7, 1477778400 - tz.transition 2017, 3, :o8, 1490479200 - tz.transition 2017, 10, :o7, 1509228000 - tz.transition 2018, 3, :o8, 1521928800 - tz.transition 2018, 10, :o7, 1540677600 - tz.transition 2019, 3, :o8, 1553983200 - tz.transition 2019, 10, :o7, 1572127200 - tz.transition 2020, 3, :o8, 1585432800 - tz.transition 2020, 10, :o7, 1603576800 - tz.transition 2021, 3, :o8, 1616882400 - tz.transition 2021, 10, :o7, 1635631200 - tz.transition 2022, 3, :o8, 1648332000 - tz.transition 2022, 10, :o7, 1667080800 - tz.transition 2023, 3, :o8, 1679781600 - tz.transition 2023, 10, :o7, 1698530400 - tz.transition 2024, 3, :o8, 1711836000 - tz.transition 2024, 10, :o7, 1729980000 - tz.transition 2025, 3, :o8, 1743285600 - tz.transition 2025, 10, :o7, 1761429600 - tz.transition 2026, 3, :o8, 1774735200 - tz.transition 2026, 10, :o7, 1792879200 - tz.transition 2027, 3, :o8, 1806184800 - tz.transition 2027, 10, :o7, 1824933600 - tz.transition 2028, 3, :o8, 1837634400 - tz.transition 2028, 10, :o7, 1856383200 - tz.transition 2029, 3, :o8, 1869084000 - tz.transition 2029, 10, :o7, 1887832800 - tz.transition 2030, 3, :o8, 1901138400 - tz.transition 2030, 10, :o7, 1919282400 - tz.transition 2031, 3, :o8, 1932588000 - tz.transition 2031, 10, :o7, 1950732000 - tz.transition 2032, 3, :o8, 1964037600 - tz.transition 2032, 10, :o7, 1982786400 - tz.transition 2033, 3, :o8, 1995487200 - tz.transition 2033, 10, :o7, 2014236000 - tz.transition 2034, 3, :o8, 2026936800 - tz.transition 2034, 10, :o7, 2045685600 - tz.transition 2035, 3, :o8, 2058386400 - tz.transition 2035, 10, :o7, 2077135200 - tz.transition 2036, 3, :o8, 2090440800 - tz.transition 2036, 10, :o7, 2108584800 - tz.transition 2037, 3, :o8, 2121890400 - tz.transition 2037, 10, :o7, 2140034400 - tz.transition 2038, 3, :o8, 29586125, 12 - tz.transition 2038, 10, :o7, 29588729, 12 - tz.transition 2039, 3, :o8, 29590493, 12 - tz.transition 2039, 10, :o7, 29593097, 12 - tz.transition 2040, 3, :o8, 29594861, 12 - tz.transition 2040, 10, :o7, 29597465, 12 - tz.transition 2041, 3, :o8, 29599313, 12 - tz.transition 2041, 10, :o7, 29601833, 12 - tz.transition 2042, 3, :o8, 29603681, 12 - tz.transition 2042, 10, :o7, 29606201, 12 - tz.transition 2043, 3, :o8, 29608049, 12 - tz.transition 2043, 10, :o7, 29610569, 12 - tz.transition 2044, 3, :o8, 29612417, 12 - tz.transition 2044, 10, :o7, 29615021, 12 - tz.transition 2045, 3, :o8, 29616785, 12 - tz.transition 2045, 10, :o7, 29619389, 12 - tz.transition 2046, 3, :o8, 29621153, 12 - tz.transition 2046, 10, :o7, 29623757, 12 - tz.transition 2047, 3, :o8, 29625605, 12 - tz.transition 2047, 10, :o7, 29628125, 12 - tz.transition 2048, 3, :o8, 29629973, 12 - tz.transition 2048, 10, :o7, 29632493, 12 - tz.transition 2049, 3, :o8, 29634341, 12 - tz.transition 2049, 10, :o7, 29636945, 12 - tz.transition 2050, 3, :o8, 29638709, 12 - tz.transition 2050, 10, :o7, 29641313, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb deleted file mode 100644 index 1bd16a75..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +++ /dev/null @@ -1,270 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Atlantic - module Azores - include TimezoneDefinition - - timezone 'Atlantic/Azores' do |tz| - tz.offset :o0, -6160, 0, :LMT - tz.offset :o1, -6872, 0, :HMT - tz.offset :o2, -7200, 0, :AZOT - tz.offset :o3, -7200, 3600, :AZOST - tz.offset :o4, -7200, 7200, :AZOMT - tz.offset :o5, -3600, 0, :AZOT - tz.offset :o6, -3600, 3600, :AZOST - tz.offset :o7, 0, 0, :WET - - tz.transition 1884, 1, :o1, 2601910697, 1080 - tz.transition 1911, 5, :o2, 26127150259, 10800 - tz.transition 1916, 6, :o3, 58104781, 24 - tz.transition 1916, 11, :o2, 29054023, 12 - tz.transition 1917, 3, :o3, 58110925, 24 - tz.transition 1917, 10, :o2, 58116397, 24 - tz.transition 1918, 3, :o3, 58119709, 24 - tz.transition 1918, 10, :o2, 58125157, 24 - tz.transition 1919, 3, :o3, 58128445, 24 - tz.transition 1919, 10, :o2, 58133917, 24 - tz.transition 1920, 3, :o3, 58137229, 24 - tz.transition 1920, 10, :o2, 58142701, 24 - tz.transition 1921, 3, :o3, 58145989, 24 - tz.transition 1921, 10, :o2, 58151461, 24 - tz.transition 1924, 4, :o3, 58173421, 24 - tz.transition 1924, 10, :o2, 58177765, 24 - tz.transition 1926, 4, :o3, 58190965, 24 - tz.transition 1926, 10, :o2, 58194997, 24 - tz.transition 1927, 4, :o3, 58199533, 24 - tz.transition 1927, 10, :o2, 58203733, 24 - tz.transition 1928, 4, :o3, 58208437, 24 - tz.transition 1928, 10, :o2, 58212637, 24 - tz.transition 1929, 4, :o3, 58217341, 24 - tz.transition 1929, 10, :o2, 58221373, 24 - tz.transition 1931, 4, :o3, 58234813, 24 - tz.transition 1931, 10, :o2, 58238845, 24 - tz.transition 1932, 4, :o3, 58243213, 24 - tz.transition 1932, 10, :o2, 58247581, 24 - tz.transition 1934, 4, :o3, 58260853, 24 - tz.transition 1934, 10, :o2, 58265221, 24 - tz.transition 1935, 3, :o3, 58269421, 24 - tz.transition 1935, 10, :o2, 58273957, 24 - tz.transition 1936, 4, :o3, 58278661, 24 - tz.transition 1936, 10, :o2, 58282693, 24 - tz.transition 1937, 4, :o3, 58287061, 24 - tz.transition 1937, 10, :o2, 58291429, 24 - tz.transition 1938, 3, :o3, 58295629, 24 - tz.transition 1938, 10, :o2, 58300165, 24 - tz.transition 1939, 4, :o3, 58304869, 24 - tz.transition 1939, 11, :o2, 58310077, 24 - tz.transition 1940, 2, :o3, 58312429, 24 - tz.transition 1940, 10, :o2, 58317805, 24 - tz.transition 1941, 4, :o3, 58322173, 24 - tz.transition 1941, 10, :o2, 58326565, 24 - tz.transition 1942, 3, :o3, 58330405, 24 - tz.transition 1942, 4, :o4, 4860951, 2 - tz.transition 1942, 8, :o3, 4861175, 2 - tz.transition 1942, 10, :o2, 58335781, 24 - tz.transition 1943, 3, :o3, 58339141, 24 - tz.transition 1943, 4, :o4, 4861665, 2 - tz.transition 1943, 8, :o3, 4861931, 2 - tz.transition 1943, 10, :o2, 58344685, 24 - tz.transition 1944, 3, :o3, 58347877, 24 - tz.transition 1944, 4, :o4, 4862407, 2 - tz.transition 1944, 8, :o3, 4862659, 2 - tz.transition 1944, 10, :o2, 58353421, 24 - tz.transition 1945, 3, :o3, 58356613, 24 - tz.transition 1945, 4, :o4, 4863135, 2 - tz.transition 1945, 8, :o3, 4863387, 2 - tz.transition 1945, 10, :o2, 58362157, 24 - tz.transition 1946, 4, :o3, 58366021, 24 - tz.transition 1946, 10, :o2, 58370389, 24 - tz.transition 1947, 4, :o3, 7296845, 3 - tz.transition 1947, 10, :o2, 7297391, 3 - tz.transition 1948, 4, :o3, 7297937, 3 - tz.transition 1948, 10, :o2, 7298483, 3 - tz.transition 1949, 4, :o3, 7299029, 3 - tz.transition 1949, 10, :o2, 7299575, 3 - tz.transition 1951, 4, :o3, 7301213, 3 - tz.transition 1951, 10, :o2, 7301780, 3 - tz.transition 1952, 4, :o3, 7302326, 3 - tz.transition 1952, 10, :o2, 7302872, 3 - tz.transition 1953, 4, :o3, 7303418, 3 - tz.transition 1953, 10, :o2, 7303964, 3 - tz.transition 1954, 4, :o3, 7304510, 3 - tz.transition 1954, 10, :o2, 7305056, 3 - tz.transition 1955, 4, :o3, 7305602, 3 - tz.transition 1955, 10, :o2, 7306148, 3 - tz.transition 1956, 4, :o3, 7306694, 3 - tz.transition 1956, 10, :o2, 7307261, 3 - tz.transition 1957, 4, :o3, 7307807, 3 - tz.transition 1957, 10, :o2, 7308353, 3 - tz.transition 1958, 4, :o3, 7308899, 3 - tz.transition 1958, 10, :o2, 7309445, 3 - tz.transition 1959, 4, :o3, 7309991, 3 - tz.transition 1959, 10, :o2, 7310537, 3 - tz.transition 1960, 4, :o3, 7311083, 3 - tz.transition 1960, 10, :o2, 7311629, 3 - tz.transition 1961, 4, :o3, 7312175, 3 - tz.transition 1961, 10, :o2, 7312721, 3 - tz.transition 1962, 4, :o3, 7313267, 3 - tz.transition 1962, 10, :o2, 7313834, 3 - tz.transition 1963, 4, :o3, 7314380, 3 - tz.transition 1963, 10, :o2, 7314926, 3 - tz.transition 1964, 4, :o3, 7315472, 3 - tz.transition 1964, 10, :o2, 7316018, 3 - tz.transition 1965, 4, :o3, 7316564, 3 - tz.transition 1965, 10, :o2, 7317110, 3 - tz.transition 1966, 4, :o5, 7317656, 3 - tz.transition 1977, 3, :o6, 228272400 - tz.transition 1977, 9, :o5, 243997200 - tz.transition 1978, 4, :o6, 260326800 - tz.transition 1978, 10, :o5, 276051600 - tz.transition 1979, 4, :o6, 291776400 - tz.transition 1979, 9, :o5, 307504800 - tz.transition 1980, 3, :o6, 323226000 - tz.transition 1980, 9, :o5, 338954400 - tz.transition 1981, 3, :o6, 354679200 - tz.transition 1981, 9, :o5, 370404000 - tz.transition 1982, 3, :o6, 386128800 - tz.transition 1982, 9, :o5, 401853600 - tz.transition 1983, 3, :o6, 417582000 - tz.transition 1983, 9, :o5, 433303200 - tz.transition 1984, 3, :o6, 449028000 - tz.transition 1984, 9, :o5, 465357600 - tz.transition 1985, 3, :o6, 481082400 - tz.transition 1985, 9, :o5, 496807200 - tz.transition 1986, 3, :o6, 512532000 - tz.transition 1986, 9, :o5, 528256800 - tz.transition 1987, 3, :o6, 543981600 - tz.transition 1987, 9, :o5, 559706400 - tz.transition 1988, 3, :o6, 575431200 - tz.transition 1988, 9, :o5, 591156000 - tz.transition 1989, 3, :o6, 606880800 - tz.transition 1989, 9, :o5, 622605600 - tz.transition 1990, 3, :o6, 638330400 - tz.transition 1990, 9, :o5, 654660000 - tz.transition 1991, 3, :o6, 670384800 - tz.transition 1991, 9, :o5, 686109600 - tz.transition 1992, 3, :o6, 701834400 - tz.transition 1992, 9, :o7, 717559200 - tz.transition 1993, 3, :o6, 733280400 - tz.transition 1993, 9, :o5, 749005200 - tz.transition 1994, 3, :o6, 764730000 - tz.transition 1994, 9, :o5, 780454800 - tz.transition 1995, 3, :o6, 796179600 - tz.transition 1995, 9, :o5, 811904400 - tz.transition 1996, 3, :o6, 828234000 - tz.transition 1996, 10, :o5, 846378000 - tz.transition 1997, 3, :o6, 859683600 - tz.transition 1997, 10, :o5, 877827600 - tz.transition 1998, 3, :o6, 891133200 - tz.transition 1998, 10, :o5, 909277200 - tz.transition 1999, 3, :o6, 922582800 - tz.transition 1999, 10, :o5, 941331600 - tz.transition 2000, 3, :o6, 954032400 - tz.transition 2000, 10, :o5, 972781200 - tz.transition 2001, 3, :o6, 985482000 - tz.transition 2001, 10, :o5, 1004230800 - tz.transition 2002, 3, :o6, 1017536400 - tz.transition 2002, 10, :o5, 1035680400 - tz.transition 2003, 3, :o6, 1048986000 - tz.transition 2003, 10, :o5, 1067130000 - tz.transition 2004, 3, :o6, 1080435600 - tz.transition 2004, 10, :o5, 1099184400 - tz.transition 2005, 3, :o6, 1111885200 - tz.transition 2005, 10, :o5, 1130634000 - tz.transition 2006, 3, :o6, 1143334800 - tz.transition 2006, 10, :o5, 1162083600 - tz.transition 2007, 3, :o6, 1174784400 - tz.transition 2007, 10, :o5, 1193533200 - tz.transition 2008, 3, :o6, 1206838800 - tz.transition 2008, 10, :o5, 1224982800 - tz.transition 2009, 3, :o6, 1238288400 - tz.transition 2009, 10, :o5, 1256432400 - tz.transition 2010, 3, :o6, 1269738000 - tz.transition 2010, 10, :o5, 1288486800 - tz.transition 2011, 3, :o6, 1301187600 - tz.transition 2011, 10, :o5, 1319936400 - tz.transition 2012, 3, :o6, 1332637200 - tz.transition 2012, 10, :o5, 1351386000 - tz.transition 2013, 3, :o6, 1364691600 - tz.transition 2013, 10, :o5, 1382835600 - tz.transition 2014, 3, :o6, 1396141200 - tz.transition 2014, 10, :o5, 1414285200 - tz.transition 2015, 3, :o6, 1427590800 - tz.transition 2015, 10, :o5, 1445734800 - tz.transition 2016, 3, :o6, 1459040400 - tz.transition 2016, 10, :o5, 1477789200 - tz.transition 2017, 3, :o6, 1490490000 - tz.transition 2017, 10, :o5, 1509238800 - tz.transition 2018, 3, :o6, 1521939600 - tz.transition 2018, 10, :o5, 1540688400 - tz.transition 2019, 3, :o6, 1553994000 - tz.transition 2019, 10, :o5, 1572138000 - tz.transition 2020, 3, :o6, 1585443600 - tz.transition 2020, 10, :o5, 1603587600 - tz.transition 2021, 3, :o6, 1616893200 - tz.transition 2021, 10, :o5, 1635642000 - tz.transition 2022, 3, :o6, 1648342800 - tz.transition 2022, 10, :o5, 1667091600 - tz.transition 2023, 3, :o6, 1679792400 - tz.transition 2023, 10, :o5, 1698541200 - tz.transition 2024, 3, :o6, 1711846800 - tz.transition 2024, 10, :o5, 1729990800 - tz.transition 2025, 3, :o6, 1743296400 - tz.transition 2025, 10, :o5, 1761440400 - tz.transition 2026, 3, :o6, 1774746000 - tz.transition 2026, 10, :o5, 1792890000 - tz.transition 2027, 3, :o6, 1806195600 - tz.transition 2027, 10, :o5, 1824944400 - tz.transition 2028, 3, :o6, 1837645200 - tz.transition 2028, 10, :o5, 1856394000 - tz.transition 2029, 3, :o6, 1869094800 - tz.transition 2029, 10, :o5, 1887843600 - tz.transition 2030, 3, :o6, 1901149200 - tz.transition 2030, 10, :o5, 1919293200 - tz.transition 2031, 3, :o6, 1932598800 - tz.transition 2031, 10, :o5, 1950742800 - tz.transition 2032, 3, :o6, 1964048400 - tz.transition 2032, 10, :o5, 1982797200 - tz.transition 2033, 3, :o6, 1995498000 - tz.transition 2033, 10, :o5, 2014246800 - tz.transition 2034, 3, :o6, 2026947600 - tz.transition 2034, 10, :o5, 2045696400 - tz.transition 2035, 3, :o6, 2058397200 - tz.transition 2035, 10, :o5, 2077146000 - tz.transition 2036, 3, :o6, 2090451600 - tz.transition 2036, 10, :o5, 2108595600 - tz.transition 2037, 3, :o6, 2121901200 - tz.transition 2037, 10, :o5, 2140045200 - tz.transition 2038, 3, :o6, 59172253, 24 - tz.transition 2038, 10, :o5, 59177461, 24 - tz.transition 2039, 3, :o6, 59180989, 24 - tz.transition 2039, 10, :o5, 59186197, 24 - tz.transition 2040, 3, :o6, 59189725, 24 - tz.transition 2040, 10, :o5, 59194933, 24 - tz.transition 2041, 3, :o6, 59198629, 24 - tz.transition 2041, 10, :o5, 59203669, 24 - tz.transition 2042, 3, :o6, 59207365, 24 - tz.transition 2042, 10, :o5, 59212405, 24 - tz.transition 2043, 3, :o6, 59216101, 24 - tz.transition 2043, 10, :o5, 59221141, 24 - tz.transition 2044, 3, :o6, 59224837, 24 - tz.transition 2044, 10, :o5, 59230045, 24 - tz.transition 2045, 3, :o6, 59233573, 24 - tz.transition 2045, 10, :o5, 59238781, 24 - tz.transition 2046, 3, :o6, 59242309, 24 - tz.transition 2046, 10, :o5, 59247517, 24 - tz.transition 2047, 3, :o6, 59251213, 24 - tz.transition 2047, 10, :o5, 59256253, 24 - tz.transition 2048, 3, :o6, 59259949, 24 - tz.transition 2048, 10, :o5, 59264989, 24 - tz.transition 2049, 3, :o6, 59268685, 24 - tz.transition 2049, 10, :o5, 59273893, 24 - tz.transition 2050, 3, :o6, 59277421, 24 - tz.transition 2050, 10, :o5, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb deleted file mode 100644 index 61c8c150..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Atlantic - module Cape_Verde - include TimezoneDefinition - - timezone 'Atlantic/Cape_Verde' do |tz| - tz.offset :o0, -5644, 0, :LMT - tz.offset :o1, -7200, 0, :CVT - tz.offset :o2, -7200, 3600, :CVST - tz.offset :o3, -3600, 0, :CVT - - tz.transition 1907, 1, :o1, 52219653811, 21600 - tz.transition 1942, 9, :o2, 29167243, 12 - tz.transition 1945, 10, :o1, 58361845, 24 - tz.transition 1975, 11, :o3, 186120000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb deleted file mode 100644 index 6a4cbafb..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Atlantic - module South_Georgia - include TimezoneDefinition - - timezone 'Atlantic/South_Georgia' do |tz| - tz.offset :o0, -8768, 0, :LMT - tz.offset :o1, -7200, 0, :GST - - tz.transition 1890, 1, :o1, 1627673806, 675 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb deleted file mode 100644 index c5d561cc..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +++ /dev/null @@ -1,187 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Adelaide - include TimezoneDefinition - - timezone 'Australia/Adelaide' do |tz| - tz.offset :o0, 33260, 0, :LMT - tz.offset :o1, 32400, 0, :CST - tz.offset :o2, 34200, 0, :CST - tz.offset :o3, 34200, 3600, :CST - - tz.transition 1895, 1, :o1, 10425132497, 4320 - tz.transition 1899, 4, :o2, 19318201, 8 - tz.transition 1916, 12, :o3, 3486569911, 1440 - tz.transition 1917, 3, :o2, 116222983, 48 - tz.transition 1941, 12, :o3, 38885763, 16 - tz.transition 1942, 3, :o2, 116661463, 48 - tz.transition 1942, 9, :o3, 38890067, 16 - tz.transition 1943, 3, :o2, 116678935, 48 - tz.transition 1943, 10, :o3, 38896003, 16 - tz.transition 1944, 3, :o2, 116696407, 48 - tz.transition 1971, 10, :o3, 57688200 - tz.transition 1972, 2, :o2, 67969800 - tz.transition 1972, 10, :o3, 89137800 - tz.transition 1973, 3, :o2, 100024200 - tz.transition 1973, 10, :o3, 120587400 - tz.transition 1974, 3, :o2, 131473800 - tz.transition 1974, 10, :o3, 152037000 - tz.transition 1975, 3, :o2, 162923400 - tz.transition 1975, 10, :o3, 183486600 - tz.transition 1976, 3, :o2, 194977800 - tz.transition 1976, 10, :o3, 215541000 - tz.transition 1977, 3, :o2, 226427400 - tz.transition 1977, 10, :o3, 246990600 - tz.transition 1978, 3, :o2, 257877000 - tz.transition 1978, 10, :o3, 278440200 - tz.transition 1979, 3, :o2, 289326600 - tz.transition 1979, 10, :o3, 309889800 - tz.transition 1980, 3, :o2, 320776200 - tz.transition 1980, 10, :o3, 341339400 - tz.transition 1981, 2, :o2, 352225800 - tz.transition 1981, 10, :o3, 372789000 - tz.transition 1982, 3, :o2, 384280200 - tz.transition 1982, 10, :o3, 404843400 - tz.transition 1983, 3, :o2, 415729800 - tz.transition 1983, 10, :o3, 436293000 - tz.transition 1984, 3, :o2, 447179400 - tz.transition 1984, 10, :o3, 467742600 - tz.transition 1985, 3, :o2, 478629000 - tz.transition 1985, 10, :o3, 499192200 - tz.transition 1986, 3, :o2, 511288200 - tz.transition 1986, 10, :o3, 530037000 - tz.transition 1987, 3, :o2, 542737800 - tz.transition 1987, 10, :o3, 562091400 - tz.transition 1988, 3, :o2, 574792200 - tz.transition 1988, 10, :o3, 594145800 - tz.transition 1989, 3, :o2, 606241800 - tz.transition 1989, 10, :o3, 625595400 - tz.transition 1990, 3, :o2, 637691400 - tz.transition 1990, 10, :o3, 657045000 - tz.transition 1991, 3, :o2, 667931400 - tz.transition 1991, 10, :o3, 688494600 - tz.transition 1992, 3, :o2, 701195400 - tz.transition 1992, 10, :o3, 719944200 - tz.transition 1993, 3, :o2, 731435400 - tz.transition 1993, 10, :o3, 751998600 - tz.transition 1994, 3, :o2, 764094600 - tz.transition 1994, 10, :o3, 783448200 - tz.transition 1995, 3, :o2, 796149000 - tz.transition 1995, 10, :o3, 814897800 - tz.transition 1996, 3, :o2, 828203400 - tz.transition 1996, 10, :o3, 846347400 - tz.transition 1997, 3, :o2, 859653000 - tz.transition 1997, 10, :o3, 877797000 - tz.transition 1998, 3, :o2, 891102600 - tz.transition 1998, 10, :o3, 909246600 - tz.transition 1999, 3, :o2, 922552200 - tz.transition 1999, 10, :o3, 941301000 - tz.transition 2000, 3, :o2, 954001800 - tz.transition 2000, 10, :o3, 972750600 - tz.transition 2001, 3, :o2, 985451400 - tz.transition 2001, 10, :o3, 1004200200 - tz.transition 2002, 3, :o2, 1017505800 - tz.transition 2002, 10, :o3, 1035649800 - tz.transition 2003, 3, :o2, 1048955400 - tz.transition 2003, 10, :o3, 1067099400 - tz.transition 2004, 3, :o2, 1080405000 - tz.transition 2004, 10, :o3, 1099153800 - tz.transition 2005, 3, :o2, 1111854600 - tz.transition 2005, 10, :o3, 1130603400 - tz.transition 2006, 4, :o2, 1143909000 - tz.transition 2006, 10, :o3, 1162053000 - tz.transition 2007, 3, :o2, 1174753800 - tz.transition 2007, 10, :o3, 1193502600 - tz.transition 2008, 4, :o2, 1207413000 - tz.transition 2008, 10, :o3, 1223137800 - tz.transition 2009, 4, :o2, 1238862600 - tz.transition 2009, 10, :o3, 1254587400 - tz.transition 2010, 4, :o2, 1270312200 - tz.transition 2010, 10, :o3, 1286037000 - tz.transition 2011, 4, :o2, 1301761800 - tz.transition 2011, 10, :o3, 1317486600 - tz.transition 2012, 3, :o2, 1333211400 - tz.transition 2012, 10, :o3, 1349541000 - tz.transition 2013, 4, :o2, 1365265800 - tz.transition 2013, 10, :o3, 1380990600 - tz.transition 2014, 4, :o2, 1396715400 - tz.transition 2014, 10, :o3, 1412440200 - tz.transition 2015, 4, :o2, 1428165000 - tz.transition 2015, 10, :o3, 1443889800 - tz.transition 2016, 4, :o2, 1459614600 - tz.transition 2016, 10, :o3, 1475339400 - tz.transition 2017, 4, :o2, 1491064200 - tz.transition 2017, 9, :o3, 1506789000 - tz.transition 2018, 3, :o2, 1522513800 - tz.transition 2018, 10, :o3, 1538843400 - tz.transition 2019, 4, :o2, 1554568200 - tz.transition 2019, 10, :o3, 1570293000 - tz.transition 2020, 4, :o2, 1586017800 - tz.transition 2020, 10, :o3, 1601742600 - tz.transition 2021, 4, :o2, 1617467400 - tz.transition 2021, 10, :o3, 1633192200 - tz.transition 2022, 4, :o2, 1648917000 - tz.transition 2022, 10, :o3, 1664641800 - tz.transition 2023, 4, :o2, 1680366600 - tz.transition 2023, 9, :o3, 1696091400 - tz.transition 2024, 4, :o2, 1712421000 - tz.transition 2024, 10, :o3, 1728145800 - tz.transition 2025, 4, :o2, 1743870600 - tz.transition 2025, 10, :o3, 1759595400 - tz.transition 2026, 4, :o2, 1775320200 - tz.transition 2026, 10, :o3, 1791045000 - tz.transition 2027, 4, :o2, 1806769800 - tz.transition 2027, 10, :o3, 1822494600 - tz.transition 2028, 4, :o2, 1838219400 - tz.transition 2028, 9, :o3, 1853944200 - tz.transition 2029, 3, :o2, 1869669000 - tz.transition 2029, 10, :o3, 1885998600 - tz.transition 2030, 4, :o2, 1901723400 - tz.transition 2030, 10, :o3, 1917448200 - tz.transition 2031, 4, :o2, 1933173000 - tz.transition 2031, 10, :o3, 1948897800 - tz.transition 2032, 4, :o2, 1964622600 - tz.transition 2032, 10, :o3, 1980347400 - tz.transition 2033, 4, :o2, 1996072200 - tz.transition 2033, 10, :o3, 2011797000 - tz.transition 2034, 4, :o2, 2027521800 - tz.transition 2034, 9, :o3, 2043246600 - tz.transition 2035, 3, :o2, 2058971400 - tz.transition 2035, 10, :o3, 2075301000 - tz.transition 2036, 4, :o2, 2091025800 - tz.transition 2036, 10, :o3, 2106750600 - tz.transition 2037, 4, :o2, 2122475400 - tz.transition 2037, 10, :o3, 2138200200 - tz.transition 2038, 4, :o2, 39448275, 16 - tz.transition 2038, 10, :o3, 39451187, 16 - tz.transition 2039, 4, :o2, 39454099, 16 - tz.transition 2039, 10, :o3, 39457011, 16 - tz.transition 2040, 3, :o2, 39459923, 16 - tz.transition 2040, 10, :o3, 39462947, 16 - tz.transition 2041, 4, :o2, 39465859, 16 - tz.transition 2041, 10, :o3, 39468771, 16 - tz.transition 2042, 4, :o2, 39471683, 16 - tz.transition 2042, 10, :o3, 39474595, 16 - tz.transition 2043, 4, :o2, 39477507, 16 - tz.transition 2043, 10, :o3, 39480419, 16 - tz.transition 2044, 4, :o2, 39483331, 16 - tz.transition 2044, 10, :o3, 39486243, 16 - tz.transition 2045, 4, :o2, 39489155, 16 - tz.transition 2045, 9, :o3, 39492067, 16 - tz.transition 2046, 3, :o2, 39494979, 16 - tz.transition 2046, 10, :o3, 39498003, 16 - tz.transition 2047, 4, :o2, 39500915, 16 - tz.transition 2047, 10, :o3, 39503827, 16 - tz.transition 2048, 4, :o2, 39506739, 16 - tz.transition 2048, 10, :o3, 39509651, 16 - tz.transition 2049, 4, :o2, 39512563, 16 - tz.transition 2049, 10, :o3, 39515475, 16 - tz.transition 2050, 4, :o2, 39518387, 16 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb deleted file mode 100644 index dd85ddae..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Brisbane - include TimezoneDefinition - - timezone 'Australia/Brisbane' do |tz| - tz.offset :o0, 36728, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1894, 12, :o1, 26062496009, 10800 - tz.transition 1916, 12, :o2, 3486569881, 1440 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 636480000 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 667929600 - tz.transition 1991, 10, :o2, 688492800 - tz.transition 1992, 2, :o1, 699379200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb deleted file mode 100644 index 17de8812..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Darwin - include TimezoneDefinition - - timezone 'Australia/Darwin' do |tz| - tz.offset :o0, 31400, 0, :LMT - tz.offset :o1, 32400, 0, :CST - tz.offset :o2, 34200, 0, :CST - tz.offset :o3, 34200, 3600, :CST - - tz.transition 1895, 1, :o1, 1042513259, 432 - tz.transition 1899, 4, :o2, 19318201, 8 - tz.transition 1916, 12, :o3, 3486569911, 1440 - tz.transition 1917, 3, :o2, 116222983, 48 - tz.transition 1941, 12, :o3, 38885763, 16 - tz.transition 1942, 3, :o2, 116661463, 48 - tz.transition 1942, 9, :o3, 38890067, 16 - tz.transition 1943, 3, :o2, 116678935, 48 - tz.transition 1943, 10, :o3, 38896003, 16 - tz.transition 1944, 3, :o2, 116696407, 48 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb deleted file mode 100644 index 11384b98..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +++ /dev/null @@ -1,193 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Hobart - include TimezoneDefinition - - timezone 'Australia/Hobart' do |tz| - tz.offset :o0, 35356, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1895, 8, :o1, 52130241161, 21600 - tz.transition 1916, 9, :o2, 14526823, 6 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1967, 9, :o2, 14638585, 6 - tz.transition 1968, 3, :o1, 14639677, 6 - tz.transition 1968, 10, :o2, 14640937, 6 - tz.transition 1969, 3, :o1, 14641735, 6 - tz.transition 1969, 10, :o2, 14643121, 6 - tz.transition 1970, 3, :o1, 5673600 - tz.transition 1970, 10, :o2, 25632000 - tz.transition 1971, 3, :o1, 37728000 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1972, 10, :o2, 89136000 - tz.transition 1973, 3, :o1, 100022400 - tz.transition 1973, 10, :o2, 120585600 - tz.transition 1974, 3, :o1, 131472000 - tz.transition 1974, 10, :o2, 152035200 - tz.transition 1975, 3, :o1, 162921600 - tz.transition 1975, 10, :o2, 183484800 - tz.transition 1976, 3, :o1, 194976000 - tz.transition 1976, 10, :o2, 215539200 - tz.transition 1977, 3, :o1, 226425600 - tz.transition 1977, 10, :o2, 246988800 - tz.transition 1978, 3, :o1, 257875200 - tz.transition 1978, 10, :o2, 278438400 - tz.transition 1979, 3, :o1, 289324800 - tz.transition 1979, 10, :o2, 309888000 - tz.transition 1980, 3, :o1, 320774400 - tz.transition 1980, 10, :o2, 341337600 - tz.transition 1981, 2, :o1, 352224000 - tz.transition 1981, 10, :o2, 372787200 - tz.transition 1982, 3, :o1, 386092800 - tz.transition 1982, 10, :o2, 404841600 - tz.transition 1983, 3, :o1, 417542400 - tz.transition 1983, 10, :o2, 436291200 - tz.transition 1984, 3, :o1, 447177600 - tz.transition 1984, 10, :o2, 467740800 - tz.transition 1985, 3, :o1, 478627200 - tz.transition 1985, 10, :o2, 499190400 - tz.transition 1986, 3, :o1, 510076800 - tz.transition 1986, 10, :o2, 530035200 - tz.transition 1987, 3, :o1, 542736000 - tz.transition 1987, 10, :o2, 562089600 - tz.transition 1988, 3, :o1, 574790400 - tz.transition 1988, 10, :o2, 594144000 - tz.transition 1989, 3, :o1, 606240000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 637689600 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 670348800 - tz.transition 1991, 10, :o2, 686678400 - tz.transition 1992, 3, :o1, 701798400 - tz.transition 1992, 10, :o2, 718128000 - tz.transition 1993, 3, :o1, 733248000 - tz.transition 1993, 10, :o2, 749577600 - tz.transition 1994, 3, :o1, 764697600 - tz.transition 1994, 10, :o2, 781027200 - tz.transition 1995, 3, :o1, 796147200 - tz.transition 1995, 9, :o2, 812476800 - tz.transition 1996, 3, :o1, 828201600 - tz.transition 1996, 10, :o2, 844531200 - tz.transition 1997, 3, :o1, 859651200 - tz.transition 1997, 10, :o2, 875980800 - tz.transition 1998, 3, :o1, 891100800 - tz.transition 1998, 10, :o2, 907430400 - tz.transition 1999, 3, :o1, 922550400 - tz.transition 1999, 10, :o2, 938880000 - tz.transition 2000, 3, :o1, 954000000 - tz.transition 2000, 8, :o2, 967305600 - tz.transition 2001, 3, :o1, 985449600 - tz.transition 2001, 10, :o2, 1002384000 - tz.transition 2002, 3, :o1, 1017504000 - tz.transition 2002, 10, :o2, 1033833600 - tz.transition 2003, 3, :o1, 1048953600 - tz.transition 2003, 10, :o2, 1065283200 - tz.transition 2004, 3, :o1, 1080403200 - tz.transition 2004, 10, :o2, 1096732800 - tz.transition 2005, 3, :o1, 1111852800 - tz.transition 2005, 10, :o2, 1128182400 - tz.transition 2006, 4, :o1, 1143907200 - tz.transition 2006, 9, :o2, 1159632000 - tz.transition 2007, 3, :o1, 1174752000 - tz.transition 2007, 10, :o2, 1191686400 - tz.transition 2008, 4, :o1, 1207411200 - tz.transition 2008, 10, :o2, 1223136000 - tz.transition 2009, 4, :o1, 1238860800 - tz.transition 2009, 10, :o2, 1254585600 - tz.transition 2010, 4, :o1, 1270310400 - tz.transition 2010, 10, :o2, 1286035200 - tz.transition 2011, 4, :o1, 1301760000 - tz.transition 2011, 10, :o2, 1317484800 - tz.transition 2012, 3, :o1, 1333209600 - tz.transition 2012, 10, :o2, 1349539200 - tz.transition 2013, 4, :o1, 1365264000 - tz.transition 2013, 10, :o2, 1380988800 - tz.transition 2014, 4, :o1, 1396713600 - tz.transition 2014, 10, :o2, 1412438400 - tz.transition 2015, 4, :o1, 1428163200 - tz.transition 2015, 10, :o2, 1443888000 - tz.transition 2016, 4, :o1, 1459612800 - tz.transition 2016, 10, :o2, 1475337600 - tz.transition 2017, 4, :o1, 1491062400 - tz.transition 2017, 9, :o2, 1506787200 - tz.transition 2018, 3, :o1, 1522512000 - tz.transition 2018, 10, :o2, 1538841600 - tz.transition 2019, 4, :o1, 1554566400 - tz.transition 2019, 10, :o2, 1570291200 - tz.transition 2020, 4, :o1, 1586016000 - tz.transition 2020, 10, :o2, 1601740800 - tz.transition 2021, 4, :o1, 1617465600 - tz.transition 2021, 10, :o2, 1633190400 - tz.transition 2022, 4, :o1, 1648915200 - tz.transition 2022, 10, :o2, 1664640000 - tz.transition 2023, 4, :o1, 1680364800 - tz.transition 2023, 9, :o2, 1696089600 - tz.transition 2024, 4, :o1, 1712419200 - tz.transition 2024, 10, :o2, 1728144000 - tz.transition 2025, 4, :o1, 1743868800 - tz.transition 2025, 10, :o2, 1759593600 - tz.transition 2026, 4, :o1, 1775318400 - tz.transition 2026, 10, :o2, 1791043200 - tz.transition 2027, 4, :o1, 1806768000 - tz.transition 2027, 10, :o2, 1822492800 - tz.transition 2028, 4, :o1, 1838217600 - tz.transition 2028, 9, :o2, 1853942400 - tz.transition 2029, 3, :o1, 1869667200 - tz.transition 2029, 10, :o2, 1885996800 - tz.transition 2030, 4, :o1, 1901721600 - tz.transition 2030, 10, :o2, 1917446400 - tz.transition 2031, 4, :o1, 1933171200 - tz.transition 2031, 10, :o2, 1948896000 - tz.transition 2032, 4, :o1, 1964620800 - tz.transition 2032, 10, :o2, 1980345600 - tz.transition 2033, 4, :o1, 1996070400 - tz.transition 2033, 10, :o2, 2011795200 - tz.transition 2034, 4, :o1, 2027520000 - tz.transition 2034, 9, :o2, 2043244800 - tz.transition 2035, 3, :o1, 2058969600 - tz.transition 2035, 10, :o2, 2075299200 - tz.transition 2036, 4, :o1, 2091024000 - tz.transition 2036, 10, :o2, 2106748800 - tz.transition 2037, 4, :o1, 2122473600 - tz.transition 2037, 10, :o2, 2138198400 - tz.transition 2038, 4, :o1, 14793103, 6 - tz.transition 2038, 10, :o2, 14794195, 6 - tz.transition 2039, 4, :o1, 14795287, 6 - tz.transition 2039, 10, :o2, 14796379, 6 - tz.transition 2040, 3, :o1, 14797471, 6 - tz.transition 2040, 10, :o2, 14798605, 6 - tz.transition 2041, 4, :o1, 14799697, 6 - tz.transition 2041, 10, :o2, 14800789, 6 - tz.transition 2042, 4, :o1, 14801881, 6 - tz.transition 2042, 10, :o2, 14802973, 6 - tz.transition 2043, 4, :o1, 14804065, 6 - tz.transition 2043, 10, :o2, 14805157, 6 - tz.transition 2044, 4, :o1, 14806249, 6 - tz.transition 2044, 10, :o2, 14807341, 6 - tz.transition 2045, 4, :o1, 14808433, 6 - tz.transition 2045, 9, :o2, 14809525, 6 - tz.transition 2046, 3, :o1, 14810617, 6 - tz.transition 2046, 10, :o2, 14811751, 6 - tz.transition 2047, 4, :o1, 14812843, 6 - tz.transition 2047, 10, :o2, 14813935, 6 - tz.transition 2048, 4, :o1, 14815027, 6 - tz.transition 2048, 10, :o2, 14816119, 6 - tz.transition 2049, 4, :o1, 14817211, 6 - tz.transition 2049, 10, :o2, 14818303, 6 - tz.transition 2050, 4, :o1, 14819395, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb deleted file mode 100644 index c1304488..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Melbourne - include TimezoneDefinition - - timezone 'Australia/Melbourne' do |tz| - tz.offset :o0, 34792, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1895, 1, :o1, 26062831051, 10800 - tz.transition 1916, 12, :o2, 3486569881, 1440 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1972, 10, :o2, 89136000 - tz.transition 1973, 3, :o1, 100022400 - tz.transition 1973, 10, :o2, 120585600 - tz.transition 1974, 3, :o1, 131472000 - tz.transition 1974, 10, :o2, 152035200 - tz.transition 1975, 3, :o1, 162921600 - tz.transition 1975, 10, :o2, 183484800 - tz.transition 1976, 3, :o1, 194976000 - tz.transition 1976, 10, :o2, 215539200 - tz.transition 1977, 3, :o1, 226425600 - tz.transition 1977, 10, :o2, 246988800 - tz.transition 1978, 3, :o1, 257875200 - tz.transition 1978, 10, :o2, 278438400 - tz.transition 1979, 3, :o1, 289324800 - tz.transition 1979, 10, :o2, 309888000 - tz.transition 1980, 3, :o1, 320774400 - tz.transition 1980, 10, :o2, 341337600 - tz.transition 1981, 2, :o1, 352224000 - tz.transition 1981, 10, :o2, 372787200 - tz.transition 1982, 3, :o1, 384278400 - tz.transition 1982, 10, :o2, 404841600 - tz.transition 1983, 3, :o1, 415728000 - tz.transition 1983, 10, :o2, 436291200 - tz.transition 1984, 3, :o1, 447177600 - tz.transition 1984, 10, :o2, 467740800 - tz.transition 1985, 3, :o1, 478627200 - tz.transition 1985, 10, :o2, 499190400 - tz.transition 1986, 3, :o1, 511286400 - tz.transition 1986, 10, :o2, 530035200 - tz.transition 1987, 3, :o1, 542736000 - tz.transition 1987, 10, :o2, 561484800 - tz.transition 1988, 3, :o1, 574790400 - tz.transition 1988, 10, :o2, 594144000 - tz.transition 1989, 3, :o1, 606240000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 637689600 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 667929600 - tz.transition 1991, 10, :o2, 688492800 - tz.transition 1992, 2, :o1, 699379200 - tz.transition 1992, 10, :o2, 719942400 - tz.transition 1993, 3, :o1, 731433600 - tz.transition 1993, 10, :o2, 751996800 - tz.transition 1994, 3, :o1, 762883200 - tz.transition 1994, 10, :o2, 783446400 - tz.transition 1995, 3, :o1, 796147200 - tz.transition 1995, 10, :o2, 814896000 - tz.transition 1996, 3, :o1, 828201600 - tz.transition 1996, 10, :o2, 846345600 - tz.transition 1997, 3, :o1, 859651200 - tz.transition 1997, 10, :o2, 877795200 - tz.transition 1998, 3, :o1, 891100800 - tz.transition 1998, 10, :o2, 909244800 - tz.transition 1999, 3, :o1, 922550400 - tz.transition 1999, 10, :o2, 941299200 - tz.transition 2000, 3, :o1, 954000000 - tz.transition 2000, 8, :o2, 967305600 - tz.transition 2001, 3, :o1, 985449600 - tz.transition 2001, 10, :o2, 1004198400 - tz.transition 2002, 3, :o1, 1017504000 - tz.transition 2002, 10, :o2, 1035648000 - tz.transition 2003, 3, :o1, 1048953600 - tz.transition 2003, 10, :o2, 1067097600 - tz.transition 2004, 3, :o1, 1080403200 - tz.transition 2004, 10, :o2, 1099152000 - tz.transition 2005, 3, :o1, 1111852800 - tz.transition 2005, 10, :o2, 1130601600 - tz.transition 2006, 4, :o1, 1143907200 - tz.transition 2006, 10, :o2, 1162051200 - tz.transition 2007, 3, :o1, 1174752000 - tz.transition 2007, 10, :o2, 1193500800 - tz.transition 2008, 4, :o1, 1207411200 - tz.transition 2008, 10, :o2, 1223136000 - tz.transition 2009, 4, :o1, 1238860800 - tz.transition 2009, 10, :o2, 1254585600 - tz.transition 2010, 4, :o1, 1270310400 - tz.transition 2010, 10, :o2, 1286035200 - tz.transition 2011, 4, :o1, 1301760000 - tz.transition 2011, 10, :o2, 1317484800 - tz.transition 2012, 3, :o1, 1333209600 - tz.transition 2012, 10, :o2, 1349539200 - tz.transition 2013, 4, :o1, 1365264000 - tz.transition 2013, 10, :o2, 1380988800 - tz.transition 2014, 4, :o1, 1396713600 - tz.transition 2014, 10, :o2, 1412438400 - tz.transition 2015, 4, :o1, 1428163200 - tz.transition 2015, 10, :o2, 1443888000 - tz.transition 2016, 4, :o1, 1459612800 - tz.transition 2016, 10, :o2, 1475337600 - tz.transition 2017, 4, :o1, 1491062400 - tz.transition 2017, 9, :o2, 1506787200 - tz.transition 2018, 3, :o1, 1522512000 - tz.transition 2018, 10, :o2, 1538841600 - tz.transition 2019, 4, :o1, 1554566400 - tz.transition 2019, 10, :o2, 1570291200 - tz.transition 2020, 4, :o1, 1586016000 - tz.transition 2020, 10, :o2, 1601740800 - tz.transition 2021, 4, :o1, 1617465600 - tz.transition 2021, 10, :o2, 1633190400 - tz.transition 2022, 4, :o1, 1648915200 - tz.transition 2022, 10, :o2, 1664640000 - tz.transition 2023, 4, :o1, 1680364800 - tz.transition 2023, 9, :o2, 1696089600 - tz.transition 2024, 4, :o1, 1712419200 - tz.transition 2024, 10, :o2, 1728144000 - tz.transition 2025, 4, :o1, 1743868800 - tz.transition 2025, 10, :o2, 1759593600 - tz.transition 2026, 4, :o1, 1775318400 - tz.transition 2026, 10, :o2, 1791043200 - tz.transition 2027, 4, :o1, 1806768000 - tz.transition 2027, 10, :o2, 1822492800 - tz.transition 2028, 4, :o1, 1838217600 - tz.transition 2028, 9, :o2, 1853942400 - tz.transition 2029, 3, :o1, 1869667200 - tz.transition 2029, 10, :o2, 1885996800 - tz.transition 2030, 4, :o1, 1901721600 - tz.transition 2030, 10, :o2, 1917446400 - tz.transition 2031, 4, :o1, 1933171200 - tz.transition 2031, 10, :o2, 1948896000 - tz.transition 2032, 4, :o1, 1964620800 - tz.transition 2032, 10, :o2, 1980345600 - tz.transition 2033, 4, :o1, 1996070400 - tz.transition 2033, 10, :o2, 2011795200 - tz.transition 2034, 4, :o1, 2027520000 - tz.transition 2034, 9, :o2, 2043244800 - tz.transition 2035, 3, :o1, 2058969600 - tz.transition 2035, 10, :o2, 2075299200 - tz.transition 2036, 4, :o1, 2091024000 - tz.transition 2036, 10, :o2, 2106748800 - tz.transition 2037, 4, :o1, 2122473600 - tz.transition 2037, 10, :o2, 2138198400 - tz.transition 2038, 4, :o1, 14793103, 6 - tz.transition 2038, 10, :o2, 14794195, 6 - tz.transition 2039, 4, :o1, 14795287, 6 - tz.transition 2039, 10, :o2, 14796379, 6 - tz.transition 2040, 3, :o1, 14797471, 6 - tz.transition 2040, 10, :o2, 14798605, 6 - tz.transition 2041, 4, :o1, 14799697, 6 - tz.transition 2041, 10, :o2, 14800789, 6 - tz.transition 2042, 4, :o1, 14801881, 6 - tz.transition 2042, 10, :o2, 14802973, 6 - tz.transition 2043, 4, :o1, 14804065, 6 - tz.transition 2043, 10, :o2, 14805157, 6 - tz.transition 2044, 4, :o1, 14806249, 6 - tz.transition 2044, 10, :o2, 14807341, 6 - tz.transition 2045, 4, :o1, 14808433, 6 - tz.transition 2045, 9, :o2, 14809525, 6 - tz.transition 2046, 3, :o1, 14810617, 6 - tz.transition 2046, 10, :o2, 14811751, 6 - tz.transition 2047, 4, :o1, 14812843, 6 - tz.transition 2047, 10, :o2, 14813935, 6 - tz.transition 2048, 4, :o1, 14815027, 6 - tz.transition 2048, 10, :o2, 14816119, 6 - tz.transition 2049, 4, :o1, 14817211, 6 - tz.transition 2049, 10, :o2, 14818303, 6 - tz.transition 2050, 4, :o1, 14819395, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb deleted file mode 100644 index d9e66f14..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Perth - include TimezoneDefinition - - timezone 'Australia/Perth' do |tz| - tz.offset :o0, 27804, 0, :LMT - tz.offset :o1, 28800, 0, :WST - tz.offset :o2, 28800, 3600, :WST - - tz.transition 1895, 11, :o1, 17377402883, 7200 - tz.transition 1916, 12, :o2, 3486570001, 1440 - tz.transition 1917, 3, :o1, 58111493, 24 - tz.transition 1941, 12, :o2, 9721441, 4 - tz.transition 1942, 3, :o1, 58330733, 24 - tz.transition 1942, 9, :o2, 9722517, 4 - tz.transition 1943, 3, :o1, 58339469, 24 - tz.transition 1974, 10, :o2, 152042400 - tz.transition 1975, 3, :o1, 162928800 - tz.transition 1983, 10, :o2, 436298400 - tz.transition 1984, 3, :o1, 447184800 - tz.transition 1991, 11, :o2, 690314400 - tz.transition 1992, 2, :o1, 699386400 - tz.transition 2006, 12, :o2, 1165082400 - tz.transition 2007, 3, :o1, 1174759200 - tz.transition 2007, 10, :o2, 1193508000 - tz.transition 2008, 3, :o1, 1206813600 - tz.transition 2008, 10, :o2, 1224957600 - tz.transition 2009, 3, :o1, 1238263200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb deleted file mode 100644 index 9062bd7c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Sydney - include TimezoneDefinition - - timezone 'Australia/Sydney' do |tz| - tz.offset :o0, 36292, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1895, 1, :o1, 52125661727, 21600 - tz.transition 1916, 12, :o2, 3486569881, 1440 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1972, 10, :o2, 89136000 - tz.transition 1973, 3, :o1, 100022400 - tz.transition 1973, 10, :o2, 120585600 - tz.transition 1974, 3, :o1, 131472000 - tz.transition 1974, 10, :o2, 152035200 - tz.transition 1975, 3, :o1, 162921600 - tz.transition 1975, 10, :o2, 183484800 - tz.transition 1976, 3, :o1, 194976000 - tz.transition 1976, 10, :o2, 215539200 - tz.transition 1977, 3, :o1, 226425600 - tz.transition 1977, 10, :o2, 246988800 - tz.transition 1978, 3, :o1, 257875200 - tz.transition 1978, 10, :o2, 278438400 - tz.transition 1979, 3, :o1, 289324800 - tz.transition 1979, 10, :o2, 309888000 - tz.transition 1980, 3, :o1, 320774400 - tz.transition 1980, 10, :o2, 341337600 - tz.transition 1981, 2, :o1, 352224000 - tz.transition 1981, 10, :o2, 372787200 - tz.transition 1982, 4, :o1, 386697600 - tz.transition 1982, 10, :o2, 404841600 - tz.transition 1983, 3, :o1, 415728000 - tz.transition 1983, 10, :o2, 436291200 - tz.transition 1984, 3, :o1, 447177600 - tz.transition 1984, 10, :o2, 467740800 - tz.transition 1985, 3, :o1, 478627200 - tz.transition 1985, 10, :o2, 499190400 - tz.transition 1986, 3, :o1, 511286400 - tz.transition 1986, 10, :o2, 530035200 - tz.transition 1987, 3, :o1, 542736000 - tz.transition 1987, 10, :o2, 562089600 - tz.transition 1988, 3, :o1, 574790400 - tz.transition 1988, 10, :o2, 594144000 - tz.transition 1989, 3, :o1, 606240000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 636480000 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 667929600 - tz.transition 1991, 10, :o2, 688492800 - tz.transition 1992, 2, :o1, 699379200 - tz.transition 1992, 10, :o2, 719942400 - tz.transition 1993, 3, :o1, 731433600 - tz.transition 1993, 10, :o2, 751996800 - tz.transition 1994, 3, :o1, 762883200 - tz.transition 1994, 10, :o2, 783446400 - tz.transition 1995, 3, :o1, 794332800 - tz.transition 1995, 10, :o2, 814896000 - tz.transition 1996, 3, :o1, 828201600 - tz.transition 1996, 10, :o2, 846345600 - tz.transition 1997, 3, :o1, 859651200 - tz.transition 1997, 10, :o2, 877795200 - tz.transition 1998, 3, :o1, 891100800 - tz.transition 1998, 10, :o2, 909244800 - tz.transition 1999, 3, :o1, 922550400 - tz.transition 1999, 10, :o2, 941299200 - tz.transition 2000, 3, :o1, 954000000 - tz.transition 2000, 8, :o2, 967305600 - tz.transition 2001, 3, :o1, 985449600 - tz.transition 2001, 10, :o2, 1004198400 - tz.transition 2002, 3, :o1, 1017504000 - tz.transition 2002, 10, :o2, 1035648000 - tz.transition 2003, 3, :o1, 1048953600 - tz.transition 2003, 10, :o2, 1067097600 - tz.transition 2004, 3, :o1, 1080403200 - tz.transition 2004, 10, :o2, 1099152000 - tz.transition 2005, 3, :o1, 1111852800 - tz.transition 2005, 10, :o2, 1130601600 - tz.transition 2006, 4, :o1, 1143907200 - tz.transition 2006, 10, :o2, 1162051200 - tz.transition 2007, 3, :o1, 1174752000 - tz.transition 2007, 10, :o2, 1193500800 - tz.transition 2008, 4, :o1, 1207411200 - tz.transition 2008, 10, :o2, 1223136000 - tz.transition 2009, 4, :o1, 1238860800 - tz.transition 2009, 10, :o2, 1254585600 - tz.transition 2010, 4, :o1, 1270310400 - tz.transition 2010, 10, :o2, 1286035200 - tz.transition 2011, 4, :o1, 1301760000 - tz.transition 2011, 10, :o2, 1317484800 - tz.transition 2012, 3, :o1, 1333209600 - tz.transition 2012, 10, :o2, 1349539200 - tz.transition 2013, 4, :o1, 1365264000 - tz.transition 2013, 10, :o2, 1380988800 - tz.transition 2014, 4, :o1, 1396713600 - tz.transition 2014, 10, :o2, 1412438400 - tz.transition 2015, 4, :o1, 1428163200 - tz.transition 2015, 10, :o2, 1443888000 - tz.transition 2016, 4, :o1, 1459612800 - tz.transition 2016, 10, :o2, 1475337600 - tz.transition 2017, 4, :o1, 1491062400 - tz.transition 2017, 9, :o2, 1506787200 - tz.transition 2018, 3, :o1, 1522512000 - tz.transition 2018, 10, :o2, 1538841600 - tz.transition 2019, 4, :o1, 1554566400 - tz.transition 2019, 10, :o2, 1570291200 - tz.transition 2020, 4, :o1, 1586016000 - tz.transition 2020, 10, :o2, 1601740800 - tz.transition 2021, 4, :o1, 1617465600 - tz.transition 2021, 10, :o2, 1633190400 - tz.transition 2022, 4, :o1, 1648915200 - tz.transition 2022, 10, :o2, 1664640000 - tz.transition 2023, 4, :o1, 1680364800 - tz.transition 2023, 9, :o2, 1696089600 - tz.transition 2024, 4, :o1, 1712419200 - tz.transition 2024, 10, :o2, 1728144000 - tz.transition 2025, 4, :o1, 1743868800 - tz.transition 2025, 10, :o2, 1759593600 - tz.transition 2026, 4, :o1, 1775318400 - tz.transition 2026, 10, :o2, 1791043200 - tz.transition 2027, 4, :o1, 1806768000 - tz.transition 2027, 10, :o2, 1822492800 - tz.transition 2028, 4, :o1, 1838217600 - tz.transition 2028, 9, :o2, 1853942400 - tz.transition 2029, 3, :o1, 1869667200 - tz.transition 2029, 10, :o2, 1885996800 - tz.transition 2030, 4, :o1, 1901721600 - tz.transition 2030, 10, :o2, 1917446400 - tz.transition 2031, 4, :o1, 1933171200 - tz.transition 2031, 10, :o2, 1948896000 - tz.transition 2032, 4, :o1, 1964620800 - tz.transition 2032, 10, :o2, 1980345600 - tz.transition 2033, 4, :o1, 1996070400 - tz.transition 2033, 10, :o2, 2011795200 - tz.transition 2034, 4, :o1, 2027520000 - tz.transition 2034, 9, :o2, 2043244800 - tz.transition 2035, 3, :o1, 2058969600 - tz.transition 2035, 10, :o2, 2075299200 - tz.transition 2036, 4, :o1, 2091024000 - tz.transition 2036, 10, :o2, 2106748800 - tz.transition 2037, 4, :o1, 2122473600 - tz.transition 2037, 10, :o2, 2138198400 - tz.transition 2038, 4, :o1, 14793103, 6 - tz.transition 2038, 10, :o2, 14794195, 6 - tz.transition 2039, 4, :o1, 14795287, 6 - tz.transition 2039, 10, :o2, 14796379, 6 - tz.transition 2040, 3, :o1, 14797471, 6 - tz.transition 2040, 10, :o2, 14798605, 6 - tz.transition 2041, 4, :o1, 14799697, 6 - tz.transition 2041, 10, :o2, 14800789, 6 - tz.transition 2042, 4, :o1, 14801881, 6 - tz.transition 2042, 10, :o2, 14802973, 6 - tz.transition 2043, 4, :o1, 14804065, 6 - tz.transition 2043, 10, :o2, 14805157, 6 - tz.transition 2044, 4, :o1, 14806249, 6 - tz.transition 2044, 10, :o2, 14807341, 6 - tz.transition 2045, 4, :o1, 14808433, 6 - tz.transition 2045, 9, :o2, 14809525, 6 - tz.transition 2046, 3, :o1, 14810617, 6 - tz.transition 2046, 10, :o2, 14811751, 6 - tz.transition 2047, 4, :o1, 14812843, 6 - tz.transition 2047, 10, :o2, 14813935, 6 - tz.transition 2048, 4, :o1, 14815027, 6 - tz.transition 2048, 10, :o2, 14816119, 6 - tz.transition 2049, 4, :o1, 14817211, 6 - tz.transition 2049, 10, :o2, 14818303, 6 - tz.transition 2050, 4, :o1, 14819395, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb deleted file mode 100644 index 28b2c6a0..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Etc - module UTC - include TimezoneDefinition - - timezone 'Etc/UTC' do |tz| - tz.offset :o0, 0, 0, :UTC - - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb deleted file mode 100644 index 2d0c95c4..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +++ /dev/null @@ -1,228 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Amsterdam - include TimezoneDefinition - - timezone 'Europe/Amsterdam' do |tz| - tz.offset :o0, 1172, 0, :LMT - tz.offset :o1, 1172, 0, :AMT - tz.offset :o2, 1172, 3600, :NST - tz.offset :o3, 1200, 3600, :NEST - tz.offset :o4, 1200, 0, :NET - tz.offset :o5, 3600, 3600, :CEST - tz.offset :o6, 3600, 0, :CET - - tz.transition 1834, 12, :o1, 51651636907, 21600 - tz.transition 1916, 4, :o2, 52293264907, 21600 - tz.transition 1916, 9, :o1, 52296568807, 21600 - tz.transition 1917, 4, :o2, 52300826707, 21600 - tz.transition 1917, 9, :o1, 52304153107, 21600 - tz.transition 1918, 4, :o2, 52308386707, 21600 - tz.transition 1918, 9, :o1, 52312317907, 21600 - tz.transition 1919, 4, :o2, 52316400307, 21600 - tz.transition 1919, 9, :o1, 52320180307, 21600 - tz.transition 1920, 4, :o2, 52324262707, 21600 - tz.transition 1920, 9, :o1, 52328042707, 21600 - tz.transition 1921, 4, :o2, 52332125107, 21600 - tz.transition 1921, 9, :o1, 52335905107, 21600 - tz.transition 1922, 3, :o2, 52339814707, 21600 - tz.transition 1922, 10, :o1, 52344048307, 21600 - tz.transition 1923, 6, :o2, 52349145907, 21600 - tz.transition 1923, 10, :o1, 52351910707, 21600 - tz.transition 1924, 3, :o2, 52355690707, 21600 - tz.transition 1924, 10, :o1, 52359773107, 21600 - tz.transition 1925, 6, :o2, 52365021907, 21600 - tz.transition 1925, 10, :o1, 52367635507, 21600 - tz.transition 1926, 5, :o2, 52372452307, 21600 - tz.transition 1926, 10, :o1, 52375497907, 21600 - tz.transition 1927, 5, :o2, 52380336307, 21600 - tz.transition 1927, 10, :o1, 52383360307, 21600 - tz.transition 1928, 5, :o2, 52388241907, 21600 - tz.transition 1928, 10, :o1, 52391373907, 21600 - tz.transition 1929, 5, :o2, 52396125907, 21600 - tz.transition 1929, 10, :o1, 52399236307, 21600 - tz.transition 1930, 5, :o2, 52404009907, 21600 - tz.transition 1930, 10, :o1, 52407098707, 21600 - tz.transition 1931, 5, :o2, 52411893907, 21600 - tz.transition 1931, 10, :o1, 52414961107, 21600 - tz.transition 1932, 5, :o2, 52419950707, 21600 - tz.transition 1932, 10, :o1, 52422823507, 21600 - tz.transition 1933, 5, :o2, 52427683507, 21600 - tz.transition 1933, 10, :o1, 52430837107, 21600 - tz.transition 1934, 5, :o2, 52435567507, 21600 - tz.transition 1934, 10, :o1, 52438699507, 21600 - tz.transition 1935, 5, :o2, 52443451507, 21600 - tz.transition 1935, 10, :o1, 52446561907, 21600 - tz.transition 1936, 5, :o2, 52451357107, 21600 - tz.transition 1936, 10, :o1, 52454424307, 21600 - tz.transition 1937, 5, :o2, 52459392307, 21600 - tz.transition 1937, 6, :o3, 52460253607, 21600 - tz.transition 1937, 10, :o4, 174874289, 72 - tz.transition 1938, 5, :o3, 174890417, 72 - tz.transition 1938, 10, :o4, 174900497, 72 - tz.transition 1939, 5, :o3, 174916697, 72 - tz.transition 1939, 10, :o4, 174927209, 72 - tz.transition 1940, 5, :o5, 174943115, 72 - tz.transition 1942, 11, :o6, 58335973, 24 - tz.transition 1943, 3, :o5, 58339501, 24 - tz.transition 1943, 10, :o6, 58344037, 24 - tz.transition 1944, 4, :o5, 58348405, 24 - tz.transition 1944, 10, :o6, 58352773, 24 - tz.transition 1945, 4, :o5, 58357141, 24 - tz.transition 1945, 9, :o6, 58361149, 24 - tz.transition 1977, 4, :o5, 228877200 - tz.transition 1977, 9, :o6, 243997200 - tz.transition 1978, 4, :o5, 260326800 - tz.transition 1978, 10, :o6, 276051600 - tz.transition 1979, 4, :o5, 291776400 - tz.transition 1979, 9, :o6, 307501200 - tz.transition 1980, 4, :o5, 323830800 - tz.transition 1980, 9, :o6, 338950800 - tz.transition 1981, 3, :o5, 354675600 - tz.transition 1981, 9, :o6, 370400400 - tz.transition 1982, 3, :o5, 386125200 - tz.transition 1982, 9, :o6, 401850000 - tz.transition 1983, 3, :o5, 417574800 - tz.transition 1983, 9, :o6, 433299600 - tz.transition 1984, 3, :o5, 449024400 - tz.transition 1984, 9, :o6, 465354000 - tz.transition 1985, 3, :o5, 481078800 - tz.transition 1985, 9, :o6, 496803600 - tz.transition 1986, 3, :o5, 512528400 - tz.transition 1986, 9, :o6, 528253200 - tz.transition 1987, 3, :o5, 543978000 - tz.transition 1987, 9, :o6, 559702800 - tz.transition 1988, 3, :o5, 575427600 - tz.transition 1988, 9, :o6, 591152400 - tz.transition 1989, 3, :o5, 606877200 - tz.transition 1989, 9, :o6, 622602000 - tz.transition 1990, 3, :o5, 638326800 - tz.transition 1990, 9, :o6, 654656400 - tz.transition 1991, 3, :o5, 670381200 - tz.transition 1991, 9, :o6, 686106000 - tz.transition 1992, 3, :o5, 701830800 - tz.transition 1992, 9, :o6, 717555600 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 9, :o6, 749005200 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 9, :o6, 780454800 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 9, :o6, 811904400 - tz.transition 1996, 3, :o5, 828234000 - tz.transition 1996, 10, :o6, 846378000 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o6, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o6, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o6, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o6, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o6, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o6, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o6, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o6, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o6, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o6, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o6, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o6, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o6, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o6, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o6, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o6, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o6, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o6, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o6, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o6, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o6, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o6, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o6, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o6, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o6, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o6, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o6, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o6, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o6, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o6, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o6, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o6, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o6, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o6, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o6, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o6, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o6, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o6, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o6, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o6, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o6, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o6, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o6, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o6, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o6, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o6, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o6, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o6, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o6, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o6, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o6, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o6, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o6, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o6, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb deleted file mode 100644 index 4e21e535..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Athens - include TimezoneDefinition - - timezone 'Europe/Athens' do |tz| - tz.offset :o0, 5692, 0, :LMT - tz.offset :o1, 5692, 0, :AMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - - tz.transition 1895, 9, :o1, 52130529377, 21600 - tz.transition 1916, 7, :o2, 3268447787, 1350 - tz.transition 1932, 7, :o3, 29122745, 12 - tz.transition 1932, 8, :o2, 19415611, 8 - tz.transition 1941, 4, :o3, 29161097, 12 - tz.transition 1941, 4, :o4, 19440915, 8 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339523, 24 - tz.transition 1943, 10, :o5, 29172017, 12 - tz.transition 1944, 4, :o2, 58348427, 24 - tz.transition 1952, 6, :o3, 29210333, 12 - tz.transition 1952, 11, :o2, 19474547, 8 - tz.transition 1975, 4, :o3, 166485600 - tz.transition 1975, 11, :o2, 186184800 - tz.transition 1976, 4, :o3, 198028800 - tz.transition 1976, 10, :o2, 213753600 - tz.transition 1977, 4, :o3, 228873600 - tz.transition 1977, 9, :o2, 244080000 - tz.transition 1978, 4, :o3, 260323200 - tz.transition 1978, 9, :o2, 275446800 - tz.transition 1979, 4, :o3, 291798000 - tz.transition 1979, 9, :o2, 307407600 - tz.transition 1980, 3, :o3, 323388000 - tz.transition 1980, 9, :o2, 338936400 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb deleted file mode 100644 index 4dbd893d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Belgrade - include TimezoneDefinition - - timezone 'Europe/Belgrade' do |tz| - tz.offset :o0, 4920, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - - tz.transition 1883, 12, :o1, 1734607039, 720 - tz.transition 1941, 4, :o2, 29161241, 12 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 5, :o2, 58358005, 24 - tz.transition 1945, 9, :o1, 58361149, 24 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb deleted file mode 100644 index 72105423..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +++ /dev/null @@ -1,188 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Berlin - include TimezoneDefinition - - timezone 'Europe/Berlin' do |tz| - tz.offset :o0, 3208, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - tz.offset :o3, 3600, 7200, :CEMT - - tz.transition 1893, 3, :o1, 26055588199, 10800 - tz.transition 1916, 4, :o2, 29051813, 12 - tz.transition 1916, 9, :o1, 58107299, 24 - tz.transition 1917, 4, :o2, 58112029, 24 - tz.transition 1917, 9, :o1, 58115725, 24 - tz.transition 1918, 4, :o2, 58120765, 24 - tz.transition 1918, 9, :o1, 58124461, 24 - tz.transition 1940, 4, :o2, 58313293, 24 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 4, :o2, 58357141, 24 - tz.transition 1945, 5, :o3, 4863199, 2 - tz.transition 1945, 9, :o2, 4863445, 2 - tz.transition 1945, 11, :o1, 58362661, 24 - tz.transition 1946, 4, :o2, 58366189, 24 - tz.transition 1946, 10, :o1, 58370413, 24 - tz.transition 1947, 4, :o2, 29187379, 12 - tz.transition 1947, 5, :o3, 58375597, 24 - tz.transition 1947, 6, :o2, 4864731, 2 - tz.transition 1947, 10, :o1, 58379125, 24 - tz.transition 1948, 4, :o2, 58383829, 24 - tz.transition 1948, 10, :o1, 58387861, 24 - tz.transition 1949, 4, :o2, 58392397, 24 - tz.transition 1949, 10, :o1, 58396597, 24 - tz.transition 1980, 4, :o2, 323830800 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb deleted file mode 100644 index 7a731a0b..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Bratislava - include TimezoneDefinition - - linked_timezone 'Europe/Bratislava', 'Europe/Prague' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb deleted file mode 100644 index 6b0a2429..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Brussels - include TimezoneDefinition - - timezone 'Europe/Brussels' do |tz| - tz.offset :o0, 1050, 0, :LMT - tz.offset :o1, 1050, 0, :BMT - tz.offset :o2, 0, 0, :WET - tz.offset :o3, 3600, 0, :CET - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 0, 3600, :WEST - - tz.transition 1879, 12, :o1, 1386844121, 576 - tz.transition 1892, 5, :o2, 1389438713, 576 - tz.transition 1914, 11, :o3, 4840889, 2 - tz.transition 1916, 4, :o4, 58103627, 24 - tz.transition 1916, 9, :o3, 58107299, 24 - tz.transition 1917, 4, :o4, 58112029, 24 - tz.transition 1917, 9, :o3, 58115725, 24 - tz.transition 1918, 4, :o4, 58120765, 24 - tz.transition 1918, 9, :o3, 58124461, 24 - tz.transition 1918, 11, :o2, 58125815, 24 - tz.transition 1919, 3, :o5, 58128467, 24 - tz.transition 1919, 10, :o2, 58133675, 24 - tz.transition 1920, 2, :o5, 58136867, 24 - tz.transition 1920, 10, :o2, 58142915, 24 - tz.transition 1921, 3, :o5, 58146323, 24 - tz.transition 1921, 10, :o2, 58151723, 24 - tz.transition 1922, 3, :o5, 58155347, 24 - tz.transition 1922, 10, :o2, 58160051, 24 - tz.transition 1923, 4, :o5, 58164755, 24 - tz.transition 1923, 10, :o2, 58168787, 24 - tz.transition 1924, 3, :o5, 58172987, 24 - tz.transition 1924, 10, :o2, 58177523, 24 - tz.transition 1925, 4, :o5, 58181891, 24 - tz.transition 1925, 10, :o2, 58186259, 24 - tz.transition 1926, 4, :o5, 58190963, 24 - tz.transition 1926, 10, :o2, 58194995, 24 - tz.transition 1927, 4, :o5, 58199531, 24 - tz.transition 1927, 10, :o2, 58203731, 24 - tz.transition 1928, 4, :o5, 58208435, 24 - tz.transition 1928, 10, :o2, 29106319, 12 - tz.transition 1929, 4, :o5, 29108671, 12 - tz.transition 1929, 10, :o2, 29110687, 12 - tz.transition 1930, 4, :o5, 29112955, 12 - tz.transition 1930, 10, :o2, 29115055, 12 - tz.transition 1931, 4, :o5, 29117407, 12 - tz.transition 1931, 10, :o2, 29119423, 12 - tz.transition 1932, 4, :o5, 29121607, 12 - tz.transition 1932, 10, :o2, 29123791, 12 - tz.transition 1933, 3, :o5, 29125891, 12 - tz.transition 1933, 10, :o2, 29128243, 12 - tz.transition 1934, 4, :o5, 29130427, 12 - tz.transition 1934, 10, :o2, 29132611, 12 - tz.transition 1935, 3, :o5, 29134711, 12 - tz.transition 1935, 10, :o2, 29136979, 12 - tz.transition 1936, 4, :o5, 29139331, 12 - tz.transition 1936, 10, :o2, 29141347, 12 - tz.transition 1937, 4, :o5, 29143531, 12 - tz.transition 1937, 10, :o2, 29145715, 12 - tz.transition 1938, 3, :o5, 29147815, 12 - tz.transition 1938, 10, :o2, 29150083, 12 - tz.transition 1939, 4, :o5, 29152435, 12 - tz.transition 1939, 11, :o2, 29155039, 12 - tz.transition 1940, 2, :o5, 29156215, 12 - tz.transition 1940, 5, :o4, 29157235, 12 - tz.transition 1942, 11, :o3, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o3, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 9, :o3, 58352413, 24 - tz.transition 1945, 4, :o4, 58357141, 24 - tz.transition 1945, 9, :o3, 58361149, 24 - tz.transition 1946, 5, :o4, 58367029, 24 - tz.transition 1946, 10, :o3, 58370413, 24 - tz.transition 1977, 4, :o4, 228877200 - tz.transition 1977, 9, :o3, 243997200 - tz.transition 1978, 4, :o4, 260326800 - tz.transition 1978, 10, :o3, 276051600 - tz.transition 1979, 4, :o4, 291776400 - tz.transition 1979, 9, :o3, 307501200 - tz.transition 1980, 4, :o4, 323830800 - tz.transition 1980, 9, :o3, 338950800 - tz.transition 1981, 3, :o4, 354675600 - tz.transition 1981, 9, :o3, 370400400 - tz.transition 1982, 3, :o4, 386125200 - tz.transition 1982, 9, :o3, 401850000 - tz.transition 1983, 3, :o4, 417574800 - tz.transition 1983, 9, :o3, 433299600 - tz.transition 1984, 3, :o4, 449024400 - tz.transition 1984, 9, :o3, 465354000 - tz.transition 1985, 3, :o4, 481078800 - tz.transition 1985, 9, :o3, 496803600 - tz.transition 1986, 3, :o4, 512528400 - tz.transition 1986, 9, :o3, 528253200 - tz.transition 1987, 3, :o4, 543978000 - tz.transition 1987, 9, :o3, 559702800 - tz.transition 1988, 3, :o4, 575427600 - tz.transition 1988, 9, :o3, 591152400 - tz.transition 1989, 3, :o4, 606877200 - tz.transition 1989, 9, :o3, 622602000 - tz.transition 1990, 3, :o4, 638326800 - tz.transition 1990, 9, :o3, 654656400 - tz.transition 1991, 3, :o4, 670381200 - tz.transition 1991, 9, :o3, 686106000 - tz.transition 1992, 3, :o4, 701830800 - tz.transition 1992, 9, :o3, 717555600 - tz.transition 1993, 3, :o4, 733280400 - tz.transition 1993, 9, :o3, 749005200 - tz.transition 1994, 3, :o4, 764730000 - tz.transition 1994, 9, :o3, 780454800 - tz.transition 1995, 3, :o4, 796179600 - tz.transition 1995, 9, :o3, 811904400 - tz.transition 1996, 3, :o4, 828234000 - tz.transition 1996, 10, :o3, 846378000 - tz.transition 1997, 3, :o4, 859683600 - tz.transition 1997, 10, :o3, 877827600 - tz.transition 1998, 3, :o4, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o4, 922582800 - tz.transition 1999, 10, :o3, 941331600 - tz.transition 2000, 3, :o4, 954032400 - tz.transition 2000, 10, :o3, 972781200 - tz.transition 2001, 3, :o4, 985482000 - tz.transition 2001, 10, :o3, 1004230800 - tz.transition 2002, 3, :o4, 1017536400 - tz.transition 2002, 10, :o3, 1035680400 - tz.transition 2003, 3, :o4, 1048986000 - tz.transition 2003, 10, :o3, 1067130000 - tz.transition 2004, 3, :o4, 1080435600 - tz.transition 2004, 10, :o3, 1099184400 - tz.transition 2005, 3, :o4, 1111885200 - tz.transition 2005, 10, :o3, 1130634000 - tz.transition 2006, 3, :o4, 1143334800 - tz.transition 2006, 10, :o3, 1162083600 - tz.transition 2007, 3, :o4, 1174784400 - tz.transition 2007, 10, :o3, 1193533200 - tz.transition 2008, 3, :o4, 1206838800 - tz.transition 2008, 10, :o3, 1224982800 - tz.transition 2009, 3, :o4, 1238288400 - tz.transition 2009, 10, :o3, 1256432400 - tz.transition 2010, 3, :o4, 1269738000 - tz.transition 2010, 10, :o3, 1288486800 - tz.transition 2011, 3, :o4, 1301187600 - tz.transition 2011, 10, :o3, 1319936400 - tz.transition 2012, 3, :o4, 1332637200 - tz.transition 2012, 10, :o3, 1351386000 - tz.transition 2013, 3, :o4, 1364691600 - tz.transition 2013, 10, :o3, 1382835600 - tz.transition 2014, 3, :o4, 1396141200 - tz.transition 2014, 10, :o3, 1414285200 - tz.transition 2015, 3, :o4, 1427590800 - tz.transition 2015, 10, :o3, 1445734800 - tz.transition 2016, 3, :o4, 1459040400 - tz.transition 2016, 10, :o3, 1477789200 - tz.transition 2017, 3, :o4, 1490490000 - tz.transition 2017, 10, :o3, 1509238800 - tz.transition 2018, 3, :o4, 1521939600 - tz.transition 2018, 10, :o3, 1540688400 - tz.transition 2019, 3, :o4, 1553994000 - tz.transition 2019, 10, :o3, 1572138000 - tz.transition 2020, 3, :o4, 1585443600 - tz.transition 2020, 10, :o3, 1603587600 - tz.transition 2021, 3, :o4, 1616893200 - tz.transition 2021, 10, :o3, 1635642000 - tz.transition 2022, 3, :o4, 1648342800 - tz.transition 2022, 10, :o3, 1667091600 - tz.transition 2023, 3, :o4, 1679792400 - tz.transition 2023, 10, :o3, 1698541200 - tz.transition 2024, 3, :o4, 1711846800 - tz.transition 2024, 10, :o3, 1729990800 - tz.transition 2025, 3, :o4, 1743296400 - tz.transition 2025, 10, :o3, 1761440400 - tz.transition 2026, 3, :o4, 1774746000 - tz.transition 2026, 10, :o3, 1792890000 - tz.transition 2027, 3, :o4, 1806195600 - tz.transition 2027, 10, :o3, 1824944400 - tz.transition 2028, 3, :o4, 1837645200 - tz.transition 2028, 10, :o3, 1856394000 - tz.transition 2029, 3, :o4, 1869094800 - tz.transition 2029, 10, :o3, 1887843600 - tz.transition 2030, 3, :o4, 1901149200 - tz.transition 2030, 10, :o3, 1919293200 - tz.transition 2031, 3, :o4, 1932598800 - tz.transition 2031, 10, :o3, 1950742800 - tz.transition 2032, 3, :o4, 1964048400 - tz.transition 2032, 10, :o3, 1982797200 - tz.transition 2033, 3, :o4, 1995498000 - tz.transition 2033, 10, :o3, 2014246800 - tz.transition 2034, 3, :o4, 2026947600 - tz.transition 2034, 10, :o3, 2045696400 - tz.transition 2035, 3, :o4, 2058397200 - tz.transition 2035, 10, :o3, 2077146000 - tz.transition 2036, 3, :o4, 2090451600 - tz.transition 2036, 10, :o3, 2108595600 - tz.transition 2037, 3, :o4, 2121901200 - tz.transition 2037, 10, :o3, 2140045200 - tz.transition 2038, 3, :o4, 59172253, 24 - tz.transition 2038, 10, :o3, 59177461, 24 - tz.transition 2039, 3, :o4, 59180989, 24 - tz.transition 2039, 10, :o3, 59186197, 24 - tz.transition 2040, 3, :o4, 59189725, 24 - tz.transition 2040, 10, :o3, 59194933, 24 - tz.transition 2041, 3, :o4, 59198629, 24 - tz.transition 2041, 10, :o3, 59203669, 24 - tz.transition 2042, 3, :o4, 59207365, 24 - tz.transition 2042, 10, :o3, 59212405, 24 - tz.transition 2043, 3, :o4, 59216101, 24 - tz.transition 2043, 10, :o3, 59221141, 24 - tz.transition 2044, 3, :o4, 59224837, 24 - tz.transition 2044, 10, :o3, 59230045, 24 - tz.transition 2045, 3, :o4, 59233573, 24 - tz.transition 2045, 10, :o3, 59238781, 24 - tz.transition 2046, 3, :o4, 59242309, 24 - tz.transition 2046, 10, :o3, 59247517, 24 - tz.transition 2047, 3, :o4, 59251213, 24 - tz.transition 2047, 10, :o3, 59256253, 24 - tz.transition 2048, 3, :o4, 59259949, 24 - tz.transition 2048, 10, :o3, 59264989, 24 - tz.transition 2049, 3, :o4, 59268685, 24 - tz.transition 2049, 10, :o3, 59273893, 24 - tz.transition 2050, 3, :o4, 59277421, 24 - tz.transition 2050, 10, :o3, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb deleted file mode 100644 index 521c3c93..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Bucharest - include TimezoneDefinition - - timezone 'Europe/Bucharest' do |tz| - tz.offset :o0, 6264, 0, :LMT - tz.offset :o1, 6264, 0, :BMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - - tz.transition 1891, 9, :o1, 964802571, 400 - tz.transition 1931, 7, :o2, 970618571, 400 - tz.transition 1932, 5, :o3, 29122181, 12 - tz.transition 1932, 10, :o2, 29123789, 12 - tz.transition 1933, 4, :o3, 29125973, 12 - tz.transition 1933, 9, :o2, 29128157, 12 - tz.transition 1934, 4, :o3, 29130425, 12 - tz.transition 1934, 10, :o2, 29132609, 12 - tz.transition 1935, 4, :o3, 29134793, 12 - tz.transition 1935, 10, :o2, 29136977, 12 - tz.transition 1936, 4, :o3, 29139161, 12 - tz.transition 1936, 10, :o2, 29141345, 12 - tz.transition 1937, 4, :o3, 29143529, 12 - tz.transition 1937, 10, :o2, 29145713, 12 - tz.transition 1938, 4, :o3, 29147897, 12 - tz.transition 1938, 10, :o2, 29150081, 12 - tz.transition 1939, 4, :o3, 29152265, 12 - tz.transition 1939, 9, :o2, 29154449, 12 - tz.transition 1979, 5, :o3, 296604000 - tz.transition 1979, 9, :o2, 307486800 - tz.transition 1980, 4, :o3, 323816400 - tz.transition 1980, 9, :o2, 338940000 - tz.transition 1981, 3, :o3, 354672000 - tz.transition 1981, 9, :o2, 370396800 - tz.transition 1982, 3, :o3, 386121600 - tz.transition 1982, 9, :o2, 401846400 - tz.transition 1983, 3, :o3, 417571200 - tz.transition 1983, 9, :o2, 433296000 - tz.transition 1984, 3, :o3, 449020800 - tz.transition 1984, 9, :o2, 465350400 - tz.transition 1985, 3, :o3, 481075200 - tz.transition 1985, 9, :o2, 496800000 - tz.transition 1986, 3, :o3, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o3, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o3, 575424000 - tz.transition 1988, 9, :o2, 591148800 - tz.transition 1989, 3, :o3, 606873600 - tz.transition 1989, 9, :o2, 622598400 - tz.transition 1990, 3, :o3, 638323200 - tz.transition 1990, 9, :o2, 654652800 - tz.transition 1991, 3, :o3, 670370400 - tz.transition 1991, 9, :o2, 686095200 - tz.transition 1992, 3, :o3, 701820000 - tz.transition 1992, 9, :o2, 717544800 - tz.transition 1993, 3, :o3, 733269600 - tz.transition 1993, 9, :o2, 748994400 - tz.transition 1994, 3, :o3, 764719200 - tz.transition 1994, 9, :o2, 780440400 - tz.transition 1995, 3, :o3, 796168800 - tz.transition 1995, 9, :o2, 811890000 - tz.transition 1996, 3, :o3, 828223200 - tz.transition 1996, 10, :o2, 846363600 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb deleted file mode 100644 index 1f3a9738..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +++ /dev/null @@ -1,197 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Budapest - include TimezoneDefinition - - timezone 'Europe/Budapest' do |tz| - tz.offset :o0, 4580, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - - tz.transition 1890, 9, :o1, 10418291051, 4320 - tz.transition 1916, 4, :o2, 29051813, 12 - tz.transition 1916, 9, :o1, 58107299, 24 - tz.transition 1917, 4, :o2, 58112029, 24 - tz.transition 1917, 9, :o1, 58115725, 24 - tz.transition 1918, 4, :o2, 29060215, 12 - tz.transition 1918, 9, :o1, 58124773, 24 - tz.transition 1919, 4, :o2, 29064763, 12 - tz.transition 1919, 9, :o1, 58133197, 24 - tz.transition 1920, 4, :o2, 29069035, 12 - tz.transition 1920, 9, :o1, 58142341, 24 - tz.transition 1941, 4, :o2, 58322173, 24 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 5, :o2, 29178929, 12 - tz.transition 1945, 11, :o1, 29181149, 12 - tz.transition 1946, 3, :o2, 58365853, 24 - tz.transition 1946, 10, :o1, 58370389, 24 - tz.transition 1947, 4, :o2, 58374757, 24 - tz.transition 1947, 10, :o1, 58379125, 24 - tz.transition 1948, 4, :o2, 58383493, 24 - tz.transition 1948, 10, :o1, 58387861, 24 - tz.transition 1949, 4, :o2, 58392397, 24 - tz.transition 1949, 10, :o1, 58396597, 24 - tz.transition 1950, 4, :o2, 58401325, 24 - tz.transition 1950, 10, :o1, 58405861, 24 - tz.transition 1954, 5, :o2, 58437251, 24 - tz.transition 1954, 10, :o1, 29220221, 12 - tz.transition 1955, 5, :o2, 58446011, 24 - tz.transition 1955, 10, :o1, 29224601, 12 - tz.transition 1956, 6, :o2, 58455059, 24 - tz.transition 1956, 9, :o1, 29228957, 12 - tz.transition 1957, 6, :o2, 4871983, 2 - tz.transition 1957, 9, :o1, 58466653, 24 - tz.transition 1980, 4, :o2, 323827200 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb deleted file mode 100644 index 47cbaf14..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +++ /dev/null @@ -1,179 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Copenhagen - include TimezoneDefinition - - timezone 'Europe/Copenhagen' do |tz| - tz.offset :o0, 3020, 0, :LMT - tz.offset :o1, 3020, 0, :CMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1889, 12, :o1, 10417111769, 4320 - tz.transition 1893, 12, :o2, 10423423289, 4320 - tz.transition 1916, 5, :o3, 29051981, 12 - tz.transition 1916, 9, :o2, 19369099, 8 - tz.transition 1940, 5, :o3, 58314347, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 10, :o2, 58352773, 24 - tz.transition 1945, 4, :o3, 58357141, 24 - tz.transition 1945, 8, :o2, 58360381, 24 - tz.transition 1946, 5, :o3, 58366597, 24 - tz.transition 1946, 9, :o2, 58369549, 24 - tz.transition 1947, 5, :o3, 58375429, 24 - tz.transition 1947, 8, :o2, 58377781, 24 - tz.transition 1948, 5, :o3, 58384333, 24 - tz.transition 1948, 8, :o2, 58386517, 24 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb deleted file mode 100644 index 0560bb54..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +++ /dev/null @@ -1,276 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Dublin - include TimezoneDefinition - - timezone 'Europe/Dublin' do |tz| - tz.offset :o0, -1500, 0, :LMT - tz.offset :o1, -1521, 0, :DMT - tz.offset :o2, -1521, 3600, :IST - tz.offset :o3, 0, 0, :GMT - tz.offset :o4, 0, 3600, :BST - tz.offset :o5, 0, 3600, :IST - tz.offset :o6, 3600, 0, :IST - - tz.transition 1880, 8, :o1, 693483701, 288 - tz.transition 1916, 5, :o2, 7747214723, 3200 - tz.transition 1916, 10, :o3, 7747640323, 3200 - tz.transition 1917, 4, :o4, 29055919, 12 - tz.transition 1917, 9, :o3, 29057863, 12 - tz.transition 1918, 3, :o4, 29060119, 12 - tz.transition 1918, 9, :o3, 29062399, 12 - tz.transition 1919, 3, :o4, 29064571, 12 - tz.transition 1919, 9, :o3, 29066767, 12 - tz.transition 1920, 3, :o4, 29068939, 12 - tz.transition 1920, 10, :o3, 29071471, 12 - tz.transition 1921, 4, :o4, 29073391, 12 - tz.transition 1921, 10, :o3, 29075587, 12 - tz.transition 1922, 3, :o5, 29077675, 12 - tz.transition 1922, 10, :o3, 29080027, 12 - tz.transition 1923, 4, :o5, 29082379, 12 - tz.transition 1923, 9, :o3, 29084143, 12 - tz.transition 1924, 4, :o5, 29086663, 12 - tz.transition 1924, 9, :o3, 29088595, 12 - tz.transition 1925, 4, :o5, 29091115, 12 - tz.transition 1925, 10, :o3, 29093131, 12 - tz.transition 1926, 4, :o5, 29095483, 12 - tz.transition 1926, 10, :o3, 29097499, 12 - tz.transition 1927, 4, :o5, 29099767, 12 - tz.transition 1927, 10, :o3, 29101867, 12 - tz.transition 1928, 4, :o5, 29104303, 12 - tz.transition 1928, 10, :o3, 29106319, 12 - tz.transition 1929, 4, :o5, 29108671, 12 - tz.transition 1929, 10, :o3, 29110687, 12 - tz.transition 1930, 4, :o5, 29112955, 12 - tz.transition 1930, 10, :o3, 29115055, 12 - tz.transition 1931, 4, :o5, 29117407, 12 - tz.transition 1931, 10, :o3, 29119423, 12 - tz.transition 1932, 4, :o5, 29121775, 12 - tz.transition 1932, 10, :o3, 29123791, 12 - tz.transition 1933, 4, :o5, 29126059, 12 - tz.transition 1933, 10, :o3, 29128243, 12 - tz.transition 1934, 4, :o5, 29130595, 12 - tz.transition 1934, 10, :o3, 29132611, 12 - tz.transition 1935, 4, :o5, 29134879, 12 - tz.transition 1935, 10, :o3, 29136979, 12 - tz.transition 1936, 4, :o5, 29139331, 12 - tz.transition 1936, 10, :o3, 29141347, 12 - tz.transition 1937, 4, :o5, 29143699, 12 - tz.transition 1937, 10, :o3, 29145715, 12 - tz.transition 1938, 4, :o5, 29147983, 12 - tz.transition 1938, 10, :o3, 29150083, 12 - tz.transition 1939, 4, :o5, 29152435, 12 - tz.transition 1939, 11, :o3, 29155039, 12 - tz.transition 1940, 2, :o5, 29156215, 12 - tz.transition 1946, 10, :o3, 58370389, 24 - tz.transition 1947, 3, :o5, 29187127, 12 - tz.transition 1947, 11, :o3, 58379797, 24 - tz.transition 1948, 4, :o5, 29191915, 12 - tz.transition 1948, 10, :o3, 29194267, 12 - tz.transition 1949, 4, :o5, 29196115, 12 - tz.transition 1949, 10, :o3, 29198635, 12 - tz.transition 1950, 4, :o5, 29200651, 12 - tz.transition 1950, 10, :o3, 29202919, 12 - tz.transition 1951, 4, :o5, 29205019, 12 - tz.transition 1951, 10, :o3, 29207287, 12 - tz.transition 1952, 4, :o5, 29209471, 12 - tz.transition 1952, 10, :o3, 29211739, 12 - tz.transition 1953, 4, :o5, 29213839, 12 - tz.transition 1953, 10, :o3, 29215855, 12 - tz.transition 1954, 4, :o5, 29218123, 12 - tz.transition 1954, 10, :o3, 29220223, 12 - tz.transition 1955, 4, :o5, 29222575, 12 - tz.transition 1955, 10, :o3, 29224591, 12 - tz.transition 1956, 4, :o5, 29227027, 12 - tz.transition 1956, 10, :o3, 29229043, 12 - tz.transition 1957, 4, :o5, 29231311, 12 - tz.transition 1957, 10, :o3, 29233411, 12 - tz.transition 1958, 4, :o5, 29235763, 12 - tz.transition 1958, 10, :o3, 29237779, 12 - tz.transition 1959, 4, :o5, 29240131, 12 - tz.transition 1959, 10, :o3, 29242147, 12 - tz.transition 1960, 4, :o5, 29244415, 12 - tz.transition 1960, 10, :o3, 29246515, 12 - tz.transition 1961, 3, :o5, 29248615, 12 - tz.transition 1961, 10, :o3, 29251219, 12 - tz.transition 1962, 3, :o5, 29252983, 12 - tz.transition 1962, 10, :o3, 29255587, 12 - tz.transition 1963, 3, :o5, 29257435, 12 - tz.transition 1963, 10, :o3, 29259955, 12 - tz.transition 1964, 3, :o5, 29261719, 12 - tz.transition 1964, 10, :o3, 29264323, 12 - tz.transition 1965, 3, :o5, 29266087, 12 - tz.transition 1965, 10, :o3, 29268691, 12 - tz.transition 1966, 3, :o5, 29270455, 12 - tz.transition 1966, 10, :o3, 29273059, 12 - tz.transition 1967, 3, :o5, 29274823, 12 - tz.transition 1967, 10, :o3, 29277511, 12 - tz.transition 1968, 2, :o5, 29278855, 12 - tz.transition 1968, 10, :o6, 58563755, 24 - tz.transition 1971, 10, :o3, 57722400 - tz.transition 1972, 3, :o5, 69818400 - tz.transition 1972, 10, :o3, 89172000 - tz.transition 1973, 3, :o5, 101268000 - tz.transition 1973, 10, :o3, 120621600 - tz.transition 1974, 3, :o5, 132717600 - tz.transition 1974, 10, :o3, 152071200 - tz.transition 1975, 3, :o5, 164167200 - tz.transition 1975, 10, :o3, 183520800 - tz.transition 1976, 3, :o5, 196221600 - tz.transition 1976, 10, :o3, 214970400 - tz.transition 1977, 3, :o5, 227671200 - tz.transition 1977, 10, :o3, 246420000 - tz.transition 1978, 3, :o5, 259120800 - tz.transition 1978, 10, :o3, 278474400 - tz.transition 1979, 3, :o5, 290570400 - tz.transition 1979, 10, :o3, 309924000 - tz.transition 1980, 3, :o5, 322020000 - tz.transition 1980, 10, :o3, 341373600 - tz.transition 1981, 3, :o5, 354675600 - tz.transition 1981, 10, :o3, 372819600 - tz.transition 1982, 3, :o5, 386125200 - tz.transition 1982, 10, :o3, 404269200 - tz.transition 1983, 3, :o5, 417574800 - tz.transition 1983, 10, :o3, 435718800 - tz.transition 1984, 3, :o5, 449024400 - tz.transition 1984, 10, :o3, 467773200 - tz.transition 1985, 3, :o5, 481078800 - tz.transition 1985, 10, :o3, 499222800 - tz.transition 1986, 3, :o5, 512528400 - tz.transition 1986, 10, :o3, 530672400 - tz.transition 1987, 3, :o5, 543978000 - tz.transition 1987, 10, :o3, 562122000 - tz.transition 1988, 3, :o5, 575427600 - tz.transition 1988, 10, :o3, 593571600 - tz.transition 1989, 3, :o5, 606877200 - tz.transition 1989, 10, :o3, 625626000 - tz.transition 1990, 3, :o5, 638326800 - tz.transition 1990, 10, :o3, 657075600 - tz.transition 1991, 3, :o5, 670381200 - tz.transition 1991, 10, :o3, 688525200 - tz.transition 1992, 3, :o5, 701830800 - tz.transition 1992, 10, :o3, 719974800 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 10, :o3, 751424400 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 10, :o3, 782874000 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 10, :o3, 814323600 - tz.transition 1996, 3, :o5, 828234000 - tz.transition 1996, 10, :o3, 846378000 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o3, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o3, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o3, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o3, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o3, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o3, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o3, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o3, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o3, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o3, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o3, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o3, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o3, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o3, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o3, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o3, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o3, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o3, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o3, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o3, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o3, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o3, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o3, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o3, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o3, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o3, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o3, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o3, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o3, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o3, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o3, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o3, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o3, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o3, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o3, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o3, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o3, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o3, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o3, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o3, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o3, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o3, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o3, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o3, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o3, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o3, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o3, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o3, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o3, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o3, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o3, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o3, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o3, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb deleted file mode 100644 index 13a806bc..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Helsinki - include TimezoneDefinition - - timezone 'Europe/Helsinki' do |tz| - tz.offset :o0, 5992, 0, :LMT - tz.offset :o1, 5992, 0, :HMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - - tz.transition 1878, 5, :o1, 25997062651, 10800 - tz.transition 1921, 4, :o2, 26166352651, 10800 - tz.transition 1942, 4, :o3, 29165429, 12 - tz.transition 1942, 10, :o2, 19445083, 8 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb deleted file mode 100644 index 8306c475..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +++ /dev/null @@ -1,218 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Istanbul - include TimezoneDefinition - - timezone 'Europe/Istanbul' do |tz| - tz.offset :o0, 6952, 0, :LMT - tz.offset :o1, 7016, 0, :IMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - tz.offset :o4, 10800, 3600, :TRST - tz.offset :o5, 10800, 0, :TRT - - tz.transition 1879, 12, :o1, 26003326531, 10800 - tz.transition 1910, 9, :o2, 26124610523, 10800 - tz.transition 1916, 4, :o3, 29051813, 12 - tz.transition 1916, 9, :o2, 19369099, 8 - tz.transition 1920, 3, :o3, 29068937, 12 - tz.transition 1920, 10, :o2, 19380979, 8 - tz.transition 1921, 4, :o3, 29073389, 12 - tz.transition 1921, 10, :o2, 19383723, 8 - tz.transition 1922, 3, :o3, 29077673, 12 - tz.transition 1922, 10, :o2, 19386683, 8 - tz.transition 1924, 5, :o3, 29087021, 12 - tz.transition 1924, 9, :o2, 19392475, 8 - tz.transition 1925, 4, :o3, 29091257, 12 - tz.transition 1925, 9, :o2, 19395395, 8 - tz.transition 1940, 6, :o3, 29157725, 12 - tz.transition 1940, 10, :o2, 19439259, 8 - tz.transition 1940, 11, :o3, 29159573, 12 - tz.transition 1941, 9, :o2, 19442067, 8 - tz.transition 1942, 3, :o3, 29165405, 12 - tz.transition 1942, 10, :o2, 19445315, 8 - tz.transition 1945, 4, :o3, 29178569, 12 - tz.transition 1945, 10, :o2, 19453891, 8 - tz.transition 1946, 5, :o3, 29183669, 12 - tz.transition 1946, 9, :o2, 19456755, 8 - tz.transition 1947, 4, :o3, 29187545, 12 - tz.transition 1947, 10, :o2, 19459707, 8 - tz.transition 1948, 4, :o3, 29191913, 12 - tz.transition 1948, 10, :o2, 19462619, 8 - tz.transition 1949, 4, :o3, 29196197, 12 - tz.transition 1949, 10, :o2, 19465531, 8 - tz.transition 1950, 4, :o3, 29200685, 12 - tz.transition 1950, 10, :o2, 19468499, 8 - tz.transition 1951, 4, :o3, 29205101, 12 - tz.transition 1951, 10, :o2, 19471419, 8 - tz.transition 1962, 7, :o3, 29254325, 12 - tz.transition 1962, 10, :o2, 19503563, 8 - tz.transition 1964, 5, :o3, 29262365, 12 - tz.transition 1964, 9, :o2, 19509355, 8 - tz.transition 1970, 5, :o3, 10533600 - tz.transition 1970, 10, :o2, 23835600 - tz.transition 1971, 5, :o3, 41983200 - tz.transition 1971, 10, :o2, 55285200 - tz.transition 1972, 5, :o3, 74037600 - tz.transition 1972, 10, :o2, 87339600 - tz.transition 1973, 6, :o3, 107910000 - tz.transition 1973, 11, :o2, 121219200 - tz.transition 1974, 3, :o3, 133920000 - tz.transition 1974, 11, :o2, 152676000 - tz.transition 1975, 3, :o3, 165362400 - tz.transition 1975, 10, :o2, 183502800 - tz.transition 1976, 5, :o3, 202428000 - tz.transition 1976, 10, :o2, 215557200 - tz.transition 1977, 4, :o3, 228866400 - tz.transition 1977, 10, :o2, 245797200 - tz.transition 1978, 4, :o3, 260316000 - tz.transition 1978, 10, :o4, 277246800 - tz.transition 1979, 10, :o5, 308779200 - tz.transition 1980, 4, :o4, 323827200 - tz.transition 1980, 10, :o5, 340228800 - tz.transition 1981, 3, :o4, 354672000 - tz.transition 1981, 10, :o5, 371678400 - tz.transition 1982, 3, :o4, 386121600 - tz.transition 1982, 10, :o5, 403128000 - tz.transition 1983, 7, :o4, 428446800 - tz.transition 1983, 10, :o5, 433886400 - tz.transition 1985, 4, :o3, 482792400 - tz.transition 1985, 9, :o2, 496702800 - tz.transition 1986, 3, :o3, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o3, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o3, 575424000 - tz.transition 1988, 9, :o2, 591148800 - tz.transition 1989, 3, :o3, 606873600 - tz.transition 1989, 9, :o2, 622598400 - tz.transition 1990, 3, :o3, 638323200 - tz.transition 1990, 9, :o2, 654652800 - tz.transition 1991, 3, :o3, 670374000 - tz.transition 1991, 9, :o2, 686098800 - tz.transition 1992, 3, :o3, 701823600 - tz.transition 1992, 9, :o2, 717548400 - tz.transition 1993, 3, :o3, 733273200 - tz.transition 1993, 9, :o2, 748998000 - tz.transition 1994, 3, :o3, 764722800 - tz.transition 1994, 9, :o2, 780447600 - tz.transition 1995, 3, :o3, 796172400 - tz.transition 1995, 9, :o2, 811897200 - tz.transition 1996, 3, :o3, 828226800 - tz.transition 1996, 10, :o2, 846370800 - tz.transition 1997, 3, :o3, 859676400 - tz.transition 1997, 10, :o2, 877820400 - tz.transition 1998, 3, :o3, 891126000 - tz.transition 1998, 10, :o2, 909270000 - tz.transition 1999, 3, :o3, 922575600 - tz.transition 1999, 10, :o2, 941324400 - tz.transition 2000, 3, :o3, 954025200 - tz.transition 2000, 10, :o2, 972774000 - tz.transition 2001, 3, :o3, 985474800 - tz.transition 2001, 10, :o2, 1004223600 - tz.transition 2002, 3, :o3, 1017529200 - tz.transition 2002, 10, :o2, 1035673200 - tz.transition 2003, 3, :o3, 1048978800 - tz.transition 2003, 10, :o2, 1067122800 - tz.transition 2004, 3, :o3, 1080428400 - tz.transition 2004, 10, :o2, 1099177200 - tz.transition 2005, 3, :o3, 1111878000 - tz.transition 2005, 10, :o2, 1130626800 - tz.transition 2006, 3, :o3, 1143327600 - tz.transition 2006, 10, :o2, 1162076400 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb deleted file mode 100644 index 513d3308..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Kiev - include TimezoneDefinition - - timezone 'Europe/Kiev' do |tz| - tz.offset :o0, 7324, 0, :LMT - tz.offset :o1, 7324, 0, :KMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 10800, 0, :MSK - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - tz.offset :o6, 10800, 3600, :MSD - tz.offset :o7, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 52006652969, 21600 - tz.transition 1924, 5, :o2, 52356400169, 21600 - tz.transition 1930, 6, :o3, 29113781, 12 - tz.transition 1941, 9, :o4, 19442059, 8 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o5, 58344037, 24 - tz.transition 1943, 11, :o3, 58344827, 24 - tz.transition 1981, 3, :o6, 354920400 - tz.transition 1981, 9, :o3, 370728000 - tz.transition 1982, 3, :o6, 386456400 - tz.transition 1982, 9, :o3, 402264000 - tz.transition 1983, 3, :o6, 417992400 - tz.transition 1983, 9, :o3, 433800000 - tz.transition 1984, 3, :o6, 449614800 - tz.transition 1984, 9, :o3, 465346800 - tz.transition 1985, 3, :o6, 481071600 - tz.transition 1985, 9, :o3, 496796400 - tz.transition 1986, 3, :o6, 512521200 - tz.transition 1986, 9, :o3, 528246000 - tz.transition 1987, 3, :o6, 543970800 - tz.transition 1987, 9, :o3, 559695600 - tz.transition 1988, 3, :o6, 575420400 - tz.transition 1988, 9, :o3, 591145200 - tz.transition 1989, 3, :o6, 606870000 - tz.transition 1989, 9, :o3, 622594800 - tz.transition 1990, 6, :o2, 646786800 - tz.transition 1992, 3, :o7, 701820000 - tz.transition 1992, 9, :o2, 717541200 - tz.transition 1993, 3, :o7, 733269600 - tz.transition 1993, 9, :o2, 748990800 - tz.transition 1994, 3, :o7, 764719200 - tz.transition 1994, 9, :o2, 780440400 - tz.transition 1995, 3, :o7, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o7, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o7, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o7, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o7, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o7, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o7, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o7, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o7, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o7, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o7, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o7, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o7, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o7, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o7, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o7, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o7, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o7, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o7, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o7, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o7, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o7, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o7, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o7, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o7, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o7, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o7, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o7, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o7, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o7, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o7, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o7, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o7, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o7, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o7, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o7, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o7, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o7, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o7, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o7, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o7, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o7, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o7, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o7, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o7, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o7, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o7, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o7, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o7, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o7, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o7, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o7, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o7, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o7, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o7, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o7, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb deleted file mode 100644 index 1c6d2a3d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +++ /dev/null @@ -1,268 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Lisbon - include TimezoneDefinition - - timezone 'Europe/Lisbon' do |tz| - tz.offset :o0, -2192, 0, :LMT - tz.offset :o1, 0, 0, :WET - tz.offset :o2, 0, 3600, :WEST - tz.offset :o3, 0, 7200, :WEMT - tz.offset :o4, 3600, 0, :CET - tz.offset :o5, 3600, 3600, :CEST - - tz.transition 1912, 1, :o1, 13064773637, 5400 - tz.transition 1916, 6, :o2, 58104779, 24 - tz.transition 1916, 11, :o1, 4842337, 2 - tz.transition 1917, 2, :o2, 58110923, 24 - tz.transition 1917, 10, :o1, 58116395, 24 - tz.transition 1918, 3, :o2, 58119707, 24 - tz.transition 1918, 10, :o1, 58125155, 24 - tz.transition 1919, 2, :o2, 58128443, 24 - tz.transition 1919, 10, :o1, 58133915, 24 - tz.transition 1920, 2, :o2, 58137227, 24 - tz.transition 1920, 10, :o1, 58142699, 24 - tz.transition 1921, 2, :o2, 58145987, 24 - tz.transition 1921, 10, :o1, 58151459, 24 - tz.transition 1924, 4, :o2, 58173419, 24 - tz.transition 1924, 10, :o1, 58177763, 24 - tz.transition 1926, 4, :o2, 58190963, 24 - tz.transition 1926, 10, :o1, 58194995, 24 - tz.transition 1927, 4, :o2, 58199531, 24 - tz.transition 1927, 10, :o1, 58203731, 24 - tz.transition 1928, 4, :o2, 58208435, 24 - tz.transition 1928, 10, :o1, 58212635, 24 - tz.transition 1929, 4, :o2, 58217339, 24 - tz.transition 1929, 10, :o1, 58221371, 24 - tz.transition 1931, 4, :o2, 58234811, 24 - tz.transition 1931, 10, :o1, 58238843, 24 - tz.transition 1932, 4, :o2, 58243211, 24 - tz.transition 1932, 10, :o1, 58247579, 24 - tz.transition 1934, 4, :o2, 58260851, 24 - tz.transition 1934, 10, :o1, 58265219, 24 - tz.transition 1935, 3, :o2, 58269419, 24 - tz.transition 1935, 10, :o1, 58273955, 24 - tz.transition 1936, 4, :o2, 58278659, 24 - tz.transition 1936, 10, :o1, 58282691, 24 - tz.transition 1937, 4, :o2, 58287059, 24 - tz.transition 1937, 10, :o1, 58291427, 24 - tz.transition 1938, 3, :o2, 58295627, 24 - tz.transition 1938, 10, :o1, 58300163, 24 - tz.transition 1939, 4, :o2, 58304867, 24 - tz.transition 1939, 11, :o1, 58310075, 24 - tz.transition 1940, 2, :o2, 58312427, 24 - tz.transition 1940, 10, :o1, 58317803, 24 - tz.transition 1941, 4, :o2, 58322171, 24 - tz.transition 1941, 10, :o1, 58326563, 24 - tz.transition 1942, 3, :o2, 58330403, 24 - tz.transition 1942, 4, :o3, 29165705, 12 - tz.transition 1942, 8, :o2, 29167049, 12 - tz.transition 1942, 10, :o1, 58335779, 24 - tz.transition 1943, 3, :o2, 58339139, 24 - tz.transition 1943, 4, :o3, 29169989, 12 - tz.transition 1943, 8, :o2, 29171585, 12 - tz.transition 1943, 10, :o1, 58344683, 24 - tz.transition 1944, 3, :o2, 58347875, 24 - tz.transition 1944, 4, :o3, 29174441, 12 - tz.transition 1944, 8, :o2, 29175953, 12 - tz.transition 1944, 10, :o1, 58353419, 24 - tz.transition 1945, 3, :o2, 58356611, 24 - tz.transition 1945, 4, :o3, 29178809, 12 - tz.transition 1945, 8, :o2, 29180321, 12 - tz.transition 1945, 10, :o1, 58362155, 24 - tz.transition 1946, 4, :o2, 58366019, 24 - tz.transition 1946, 10, :o1, 58370387, 24 - tz.transition 1947, 4, :o2, 29187379, 12 - tz.transition 1947, 10, :o1, 29189563, 12 - tz.transition 1948, 4, :o2, 29191747, 12 - tz.transition 1948, 10, :o1, 29193931, 12 - tz.transition 1949, 4, :o2, 29196115, 12 - tz.transition 1949, 10, :o1, 29198299, 12 - tz.transition 1951, 4, :o2, 29204851, 12 - tz.transition 1951, 10, :o1, 29207119, 12 - tz.transition 1952, 4, :o2, 29209303, 12 - tz.transition 1952, 10, :o1, 29211487, 12 - tz.transition 1953, 4, :o2, 29213671, 12 - tz.transition 1953, 10, :o1, 29215855, 12 - tz.transition 1954, 4, :o2, 29218039, 12 - tz.transition 1954, 10, :o1, 29220223, 12 - tz.transition 1955, 4, :o2, 29222407, 12 - tz.transition 1955, 10, :o1, 29224591, 12 - tz.transition 1956, 4, :o2, 29226775, 12 - tz.transition 1956, 10, :o1, 29229043, 12 - tz.transition 1957, 4, :o2, 29231227, 12 - tz.transition 1957, 10, :o1, 29233411, 12 - tz.transition 1958, 4, :o2, 29235595, 12 - tz.transition 1958, 10, :o1, 29237779, 12 - tz.transition 1959, 4, :o2, 29239963, 12 - tz.transition 1959, 10, :o1, 29242147, 12 - tz.transition 1960, 4, :o2, 29244331, 12 - tz.transition 1960, 10, :o1, 29246515, 12 - tz.transition 1961, 4, :o2, 29248699, 12 - tz.transition 1961, 10, :o1, 29250883, 12 - tz.transition 1962, 4, :o2, 29253067, 12 - tz.transition 1962, 10, :o1, 29255335, 12 - tz.transition 1963, 4, :o2, 29257519, 12 - tz.transition 1963, 10, :o1, 29259703, 12 - tz.transition 1964, 4, :o2, 29261887, 12 - tz.transition 1964, 10, :o1, 29264071, 12 - tz.transition 1965, 4, :o2, 29266255, 12 - tz.transition 1965, 10, :o1, 29268439, 12 - tz.transition 1966, 4, :o4, 29270623, 12 - tz.transition 1976, 9, :o1, 212544000 - tz.transition 1977, 3, :o2, 228268800 - tz.transition 1977, 9, :o1, 243993600 - tz.transition 1978, 4, :o2, 260323200 - tz.transition 1978, 10, :o1, 276048000 - tz.transition 1979, 4, :o2, 291772800 - tz.transition 1979, 9, :o1, 307501200 - tz.transition 1980, 3, :o2, 323222400 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417578400 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o4, 717555600 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 9, :o4, 749005200 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 9, :o4, 780454800 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 9, :o4, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb deleted file mode 100644 index a9828e6e..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Ljubljana - include TimezoneDefinition - - linked_timezone 'Europe/Ljubljana', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb deleted file mode 100644 index 64ce41e9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +++ /dev/null @@ -1,288 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module London - include TimezoneDefinition - - timezone 'Europe/London' do |tz| - tz.offset :o0, -75, 0, :LMT - tz.offset :o1, 0, 0, :GMT - tz.offset :o2, 0, 3600, :BST - tz.offset :o3, 0, 7200, :BDST - tz.offset :o4, 3600, 0, :BST - - tz.transition 1847, 12, :o1, 2760187969, 1152 - tz.transition 1916, 5, :o2, 29052055, 12 - tz.transition 1916, 10, :o1, 29053651, 12 - tz.transition 1917, 4, :o2, 29055919, 12 - tz.transition 1917, 9, :o1, 29057863, 12 - tz.transition 1918, 3, :o2, 29060119, 12 - tz.transition 1918, 9, :o1, 29062399, 12 - tz.transition 1919, 3, :o2, 29064571, 12 - tz.transition 1919, 9, :o1, 29066767, 12 - tz.transition 1920, 3, :o2, 29068939, 12 - tz.transition 1920, 10, :o1, 29071471, 12 - tz.transition 1921, 4, :o2, 29073391, 12 - tz.transition 1921, 10, :o1, 29075587, 12 - tz.transition 1922, 3, :o2, 29077675, 12 - tz.transition 1922, 10, :o1, 29080027, 12 - tz.transition 1923, 4, :o2, 29082379, 12 - tz.transition 1923, 9, :o1, 29084143, 12 - tz.transition 1924, 4, :o2, 29086663, 12 - tz.transition 1924, 9, :o1, 29088595, 12 - tz.transition 1925, 4, :o2, 29091115, 12 - tz.transition 1925, 10, :o1, 29093131, 12 - tz.transition 1926, 4, :o2, 29095483, 12 - tz.transition 1926, 10, :o1, 29097499, 12 - tz.transition 1927, 4, :o2, 29099767, 12 - tz.transition 1927, 10, :o1, 29101867, 12 - tz.transition 1928, 4, :o2, 29104303, 12 - tz.transition 1928, 10, :o1, 29106319, 12 - tz.transition 1929, 4, :o2, 29108671, 12 - tz.transition 1929, 10, :o1, 29110687, 12 - tz.transition 1930, 4, :o2, 29112955, 12 - tz.transition 1930, 10, :o1, 29115055, 12 - tz.transition 1931, 4, :o2, 29117407, 12 - tz.transition 1931, 10, :o1, 29119423, 12 - tz.transition 1932, 4, :o2, 29121775, 12 - tz.transition 1932, 10, :o1, 29123791, 12 - tz.transition 1933, 4, :o2, 29126059, 12 - tz.transition 1933, 10, :o1, 29128243, 12 - tz.transition 1934, 4, :o2, 29130595, 12 - tz.transition 1934, 10, :o1, 29132611, 12 - tz.transition 1935, 4, :o2, 29134879, 12 - tz.transition 1935, 10, :o1, 29136979, 12 - tz.transition 1936, 4, :o2, 29139331, 12 - tz.transition 1936, 10, :o1, 29141347, 12 - tz.transition 1937, 4, :o2, 29143699, 12 - tz.transition 1937, 10, :o1, 29145715, 12 - tz.transition 1938, 4, :o2, 29147983, 12 - tz.transition 1938, 10, :o1, 29150083, 12 - tz.transition 1939, 4, :o2, 29152435, 12 - tz.transition 1939, 11, :o1, 29155039, 12 - tz.transition 1940, 2, :o2, 29156215, 12 - tz.transition 1941, 5, :o3, 58322845, 24 - tz.transition 1941, 8, :o2, 58325197, 24 - tz.transition 1942, 4, :o3, 58330909, 24 - tz.transition 1942, 8, :o2, 58333933, 24 - tz.transition 1943, 4, :o3, 58339645, 24 - tz.transition 1943, 8, :o2, 58342837, 24 - tz.transition 1944, 4, :o3, 58348381, 24 - tz.transition 1944, 9, :o2, 58352413, 24 - tz.transition 1945, 4, :o3, 58357141, 24 - tz.transition 1945, 7, :o2, 58359637, 24 - tz.transition 1945, 10, :o1, 29180827, 12 - tz.transition 1946, 4, :o2, 29183095, 12 - tz.transition 1946, 10, :o1, 29185195, 12 - tz.transition 1947, 3, :o2, 29187127, 12 - tz.transition 1947, 4, :o3, 58374925, 24 - tz.transition 1947, 8, :o2, 58377781, 24 - tz.transition 1947, 11, :o1, 29189899, 12 - tz.transition 1948, 3, :o2, 29191495, 12 - tz.transition 1948, 10, :o1, 29194267, 12 - tz.transition 1949, 4, :o2, 29196115, 12 - tz.transition 1949, 10, :o1, 29198635, 12 - tz.transition 1950, 4, :o2, 29200651, 12 - tz.transition 1950, 10, :o1, 29202919, 12 - tz.transition 1951, 4, :o2, 29205019, 12 - tz.transition 1951, 10, :o1, 29207287, 12 - tz.transition 1952, 4, :o2, 29209471, 12 - tz.transition 1952, 10, :o1, 29211739, 12 - tz.transition 1953, 4, :o2, 29213839, 12 - tz.transition 1953, 10, :o1, 29215855, 12 - tz.transition 1954, 4, :o2, 29218123, 12 - tz.transition 1954, 10, :o1, 29220223, 12 - tz.transition 1955, 4, :o2, 29222575, 12 - tz.transition 1955, 10, :o1, 29224591, 12 - tz.transition 1956, 4, :o2, 29227027, 12 - tz.transition 1956, 10, :o1, 29229043, 12 - tz.transition 1957, 4, :o2, 29231311, 12 - tz.transition 1957, 10, :o1, 29233411, 12 - tz.transition 1958, 4, :o2, 29235763, 12 - tz.transition 1958, 10, :o1, 29237779, 12 - tz.transition 1959, 4, :o2, 29240131, 12 - tz.transition 1959, 10, :o1, 29242147, 12 - tz.transition 1960, 4, :o2, 29244415, 12 - tz.transition 1960, 10, :o1, 29246515, 12 - tz.transition 1961, 3, :o2, 29248615, 12 - tz.transition 1961, 10, :o1, 29251219, 12 - tz.transition 1962, 3, :o2, 29252983, 12 - tz.transition 1962, 10, :o1, 29255587, 12 - tz.transition 1963, 3, :o2, 29257435, 12 - tz.transition 1963, 10, :o1, 29259955, 12 - tz.transition 1964, 3, :o2, 29261719, 12 - tz.transition 1964, 10, :o1, 29264323, 12 - tz.transition 1965, 3, :o2, 29266087, 12 - tz.transition 1965, 10, :o1, 29268691, 12 - tz.transition 1966, 3, :o2, 29270455, 12 - tz.transition 1966, 10, :o1, 29273059, 12 - tz.transition 1967, 3, :o2, 29274823, 12 - tz.transition 1967, 10, :o1, 29277511, 12 - tz.transition 1968, 2, :o2, 29278855, 12 - tz.transition 1968, 10, :o4, 58563755, 24 - tz.transition 1971, 10, :o1, 57722400 - tz.transition 1972, 3, :o2, 69818400 - tz.transition 1972, 10, :o1, 89172000 - tz.transition 1973, 3, :o2, 101268000 - tz.transition 1973, 10, :o1, 120621600 - tz.transition 1974, 3, :o2, 132717600 - tz.transition 1974, 10, :o1, 152071200 - tz.transition 1975, 3, :o2, 164167200 - tz.transition 1975, 10, :o1, 183520800 - tz.transition 1976, 3, :o2, 196221600 - tz.transition 1976, 10, :o1, 214970400 - tz.transition 1977, 3, :o2, 227671200 - tz.transition 1977, 10, :o1, 246420000 - tz.transition 1978, 3, :o2, 259120800 - tz.transition 1978, 10, :o1, 278474400 - tz.transition 1979, 3, :o2, 290570400 - tz.transition 1979, 10, :o1, 309924000 - tz.transition 1980, 3, :o2, 322020000 - tz.transition 1980, 10, :o1, 341373600 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 10, :o1, 372819600 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 10, :o1, 404269200 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 10, :o1, 435718800 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 10, :o1, 467773200 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 10, :o1, 499222800 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 10, :o1, 530672400 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 10, :o1, 562122000 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 10, :o1, 593571600 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 10, :o1, 625626000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 10, :o1, 657075600 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 10, :o1, 688525200 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 10, :o1, 719974800 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 10, :o1, 751424400 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 10, :o1, 782874000 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 10, :o1, 814323600 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb deleted file mode 100644 index 1fb56823..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +++ /dev/null @@ -1,211 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Madrid - include TimezoneDefinition - - timezone 'Europe/Madrid' do |tz| - tz.offset :o0, -884, 0, :LMT - tz.offset :o1, 0, 0, :WET - tz.offset :o2, 0, 3600, :WEST - tz.offset :o3, 0, 7200, :WEMT - tz.offset :o4, 3600, 0, :CET - tz.offset :o5, 3600, 3600, :CEST - - tz.transition 1901, 1, :o1, 52172327021, 21600 - tz.transition 1917, 5, :o2, 58112507, 24 - tz.transition 1917, 10, :o1, 58116203, 24 - tz.transition 1918, 4, :o2, 58120787, 24 - tz.transition 1918, 10, :o1, 58124963, 24 - tz.transition 1919, 4, :o2, 58129307, 24 - tz.transition 1919, 10, :o1, 58133723, 24 - tz.transition 1924, 4, :o2, 58173419, 24 - tz.transition 1924, 10, :o1, 58177523, 24 - tz.transition 1926, 4, :o2, 58190963, 24 - tz.transition 1926, 10, :o1, 58194995, 24 - tz.transition 1927, 4, :o2, 58199531, 24 - tz.transition 1927, 10, :o1, 58203731, 24 - tz.transition 1928, 4, :o2, 58208435, 24 - tz.transition 1928, 10, :o1, 58212635, 24 - tz.transition 1929, 4, :o2, 58217339, 24 - tz.transition 1929, 10, :o1, 58221371, 24 - tz.transition 1937, 5, :o2, 58288235, 24 - tz.transition 1937, 10, :o1, 58291427, 24 - tz.transition 1938, 3, :o2, 58295531, 24 - tz.transition 1938, 10, :o1, 58300163, 24 - tz.transition 1939, 4, :o2, 58304867, 24 - tz.transition 1939, 10, :o1, 58309067, 24 - tz.transition 1940, 3, :o2, 58312931, 24 - tz.transition 1942, 5, :o3, 29165789, 12 - tz.transition 1942, 9, :o2, 29167253, 12 - tz.transition 1943, 4, :o3, 29169989, 12 - tz.transition 1943, 10, :o2, 29172017, 12 - tz.transition 1944, 4, :o3, 29174357, 12 - tz.transition 1944, 10, :o2, 29176493, 12 - tz.transition 1945, 4, :o3, 29178725, 12 - tz.transition 1945, 9, :o2, 58361483, 24 - tz.transition 1946, 4, :o3, 29183093, 12 - tz.transition 1946, 9, :o4, 29185121, 12 - tz.transition 1949, 4, :o5, 29196449, 12 - tz.transition 1949, 9, :o4, 58396547, 24 - tz.transition 1974, 4, :o5, 135122400 - tz.transition 1974, 10, :o4, 150246000 - tz.transition 1975, 4, :o5, 167176800 - tz.transition 1975, 10, :o4, 181695600 - tz.transition 1976, 3, :o5, 196812000 - tz.transition 1976, 9, :o4, 212540400 - tz.transition 1977, 4, :o5, 228866400 - tz.transition 1977, 9, :o4, 243990000 - tz.transition 1978, 4, :o5, 260402400 - tz.transition 1978, 9, :o4, 276044400 - tz.transition 1979, 4, :o5, 291776400 - tz.transition 1979, 9, :o4, 307501200 - tz.transition 1980, 4, :o5, 323830800 - tz.transition 1980, 9, :o4, 338950800 - tz.transition 1981, 3, :o5, 354675600 - tz.transition 1981, 9, :o4, 370400400 - tz.transition 1982, 3, :o5, 386125200 - tz.transition 1982, 9, :o4, 401850000 - tz.transition 1983, 3, :o5, 417574800 - tz.transition 1983, 9, :o4, 433299600 - tz.transition 1984, 3, :o5, 449024400 - tz.transition 1984, 9, :o4, 465354000 - tz.transition 1985, 3, :o5, 481078800 - tz.transition 1985, 9, :o4, 496803600 - tz.transition 1986, 3, :o5, 512528400 - tz.transition 1986, 9, :o4, 528253200 - tz.transition 1987, 3, :o5, 543978000 - tz.transition 1987, 9, :o4, 559702800 - tz.transition 1988, 3, :o5, 575427600 - tz.transition 1988, 9, :o4, 591152400 - tz.transition 1989, 3, :o5, 606877200 - tz.transition 1989, 9, :o4, 622602000 - tz.transition 1990, 3, :o5, 638326800 - tz.transition 1990, 9, :o4, 654656400 - tz.transition 1991, 3, :o5, 670381200 - tz.transition 1991, 9, :o4, 686106000 - tz.transition 1992, 3, :o5, 701830800 - tz.transition 1992, 9, :o4, 717555600 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 9, :o4, 749005200 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 9, :o4, 780454800 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 9, :o4, 811904400 - tz.transition 1996, 3, :o5, 828234000 - tz.transition 1996, 10, :o4, 846378000 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o4, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o4, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o4, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o4, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o4, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o4, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o4, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o4, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o4, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o4, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o4, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o4, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o4, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o4, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o4, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o4, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o4, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o4, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o4, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o4, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o4, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o4, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o4, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o4, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o4, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o4, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o4, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o4, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o4, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o4, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o4, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o4, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o4, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o4, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o4, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o4, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o4, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o4, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o4, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o4, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o4, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o4, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o4, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o4, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o4, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o4, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o4, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o4, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o4, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o4, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o4, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o4, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o4, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o4, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb deleted file mode 100644 index fa15816c..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +++ /dev/null @@ -1,170 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Minsk - include TimezoneDefinition - - timezone 'Europe/Minsk' do |tz| - tz.offset :o0, 6616, 0, :LMT - tz.offset :o1, 6600, 0, :MMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 10800, 0, :MSK - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - tz.offset :o6, 10800, 3600, :MSD - tz.offset :o7, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 26003326573, 10800 - tz.transition 1924, 5, :o2, 349042669, 144 - tz.transition 1930, 6, :o3, 29113781, 12 - tz.transition 1941, 6, :o4, 19441387, 8 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o5, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 7, :o3, 29175293, 12 - tz.transition 1981, 3, :o6, 354920400 - tz.transition 1981, 9, :o3, 370728000 - tz.transition 1982, 3, :o6, 386456400 - tz.transition 1982, 9, :o3, 402264000 - tz.transition 1983, 3, :o6, 417992400 - tz.transition 1983, 9, :o3, 433800000 - tz.transition 1984, 3, :o6, 449614800 - tz.transition 1984, 9, :o3, 465346800 - tz.transition 1985, 3, :o6, 481071600 - tz.transition 1985, 9, :o3, 496796400 - tz.transition 1986, 3, :o6, 512521200 - tz.transition 1986, 9, :o3, 528246000 - tz.transition 1987, 3, :o6, 543970800 - tz.transition 1987, 9, :o3, 559695600 - tz.transition 1988, 3, :o6, 575420400 - tz.transition 1988, 9, :o3, 591145200 - tz.transition 1989, 3, :o6, 606870000 - tz.transition 1989, 9, :o3, 622594800 - tz.transition 1991, 3, :o7, 670374000 - tz.transition 1991, 9, :o2, 686102400 - tz.transition 1992, 3, :o7, 701820000 - tz.transition 1992, 9, :o2, 717544800 - tz.transition 1993, 3, :o7, 733276800 - tz.transition 1993, 9, :o2, 749001600 - tz.transition 1994, 3, :o7, 764726400 - tz.transition 1994, 9, :o2, 780451200 - tz.transition 1995, 3, :o7, 796176000 - tz.transition 1995, 9, :o2, 811900800 - tz.transition 1996, 3, :o7, 828230400 - tz.transition 1996, 10, :o2, 846374400 - tz.transition 1997, 3, :o7, 859680000 - tz.transition 1997, 10, :o2, 877824000 - tz.transition 1998, 3, :o7, 891129600 - tz.transition 1998, 10, :o2, 909273600 - tz.transition 1999, 3, :o7, 922579200 - tz.transition 1999, 10, :o2, 941328000 - tz.transition 2000, 3, :o7, 954028800 - tz.transition 2000, 10, :o2, 972777600 - tz.transition 2001, 3, :o7, 985478400 - tz.transition 2001, 10, :o2, 1004227200 - tz.transition 2002, 3, :o7, 1017532800 - tz.transition 2002, 10, :o2, 1035676800 - tz.transition 2003, 3, :o7, 1048982400 - tz.transition 2003, 10, :o2, 1067126400 - tz.transition 2004, 3, :o7, 1080432000 - tz.transition 2004, 10, :o2, 1099180800 - tz.transition 2005, 3, :o7, 1111881600 - tz.transition 2005, 10, :o2, 1130630400 - tz.transition 2006, 3, :o7, 1143331200 - tz.transition 2006, 10, :o2, 1162080000 - tz.transition 2007, 3, :o7, 1174780800 - tz.transition 2007, 10, :o2, 1193529600 - tz.transition 2008, 3, :o7, 1206835200 - tz.transition 2008, 10, :o2, 1224979200 - tz.transition 2009, 3, :o7, 1238284800 - tz.transition 2009, 10, :o2, 1256428800 - tz.transition 2010, 3, :o7, 1269734400 - tz.transition 2010, 10, :o2, 1288483200 - tz.transition 2011, 3, :o7, 1301184000 - tz.transition 2011, 10, :o2, 1319932800 - tz.transition 2012, 3, :o7, 1332633600 - tz.transition 2012, 10, :o2, 1351382400 - tz.transition 2013, 3, :o7, 1364688000 - tz.transition 2013, 10, :o2, 1382832000 - tz.transition 2014, 3, :o7, 1396137600 - tz.transition 2014, 10, :o2, 1414281600 - tz.transition 2015, 3, :o7, 1427587200 - tz.transition 2015, 10, :o2, 1445731200 - tz.transition 2016, 3, :o7, 1459036800 - tz.transition 2016, 10, :o2, 1477785600 - tz.transition 2017, 3, :o7, 1490486400 - tz.transition 2017, 10, :o2, 1509235200 - tz.transition 2018, 3, :o7, 1521936000 - tz.transition 2018, 10, :o2, 1540684800 - tz.transition 2019, 3, :o7, 1553990400 - tz.transition 2019, 10, :o2, 1572134400 - tz.transition 2020, 3, :o7, 1585440000 - tz.transition 2020, 10, :o2, 1603584000 - tz.transition 2021, 3, :o7, 1616889600 - tz.transition 2021, 10, :o2, 1635638400 - tz.transition 2022, 3, :o7, 1648339200 - tz.transition 2022, 10, :o2, 1667088000 - tz.transition 2023, 3, :o7, 1679788800 - tz.transition 2023, 10, :o2, 1698537600 - tz.transition 2024, 3, :o7, 1711843200 - tz.transition 2024, 10, :o2, 1729987200 - tz.transition 2025, 3, :o7, 1743292800 - tz.transition 2025, 10, :o2, 1761436800 - tz.transition 2026, 3, :o7, 1774742400 - tz.transition 2026, 10, :o2, 1792886400 - tz.transition 2027, 3, :o7, 1806192000 - tz.transition 2027, 10, :o2, 1824940800 - tz.transition 2028, 3, :o7, 1837641600 - tz.transition 2028, 10, :o2, 1856390400 - tz.transition 2029, 3, :o7, 1869091200 - tz.transition 2029, 10, :o2, 1887840000 - tz.transition 2030, 3, :o7, 1901145600 - tz.transition 2030, 10, :o2, 1919289600 - tz.transition 2031, 3, :o7, 1932595200 - tz.transition 2031, 10, :o2, 1950739200 - tz.transition 2032, 3, :o7, 1964044800 - tz.transition 2032, 10, :o2, 1982793600 - tz.transition 2033, 3, :o7, 1995494400 - tz.transition 2033, 10, :o2, 2014243200 - tz.transition 2034, 3, :o7, 2026944000 - tz.transition 2034, 10, :o2, 2045692800 - tz.transition 2035, 3, :o7, 2058393600 - tz.transition 2035, 10, :o2, 2077142400 - tz.transition 2036, 3, :o7, 2090448000 - tz.transition 2036, 10, :o2, 2108592000 - tz.transition 2037, 3, :o7, 2121897600 - tz.transition 2037, 10, :o2, 2140041600 - tz.transition 2038, 3, :o7, 4931021, 2 - tz.transition 2038, 10, :o2, 4931455, 2 - tz.transition 2039, 3, :o7, 4931749, 2 - tz.transition 2039, 10, :o2, 4932183, 2 - tz.transition 2040, 3, :o7, 4932477, 2 - tz.transition 2040, 10, :o2, 4932911, 2 - tz.transition 2041, 3, :o7, 4933219, 2 - tz.transition 2041, 10, :o2, 4933639, 2 - tz.transition 2042, 3, :o7, 4933947, 2 - tz.transition 2042, 10, :o2, 4934367, 2 - tz.transition 2043, 3, :o7, 4934675, 2 - tz.transition 2043, 10, :o2, 4935095, 2 - tz.transition 2044, 3, :o7, 4935403, 2 - tz.transition 2044, 10, :o2, 4935837, 2 - tz.transition 2045, 3, :o7, 4936131, 2 - tz.transition 2045, 10, :o2, 4936565, 2 - tz.transition 2046, 3, :o7, 4936859, 2 - tz.transition 2046, 10, :o2, 4937293, 2 - tz.transition 2047, 3, :o7, 4937601, 2 - tz.transition 2047, 10, :o2, 4938021, 2 - tz.transition 2048, 3, :o7, 4938329, 2 - tz.transition 2048, 10, :o2, 4938749, 2 - tz.transition 2049, 3, :o7, 4939057, 2 - tz.transition 2049, 10, :o2, 4939491, 2 - tz.transition 2050, 3, :o7, 4939785, 2 - tz.transition 2050, 10, :o2, 4940219, 2 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb deleted file mode 100644 index ef269b67..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Moscow - include TimezoneDefinition - - timezone 'Europe/Moscow' do |tz| - tz.offset :o0, 9020, 0, :LMT - tz.offset :o1, 9000, 0, :MMT - tz.offset :o2, 9048, 0, :MMT - tz.offset :o3, 9048, 3600, :MST - tz.offset :o4, 9048, 7200, :MDST - tz.offset :o5, 10800, 3600, :MSD - tz.offset :o6, 10800, 0, :MSK - tz.offset :o7, 10800, 7200, :MSD - tz.offset :o8, 7200, 0, :EET - tz.offset :o9, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 10401330509, 4320 - tz.transition 1916, 7, :o2, 116210275, 48 - tz.transition 1917, 7, :o3, 8717080873, 3600 - tz.transition 1917, 12, :o2, 8717725273, 3600 - tz.transition 1918, 5, :o4, 8718283123, 3600 - tz.transition 1918, 9, :o3, 8718668473, 3600 - tz.transition 1919, 5, :o4, 8719597123, 3600 - tz.transition 1919, 6, :o5, 8719705423, 3600 - tz.transition 1919, 8, :o6, 7266559, 3 - tz.transition 1921, 2, :o5, 7268206, 3 - tz.transition 1921, 3, :o7, 58146463, 24 - tz.transition 1921, 8, :o5, 58150399, 24 - tz.transition 1921, 9, :o6, 7268890, 3 - tz.transition 1922, 9, :o8, 19386627, 8 - tz.transition 1930, 6, :o6, 29113781, 12 - tz.transition 1981, 3, :o5, 354920400 - tz.transition 1981, 9, :o6, 370728000 - tz.transition 1982, 3, :o5, 386456400 - tz.transition 1982, 9, :o6, 402264000 - tz.transition 1983, 3, :o5, 417992400 - tz.transition 1983, 9, :o6, 433800000 - tz.transition 1984, 3, :o5, 449614800 - tz.transition 1984, 9, :o6, 465346800 - tz.transition 1985, 3, :o5, 481071600 - tz.transition 1985, 9, :o6, 496796400 - tz.transition 1986, 3, :o5, 512521200 - tz.transition 1986, 9, :o6, 528246000 - tz.transition 1987, 3, :o5, 543970800 - tz.transition 1987, 9, :o6, 559695600 - tz.transition 1988, 3, :o5, 575420400 - tz.transition 1988, 9, :o6, 591145200 - tz.transition 1989, 3, :o5, 606870000 - tz.transition 1989, 9, :o6, 622594800 - tz.transition 1990, 3, :o5, 638319600 - tz.transition 1990, 9, :o6, 654649200 - tz.transition 1991, 3, :o9, 670374000 - tz.transition 1991, 9, :o8, 686102400 - tz.transition 1992, 1, :o6, 695779200 - tz.transition 1992, 3, :o5, 701812800 - tz.transition 1992, 9, :o6, 717534000 - tz.transition 1993, 3, :o5, 733273200 - tz.transition 1993, 9, :o6, 748998000 - tz.transition 1994, 3, :o5, 764722800 - tz.transition 1994, 9, :o6, 780447600 - tz.transition 1995, 3, :o5, 796172400 - tz.transition 1995, 9, :o6, 811897200 - tz.transition 1996, 3, :o5, 828226800 - tz.transition 1996, 10, :o6, 846370800 - tz.transition 1997, 3, :o5, 859676400 - tz.transition 1997, 10, :o6, 877820400 - tz.transition 1998, 3, :o5, 891126000 - tz.transition 1998, 10, :o6, 909270000 - tz.transition 1999, 3, :o5, 922575600 - tz.transition 1999, 10, :o6, 941324400 - tz.transition 2000, 3, :o5, 954025200 - tz.transition 2000, 10, :o6, 972774000 - tz.transition 2001, 3, :o5, 985474800 - tz.transition 2001, 10, :o6, 1004223600 - tz.transition 2002, 3, :o5, 1017529200 - tz.transition 2002, 10, :o6, 1035673200 - tz.transition 2003, 3, :o5, 1048978800 - tz.transition 2003, 10, :o6, 1067122800 - tz.transition 2004, 3, :o5, 1080428400 - tz.transition 2004, 10, :o6, 1099177200 - tz.transition 2005, 3, :o5, 1111878000 - tz.transition 2005, 10, :o6, 1130626800 - tz.transition 2006, 3, :o5, 1143327600 - tz.transition 2006, 10, :o6, 1162076400 - tz.transition 2007, 3, :o5, 1174777200 - tz.transition 2007, 10, :o6, 1193526000 - tz.transition 2008, 3, :o5, 1206831600 - tz.transition 2008, 10, :o6, 1224975600 - tz.transition 2009, 3, :o5, 1238281200 - tz.transition 2009, 10, :o6, 1256425200 - tz.transition 2010, 3, :o5, 1269730800 - tz.transition 2010, 10, :o6, 1288479600 - tz.transition 2011, 3, :o5, 1301180400 - tz.transition 2011, 10, :o6, 1319929200 - tz.transition 2012, 3, :o5, 1332630000 - tz.transition 2012, 10, :o6, 1351378800 - tz.transition 2013, 3, :o5, 1364684400 - tz.transition 2013, 10, :o6, 1382828400 - tz.transition 2014, 3, :o5, 1396134000 - tz.transition 2014, 10, :o6, 1414278000 - tz.transition 2015, 3, :o5, 1427583600 - tz.transition 2015, 10, :o6, 1445727600 - tz.transition 2016, 3, :o5, 1459033200 - tz.transition 2016, 10, :o6, 1477782000 - tz.transition 2017, 3, :o5, 1490482800 - tz.transition 2017, 10, :o6, 1509231600 - tz.transition 2018, 3, :o5, 1521932400 - tz.transition 2018, 10, :o6, 1540681200 - tz.transition 2019, 3, :o5, 1553986800 - tz.transition 2019, 10, :o6, 1572130800 - tz.transition 2020, 3, :o5, 1585436400 - tz.transition 2020, 10, :o6, 1603580400 - tz.transition 2021, 3, :o5, 1616886000 - tz.transition 2021, 10, :o6, 1635634800 - tz.transition 2022, 3, :o5, 1648335600 - tz.transition 2022, 10, :o6, 1667084400 - tz.transition 2023, 3, :o5, 1679785200 - tz.transition 2023, 10, :o6, 1698534000 - tz.transition 2024, 3, :o5, 1711839600 - tz.transition 2024, 10, :o6, 1729983600 - tz.transition 2025, 3, :o5, 1743289200 - tz.transition 2025, 10, :o6, 1761433200 - tz.transition 2026, 3, :o5, 1774738800 - tz.transition 2026, 10, :o6, 1792882800 - tz.transition 2027, 3, :o5, 1806188400 - tz.transition 2027, 10, :o6, 1824937200 - tz.transition 2028, 3, :o5, 1837638000 - tz.transition 2028, 10, :o6, 1856386800 - tz.transition 2029, 3, :o5, 1869087600 - tz.transition 2029, 10, :o6, 1887836400 - tz.transition 2030, 3, :o5, 1901142000 - tz.transition 2030, 10, :o6, 1919286000 - tz.transition 2031, 3, :o5, 1932591600 - tz.transition 2031, 10, :o6, 1950735600 - tz.transition 2032, 3, :o5, 1964041200 - tz.transition 2032, 10, :o6, 1982790000 - tz.transition 2033, 3, :o5, 1995490800 - tz.transition 2033, 10, :o6, 2014239600 - tz.transition 2034, 3, :o5, 2026940400 - tz.transition 2034, 10, :o6, 2045689200 - tz.transition 2035, 3, :o5, 2058390000 - tz.transition 2035, 10, :o6, 2077138800 - tz.transition 2036, 3, :o5, 2090444400 - tz.transition 2036, 10, :o6, 2108588400 - tz.transition 2037, 3, :o5, 2121894000 - tz.transition 2037, 10, :o6, 2140038000 - tz.transition 2038, 3, :o5, 59172251, 24 - tz.transition 2038, 10, :o6, 59177459, 24 - tz.transition 2039, 3, :o5, 59180987, 24 - tz.transition 2039, 10, :o6, 59186195, 24 - tz.transition 2040, 3, :o5, 59189723, 24 - tz.transition 2040, 10, :o6, 59194931, 24 - tz.transition 2041, 3, :o5, 59198627, 24 - tz.transition 2041, 10, :o6, 59203667, 24 - tz.transition 2042, 3, :o5, 59207363, 24 - tz.transition 2042, 10, :o6, 59212403, 24 - tz.transition 2043, 3, :o5, 59216099, 24 - tz.transition 2043, 10, :o6, 59221139, 24 - tz.transition 2044, 3, :o5, 59224835, 24 - tz.transition 2044, 10, :o6, 59230043, 24 - tz.transition 2045, 3, :o5, 59233571, 24 - tz.transition 2045, 10, :o6, 59238779, 24 - tz.transition 2046, 3, :o5, 59242307, 24 - tz.transition 2046, 10, :o6, 59247515, 24 - tz.transition 2047, 3, :o5, 59251211, 24 - tz.transition 2047, 10, :o6, 59256251, 24 - tz.transition 2048, 3, :o5, 59259947, 24 - tz.transition 2048, 10, :o6, 59264987, 24 - tz.transition 2049, 3, :o5, 59268683, 24 - tz.transition 2049, 10, :o6, 59273891, 24 - tz.transition 2050, 3, :o5, 59277419, 24 - tz.transition 2050, 10, :o6, 59282627, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb deleted file mode 100644 index e3236c0b..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Paris - include TimezoneDefinition - - timezone 'Europe/Paris' do |tz| - tz.offset :o0, 561, 0, :LMT - tz.offset :o1, 561, 0, :PMT - tz.offset :o2, 0, 0, :WET - tz.offset :o3, 0, 3600, :WEST - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - tz.offset :o6, 0, 7200, :WEMT - - tz.transition 1891, 3, :o1, 69460027033, 28800 - tz.transition 1911, 3, :o2, 69670267033, 28800 - tz.transition 1916, 6, :o3, 58104707, 24 - tz.transition 1916, 10, :o2, 58107323, 24 - tz.transition 1917, 3, :o3, 58111499, 24 - tz.transition 1917, 10, :o2, 58116227, 24 - tz.transition 1918, 3, :o3, 58119899, 24 - tz.transition 1918, 10, :o2, 58124963, 24 - tz.transition 1919, 3, :o3, 58128467, 24 - tz.transition 1919, 10, :o2, 58133699, 24 - tz.transition 1920, 2, :o3, 58136867, 24 - tz.transition 1920, 10, :o2, 58142915, 24 - tz.transition 1921, 3, :o3, 58146323, 24 - tz.transition 1921, 10, :o2, 58151723, 24 - tz.transition 1922, 3, :o3, 58155347, 24 - tz.transition 1922, 10, :o2, 58160051, 24 - tz.transition 1923, 5, :o3, 58165595, 24 - tz.transition 1923, 10, :o2, 58168787, 24 - tz.transition 1924, 3, :o3, 58172987, 24 - tz.transition 1924, 10, :o2, 58177523, 24 - tz.transition 1925, 4, :o3, 58181891, 24 - tz.transition 1925, 10, :o2, 58186259, 24 - tz.transition 1926, 4, :o3, 58190963, 24 - tz.transition 1926, 10, :o2, 58194995, 24 - tz.transition 1927, 4, :o3, 58199531, 24 - tz.transition 1927, 10, :o2, 58203731, 24 - tz.transition 1928, 4, :o3, 58208435, 24 - tz.transition 1928, 10, :o2, 58212635, 24 - tz.transition 1929, 4, :o3, 58217339, 24 - tz.transition 1929, 10, :o2, 58221371, 24 - tz.transition 1930, 4, :o3, 58225907, 24 - tz.transition 1930, 10, :o2, 58230107, 24 - tz.transition 1931, 4, :o3, 58234811, 24 - tz.transition 1931, 10, :o2, 58238843, 24 - tz.transition 1932, 4, :o3, 58243211, 24 - tz.transition 1932, 10, :o2, 58247579, 24 - tz.transition 1933, 3, :o3, 58251779, 24 - tz.transition 1933, 10, :o2, 58256483, 24 - tz.transition 1934, 4, :o3, 58260851, 24 - tz.transition 1934, 10, :o2, 58265219, 24 - tz.transition 1935, 3, :o3, 58269419, 24 - tz.transition 1935, 10, :o2, 58273955, 24 - tz.transition 1936, 4, :o3, 58278659, 24 - tz.transition 1936, 10, :o2, 58282691, 24 - tz.transition 1937, 4, :o3, 58287059, 24 - tz.transition 1937, 10, :o2, 58291427, 24 - tz.transition 1938, 3, :o3, 58295627, 24 - tz.transition 1938, 10, :o2, 58300163, 24 - tz.transition 1939, 4, :o3, 58304867, 24 - tz.transition 1939, 11, :o2, 58310075, 24 - tz.transition 1940, 2, :o3, 29156215, 12 - tz.transition 1940, 6, :o4, 29157545, 12 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o5, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 8, :o6, 29175929, 12 - tz.transition 1944, 10, :o3, 58352915, 24 - tz.transition 1945, 4, :o6, 58357141, 24 - tz.transition 1945, 9, :o5, 58361149, 24 - tz.transition 1976, 3, :o4, 196819200 - tz.transition 1976, 9, :o5, 212540400 - tz.transition 1977, 4, :o4, 228877200 - tz.transition 1977, 9, :o5, 243997200 - tz.transition 1978, 4, :o4, 260326800 - tz.transition 1978, 10, :o5, 276051600 - tz.transition 1979, 4, :o4, 291776400 - tz.transition 1979, 9, :o5, 307501200 - tz.transition 1980, 4, :o4, 323830800 - tz.transition 1980, 9, :o5, 338950800 - tz.transition 1981, 3, :o4, 354675600 - tz.transition 1981, 9, :o5, 370400400 - tz.transition 1982, 3, :o4, 386125200 - tz.transition 1982, 9, :o5, 401850000 - tz.transition 1983, 3, :o4, 417574800 - tz.transition 1983, 9, :o5, 433299600 - tz.transition 1984, 3, :o4, 449024400 - tz.transition 1984, 9, :o5, 465354000 - tz.transition 1985, 3, :o4, 481078800 - tz.transition 1985, 9, :o5, 496803600 - tz.transition 1986, 3, :o4, 512528400 - tz.transition 1986, 9, :o5, 528253200 - tz.transition 1987, 3, :o4, 543978000 - tz.transition 1987, 9, :o5, 559702800 - tz.transition 1988, 3, :o4, 575427600 - tz.transition 1988, 9, :o5, 591152400 - tz.transition 1989, 3, :o4, 606877200 - tz.transition 1989, 9, :o5, 622602000 - tz.transition 1990, 3, :o4, 638326800 - tz.transition 1990, 9, :o5, 654656400 - tz.transition 1991, 3, :o4, 670381200 - tz.transition 1991, 9, :o5, 686106000 - tz.transition 1992, 3, :o4, 701830800 - tz.transition 1992, 9, :o5, 717555600 - tz.transition 1993, 3, :o4, 733280400 - tz.transition 1993, 9, :o5, 749005200 - tz.transition 1994, 3, :o4, 764730000 - tz.transition 1994, 9, :o5, 780454800 - tz.transition 1995, 3, :o4, 796179600 - tz.transition 1995, 9, :o5, 811904400 - tz.transition 1996, 3, :o4, 828234000 - tz.transition 1996, 10, :o5, 846378000 - tz.transition 1997, 3, :o4, 859683600 - tz.transition 1997, 10, :o5, 877827600 - tz.transition 1998, 3, :o4, 891133200 - tz.transition 1998, 10, :o5, 909277200 - tz.transition 1999, 3, :o4, 922582800 - tz.transition 1999, 10, :o5, 941331600 - tz.transition 2000, 3, :o4, 954032400 - tz.transition 2000, 10, :o5, 972781200 - tz.transition 2001, 3, :o4, 985482000 - tz.transition 2001, 10, :o5, 1004230800 - tz.transition 2002, 3, :o4, 1017536400 - tz.transition 2002, 10, :o5, 1035680400 - tz.transition 2003, 3, :o4, 1048986000 - tz.transition 2003, 10, :o5, 1067130000 - tz.transition 2004, 3, :o4, 1080435600 - tz.transition 2004, 10, :o5, 1099184400 - tz.transition 2005, 3, :o4, 1111885200 - tz.transition 2005, 10, :o5, 1130634000 - tz.transition 2006, 3, :o4, 1143334800 - tz.transition 2006, 10, :o5, 1162083600 - tz.transition 2007, 3, :o4, 1174784400 - tz.transition 2007, 10, :o5, 1193533200 - tz.transition 2008, 3, :o4, 1206838800 - tz.transition 2008, 10, :o5, 1224982800 - tz.transition 2009, 3, :o4, 1238288400 - tz.transition 2009, 10, :o5, 1256432400 - tz.transition 2010, 3, :o4, 1269738000 - tz.transition 2010, 10, :o5, 1288486800 - tz.transition 2011, 3, :o4, 1301187600 - tz.transition 2011, 10, :o5, 1319936400 - tz.transition 2012, 3, :o4, 1332637200 - tz.transition 2012, 10, :o5, 1351386000 - tz.transition 2013, 3, :o4, 1364691600 - tz.transition 2013, 10, :o5, 1382835600 - tz.transition 2014, 3, :o4, 1396141200 - tz.transition 2014, 10, :o5, 1414285200 - tz.transition 2015, 3, :o4, 1427590800 - tz.transition 2015, 10, :o5, 1445734800 - tz.transition 2016, 3, :o4, 1459040400 - tz.transition 2016, 10, :o5, 1477789200 - tz.transition 2017, 3, :o4, 1490490000 - tz.transition 2017, 10, :o5, 1509238800 - tz.transition 2018, 3, :o4, 1521939600 - tz.transition 2018, 10, :o5, 1540688400 - tz.transition 2019, 3, :o4, 1553994000 - tz.transition 2019, 10, :o5, 1572138000 - tz.transition 2020, 3, :o4, 1585443600 - tz.transition 2020, 10, :o5, 1603587600 - tz.transition 2021, 3, :o4, 1616893200 - tz.transition 2021, 10, :o5, 1635642000 - tz.transition 2022, 3, :o4, 1648342800 - tz.transition 2022, 10, :o5, 1667091600 - tz.transition 2023, 3, :o4, 1679792400 - tz.transition 2023, 10, :o5, 1698541200 - tz.transition 2024, 3, :o4, 1711846800 - tz.transition 2024, 10, :o5, 1729990800 - tz.transition 2025, 3, :o4, 1743296400 - tz.transition 2025, 10, :o5, 1761440400 - tz.transition 2026, 3, :o4, 1774746000 - tz.transition 2026, 10, :o5, 1792890000 - tz.transition 2027, 3, :o4, 1806195600 - tz.transition 2027, 10, :o5, 1824944400 - tz.transition 2028, 3, :o4, 1837645200 - tz.transition 2028, 10, :o5, 1856394000 - tz.transition 2029, 3, :o4, 1869094800 - tz.transition 2029, 10, :o5, 1887843600 - tz.transition 2030, 3, :o4, 1901149200 - tz.transition 2030, 10, :o5, 1919293200 - tz.transition 2031, 3, :o4, 1932598800 - tz.transition 2031, 10, :o5, 1950742800 - tz.transition 2032, 3, :o4, 1964048400 - tz.transition 2032, 10, :o5, 1982797200 - tz.transition 2033, 3, :o4, 1995498000 - tz.transition 2033, 10, :o5, 2014246800 - tz.transition 2034, 3, :o4, 2026947600 - tz.transition 2034, 10, :o5, 2045696400 - tz.transition 2035, 3, :o4, 2058397200 - tz.transition 2035, 10, :o5, 2077146000 - tz.transition 2036, 3, :o4, 2090451600 - tz.transition 2036, 10, :o5, 2108595600 - tz.transition 2037, 3, :o4, 2121901200 - tz.transition 2037, 10, :o5, 2140045200 - tz.transition 2038, 3, :o4, 59172253, 24 - tz.transition 2038, 10, :o5, 59177461, 24 - tz.transition 2039, 3, :o4, 59180989, 24 - tz.transition 2039, 10, :o5, 59186197, 24 - tz.transition 2040, 3, :o4, 59189725, 24 - tz.transition 2040, 10, :o5, 59194933, 24 - tz.transition 2041, 3, :o4, 59198629, 24 - tz.transition 2041, 10, :o5, 59203669, 24 - tz.transition 2042, 3, :o4, 59207365, 24 - tz.transition 2042, 10, :o5, 59212405, 24 - tz.transition 2043, 3, :o4, 59216101, 24 - tz.transition 2043, 10, :o5, 59221141, 24 - tz.transition 2044, 3, :o4, 59224837, 24 - tz.transition 2044, 10, :o5, 59230045, 24 - tz.transition 2045, 3, :o4, 59233573, 24 - tz.transition 2045, 10, :o5, 59238781, 24 - tz.transition 2046, 3, :o4, 59242309, 24 - tz.transition 2046, 10, :o5, 59247517, 24 - tz.transition 2047, 3, :o4, 59251213, 24 - tz.transition 2047, 10, :o5, 59256253, 24 - tz.transition 2048, 3, :o4, 59259949, 24 - tz.transition 2048, 10, :o5, 59264989, 24 - tz.transition 2049, 3, :o4, 59268685, 24 - tz.transition 2049, 10, :o5, 59273893, 24 - tz.transition 2050, 3, :o4, 59277421, 24 - tz.transition 2050, 10, :o5, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb deleted file mode 100644 index bcabee96..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +++ /dev/null @@ -1,187 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Prague - include TimezoneDefinition - - timezone 'Europe/Prague' do |tz| - tz.offset :o0, 3464, 0, :LMT - tz.offset :o1, 3464, 0, :PMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1849, 12, :o1, 25884991367, 10800 - tz.transition 1891, 9, :o2, 26049669767, 10800 - tz.transition 1916, 4, :o3, 29051813, 12 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1917, 4, :o3, 58112029, 24 - tz.transition 1917, 9, :o2, 58115725, 24 - tz.transition 1918, 4, :o3, 58120765, 24 - tz.transition 1918, 9, :o2, 58124461, 24 - tz.transition 1940, 4, :o3, 58313293, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 9, :o2, 58352413, 24 - tz.transition 1945, 4, :o3, 58357285, 24 - tz.transition 1945, 11, :o2, 58362661, 24 - tz.transition 1946, 5, :o3, 58366717, 24 - tz.transition 1946, 10, :o2, 58370389, 24 - tz.transition 1947, 4, :o3, 58375093, 24 - tz.transition 1947, 10, :o2, 58379125, 24 - tz.transition 1948, 4, :o3, 58383829, 24 - tz.transition 1948, 10, :o2, 58387861, 24 - tz.transition 1949, 4, :o3, 58392373, 24 - tz.transition 1949, 10, :o2, 58396597, 24 - tz.transition 1979, 4, :o3, 291776400 - tz.transition 1979, 9, :o2, 307501200 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb deleted file mode 100644 index 784837f7..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Riga - include TimezoneDefinition - - timezone 'Europe/Riga' do |tz| - tz.offset :o0, 5784, 0, :LMT - tz.offset :o1, 5784, 0, :RMT - tz.offset :o2, 5784, 3600, :LST - tz.offset :o3, 7200, 0, :EET - tz.offset :o4, 10800, 0, :MSK - tz.offset :o5, 3600, 3600, :CEST - tz.offset :o6, 3600, 0, :CET - tz.offset :o7, 10800, 3600, :MSD - tz.offset :o8, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 8667775559, 3600 - tz.transition 1918, 4, :o2, 8718114659, 3600 - tz.transition 1918, 9, :o1, 8718669059, 3600 - tz.transition 1919, 4, :o2, 8719378259, 3600 - tz.transition 1919, 5, :o1, 8719561859, 3600 - tz.transition 1926, 5, :o3, 8728727159, 3600 - tz.transition 1940, 8, :o4, 29158157, 12 - tz.transition 1941, 6, :o5, 19441411, 8 - tz.transition 1942, 11, :o6, 58335973, 24 - tz.transition 1943, 3, :o5, 58339501, 24 - tz.transition 1943, 10, :o6, 58344037, 24 - tz.transition 1944, 4, :o5, 58348405, 24 - tz.transition 1944, 10, :o6, 58352773, 24 - tz.transition 1944, 10, :o4, 58353035, 24 - tz.transition 1981, 3, :o7, 354920400 - tz.transition 1981, 9, :o4, 370728000 - tz.transition 1982, 3, :o7, 386456400 - tz.transition 1982, 9, :o4, 402264000 - tz.transition 1983, 3, :o7, 417992400 - tz.transition 1983, 9, :o4, 433800000 - tz.transition 1984, 3, :o7, 449614800 - tz.transition 1984, 9, :o4, 465346800 - tz.transition 1985, 3, :o7, 481071600 - tz.transition 1985, 9, :o4, 496796400 - tz.transition 1986, 3, :o7, 512521200 - tz.transition 1986, 9, :o4, 528246000 - tz.transition 1987, 3, :o7, 543970800 - tz.transition 1987, 9, :o4, 559695600 - tz.transition 1988, 3, :o7, 575420400 - tz.transition 1988, 9, :o4, 591145200 - tz.transition 1989, 3, :o8, 606870000 - tz.transition 1989, 9, :o3, 622598400 - tz.transition 1990, 3, :o8, 638323200 - tz.transition 1990, 9, :o3, 654652800 - tz.transition 1991, 3, :o8, 670377600 - tz.transition 1991, 9, :o3, 686102400 - tz.transition 1992, 3, :o8, 701827200 - tz.transition 1992, 9, :o3, 717552000 - tz.transition 1993, 3, :o8, 733276800 - tz.transition 1993, 9, :o3, 749001600 - tz.transition 1994, 3, :o8, 764726400 - tz.transition 1994, 9, :o3, 780451200 - tz.transition 1995, 3, :o8, 796176000 - tz.transition 1995, 9, :o3, 811900800 - tz.transition 1996, 3, :o8, 828230400 - tz.transition 1996, 9, :o3, 843955200 - tz.transition 1997, 3, :o8, 859683600 - tz.transition 1997, 10, :o3, 877827600 - tz.transition 1998, 3, :o8, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o8, 922582800 - tz.transition 1999, 10, :o3, 941331600 - tz.transition 2001, 3, :o8, 985482000 - tz.transition 2001, 10, :o3, 1004230800 - tz.transition 2002, 3, :o8, 1017536400 - tz.transition 2002, 10, :o3, 1035680400 - tz.transition 2003, 3, :o8, 1048986000 - tz.transition 2003, 10, :o3, 1067130000 - tz.transition 2004, 3, :o8, 1080435600 - tz.transition 2004, 10, :o3, 1099184400 - tz.transition 2005, 3, :o8, 1111885200 - tz.transition 2005, 10, :o3, 1130634000 - tz.transition 2006, 3, :o8, 1143334800 - tz.transition 2006, 10, :o3, 1162083600 - tz.transition 2007, 3, :o8, 1174784400 - tz.transition 2007, 10, :o3, 1193533200 - tz.transition 2008, 3, :o8, 1206838800 - tz.transition 2008, 10, :o3, 1224982800 - tz.transition 2009, 3, :o8, 1238288400 - tz.transition 2009, 10, :o3, 1256432400 - tz.transition 2010, 3, :o8, 1269738000 - tz.transition 2010, 10, :o3, 1288486800 - tz.transition 2011, 3, :o8, 1301187600 - tz.transition 2011, 10, :o3, 1319936400 - tz.transition 2012, 3, :o8, 1332637200 - tz.transition 2012, 10, :o3, 1351386000 - tz.transition 2013, 3, :o8, 1364691600 - tz.transition 2013, 10, :o3, 1382835600 - tz.transition 2014, 3, :o8, 1396141200 - tz.transition 2014, 10, :o3, 1414285200 - tz.transition 2015, 3, :o8, 1427590800 - tz.transition 2015, 10, :o3, 1445734800 - tz.transition 2016, 3, :o8, 1459040400 - tz.transition 2016, 10, :o3, 1477789200 - tz.transition 2017, 3, :o8, 1490490000 - tz.transition 2017, 10, :o3, 1509238800 - tz.transition 2018, 3, :o8, 1521939600 - tz.transition 2018, 10, :o3, 1540688400 - tz.transition 2019, 3, :o8, 1553994000 - tz.transition 2019, 10, :o3, 1572138000 - tz.transition 2020, 3, :o8, 1585443600 - tz.transition 2020, 10, :o3, 1603587600 - tz.transition 2021, 3, :o8, 1616893200 - tz.transition 2021, 10, :o3, 1635642000 - tz.transition 2022, 3, :o8, 1648342800 - tz.transition 2022, 10, :o3, 1667091600 - tz.transition 2023, 3, :o8, 1679792400 - tz.transition 2023, 10, :o3, 1698541200 - tz.transition 2024, 3, :o8, 1711846800 - tz.transition 2024, 10, :o3, 1729990800 - tz.transition 2025, 3, :o8, 1743296400 - tz.transition 2025, 10, :o3, 1761440400 - tz.transition 2026, 3, :o8, 1774746000 - tz.transition 2026, 10, :o3, 1792890000 - tz.transition 2027, 3, :o8, 1806195600 - tz.transition 2027, 10, :o3, 1824944400 - tz.transition 2028, 3, :o8, 1837645200 - tz.transition 2028, 10, :o3, 1856394000 - tz.transition 2029, 3, :o8, 1869094800 - tz.transition 2029, 10, :o3, 1887843600 - tz.transition 2030, 3, :o8, 1901149200 - tz.transition 2030, 10, :o3, 1919293200 - tz.transition 2031, 3, :o8, 1932598800 - tz.transition 2031, 10, :o3, 1950742800 - tz.transition 2032, 3, :o8, 1964048400 - tz.transition 2032, 10, :o3, 1982797200 - tz.transition 2033, 3, :o8, 1995498000 - tz.transition 2033, 10, :o3, 2014246800 - tz.transition 2034, 3, :o8, 2026947600 - tz.transition 2034, 10, :o3, 2045696400 - tz.transition 2035, 3, :o8, 2058397200 - tz.transition 2035, 10, :o3, 2077146000 - tz.transition 2036, 3, :o8, 2090451600 - tz.transition 2036, 10, :o3, 2108595600 - tz.transition 2037, 3, :o8, 2121901200 - tz.transition 2037, 10, :o3, 2140045200 - tz.transition 2038, 3, :o8, 59172253, 24 - tz.transition 2038, 10, :o3, 59177461, 24 - tz.transition 2039, 3, :o8, 59180989, 24 - tz.transition 2039, 10, :o3, 59186197, 24 - tz.transition 2040, 3, :o8, 59189725, 24 - tz.transition 2040, 10, :o3, 59194933, 24 - tz.transition 2041, 3, :o8, 59198629, 24 - tz.transition 2041, 10, :o3, 59203669, 24 - tz.transition 2042, 3, :o8, 59207365, 24 - tz.transition 2042, 10, :o3, 59212405, 24 - tz.transition 2043, 3, :o8, 59216101, 24 - tz.transition 2043, 10, :o3, 59221141, 24 - tz.transition 2044, 3, :o8, 59224837, 24 - tz.transition 2044, 10, :o3, 59230045, 24 - tz.transition 2045, 3, :o8, 59233573, 24 - tz.transition 2045, 10, :o3, 59238781, 24 - tz.transition 2046, 3, :o8, 59242309, 24 - tz.transition 2046, 10, :o3, 59247517, 24 - tz.transition 2047, 3, :o8, 59251213, 24 - tz.transition 2047, 10, :o3, 59256253, 24 - tz.transition 2048, 3, :o8, 59259949, 24 - tz.transition 2048, 10, :o3, 59264989, 24 - tz.transition 2049, 3, :o8, 59268685, 24 - tz.transition 2049, 10, :o3, 59273893, 24 - tz.transition 2050, 3, :o8, 59277421, 24 - tz.transition 2050, 10, :o3, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb deleted file mode 100644 index aa7b43d9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +++ /dev/null @@ -1,215 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Rome - include TimezoneDefinition - - timezone 'Europe/Rome' do |tz| - tz.offset :o0, 2996, 0, :LMT - tz.offset :o1, 2996, 0, :RMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1866, 9, :o1, 51901915651, 21600 - tz.transition 1893, 10, :o2, 52115798851, 21600 - tz.transition 1916, 6, :o3, 58104419, 24 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1917, 3, :o3, 58111667, 24 - tz.transition 1917, 9, :o2, 58116035, 24 - tz.transition 1918, 3, :o3, 58119899, 24 - tz.transition 1918, 10, :o2, 58124939, 24 - tz.transition 1919, 3, :o3, 58128467, 24 - tz.transition 1919, 10, :o2, 58133675, 24 - tz.transition 1920, 3, :o3, 58137707, 24 - tz.transition 1920, 9, :o2, 58142075, 24 - tz.transition 1940, 6, :o3, 58315091, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 9, :o2, 58352411, 24 - tz.transition 1945, 4, :o3, 58357141, 24 - tz.transition 1945, 9, :o2, 58361123, 24 - tz.transition 1946, 3, :o3, 58365517, 24 - tz.transition 1946, 10, :o2, 58370389, 24 - tz.transition 1947, 3, :o3, 58374251, 24 - tz.transition 1947, 10, :o2, 58379123, 24 - tz.transition 1948, 2, :o3, 58382653, 24 - tz.transition 1948, 10, :o2, 58387861, 24 - tz.transition 1966, 5, :o3, 58542419, 24 - tz.transition 1966, 9, :o2, 29272721, 12 - tz.transition 1967, 5, :o3, 58551323, 24 - tz.transition 1967, 9, :o2, 29277089, 12 - tz.transition 1968, 5, :o3, 58560059, 24 - tz.transition 1968, 9, :o2, 29281457, 12 - tz.transition 1969, 5, :o3, 58568963, 24 - tz.transition 1969, 9, :o2, 29285909, 12 - tz.transition 1970, 5, :o3, 12956400 - tz.transition 1970, 9, :o2, 23234400 - tz.transition 1971, 5, :o3, 43801200 - tz.transition 1971, 9, :o2, 54687600 - tz.transition 1972, 5, :o3, 75855600 - tz.transition 1972, 9, :o2, 86738400 - tz.transition 1973, 6, :o3, 107910000 - tz.transition 1973, 9, :o2, 118188000 - tz.transition 1974, 5, :o3, 138754800 - tz.transition 1974, 9, :o2, 149637600 - tz.transition 1975, 5, :o3, 170809200 - tz.transition 1975, 9, :o2, 181090800 - tz.transition 1976, 5, :o3, 202258800 - tz.transition 1976, 9, :o2, 212540400 - tz.transition 1977, 5, :o3, 233103600 - tz.transition 1977, 9, :o2, 243990000 - tz.transition 1978, 5, :o3, 265158000 - tz.transition 1978, 9, :o2, 276044400 - tz.transition 1979, 5, :o3, 296607600 - tz.transition 1979, 9, :o2, 307494000 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb deleted file mode 100644 index 068c5fe6..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Sarajevo - include TimezoneDefinition - - linked_timezone 'Europe/Sarajevo', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb deleted file mode 100644 index 10b71f28..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Skopje - include TimezoneDefinition - - linked_timezone 'Europe/Skopje', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb deleted file mode 100644 index 38a70ece..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +++ /dev/null @@ -1,173 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Sofia - include TimezoneDefinition - - timezone 'Europe/Sofia' do |tz| - tz.offset :o0, 5596, 0, :LMT - tz.offset :o1, 7016, 0, :IMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 3600, 0, :CET - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 52006653401, 21600 - tz.transition 1894, 11, :o2, 26062154123, 10800 - tz.transition 1942, 11, :o3, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o3, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 10, :o3, 58352773, 24 - tz.transition 1945, 4, :o2, 29178571, 12 - tz.transition 1979, 3, :o5, 291762000 - tz.transition 1979, 9, :o2, 307576800 - tz.transition 1980, 4, :o5, 323816400 - tz.transition 1980, 9, :o2, 339026400 - tz.transition 1981, 4, :o5, 355266000 - tz.transition 1981, 9, :o2, 370393200 - tz.transition 1982, 4, :o5, 386715600 - tz.transition 1982, 9, :o2, 401846400 - tz.transition 1983, 3, :o5, 417571200 - tz.transition 1983, 9, :o2, 433296000 - tz.transition 1984, 3, :o5, 449020800 - tz.transition 1984, 9, :o2, 465350400 - tz.transition 1985, 3, :o5, 481075200 - tz.transition 1985, 9, :o2, 496800000 - tz.transition 1986, 3, :o5, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o5, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o5, 575424000 - tz.transition 1988, 9, :o2, 591148800 - tz.transition 1989, 3, :o5, 606873600 - tz.transition 1989, 9, :o2, 622598400 - tz.transition 1990, 3, :o5, 638323200 - tz.transition 1990, 9, :o2, 654652800 - tz.transition 1991, 3, :o5, 670370400 - tz.transition 1991, 9, :o2, 686091600 - tz.transition 1992, 3, :o5, 701820000 - tz.transition 1992, 9, :o2, 717541200 - tz.transition 1993, 3, :o5, 733269600 - tz.transition 1993, 9, :o2, 748990800 - tz.transition 1994, 3, :o5, 764719200 - tz.transition 1994, 9, :o2, 780440400 - tz.transition 1995, 3, :o5, 796168800 - tz.transition 1995, 9, :o2, 811890000 - tz.transition 1996, 3, :o5, 828223200 - tz.transition 1996, 10, :o2, 846363600 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb deleted file mode 100644 index 43db70fa..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Stockholm - include TimezoneDefinition - - timezone 'Europe/Stockholm' do |tz| - tz.offset :o0, 4332, 0, :LMT - tz.offset :o1, 3614, 0, :SET - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1878, 12, :o1, 17332923239, 7200 - tz.transition 1899, 12, :o2, 104328883793, 43200 - tz.transition 1916, 5, :o3, 29051981, 12 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb deleted file mode 100644 index de5a8569..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +++ /dev/null @@ -1,172 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Tallinn - include TimezoneDefinition - - timezone 'Europe/Tallinn' do |tz| - tz.offset :o0, 5940, 0, :LMT - tz.offset :o1, 5940, 0, :TMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - tz.offset :o4, 7200, 0, :EET - tz.offset :o5, 10800, 0, :MSK - tz.offset :o6, 10800, 3600, :MSD - tz.offset :o7, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 385234469, 160 - tz.transition 1918, 1, :o2, 387460069, 160 - tz.transition 1918, 4, :o3, 58120765, 24 - tz.transition 1918, 9, :o2, 58124461, 24 - tz.transition 1919, 6, :o1, 58131371, 24 - tz.transition 1921, 4, :o4, 387649669, 160 - tz.transition 1940, 8, :o5, 29158169, 12 - tz.transition 1941, 9, :o3, 19442019, 8 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 9, :o5, 29176265, 12 - tz.transition 1981, 3, :o6, 354920400 - tz.transition 1981, 9, :o5, 370728000 - tz.transition 1982, 3, :o6, 386456400 - tz.transition 1982, 9, :o5, 402264000 - tz.transition 1983, 3, :o6, 417992400 - tz.transition 1983, 9, :o5, 433800000 - tz.transition 1984, 3, :o6, 449614800 - tz.transition 1984, 9, :o5, 465346800 - tz.transition 1985, 3, :o6, 481071600 - tz.transition 1985, 9, :o5, 496796400 - tz.transition 1986, 3, :o6, 512521200 - tz.transition 1986, 9, :o5, 528246000 - tz.transition 1987, 3, :o6, 543970800 - tz.transition 1987, 9, :o5, 559695600 - tz.transition 1988, 3, :o6, 575420400 - tz.transition 1988, 9, :o5, 591145200 - tz.transition 1989, 3, :o7, 606870000 - tz.transition 1989, 9, :o4, 622598400 - tz.transition 1990, 3, :o7, 638323200 - tz.transition 1990, 9, :o4, 654652800 - tz.transition 1991, 3, :o7, 670377600 - tz.transition 1991, 9, :o4, 686102400 - tz.transition 1992, 3, :o7, 701827200 - tz.transition 1992, 9, :o4, 717552000 - tz.transition 1993, 3, :o7, 733276800 - tz.transition 1993, 9, :o4, 749001600 - tz.transition 1994, 3, :o7, 764726400 - tz.transition 1994, 9, :o4, 780451200 - tz.transition 1995, 3, :o7, 796176000 - tz.transition 1995, 9, :o4, 811900800 - tz.transition 1996, 3, :o7, 828230400 - tz.transition 1996, 10, :o4, 846374400 - tz.transition 1997, 3, :o7, 859680000 - tz.transition 1997, 10, :o4, 877824000 - tz.transition 1998, 3, :o7, 891129600 - tz.transition 1998, 10, :o4, 909277200 - tz.transition 1999, 3, :o7, 922582800 - tz.transition 1999, 10, :o4, 941331600 - tz.transition 2002, 3, :o7, 1017536400 - tz.transition 2002, 10, :o4, 1035680400 - tz.transition 2003, 3, :o7, 1048986000 - tz.transition 2003, 10, :o4, 1067130000 - tz.transition 2004, 3, :o7, 1080435600 - tz.transition 2004, 10, :o4, 1099184400 - tz.transition 2005, 3, :o7, 1111885200 - tz.transition 2005, 10, :o4, 1130634000 - tz.transition 2006, 3, :o7, 1143334800 - tz.transition 2006, 10, :o4, 1162083600 - tz.transition 2007, 3, :o7, 1174784400 - tz.transition 2007, 10, :o4, 1193533200 - tz.transition 2008, 3, :o7, 1206838800 - tz.transition 2008, 10, :o4, 1224982800 - tz.transition 2009, 3, :o7, 1238288400 - tz.transition 2009, 10, :o4, 1256432400 - tz.transition 2010, 3, :o7, 1269738000 - tz.transition 2010, 10, :o4, 1288486800 - tz.transition 2011, 3, :o7, 1301187600 - tz.transition 2011, 10, :o4, 1319936400 - tz.transition 2012, 3, :o7, 1332637200 - tz.transition 2012, 10, :o4, 1351386000 - tz.transition 2013, 3, :o7, 1364691600 - tz.transition 2013, 10, :o4, 1382835600 - tz.transition 2014, 3, :o7, 1396141200 - tz.transition 2014, 10, :o4, 1414285200 - tz.transition 2015, 3, :o7, 1427590800 - tz.transition 2015, 10, :o4, 1445734800 - tz.transition 2016, 3, :o7, 1459040400 - tz.transition 2016, 10, :o4, 1477789200 - tz.transition 2017, 3, :o7, 1490490000 - tz.transition 2017, 10, :o4, 1509238800 - tz.transition 2018, 3, :o7, 1521939600 - tz.transition 2018, 10, :o4, 1540688400 - tz.transition 2019, 3, :o7, 1553994000 - tz.transition 2019, 10, :o4, 1572138000 - tz.transition 2020, 3, :o7, 1585443600 - tz.transition 2020, 10, :o4, 1603587600 - tz.transition 2021, 3, :o7, 1616893200 - tz.transition 2021, 10, :o4, 1635642000 - tz.transition 2022, 3, :o7, 1648342800 - tz.transition 2022, 10, :o4, 1667091600 - tz.transition 2023, 3, :o7, 1679792400 - tz.transition 2023, 10, :o4, 1698541200 - tz.transition 2024, 3, :o7, 1711846800 - tz.transition 2024, 10, :o4, 1729990800 - tz.transition 2025, 3, :o7, 1743296400 - tz.transition 2025, 10, :o4, 1761440400 - tz.transition 2026, 3, :o7, 1774746000 - tz.transition 2026, 10, :o4, 1792890000 - tz.transition 2027, 3, :o7, 1806195600 - tz.transition 2027, 10, :o4, 1824944400 - tz.transition 2028, 3, :o7, 1837645200 - tz.transition 2028, 10, :o4, 1856394000 - tz.transition 2029, 3, :o7, 1869094800 - tz.transition 2029, 10, :o4, 1887843600 - tz.transition 2030, 3, :o7, 1901149200 - tz.transition 2030, 10, :o4, 1919293200 - tz.transition 2031, 3, :o7, 1932598800 - tz.transition 2031, 10, :o4, 1950742800 - tz.transition 2032, 3, :o7, 1964048400 - tz.transition 2032, 10, :o4, 1982797200 - tz.transition 2033, 3, :o7, 1995498000 - tz.transition 2033, 10, :o4, 2014246800 - tz.transition 2034, 3, :o7, 2026947600 - tz.transition 2034, 10, :o4, 2045696400 - tz.transition 2035, 3, :o7, 2058397200 - tz.transition 2035, 10, :o4, 2077146000 - tz.transition 2036, 3, :o7, 2090451600 - tz.transition 2036, 10, :o4, 2108595600 - tz.transition 2037, 3, :o7, 2121901200 - tz.transition 2037, 10, :o4, 2140045200 - tz.transition 2038, 3, :o7, 59172253, 24 - tz.transition 2038, 10, :o4, 59177461, 24 - tz.transition 2039, 3, :o7, 59180989, 24 - tz.transition 2039, 10, :o4, 59186197, 24 - tz.transition 2040, 3, :o7, 59189725, 24 - tz.transition 2040, 10, :o4, 59194933, 24 - tz.transition 2041, 3, :o7, 59198629, 24 - tz.transition 2041, 10, :o4, 59203669, 24 - tz.transition 2042, 3, :o7, 59207365, 24 - tz.transition 2042, 10, :o4, 59212405, 24 - tz.transition 2043, 3, :o7, 59216101, 24 - tz.transition 2043, 10, :o4, 59221141, 24 - tz.transition 2044, 3, :o7, 59224837, 24 - tz.transition 2044, 10, :o4, 59230045, 24 - tz.transition 2045, 3, :o7, 59233573, 24 - tz.transition 2045, 10, :o4, 59238781, 24 - tz.transition 2046, 3, :o7, 59242309, 24 - tz.transition 2046, 10, :o4, 59247517, 24 - tz.transition 2047, 3, :o7, 59251213, 24 - tz.transition 2047, 10, :o4, 59256253, 24 - tz.transition 2048, 3, :o7, 59259949, 24 - tz.transition 2048, 10, :o4, 59264989, 24 - tz.transition 2049, 3, :o7, 59268685, 24 - tz.transition 2049, 10, :o4, 59273893, 24 - tz.transition 2050, 3, :o7, 59277421, 24 - tz.transition 2050, 10, :o4, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb deleted file mode 100644 index 990aabab..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +++ /dev/null @@ -1,183 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Vienna - include TimezoneDefinition - - timezone 'Europe/Vienna' do |tz| - tz.offset :o0, 3920, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - - tz.transition 1893, 3, :o1, 2605558811, 1080 - tz.transition 1916, 4, :o2, 29051813, 12 - tz.transition 1916, 9, :o1, 58107299, 24 - tz.transition 1917, 4, :o2, 58112029, 24 - tz.transition 1917, 9, :o1, 58115725, 24 - tz.transition 1918, 4, :o2, 58120765, 24 - tz.transition 1918, 9, :o1, 58124461, 24 - tz.transition 1920, 4, :o2, 58138069, 24 - tz.transition 1920, 9, :o1, 58141933, 24 - tz.transition 1940, 4, :o2, 58313293, 24 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 4, :o2, 58357141, 24 - tz.transition 1945, 4, :o1, 58357381, 24 - tz.transition 1946, 4, :o2, 58366189, 24 - tz.transition 1946, 10, :o1, 58370389, 24 - tz.transition 1947, 4, :o2, 58374757, 24 - tz.transition 1947, 10, :o1, 58379125, 24 - tz.transition 1948, 4, :o2, 58383829, 24 - tz.transition 1948, 10, :o1, 58387861, 24 - tz.transition 1980, 4, :o2, 323823600 - tz.transition 1980, 9, :o1, 338940000 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb deleted file mode 100644 index d89d095a..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +++ /dev/null @@ -1,170 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Vilnius - include TimezoneDefinition - - timezone 'Europe/Vilnius' do |tz| - tz.offset :o0, 6076, 0, :LMT - tz.offset :o1, 5040, 0, :WMT - tz.offset :o2, 5736, 0, :KMT - tz.offset :o3, 3600, 0, :CET - tz.offset :o4, 7200, 0, :EET - tz.offset :o5, 10800, 0, :MSK - tz.offset :o6, 3600, 3600, :CEST - tz.offset :o7, 10800, 3600, :MSD - tz.offset :o8, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 52006653281, 21600 - tz.transition 1916, 12, :o2, 290547533, 120 - tz.transition 1919, 10, :o3, 8720069161, 3600 - tz.transition 1920, 7, :o4, 58140419, 24 - tz.transition 1920, 10, :o3, 29071277, 12 - tz.transition 1940, 8, :o5, 58316267, 24 - tz.transition 1941, 6, :o6, 19441355, 8 - tz.transition 1942, 11, :o3, 58335973, 24 - tz.transition 1943, 3, :o6, 58339501, 24 - tz.transition 1943, 10, :o3, 58344037, 24 - tz.transition 1944, 4, :o6, 58348405, 24 - tz.transition 1944, 7, :o5, 29175641, 12 - tz.transition 1981, 3, :o7, 354920400 - tz.transition 1981, 9, :o5, 370728000 - tz.transition 1982, 3, :o7, 386456400 - tz.transition 1982, 9, :o5, 402264000 - tz.transition 1983, 3, :o7, 417992400 - tz.transition 1983, 9, :o5, 433800000 - tz.transition 1984, 3, :o7, 449614800 - tz.transition 1984, 9, :o5, 465346800 - tz.transition 1985, 3, :o7, 481071600 - tz.transition 1985, 9, :o5, 496796400 - tz.transition 1986, 3, :o7, 512521200 - tz.transition 1986, 9, :o5, 528246000 - tz.transition 1987, 3, :o7, 543970800 - tz.transition 1987, 9, :o5, 559695600 - tz.transition 1988, 3, :o7, 575420400 - tz.transition 1988, 9, :o5, 591145200 - tz.transition 1989, 3, :o7, 606870000 - tz.transition 1989, 9, :o5, 622594800 - tz.transition 1990, 3, :o7, 638319600 - tz.transition 1990, 9, :o5, 654649200 - tz.transition 1991, 3, :o8, 670374000 - tz.transition 1991, 9, :o4, 686102400 - tz.transition 1992, 3, :o8, 701827200 - tz.transition 1992, 9, :o4, 717552000 - tz.transition 1993, 3, :o8, 733276800 - tz.transition 1993, 9, :o4, 749001600 - tz.transition 1994, 3, :o8, 764726400 - tz.transition 1994, 9, :o4, 780451200 - tz.transition 1995, 3, :o8, 796176000 - tz.transition 1995, 9, :o4, 811900800 - tz.transition 1996, 3, :o8, 828230400 - tz.transition 1996, 10, :o4, 846374400 - tz.transition 1997, 3, :o8, 859680000 - tz.transition 1997, 10, :o4, 877824000 - tz.transition 1998, 3, :o6, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o6, 922582800 - tz.transition 1999, 10, :o4, 941331600 - tz.transition 2003, 3, :o8, 1048986000 - tz.transition 2003, 10, :o4, 1067130000 - tz.transition 2004, 3, :o8, 1080435600 - tz.transition 2004, 10, :o4, 1099184400 - tz.transition 2005, 3, :o8, 1111885200 - tz.transition 2005, 10, :o4, 1130634000 - tz.transition 2006, 3, :o8, 1143334800 - tz.transition 2006, 10, :o4, 1162083600 - tz.transition 2007, 3, :o8, 1174784400 - tz.transition 2007, 10, :o4, 1193533200 - tz.transition 2008, 3, :o8, 1206838800 - tz.transition 2008, 10, :o4, 1224982800 - tz.transition 2009, 3, :o8, 1238288400 - tz.transition 2009, 10, :o4, 1256432400 - tz.transition 2010, 3, :o8, 1269738000 - tz.transition 2010, 10, :o4, 1288486800 - tz.transition 2011, 3, :o8, 1301187600 - tz.transition 2011, 10, :o4, 1319936400 - tz.transition 2012, 3, :o8, 1332637200 - tz.transition 2012, 10, :o4, 1351386000 - tz.transition 2013, 3, :o8, 1364691600 - tz.transition 2013, 10, :o4, 1382835600 - tz.transition 2014, 3, :o8, 1396141200 - tz.transition 2014, 10, :o4, 1414285200 - tz.transition 2015, 3, :o8, 1427590800 - tz.transition 2015, 10, :o4, 1445734800 - tz.transition 2016, 3, :o8, 1459040400 - tz.transition 2016, 10, :o4, 1477789200 - tz.transition 2017, 3, :o8, 1490490000 - tz.transition 2017, 10, :o4, 1509238800 - tz.transition 2018, 3, :o8, 1521939600 - tz.transition 2018, 10, :o4, 1540688400 - tz.transition 2019, 3, :o8, 1553994000 - tz.transition 2019, 10, :o4, 1572138000 - tz.transition 2020, 3, :o8, 1585443600 - tz.transition 2020, 10, :o4, 1603587600 - tz.transition 2021, 3, :o8, 1616893200 - tz.transition 2021, 10, :o4, 1635642000 - tz.transition 2022, 3, :o8, 1648342800 - tz.transition 2022, 10, :o4, 1667091600 - tz.transition 2023, 3, :o8, 1679792400 - tz.transition 2023, 10, :o4, 1698541200 - tz.transition 2024, 3, :o8, 1711846800 - tz.transition 2024, 10, :o4, 1729990800 - tz.transition 2025, 3, :o8, 1743296400 - tz.transition 2025, 10, :o4, 1761440400 - tz.transition 2026, 3, :o8, 1774746000 - tz.transition 2026, 10, :o4, 1792890000 - tz.transition 2027, 3, :o8, 1806195600 - tz.transition 2027, 10, :o4, 1824944400 - tz.transition 2028, 3, :o8, 1837645200 - tz.transition 2028, 10, :o4, 1856394000 - tz.transition 2029, 3, :o8, 1869094800 - tz.transition 2029, 10, :o4, 1887843600 - tz.transition 2030, 3, :o8, 1901149200 - tz.transition 2030, 10, :o4, 1919293200 - tz.transition 2031, 3, :o8, 1932598800 - tz.transition 2031, 10, :o4, 1950742800 - tz.transition 2032, 3, :o8, 1964048400 - tz.transition 2032, 10, :o4, 1982797200 - tz.transition 2033, 3, :o8, 1995498000 - tz.transition 2033, 10, :o4, 2014246800 - tz.transition 2034, 3, :o8, 2026947600 - tz.transition 2034, 10, :o4, 2045696400 - tz.transition 2035, 3, :o8, 2058397200 - tz.transition 2035, 10, :o4, 2077146000 - tz.transition 2036, 3, :o8, 2090451600 - tz.transition 2036, 10, :o4, 2108595600 - tz.transition 2037, 3, :o8, 2121901200 - tz.transition 2037, 10, :o4, 2140045200 - tz.transition 2038, 3, :o8, 59172253, 24 - tz.transition 2038, 10, :o4, 59177461, 24 - tz.transition 2039, 3, :o8, 59180989, 24 - tz.transition 2039, 10, :o4, 59186197, 24 - tz.transition 2040, 3, :o8, 59189725, 24 - tz.transition 2040, 10, :o4, 59194933, 24 - tz.transition 2041, 3, :o8, 59198629, 24 - tz.transition 2041, 10, :o4, 59203669, 24 - tz.transition 2042, 3, :o8, 59207365, 24 - tz.transition 2042, 10, :o4, 59212405, 24 - tz.transition 2043, 3, :o8, 59216101, 24 - tz.transition 2043, 10, :o4, 59221141, 24 - tz.transition 2044, 3, :o8, 59224837, 24 - tz.transition 2044, 10, :o4, 59230045, 24 - tz.transition 2045, 3, :o8, 59233573, 24 - tz.transition 2045, 10, :o4, 59238781, 24 - tz.transition 2046, 3, :o8, 59242309, 24 - tz.transition 2046, 10, :o4, 59247517, 24 - tz.transition 2047, 3, :o8, 59251213, 24 - tz.transition 2047, 10, :o4, 59256253, 24 - tz.transition 2048, 3, :o8, 59259949, 24 - tz.transition 2048, 10, :o4, 59264989, 24 - tz.transition 2049, 3, :o8, 59268685, 24 - tz.transition 2049, 10, :o4, 59273893, 24 - tz.transition 2050, 3, :o8, 59277421, 24 - tz.transition 2050, 10, :o4, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb deleted file mode 100644 index 7fa51c26..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +++ /dev/null @@ -1,212 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Warsaw - include TimezoneDefinition - - timezone 'Europe/Warsaw' do |tz| - tz.offset :o0, 5040, 0, :LMT - tz.offset :o1, 5040, 0, :WMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - tz.offset :o4, 7200, 0, :EET - tz.offset :o5, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 288925853, 120 - tz.transition 1915, 8, :o2, 290485733, 120 - tz.transition 1916, 4, :o3, 29051813, 12 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1917, 4, :o3, 58112029, 24 - tz.transition 1917, 9, :o2, 58115725, 24 - tz.transition 1918, 4, :o3, 58120765, 24 - tz.transition 1918, 9, :o4, 58124461, 24 - tz.transition 1919, 4, :o5, 4844127, 2 - tz.transition 1919, 9, :o4, 4844435, 2 - tz.transition 1922, 5, :o2, 29078477, 12 - tz.transition 1940, 6, :o3, 58315285, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 10, :o2, 4862735, 2 - tz.transition 1945, 4, :o3, 58357787, 24 - tz.transition 1945, 10, :o2, 29181125, 12 - tz.transition 1946, 4, :o3, 58366187, 24 - tz.transition 1946, 10, :o2, 58370413, 24 - tz.transition 1947, 5, :o3, 58375429, 24 - tz.transition 1947, 10, :o2, 58379125, 24 - tz.transition 1948, 4, :o3, 58383829, 24 - tz.transition 1948, 10, :o2, 58387861, 24 - tz.transition 1949, 4, :o3, 58392397, 24 - tz.transition 1949, 10, :o2, 58396597, 24 - tz.transition 1957, 6, :o3, 4871983, 2 - tz.transition 1957, 9, :o2, 4872221, 2 - tz.transition 1958, 3, :o3, 4872585, 2 - tz.transition 1958, 9, :o2, 4872949, 2 - tz.transition 1959, 5, :o3, 4873439, 2 - tz.transition 1959, 10, :o2, 4873691, 2 - tz.transition 1960, 4, :o3, 4874055, 2 - tz.transition 1960, 10, :o2, 4874419, 2 - tz.transition 1961, 5, :o3, 4874895, 2 - tz.transition 1961, 10, :o2, 4875147, 2 - tz.transition 1962, 5, :o3, 4875623, 2 - tz.transition 1962, 9, :o2, 4875875, 2 - tz.transition 1963, 5, :o3, 4876351, 2 - tz.transition 1963, 9, :o2, 4876603, 2 - tz.transition 1964, 5, :o3, 4877093, 2 - tz.transition 1964, 9, :o2, 4877331, 2 - tz.transition 1977, 4, :o3, 228873600 - tz.transition 1977, 9, :o2, 243993600 - tz.transition 1978, 4, :o3, 260323200 - tz.transition 1978, 10, :o2, 276048000 - tz.transition 1979, 4, :o3, 291772800 - tz.transition 1979, 9, :o2, 307497600 - tz.transition 1980, 4, :o3, 323827200 - tz.transition 1980, 9, :o2, 338947200 - tz.transition 1981, 3, :o3, 354672000 - tz.transition 1981, 9, :o2, 370396800 - tz.transition 1982, 3, :o3, 386121600 - tz.transition 1982, 9, :o2, 401846400 - tz.transition 1983, 3, :o3, 417571200 - tz.transition 1983, 9, :o2, 433296000 - tz.transition 1984, 3, :o3, 449020800 - tz.transition 1984, 9, :o2, 465350400 - tz.transition 1985, 3, :o3, 481075200 - tz.transition 1985, 9, :o2, 496800000 - tz.transition 1986, 3, :o3, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o3, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb deleted file mode 100644 index ecdd903d..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Zagreb - include TimezoneDefinition - - linked_timezone 'Europe/Zagreb', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb deleted file mode 100644 index a524fd6b..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +++ /dev/null @@ -1,202 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Auckland - include TimezoneDefinition - - timezone 'Pacific/Auckland' do |tz| - tz.offset :o0, 41944, 0, :LMT - tz.offset :o1, 41400, 0, :NZMT - tz.offset :o2, 41400, 3600, :NZST - tz.offset :o3, 41400, 1800, :NZST - tz.offset :o4, 43200, 0, :NZST - tz.offset :o5, 43200, 3600, :NZDT - - tz.transition 1868, 11, :o1, 25959290557, 10800 - tz.transition 1927, 11, :o2, 116409125, 48 - tz.transition 1928, 3, :o1, 38804945, 16 - tz.transition 1928, 10, :o3, 116425589, 48 - tz.transition 1929, 3, :o1, 29108245, 12 - tz.transition 1929, 10, :o3, 116443061, 48 - tz.transition 1930, 3, :o1, 29112613, 12 - tz.transition 1930, 10, :o3, 116460533, 48 - tz.transition 1931, 3, :o1, 29116981, 12 - tz.transition 1931, 10, :o3, 116478005, 48 - tz.transition 1932, 3, :o1, 29121433, 12 - tz.transition 1932, 10, :o3, 116495477, 48 - tz.transition 1933, 3, :o1, 29125801, 12 - tz.transition 1933, 10, :o3, 116512949, 48 - tz.transition 1934, 4, :o1, 29130673, 12 - tz.transition 1934, 9, :o3, 116530085, 48 - tz.transition 1935, 4, :o1, 29135041, 12 - tz.transition 1935, 9, :o3, 116547557, 48 - tz.transition 1936, 4, :o1, 29139409, 12 - tz.transition 1936, 9, :o3, 116565029, 48 - tz.transition 1937, 4, :o1, 29143777, 12 - tz.transition 1937, 9, :o3, 116582501, 48 - tz.transition 1938, 4, :o1, 29148145, 12 - tz.transition 1938, 9, :o3, 116599973, 48 - tz.transition 1939, 4, :o1, 29152597, 12 - tz.transition 1939, 9, :o3, 116617445, 48 - tz.transition 1940, 4, :o1, 29156965, 12 - tz.transition 1940, 9, :o3, 116635253, 48 - tz.transition 1945, 12, :o4, 2431821, 1 - tz.transition 1974, 11, :o5, 152632800 - tz.transition 1975, 2, :o4, 162309600 - tz.transition 1975, 10, :o5, 183477600 - tz.transition 1976, 3, :o4, 194968800 - tz.transition 1976, 10, :o5, 215532000 - tz.transition 1977, 3, :o4, 226418400 - tz.transition 1977, 10, :o5, 246981600 - tz.transition 1978, 3, :o4, 257868000 - tz.transition 1978, 10, :o5, 278431200 - tz.transition 1979, 3, :o4, 289317600 - tz.transition 1979, 10, :o5, 309880800 - tz.transition 1980, 3, :o4, 320767200 - tz.transition 1980, 10, :o5, 341330400 - tz.transition 1981, 2, :o4, 352216800 - tz.transition 1981, 10, :o5, 372780000 - tz.transition 1982, 3, :o4, 384271200 - tz.transition 1982, 10, :o5, 404834400 - tz.transition 1983, 3, :o4, 415720800 - tz.transition 1983, 10, :o5, 436284000 - tz.transition 1984, 3, :o4, 447170400 - tz.transition 1984, 10, :o5, 467733600 - tz.transition 1985, 3, :o4, 478620000 - tz.transition 1985, 10, :o5, 499183200 - tz.transition 1986, 3, :o4, 510069600 - tz.transition 1986, 10, :o5, 530632800 - tz.transition 1987, 2, :o4, 541519200 - tz.transition 1987, 10, :o5, 562082400 - tz.transition 1988, 3, :o4, 573573600 - tz.transition 1988, 10, :o5, 594136800 - tz.transition 1989, 3, :o4, 605023200 - tz.transition 1989, 10, :o5, 623772000 - tz.transition 1990, 3, :o4, 637682400 - tz.transition 1990, 10, :o5, 655221600 - tz.transition 1991, 3, :o4, 669132000 - tz.transition 1991, 10, :o5, 686671200 - tz.transition 1992, 3, :o4, 700581600 - tz.transition 1992, 10, :o5, 718120800 - tz.transition 1993, 3, :o4, 732636000 - tz.transition 1993, 10, :o5, 749570400 - tz.transition 1994, 3, :o4, 764085600 - tz.transition 1994, 10, :o5, 781020000 - tz.transition 1995, 3, :o4, 795535200 - tz.transition 1995, 9, :o5, 812469600 - tz.transition 1996, 3, :o4, 826984800 - tz.transition 1996, 10, :o5, 844524000 - tz.transition 1997, 3, :o4, 858434400 - tz.transition 1997, 10, :o5, 875973600 - tz.transition 1998, 3, :o4, 889884000 - tz.transition 1998, 10, :o5, 907423200 - tz.transition 1999, 3, :o4, 921938400 - tz.transition 1999, 10, :o5, 938872800 - tz.transition 2000, 3, :o4, 953388000 - tz.transition 2000, 9, :o5, 970322400 - tz.transition 2001, 3, :o4, 984837600 - tz.transition 2001, 10, :o5, 1002376800 - tz.transition 2002, 3, :o4, 1016287200 - tz.transition 2002, 10, :o5, 1033826400 - tz.transition 2003, 3, :o4, 1047736800 - tz.transition 2003, 10, :o5, 1065276000 - tz.transition 2004, 3, :o4, 1079791200 - tz.transition 2004, 10, :o5, 1096725600 - tz.transition 2005, 3, :o4, 1111240800 - tz.transition 2005, 10, :o5, 1128175200 - tz.transition 2006, 3, :o4, 1142690400 - tz.transition 2006, 9, :o5, 1159624800 - tz.transition 2007, 3, :o4, 1174140000 - tz.transition 2007, 9, :o5, 1191074400 - tz.transition 2008, 4, :o4, 1207404000 - tz.transition 2008, 9, :o5, 1222524000 - tz.transition 2009, 4, :o4, 1238853600 - tz.transition 2009, 9, :o5, 1253973600 - tz.transition 2010, 4, :o4, 1270303200 - tz.transition 2010, 9, :o5, 1285423200 - tz.transition 2011, 4, :o4, 1301752800 - tz.transition 2011, 9, :o5, 1316872800 - tz.transition 2012, 3, :o4, 1333202400 - tz.transition 2012, 9, :o5, 1348927200 - tz.transition 2013, 4, :o4, 1365256800 - tz.transition 2013, 9, :o5, 1380376800 - tz.transition 2014, 4, :o4, 1396706400 - tz.transition 2014, 9, :o5, 1411826400 - tz.transition 2015, 4, :o4, 1428156000 - tz.transition 2015, 9, :o5, 1443276000 - tz.transition 2016, 4, :o4, 1459605600 - tz.transition 2016, 9, :o5, 1474725600 - tz.transition 2017, 4, :o4, 1491055200 - tz.transition 2017, 9, :o5, 1506175200 - tz.transition 2018, 3, :o4, 1522504800 - tz.transition 2018, 9, :o5, 1538229600 - tz.transition 2019, 4, :o4, 1554559200 - tz.transition 2019, 9, :o5, 1569679200 - tz.transition 2020, 4, :o4, 1586008800 - tz.transition 2020, 9, :o5, 1601128800 - tz.transition 2021, 4, :o4, 1617458400 - tz.transition 2021, 9, :o5, 1632578400 - tz.transition 2022, 4, :o4, 1648908000 - tz.transition 2022, 9, :o5, 1664028000 - tz.transition 2023, 4, :o4, 1680357600 - tz.transition 2023, 9, :o5, 1695477600 - tz.transition 2024, 4, :o4, 1712412000 - tz.transition 2024, 9, :o5, 1727532000 - tz.transition 2025, 4, :o4, 1743861600 - tz.transition 2025, 9, :o5, 1758981600 - tz.transition 2026, 4, :o4, 1775311200 - tz.transition 2026, 9, :o5, 1790431200 - tz.transition 2027, 4, :o4, 1806760800 - tz.transition 2027, 9, :o5, 1821880800 - tz.transition 2028, 4, :o4, 1838210400 - tz.transition 2028, 9, :o5, 1853330400 - tz.transition 2029, 3, :o4, 1869660000 - tz.transition 2029, 9, :o5, 1885384800 - tz.transition 2030, 4, :o4, 1901714400 - tz.transition 2030, 9, :o5, 1916834400 - tz.transition 2031, 4, :o4, 1933164000 - tz.transition 2031, 9, :o5, 1948284000 - tz.transition 2032, 4, :o4, 1964613600 - tz.transition 2032, 9, :o5, 1979733600 - tz.transition 2033, 4, :o4, 1996063200 - tz.transition 2033, 9, :o5, 2011183200 - tz.transition 2034, 4, :o4, 2027512800 - tz.transition 2034, 9, :o5, 2042632800 - tz.transition 2035, 3, :o4, 2058962400 - tz.transition 2035, 9, :o5, 2074687200 - tz.transition 2036, 4, :o4, 2091016800 - tz.transition 2036, 9, :o5, 2106136800 - tz.transition 2037, 4, :o4, 2122466400 - tz.transition 2037, 9, :o5, 2137586400 - tz.transition 2038, 4, :o4, 29586205, 12 - tz.transition 2038, 9, :o5, 29588305, 12 - tz.transition 2039, 4, :o4, 29590573, 12 - tz.transition 2039, 9, :o5, 29592673, 12 - tz.transition 2040, 3, :o4, 29594941, 12 - tz.transition 2040, 9, :o5, 29597125, 12 - tz.transition 2041, 4, :o4, 29599393, 12 - tz.transition 2041, 9, :o5, 29601493, 12 - tz.transition 2042, 4, :o4, 29603761, 12 - tz.transition 2042, 9, :o5, 29605861, 12 - tz.transition 2043, 4, :o4, 29608129, 12 - tz.transition 2043, 9, :o5, 29610229, 12 - tz.transition 2044, 4, :o4, 29612497, 12 - tz.transition 2044, 9, :o5, 29614597, 12 - tz.transition 2045, 4, :o4, 29616865, 12 - tz.transition 2045, 9, :o5, 29618965, 12 - tz.transition 2046, 3, :o4, 29621233, 12 - tz.transition 2046, 9, :o5, 29623417, 12 - tz.transition 2047, 4, :o4, 29625685, 12 - tz.transition 2047, 9, :o5, 29627785, 12 - tz.transition 2048, 4, :o4, 29630053, 12 - tz.transition 2048, 9, :o5, 29632153, 12 - tz.transition 2049, 4, :o4, 29634421, 12 - tz.transition 2049, 9, :o5, 29636521, 12 - tz.transition 2050, 4, :o4, 29638789, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb deleted file mode 100644 index 5fe9bbd9..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Fiji - include TimezoneDefinition - - timezone 'Pacific/Fiji' do |tz| - tz.offset :o0, 42820, 0, :LMT - tz.offset :o1, 43200, 0, :FJT - tz.offset :o2, 43200, 3600, :FJST - - tz.transition 1915, 10, :o1, 10457838739, 4320 - tz.transition 1998, 10, :o2, 909842400 - tz.transition 1999, 2, :o1, 920124000 - tz.transition 1999, 11, :o2, 941896800 - tz.transition 2000, 2, :o1, 951573600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb deleted file mode 100644 index d4c1a0a6..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Guam - include TimezoneDefinition - - timezone 'Pacific/Guam' do |tz| - tz.offset :o0, -51660, 0, :LMT - tz.offset :o1, 34740, 0, :LMT - tz.offset :o2, 36000, 0, :GST - tz.offset :o3, 36000, 0, :ChST - - tz.transition 1844, 12, :o1, 1149567407, 480 - tz.transition 1900, 12, :o2, 1159384847, 480 - tz.transition 2000, 12, :o3, 977493600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb deleted file mode 100644 index 204b2265..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Honolulu - include TimezoneDefinition - - timezone 'Pacific/Honolulu' do |tz| - tz.offset :o0, -37886, 0, :LMT - tz.offset :o1, -37800, 0, :HST - tz.offset :o2, -37800, 3600, :HDT - tz.offset :o3, -37800, 3600, :HWT - tz.offset :o4, -37800, 3600, :HPT - tz.offset :o5, -36000, 0, :HST - - tz.transition 1900, 1, :o1, 104328926143, 43200 - tz.transition 1933, 4, :o2, 116505265, 48 - tz.transition 1933, 5, :o1, 116506271, 48 - tz.transition 1942, 2, :o3, 116659201, 48 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 116722991, 48 - tz.transition 1947, 6, :o5, 116752561, 48 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb deleted file mode 100644 index 32adad92..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Majuro - include TimezoneDefinition - - timezone 'Pacific/Majuro' do |tz| - tz.offset :o0, 41088, 0, :LMT - tz.offset :o1, 39600, 0, :MHT - tz.offset :o2, 43200, 0, :MHT - - tz.transition 1900, 12, :o1, 1086923261, 450 - tz.transition 1969, 9, :o2, 58571881, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb deleted file mode 100644 index 97784fcc..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Midway - include TimezoneDefinition - - timezone 'Pacific/Midway' do |tz| - tz.offset :o0, -42568, 0, :LMT - tz.offset :o1, -39600, 0, :NST - tz.offset :o2, -39600, 3600, :NDT - tz.offset :o3, -39600, 0, :BST - tz.offset :o4, -39600, 0, :SST - - tz.transition 1901, 1, :o1, 26086168721, 10800 - tz.transition 1956, 6, :o2, 58455071, 24 - tz.transition 1956, 9, :o1, 29228627, 12 - tz.transition 1967, 4, :o3, 58549967, 24 - tz.transition 1983, 11, :o4, 439038000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb deleted file mode 100644 index 70173db8..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Noumea - include TimezoneDefinition - - timezone 'Pacific/Noumea' do |tz| - tz.offset :o0, 39948, 0, :LMT - tz.offset :o1, 39600, 0, :NCT - tz.offset :o2, 39600, 3600, :NCST - - tz.transition 1912, 1, :o1, 17419781071, 7200 - tz.transition 1977, 12, :o2, 250002000 - tz.transition 1978, 2, :o1, 257342400 - tz.transition 1978, 12, :o2, 281451600 - tz.transition 1979, 2, :o1, 288878400 - tz.transition 1996, 11, :o2, 849366000 - tz.transition 1997, 3, :o1, 857228400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb deleted file mode 100644 index c8fcd7d5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Pago_Pago - include TimezoneDefinition - - timezone 'Pacific/Pago_Pago' do |tz| - tz.offset :o0, 45432, 0, :LMT - tz.offset :o1, -40968, 0, :LMT - tz.offset :o2, -41400, 0, :SAMT - tz.offset :o3, -39600, 0, :NST - tz.offset :o4, -39600, 0, :BST - tz.offset :o5, -39600, 0, :SST - - tz.transition 1879, 7, :o1, 2889041969, 1200 - tz.transition 1911, 1, :o2, 2902845569, 1200 - tz.transition 1950, 1, :o3, 116797583, 48 - tz.transition 1967, 4, :o4, 58549967, 24 - tz.transition 1983, 11, :o5, 439038000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb deleted file mode 100644 index f06cf6d5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Port_Moresby - include TimezoneDefinition - - timezone 'Pacific/Port_Moresby' do |tz| - tz.offset :o0, 35320, 0, :LMT - tz.offset :o1, 35312, 0, :PMMT - tz.offset :o2, 36000, 0, :PGT - - tz.transition 1879, 12, :o1, 5200664597, 2160 - tz.transition 1894, 12, :o2, 13031248093, 5400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb deleted file mode 100644 index 7578d92f..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Tongatapu - include TimezoneDefinition - - timezone 'Pacific/Tongatapu' do |tz| - tz.offset :o0, 44360, 0, :LMT - tz.offset :o1, 44400, 0, :TOT - tz.offset :o2, 46800, 0, :TOT - tz.offset :o3, 46800, 3600, :TOST - - tz.transition 1900, 12, :o1, 5217231571, 2160 - tz.transition 1940, 12, :o2, 174959639, 72 - tz.transition 1999, 10, :o3, 939214800 - tz.transition 2000, 3, :o2, 953384400 - tz.transition 2000, 11, :o3, 973342800 - tz.transition 2001, 1, :o2, 980596800 - tz.transition 2001, 11, :o3, 1004792400 - tz.transition 2002, 1, :o2, 1012046400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb deleted file mode 100644 index 001303c5..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +++ /dev/null @@ -1,52 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/timezone' - -module TZInfo - - # A Timezone based on a TimezoneInfo. - class InfoTimezone < Timezone #:nodoc: - - # Constructs a new InfoTimezone with a TimezoneInfo instance. - def self.new(info) - tz = super() - tz.send(:setup, info) - tz - end - - # The identifier of the timezone, e.g. "Europe/Paris". - def identifier - @info.identifier - end - - protected - # The TimezoneInfo for this Timezone. - def info - @info - end - - def setup(info) - @info = info - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb deleted file mode 100644 index f8ec4fca..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +++ /dev/null @@ -1,51 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/info_timezone' - -module TZInfo - - class LinkedTimezone < InfoTimezone #:nodoc: - # Returns the TimezonePeriod for the given UTC time. utc can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in utc is ignored (it is treated as a UTC time). - # - # If no TimezonePeriod could be found, PeriodNotFound is raised. - def period_for_utc(utc) - @linked_timezone.period_for_utc(utc) - end - - # Returns the set of TimezonePeriod instances that are valid for the given - # local time as an array. If you just want a single period, use - # period_for_local instead and specify how abiguities should be resolved. - # Raises PeriodNotFound if no periods are found for the given time. - def periods_for_local(local) - @linked_timezone.periods_for_local(local) - end - - protected - def setup(info) - super(info) - @linked_timezone = Timezone.get(info.link_to_identifier) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb deleted file mode 100644 index 8197ff3e..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +++ /dev/null @@ -1,44 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/timezone_info' - -module TZInfo - # Represents a linked timezone defined in a data module. - class LinkedTimezoneInfo < TimezoneInfo #:nodoc: - - # The zone that provides the data (that this zone is an alias for). - attr_reader :link_to_identifier - - # Constructs a new TimezoneInfo with an identifier and the identifier - # of the zone linked to. - def initialize(identifier, link_to_identifier) - super(identifier) - @link_to_identifier = link_to_identifier - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #@identifier,#@link_to_identifier>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb deleted file mode 100644 index b1f10b2b..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +++ /dev/null @@ -1,98 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'rational' -require 'tzinfo/ruby_core_support' - -module TZInfo - - # Provides a method for getting Rationals for a timezone offset in seconds. - # Pre-reduced rationals are returned for all the half-hour intervals between - # -14 and +14 hours to avoid having to call gcd at runtime. - module OffsetRationals #:nodoc: - @@rational_cache = { - -50400 => RubyCoreSupport.rational_new!(-7,12), - -48600 => RubyCoreSupport.rational_new!(-9,16), - -46800 => RubyCoreSupport.rational_new!(-13,24), - -45000 => RubyCoreSupport.rational_new!(-25,48), - -43200 => RubyCoreSupport.rational_new!(-1,2), - -41400 => RubyCoreSupport.rational_new!(-23,48), - -39600 => RubyCoreSupport.rational_new!(-11,24), - -37800 => RubyCoreSupport.rational_new!(-7,16), - -36000 => RubyCoreSupport.rational_new!(-5,12), - -34200 => RubyCoreSupport.rational_new!(-19,48), - -32400 => RubyCoreSupport.rational_new!(-3,8), - -30600 => RubyCoreSupport.rational_new!(-17,48), - -28800 => RubyCoreSupport.rational_new!(-1,3), - -27000 => RubyCoreSupport.rational_new!(-5,16), - -25200 => RubyCoreSupport.rational_new!(-7,24), - -23400 => RubyCoreSupport.rational_new!(-13,48), - -21600 => RubyCoreSupport.rational_new!(-1,4), - -19800 => RubyCoreSupport.rational_new!(-11,48), - -18000 => RubyCoreSupport.rational_new!(-5,24), - -16200 => RubyCoreSupport.rational_new!(-3,16), - -14400 => RubyCoreSupport.rational_new!(-1,6), - -12600 => RubyCoreSupport.rational_new!(-7,48), - -10800 => RubyCoreSupport.rational_new!(-1,8), - -9000 => RubyCoreSupport.rational_new!(-5,48), - -7200 => RubyCoreSupport.rational_new!(-1,12), - -5400 => RubyCoreSupport.rational_new!(-1,16), - -3600 => RubyCoreSupport.rational_new!(-1,24), - -1800 => RubyCoreSupport.rational_new!(-1,48), - 0 => RubyCoreSupport.rational_new!(0,1), - 1800 => RubyCoreSupport.rational_new!(1,48), - 3600 => RubyCoreSupport.rational_new!(1,24), - 5400 => RubyCoreSupport.rational_new!(1,16), - 7200 => RubyCoreSupport.rational_new!(1,12), - 9000 => RubyCoreSupport.rational_new!(5,48), - 10800 => RubyCoreSupport.rational_new!(1,8), - 12600 => RubyCoreSupport.rational_new!(7,48), - 14400 => RubyCoreSupport.rational_new!(1,6), - 16200 => RubyCoreSupport.rational_new!(3,16), - 18000 => RubyCoreSupport.rational_new!(5,24), - 19800 => RubyCoreSupport.rational_new!(11,48), - 21600 => RubyCoreSupport.rational_new!(1,4), - 23400 => RubyCoreSupport.rational_new!(13,48), - 25200 => RubyCoreSupport.rational_new!(7,24), - 27000 => RubyCoreSupport.rational_new!(5,16), - 28800 => RubyCoreSupport.rational_new!(1,3), - 30600 => RubyCoreSupport.rational_new!(17,48), - 32400 => RubyCoreSupport.rational_new!(3,8), - 34200 => RubyCoreSupport.rational_new!(19,48), - 36000 => RubyCoreSupport.rational_new!(5,12), - 37800 => RubyCoreSupport.rational_new!(7,16), - 39600 => RubyCoreSupport.rational_new!(11,24), - 41400 => RubyCoreSupport.rational_new!(23,48), - 43200 => RubyCoreSupport.rational_new!(1,2), - 45000 => RubyCoreSupport.rational_new!(25,48), - 46800 => RubyCoreSupport.rational_new!(13,24), - 48600 => RubyCoreSupport.rational_new!(9,16), - 50400 => RubyCoreSupport.rational_new!(7,12)} - - # Returns a Rational expressing the fraction of a day that offset in - # seconds represents (i.e. equivalent to Rational(offset, 86400)). - def rational_for_offset(offset) - @@rational_cache[offset] || Rational(offset, 86400) - end - module_function :rational_for_offset - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb deleted file mode 100644 index 9a044120..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +++ /dev/null @@ -1,56 +0,0 @@ -#-- -# Copyright (c) 2008 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -require 'rational' - -module TZInfo - - # Methods to support different versions of Ruby. - module RubyCoreSupport #:nodoc: - - # Use Rational.new! for performance reasons in Ruby 1.8. - # This has been removed from 1.9, but Rational performs better. - if Rational.respond_to? :new! - def self.rational_new!(numerator, denominator = 1) - Rational.new!(numerator, denominator) - end - else - def self.rational_new!(numerator, denominator = 1) - Rational(numerator, denominator) - end - end - - # Ruby 1.8.6 introduced new! and deprecated new0. - # Ruby 1.9.0 removed new0. - # We still need to support new0 for older versions of Ruby. - if DateTime.respond_to? :new! - def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) - DateTime.new!(ajd, of, sg) - end - else - def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) - DateTime.new0(ajd, of, sg) - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb deleted file mode 100644 index 264517f3..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +++ /dev/null @@ -1,292 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -require 'time' -require 'tzinfo/offset_rationals' - -module TZInfo - # Used by TZInfo internally to represent either a Time, DateTime or integer - # timestamp (seconds since 1970-01-01 00:00:00). - class TimeOrDateTime #:nodoc: - include Comparable - - # Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime - # or an integer. If using a Time or DateTime, any time zone information is - # ignored. - def initialize(timeOrDateTime) - @time = nil - @datetime = nil - @timestamp = nil - - if timeOrDateTime.is_a?(Time) - @time = timeOrDateTime - @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec) unless @time.zone == 'UTC' - @orig = @time - elsif timeOrDateTime.is_a?(DateTime) - @datetime = timeOrDateTime - @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 - @orig = @datetime - else - @timestamp = timeOrDateTime.to_i - @orig = @timestamp - end - end - - # Returns the time as a Time. - def to_time - unless @time - if @timestamp - @time = Time.at(@timestamp).utc - else - @time = Time.utc(year, mon, mday, hour, min, sec) - end - end - - @time - end - - # Returns the time as a DateTime. - def to_datetime - unless @datetime - @datetime = DateTime.new(year, mon, mday, hour, min, sec) - end - - @datetime - end - - # Returns the time as an integer timestamp. - def to_i - unless @timestamp - @timestamp = to_time.to_i - end - - @timestamp - end - - # Returns the time as the original time passed to new. - def to_orig - @orig - end - - # Returns a string representation of the TimeOrDateTime. - def to_s - if @orig.is_a?(Time) - "Time: #{@orig.to_s}" - elsif @orig.is_a?(DateTime) - "DateTime: #{@orig.to_s}" - else - "Timestamp: #{@orig.to_s}" - end - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #{@orig.inspect}>" - end - - # Returns the year. - def year - if @time - @time.year - elsif @datetime - @datetime.year - else - to_time.year - end - end - - # Returns the month of the year (1..12). - def mon - if @time - @time.mon - elsif @datetime - @datetime.mon - else - to_time.mon - end - end - alias :month :mon - - # Returns the day of the month (1..n). - def mday - if @time - @time.mday - elsif @datetime - @datetime.mday - else - to_time.mday - end - end - alias :day :mday - - # Returns the hour of the day (0..23). - def hour - if @time - @time.hour - elsif @datetime - @datetime.hour - else - to_time.hour - end - end - - # Returns the minute of the hour (0..59). - def min - if @time - @time.min - elsif @datetime - @datetime.min - else - to_time.min - end - end - - # Returns the second of the minute (0..60). (60 for a leap second). - def sec - if @time - @time.sec - elsif @datetime - @datetime.sec - else - to_time.sec - end - end - - # Compares this TimeOrDateTime with another Time, DateTime, integer - # timestamp or TimeOrDateTime. Returns -1, 0 or +1 depending whether the - # receiver is less than, equal to, or greater than timeOrDateTime. - # - # Milliseconds and smaller units are ignored in the comparison. - def <=>(timeOrDateTime) - if timeOrDateTime.is_a?(TimeOrDateTime) - orig = timeOrDateTime.to_orig - - if @orig.is_a?(DateTime) || orig.is_a?(DateTime) - # If either is a DateTime, assume it is there for a reason - # (i.e. for range). - to_datetime <=> timeOrDateTime.to_datetime - elsif orig.is_a?(Time) - to_time <=> timeOrDateTime.to_time - else - to_i <=> timeOrDateTime.to_i - end - elsif @orig.is_a?(DateTime) || timeOrDateTime.is_a?(DateTime) - # If either is a DateTime, assume it is there for a reason - # (i.e. for range). - to_datetime <=> TimeOrDateTime.wrap(timeOrDateTime).to_datetime - elsif timeOrDateTime.is_a?(Time) - to_time <=> timeOrDateTime - else - to_i <=> timeOrDateTime.to_i - end - end - - # Adds a number of seconds to the TimeOrDateTime. Returns a new - # TimeOrDateTime, preserving what the original constructed type was. - # If the original type is a Time and the resulting calculation goes out of - # range for Times, then an exception will be raised by the Time class. - def +(seconds) - if seconds == 0 - self - else - if @orig.is_a?(DateTime) - TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) - else - # + defined for Time and integer timestamps - TimeOrDateTime.new(@orig + seconds) - end - end - end - - # Subtracts a number of seconds from the TimeOrDateTime. Returns a new - # TimeOrDateTime, preserving what the original constructed type was. - # If the original type is a Time and the resulting calculation goes out of - # range for Times, then an exception will be raised by the Time class. - def -(seconds) - self + (-seconds) - end - - # Similar to the + operator, but for cases where adding would cause a - # timestamp or time to go out of the allowed range, converts to a DateTime - # based TimeOrDateTime. - def add_with_convert(seconds) - if seconds == 0 - self - else - if @orig.is_a?(DateTime) - TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) - else - # A Time or timestamp. - result = to_i + seconds - - if result < 0 || result > 2147483647 - result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds)) - else - result = TimeOrDateTime.new(@orig + seconds) - end - end - end - end - - # Returns true if todt represents the same time and was originally - # constructed with the same type (DateTime, Time or timestamp) as this - # TimeOrDateTime. - def eql?(todt) - todt.respond_to?(:to_orig) && to_orig.eql?(todt.to_orig) - end - - # Returns a hash of this TimeOrDateTime. - def hash - @orig.hash - end - - # If no block is given, returns a TimeOrDateTime wrapping the given - # timeOrDateTime. If a block is specified, a TimeOrDateTime is constructed - # and passed to the block. The result of the block must be a TimeOrDateTime. - # to_orig will be called on the result and the result of to_orig will be - # returned. - # - # timeOrDateTime can be a Time, DateTime, integer timestamp or TimeOrDateTime. - # If a TimeOrDateTime is passed in, no new TimeOrDateTime will be constructed, - # the passed in value will be used. - def self.wrap(timeOrDateTime) - t = timeOrDateTime.is_a?(TimeOrDateTime) ? timeOrDateTime : TimeOrDateTime.new(timeOrDateTime) - - if block_given? - t = yield t - - if timeOrDateTime.is_a?(TimeOrDateTime) - t - elsif timeOrDateTime.is_a?(Time) - t.to_time - elsif timeOrDateTime.is_a?(DateTime) - t.to_datetime - else - t.to_i - end - else - t - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb deleted file mode 100644 index f87fb6fb..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +++ /dev/null @@ -1,508 +0,0 @@ -#-- -# Copyright (c) 2005-2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -# require 'tzinfo/country' -require 'tzinfo/time_or_datetime' -require 'tzinfo/timezone_period' - -module TZInfo - # Indicate a specified time in a local timezone has more than one - # possible time in UTC. This happens when switching from daylight savings time - # to normal time where the clocks are rolled back. Thrown by period_for_local - # and local_to_utc when using an ambiguous time and not specifying any - # means to resolve the ambiguity. - class AmbiguousTime < StandardError - end - - # Thrown to indicate that no TimezonePeriod matching a given time could be found. - class PeriodNotFound < StandardError - end - - # Thrown by Timezone#get if the identifier given is not valid. - class InvalidTimezoneIdentifier < StandardError - end - - # Thrown if an attempt is made to use a timezone created with Timezone.new(nil). - class UnknownTimezone < StandardError - end - - # Timezone is the base class of all timezones. It provides a factory method - # get to access timezones by identifier. Once a specific Timezone has been - # retrieved, DateTimes, Times and timestamps can be converted between the UTC - # and the local time for the zone. For example: - # - # tz = TZInfo::Timezone.get('America/New_York') - # puts tz.utc_to_local(DateTime.new(2005,8,29,15,35,0)).to_s - # puts tz.local_to_utc(Time.utc(2005,8,29,11,35,0)).to_s - # puts tz.utc_to_local(1125315300).to_s - # - # Each time conversion method returns an object of the same type it was - # passed. - # - # The timezone information all comes from the tz database - # (see http://www.twinsun.com/tz/tz-link.htm) - class Timezone - include Comparable - - # Cache of loaded zones by identifier to avoid using require if a zone - # has already been loaded. - @@loaded_zones = {} - - # Whether the timezones index has been loaded yet. - @@index_loaded = false - - # Returns a timezone by its identifier (e.g. "Europe/London", - # "America/Chicago" or "UTC"). - # - # Raises InvalidTimezoneIdentifier if the timezone couldn't be found. - def self.get(identifier) - instance = @@loaded_zones[identifier] - unless instance - raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier !~ /^[A-z0-9\+\-_]+(\/[A-z0-9\+\-_]+)*$/ - identifier = identifier.gsub(/-/, '__m__').gsub(/\+/, '__p__') - begin - # Use a temporary variable to avoid an rdoc warning - file = "tzinfo/definitions/#{identifier}" - require file - - m = Definitions - identifier.split(/\//).each {|part| - m = m.const_get(part) - } - - info = m.get - - # Could make Timezone subclasses register an interest in an info - # type. Since there are currently only two however, there isn't - # much point. - if info.kind_of?(DataTimezoneInfo) - instance = DataTimezone.new(info) - elsif info.kind_of?(LinkedTimezoneInfo) - instance = LinkedTimezone.new(info) - else - raise InvalidTimezoneIdentifier, "No handler for info type #{info.class}" - end - - @@loaded_zones[instance.identifier] = instance - rescue LoadError, NameError => e - raise InvalidTimezoneIdentifier, e.message - end - end - - instance - end - - # Returns a proxy for the Timezone with the given identifier. The proxy - # will cause the real timezone to be loaded when an attempt is made to - # find a period or convert a time. get_proxy will not validate the - # identifier. If an invalid identifier is specified, no exception will be - # raised until the proxy is used. - def self.get_proxy(identifier) - TimezoneProxy.new(identifier) - end - - # If identifier is nil calls super(), otherwise calls get. An identfier - # should always be passed in when called externally. - def self.new(identifier = nil) - if identifier - get(identifier) - else - super() - end - end - - # Returns an array containing all the available Timezones. - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all - get_proxies(all_identifiers) - end - - # Returns an array containing the identifiers of all the available - # Timezones. - def self.all_identifiers - load_index - Indexes::Timezones.timezones - end - - # Returns an array containing all the available Timezones that are based - # on data (are not links to other Timezones). - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all_data_zones - get_proxies(all_data_zone_identifiers) - end - - # Returns an array containing the identifiers of all the available - # Timezones that are based on data (are not links to other Timezones).. - def self.all_data_zone_identifiers - load_index - Indexes::Timezones.data_timezones - end - - # Returns an array containing all the available Timezones that are links - # to other Timezones. - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all_linked_zones - get_proxies(all_linked_zone_identifiers) - end - - # Returns an array containing the identifiers of all the available - # Timezones that are links to other Timezones. - def self.all_linked_zone_identifiers - load_index - Indexes::Timezones.linked_timezones - end - - # Returns all the Timezones defined for all Countries. This is not the - # complete set of Timezones as some are not country specific (e.g. - # 'Etc/GMT'). - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all_country_zones - Country.all_codes.inject([]) {|zones,country| - zones += Country.get(country).zones - } - end - - # Returns all the zone identifiers defined for all Countries. This is not the - # complete set of zone identifiers as some are not country specific (e.g. - # 'Etc/GMT'). You can obtain a Timezone instance for a given identifier - # with the get method. - def self.all_country_zone_identifiers - Country.all_codes.inject([]) {|zones,country| - zones += Country.get(country).zone_identifiers - } - end - - # Returns all US Timezone instances. A shortcut for - # TZInfo::Country.get('US').zones. - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.us_zones - Country.get('US').zones - end - - # Returns all US zone identifiers. A shortcut for - # TZInfo::Country.get('US').zone_identifiers. - def self.us_zone_identifiers - Country.get('US').zone_identifiers - end - - # The identifier of the timezone, e.g. "Europe/Paris". - def identifier - raise UnknownTimezone, 'TZInfo::Timezone constructed directly' - end - - # An alias for identifier. - def name - # Don't use alias, as identifier gets overridden. - identifier - end - - # Returns a friendlier version of the identifier. - def to_s - friendly_identifier - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #{identifier}>" - end - - # Returns a friendlier version of the identifier. Set skip_first_part to - # omit the first part of the identifier (typically a region name) where - # there is more than one part. - # - # For example: - # - # Timezone.get('Europe/Paris').friendly_identifier(false) #=> "Europe - Paris" - # Timezone.get('Europe/Paris').friendly_identifier(true) #=> "Paris" - # Timezone.get('America/Indiana/Knox').friendly_identifier(false) #=> "America - Knox, Indiana" - # Timezone.get('America/Indiana/Knox').friendly_identifier(true) #=> "Knox, Indiana" - def friendly_identifier(skip_first_part = false) - parts = identifier.split('/') - if parts.empty? - # shouldn't happen - identifier - elsif parts.length == 1 - parts[0] - else - if skip_first_part - result = '' - else - result = parts[0] + ' - ' - end - - parts[1, parts.length - 1].reverse_each {|part| - part.gsub!(/_/, ' ') - - if part.index(/[a-z]/) - # Missing a space if a lower case followed by an upper case and the - # name isn't McXxxx. - part.gsub!(/([^M][a-z])([A-Z])/, '\1 \2') - part.gsub!(/([M][a-bd-z])([A-Z])/, '\1 \2') - - # Missing an apostrophe if two consecutive upper case characters. - part.gsub!(/([A-Z])([A-Z])/, '\1\'\2') - end - - result << part - result << ', ' - } - - result.slice!(result.length - 2, 2) - result - end - end - - # Returns the TimezonePeriod for the given UTC time. utc can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in utc is ignored (it is treated as a UTC time). - def period_for_utc(utc) - raise UnknownTimezone, 'TZInfo::Timezone constructed directly' - end - - # Returns the set of TimezonePeriod instances that are valid for the given - # local time as an array. If you just want a single period, use - # period_for_local instead and specify how ambiguities should be resolved. - # Returns an empty array if no periods are found for the given time. - def periods_for_local(local) - raise UnknownTimezone, 'TZInfo::Timezone constructed directly' - end - - # Returns the TimezonePeriod for the given local time. local can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in local is ignored (it is treated as a time in the current - # timezone). - # - # Warning: There are local times that have no equivalent UTC times (e.g. - # in the transition from standard time to daylight savings time). There are - # also local times that have more than one UTC equivalent (e.g. in the - # transition from daylight savings time to standard time). - # - # In the first case (no equivalent UTC time), a PeriodNotFound exception - # will be raised. - # - # In the second case (more than one equivalent UTC time), an AmbiguousTime - # exception will be raised unless the optional dst parameter or block - # handles the ambiguity. - # - # If the ambiguity is due to a transition from daylight savings time to - # standard time, the dst parameter can be used to select whether the - # daylight savings time or local time is used. For example, - # - # Timezone.get('America/New_York').period_for_local(DateTime.new(2004,10,31,1,30,0)) - # - # would raise an AmbiguousTime exception. - # - # Specifying dst=true would the daylight savings period from April to - # October 2004. Specifying dst=false would return the standard period - # from October 2004 to April 2005. - # - # If the dst parameter does not resolve the ambiguity, and a block is - # specified, it is called. The block must take a single parameter - an - # array of the periods that need to be resolved. The block can select and - # return a single period or return nil or an empty array - # to cause an AmbiguousTime exception to be raised. - def period_for_local(local, dst = nil) - results = periods_for_local(local) - - if results.empty? - raise PeriodNotFound - elsif results.size < 2 - results.first - else - # ambiguous result try to resolve - - if !dst.nil? - matches = results.find_all {|period| period.dst? == dst} - results = matches if !matches.empty? - end - - if results.size < 2 - results.first - else - # still ambiguous, try the block - - if block_given? - results = yield results - end - - if results.is_a?(TimezonePeriod) - results - elsif results && results.size == 1 - results.first - else - raise AmbiguousTime, "#{local} is an ambiguous local time." - end - end - end - end - - # Converts a time in UTC to the local timezone. utc can either be - # a DateTime, Time or timestamp (Time.to_i). The returned time has the same - # type as utc. Any timezone information in utc is ignored (it is treated as - # a UTC time). - def utc_to_local(utc) - TimeOrDateTime.wrap(utc) {|wrapped| - period_for_utc(wrapped).to_local(wrapped) - } - end - - # Converts a time in the local timezone to UTC. local can either be - # a DateTime, Time or timestamp (Time.to_i). The returned time has the same - # type as local. Any timezone information in local is ignored (it is treated - # as a local time). - # - # Warning: There are local times that have no equivalent UTC times (e.g. - # in the transition from standard time to daylight savings time). There are - # also local times that have more than one UTC equivalent (e.g. in the - # transition from daylight savings time to standard time). - # - # In the first case (no equivalent UTC time), a PeriodNotFound exception - # will be raised. - # - # In the second case (more than one equivalent UTC time), an AmbiguousTime - # exception will be raised unless the optional dst parameter or block - # handles the ambiguity. - # - # If the ambiguity is due to a transition from daylight savings time to - # standard time, the dst parameter can be used to select whether the - # daylight savings time or local time is used. For example, - # - # Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,10,31,1,30,0)) - # - # would raise an AmbiguousTime exception. - # - # Specifying dst=true would return 2004-10-31 5:30:00. Specifying dst=false - # would return 2004-10-31 6:30:00. - # - # If the dst parameter does not resolve the ambiguity, and a block is - # specified, it is called. The block must take a single parameter - an - # array of the periods that need to be resolved. The block can return a - # single period to use to convert the time or return nil or an empty array - # to cause an AmbiguousTime exception to be raised. - def local_to_utc(local, dst = nil) - TimeOrDateTime.wrap(local) {|wrapped| - if block_given? - period = period_for_local(wrapped, dst) {|periods| yield periods } - else - period = period_for_local(wrapped, dst) - end - - period.to_utc(wrapped) - } - end - - # Returns the current time in the timezone as a Time. - def now - utc_to_local(Time.now.utc) - end - - # Returns the TimezonePeriod for the current time. - def current_period - period_for_utc(Time.now.utc) - end - - # Returns the current Time and TimezonePeriod as an array. The first element - # is the time, the second element is the period. - def current_period_and_time - utc = Time.now.utc - period = period_for_utc(utc) - [period.to_local(utc), period] - end - - alias :current_time_and_period :current_period_and_time - - # Converts a time in UTC to local time and returns it as a string - # according to the given format. The formatting is identical to - # Time.strftime and DateTime.strftime, except %Z is replaced with the - # timezone abbreviation for the specified time (for example, EST or EDT). - def strftime(format, utc = Time.now.utc) - period = period_for_utc(utc) - local = period.to_local(utc) - local = Time.at(local).utc unless local.kind_of?(Time) || local.kind_of?(DateTime) - abbreviation = period.abbreviation.to_s.gsub(/%/, '%%') - - format = format.gsub(/(.?)%Z/) do - if $1 == '%' - # return %%Z so the real strftime treats it as a literal %Z too - '%%Z' - else - "#$1#{abbreviation}" - end - end - - local.strftime(format) - end - - # Compares two Timezones based on their identifier. Returns -1 if tz is less - # than self, 0 if tz is equal to self and +1 if tz is greater than self. - def <=>(tz) - identifier <=> tz.identifier - end - - # Returns true if and only if the identifier of tz is equal to the - # identifier of this Timezone. - def eql?(tz) - self == tz - end - - # Returns a hash of this Timezone. - def hash - identifier.hash - end - - # Dumps this Timezone for marshalling. - def _dump(limit) - identifier - end - - # Loads a marshalled Timezone. - def self._load(data) - Timezone.get(data) - end - - private - # Loads in the index of timezones if it hasn't already been loaded. - def self.load_index - unless @@index_loaded - require 'tzinfo/indexes/timezones' - @@index_loaded = true - end - end - - # Returns an array of proxies corresponding to the given array of - # identifiers. - def self.get_proxies(identifiers) - identifiers.collect {|identifier| get_proxy(identifier)} - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb deleted file mode 100644 index 39ca8bfa..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +++ /dev/null @@ -1,56 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/data_timezone_info' -require 'tzinfo/linked_timezone_info' - -module TZInfo - - # TimezoneDefinition is included into Timezone definition modules. - # TimezoneDefinition provides the methods for defining timezones. - module TimezoneDefinition #:nodoc: - # Add class methods to the includee. - def self.append_features(base) - super - base.extend(ClassMethods) - end - - # Class methods for inclusion. - module ClassMethods #:nodoc: - # Returns and yields a DataTimezoneInfo object to define a timezone. - def timezone(identifier) - yield @timezone = DataTimezoneInfo.new(identifier) - end - - # Defines a linked timezone. - def linked_timezone(identifier, link_to_identifier) - @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier) - end - - # Returns the last TimezoneInfo to be defined with timezone or - # linked_timezone. - def get - @timezone - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb deleted file mode 100644 index 68e38c35..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +++ /dev/null @@ -1,40 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -module TZInfo - # Represents a timezone defined in a data module. - class TimezoneInfo #:nodoc: - - # The timezone identifier. - attr_reader :identifier - - # Constructs a new TimezoneInfo with an identifier. - def initialize(identifier) - @identifier = identifier - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #@identifier>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb deleted file mode 100644 index 6a0bbca4..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +++ /dev/null @@ -1,94 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -module TZInfo - # Represents an offset defined in a Timezone data file. - class TimezoneOffsetInfo #:nodoc: - # The base offset of the timezone from UTC in seconds. - attr_reader :utc_offset - - # The offset from standard time for the zone in seconds (i.e. non-zero if - # daylight savings is being observed). - attr_reader :std_offset - - # The total offset of this observance from UTC in seconds - # (utc_offset + std_offset). - attr_reader :utc_total_offset - - # The abbreviation that identifies this observance, e.g. "GMT" - # (Greenwich Mean Time) or "BST" (British Summer Time) for "Europe/London". The returned identifier is a - # symbol. - attr_reader :abbreviation - - # Constructs a new TimezoneOffsetInfo. utc_offset and std_offset are - # specified in seconds. - def initialize(utc_offset, std_offset, abbreviation) - @utc_offset = utc_offset - @std_offset = std_offset - @abbreviation = abbreviation - - @utc_total_offset = @utc_offset + @std_offset - end - - # True if std_offset is non-zero. - def dst? - @std_offset != 0 - end - - # Converts a UTC DateTime to local time based on the offset of this period. - def to_local(utc) - TimeOrDateTime.wrap(utc) {|wrapped| - wrapped + @utc_total_offset - } - end - - # Converts a local DateTime to UTC based on the offset of this period. - def to_utc(local) - TimeOrDateTime.wrap(local) {|wrapped| - wrapped - @utc_total_offset - } - end - - # Returns true if and only if toi has the same utc_offset, std_offset - # and abbreviation as this TimezoneOffsetInfo. - def ==(toi) - toi.respond_to?(:utc_offset) && toi.respond_to?(:std_offset) && toi.respond_to?(:abbreviation) && - utc_offset == toi.utc_offset && std_offset == toi.std_offset && abbreviation == toi.abbreviation - end - - # Returns true if and only if toi has the same utc_offset, std_offset - # and abbreviation as this TimezoneOffsetInfo. - def eql?(toi) - self == toi - end - - # Returns a hash of this TimezoneOffsetInfo. - def hash - utc_offset.hash ^ std_offset.hash ^ abbreviation.hash - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #@utc_offset,#@std_offset,#@abbreviation>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb deleted file mode 100644 index 00888fcf..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +++ /dev/null @@ -1,198 +0,0 @@ -#-- -# Copyright (c) 2005-2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/offset_rationals' -require 'tzinfo/time_or_datetime' - -module TZInfo - # A period of time in a timezone where the same offset from UTC applies. - # - # All the methods that take times accept instances of Time, DateTime or - # integer timestamps. - class TimezonePeriod - # The TimezoneTransitionInfo that defines the start of this TimezonePeriod - # (may be nil if unbounded). - attr_reader :start_transition - - # The TimezoneTransitionInfo that defines the end of this TimezonePeriod - # (may be nil if unbounded). - attr_reader :end_transition - - # The TimezoneOffsetInfo for this period. - attr_reader :offset - - # Initializes a new TimezonePeriod. - def initialize(start_transition, end_transition, offset = nil) - @start_transition = start_transition - @end_transition = end_transition - - if offset - raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition - @offset = offset - else - if @start_transition - @offset = @start_transition.offset - elsif @end_transition - @offset = @end_transition.previous_offset - else - raise ArgumentError, 'No offset specified and no transitions to determine it from' - end - end - - @utc_total_offset_rational = nil - end - - # Base offset of the timezone from UTC (seconds). - def utc_offset - @offset.utc_offset - end - - # Offset from the local time where daylight savings is in effect (seconds). - # E.g.: utc_offset could be -5 hours. Normally, std_offset would be 0. - # During daylight savings, std_offset would typically become +1 hours. - def std_offset - @offset.std_offset - end - - # The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST" - # (British Summer Time) for "Europe/London". The returned identifier is a - # symbol. - def abbreviation - @offset.abbreviation - end - alias :zone_identifier :abbreviation - - # Total offset from UTC (seconds). Equal to utc_offset + std_offset. - def utc_total_offset - @offset.utc_total_offset - end - - # Total offset from UTC (days). Result is a Rational. - def utc_total_offset_rational - unless @utc_total_offset_rational - @utc_total_offset_rational = OffsetRationals.rational_for_offset(utc_total_offset) - end - @utc_total_offset_rational - end - - # The start time of the period in UTC as a DateTime. May be nil if unbounded. - def utc_start - @start_transition ? @start_transition.at.to_datetime : nil - end - - # The end time of the period in UTC as a DateTime. May be nil if unbounded. - def utc_end - @end_transition ? @end_transition.at.to_datetime : nil - end - - # The start time of the period in local time as a DateTime. May be nil if - # unbounded. - def local_start - @start_transition ? @start_transition.local_start.to_datetime : nil - end - - # The end time of the period in local time as a DateTime. May be nil if - # unbounded. - def local_end - @end_transition ? @end_transition.local_end.to_datetime : nil - end - - # true if daylight savings is in effect for this period; otherwise false. - def dst? - @offset.dst? - end - - # true if this period is valid for the given UTC DateTime; otherwise false. - def valid_for_utc?(utc) - utc_after_start?(utc) && utc_before_end?(utc) - end - - # true if the given UTC DateTime is after the start of the period - # (inclusive); otherwise false. - def utc_after_start?(utc) - !@start_transition || @start_transition.at <= utc - end - - # true if the given UTC DateTime is before the end of the period - # (exclusive); otherwise false. - def utc_before_end?(utc) - !@end_transition || @end_transition.at > utc - end - - # true if this period is valid for the given local DateTime; otherwise false. - def valid_for_local?(local) - local_after_start?(local) && local_before_end?(local) - end - - # true if the given local DateTime is after the start of the period - # (inclusive); otherwise false. - def local_after_start?(local) - !@start_transition || @start_transition.local_start <= local - end - - # true if the given local DateTime is before the end of the period - # (exclusive); otherwise false. - def local_before_end?(local) - !@end_transition || @end_transition.local_end > local - end - - # Converts a UTC DateTime to local time based on the offset of this period. - def to_local(utc) - @offset.to_local(utc) - end - - # Converts a local DateTime to UTC based on the offset of this period. - def to_utc(local) - @offset.to_utc(local) - end - - # Returns true if this TimezonePeriod is equal to p. This compares the - # start_transition, end_transition and offset using ==. - def ==(p) - p.respond_to?(:start_transition) && p.respond_to?(:end_transition) && - p.respond_to?(:offset) && start_transition == p.start_transition && - end_transition == p.end_transition && offset == p.offset - end - - # Returns true if this TimezonePeriods is equal to p. This compares the - # start_transition, end_transition and offset using eql? - def eql?(p) - p.respond_to?(:start_transition) && p.respond_to?(:end_transition) && - p.respond_to?(:offset) && start_transition.eql?(p.start_transition) && - end_transition.eql?(p.end_transition) && offset.eql?(p.offset) - end - - # Returns a hash of this TimezonePeriod. - def hash - result = @start_transition.hash ^ @end_transition.hash - result ^= @offset.hash unless @start_transition || @end_transition - result - end - - # Returns internal object state as a programmer-readable string. - def inspect - result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}" - result << ",#{@offset.inspect}>" unless @start_transition || @end_transition - result + '>' - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb deleted file mode 100644 index 6b0669cc..00000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +++ /dev/null @@ -1,129 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -require 'tzinfo/time_or_datetime' - -module TZInfo - # Represents an offset defined in a Timezone data file. - class TimezoneTransitionInfo #:nodoc: - # The offset this transition changes to (a TimezoneOffsetInfo instance). - attr_reader :offset - - # The offset this transition changes from (a TimezoneOffsetInfo instance). - attr_reader :previous_offset - - # The numerator of the DateTime if the transition time is defined as a - # DateTime, otherwise the transition time as a timestamp. - attr_reader :numerator_or_time - protected :numerator_or_time - - # Either the denominotor of the DateTime if the transition time is defined - # as a DateTime, otherwise nil. - attr_reader :denominator - protected :denominator - - # Creates a new TimezoneTransitionInfo with the given offset, - # previous_offset (both TimezoneOffsetInfo instances) and UTC time. - # if denominator is nil, numerator_or_time is treated as a number of - # seconds since the epoch. If denominator is specified numerator_or_time - # and denominator are used to create a DateTime as follows: - # - # DateTime.new!(Rational.send(:new!, numerator_or_time, denominator), 0, Date::ITALY) - # - # For performance reasons, the numerator and denominator must be specified - # in their lowest form. - def initialize(offset, previous_offset, numerator_or_time, denominator = nil) - @offset = offset - @previous_offset = previous_offset - @numerator_or_time = numerator_or_time - @denominator = denominator - - @at = nil - @local_end = nil - @local_start = nil - end - - # A TimeOrDateTime instance representing the UTC time when this transition - # occurs. - def at - unless @at - unless @denominator - @at = TimeOrDateTime.new(@numerator_or_time) - else - r = RubyCoreSupport.rational_new!(@numerator_or_time, @denominator) - dt = RubyCoreSupport.datetime_new!(r, 0, Date::ITALY) - @at = TimeOrDateTime.new(dt) - end - end - - @at - end - - # A TimeOrDateTime instance representing the local time when this transition - # causes the previous observance to end (calculated from at using - # previous_offset). - def local_end - @local_end = at.add_with_convert(@previous_offset.utc_total_offset) unless @local_end - @local_end - end - - # A TimeOrDateTime instance representing the local time when this transition - # causes the next observance to start (calculated from at using offset). - def local_start - @local_start = at.add_with_convert(@offset.utc_total_offset) unless @local_start - @local_start - end - - # Returns true if this TimezoneTransitionInfo is equal to the given - # TimezoneTransitionInfo. Two TimezoneTransitionInfo instances are - # considered to be equal by == if offset, previous_offset and at are all - # equal. - def ==(tti) - tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && tti.respond_to?(:at) && - offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at - end - - # Returns true if this TimezoneTransitionInfo is equal to the given - # TimezoneTransitionInfo. Two TimezoneTransitionInfo instances are - # considered to be equal by eql? if offset, previous_offset, - # numerator_or_time and denominator are all equal. This is stronger than ==, - # which just requires the at times to be equal regardless of how they were - # originally specified. - def eql?(tti) - tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && - tti.respond_to?(:numerator_or_time) && tti.respond_to?(:denominator) && - offset == tti.offset && previous_offset == tti.previous_offset && - numerator_or_time == tti.numerator_or_time && denominator == tti.denominator - end - - # Returns a hash of this TimezoneTransitionInfo instance. - def hash - @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #{at.inspect},#{@offset.inspect}>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/version.rb b/vendor/rails/activesupport/lib/active_support/version.rb deleted file mode 100644 index 0fbeaa67..00000000 --- a/vendor/rails/activesupport/lib/active_support/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveSupport - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 14 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/activesupport/lib/active_support/whiny_nil.rb b/vendor/rails/activesupport/lib/active_support/whiny_nil.rb deleted file mode 100644 index c4aaba7a..00000000 --- a/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +++ /dev/null @@ -1,64 +0,0 @@ -# Extensions to +nil+ which allow for more helpful error messages for people who -# are new to Rails. -# -# Ruby raises NoMethodError if you invoke a method on an object that does not -# respond to it: -# -# $ ruby -e nil.destroy -# -e:1: undefined method `destroy' for nil:NilClass (NoMethodError) -# -# With these extensions, if the method belongs to the public interface of the -# classes in NilClass::WHINERS the error message suggests which could be the -# actual intended class: -# -# $ script/runner nil.destroy -# ... -# You might have expected an instance of ActiveRecord::Base. -# ... -# -# NilClass#id exists in Ruby 1.8 (though it is deprecated). Since +id+ is a fundamental -# method of Active Record models NilClass#id is redefined as well to raise a RuntimeError -# and warn the user. She probably wanted a model database identifier and the 4 -# returned by the original method could result in obscure bugs. -# -# The flag <tt>config.whiny_nils</tt> determines whether this feature is enabled. -# By default it is on in development and test modes, and it is off in production -# mode. -class NilClass - WHINERS = [::Array] - WHINERS << ::ActiveRecord::Base if defined? ::ActiveRecord - - METHOD_CLASS_MAP = Hash.new - - WHINERS.each do |klass| - methods = klass.public_instance_methods - public_instance_methods - class_name = klass.name - methods.each { |method| METHOD_CLASS_MAP[method.to_sym] = class_name } - end - - # Raises a RuntimeError when you attempt to call +id+ on +nil+. - def id - raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller - end - - private - def method_missing(method, *args, &block) - # Ruby 1.9.2: disallow explicit coercion via method_missing. - if method == :to_ary || method == :to_str - super - elsif klass = METHOD_CLASS_MAP[method] - raise_nil_warning_for klass, method, caller - else - super - end - end - - # Raises a NoMethodError when you attempt to call a method on +nil+. - def raise_nil_warning_for(class_name = nil, selector = nil, with_caller = nil) - message = "You have a nil object when you didn't expect it!" - message << "\nYou might have expected an instance of #{class_name}." if class_name - message << "\nThe error occurred while evaluating nil.#{selector}" if selector - - raise NoMethodError, message, with_caller || caller - end -end diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini.rb b/vendor/rails/activesupport/lib/active_support/xml_mini.rb deleted file mode 100644 index ccd13494..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini.rb +++ /dev/null @@ -1,31 +0,0 @@ -module ActiveSupport - # = XmlMini - # - # To use the much faster libxml parser: - # gem 'libxml-ruby', '=0.9.7' - # XmlMini.backend = 'LibXML' - module XmlMini - extend self - - attr_reader :backend - delegate :parse, :to => :backend - - def backend=(name) - if name.is_a?(Module) - @backend = name - else - require "active_support/xml_mini/#{name.to_s.downcase}.rb" - @backend = ActiveSupport.const_get("XmlMini_#{name}") - end - end - - def with_backend(name) - old_backend, self.backend = backend, name - yield - ensure - self.backend = old_backend - end - end - - XmlMini.backend = 'REXML' -end diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb deleted file mode 100644 index d795d556..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb +++ /dev/null @@ -1,162 +0,0 @@ -raise "JRuby is required to use the JDOM backend for XmlMini" unless RUBY_PLATFORM =~ /java/ - -require 'jruby' -include Java - -import javax.xml.parsers.DocumentBuilder unless defined? DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory unless defined? DocumentBuilderFactory -import java.io.StringReader unless defined? StringReader -import org.xml.sax.InputSource unless defined? InputSource -import org.xml.sax.Attributes unless defined? Attributes -import org.w3c.dom.Node unless defined? Node - -# = XmlMini JRuby JDOM implementation -module ActiveSupport - module XmlMini_JDOM #:nodoc: - extend self - - CONTENT_KEY = '__content__'.freeze - - NODE_TYPE_NAMES = %w{ATTRIBUTE_NODE CDATA_SECTION_NODE COMMENT_NODE DOCUMENT_FRAGMENT_NODE - DOCUMENT_NODE DOCUMENT_TYPE_NODE ELEMENT_NODE ENTITY_NODE ENTITY_REFERENCE_NODE NOTATION_NODE - PROCESSING_INSTRUCTION_NODE TEXT_NODE} - - node_type_map = {} - NODE_TYPE_NAMES.each { |type| node_type_map[Node.send(type)] = type } - - # Parse an XML Document string into a simple hash using Java's jdom. - # string:: - # XML Document string to parse - def parse(string) - if string.blank? - {} - else - @dbf = DocumentBuilderFactory.new_instance - xml_string_reader = StringReader.new(string) - xml_input_source = InputSource.new(xml_string_reader) - doc = @dbf.new_document_builder.parse(xml_input_source) - merge_element!({}, doc.document_element) - end - end - - private - - # Convert an XML element and merge into the hash - # - # hash:: - # Hash to merge the converted element into. - # element:: - # XML element to merge into hash - def merge_element!(hash, element) - merge!(hash, element.tag_name, collapse(element)) - end - - # Actually converts an XML document element into a data structure. - # - # element:: - # The document element to be collapsed. - def collapse(element) - hash = get_attributes(element) - - child_nodes = element.child_nodes - if child_nodes.length > 0 - for i in 0...child_nodes.length - child = child_nodes.item(i) - merge_element!(hash, child) unless child.node_type == Node.TEXT_NODE - end - merge_texts!(hash, element) unless empty_content?(element) - hash - else - merge_texts!(hash, element) - end - end - - # Merge all the texts of an element into the hash - # - # hash:: - # Hash to add the converted emement to. - # element:: - # XML element whose texts are to me merged into the hash - def merge_texts!(hash, element) - text_children = texts(element) - if text_children.join.empty? - hash - else - # must use value to prevent double-escaping - merge!(hash, CONTENT_KEY, text_children.join) - end - end - - # Adds a new key/value pair to an existing Hash. If the key to be added - # already exists and the existing value associated with key is not - # an Array, it will be wrapped in an Array. Then the new value is - # appended to that Array. - # - # hash:: - # Hash to add key/value pair to. - # key:: - # Key to be added. - # value:: - # Value to be associated with key. - def merge!(hash, key, value) - if hash.has_key?(key) - if hash[key].instance_of?(Array) - hash[key] << value - else - hash[key] = [hash[key], value] - end - elsif value.instance_of?(Array) - hash[key] = [value] - else - hash[key] = value - end - hash - end - - # Converts the attributes array of an XML element into a hash. - # Returns an empty Hash if node has no attributes. - # - # element:: - # XML element to extract attributes from. - def get_attributes(element) - attribute_hash = {} - attributes = element.attributes - for i in 0...attributes.length - attribute_hash[attributes.item(i).name] = attributes.item(i).value - end - attribute_hash - end - - # Determines if a document element has text content - # - # element:: - # XML element to be checked. - def texts(element) - texts = [] - child_nodes = element.child_nodes - for i in 0...child_nodes.length - item = child_nodes.item(i) - if item.node_type == Node.TEXT_NODE - texts << item.get_data - end - end - texts - end - - # Determines if a document element has text content - # - # element:: - # XML element to be checked. - def empty_content?(element) - text = '' - child_nodes = element.child_nodes - for i in 0...child_nodes.length - item = child_nodes.item(i) - if item.node_type == Node.TEXT_NODE - text << item.get_data.strip - end - end - text.strip.length == 0 - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/libxml.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/libxml.rb deleted file mode 100644 index 837a1df6..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/libxml.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'libxml' - -# = XmlMini LibXML implementation -module ActiveSupport - module XmlMini_LibXML #:nodoc: - extend self - - # Parse an XML Document string into a simple hash using libxml. - # string:: - # XML Document string to parse - def parse(string) - if string.blank? - {} - else - LibXML::XML::Parser.string(string.strip).parse.to_hash - end - end - end -end - -module LibXML - module Conversions - module Document - def to_hash - root.to_hash - end - end - - module Node - CONTENT_ROOT = '__content__'.freeze - - # Convert XML document to hash - # - # hash:: - # Hash to merge the converted element into. - def to_hash(hash={}) - node_hash = {} - - # Insert node hash into parent hash correctly. - case hash[name] - when Array then hash[name] << node_hash - when Hash then hash[name] = [hash[name], node_hash] - when nil then hash[name] = node_hash - else raise "Unexpected error during hash insertion!" - end - - # Handle child elements - each_child do |c| - if c.element? - c.to_hash(node_hash) - elsif c.text? || c.cdata? - node_hash[CONTENT_ROOT] ||= '' - node_hash[CONTENT_ROOT] << c.content - end - end - - - # Remove content node if it is blank - if node_hash.length > 1 && node_hash[CONTENT_ROOT].blank? - node_hash.delete(CONTENT_ROOT) - end - - # Handle attributes - each_attr { |a| node_hash[a.name] = a.value } - - hash - end - end - end -end - -LibXML::XML::Document.send(:include, LibXML::Conversions::Document) -LibXML::XML::Node.send(:include, LibXML::Conversions::Node) diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/libxmlsax.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/libxmlsax.rb deleted file mode 100644 index a88607d8..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/libxmlsax.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'libxml' - -# = XmlMini LibXML implementation using a SAX-based parser -module ActiveSupport - module XmlMini_LibXMLSAX - extend self - - # Class that will build the hash while the XML document - # is being parsed using SAX events. - class HashBuilder - - include LibXML::XML::SaxParser::Callbacks - - CONTENT_KEY = '__content__'.freeze - HASH_SIZE_KEY = '__hash_size__'.freeze - - attr_reader :hash - - def current_hash - @hash_stack.last - end - - def on_start_document - @hash = { CONTENT_KEY => '' } - @hash_stack = [@hash] - end - - def on_end_document - @hash = @hash_stack.pop - @hash.delete(CONTENT_KEY) - end - - def on_start_element(name, attrs = {}) - new_hash = { CONTENT_KEY => '' }.merge(attrs) - new_hash[HASH_SIZE_KEY] = new_hash.size + 1 - - case current_hash[name] - when Array then current_hash[name] << new_hash - when Hash then current_hash[name] = [current_hash[name], new_hash] - when nil then current_hash[name] = new_hash - end - - @hash_stack.push(new_hash) - end - - def on_end_element(name) - if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] == '' - current_hash.delete(CONTENT_KEY) - end - @hash_stack.pop - end - - def on_characters(string) - current_hash[CONTENT_KEY] << string - end - - alias_method :on_cdata_block, :on_characters - end - - attr_accessor :document_class - self.document_class = HashBuilder - - def parse(string) - return {} if string.blank? - LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER) - parser = LibXML::XML::SaxParser.string(string) - document = self.document_class.new - - parser.callbacks = document - parser.parse - document.hash - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb deleted file mode 100644 index 096ae0f4..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'nokogiri' - -# = XmlMini Nokogiri implementation -module ActiveSupport - module XmlMini_Nokogiri #:nodoc: - extend self - - # Parse an XML Document string into a simple hash using libxml / nokogiri. - # string:: - # XML Document string to parse - def parse(string) - if string.blank? - {} - else - doc = Nokogiri::XML(string) - raise doc.errors.first if doc.errors.length > 0 - doc.to_hash - end - end - - module Conversions - module Document - def to_hash - root.to_hash - end - end - - module Node - CONTENT_ROOT = '__content__'.freeze - - # Convert XML document to hash - # - # hash:: - # Hash to merge the converted element into. - def to_hash(hash = {}) - node_hash = {} - - # Insert node hash into parent hash correctly. - case hash[name] - when Array then hash[name] << node_hash - when Hash then hash[name] = [hash[name], node_hash] - when nil then hash[name] = node_hash - else raise "Unexpected error during hash insertion!" - end - - # Handle child elements - children.each do |c| - if c.element? - c.to_hash(node_hash) - elsif c.text? || c.cdata? - node_hash[CONTENT_ROOT] ||= '' - node_hash[CONTENT_ROOT] << c.content - end - end - - # Remove content node if it is blank and there are child tags - if node_hash.length > 1 && node_hash[CONTENT_ROOT].blank? - node_hash.delete(CONTENT_ROOT) - end - - # Handle attributes - attribute_nodes.each { |a| node_hash[a.node_name] = a.value } - - hash - end - end - end - - Nokogiri::XML::Document.send(:include, Conversions::Document) - Nokogiri::XML::Node.send(:include, Conversions::Node) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/nokogirisax.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/nokogirisax.rb deleted file mode 100644 index f13c9bf2..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/nokogirisax.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'nokogiri' - -# = XmlMini Nokogiri implementation using a SAX-based parser -module ActiveSupport - module XmlMini_NokogiriSAX - extend self - - # Class that will build the hash while the XML document - # is being parsed using SAX events. - class HashBuilder < Nokogiri::XML::SAX::Document - - CONTENT_KEY = '__content__'.freeze - HASH_SIZE_KEY = '__hash_size__'.freeze - - attr_reader :hash - - def current_hash - @hash_stack.last - end - - def start_document - @hash = {} - @hash_stack = [@hash] - end - - def end_document - raise "Parse stack not empty!" if @hash_stack.size > 1 - end - - def error(error_message) - raise error_message - end - - def start_element(name, attrs = []) - new_hash = { CONTENT_KEY => '' } - new_hash[attrs.shift] = attrs.shift while attrs.length > 0 - new_hash[HASH_SIZE_KEY] = new_hash.size + 1 - - case current_hash[name] - when Array then current_hash[name] << new_hash - when Hash then current_hash[name] = [current_hash[name], new_hash] - when nil then current_hash[name] = new_hash - end - - @hash_stack.push(new_hash) - end - - def end_element(name) - if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] == '' - current_hash.delete(CONTENT_KEY) - end - @hash_stack.pop - end - - def characters(string) - current_hash[CONTENT_KEY] << string - end - - alias_method :cdata_block, :characters - end - - attr_accessor :document_class - self.document_class = HashBuilder - - def parse(string) - return {} if string.blank? - document = self.document_class.new - parser = Nokogiri::XML::SAX::Parser.new(document) - parser.parse(string) - document.hash - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/rexml.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/rexml.rb deleted file mode 100644 index a8fdeca9..00000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/rexml.rb +++ /dev/null @@ -1,108 +0,0 @@ -# = XmlMini ReXML implementation -module ActiveSupport - module XmlMini_REXML #:nodoc: - extend self - - CONTENT_KEY = '__content__'.freeze - - # Parse an XML Document string into a simple hash - # - # Same as XmlSimple::xml_in but doesn't shoot itself in the foot, - # and uses the defaults from ActiveSupport - # - # string:: - # XML Document string to parse - def parse(string) - require 'rexml/document' unless defined?(REXML::Document) - doc = REXML::Document.new(string) - merge_element!({}, doc.root) - end - - private - # Convert an XML element and merge into the hash - # - # hash:: - # Hash to merge the converted element into. - # element:: - # XML element to merge into hash - def merge_element!(hash, element) - merge!(hash, element.name, collapse(element)) - end - - # Actually converts an XML document element into a data structure. - # - # element:: - # The document element to be collapsed. - def collapse(element) - hash = get_attributes(element) - - if element.has_elements? - element.each_element {|child| merge_element!(hash, child) } - merge_texts!(hash, element) unless empty_content?(element) - hash - else - merge_texts!(hash, element) - end - end - - # Merge all the texts of an element into the hash - # - # hash:: - # Hash to add the converted emement to. - # element:: - # XML element whose texts are to me merged into the hash - def merge_texts!(hash, element) - unless element.has_text? - hash - else - # must use value to prevent double-escaping - merge!(hash, CONTENT_KEY, element.texts.sum(&:value)) - end - end - - # Adds a new key/value pair to an existing Hash. If the key to be added - # already exists and the existing value associated with key is not - # an Array, it will be wrapped in an Array. Then the new value is - # appended to that Array. - # - # hash:: - # Hash to add key/value pair to. - # key:: - # Key to be added. - # value:: - # Value to be associated with key. - def merge!(hash, key, value) - if hash.has_key?(key) - if hash[key].instance_of?(Array) - hash[key] << value - else - hash[key] = [hash[key], value] - end - elsif value.instance_of?(Array) - hash[key] = [value] - else - hash[key] = value - end - hash - end - - # Converts the attributes array of an XML element into a hash. - # Returns an empty Hash if node has no attributes. - # - # element:: - # XML element to extract attributes from. - def get_attributes(element) - attributes = {} - element.attributes.each { |n,v| attributes[n] = v } - attributes - end - - # Determines if a document element has text content - # - # element:: - # XML element to be checked. - def empty_content?(element) - element.texts.join.blank? - end - end -end diff --git a/vendor/rails/activesupport/lib/activesupport.rb b/vendor/rails/activesupport/lib/activesupport.rb deleted file mode 100644 index 9cae13f0..00000000 --- a/vendor/rails/activesupport/lib/activesupport.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'active_support' -ActiveSupport::Deprecation.warn 'require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.' diff --git a/vendor/rails/railties/CHANGELOG b/vendor/rails/railties/CHANGELOG deleted file mode 100644 index 2e292142..00000000 --- a/vendor/rails/railties/CHANGELOG +++ /dev/null @@ -1,2193 +0,0 @@ -*2.3.11 (February 9, 2011)* - -*2.3.10 (October 15, 2010)* - -*2.3.9 (September 4, 2010)* - -* Deprecates config.load_(once_)paths in favor of autolaod_(once_)paths. [fxn] - - -*2.3.8 (May 24, 2010)* -*2.3.7 (May 24, 2010)* - -* Version bump. - - -*2.3.6 (May 23, 2010)* - -* Added config/initializers/cookie_verification_secret.rb with an auto-generated secret for using ActionController::Base#cookies.signed [DHH] - -* Fixed that the debugger wouldn't go into IRB mode because of left-over ARGVs [DHH] - - -*2.3.5 (November 25, 2009)* - -* Ruby 1.9 compatibility - - -*2.3.4 (September 4, 2009)* - -* I18n support for plugins. #2325 [Antonio Tapiador, Sven Fuchs] - - -*2.3.3 (July 12 2009) - -* Version bump - - -*2.3.2 [Final] (March 15, 2009)* - -* Allow metal to live in plugins #2045 [Matthew Rudy] - -* Added metal [Josh Peek] - -* Remove script/performance/request in favour of the performance integration tests. [Pratik Naik] - - To continue using script/performance/request, install the request_profiler plugin : - - script/plugin install git://github.com/rails/request_profiler.git - -* Add a rake task to apply a template to an existing application : rake rails:template LOCATION=~/template.rb [Pratik Naik] - -* Add "-m/--template" option to Rails generator to apply a template to the generated application. [Jeremy McAnally] - - This has been extracted from rg - http://github.com/jeremymcanally/rg - - Example: - - # template.rb - - # Install plugins from git or svn - plugin "will-paginate", :git => "git://github.com/mislav/will_paginate.git" - plugin "old-restful-auth", :svn => "http://svn.techno-weenie.net/projects/plugins/restful_authentication/" - - # Add gems to environment.rb - gem "jeremymcanally-context" - gem "bluecloth" - - # Vendor file. Data in a string or... - vendor("borrowed.rb", <<CODE - def helpful_method - do_something_helpful_here - end - CODE - - # ...file data from block return value. - # #initializer creates a new initializer file - initializer("crypto.rb") do - salt = "--#{Time.now}--#{rand}--#{srand(Time.now.to_i)}" - - "SPECIAL_SALT = '#{salt}'" - end - - Usage: - - To use a template, provide a file path or URL: - - 1. Using a local file : - - rails <application name> -m /path/to/my/template.rb - - 2. Or directly from a URL : - - rails <application name> --template=http://gist.github.com/31208.txt - -* Extracted the process scripts (inspector, reaper, spawner) into the plugin irs_process_scripts [David Heinemeier Hansson] - -* Changed Rails.root to return a Pathname object (allows for Rails.root.join('app', 'controllers') => "#{RAILS_ROOT}/app/controllers") #1482 [Damian Janowski/?] - -* Added view path support for engines [David Heinemeier Hansson] - -* Added that config/routes.rb files in engine plugins are automatically loaded (and reloaded when they change in dev mode) [David Heinemeier Hansson] - -* Added app/[models|controllers|helpers] to the load path for plugins that has an app directory (go engines ;)) [David Heinemeier Hansson] - -* Add config.preload_frameworks to load all frameworks at startup. Default to false so Rails autoloads itself as it's used. Turn this on for Passenger and JRuby. Also turned on by config.threadsafe! [Jeremy Kemper] - -* Add a rake task to generate dispatchers : rake rails:generate_dispatchers [Pratik Naik] - -* "rails <app>" will not generate public/dispatch.cgi/fcgi/rb files by default now. Please use "--with-dispatchers" option if you need them. [Yaroslav Markin, Pratik Naik] - -* Added rake rails:update:application_controller to renamed application.rb to application_controller.rb -- included in rake rails:update so upgrading to 2.3 will automatically trigger it #1439 [kastner] - -* Added Rails.backtrace_cleaner as an accessor for the Rails::BacktraceCleaner instance used by the framework to cut down on backtrace noise and config/initializers/backtrace_silencers.rb to add your own (or turn them all off) [David Heinemeier Hansson] - -* Switch from Test::Unit::TestCase to ActiveSupport::TestCase. [Jeremy Kemper] - -* Added config.i18n settings gatherer to config/environment, auto-loading of all locales in config/locales/*.rb,yml, and config/locales/en.yml as a sample locale [David Heinemeier Hansson] - -* BACKWARDS INCOMPATIBLE: Renamed application.rb to application_controller.rb and removed all the special casing that was in place to support the former. You must do this rename in your own application when you upgrade to this version [David Heinemeier Hansson] - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Fixed plugin generator so that generated unit tests would subclass ActiveSupport::TestCase, also introduced a helper script to reduce the needed require statements #1137 [Mathias Meyer] - -* Update Prototype to 1.6.0.3 [sam] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* Fixed that sqlite would report "db/development.sqlite3 already exists" whether true or not on db:create #614 [Antonio Cangiano] - -* Added config.threadsafe! to toggle allow concurrency settings and disable the dependency loader [Josh Peek] - -* Turn cache_classes on by default [Josh Peek] - -* Added configurable eager load paths. Defaults to app/models, app/controllers, and app/helpers [Josh Peek] - -* Introduce simple internationalization support. [Ruby i18n team] - -* Make script/plugin install <plugin> -r <revision> option work with git based plugins. #257. [Tim Pope Jakub Kuźma]. Example: - - script/plugin install git://github.com/mislav/will_paginate.git -r agnostic # Installs 'agnostic' branch - script/plugin install git://github.com/dchelimsky/rspec.git -r 'tag 1.1.4' - -* Added Rails.initialized? flag [Josh Peek] - -* Make rake test:uncommitted work with Git. [Tim Pope] - -* Added Thin support to script/server. #488 [Bob Klosinski] - -* Fix script/about in production mode. #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic] - -* Add the gem load paths before the framework is loaded, so certain gems like RedCloth and BlueCloth can be frozen. - -* Fix discrepancies with loading rails/init.rb from gems. - -* Plugins check for the gem init path (rails/init.rb) before the standard plugin init path (init.rb) [Jacek Becela] - -* Changed all generated tests to use the test/do declaration style [David Heinemeier Hansson] - -* Wrapped Rails.env in StringInquirer so you can do Rails.env.development? [David Heinemeier Hansson] - -* Fixed that RailsInfoController wasn't considering all requests local in development mode (Edgard Castro) [#310 state:resolved] - - -*2.1.0 (May 31st, 2008)* - -* script/dbconsole fires up the command-line database client. #102 [Steve Purcell] - -* Fix bug where plugin init.rb files from frozen gem specs weren't being run. (pjb3) [#122 state:resolved] - -* Made the location of the routes file configurable with config.routes_configuration_file (Scott Fleckenstein) [#88] - -* Rails Edge info returns the latest git commit hash [Francesc Esplugas] - -* Added Rails.public_path to control where HTML and assets are expected to be loaded from (defaults to Rails.root + "/public") #11581 [Nick Sieger] - -* rake time:zones:local finds correct base utc offset for zones in the Southern Hemisphere [Geoff Buesing] - -* Don't require rails/gem_builder during rails initialization, it's only needed for the gems:build task. [Rick Olson] - -* script/performance/profiler compatibility with the ruby-prof >= 0.5.0. Closes #9176. [Jonathan del Strother] - -* Flesh out rake gems:unpack to unpack all gems, and add rake gems:build for native extensions. #11513 [ddollar] - - rake gems:unpack # unpacks all gems - rake gems:unpack GEM=mygem # unpacks only the gem 'mygem' - - rake gems:build # builds all unpacked gems - rake gems:build GEM=mygem # builds only the gem 'mygem' - -* Add config.active_support for future configuration options. Also, add more new Rails 3 config settings to new_rails_defaults.rb [Rick Olson] - -* Add Rails.logger, Rails.root, Rails.env and Rails.cache shortcuts for RAILS_* constants [Pratik Naik] - -* Allow files in plugins to be reloaded like the rest of the application. [Rick Olson] - - Enables or disables plugin reloading. - - config.reload_plugins = true - - You can get around this setting per plugin. - If #reload_plugins? == false (DEFAULT), add this to your plugin's init.rb to make it reloadable: - - Dependencies.load_once_paths.delete lib_path - - If #reload_plugins? == true, add this to your plugin's init.rb to only load it once: - - Dependencies.load_once_paths << lib_path - -* Small tweak to allow plugins to specify gem dependencies. [Rick Olson] - - # OLD open_id_authentication plugin init.rb - require 'yadis' - require 'openid' - ActionController::Base.send :include, OpenIdAuthentication - - # NEW - config.gem "ruby-openid", :lib => "openid", :version => "1.1.4" - config.gem "ruby-yadis", :lib => "yadis", :version => "0.3.4" - - config.after_initialize do - ActionController::Base.send :include, OpenIdAuthentication - end - -* Added config.gem for specifying which gems are required by the application, as well as rake tasks for installing and freezing gems. [Rick Olson] - - Rails::Initializer.run do |config| - config.gem "bj" - config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - config.gem "aws-s3", :lib => "aws/s3" - end - - # List required gems. - rake gems - - # Install all required gems: - rake gems:install - - # Unpack specified gem to vendor/gems/gem_name-x.x.x - rake gems:unpack GEM=bj - -* Removed the default .htaccess configuration as there are so many good deployment options now (kept it as an example in README) [David Heinemeier Hansson] - -* config.time_zone accepts TZInfo::Timezone identifiers as well as Rails TimeZone identifiers [Geoff Buesing] - -* Rails::Initializer#initialize_time_zone raises an error if value assigned to config.time_zone is not recognized. Rake time zone tasks only require ActiveSupport instead of entire environment [Geoff Buesing] - -* Stop adding the antiquated test/mocks/* directories and only add them to the path if they're still there for legacy reasons [David Heinemeier Hansson] - -* Added that gems can now be plugins if they include rails/init.rb #11444 [John Barnette] - -* Added Plugin#about method to programmatically access the about.yml in a plugin #10979 [James Adam] - - plugin = Rails::Plugin.new(path_to_my_plugin) - plugin.about["author"] # => "James Adam" - plugin.about["url"] # => "http://interblah.net" - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Added config.time_zone = 'UTC' in the default environment.rb [Geoff Buesing] - -* Added rake tasks time:zones:all, time:zones:us and time:zones:local for finding time zone names for config.time_zone option [Geoff Buesing] - -* Add config.time_zone for configuring the default Time.zone value. #10982 [Geoff Buesing] - -* Added support for installing plugins hosted at git repositories #11294 [Jack Danger Canty] - -* Fixed that script/generate would not look for plugin generators in plugin_paths #11000 [glv] - -* Fixed database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt] - -* Added a -e/--export to script/plugin install, uses svn export. #10847 [jon@blankpad.net)] - -* Reshuffle load order so that routes and observers are initialized after plugins and app initializers. Closes #10980 [Rick Olson] - -* Git support for script/generate. #10690 [ssoroka] - -* Update scaffold to use labels instead of bold tags. Closes #10757 [zach-inglis-lt3] - -* Resurrect WordNet synonym lookups. #10710 [tom./, matt] - -* Added config.cache_store to environment options to control the default cache store (default is FileStore if tmp/cache is present, otherwise MemoryStore is used) [David Heinemeier Hansson] - -* Added that rails:update is run when you do rails:freeze:edge to ensure you also get the latest JS and config files #10565 [jeff] - -* SQLite: db:drop:all doesn't fail silently if the database is already open. #10577 [Cheah Chu Yeow, mrichman] - -* Introduce native mongrel handler and push mutex into dispatcher. [Jeremy Kemper] - -* Ruby 1.9 compatibility. #1689, #10546 [Cheah Chu Yeow, frederico] - - -*2.0.2* (December 16th, 2007) - -* Changed the default database from mysql to sqlite3, so now running "rails myapp" will have a config/database.yml that's setup for SQLite3 (which in OS X Leopard is installed by default, so is the gem, so everything Just Works with no database configuration at all). To get a Rails application preconfigured for MySQL, just run "rails -d mysql myapp" [David Heinemeier Hansson] - -* Turned on ActionView::Base.cache_template_loading by default in config/environments/production.rb to prevent file system stat calls for every template loading to see if it changed (this means that you have to restart the application to see template changes in production mode) [David Heinemeier Hansson] - -* Introduce `rake secret` to output a crytographically secure secret key for use with cookie sessions #10363 [revans] - -* Fixed that local database creation should consider 127.0.0.1 local #9026 [parcelbrat] - -* Fixed that functional tests generated for scaffolds should use fixture calls instead of hard-coded IDs #10435 [boone] - -* Added db:migrate:redo and db:migrate:reset for rerunning existing migrations #10431, #10432 [matt] - -* RAILS_GEM_VERSION may be double-quoted also. #10443 [James Cox] - -* Update rails:freeze:gems to work with RubyGems 0.9.5. [Jeremy Kemper] - - -*2.0.1* (December 7th, 2007) - -* Fixed Active Record bug - - -*2.0.0* (December 6th, 2007) - -* The test task stops with a warning if you have pending migrations. #10377 [Josh Knowles] - -* Add warning to documentation about using transactional fixtures when the code under test uses transactions itself. Closes #7548 [Thijs van der Vossen] - -* Update Prototype to 1.6.0.1. [sam] - -* Update script.aculo.us to 1.8.0.1. [madrobby] - -* Added db:fixtures:identity as a way of locating what ID a foxy fixture was assigned #10332 [John Barnette] - -* Generated fixtures should not specify ids since theyre expected to be foxy fixtures #10330 [John Barnette] - -* Update to Prototype -r8232. [sam] - -* Introduce SecretKeyGenerator for more secure session secrets than CGI::Session's pseudo-random id generator. Consider extracting to Active Support later. #10286 [Hongli Lai (Phusion)] - -* RAILS_GEM_VERSION may be set to any valid gem version specifier. #10057 [Chad Woolley, Cheah Chu Yeow] - -* Load config/preinitializer.rb, if present, before loading the environment. #9943 [Chad Woolley] - -* FastCGI handler ignores unsupported signals like USR2 on Windows. [Grzegorz Derebecki] - -* Only load ActionMailer::TestCase if ActionMailer is loaded. Closes #10137 [defunkt] - -* Fixed that db:reset would use migrations instead of loading db/schema.rb [David Heinemeier Hansson] - -* Ensure the plugin loader only loads plugins once. Closes #10102 [haruki_zaemon] - -* Refactor Plugin Loader. Add plugin lib paths early, and add lots of tests. Closes #9795 [James Adam] - -* Added --skip-timestamps to generators that produce models #10036 [Tim Pope] - -* Update Prototype to 1.6.0 and script.aculo.us to 1.8.0. [sam, madrobby] - -* Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy] - -* Fix typo in test_helper. Closes #9925 [viktor tron] - -* Request profiler. [Jeremy Kemper] - -* config/boot.rb correctly detects RAILS_GEM_VERSION. #9834 [alexch, thewoolleyman] - -* Fixed incorrect migration number if script/generate executed outside of Rails root #7080 [Jeremy McAnally] - -* Update Prototype to 1.6.0_rc1 and script.aculo.us to 1.8.0 preview 0. [sam, madrobby] - -* Generated fixtures use the actual primary key instead of id. #4343 [Frederick Ros, Tarmo Tänav] - -* Extend the console +helper+ method to allow you to include custom helpers. e.g: - >> helper :posts - >> helper.some_method_from_posts_helper(Post.find(1)) - -* db:create works with remote databases whereas db:create:all only creates -databases on localhost. #9753 [Trevor Wennblom] - -* Removed calls to fixtures in generated tests as fixtures :all is now present by default in test_helper.rb [David Heinemeier Hansson] - -* Add --prefix option to script/server when using mongrel. [dacat] - - -*2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.1.4 - 1.2.3] - -* Fixed that installing plugins from SVN repositories that use trunk/ will work #8188 [evan] - -* Moved the SourceAnnotationExtractor to a separate file in case libraries try to load the rails rake tasks twice. [Rick Olson] - -* Moved Dispatcher to ActionController::Dispatcher. [Jeremy Kemper] - -* Changed the default logger from Ruby's own Logger with the clean_logger extensions to ActiveSupport::BufferedLogger for performance reasons [David Heinemeier Hansson]. (You can change it back with config.logger = Logger.new("/path/to/log", level).) - -* Added a default 422.html page to be rendered when ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, or ActionController::InvalidAuthenticityToken is raised [David Heinemeier Hansson] - -* Added --skip-fixture option to script/generate model #6862 [sandofsky] - -* Print Rails version when starting console #7440 [eyematz] - -* Fixed the placement of fixture files for nested models when generating through script/generate model #7547 [jkit] - -* Added TEMPLATE option to rake doc:app to set a custom output template #7737 [Jakob Skjerning] - -* Added VERBOSE option to rake db:migrate to turn off output #8204 [John Barnette] - -* Fixed that rake doc:app should use UTF-8 #8906 [farzy] - -* Fixes rake annotations to search erb and builder files as well #9150 [m.langenberg] - -* Removed web_service generator [Michael Koziarski] - -* Added the :all option to config.plugins that'll include the rest of the plugins not already explicitly named #9613 [Frederick Cheung]. Example: - - # Loads :classic_pagination before all the other plugins - config.plugins = [ :classic_pagination, :all ] - -* Added symbols as a legal way of specifying plugins in config.plugins #9629 [tom] - -* Removed deprecated task names, like clear_logs, in favor of the new namespaced style [David Heinemeier Hansson] - -* Support multiple config.after_initialize blocks so plugins and apps can more easily cooperate. #9582 [Zach Dennis] - -* Added db:drop:all to drop all databases declared in config/database.yml [David Heinemeier Hansson] - -* Use attribute pairs instead of the migration name to create add and remove column migrations. Closes #9166 [Pratik Naik] - - For example: - - ruby script/generation migration AddSomeStuffToCustomers first_name:string last_name:string - - or - - ruby script/generation migration RemoveSomeStuffFromCustomers first_name:string last_name:string - -* Add ActiveResource to Rails::Info. Closes #8741 [Chris Kampmeier] - -* use Gem.find_name instead of search when freezing gems. Prevent false positives for other gems with rails in the name. Closes #8729 [wselman] - -* Automatically generate add/remove column commands in specially named migrations like AddLocationToEvent. Closes #9006 [Ryan Davis] - -* Default to plural table name in Rails Generator if ActiveRecord is not present. Closes #8963 [evan] - -* Added rake routes for listing all the defined routes in the system. #8795 [Josh Peek] - -* db:create creates the database for the current environment if it's on localhost. db:create:all creates local databases for all environments. #8783 [matt] - -* Generators: look for generators in all gems, not just those suffixed with _generator, in the gem's generators or rails_generators directory. Allow use of the rails_generators directory instead of the standard generators directory in plugins also. #8730 [Dr Nic, topfunky] - -* MySQL, PostgreSQL: database.yml defaults to utf-8. #8701 [matt] - -* Added db:version to get the current schema number [via Err The Blog] - -* Added --skip-migration option to scaffold and resource generators #8656 [Michael Glaesemann] - -* Fix that FCGIs would leave log files open when asked to shut down by USR2. #3028 [Sebastian Kanthak, Josh Peek] - -* Fixed that dispatcher preparation callbacks only run once in production mode. Mock Routes.reload so that dispatcher preparation callback tests run. [Rick Olson] - -* Fix syntax error in dispatcher than wrecked failsafe responses. #8625 [mtitorenko] - -* Scaffolded validation errors set the appropriate HTTP status for XML responses. #6946, #8622 [Manfred Stienstra, mmmultiworks] - -* Sexy migrations for the session_migration generator. #8561 [Vladislav] - -* Console reload! runs to_prepare callbacks also. #8393 [f.svehla] - -* Generated migrations include timestamps by default. #8501 [Shane Vitarana] - -* Drop Action Web Service from rails:freeze:edge. [Jeremy Kemper] - -* Add db:create, drop, reset, charset, and collation tasks. #8448 [matt] - -* Scaffold generator depends on model generator instead of duplicating it. #7222 [bscofield] - -* Scaffold generator tests. #8443 [pelle] - -* Generated scaffold functional tests use assert_difference. #8421 [Norbert Crombach] - -* Update to Prototype 1.5.1. [Sam Stephenson] - -* Update to script.aculo.us 1.7.1_beta3. [Thomas Fuchs] - -* Generators use *.html.erb view template naming. #8278 [Tim Pope] - -* Updated resource_scaffold and model generators to use short-hand style migrations [David Heinemeier Hansson] - -* Updated initializer to only load #{RAILS_ENV}.rb once. Added deprecation warning for config.breakpoint_server. [Nicholas Seckar] - -* Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [David Heinemeier Hansson] - - To use the new debugger, start your server with script/server --debugger and insert a call to 'debugger' - (instead of 'breakpoint') where you want to jump into the debugger. - - BACKWARDS INCOMPATIBILITY NOTE: You must remove the default line 12 from config/environments/development.rb: - - config.breakpoint_server = true - - This configuration option is no longer available. Rails will fail to start in development mode as long as - that's still present. - -* Resource scaffolding returns the created entity.to_xml. [Jeremy Kemper] - -* Resource scaffolding responds to new.xml. #8185 [Eric Mill] - -* Include Active Resource in rails:freeze:edge rake task. [Thomas Fuchs] - -* Include Active Resource instead of Action Web Service [David Heinemeier Hansson] You can add AWS back with this in config/environment.rb: - - config.load_paths += %W( #{RAILS_ROOT}/vendor/rails/actionwebservice/lib ) - - ...or just gem 'actionwebservice' - -* Give generate scaffold a more descriptive database message. Closes #7316 [Jeremy McAnally] - -* Canonicalize RAILS_ROOT by using File.expand_path on Windows, which doesn't have to worry about symlinks, and Pathname#realpath elsewhere, which respects symlinks in relative paths but is incompatible with Windows. #6755 [Jeremy Kemper, trevor] - -* Deprecation: remove components from controller paths. [Jeremy Kemper] - -* Add environment variable RAILS_DEFAULT_DATABASE, which allows the builtin default of 'mysql' to be overridden. [Nicholas Seckar] - -* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess] - -* Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.] - -* Split plugin location and loading out of the initializer and into a new Plugin namespace, which includes Plugin::Locater and Plugin::Loader. The loader class that is used can be customized using the config.plugin_loader option. Those monkey patching the plugin loading subsystem take note, the internals changing here will likely break your modifications. The good news is that it should be substantially easier to hook into the plugin locating and loading process now. [Marcel Molina Jr.] - -* Added assumption that all plugin creators desire to be sharing individuals and release their work under the MIT license [David Heinemeier Hansson] - -* Added source-annotations extractor tasks to rake [Jamis Buck]. This allows you to add FIXME, OPTIMIZE, and TODO comments to your source code that can then be extracted in concert with rake notes (shows all), rake notes:fixme, rake notes:optimize and rake notes:todo. - -* Added fixtures :all to test_helper.rb to assume that most people just want all their fixtures loaded all the time [David Heinemeier Hansson] - -* Added config/initializers where all ruby files within it are automatically loaded after the Rails configuration is done, so you don't have to litter the environment.rb file with a ton of mixed stuff [David Heinemeier Hansson] - -* For new apps, generate a random secret for the cookie-based session store. [Jeremy Kemper] - -* Stop swallowing errors during rake test [Michael Koziarski] - -* Update Rails Initializer to use ActionController::Base#view_paths [Rick Olson] - -* Fix gem deprecation warnings, which also means depending on RubyGems 0.9.0+ [Chad Fowler] - -* Plugins may be symlinked in vendor/plugins. #4245 [brandon, progrium@gmail.com] - -* Resource generator depends on the model generator rather than duplicating it. #7269 [bscofield] - -* Add/Update usage documentation for script/destroy, resource generator and scaffold_resource generator. Closes #7092, #7271, #7267. [bscofield] - -* Update to script.aculo.us 1.7.0. [Thomas Fuchs] - -* Update to Prototype 1.5.0. [Sam Stephenson] - -* Generator: use destination path for diff tempfiles. #7015 [alfeld] - -* Fixed that webrick would strip leading newlines and hang connection #4156 [psross] - -* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson] - If you really want your plugins to reload, add this to the very top of init.rb: - - Dependencies.load_once_paths.delete(lib_path) - -* Allow config.to_prepare to work, make the dispatcher safe to 're require'. [Michael Koziarski, Nicholas Seckar] - -* Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish] - -* Fix Webrick Daemon dispatching bug regarding a bad current working directory. Closes #4899 [Rick Olson] - -* Make config.plugins affect the load path and the dependencies system. Allows you to control plugin loading order, and keep disabled plugins off the load path. [James Adam] - -* Don't generate a components directory in new Rails apps. [Jeremy Kemper] - -* Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [David Heinemeier Hansson] - -* Added one-letter aliases for the three default environments to script/console, so script/console p will load the production environment (t for test, d for development) [David Heinemeier Hansson] - -* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [David Heinemeier Hansson] - -* Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar] - -* Added ActiveRecord::Base.clear_active_connections! in development mode so the database connection is not carried over from request to request. Some databases won't reread the schema if that doesn't happen (I'm looking at you SQLite), so you have to restart the server after each migration (= no fun) [David Heinemeier Hansson] - -* Made RAILS_GEM_VERSION work for beta gems too, so specifying 1.1.6 will give you 1.1.6.4520 if available [David Heinemeier Hansson] - -* Update to Prototype and script.aculo.us [5579]. [Thomas Fuchs] - -* Made script/server work with -e and -d when using Mongrel [David Heinemeier Hansson] - -* Update to Prototype 1.5.0_rc2 [5550] which makes it work in Opera again [Thomas Fuchs] - -* Make sure that exceptions which are thrown outside of the user code try their best to be handeled in ApplicationController#rescue_action [Tobias Lütke] - -* Rails::VERSION::STRING should always be available without having to require 'rails/version'. #6244 [fearoffish] - -* Update to Prototype 1.5.0_rc2. [Sam Stephenson] - -* Add grep-based fallback to reaper, to work in pidless setups [Jamis Buck] - -* Only wrap request processing with our USR1 signal handler so FastCGI can trap it and raise an exception while waiting for connections. Idle processes exit immediately rather than waiting for another request; active processes gracefully exit when the request is finished. [Jeremy Kemper] - -* Alter prior change to use require_dependency instead of require_or_load. Causes ApplicationController to be reloaded again. Closes #6587. [Nicholas Seckar] - -* Rake: use absolute paths to load lib and vendor tasks so they may be run outside of RAILS_ROOT. #6584 [jchris] - -* Remove temporary crutch to help ApplicationController be unloaded. Closes #6496. [Nicholas Seckar] - -* scaffold_resource generator uses _path named routes and head instead of render :nothing => true. #6545 [Josh Susser] - -* Generator can show diff on file collision to help you decide whether to skip or overwrite. #6364 [jeffw, Jeremy Kemper] - -* Generated directories are recursively svn added, like mkdir -p. #6416 [NeilW] - -* resource and scaffold_resource generators add a restful route to config/routes.rb [Jeremy Kemper] - -* Revert environment changes for autoload_paths. [Michael Koziarski] - -* Update to latest Prototype, which doesn't serialize disabled form elements, adds clone() to arrays, empty/non-string Element.update() and adds a fixes excessive error reporting in WebKit beta versions [Thomas Fuchs] - -* Clean up the output of rake stats, de-emphasise components and apis, and remove the indents for tests [Michael Koziarski] - -* Added option to script/process/spawner of specifying the binding address #5133 [Dee Zsombor] - -* Update environment.rb comments to include config.autoload_paths. Closes #6478 [caio] - -* Update scaffold to use new form_tag block functionality. Closes #6480. [Bob Silva] - -* Plugin generator: check for class collisions. #4833 [vinbarnes@gmail.com] - -* Mailer generator: handle mailers in modules, set mime_version in unit test. [Jeremy Kemper] - -* Set $KCODE to 'u' by default to enable the multibyte safe String#chars proxy. [Michael Koziarski] - -* Added config.plugins to control which plugins are loaded #6269 [Stefan Kaes]. By default, everything in vendor/plugins will be loaded, but if you specify config.plugins, only those will be loaded. Example: - - config.plugins = %w[ routing_navigator simply_helpful ] - -* Clean up html on included error pages. [Tim Lucas] - -* Fixed default 404.html and 500.htmls to remove extreme ugliness and include human language [David Heinemeier Hansson] - -* Update to latest Prototype and script.aculo.us trunk versions [Thomas Fuchs] - -* PostgreSQL: db:test:purge closes open database connections first. #6236 [alex] - -* Fixed test:uncommitted on Windows (backslash issue) #4999 [paul@paulbutcher.com] - -* Fixed migration creation to work with namespaced models, so script/generate model Gallery::Image will use create_table :gallery_images #6327 [Bob Silva] - -* Fixed rename_table on SQLite tables with indexes defined #5942 [brandon@opensoul.org] - -* Added default timeout setting of 5 seconds to SQLite3 database.yml configurations [David Heinemeier Hansson] - -* Added generated attribute options to script/generate model, like the one found in scaffold_resource and resource [David Heinemeier Hansson]. Examples: - - ./script/generate model post title:string created_on:date body:text published:boolean - -* Added script/generate resource which works just like scaffold_resource, but creates empty placeholders instead of predefined [David Heinemeier Hansson] - -* script/runner can run files, pass on arguments, and be used as a shebang. #6286 [Tuxie, dlpond] - #!/usr/bin/env /path/to/my/app/script/runner - # Example: just start using your models as if you are in script/console - Product.find(:all).each { |product| product.check_inventory } - -* Look for rake tasks in plugin subdirs. #6259 [obrie] - -* Added map.connect ':controller/:action/:id.:format' as a default route to config/routes.rb [David Heinemeier Hansson] - -* Updated prototype.js to 1.5.0_rc1 with latest fixes. [Rick Olson] - - - XPATH support - - Make Form.getElements() return elements in the correct order - - fix broken Form.serialize return - -* session_migration generator adds an index on updated_at. #6207 [grg] - -* script/server creates the tmp/pids directory. #6204 [jonathan] - -* Fix script/console --sandbox for internal transactions changes. #5738 [Chris McGrath, charles.gerungan@gmail.com] - -* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As -documented in initializer.rb, the workaround is: - - config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/'] - -References #6031. [Nicholas Seckar] - -* Update to script.aculo.us 1.6.3 [Thomas Fuchs] - -* Update to Prototype 1.5.0_rc1 [sam] - -* Formally Deprecate the old rake tasks. [Michael Koziarski] - -* Thoroughly test the FCGI dispatcher. #5970 [Kevin Clark] - -* Remove Dir.chdir in the Webrick DispatchServlet#initialize method. Fix bad path errors when trying to load config/routes.rb. [Rick Olson] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Cleaning up tests. [Kevin Clark, Jeremy Kemper] - -* Add Dependencies.load_once_paths. [Nicholas Seckar] - -* Updated to script.aculo.us 1.6.2 [Thomas Fuchs] - -* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar] - -* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar] - -* Rearrange application resetting and preparation, fix bug with leaking subclasses hash in ActiveRecord::Base [Rick Olson] - - ActiveRecord::Base.reset_subclasses is called before Dependencies are cleared and classes removed. - ActiveRecord::Base.instantiate_observers is called during a Dispatcher preparation callback. - -* Add missing mock directories from the autoload_paths configuration. [Rick Olson] - -* Nested controller scaffolding also nests the generated layout. [iain d broadfoot] - -* Add "require 'dispatcher'" to webrick server in the continuing quest to squash webrick weirdness. [Nicholas Seckar] - -* Add autoload_paths support to Initializer. [Nicholas Seckar] - -* Fix Dispatcher.reset_application! so that AR subclasses are removed and Observers re-initialized *after* Reloadable classes are removed. Closes #5743. [Rick Olson] - -* Clarify usage of script/plugin source. Closes #5344. [James Adam] - -* Add Dispatcher.to_prepare and config.to_prepare to provide a pre-request hook. [Nicholas Seckar] - -* Tweak the Rails load order so observers are loaded after plugins, and reloaded in development mode. Closed #5279. [Rick Olson] - -* Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p #5465 [mats@imediatec.co.uk] - -* script/performance/profiler compatibility with the new ruby-prof, including an option to choose the results printer. #5679 [Shugo Maeda] - -* Fixed the failsafe response so it uses either the current recognized controller or ApplicationController. [Rick Olson] - -* Make sure script/reaper only reaps dispatcher pids by default, and not the spawner's pid. [Jamis Buck] - -* Fix script/plugin about so it uses about.yml and not meta.yml. [James Adam] - -* Dispatcher processes rescued actions with the same controller that processed the request. #4625 [sd@notso.net] - -* rails -d frontbase to create a new project with a frontbase database.yml. #4945 [mlaster@metavillage.com] - -* Ensure the logger is initialized. #5629 [mike@clarkware.com] - -* Added Mongrel-spawning capabilities to script/process/spawner. Mongrel will be the default choice if installed, otherwise FCGI is tried [David Heinemeier Hansson]. Examples: - - spawner # starts instances on 8000, 8001, and 8002 using Mongrel if available - spawner fcgi # starts instances on 8000, 8001, and 8002 using FCGI - spawner mongrel -i 5 # starts instances on 8000, 8001, 8002, 8003, and 8004 using Mongrel - spawner -p 9100 -i 10 # starts 10 instances counting from 9100 to 9109 using Mongrel if available - spawner -p 9100 -r 5 # starts 3 instances counting from 9100 to 9102 and attempts start them every 5 seconds - - Also note that script/process/reaper is Mongrel capable. So the combination of spawner and reaper is a built-in alternative to something like mongrel_cluster. - -* Update scaffolding functional tests to use :id => people(:first) instead of :id => 1. #5612 [evan@protest.net] - -* db:test:clone should remove existing tables before reloading the schema. #5607 [sveit@tradeharbor.com] - -* Fixed migration generation for class names like ACLController #5197 [brad@madriska.com] - -* Added show_source_list and show_call_stack to breakpoints to make it easier to get context #5476 [takiuchi@drecom.co.jp]. Examples: - - irb(#<TopController:0x40822a68>):002:0> show_source_list - 0001 class TopController < ApplicationController - 0002 def show - 0003-> breakpoint - 0004 end - 0005 - 0006 def index - 0007 end - 0008 - => "/path/to/rails/root/app/controllers/top_controller.rb" - - irb(#<TopController:0x40822a68>):004:0> show_call_stack 3 - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - app/controllers/top_controller.rb:3:in `show' - => "/path/to/rails/root/app/controllers/top_controller.rb:3" - -* Generate scaffold layout in subdirectory appropriate to its module nesting. #5511 [nils@alumni.rice.edu] - -* Mongrel: script/server tails the rails log like it does with lighttpd. Prefer mongrel over lighttpd. #5541 [mike@clarkware.com] - -* Don't assume Active Record is available. #5497 [bob@sporkmonger.com] - -* Mongrel: script/server works on Win32. #5499 [jeremydurham@gmail.com] - -* Remove opts.on { |options[:option_name] } style hash assignment. Closes #4440. [Nick Sieger] - -* Mongrel support for script/server. #5475 [jeremydurham@gmail.com] - -* Fix script/plugin so it doesn't barf on invalid URLs [Rick Olson] - -* Fix plugin install bug at dir with space. (closes #5359) [Yoshimasa NIWA] - -* Fix bug with 'script/plugin install' so it reports unknown plugin names correctly. [Rick Olson] - -* Added uninstall.rb hook to plugin handling, such that plugins have a way of removing assets and other artifacts on removal #5003 [takiuchi@drecom.co.jp] - -* Create temporary dirs relative to RAILS_ROOT when running script/server #5014 [elliot@townx.org] - -* Minor tweak to dispatcher to use recognize instead of recognize!, as per the new routes. [Jamis Buck] - -* Make "script/plugin install" work with svn+ssh URLs. [Sam Stephenson] - -* Added lib/ to the directories that will get application docs generated [David Heinemeier Hansson] - -* Add observer generator. Closes #5167. [François Beausoleil] - -* Session migration generator obeys pluralize_table_names. #5145 [James Adam] - -* rake test:recent understands subdirectories. #2925 [jerrett@bravenet.com] - -* The app generator detects the XAMPP package's MySQL socket location. #3832 [elliot@townx.org] - -* The app generator sets a session key in application.rb so apps running on the same host may distinguish their cookies. #2967 [rcoder, rails-bug@owl.me.uk] - -* Distinguish the spawners for different processes [David Heinemeier Hansson] - -* Added -n/--process to script/process/spawner name the process pid (default is dispatch) [David Heinemeier Hansson] - -* Namespaced OrderedHash so the Rails implementation does not clash with any others. (fixes #4911) [Julian Tarkhanov] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Added script/process/inspector to do simple process status information on Rails dispatchers keeping pid files in tmp/pids [David Heinemeier Hansson] - -* Added pid file usage to script/process/spawner and script/process/reaper along with a directive in default config/lighttpd.conf file to record the pid. They will all save their pid file in tmp/pids [David Heinemeier Hansson] - - -*1.2.3* (March 12th, 2007) - -* Ruby 1.8.6 compatibility - -* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess] - -* Stop swallowing errors during rake test [Michael Koziarski] - - -*1.2.2* (February 5th, 2007) - -* Fix gem deprecation warnings, which also means depending on RubyGems 0.9.0+ [Chad Fowler] - -* Require the dispatcher for Rails::Configuration#to_prepare. [Rick Olson] - - -*1.2.1* (January 16th, 2007) - -* Updated to Active Record 1.15.1, Action Pack 1.13.1, Action Mailer 1.3.1, Action Web Service 1.2.1 - - -*1.2.0* (January 16th, 2007) - -* Update to Prototype 1.5.0. [Sam Stephenson] - -* Generator: use destination path for diff tempfiles. #7015 [alfeld] - -* Fixed that webrick would strip leading newlines and hang connection #4156 [psross] - -* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson] - If you really want your plugins to reload, add this to the very top of init.rb: - - Dependencies.load_once_paths.delete(lib_path) - -* Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish] - -* Fix Webrick Daemon dispatching bug regarding a bad current working directory. Closes #4899 [Rick Olson] - -* Make config.plugins affect the load path and the dependencies system. Allows you to control plugin loading order, and keep disabled plugins off the load path. [James Adam] - -* Don't generate a components directory in new Rails apps. [Jeremy Kemper] - -* Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [David Heinemeier Hansson] - -* Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [David Heinemeier Hansson] - -* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [David Heinemeier Hansson] - -* Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar] - -* Added ActiveRecord::Base.clear_active_connections! in development mode so the database connection is not carried over from request to request. Some databases won't reread the schema if that doesn't happen (I'm looking at you SQLite), so you have to restart the server after each migration (= no fun) [David Heinemeier Hansson] - -* Made RAILS_GEM_VERSION work for beta gems too, so specifying 1.1.6 will give you 1.1.6.4520 if available [David Heinemeier Hansson] - -* Update to Prototype and script.aculo.us [5579]. [Sam Stephenson, Thomas Fuchs] - -* Made script/server work with -e and -d when using Mongrel [David Heinemeier Hansson] - -* Make sure that exceptions which are thrown outside of the user code try their best to be handeled in ApplicationController#rescue_action [Tobias Lütke] - -* Rails::VERSION::STRING should always be available without having to require 'rails/version'. #6244 [fearoffish] - -* Add grep-based fallback to reaper, to work in pidless setups [Jamis Buck] - -* Only wrap request processing with our USR1 signal handler so FastCGI can trap it and raise an exception while waiting for connections. Idle processes exit immediately rather than waiting for another request; active processes gracefully exit when the request is finished. [Jeremy Kemper] - -* Alter prior change to use require_dependency instead of require_or_load. Causes ApplicationController to be reloaded again. Closes #6587. [Nicholas Seckar] - -* Rake: use absolute paths to load lib and vendor tasks so they may be run outside of RAILS_ROOT. #6584 [jchris] - -* scaffold_resource generator uses _path named routes and head instead of render :nothing => true. #6545 [Josh Susser] - -* Generator can show diff on file collision to help you decide whether to skip or overwrite. #6364 [jeffw, Jeremy Kemper] - -* Generated directories are recursively svn added, like mkdir -p. #6416 [NeilW] - -* resource and scaffold_resource generators add a restful route to config/routes.rb [Jeremy Kemper] - -* Revert environment changes for autoload_paths. [Michael Koziarski] - -* Clean up the output of rake stats, de-emphasise components and apis, and remove the indents for tests [Michael Koziarski] - -* Added option to script/process/spawner of specifying the binding address #5133 [Dee Zsombor] - -* Update environment.rb comments to include config.autoload_paths. Closes #6478 [caio] - -* Update scaffold to use new form_tag block functionality. Closes #6480. [Bob Silva] - -* Plugin generator: check for class collisions. #4833 [vinbarnes@gmail.com] - -* Mailer generator: handle mailers in modules, set mime_version in unit test. [Jeremy Kemper] - -* Set $KCODE to 'u' by default to enable the multibyte safe String#chars proxy. [Michael Koziarski] - -* Added config.plugins to control which plugins are loaded #6269 [Stefan Kaes]. By default, everything in vendor/plugins will be loaded, but if you specify config.plugins, only those will be loaded. Example: - - config.plugins = %w[ routing_navigator simply_helpful ] - -* Clean up html on included error pages. [Tim Lucas] - -* Fixed default 404.html and 500.htmls to remove extreme ugliness and include human language [David Heinemeier Hansson] - -* Update to latest Prototype and script.aculo.us trunk versions [Thomas Fuchs] - -* PostgreSQL: db:test:purge closes open database connections first. #6236 [alex] - -* Fixed test:uncommitted on Windows (backslash issue) #4999 [paul@paulbutcher.com] - -* Fixed migration creation to work with namespaced models, so script/generate model Gallery::Image will use create_table :gallery_images #6327 [Bob Silva] - -* Fixed rename_table on SQLite tables with indexes defined #5942 [brandon@opensoul.org] - -* Added default timeout setting of 5 seconds to SQLite3 database.yml configurations [David Heinemeier Hansson] - -* Added generated attribute options to script/generate model, like the one found in scaffold_resource and resource [David Heinemeier Hansson]. Examples: - - ./script/generate model post title:string created_on:date body:text published:boolean - -* Added script/generate resource which works just like scaffold_resource, but creates empty placeholders instead of predefined [David Heinemeier Hansson] - -* script/runner can run files, pass on arguments, and be used as a shebang. #6286 [Tuxie, dlpond] - #!/usr/bin/env /path/to/my/app/script/runner - # Example: just start using your models as if you are in script/console - Product.find(:all).each { |product| product.check_inventory } - -* Look for rake tasks in plugin subdirs. #6259 [obrie] - -* Added map.connect ':controller/:action/:id.:format' as a default route to config/routes.rb [David Heinemeier Hansson] - -* session_migration generator adds an index on updated_at. #6207 [grg] - -* script/server creates the tmp/pids directory. #6204 [jonathan] - -* Fix script/console --sandbox for internal transactions changes. #5738 [Chris McGrath, charles.gerungan@gmail.com] - -* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As -documented in initializer.rb, the workaround is: - - config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/'] - -References #6031. [Nicholas Seckar] - -* Update to script.aculo.us 1.6.3 [Thomas Fuchs] - -* Formally Deprecate the old rake tasks. [Michael Koziarski] - -* Thoroughly test the FCGI dispatcher. #5970 [Kevin Clark] - -* Remove Dir.chdir in the Webrick DispatchServlet#initialize method. Fix bad path errors when trying to load config/routes.rb. [Rick Olson] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Cleaning up tests. [Kevin Clark, Jeremy Kemper] - -* Add Dependencies.load_once_paths. [Nicholas Seckar] - -* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar] - -* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar] - -* Rearrange application resetting and preparation, fix bug with leaking subclasses hash in ActiveRecord::Base [Rick Olson] - - ActiveRecord::Base.reset_subclasses is called before Dependencies are cleared and classes removed. - ActiveRecord::Base.instantiate_observers is called during a Dispatcher preparation callback. - -* Add missing mock directories from the autoload_paths configuration. [Rick Olson] - -* Nested controller scaffolding also nests the generated layout. [iain d broadfoot] - -* Add "require 'dispatcher'" to webrick server in the continuing quest to squash webrick weirdness. [Nicholas Seckar] - -* Add autoload_paths support to Initializer. [Nicholas Seckar] - -* Fix Dispatcher.reset_application! so that AR subclasses are removed and Observers re-initialized *after* Reloadable classes are removed. Closes #5743. [Rick Olson] - -* Clarify usage of script/plugin source. Closes #5344. [James Adam] - -* Add Dispatcher.to_prepare and config.to_prepare to provide a pre-request hook. [Nicholas Seckar] - -* Tweak the Rails load order so observers are loaded after plugins, and reloaded in development mode. Closed #5279. [Rick Olson] - -* Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p #5465 [mats@imediatec.co.uk] - -* script/performance/profiler compatibility with the new ruby-prof, including an option to choose the results printer. #5679 [Shugo Maeda] - -* Fixed the failsafe response so it uses either the current recognized controller or ApplicationController. [Rick Olson] - -* Make sure script/reaper only reaps dispatcher pids by default, and not the spawner's pid. [Jamis Buck] - -* Fix script/plugin about so it uses about.yml and not meta.yml. [James Adam] - -* Dispatcher processes rescued actions with the same controller that processed the request. #4625 [sd@notso.net] - -* rails -d frontbase to create a new project with a frontbase database.yml. #4945 [mlaster@metavillage.com] - -* Ensure the logger is initialized. #5629 [mike@clarkware.com] - -* Added Mongrel-spawning capabilities to script/process/spawner. Mongrel will be the default choice if installed, otherwise FCGI is tried [David Heinemeier Hansson]. Examples: - - spawner # starts instances on 8000, 8001, and 8002 using Mongrel if available - spawner fcgi # starts instances on 8000, 8001, and 8002 using FCGI - spawner mongrel -i 5 # starts instances on 8000, 8001, 8002, 8003, and 8004 using Mongrel - spawner -p 9100 -i 10 # starts 10 instances counting from 9100 to 9109 using Mongrel if available - spawner -p 9100 -r 5 # starts 3 instances counting from 9100 to 9102 and attempts start them every 5 seconds - - Also note that script/process/reaper is Mongrel capable. So the combination of spawner and reaper is a built-in alternative to something like mongrel_cluster. - -* Update scaffolding functional tests to use :id => people(:first) instead of :id => 1. #5612 [evan@protest.net] - -* db:test:clone should remove existing tables before reloading the schema. #5607 [sveit@tradeharbor.com] - -* Fixed migration generation for class names like ACLController #5197 [brad@madriska.com] - -* Added show_source_list and show_call_stack to breakpoints to make it easier to get context #5476 [takiuchi@drecom.co.jp]. Examples: - - irb(#<TopController:0x40822a68>):002:0> show_source_list - 0001 class TopController < ApplicationController - 0002 def show - 0003-> breakpoint - 0004 end - 0005 - 0006 def index - 0007 end - 0008 - => "/path/to/rails/root/app/controllers/top_controller.rb" - - irb(#<TopController:0x40822a68>):004:0> show_call_stack 3 - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - app/controllers/top_controller.rb:3:in `show' - => "/path/to/rails/root/app/controllers/top_controller.rb:3" - -* Generate scaffold layout in subdirectory appropriate to its module nesting. #5511 [nils@alumni.rice.edu] - -* Mongrel: script/server tails the rails log like it does with lighttpd. Prefer mongrel over lighttpd. #5541 [mike@clarkware.com] - -* Don't assume Active Record is available. #5497 [bob@sporkmonger.com] - -* Mongrel: script/server works on Win32. #5499 [jeremydurham@gmail.com] - -* Remove opts.on { |options[:option_name] } style hash assignment. Closes #4440. [Nick Sieger] - -* Mongrel support for script/server. #5475 [jeremydurham@gmail.com] - -* Fix script/plugin so it doesn't barf on invalid URLs [Rick Olson] - -* Fix plugin install bug at dir with space. (closes #5359) [Yoshimasa NIWA] - -* Fix bug with 'script/plugin install' so it reports unknown plugin names correctly. [Rick Olson] - -* Added uninstall.rb hook to plugin handling, such that plugins have a way of removing assets and other artifacts on removal #5003 [takiuchi@drecom.co.jp] - -* Create temporary dirs relative to RAILS_ROOT when running script/server #5014 [elliot@townx.org] - -* Minor tweak to dispatcher to use recognize instead of recognize!, as per the new routes. [Jamis Buck] - -* Make "script/plugin install" work with svn+ssh URLs. [Sam Stephenson] - -* Added lib/ to the directories that will get application docs generated [David Heinemeier Hansson] - -* Add observer generator. Closes #5167. [François Beausoleil] - -* Session migration generator obeys pluralize_table_names. #5145 [James Adam] - -* rake test:recent understands subdirectories. #2925 [jerrett@bravenet.com] - -* The app generator detects the XAMPP package's MySQL socket location. #3832 [elliot@townx.org] - -* The app generator sets a session key in application.rb so apps running on the same host may distinguish their cookies. #2967 [rcoder, rails-bug@owl.me.uk] - -* Distinguish the spawners for different processes [David Heinemeier Hansson] - -* Added -n/--process to script/process/spawner name the process pid (default is dispatch) [David Heinemeier Hansson] - -* Namespaced OrderedHash so the Rails implementation does not clash with any others. (fixes #4911) [Julian Tarkhanov] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Added script/process/inspector to do simple process status information on Rails dispatchers keeping pid files in tmp/pids [David Heinemeier Hansson] - -* Added pid file usage to script/process/spawner and script/process/reaper along with a directive in default config/lighttpd.conf file to record the pid. They will all save their pid file in tmp/pids [David Heinemeier Hansson] - - -*1.1.6* (August 10th, 2006) - -* Additional security patch - - -*1.1.5* (August 8th, 2006) - -* Mention in docs that config.frameworks doesn't work when getting Rails via Gems. #4857 [Alisdair McDiarmid] - -* Change the scaffolding layout to use yield rather than @content_for_layout. [Marcel Molina Jr.] - -* Includes critical security patch - - -*1.1.4* (June 29th, 2006) - -* Remove use of opts.on { |options[:name] } style hash assignment. References #4440. [headius@headius.com] - -* Updated to Action Pack 1.12.3, ActionWebService 1.1.4, ActionMailer 1.2.3 - - -*1.1.3* (June 27th, 2006) - -* Updated to Active Record 1.14.3, Action Pack 1.12.2, ActionWebService 1.1.3, ActionMailer 1.2.2 - - -*1.1.2* (April 9th, 2006) - -* Mention in docs that config.frameworks doesn't work when getting Rails via Gems. Closes #4857. [Alisdair McDiarmid] - -* Change the scaffolding layout to use yield rather than @content_for_layout. [Marcel Molina Jr.] - -* Added rake rails:update:configs to update config/boot.rb from the latest (also included in rake rails:update) [David Heinemeier Hansson] - -* Fixed that boot.rb would set RAILS_GEM_VERSION twice, not respect an uncommented RAILS_GEM_VERSION line, and not use require_gem [David Heinemeier Hansson] - - -*1.1.1* (April 6th, 2006) - -* Enhances plugin#discover allowing it to discover svn:// like URIs (closes #4565) [ruben.nine@gmail.com] - -* Update to Prototype 1.5.0_rc0 [Sam Stephenson] - -* Fixed that the -r/--ruby path option of the rails command was not being respected #4549 [ryan.raaum@gmail.com] - -* Added that Dispatcher exceptions should not be shown to the user unless a default log has not been configured. Instead show public/500.html [David Heinemeier Hansson] - -* Fixed that rake clone_structure_to_test should quit on pgsql if the dump is unsuccesful #4585 [augustz@augustz.com] - -* Fixed that rails --version should have the return code of 0 (success) #4560 [blair@orcaware.com] - -* Install alias so Rails::InfoController is accessible at /rails_info. Closes #4546. [Nicholas Seckar] - -* Fixed that spawner should daemonize if running in repeat mode [David Heinemeier Hansson] - -* Added TAG option for rake rails:freeze:edge, so you can say rake rails:freeze:edge TAG=rel_1-1-0 to lock to the 1.1.0 release [David Heinemeier Hansson] - -* Applied Prototype $() performance patches (#4465, #4477) and updated script.aculo.us [Sam Stephenson, Thomas Fuchs] - -* Use --simple-prompt instead of --prompt-mode simple for console compatibility with Windows/Ruby 1.8.2 #4532 [starr@starrnhorne.com] - -* Make Rails::VERSION implicitly loadable #4491. [Nicholas Seckar] - -* Fixed rake rails:freeze:gems #4518 [benji@silverinsanity.com] - -* Added -f/--freeze option to rails command for freezing the application to the Rails version it was generated with [David Heinemeier Hansson] - -* Added gem binding of apps generated through the rails command to the gems of they were generated with [Nicholas Seckar] - -* Added expiration settings for JavaScript, CSS, HTML, and images to default lighttpd.conf [David Heinemeier Hansson] - -* Added gzip compression for JavaScript, CSS, and HTML to default lighttpd.conf [David Heinemeier Hansson] - -* Avoid passing escapeHTML non-string in Rails' info controller [Nicholas Seckar] - - -*1.1.0* (March 27th, 2006) - -* Allow db:fixtures:load to load a subset of the applications fixtures. [Chad Fowler] - - ex. - - rake db:fixtures:load FIXTURES=customers,plans - -* Update to Prototype 1.5.0_pre1 [Sam Stephenson] - -* Update to script.aculo.us 1.6 [Thomas Fuchs] - -* Add an integration_test generator [Jamis Buck] - -* Make all ActionView helpers available in the console from the helper method for debugging purposes. n.b.: Only an 80% solution. Some stuff won't work, most will. [Marcel Molina Jr.] - - ex. - - >> puts helper.options_for_select([%w(a 1), %w(b 2), %w(c 3)]) - <option value="1">a</option> - <option value="2">b</option> - <option value="3">c</option> - => nil - -* Replaced old session rake tasks with db:sessions:create to generate a migration, and db:sessions:clear to remove sessions. [Rick Olson] - -* Reject Ruby 1.8.3 when loading Rails; extract version checking code. [Chad Fowler] - -* Remove explicit loading of RailsInfo and RailsInfoController. [Nicholas Seckar] - -* Move RailsInfo and RailsInfoController to Rails::Info and Rails::InfoController. [Nicholas Seckar] - -* Extend load path with Railties' builtin directory to make adding support code easy. [Nicholas Seckar] - -* Fix the rails_info controller by explicitly loading it, and marking it as not reloadable. [Nicholas Seckar] - -* Fixed rails:freeze:gems for Windows #3274 [paul@paulbutcher.com] - -* Added 'port open?' check to the spawner when running in repeat mode so we don't needlessly boot the dispatcher if the port is already in use anyway #4089 [guy.naor@famundo.com] - -* Add verification to generated scaffolds, don't allow get for unsafe actions [Michael Koziarski] - -* Don't replace application.js in public/javascripts if it already exists [Cody Fauser] - -* Change test:uncommitted to delay execution of `svn status` by using internal Rake API's. [Nicholas Seckar] - -* Use require_library_or_gem to load rake in commands/server.rb. Closes #4205. [rob.rasmussen@gmail.com] - -* Use the Rake API instead of shelling out to create the tmp directory in commands/server.rb. [Chad Fowler] - -* Added a backtrace to the evil WSOD (White Screen of Death). Closes #4073. TODO: Clearer exceptions [Rick Olson] - -* Added tracking of database and framework versions in script/about #4088 [charles.gerungan@gmail.com/Rick Olson] - -* Added public/javascripts/application.js as a sample since it'll automatically be included in javascript_include_tag :defaults [David Heinemeier Hansson] - -* Added socket cleanup for lighttpd, both before and after [David Heinemeier Hansson] - -* Added automatic creation of tmp/ when running script/server [David Heinemeier Hansson] - -* Added silence_stream that'll work on both STDERR or STDOUT or any other stream and deprecated silence_stderr in the process [David Heinemeier Hansson] - -* Added reload! method to script/console to reload all models and others that include Reloadable without quitting the console #4056 [esad@esse.at] - -* Added that rake rails:freeze:edge will now just export all the contents of the frameworks instead of just lib, so stuff like rails:update:scripts, rails:update:javascripts, and script/server on lighttpd still just works #4047 [David Heinemeier Hansson] - -* Added fix for upload problems with lighttpd from Safari/IE to config/lighttpd.conf #3999 [Thijs van der Vossen] - -* Added test:uncommitted to test changes since last checkin to Subversion #4035 [technomancy@gmail.com] - -* Help script/about print the correct svn revision when in a non-English locale. #4026 [babie7a0@ybb.ne.jp] - -* Add 'app' accessor to script/console as an instance of Integration::Session [Jamis Buck] - -* Generator::Base#usage takes an optional message argument which defaults to Generator::Base#usage_message. [Jeremy Kemper] - -* Remove the extraneous AR::Base.threaded_connections setting from the webrick server. [Jeremy Kemper] - -* Add integration test support to app generation and testing [Jamis Buck] - -* Added namespaces to all tasks, so for example load_fixtures is now db:fixtures:load. All the old task names are still valid, they just point to the new namespaced names. "rake -T" will only show the namespaced ones, though [David Heinemeier Hansson] - -* CHANGED DEFAULT: ActiveRecord::Base.schema_format is now :ruby by default instead of :sql. This means that we'll assume you want to live in the world of db/schema.rb where the grass is green and the girls are pretty. If your schema contains un-dumpable elements, such as constraints or database-specific column types, you just got an invitation to either 1) patch the dumper to include foreign key support, 2) stop being db specific, or 3) just change the default in config/environment.rb to config.active_record.schema_format = :sql -- we even include an example for that on new Rails skeletons now. Brought to you by the federation of opinionated framework builders! [David Heinemeier Hansson] - -* Added -r/--repeat option to script/process/spawner that offers the same loop protection as the spinner did. This deprecates the script/process/spinner, so it's no longer included in the default Rails skeleton, but still available for backwards compatibility #3461 [ror@andreas-s.net] - -* Added collision option to template generation in generators #3329 [anna@wota.jp]. Examples: - - m.template "stuff.config" , "config/stuff.config" , :collision => :skip - m.template "auto-stamping", "config/generator.log", :collision => :force - -* Added more information to script/plugin's doings to ease debugging #3755 [Rick Olson] - -* Changed the default configuration for lighttpd to use tmp/sockets instead of log/ for the FastCGI sockets [David Heinemeier Hansson] - -* Added a default configuration of the FileStore for fragment caching if tmp/cache is available, which makes action/fragment caching ready to use out of the box with no additional configuration [David Heinemeier Hansson] - -* Changed the default session configuration to place sessions in tmp/sessions, if that directory is available, instead of /tmp (this essentially means a goodbye to 9/10 White Screen of Death errors and should have web hosting firms around the world cheering) [David Heinemeier Hansson] - -* Added tmp/sessions, tmp/cache, and tmp/sockets as default directories in the Rails skeleton [David Heinemeier Hansson] - -* Added that script/generate model will now automatically create a migration file for the model created. This can be turned off by calling the generator with --skip-migration [David Heinemeier Hansson] - -* Added -d/--database option to the rails command, so you can do "rails --database=sqlite2 myapp" to start a new application preconfigured to use SQLite2 as the database. Removed the configuration examples from SQLite and PostgreSQL from the default MySQL configuration [David Heinemeier Hansson] - -* Allow script/server -c /path/to/lighttpd.conf [Jeremy Kemper] - -* Remove hardcoded path to reaper script in script/server [Jeremy Kemper] - -* Update script.aculo.us to V1.5.3 [Thomas Fuchs] - -* Added SIGTRAP signal handler to RailsFCGIHandler that'll force the process into a breakpoint after the next request. This breakpoint can then be caught with script/breakpointer and give you access to the Ruby image inside that process. Useful for debugging memory leaks among other things [David Heinemeier Hansson] - -* Changed default lighttpd.conf to use CWD from lighttpd 1.4.10 that allows the same configuration to be used for both detach and not. Also ensured that auto-repeaping of FCGIs only happens when lighttpd is not detached. [David Heinemeier Hansson] - -* Added Configuration#after_initialize for registering a block which gets called after the framework is fully initialized. Useful for things like per-environment configuration of plugins. [Michael Koziarski] - -* Added check for RAILS_FRAMEWORK_ROOT constant that allows the Rails framework to be found in a different place than vendor/rails. Should be set in boot.rb. [David Heinemeier Hansson] - -* Fixed that static requests could unlock the mutex guarding dynamic requests in the WEBrick servlet #3433 [tom@craz8.com] - -* Fixed documentation tasks to work with Rake 0.7.0 #3563 [kazuhiko@fdiary.net] - -* Update to Prototype 1.5.0_pre0 [Sam Stephenson] - -* Sort the list of plugins so we load in a consistent order [Rick Olson] - -* Show usage when script/plugin is called without arguments [tom@craz8.com] - -* Corrected problems with plugin loader where plugins set 'name' incorrectly #3297 [anna@wota.jp] - -* Make migration generator only report on exact duplicate names, not partial dupliate names. #3442 [jeremy@planetargon.com Marcel Molina Jr.] - -* Fix typo in mailer generator USAGE. #3458 [chriztian.steinmeier@gmail.com] - -* Ignore version mismatch between pg_dump and the database server. #3457 [Simon Stapleton] - -* Reap FCGI processes after lighttpd exits. [Sam Stephenson] - -* Honor ActiveRecord::Base.pluralize_table_names when creating and destroying session store table. #3204. [rails@bencurtis.com, Marcel Molina Jr.] - -*1.0.0* (December 13th, 2005) - -* Update instructions on how to find and install generators. #3172. [Chad Fowler] - -* Generator looks in vendor/generators also. [Chad Fowler] - -* Generator copies files in binary mode. #3156 [minimudboy@gmail.com] - -* Add builtin/ to the gemspec. Closes #3047. [Nicholas Seckar, Sam Stephenson] - -* Add install.rb file to plugin generation which is loaded, if it exists, when you install a plugin. [Marcel Molina Jr.] - -* Run initialize_logger in script/lighttpd to ensure the log file exists before tailing it. [Sam Stephenson] - -* Make load_fixtures include csv fixtures. #3053. [me@mdaines.com] - -* Fix freeze_gems so that the latest rails version is dumped by default. [Nicholas Seckar] - -* script/plugin: handle root paths and plugin names which contain spaces. #2995 [justin@aspect.net] - -* Model generator: correct relative path to test_helper in unit test. [Jeremy Kemper] - -* Make the db_schema_dump task honor the SCHEMA environment variable if present the way db_schema_import does. #2931. [Blair Zajac] - -* Have the lighttpd server script report the actual ip to which the server is bound. #2903. [Adam] - -* Add plugin library directories to the load path after the lib directory so that libraries in the lib directory get precedence. #2910. [James Adam] - -* Make help for the console command more explicit about how to specify the desired environment in which to run the console. #2911. [anonymous] - -* PostgreSQL: the purge_test_database Rake task shouldn't explicitly specify the template0 template when creating a fresh test database. #2964 [Dreamer3] - -* Introducing the session_migration generator. Creates an add_session_table migration. Allows generator to specify migrations directory. #2958, #2960 [Rick Olson] - -* script/console uses RAILS_ENV environment variable if present. #2932 [Blair Zajac <blair@orcaware.com> - -* Windows: eliminate the socket option in database.yml. #2924 [Wayne Vucenic <waynev@gmail.com>] - -* Eliminate nil from newly generated logfiles. #2927 [Blair Zajac <blair@orcaware.com>] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Eliminate Subversion dependencies in scripts/plugin. Correct install options. Introduce --force option to reinstall a plugin. Remove useless --long option for list. Use --quiet to quiet the download output and --revision to update to a specific svn revision. #2842 [Chad Fowler, Rick Olson] - -* SQLite: the clone_structure_to_test and purge_test_database Rake tasks should always use the test environment. #2846 [Rick Olson] - -* Make sure that legacy db tasks also reference :database for SQLite #2830 [kazuhiko@fdiary.net] - -* Pass __FILE__ when evaluating plugins' init.rb. #2817 [James Adam] - -* Better svn status matching for generators. #2814 [François Beausoleil <francois.beausoleil@gmail.com>, Blair Zajac <blair@orcaware.com>] - -* Don't reload routes until plugins have been loaded so they have a chance to extend the routing capabilities [David Heinemeier Hansson] - -* Don't detach or fork for script/server tailing [Nicholas Seckar] - -* Changed all script/* to use #!/usr/bin/env ruby instead of hard-coded Ruby path. public/dispatcher.* still uses the hard-coded path for compatibility with web servers that don't have Ruby in path [David Heinemeier Hansson] - -* Force RAILS_ENV to be "test" when running tests, so that ENV["RAILS_ENV"] = "production" in config/environment.rb doesn't wreck havok [David Heinemeier Hansson] #2660 - -* Correct versioning in :freeze_gems Rake task. #2778 [Jakob Skjerning, Jeremy Kemper] - -* Added an omnipresent RailsInfoController with a properties action that delivers an HTML rendering of Rails::Info (but only when local_request? is true). Added a new default index.html which fetches this with Ajax. [Sam Stephenson] - - -*0.14.3 (RC4)* (November 7th, 2005) - -* Add 'add_new_scripts' rake task for adding new rails scripts to script/* [Jamis Buck] - -* Remove bogus hyphen from script/process/reaper calls to 'ps'. #2767 [anonymous] - -* Copy lighttpd.conf when it is first needed, instead of on app creation [Jamis Buck] - -* Use require_library_or_gem 'fcgi' in script/server [Sam Stephenson] - -* Added default lighttpd config in config/lighttpd.conf and added a default runner for lighttpd in script/server (works like script/server, but using lighttpd and FastCGI). It will use lighttpd if available, otherwise WEBrick. You can force either or using 'script/server lighttpd' or 'script/server webrick' [David Heinemeier Hansson] - -* New configuration option config.plugin_paths which may be a single path like the default 'vendor/plugins' or an array of paths: ['vendor/plugins', 'lib/plugins']. [Jeremy Kemper] - -* Plugins are discovered in nested paths, so you can organize your plugins directory as you like. [Jeremy Kemper] - -* Refactor load_plugin from load_plugins. #2757 [alex.r.moon@gmail.com] - -* Make use of silence_stderr in script/lighttpd, script/plugin, and Rails::Info [Sam Stephenson] - -* Enable HTTP installation of plugins when svn isn't avaialable. Closes #2661. [Chad Fowler] - -* Added script/about to display formatted Rails::Info output [Sam Stephenson] - -* Added Rails::Info to catalog assorted information about a Rails application's environment [Sam Stephenson] - -* Tail the logfile when running script/server lighttpd in the foreground [Sam Stephenson] - -* Try to guess the port number from config/lighttpd.conf in script/server lighttpd [Sam Stephenson] - -* Don't reap spawn-fcgi. #2727 [matthew@walker.wattle.id.au] - -* Reaper knows how to find processes even if the dispatch path is very long. #2711 [matthew@walker.wattle.id.au] - -* Make fcgi handler respond to TERM signals with an explicit exit [Jamis Buck] - -* Added demonstration of fixture use to the test case generated by the model generator [David Heinemeier Hansson] - -* If specified, pass PostgreSQL client character encoding to createdb. #2703 [Kazuhiko <kazuhiko@fdiary.net>] - -* Catch CGI multipart parse errors. Wrap dispatcher internals in a failsafe response handler. [Jeremy Kemper] - -* The freeze_gems Rake task accepts the VERSION environment variable to decide which version of Rails to pull into vendor/rails. [Chad Fowler, Jeremy Kemper] - -* Removed script.aculo.us.js, builder.js and slider.js (preperation for move of scriptaculous extensions to plugins, core scriptaculous will remain in Railties) [Thomas Fuchs] - -* The freeze_edge Rake task does smarter svn detection and can export a specific revision by passing the REVISION environment variable. For example: rake freeze_edge REVISION=1234. #2663 [Rick Olson] - -* Comment database.yml and include PostgreSQL and SQLite examples. [Jeremy Kemper] - -* Improve script/plugin on Windows. #2646 [Chad Fowler] - -* The *_plugindoc Rake tasks look deeper into the plugins' lib directories. #2652 [bellis@deepthought.org] - -* The PostgreSQL :db_structure_dump Rake task limits its dump to the schema search path in database.yml. [Anatol Pomozov <anatol.pomozov@gmail.com>] - -* Add task to generate rdoc for all installed plugins. [Marcel Molina Jr.] - -* Update script.aculo.us to V1.5_rc4 [Thomas Fuchs] - -* Add default Mac + DarwinPorts MySQL socket locations to the app generator. [Jeremy Kemper] - -* Migrations may be destroyed: script/destroy migration foo. #2635 [Charles M. Gerungan <charles.gerungan@gmail.com>, Jamis Buck, Jeremy Kemper] - -* Added that plugins can carry generators and that generator stub files can be created along with new plugins using script/generate plugin <name> --with-generator [David Heinemeier Hansson] - -* Removed app/apis as a default empty dir since its automatically created when using script/generate web_service [David Heinemeier Hansson] - -* Added script/plugin to manage plugins (install, remove, list, etc) [Ryan Tomayko] - -* Added test_plugins task: Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name) [David Heinemeier Hansson] - -* Added plugin generator to create a stub structure for a new plugin in vendor/plugins (see "script/generate plugin" for help) [David Heinemeier Hansson] - -* Fixed scaffold generator when started with only 1 parameter #2609 [self@mattmower.com] - -* rake should run functional tests even if the unit tests have failures [Jim Weirich] - -* Back off cleanpath to be symlink friendly. Closes #2533 [Nicholas Seckar] - -* Load rake task files in alphabetical order so you can build dependencies and count on them #2554 [Blair Zajac] - - -*0.14.2 (RC3)* (October 26th, 2005) - -* Constants set in the development/test/production environment file are set in Object - -* Scaffold generator pays attention to the controller name. #2562 [self@mattmower.com] - -* Include tasks from vendor/plugins/*/tasks in the Rakefile #2545 [Rick Olson] - - -*0.14.1 (RC2)* (October 19th, 2005) - -* Don't clean RAILS_ROOT on windows - -* Remove trailing '/' from RAILS_ROOT [Nicholas Seckar] - -* Upgraded to Active Record 1.12.1 and Action Pack 1.10.1 - - -*0.14.0 (RC1)* (October 16th, 2005) - -* Moved generator folder from RAILS_ROOT/generators to RAILS_ROOT/lib/generators [Tobias Lütke] - -* Fix rake dev and related commands [Nicholas Seckar] - -* The rails command tries to deduce your MySQL socket by running `mysql_config ---socket`. If it fails, default to /path/to/your/mysql.sock - -* Made the rails command use the application name for database names in the tailored database.yml file. Example: "rails ~/projects/blog" will use "blog_development" instead of "rails_development". [Florian Weber] - -* Added Rails framework freezing tasks: freeze_gems (freeze to current gems), freeze_edge (freeze to Rails SVN trunk), unfreeze_rails (float with newest gems on system) - -* Added update_javascripts task which will fetch all the latest js files from your current rails install. Use after updating rails. [Tobias Lütke] - -* Added cleaning of RAILS_ROOT to useless elements such as '../non-dot-dot/'. Provides cleaner backtraces and error messages. [Nicholas Seckar] - -* Made the instantiated/transactional fixtures settings be controlled through Rails::Initializer. Transactional and non-instantiated fixtures are default from now on. [Florian Weber] - -* Support using different database adapters for development and test with ActiveRecord::Base.schema_format = :ruby [Sam Stephenson] - -* Make webrick work with session(:off) - -* Add --version, -v option to the Rails command. Closes #1840. [stancell] - -* Update Prototype to V1.4.0_pre11, script.aculo.us to V1.5_rc3 [2504] and fix the rails generator to include the new .js files [Thomas Fuchs] - -* Make the generator skip a file if it already exists and is identical to the new file. - -* Add experimental plugin support #2335 - -* Made Rakefile aware of new .js files in script.aculo.us [Thomas Fuchs] - -* Make table_name and controller_name in generators honor AR::Base.pluralize_table_names. #1216 #2213 [kazuhiko@fdiary.net] - -* Clearly label functional and unit tests in rake stats output. #2297 [lasse.koskela@gmail.com] - -* Make the migration generator only check files ending in *.rb when calculating the next file name #2317 [Chad Fowler] - -* Added prevention of duplicate migrations from the generator #2240 [François Beausoleil] - -* Add db_schema_dump and db_schema_import rake tasks to work with the new ActiveRecord::SchemaDumper (for dumping a schema to and reading a schema from a ruby file). - -* Reformed all the config/environments/* files to conform to the new Rails::Configuration approach. Fully backwards compatible. - -* Added create_sessions_table, drop_sessions_table, and purge_sessions_table as rake tasks for databases that supports migrations (MySQL, PostgreSQL, SQLite) to get a table for use with CGI::Session::ActiveRecordStore - -* Added dump of schema version to the db_structure_dump task for databases that support migrations #1835 [Rick Olson] - -* Fixed script/profiler for Ruby 1.8.2 #1863 [Rick Olson] - -* Fixed clone_structure_to_test task for SQLite #1864 [jon@burningbush.us] - -* Added -m/--mime-types option to the WEBrick server, so you can specify a Apache-style mime.types file to load #2059 [ask@develooper.com] - -* Added -c/--svn option to the generator that'll add new files and remove destroyed files using svn add/revert/remove as appropriate #2064 [Kevin Clark] - -* Added -c/--charset option to WEBrick server, so you can specify a default charset (which without changes is UTF-8) #2084 [wejn@box.cz] - -* Make the default stats task extendable by modifying the STATS_DIRECTORIES constant - -* Allow the selected environment to define RAILS_DEFAULT_LOGGER, and have Rails::Initializer use it if it exists. - -* Moved all the shared tasks from Rakefile into Rails, so that the Rakefile is empty and doesn't require updating. - -* Added Rails::Initializer and Rails::Configuration to abstract all of the common setup out of config/environment.rb (uses config/boot.rb to bootstrap the initializer and paths) - -* Fixed the scaffold generator to fail right away if the database isn't accessible instead of in mid-air #1169 [Chad Fowler] - -* Corrected project-local generator location in scripts.rb #2010 [Michael Schuerig] - -* Don't require the environment just to clear the logs #2093 [Scott Barron] - -* Make the default rakefile read *.rake files from config/tasks (for easy extension of the rakefile by e.g. generators) - -* Only load breakpoint in development mode and when BREAKPOINT_SERVER_PORT is defined. - -* Allow the --toggle-spin switch on process/reaper to be negated - -* Replace render_partial with render :partial in scaffold generator [Nicholas Seckar] - -* Added -w flag to ps in process/reaper #1934 [Scott Barron] - -* Allow ERb in the database.yml file (just like with fixtures), so you can pull out the database configuration in environment variables #1822 [Duane Johnson] - -* Added convenience controls for FCGI processes (especially when managed remotely): spinner, spawner, and reaper. They reside in script/process. More details can be had by calling them with -h/--help. - -* Added load_fixtures task to the Rakefile, which will load all the fixtures into the database for the current environment #1791 [Marcel Molina Jr.] - -* Added an empty robots.txt to public/, so that web servers asking for it won't trigger a dynamic call, like favicon.ico #1738 [Michael Schubert] - -* Dropped the 'immediate close-down' of FCGI processes since it didn't work consistently and produced bad responses when it didn't. So now a TERM ensures exit after the next request (just as if the process is handling a request when it receives the signal). This means that you'll have to 'nudge' all FCGI processes with a request in order to ensure that they have all reloaded. This can be done by something like ./script/process/repear --nudge 'http://www.myapp.com' --instances 10, which will load the myapp site 10 times (and thus hit all of the 10 FCGI processes once, enough to shut down). - - -*0.13.1* (11 July, 2005) - -* Look for app-specific generators in RAILS_ROOT/generators rather than the clunky old RAILS_ROOT/script/generators. Nobody really uses this feature except for the unit tests, so it's a negligible-impact change. If you want to work with third-party generators, drop them in ~/.rails/generators or simply install gems. - -* Fixed that each request with the WEBrick adapter would open a new database connection #1685 [Sam Stephenson] - -* Added support for SQL Server in the database rake tasks #1652 [Ken Barker] Note: osql and scptxfr may need to be installed on your development environment. This involves getting the .exes and a .rll (scptxfr) from a production SQL Server (not developer level SQL Server). Add their location to your Environment PATH and you are all set. - -* Added a VERSION parameter to the migrate task that allows you to do "rake migrate VERSION=34" to migrate to the 34th version traveling up or down depending on the current version - -* Extend Ruby version check to include RUBY_RELEASE_DATE >= '2005-12-25', the final Ruby 1.8.2 release #1674 [court3nay] - -* Improved documentation for environment config files #1625 [court3nay] - - -*0.13.0* (6 July, 2005) - -* Changed the default logging level in config/environment.rb to INFO for production (so SQL statements won't be logged) - -* Added migration generator: ./script/generate migration add_system_settings - -* Added "migrate" as rake task to execute all the pending migrations from db/migrate - -* Fixed that model generator would make fixtures plural, even if ActiveRecord::Base.pluralize_table_names was false #1185 [Marcel Molina Jr.] - -* Added a DOCTYPE of HTML transitional to the HTML files generated by Rails #1124 [Michael Koziarski] - -* SIGTERM also gracefully exits dispatch.fcgi. Ignore SIGUSR1 on Windows. - -* Add the option to manually manage garbage collection in the FastCGI dispatcher. Set the number of requests between GC runs in your public/dispatch.fcgi [Stefan Kaes] - -* Allow dynamic application reloading for dispatch.fcgi processes by sending a SIGHUP. If the process is currently handling a request, the request will be allowed to complete first. This allows production fcgi's to be reloaded without having to restart them. - -* RailsFCGIHandler (dispatch.fcgi) no longer tries to explicitly flush $stdout (CgiProcess#out always calls flush) - -* Fixed rakefile actions against PostgreSQL when the password is all numeric #1462 [Michael Schubert] - -* ActionMailer::Base subclasses are reloaded with the other rails components #1262 - -* Made the WEBrick adapter not use a mutex around action performance if ActionController::Base.allow_concurrency is true (default is false) - -* Fixed that mailer generator generated fixtures/plural while units expected fixtures/singular #1457 [Scott Barron] - -* Added a 'whiny nil' that's aim to ensure that when users pass nil to methods where that isn't appropriate, instead of NoMethodError? and the name of some method used by the framework users will see a message explaining what type of object was expected. Only active in test and development environments by default #1209 [Michael Koziarski] - -* Fixed the test_helper.rb to be safe for requiring controllers from multiple spots, like app/controllers/article_controller.rb and app/controllers/admin/article_controller.rb, without reloading the environment twice #1390 [Nicholas Seckar] - -* Fixed Webrick to escape + characters in URL's the same way that lighttpd and apache do #1397 [Nicholas Seckar] - -* Added -e/--environment option to script/runner #1408 [François Beausoleil] - -* Modernize the scaffold generator to use the simplified render and test methods and to change style from @params["id"] to params[:id]. #1367 - -* Added graceful exit from pressing CTRL-C during the run of the rails command #1150 [Caleb Tennis] - -* Allow graceful exits for dispatch.fcgi processes by sending a SIGUSR1. If the process is currently handling a request, the request will be allowed to complete and then will terminate itself. If a request is not being handled, the process is terminated immediately (via #exit). This basically works like restart graceful on Apache. [Jamis Buck] - -* Made dispatch.fcgi more robust by catching fluke errors and retrying unless its a permanent condition. [Jamis Buck] - -* Added console --profile for profiling an IRB session #1154 [Jeremy Kemper] - -* Changed console_sandbox into console --sandbox #1154 [Jeremy Kemper] - - -*0.12.1* (20th April, 2005) - -* Upgraded to Active Record 1.10.1, Action Pack 1.8.1, Action Mailer 0.9.1, Action Web Service 0.7.1 - - -*0.12.0* (19th April, 2005) - -* Fixed that purge_test_database would use database settings from the development environment when recreating the test database #1122 [rails@cogentdude.com] - -* Added script/benchmarker to easily benchmark one or more statement a number of times from within the environment. Examples: - - # runs the one statement 10 times - script/benchmarker 10 'Person.expensive_method(10)' - - # pits the two statements against each other with 50 runs each - script/benchmarker 50 'Person.expensive_method(10)' 'Person.cheap_method(10)' - -* Added script/profiler to easily profile a single statement from within the environment. Examples: - - script/profiler 'Person.expensive_method(10)' - script/profiler 'Person.expensive_method(10)' 10 # runs the statement 10 times - -* Added Rake target clear_logs that'll truncate all the *.log files in log/ to zero #1079 [Lucas Carlson] - -* Added lazy typing for generate, such that ./script/generate cn == ./script/generate controller and the likes #1051 [k@v2studio.com] - -* Fixed that ownership is brought over in pg_dump during tests for PostgreSQL #1060 [pburleson] - -* Upgraded to Active Record 1.10.0, Action Pack 1.8.0, Action Mailer 0.9.0, Action Web Service 0.7.0, Active Support 1.0.4 - - -*0.11.1* (27th March, 2005) - -* Fixed the dispatch.fcgi use of a logger - -* Upgraded to Active Record 1.9.1, Action Pack 1.7.0, Action Mailer 0.8.1, Action Web Service 0.6.2, Active Support 1.0.3 - - -*0.11.0* (22th March, 2005) - -* Removed SCRIPT_NAME from the WEBrick environment to prevent conflicts with PATH_INFO #896 [Nicholas Seckar] - -* Removed ?$1 from the dispatch.f/cgi redirect line to get rid of 'complete/path/from/request.html' => nil being in the @params now that the ENV["REQUEST_URI"] is used to determine the path #895 [dblack/Nicholas Seckar] - -* Added additional error handling to the FastCGI dispatcher to catch even errors taking down the entire process - -* Improved the generated scaffold code a lot to take advantage of recent Rails developments #882 [Tobias Lütke] - -* Combined the script/environment.rb used for gems and regular files version. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar] - -* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Lütke] - -* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples: - - ./script/runner 'ReminderService.deliver' - ./script/runner 'Mailer.receive(STDIN.read)' - - This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code. - -* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [dave@cherryville.org] - -* Fixed the Rakefile's interaction with postgresql to: - - 1. Use PGPASSWORD and PGHOST in the environment to fix prompting for - passwords when connecting to a remote db and local socket connections. - 2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik] - 3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson] - 4. Use the port if available #875 [madrobby] - -* Upgraded to Active Record 1.9.0, Action Pack 1.6.0, Action Mailer 0.8.0, Action Web Service 0.6.1, Active Support 1.0.2 - - -*0.10.1* (7th March, 2005) - -* Fixed rake stats to ignore editor backup files like model.rb~ #791 [Sebastian Kanthak] - -* Added exception shallowing if the DRb server can't be started (not worth making a fuss about to distract new users) #779 [Tobias Lütke] - -* Added an empty favicon.ico file to the public directory of new applications (so the logs are not spammed by its absence) - -* Fixed that scaffold generator new template should use local variable instead of instance variable #778 [Dan Peterson] - -* Allow unit tests to run on a remote server for PostgreSQL #781 [adamm@galacticasoftware.com] - -* Added web_service generator (run ./script/generate web_service for help) #776 [Leon Bredt] - -* Added app/apis and components to code statistics report #729 [Scott Barron] - -* Fixed WEBrick server to use ABSOLUTE_RAILS_ROOT instead of working_directory #687 [Nicholas Seckar] - -* Fixed rails_generator to be usable without RubyGems #686 [Cristi BALAN] - -* Fixed -h/--help for generate and destroy generators #331 - -* Added begin/rescue around the FCGI dispatcher so no uncaught exceptions can bubble up to kill the process (logs to log/fastcgi.crash.log) - -* Fixed that association#count would produce invalid sql when called sequentialy #659 [kanis@comcard.de] - -* Fixed test/mocks/testing to the correct test/mocks/test #740 - -* Added early failure if the Ruby version isn't 1.8.2 or above #735 - -* Removed the obsolete -i/--index option from the WEBrick servlet #743 - -* Upgraded to Active Record 1.8.0, Action Pack 1.5.1, Action Mailer 0.7.1, Action Web Service 0.6.0, Active Support 1.0.1 - - -*0.10.0* (24th February, 2005) - -* Changed default IP binding for WEBrick from 127.0.0.1 to 0.0.0.0 so that the server is accessible both locally and remotely #696 [Marcel Molina Jr.] - -* Fixed that script/server -d was broken so daemon mode couldn't be used #687 [Nicholas Seckar] - -* Upgraded to breakpoint 92 which fixes: - - * overload IRB.parse_opts(), fixes #443 - => breakpoints in tests work even when running them via rake - * untaint handlers, might fix an issue discussed on the Rails ML - * added verbose mode to breakpoint_client - * less noise caused by breakpoint_client by default - * ignored TerminateLineInput exception in signal handler - => quiet exit on Ctrl-C - -* Added support for independent components residing in /components. Example: - - Controller: components/list/items_controller.rb - (holds a List::ItemsController class with uses_component_template_root called) - - Model : components/list/item.rb - (namespace is still shared, so an Item model in app/models will take precedence) - - Views : components/list/items/show.rhtml - - -* Added --sandbox option to script/console that'll roll back all changes made to the database when you quit #672 [Jeremy Kemper] - -* Added 'recent' as a rake target that'll run tests for files that changed in the last 10 minutes #612 [Jeremy Kemper] - -* Changed script/console to default to development environment and drop --no-inspect #650 [Jeremy Kemper] - -* Added that the 'fixture :posts' syntax can be used for has_and_belongs_to_many fixtures where a model doesn't exist #572 [Jeremy Kemper] - -* Added that running test_units and test_functional now performs the clone_structure_to_test as well #566 [rasputnik] - -* Added new generator framework that informs about its doings on generation and enables updating and destruction of generated artifacts. See the new script/destroy and script/update for more details #487 [Jeremy Kemper] - -* Added Action Web Service as a new add-on framework for Action Pack [Leon Bredt] - -* Added Active Support as an independent utility and standard library extension bundle - -* Upgraded to Active Record 1.7.0, Action Pack 1.5.0, Action Mailer 0.7.0 - - -*0.9.5* (January 25th, 2005) - -* Fixed dependency reloading by switching to a remove_const approach where all Active Records, Active Record Observers, and Action Controllers are reloading by undefining their classes. This enables you to remove methods in all three types and see the change reflected immediately and it fixes #539. This also means that only those three types of classes will benefit from the const_missing and reloading approach. If you want other classes (like some in lib/) to reload, you must use require_dependency to do it. - -* Added Florian Gross' latest version of Breakpointer and friends that fixes a variaty of bugs #441 [Florian Gross] - -* Fixed skeleton Rakefile to work with sqlite3 out of the box #521 [rasputnik] - -* Fixed that script/breakpointer didn't get the Ruby path rewritten as the other scripts #523 [brandt@kurowski.net] - -* Fixed handling of syntax errors in models that had already been succesfully required once in the current interpreter - -* Fixed that models that weren't referenced in associations weren't being reloaded in the development mode by reinstating the reload - -* Fixed that generate scaffold would produce bad functional tests - -* Fixed that FCGI can also display SyntaxErrors - -* Upgraded to Active Record 1.6.0, Action Pack 1.4.0 - - -*0.9.4.1* (January 18th, 2005) - -* Added 5-second timeout to WordNet alternatives on creating reserved-word models #501 [Marcel Molina Jr.] - -* Fixed binding of caller #496 [Alexey] - -* Upgraded to Active Record 1.5.1, Action Pack 1.3.1, Action Mailer 0.6.1 - - -*0.9.4* (January 17th, 2005) - -* Added that ApplicationController will catch a ControllerNotFound exception if someone attempts to access a url pointing to an unexisting controller [Tobias Lütke] - -* Flipped code-to-test ratio around to be more readable #468 [Scott Baron] - -* Fixed log file permissions to be 666 instead of 777 (so they're not executable) #471 [Lucas Carlson] - -* Fixed that auto reloading would some times not work or would reload the models twice #475 [Tobias Lütke] - -* Added rewrite rules to deal with caching to public/.htaccess - -* Added the option to specify a controller name to "generate scaffold" and made the default controller name the plural form of the model. - -* Added that rake clone_structure_to_test, db_structure_dump, and purge_test_database tasks now pick up the source database to use from - RAILS_ENV instead of just forcing development #424 [Tobias Lütke] - -* Fixed script/console to work with Windows (that requires the use of irb.bat) #418 [Chris McGrath] - -* Fixed WEBrick servlet slowdown over time by restricting the load path reloading to mod_ruby - -* Removed Fancy Indexing as a default option on the WEBrick servlet as it made it harder to use various caching schemes - -* Upgraded to Active Record 1.5, Action Pack 1.3, Action Mailer 0.6 - - -*0.9.3* (January 4th, 2005) - -* Added support for SQLite in the auto-dumping/importing of schemas for development -> test #416 - -* Added automated rewriting of the shebang lines on installs through the gem rails command #379 [Manfred Stienstra] - -* Added ActionMailer::Base.deliver_method = :test to the test environment so that mail objects are available in ActionMailer::Base.deliveries - for functional testing. - -* Added protection for creating a model through the generators with a name of an existing class, like Thread or Date. - It'll even offer you a synonym using wordnet.princeton.edu as a look-up. No, I'm not kidding :) [Florian Gross] - -* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that - the environment options needs to change from: - - Before in development.rb: - ActionController::Base.reload_dependencies = true   - ActiveRecord::Base.reload_associations     = true - - Now in development.rb: - Dependencies.mechanism = :load - - Before in production.rb and test.rb: - ActionController::Base.reload_dependencies = false - ActiveRecord::Base.reload_associations     = false - - Now in production.rb and test.rb: - Dependencies.mechanism = :require - -* Fixed problems with dependency caching and controller hierarchies on Ruby 1.8.2 in development mode #351 - -* Fixed that generated action_mailers doesnt need to require the action_mailer since thats already done in the environment #382 [Lucas Carlson] - -* Upgraded to Action Pack 1.2.0 and Active Record 1.4.0 - - -*0.9.2* - -* Fixed CTRL-C exists from the Breakpointer to be a clean affair without error dumping [Kent Sibilev] - -* Fixed "rake stats" to work with sub-directories in models and controllers and to report the code to test ration [Scott Baron] - -* Added that Active Record associations are now reloaded instead of cleared to work with the new const_missing hook in Active Record. - -* Added graceful handling of an inaccessible log file by redirecting output to STDERR with a warning #330 [rainmkr] - -* Added support for a -h/--help parameter in the generator #331 [Ulysses] - -* Fixed that File.expand_path in config/environment.rb would fail when dealing with symlinked public directories [mjobin] - -* Upgraded to Action Pack 1.1.0 and Active Record 1.3.0 - - -*0.9.1* - -* Upgraded to Action Pack 1.0.1 for important bug fix - -* Updated gem dependencies - - -*0.9.0* - -* Renamed public/dispatch.servlet to script/server -- it wasn't really dispatching anyway as its delegating calls to public/dispatch.rb - -* Renamed AbstractApplicationController and abstract_application.rb to ApplicationController and application.rb, so that it will be possible - for the framework to automatically pick up on app/views/layouts/application.rhtml and app/helpers/application.rb - -* Added script/console that makes it even easier to start an IRB session for interacting with the domain model. Run with no-args to - see help. - -* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in - the code, investigate and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find_all - breakpoint "Breaking out from the list" - end - end - - So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window. - Here you can do things like: - - Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - - ...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - - Finally, when you're ready to resume execution, you press CTRL-D - -* Changed environments to be configurable through an environment variable. By default, the environment is "development", but you - can change that and set your own by configuring the Apache vhost with a string like (mod_env must be available on the server): - - SetEnv RAILS_ENV production - - ...if you're using WEBrick, you can pick the environment to use with the command-line parameters -e/--environment, like this: - - ruby public/dispatcher.servlet -e production - -* Added a new default environment called "development", which leaves the production environment to be tuned exclusively for that. - -* Added a start_server in the root of the Rails application to make it even easier to get started - -* Fixed public/.htaccess to use RewriteBase and share the same rewrite rules for all the dispatch methods - -* Fixed webrick_server to handle requests in a serialized manner (the Rails reloading infrastructure is not thread-safe) - -* Added support for controllers in directories. So you can have: - - app/controllers/account_controller.rb # URL: /account/ - app/controllers/admin/account_controller.rb # URL: /admin/account/ - - NOTE: You need to update your public/.htaccess with the new rules to pick it up - -* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use - those environments for development. This is turned on by default, but can be turned off with - ActiveRecord::Base.reload_associations = false and ActionController::Base.reload_dependencies = false in production environments. - -* Added support for sub-directories in app/models. So now you can have something like Basecamp with: - - app/models/accounting - app/models/project - app/models/participants - app/models/settings - - It's poor man's namespacing, but only for file-system organization. You still require files just like before. - Nothing changes inside the files themselves. - - -* Fixed a few references in the tests generated by new_mailer [Jeremy Kemper] - -* Added support for mocks in testing with test/mocks - -* Cleaned up the environments a bit and added global constant RAILS_ROOT - - -*0.8.5* (9) - -* Made dev-util available to all tests, so you can insert breakpoints in any test case to get an IRB prompt at that point [Jeremy Kemper]: - - def test_complex_stuff - @david.projects << @new_project - breakpoint "Let's have a closer look at @david" - end - - You need to install dev-utils yourself for this to work ("gem install dev-util"). - -* Added shared generator behavior so future upgrades should be possible without manually copying over files [Jeremy Kemper] - -* Added the new helper style to both controller and helper templates [Jeremy Kemper] - -* Added new_crud generator for creating a model and controller at the same time with explicit scaffolding [Jeremy Kemper] - -* Added configuration of Test::Unit::TestCase.fixture_path to test_helper to concide with the new AR fixtures style - -* Fixed that new_model was generating singular table/fixture names - -* Upgraded to Action Mailer 0.4.0 - -* Upgraded to Action Pack 0.9.5 - -* Upgraded to Active Record 1.1.0 - - -*0.8.0 (15)* - -* Removed custom_table_name option for new_model now that the Inflector is as powerful as it is - -* Changed the default rake action to just do testing and separate API generation and coding statistics into a "doc" task. - -* Fixed WEBrick dispatcher to handle missing slashes in the URLs gracefully [alexey] - -* Added user option for all postgresql tool calls in the rakefile [elvstone] - -* Fixed problem with running "ruby public/dispatch.servlet" instead of "cd public; ruby dispatch.servlet" [alexey] - -* Fixed WEBrick server so that it no longer hardcodes the ruby interpreter used to "ruby" but will get the one used based - on the Ruby runtime configuration. [Marcel Molina Jr.] - -* Fixed Dispatcher so it'll route requests to magic_beans to MagicBeansController/magic_beans_controller.rb [Caio Chassot] - -* "new_controller MagicBeans" and "new_model SubscriptionPayments" will now both behave properly as they use the new Inflector. - -* Fixed problem with MySQL foreign key constraint checks in Rake :clone_production_structure_to_test target [Andreas Schwarz] - -* Changed WEBrick server to by default be auto-reloading, which is slower but makes source changes instant. - Class compilation cache can be turned on with "-c" or "--cache-classes". - -* Added "-b/--binding" option to WEBrick dispatcher to bind the server to a specific IP address (default: 127.0.0.1) [Kevin Temp] - -* dispatch.fcgi now DOESN'T set FCGI_PURE_RUBY as it was slowing things down for now reason [Andreas Schwarz] - -* Added new_mailer generator to work with Action Mailer - -* Included new framework: Action Mailer 0.3 - -* Upgraded to Action Pack 0.9.0 - -* Upgraded to Active Record 1.0.0 - - -*0.7.0* - -* Added an optional second argument to the new_model script that allows the programmer to specify the table name, - which will used to generate a custom table_name method in the model and will also be used in the creation of fixtures. - [Kevin Radloff] - -* script/new_model now turns AccountHolder into account_holder instead of accountholder [Kevin Radloff] - -* Fixed the faulty handleing of static files with WEBrick [Andreas Schwarz] - -* Unified function_test_helper and unit_test_helper into test_helper - -* Fixed bug with the automated production => test database dropping on PostgreSQL [dhawkins] - -* create_fixtures in both the functional and unit test helper now turns off the log during fixture generation - and can generate more than one fixture at a time. Which makes it possible for assignments like: - - @people, @projects, @project_access, @companies, @accounts = - create_fixtures "people", "projects", "project_access", "companies", "accounts" - -* Upgraded to Action Pack 0.8.5 (locally-scoped variables, partials, advanced send_file) - -* Upgraded to Active Record 0.9.5 (better table_name guessing, cloning, find_all_in_collection) - - -*0.6.5* - -* No longer specifies a template for rdoc, so it'll use whatever is default (you can change it in the rakefile) - -* The new_model generator will now use the same rules for plural wordings as Active Record - (so Category will give categories, not categorys) [Kevin Radloff] - -* dispatch.fcgi now sets FCGI_PURE_RUBY to true to ensure that it's the Ruby version that's loaded [danp] - -* Made the GEM work with Windows - -* Fixed bug where mod_ruby would "forget" the load paths added when switching between controllers - -* PostgreSQL are now supported for the automated production => test database dropping [Kevin Radloff] - -* Errors thrown by the dispatcher are now properly handled in FCGI. - -* Upgraded to Action Pack 0.8.0 (lots and lots and lots of fixes) - -* Upgraded to Active Record 0.9.4 (a bunch of fixes) - - -*0.6.0* - -* Added AbstractionApplicationController as a superclass for all controllers generated. This class can be used - to carry filters and methods that are to be shared by all. It has an accompanying ApplicationHelper that all - controllers will also automatically have available. - -* Added environments that can be included from any script to get the full Active Record and Action Controller - context running. This can be used by maintenance scripts or to interact with the model through IRB. Example: - - require 'config/environments/production' - - for account in Account.find_all - account.recalculate_interests - end - - A short migration script for an account model that had it's interest calculation strategy changed. - -* Accessing the index of a controller with "/weblog" will now redirect to "/weblog/" (only on Apache, not WEBrick) - -* Simplified the default Apache config so even remote requests are served off CGI as a default. - You'll now have to do something specific to activate mod_ruby and FCGI (like using the force urls). - This should make it easier for new comers that start on an external server. - -* Added more of the necessary Apache options to .htaccess to make it easier to setup - -* Upgraded to Action Pack 0.7.9 (lots of fixes) - -* Upgraded to Active Record 0.9.3 (lots of fixes) - - -*0.5.7* - -* Fixed bug in the WEBrick dispatcher that prevented it from getting parameters from the URL - (through GET requests or otherwise) - -* Added lib in root as a place to store app specific libraries - -* Added lib and vendor to load_path, so anything store within can be loaded directly. - Hence lib/redcloth.rb can be loaded with require "redcloth" - -* Upgraded to Action Pack 0.7.8 (lots of fixes) - -* Upgraded to Active Record 0.9.2 (minor upgrade) - - -*0.5.6* - -* Upgraded to Action Pack 0.7.7 (multipart form fix) - -* Updated the generated template stubs to valid XHTML files - -* Ensure that controllers generated are capitalized, so "new_controller TodoLists" - gives the same as "new_controller Todolists" and "new_controller todolists". - - -*0.5.5* - -* Works on Windows out of the box! (Dropped symlinks) - -* Added webrick dispatcher: Try "ruby public/dispatch.servlet --help" [Florian Gross] - -* Report errors about initialization to browser (instead of attempting to use uninitialized logger) - -* Upgraded to Action Pack 0.7.6 - -* Upgraded to Active Record 0.9.1 - -* Added distinct 500.html instead of reusing 404.html - -* Added MIT license - - -*0.5.0* - -* First public release diff --git a/vendor/rails/railties/MIT-LICENSE b/vendor/rails/railties/MIT-LICENSE deleted file mode 100644 index 86bcb23b..00000000 --- a/vendor/rails/railties/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2004-2010 David Heinemeier Hansson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/rails/railties/README b/vendor/rails/railties/README deleted file mode 100644 index 37ec8ea2..00000000 --- a/vendor/rails/railties/README +++ /dev/null @@ -1,243 +0,0 @@ -== Welcome to Rails - -Rails is a web-application framework that includes everything needed to create -database-backed web applications according to the Model-View-Control pattern. - -This pattern splits the view (also called the presentation) into "dumb" templates -that are primarily responsible for inserting pre-built data in between HTML tags. -The model contains the "smart" domain objects (such as Account, Product, Person, -Post) that holds all the business logic and knows how to persist themselves to -a database. The controller handles the incoming requests (such as Save New Account, -Update Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting Started - -1. At the command prompt, start a new Rails application using the <tt>rails</tt> command - and your application name. Ex: rails myapp -2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options) -3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!" -4. Follow the guidelines to start developing your application - - -== Web Servers - -By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails -with a variety of other web servers. - -Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is -suitable for development and deployment of Rails applications. If you have Ruby Gems installed, -getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>. -More info at: http://mongrel.rubyforge.org - -Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or -Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use -FCGI or proxy to a pack of Mongrels/Thin/Ebb servers. - -== Apache .htaccess example for FCGI/CGI - -# General Apache options -AddHandler fastcgi-script .fcgi -AddHandler cgi-script .cgi -Options +FollowSymLinks +ExecCGI - -# If you don't want Rails to look in certain directories, -# use the following rewrite rules so that Apache won't rewrite certain requests -# -# Example: -# RewriteCond %{REQUEST_URI} ^/notrails.* -# RewriteRule .* - [L] - -# Redirect all requests not available on the filesystem to Rails -# By default the cgi dispatcher is used which is very slow -# -# For better performance replace the dispatcher with the fastcgi one -# -# Example: -# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] -RewriteEngine On - -# If your Rails application is accessed via an Alias directive, -# then you MUST also set the RewriteBase in this htaccess file. -# -# Example: -# Alias /myrailsapp /path/to/myrailsapp/public -# RewriteBase /myrailsapp - -RewriteRule ^$ index.html [QSA] -RewriteRule ^([^.]+)$ $1.html [QSA] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ dispatch.cgi [QSA,L] - -# In case Rails experiences terminal errors -# Instead of displaying this message you can supply a file here which will be rendered instead -# -# Example: -# ErrorDocument 500 /500.html - -ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly" - - -== Debugging Rails - -Sometimes your application goes wrong. Fortunately there are a lot of tools that -will help you debug it and get it back on the rails. - -First area to check is the application log files. Have "tail -f" commands running -on the server.log and development.log. Rails will automatically display debugging -and runtime information to these files. Debugging info will also be shown in the -browser on requests from 127.0.0.1. - -You can also log your own messages directly into the log file from your code using -the Ruby logger class from inside your controllers. Example: - - class WeblogController < ActionController::Base - def destroy - @weblog = Weblog.find(params[:id]) - @weblog.destroy - logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") - end - end - -The result will be a message in your log file along the lines of: - - Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1 - -More information on how to use the logger is at http://www.ruby-doc.org/core/ - -Also, Ruby documentation can be found at http://www.ruby-lang.org/ including: - -* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/ -* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) - -These two online (and free) books will bring you up to speed on the Ruby language -and also on programming in general. - - -== Debugger - -Debugger support is available through the debugger command when you start your Mongrel or -Webrick server with --debugger. This means that you can break out of execution at any point -in the code, investigate and change the model, AND then resume execution! -You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug' -Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find(:all) - debugger - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the server window. Here you can do things like: - - >> @posts.inspect - => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a debugger" - => "hello from a debugger" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you enter "cont" - - -== Console - -You can interact with the domain model by starting the console through <tt>script/console</tt>. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like <tt>script/console production</tt>. - -To reload your controllers and models after launching the console run <tt>reload!</tt> - -== dbconsole - -You can go to the command line of your database directly through <tt>script/dbconsole</tt>. -You would be connected to the database with the credentials defined in database.yml. -Starting the script without arguments will connect you to the development database. Passing an -argument will connect you to a different database, like <tt>script/dbconsole production</tt>. -Currently works for mysql, postgresql and sqlite. - -== Description of Contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from ApplicationController - which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby - syntax. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the common - header/footer method of wrapping views. In your views, define a layout using the - <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb, - call <% yield %> to render the view using this layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are generated - for you automatically when using script/generate for controllers. Helpers can be used to - wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -db - Contains the database schema in schema.rb. db/migrate contains all - the sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when generated - using <tt>rake doc:app</tt> - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. This should be - set as the DOCUMENT_ROOT of your web server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the script/generate scripts, template - test files will be generated for you and placed in this directory. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - If the app has frozen rails, those gems also go here, under vendor/rails/. - This directory is in the load path. diff --git a/vendor/rails/railties/Rakefile b/vendor/rails/railties/Rakefile deleted file mode 100644 index c3d8eeb7..00000000 --- a/vendor/rails/railties/Rakefile +++ /dev/null @@ -1,365 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rdoc/task' -require 'rubygems/package_task' - -require 'date' -require 'rbconfig' - -require File.join(File.dirname(__FILE__), 'lib/rails', 'version') - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'rails' -PKG_VERSION = Rails::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" -PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "rails" -RUBY_FORGE_USER = "webster132" - - -task :default => :test - -## This is required until the regular test task -## below passes. It's not ideal, but at least -## we can see the failures -task :test do - Dir['test/**/*_test.rb'].all? do |file| - ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) - system(ruby, '-Itest', file) - end or raise "Failures" -end - -Rake::TestTask.new("regular_test") do |t| - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.warning = true - t.verbose = true -end - - -BASE_DIRS = %w( - app - config/environments - config/initializers - config/locales - db - doc - log - lib - lib/tasks - public - script - script/performance - test - vendor - vendor/plugins - tmp/sessions - tmp/cache - tmp/sockets - tmp/pids -) - -APP_DIRS = %w( models controllers helpers views views/layouts ) -PUBLIC_DIRS = %w( images javascripts stylesheets ) -TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test ) - -LOG_FILES = %w( server.log development.log test.log production.log ) -HTML_FILES = %w( 422.html 404.html 500.html index.html robots.txt favicon.ico images/rails.png - javascripts/prototype.js javascripts/application.js - javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js ) -BIN_FILES = %w( about console destroy generate performance/benchmarker performance/profiler runner server plugin ) - -VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport activeresource railties ) - - -desc "Generates a fresh Rails package with documentation" -task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ] - -desc "Generates a fresh Rails package using GEMs with documentation" -task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ] - -desc "Generates a fresh Rails package without documentation (faster)" -task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ] - -desc "Generates a fresh Rails package without documentation (faster)" -task :fresh_rails_without_docs_using_links => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ] - -desc "Generates minimal Rails package using symlinks" -task :dev => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ] - -desc "Packages the fresh Rails package with documentation" -task :package => [ :clean, :fresh_rails ] do - system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}} - system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}} -end - -task :clean do - rm_rf PKG_DESTINATION -end - -# Get external spinoffs ------------------------------------------------------------------- - -desc "Updates railties to the latest version of the javascript spinoffs" -task :update_js do - for js in %w( prototype controls dragdrop effects ) - rm "html/javascripts/#{js}.js" - cp "./../actionpack/lib/action_view/helpers/javascripts/#{js}.js", "html/javascripts" - end -end - -# Make directory structure ---------------------------------------------------------------- - -def make_dest_dirs(dirs, path = '.') - mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path.to_s, dir) } -end - -desc "Make the directory structure for the new Rails application" -task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ] - -task(:make_base_dirs) { make_dest_dirs BASE_DIRS } -task(:make_app_dirs) { make_dest_dirs APP_DIRS, 'app' } -task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public' } -task(:make_test_dirs) { make_dest_dirs TEST_DIRS, 'test' } - - -# Initialize file stubs ------------------------------------------------------------------- - -desc "Initialize empty file stubs (such as for logging)" -task :initialize_file_stubs => [ :initialize_log_files ] - -task :initialize_log_files do - log_dir = File.join(PKG_DESTINATION, 'log') - chmod 0777, log_dir - LOG_FILES.each do |log_file| - log_path = File.join(log_dir, log_file) - touch log_path - chmod 0666, log_path - end -end - - -# Copy Vendors ---------------------------------------------------------------------------- - -desc "Copy in all the Rails packages to vendor" -task :copy_vendor_libraries do - mkdir File.join(PKG_DESTINATION, 'vendor', 'rails') - VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) } - FileUtils.rm_r(Dir.glob(File.join(PKG_DESTINATION, 'vendor', 'rails', "**", ".svn"))) -end - -desc "Link in all the Rails packages to vendor" -task :link_vendor_libraries do - mkdir File.join(PKG_DESTINATION, 'vendor', 'rails') - VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) } -end - - -# Copy Ties Content ----------------------------------------------------------------------- - -desc "Make copies of all the default content of ties" -task :copy_ties_content => [ - :copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application, - :copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ] - -task :copy_dispatches do - copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb" - - copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi" - - copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi" -end - -task :copy_html_files do - HTML_FILES.each { |file| cp File.join('html', file), File.join(PKG_DESTINATION, 'public', file) } -end - -task :copy_application do - cp "helpers/application_controller.rb", "#{PKG_DESTINATION}/app/controllers/application_controller.rb" - cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb" -end - -task :copy_configs do - app_name = "rails" - socket = nil - require 'erb' - File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/databases/sqlite3.yml"), nil, '-').result(binding)} - - cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb" - - cp "configs/initializers/backtrace_silencers.rb", "#{PKG_DESTINATION}/config/initializers/backtrace_silencers.rb" - cp "configs/initializers/inflections.rb", "#{PKG_DESTINATION}/config/initializers/inflections.rb" - cp "configs/initializers/mime_types.rb", "#{PKG_DESTINATION}/config/initializers/mime_types.rb" - cp "configs/initializers/new_rails_defaults.rb", "#{PKG_DESTINATION}/config/initializers/new_rails_defaults.rb" - - cp "configs/locales/en.yml", "#{PKG_DESTINATION}/config/locales/en.yml" - - cp "configs/seeds.rb", "#{PKG_DESTINATION}/db/seeds.rb" - - cp "environments/boot.rb", "#{PKG_DESTINATION}/config/boot.rb" - File.open("#{PKG_DESTINATION}/config/environment.rb", 'w') {|f| f.write ERB.new(IO.read("environments/environment.rb"), nil, '-').result(binding)} - cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb" - cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb" - cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb" - -end - -task :copy_binfiles do - BIN_FILES.each do |file| - dest_file = File.join(PKG_DESTINATION, 'script', file) - copy_with_rewritten_ruby_path(File.join('bin', file), dest_file) - chmod 0755, dest_file - end -end - -task :copy_rootfiles do - cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile" - cp "README", "#{PKG_DESTINATION}/README" - cp "CHANGELOG", "#{PKG_DESTINATION}/CHANGELOG" -end - -task :copy_test_helpers do - cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb" -end - -task :copy_app_doc_readme do - cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP" -end - -def copy_with_rewritten_ruby_path(src_file, dest_file) - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - - File.open(dest_file, 'w') do |df| - File.open(src_file) do |sf| - line = sf.gets - if (line =~ /#!.+ruby\s*/) != nil - df.puts("#!#{ruby}") - else - df.puts(line) - end - df.write(sf.read) - end - end -end - -desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"' -task :generate_guides do - ruby "guides/rails_guides.rb" -end - - -# Generate documentation ------------------------------------------------------------------ - -desc "Generate documentation for the framework and for the empty application" -task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ] - -task :generate_rails_framework_doc do - system %{cd #{PKG_DESTINATION}; rake doc:rails} -end - -task :generate_app_doc do - cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP" - system %{cd #{PKG_DESTINATION}; rake doc:app} -end - -RDoc::Task.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Railties -- Gluing the Engine to the Rails" - rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'CHANGELOG') - rdoc.rdoc_files.include('lib/*.rb') - rdoc.rdoc_files.include('lib/rails/*.rb') - rdoc.rdoc_files.include('lib/rails_generator/*.rb') - rdoc.rdoc_files.include('lib/commands/**/*.rb') -} - -# Generate GEM ---------------------------------------------------------------------------- - -task :copy_gem_environment do - cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb" - chmod 0755, dest_file -end - - -PKG_FILES = FileList[ - '[a-zA-Z]*', - 'bin/**/*', - 'builtin/**/*', - 'configs/**/*', - 'doc/**/*', - 'dispatches/**/*', - 'environments/**/*', - 'helpers/**/*', - 'generators/**/*', - 'html/**/*', - 'lib/**/*' -] - [ 'test' ] - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'rails' - s.version = PKG_VERSION - s.summary = "Web-application framework with template engine, control-flow layer, and ORM." - s.description = <<-EOF - Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick - on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. - EOF - - s.add_dependency('rake', '>= 0.8.3') - s.add_dependency('activesupport', '= 2.3.14' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.3.14' + PKG_BUILD) - s.add_dependency('actionpack', '= 2.3.14' + PKG_BUILD) - s.add_dependency('actionmailer', '= 2.3.14' + PKG_BUILD) - s.add_dependency('activeresource', '= 2.3.14' + PKG_BUILD) - - s.rdoc_options << '--exclude' << '.' - - s.files = PKG_FILES - s.require_path = 'lib' - s.bindir = "bin" # Use these for applications. - s.executables = ["rails"] - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "rails" -end - -Gem::PackageTask.new(spec) do |pkg| - pkg.gem_spec = spec -end - - -# Publishing ------------------------------------------------------- -desc "Publish the rails gem" -task :pgem => [:gem] do - Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` -end - -desc "Publish the guides" -task :pguides => :generate_guides do - mkdir_p 'pkg' - `tar -czf pkg/guides.gz guides/output` - Rake::SshFilePublisher.new("web.rubyonrails.org", "/u/sites/guides.rubyonrails.org/public", "pkg", "guides.gz").upload - `ssh web.rubyonrails.org 'cd /u/sites/guides.rubyonrails.org/public/ && tar -xvzf guides.gz && mv guides/output/* . && rm -rf guides*'` -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - require 'rake/contrib/rubyforgepublisher' - require 'rubyforge' - - packages = %w( gem ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" } - - rubyforge = RubyForge.new - rubyforge.login - rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages) -end diff --git a/vendor/rails/railties/bin/about b/vendor/rails/railties/bin/about deleted file mode 100755 index 1eeb6eb9..00000000 --- a/vendor/rails/railties/bin/about +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" -require 'commands/about' diff --git a/vendor/rails/railties/bin/console b/vendor/rails/railties/bin/console deleted file mode 100755 index 235a1f27..00000000 --- a/vendor/rails/railties/bin/console +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/console' diff --git a/vendor/rails/railties/bin/dbconsole b/vendor/rails/railties/bin/dbconsole deleted file mode 100755 index 83c8436a..00000000 --- a/vendor/rails/railties/bin/dbconsole +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/dbconsole' diff --git a/vendor/rails/railties/bin/destroy b/vendor/rails/railties/bin/destroy deleted file mode 100755 index 88d295f7..00000000 --- a/vendor/rails/railties/bin/destroy +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/destroy' diff --git a/vendor/rails/railties/bin/generate b/vendor/rails/railties/bin/generate deleted file mode 100755 index 62a8a4c0..00000000 --- a/vendor/rails/railties/bin/generate +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/generate' diff --git a/vendor/rails/railties/bin/performance/benchmarker b/vendor/rails/railties/bin/performance/benchmarker deleted file mode 100755 index 3bff809f..00000000 --- a/vendor/rails/railties/bin/performance/benchmarker +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../../config/boot', __FILE__) -require 'commands/performance/benchmarker' diff --git a/vendor/rails/railties/bin/performance/profiler b/vendor/rails/railties/bin/performance/profiler deleted file mode 100755 index 07640575..00000000 --- a/vendor/rails/railties/bin/performance/profiler +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../../config/boot', __FILE__) -require 'commands/performance/profiler' diff --git a/vendor/rails/railties/bin/plugin b/vendor/rails/railties/bin/plugin deleted file mode 100755 index b82201fa..00000000 --- a/vendor/rails/railties/bin/plugin +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/plugin' diff --git a/vendor/rails/railties/bin/rails b/vendor/rails/railties/bin/rails deleted file mode 100755 index 728d0544..00000000 --- a/vendor/rails/railties/bin/rails +++ /dev/null @@ -1,21 +0,0 @@ -$:.unshift File.expand_path("../../lib", __FILE__) - -require 'ruby_version_check' -Signal.trap("INT") { puts; exit } - -require 'rails/version' -if %w(--version -v).include? ARGV.first - puts "Rails #{Rails::VERSION::STRING}" - exit(0) -end - -freeze = ARGV.any? { |option| %w(--freeze -f).include?(option) } -app_path = ARGV.first - -require 'rails_generator' -require 'rails_generator/scripts/generate' - -Rails::Generator::Base.use_application_sources! -Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app') - -Dir.chdir(app_path) { `rake rails:freeze:gems`; puts "froze" } if freeze \ No newline at end of file diff --git a/vendor/rails/railties/bin/runner b/vendor/rails/railties/bin/runner deleted file mode 100755 index be4c5d45..00000000 --- a/vendor/rails/railties/bin/runner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/runner' diff --git a/vendor/rails/railties/bin/server b/vendor/rails/railties/bin/server deleted file mode 100755 index b9fcb717..00000000 --- a/vendor/rails/railties/bin/server +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) -require 'commands/server' diff --git a/vendor/rails/railties/builtin/rails_info/rails/info.rb b/vendor/rails/railties/builtin/rails_info/rails/info.rb deleted file mode 100644 index b2799f09..00000000 --- a/vendor/rails/railties/builtin/rails_info/rails/info.rb +++ /dev/null @@ -1,131 +0,0 @@ -module Rails - module Info - mattr_accessor :properties - class << (@@properties = []) - def names - map &:first - end - - def value_for(property_name) - if property = assoc(property_name) - property.last - end - end - end - - class << self #:nodoc: - def property(name, value = nil) - value ||= yield - properties << [name, value] if value - rescue Exception - end - - def frameworks - %w( active_record action_pack active_resource action_mailer active_support ) - end - - def framework_version(framework) - if Object.const_defined?(framework.classify) - require "#{framework}/version" - "#{framework.classify}::VERSION::STRING".constantize - end - end - - def edge_rails_revision(info = git_info) - info[/commit ([a-z0-9-]+)/, 1] || freeze_edge_version - end - - def freeze_edge_version - if File.exist?(rails_vendor_root) - begin - File.readlines(File.join(rails_vendor_root,'REVISION')).first.strip - rescue - Dir[File.join(rails_vendor_root, 'TAG_*')].first.scan(/_(.+)$/).first.first rescue 'unknown' - end - end - end - - def to_s - column_width = properties.names.map {|name| name.length}.max - ["About your application's environment", *properties.map do |property| - "%-#{column_width}s %s" % property - end] * "\n" - end - - alias inspect to_s - - def to_html - '<table>'.tap do |table| - properties.each do |(name, value)| - table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>) - table << %(<td class="value">#{CGI.escapeHTML(value.to_s)}</td></tr>) - end - table << '</table>' - end - end - - protected - def rails_vendor_root - @rails_vendor_root ||= "#{RAILS_ROOT}/vendor/rails" - end - - def git_info - env_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C' - Dir.chdir(rails_vendor_root) do - silence_stderr { `git log -n 1` } - end - ensure - ENV['LC_ALL'] = env_lang - end - end - - # The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)". - property 'Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})" - - # The RubyGems version, if it's installed. - property 'RubyGems version' do - Gem::RubyGemsVersion - end - - property 'Rack version' do - ::Rack.release - end - - # The Rails version. - property 'Rails version' do - Rails::VERSION::STRING - end - - # Versions of each Rails framework (Active Record, Action Pack, - # Active Resource, Action Mailer, and Active Support). - frameworks.each do |framework| - property "#{framework.titlecase} version" do - framework_version(framework) - end - end - - # The Rails Git revision, if it's checked out into vendor/rails. - property 'Edge Rails revision' do - edge_rails_revision - end - - # The application's location on the filesystem. - property 'Application root' do - File.expand_path(RAILS_ROOT) - end - - # The current Rails environment (development, test, or production). - property 'Environment' do - RAILS_ENV - end - - # The name of the database adapter for the current environment. - property 'Database adapter' do - ActiveRecord::Base.configurations[RAILS_ENV]['adapter'] - end - - property 'Database schema version' do - ActiveRecord::Migrator.current_version rescue nil - end - end -end diff --git a/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb b/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb deleted file mode 100644 index 05745d60..00000000 --- a/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Rails::InfoController < ActionController::Base - def properties - if consider_all_requests_local || local_request? - render :inline => Rails::Info.to_html - else - render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500 - end - end -end diff --git a/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb b/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb deleted file mode 100644 index e5605a8d..00000000 --- a/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Rails::InfoHelper -end diff --git a/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb b/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb deleted file mode 100644 index 2009eb3a..00000000 --- a/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Alias to ensure old public.html still works. -RailsInfoController = Rails::InfoController diff --git a/vendor/rails/railties/configs/databases/frontbase.yml b/vendor/rails/railties/configs/databases/frontbase.yml deleted file mode 100644 index c0c3588b..00000000 --- a/vendor/rails/railties/configs/databases/frontbase.yml +++ /dev/null @@ -1,28 +0,0 @@ -# FrontBase versions 4.x -# -# Get the bindings: -# gem install ruby-frontbase - -development: - adapter: frontbase - host: localhost - database: <%= app_name %>_development - username: <%= app_name %> - password: '' - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: frontbase - host: localhost - database: <%= app_name %>_test - username: <%= app_name %> - password: '' - -production: - adapter: frontbase - host: localhost - database: <%= app_name %>_production - username: <%= app_name %> - password: '' diff --git a/vendor/rails/railties/configs/databases/ibm_db.yml b/vendor/rails/railties/configs/databases/ibm_db.yml deleted file mode 100644 index a9716ddb..00000000 --- a/vendor/rails/railties/configs/databases/ibm_db.yml +++ /dev/null @@ -1,62 +0,0 @@ -# IBM Dataservers -# -# Home Page -# http://rubyforge.org/projects/rubyibm/ -# -# To install the ibm_db gem: -# On Linux: -# Source the db2profile file and set the necessary environment variables: -# -# . /home/db2inst1/sqllib/db2profile -# export IBM_DB_DIR=/opt/ibm/db2/V9.1 -# export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32 -# -# Then issue the command: gem install ibm_db -# -# On Windows: -# Issue the command: gem install ibm_db -# If prompted, select the mswin32 option -# -# For more details on the installation refer to http://rubyforge.org/docman/view.php/2361/7682/IBM_DB_GEM.pdf -# -# For more details on the connection parameters below refer to: -# http://rubyibm.rubyforge.org/docs/adapter/0.9.0/rdoc/classes/ActiveRecord/ConnectionAdapters/IBM_DBAdapter.html - -development: - adapter: ibm_db - username: db2inst1 - password: - database: <%= app_name[0,4] %>_dev - #schema: db2inst1 - #host: localhost - #port: 50000 - #account: my_account - #app_user: my_app_user - #application: my_application - #workstation: my_workstation - -test: - adapter: ibm_db - username: db2inst1 - password: - database: <%= app_name[0,4] %>_tst - #schema: db2inst1 - #host: localhost - #port: 50000 - #account: my_account - #app_user: my_app_user - #application: my_application - #workstation: my_workstation - -production: - adapter: ibm_db - username: db2inst1 - password: - database: <%= app_name[0,4] %>_prd - #schema: db2inst1 - #host: localhost - #port: 50000 - #account: my_account - #app_user: my_app_user - #application: my_application - #workstation: my_workstation \ No newline at end of file diff --git a/vendor/rails/railties/configs/databases/mysql.yml b/vendor/rails/railties/configs/databases/mysql.yml deleted file mode 100644 index 1a14bfb3..00000000 --- a/vendor/rails/railties/configs/databases/mysql.yml +++ /dev/null @@ -1,60 +0,0 @@ -# MySQL. Versions 4.1 and 5.0 are recommended. -# -# Install the MySQL driver: -# gem install mysql -# On Mac OS X: -# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql -# On Mac OS X Leopard: -# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config -# This sets the ARCHFLAGS environment variable to your native architecture -# On Windows: -# gem install mysql -# Choose the win32 build. -# Install MySQL and put its /bin directory on your path. -# -# And be sure to use new-style password hashing: -# http://dev.mysql.com/doc/refman/5.0/en/old-client.html -development: - adapter: mysql - encoding: utf8 - reconnect: false - database: <%= app_name %>_development - pool: 5 - username: root - password: -<% if socket -%> - socket: <%= socket %> -<% else -%> - host: localhost -<% end -%> - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: mysql - encoding: utf8 - reconnect: false - database: <%= app_name %>_test - pool: 5 - username: root - password: -<% if socket -%> - socket: <%= socket %> -<% else -%> - host: localhost -<% end -%> - -production: - adapter: mysql - encoding: utf8 - reconnect: false - database: <%= app_name %>_production - pool: 5 - username: root - password: -<% if socket -%> - socket: <%= socket %> -<% else -%> - host: localhost -<% end -%> diff --git a/vendor/rails/railties/configs/databases/oracle.yml b/vendor/rails/railties/configs/databases/oracle.yml deleted file mode 100644 index a1883f62..00000000 --- a/vendor/rails/railties/configs/databases/oracle.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Oracle/OCI 8i, 9, 10g -# -# Requires Ruby/OCI8: -# http://rubyforge.org/projects/ruby-oci8/ -# -# Specify your database using any valid connection syntax, such as a -# tnsnames.ora service name, or a SQL connect url string of the form: -# -# //host:[port][/service name] -# -# By default prefetch_rows (OCI_ATTR_PREFETCH_ROWS) is set to 100. And -# until true bind variables are supported, cursor_sharing is set by default -# to 'similar'. Both can be changed in the configation below; the defaults -# are equivalent to specifying: -# -# prefetch_rows: 100 -# cursor_sharing: similar -# - -development: - adapter: oracle - database: <%= app_name %>_development - username: <%= app_name %> - password: - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: oracle - database: <%= app_name %>_test - username: <%= app_name %> - password: - -production: - adapter: oracle - database: <%= app_name %>_production - username: <%= app_name %> - password: diff --git a/vendor/rails/railties/configs/databases/postgresql.yml b/vendor/rails/railties/configs/databases/postgresql.yml deleted file mode 100644 index f600e054..00000000 --- a/vendor/rails/railties/configs/databases/postgresql.yml +++ /dev/null @@ -1,51 +0,0 @@ -# PostgreSQL. Versions 7.4 and 8.x are supported. -# -# Install the ruby-postgres driver: -# gem install ruby-postgres -# On Mac OS X: -# gem install ruby-postgres -- --include=/usr/local/pgsql -# On Windows: -# gem install ruby-postgres -# Choose the win32 build. -# Install PostgreSQL and put its /bin directory on your path. -development: - adapter: postgresql - encoding: unicode - database: <%= app_name %>_development - pool: 5 - username: <%= app_name %> - password: - - # Connect on a TCP socket. Omitted by default since the client uses a - # domain socket that doesn't need configuration. Windows does not have - # domain sockets, so uncomment these lines. - #host: localhost - #port: 5432 - - # Schema search path. The server defaults to $user,public - #schema_search_path: myapp,sharedapp,public - - # Minimum log levels, in increasing order: - # debug5, debug4, debug3, debug2, debug1, - # log, notice, warning, error, fatal, and panic - # The server defaults to notice. - #min_messages: warning - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: postgresql - encoding: unicode - database: <%= app_name %>_test - pool: 5 - username: <%= app_name %> - password: - -production: - adapter: postgresql - encoding: unicode - database: <%= app_name %>_production - pool: 5 - username: <%= app_name %> - password: diff --git a/vendor/rails/railties/configs/databases/sqlite2.yml b/vendor/rails/railties/configs/databases/sqlite2.yml deleted file mode 100644 index 46f01cb4..00000000 --- a/vendor/rails/railties/configs/databases/sqlite2.yml +++ /dev/null @@ -1,19 +0,0 @@ -# SQLite version 2.x -# gem install sqlite-ruby -development: - adapter: sqlite - database: db/development.sqlite2 - pool: 5 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite - database: db/test.sqlite2 - pool: 5 - -production: - adapter: sqlite - database: db/production.sqlite2 - pool: 5 diff --git a/vendor/rails/railties/configs/databases/sqlite3.yml b/vendor/rails/railties/configs/databases/sqlite3.yml deleted file mode 100644 index 025d62a8..00000000 --- a/vendor/rails/railties/configs/databases/sqlite3.yml +++ /dev/null @@ -1,22 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3-ruby (not necessary on OS X Leopard) -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 diff --git a/vendor/rails/railties/configs/empty.log b/vendor/rails/railties/configs/empty.log deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/railties/configs/initializers/backtrace_silencers.rb b/vendor/rails/railties/configs/initializers/backtrace_silencers.rb deleted file mode 100644 index c2169ed0..00000000 --- a/vendor/rails/railties/configs/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code. -# Rails.backtrace_cleaner.remove_silencers! \ No newline at end of file diff --git a/vendor/rails/railties/configs/initializers/cookie_verification_secret.rb b/vendor/rails/railties/configs/initializers/cookie_verification_secret.rb deleted file mode 100644 index 9f05cd5a..00000000 --- a/vendor/rails/railties/configs/initializers/cookie_verification_secret.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ActionController::Base.cookie_verifier_secret = '<%= app_secret %>'; diff --git a/vendor/rails/railties/configs/initializers/inflections.rb b/vendor/rails/railties/configs/initializers/inflections.rb deleted file mode 100644 index d531b8bb..00000000 --- a/vendor/rails/railties/configs/initializers/inflections.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end diff --git a/vendor/rails/railties/configs/initializers/mime_types.rb b/vendor/rails/railties/configs/initializers/mime_types.rb deleted file mode 100644 index 72aca7e4..00000000 --- a/vendor/rails/railties/configs/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/vendor/rails/railties/configs/initializers/new_rails_defaults.rb b/vendor/rails/railties/configs/initializers/new_rails_defaults.rb deleted file mode 100644 index c94db0a6..00000000 --- a/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# These settings change the behavior of Rails 2 apps and will be defaults -# for Rails 3. You can remove this initializer when Rails 3 is released. - -if defined?(ActiveRecord) - # Include Active Record class name as root for JSON serialized output. - ActiveRecord::Base.include_root_in_json = true - - # Store the full class name (including module namespace) in STI type column. - ActiveRecord::Base.store_full_sti_class = true -end - -ActionController::Routing.generate_best_match = false - -# Use ISO 8601 format for JSON serialized times and dates. -ActiveSupport.use_standard_json_time_format = true - -# Don't escape HTML entities in JSON, leave that for the #json_escape helper. -# if you're including raw json in an HTML page. -ActiveSupport.escape_html_entities_in_json = false \ No newline at end of file diff --git a/vendor/rails/railties/configs/initializers/session_store.rb b/vendor/rails/railties/configs/initializers/session_store.rb deleted file mode 100644 index 4499ab84..00000000 --- a/vendor/rails/railties/configs/initializers/session_store.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying cookie session data integrity. -# If you change this key, all old sessions will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ActionController::Base.session = { - :key => '_<%= app_name %>_session', - :secret => '<%= app_secret %>' -} - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rake db:sessions:create") -# ActionController::Base.session_store = :active_record_store diff --git a/vendor/rails/railties/configs/locales/en.yml b/vendor/rails/railties/configs/locales/en.yml deleted file mode 100644 index f265c068..00000000 --- a/vendor/rails/railties/configs/locales/en.yml +++ /dev/null @@ -1,5 +0,0 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. - -en: - hello: "Hello world" \ No newline at end of file diff --git a/vendor/rails/railties/configs/routes.rb b/vendor/rails/railties/configs/routes.rb deleted file mode 100644 index ea14ce1b..00000000 --- a/vendor/rails/railties/configs/routes.rb +++ /dev/null @@ -1,43 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - # The priority is based upon order of creation: first created -> highest priority. - - # Sample of regular route: - # map.connect 'products/:id', :controller => 'catalog', :action => 'view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # map.resources :products - - # Sample resource route with options: - # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } - - # Sample resource route with sub-resources: - # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller - - # Sample resource route with more complex sub-resources - # map.resources :products do |products| - # products.resources :comments - # products.resources :sales, :collection => { :recent => :get } - # end - - # Sample resource route within a namespace: - # map.namespace :admin do |admin| - # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb) - # admin.resources :products - # end - - # You can have the root of your site routed with map.root -- just remember to delete public/index.html. - # map.root :controller => "welcome" - - # See how all your routes lay out with "rake routes" - - # Install the default routes as the lowest priority. - # Note: These default routes make all actions in every controller accessible via GET requests. You should - # consider removing or commenting them out if you're using named routes and resources. - map.connect ':controller/:action/:id' - map.connect ':controller/:action/:id.:format' -end diff --git a/vendor/rails/railties/configs/seeds.rb b/vendor/rails/railties/configs/seeds.rb deleted file mode 100644 index 3174d0cb..00000000 --- a/vendor/rails/railties/configs/seeds.rb +++ /dev/null @@ -1,7 +0,0 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Major.create(:name => 'Daley', :city => cities.first) diff --git a/vendor/rails/railties/dispatches/config.ru b/vendor/rails/railties/dispatches/config.ru deleted file mode 100644 index acbfe4e9..00000000 --- a/vendor/rails/railties/dispatches/config.ru +++ /dev/null @@ -1,7 +0,0 @@ -# Rack Dispatcher - -# Require your environment file to bootstrap Rails -require File.dirname(__FILE__) + '/config/environment' - -# Dispatch the request -run ActionController::Dispatcher.new diff --git a/vendor/rails/railties/dispatches/dispatch.fcgi b/vendor/rails/railties/dispatches/dispatch.fcgi deleted file mode 100755 index 664dbbbe..00000000 --- a/vendor/rails/railties/dispatches/dispatch.fcgi +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby -# -# You may specify the path to the FastCGI crash log (a log of unhandled -# exceptions which forced the FastCGI instance to exit, great for debugging) -# and the number of requests to process before running garbage collection. -# -# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log -# and the GC period is nil (turned off). A reasonable number of requests -# could range from 10-100 depending on the memory footprint of your app. -# -# Example: -# # Default log path, normal GC behavior. -# RailsFCGIHandler.process! -# -# # Default log path, 50 requests between GC. -# RailsFCGIHandler.process! nil, 50 -# -# # Custom log path, normal GC behavior. -# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' -# -require File.dirname(__FILE__) + "/../config/environment" -require 'fcgi_handler' - -RailsFCGIHandler.process! diff --git a/vendor/rails/railties/dispatches/dispatch.rb b/vendor/rails/railties/dispatches/dispatch.rb deleted file mode 100755 index 32fa3b26..00000000 --- a/vendor/rails/railties/dispatches/dispatch.rb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch diff --git a/vendor/rails/railties/dispatches/gateway.cgi b/vendor/rails/railties/dispatches/gateway.cgi deleted file mode 100755 index 0305b7f8..00000000 --- a/vendor/rails/railties/dispatches/gateway.cgi +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env ruby - -require 'drb' - -# This file includes an experimental gateway CGI implementation. It will work -# only on platforms which support both fork and sockets. -# -# To enable it edit public/.htaccess and replace dispatch.cgi with gateway.cgi. -# -# Next, create the directory log/drb_gateway and grant the apache user rw access -# to said directory. -# -# On the next request to your server, the gateway tracker should start up, along -# with a few listener processes. This setup should provide you with much better -# speeds than dispatch.cgi. -# -# Keep in mind that the first request made to the server will be slow, as the -# tracker and listeners will have to load. Also, the tracker and listeners will -# shutdown after a period if inactivity. You can set this value below -- the -# default is 90 seconds. - -TrackerSocket = File.expand_path(File.join(File.dirname(__FILE__), '../log/drb_gateway/tracker.sock')) -DieAfter = 90 # Seconds -Listeners = 3 - -def message(s) - $stderr.puts "gateway.cgi: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -def listener_socket(number) - File.expand_path(File.join(File.dirname(__FILE__), "../log/drb_gateway/listener_#{number}.sock")) -end - -unless File.exist? TrackerSocket - message "Starting tracker and #{Listeners} listeners" - fork do - Process.setsid - STDIN.reopen "/dev/null" - STDOUT.reopen "/dev/null", "a" - - root = File.expand_path(File.dirname(__FILE__) + '/..') - - message "starting tracker" - fork do - ARGV.clear - ARGV << TrackerSocket << Listeners.to_s << DieAfter.to_s - load File.join(root, 'script', 'tracker') - end - - message "starting listeners" - require File.join(root, 'config/environment.rb') - Listeners.times do |number| - fork do - ARGV.clear - ARGV << listener_socket(number) << DieAfter.to_s - load File.join(root, 'script', 'listener') - end - end - end - - message "waiting for tracker and listener to arise..." - ready = false - 10.times do - sleep 0.5 - break if (ready = File.exist?(TrackerSocket) && File.exist?(listener_socket(0))) - end - - if ready - message "tracker and listener are ready" - else - message "Waited 5 seconds, listener and tracker not ready... dropping request" - Kernel.exit 1 - end -end - -DRb.start_service - -message "connecting to tracker" -tracker = DRbObject.new_with_uri("drbunix:#{TrackerSocket}") - -input = $stdin.read -$stdin.close - -env = ENV.inspect - -output = nil -tracker.with_listener do |number| - message "connecting to listener #{number}" - socket = listener_socket(number) - listener = DRbObject.new_with_uri("drbunix:#{socket}") - output = listener.process(env, input) - message "listener #{number} has finished, writing output" -end - -$stdout.write output -$stdout.flush -$stdout.close diff --git a/vendor/rails/railties/doc/README_FOR_APP b/vendor/rails/railties/doc/README_FOR_APP deleted file mode 100644 index fe41f5cc..00000000 --- a/vendor/rails/railties/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -Use this README file to introduce your application and point to useful places in the API for learning more. -Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. diff --git a/vendor/rails/railties/environments/boot.rb b/vendor/rails/railties/environments/boot.rb deleted file mode 100644 index 6686664c..00000000 --- a/vendor/rails/railties/environments/boot.rb +++ /dev/null @@ -1,114 +0,0 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb - -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) - -module Rails - class << self - def boot! - unless booted? - preinitialize - pick_boot.run - end - end - - def booted? - defined? Rails::Initializer - end - - def pick_boot - (vendor_rails? ? VendorBoot : GemBoot).new - end - - def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") - end - - def preinitialize - load(preinitializer_path) if File.exist?(preinitializer_path) - end - - def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" - end - end - - class Boot - def run - load_initializer - Rails::Initializer.run(:set_load_path) - end - end - - class VendorBoot < Boot - def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" - Rails::Initializer.run(:install_gem_spec_stubs) - Rails::GemDependency.add_frozen_gem_path - end - end - - class GemBoot < Boot - def load_initializer - self.class.load_rubygems - load_rails_gem - require 'initializer' - end - - def load_rails_gem - if version = self.class.gem_version - gem 'rails', version - else - gem 'rails' - end - rescue Gem::LoadError => load_error - if load_error.message =~ /Could not find RubyGem rails/ - 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.) - exit 1 - else - raise - end - end - - class << self - def rubygems_version - Gem::RubyGemsVersion rescue nil - end - - def gem_version - if defined? RAILS_GEM_VERSION - RAILS_GEM_VERSION - elsif ENV.include?('RAILS_GEM_VERSION') - ENV['RAILS_GEM_VERSION'] - else - parse_gem_version(read_environment_rb) - end - end - - def load_rubygems - min_version = '1.3.2' - require 'rubygems' - unless rubygems_version >= min_version - $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) - exit 1 - end - - rescue LoadError - $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) - exit 1 - end - - def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ - end - - private - def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") - end - end - end -end - -# All that for this: -Rails.boot! diff --git a/vendor/rails/railties/environments/development.rb b/vendor/rails/railties/environments/development.rb deleted file mode 100644 index 85c9a608..00000000 --- a/vendor/rails/railties/environments/development.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# In the development environment your application's code is reloaded on -# every request. This slows down response time but is perfect for development -# since you don't have to restart the webserver when you make code changes. -config.cache_classes = false - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_view.debug_rjs = true -config.action_controller.perform_caching = false - -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false \ No newline at end of file diff --git a/vendor/rails/railties/environments/environment.rb b/vendor/rails/railties/environments/environment.rb deleted file mode 100644 index 250deaf4..00000000 --- a/vendor/rails/railties/environments/environment.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Be sure to restart your server when you modify this file - -# Specifies gem version of Rails to use when vendor/rails is not present -<%= '# ' if freeze %>RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>' unless defined? RAILS_GEM_VERSION - -# Bootstrap the Rails environment, frameworks, and default configuration -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Add additional load paths for your own custom dirs - # config.autoload_paths += %W( #{RAILS_ROOT}/extras ) - - # Specify gems that this application depends on and have them installed with rake gems:install - # config.gem "bj" - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - # config.gem "sqlite3-ruby", :lib => "sqlite3" - # config.gem "aws-s3", :lib => "aws/s3" - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Skip frameworks you're not going to use. To use Rails without a database, - # you must remove the Active Record framework. - # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. - config.time_zone = 'UTC' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] - # config.i18n.default_locale = :de -end \ No newline at end of file diff --git a/vendor/rails/railties/environments/production.rb b/vendor/rails/railties/environments/production.rb deleted file mode 100644 index 27119d2d..00000000 --- a/vendor/rails/railties/environments/production.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true - -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true -config.action_view.cache_template_loading = true - -# See everything in the log (default is :info) -# config.log_level = :debug - -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new - -# Use a different cache store in production -# config.cache_store = :mem_cache_store - -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" - -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false - -# Enable threaded mode -# config.threadsafe! \ No newline at end of file diff --git a/vendor/rails/railties/environments/test.rb b/vendor/rails/railties/environments/test.rb deleted file mode 100644 index d6f80a40..00000000 --- a/vendor/rails/railties/environments/test.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = true - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false -config.action_view.cache_template_loading = true - -# Disable request forgery protection in test environment -config.action_controller.allow_forgery_protection = false - -# Tell Action Mailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test - -# Use SQL instead of Active Record's schema dumper when creating the test database. -# This is necessary if your schema can't be completely dumped by the schema dumper, -# like if you have constraints or database-specific column types -# config.active_record.schema_format = :sql \ No newline at end of file diff --git a/vendor/rails/railties/fresh_rakefile b/vendor/rails/railties/fresh_rakefile deleted file mode 100755 index 3bb0e859..00000000 --- a/vendor/rails/railties/fresh_rakefile +++ /dev/null @@ -1,10 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require(File.join(File.dirname(__FILE__), 'config', 'boot')) - -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -require 'tasks/rails' diff --git a/vendor/rails/railties/helpers/application_controller.rb b/vendor/rails/railties/helpers/application_controller.rb deleted file mode 100644 index 6635a3f4..00000000 --- a/vendor/rails/railties/helpers/application_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - -class ApplicationController < ActionController::Base - helper :all # include all helpers, all the time - protect_from_forgery # See ActionController::RequestForgeryProtection for details - - # Scrub sensitive parameters from your log - # filter_parameter_logging :password -end diff --git a/vendor/rails/railties/helpers/application_helper.rb b/vendor/rails/railties/helpers/application_helper.rb deleted file mode 100644 index 22a7940e..00000000 --- a/vendor/rails/railties/helpers/application_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Methods added to this helper will be available to all templates in the application. -module ApplicationHelper -end diff --git a/vendor/rails/railties/helpers/performance_test.rb b/vendor/rails/railties/helpers/performance_test.rb deleted file mode 100644 index 4b60558b..00000000 --- a/vendor/rails/railties/helpers/performance_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'performance_test_help' - -# Profiling results for each test method are written to tmp/performance. -class BrowsingTest < ActionController::PerformanceTest - def test_homepage - get '/' - end -end diff --git a/vendor/rails/railties/helpers/test_helper.rb b/vendor/rails/railties/helpers/test_helper.rb deleted file mode 100644 index b9fe2517..00000000 --- a/vendor/rails/railties/helpers/test_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") -require 'test_help' - -class ActiveSupport::TestCase - # Transactional fixtures accelerate your tests by wrapping each test method - # in a transaction that's rolled back on completion. This ensures that the - # test database remains unchanged so your fixtures don't have to be reloaded - # between every test method. Fewer database queries means faster tests. - # - # Read Mike Clark's excellent walkthrough at - # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting - # - # Every Active Record database supports transactions except MyISAM tables - # in MySQL. Turn off transactional fixtures in this case; however, if you - # don't care one way or the other, switching from MyISAM to InnoDB tables - # is recommended. - # - # The only drawback to using transactional fixtures is when you actually - # need to test transactions. Since your test is bracketed by a transaction, - # any transactions started in your code will be automatically rolled back. - self.use_transactional_fixtures = true - - # Instantiated fixtures are slow, but give you @david where otherwise you - # would need people(:david). If you don't want to migrate your existing - # test cases which use the @david style and don't mind the speed hit (each - # instantiated fixtures translates to a database query per test method), - # then set this back to true. - self.use_instantiated_fixtures = false - - # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - - # Add more helper methods to be used by all tests here... -end diff --git a/vendor/rails/railties/html/404.html b/vendor/rails/railties/html/404.html deleted file mode 100644 index eff660b9..00000000 --- a/vendor/rails/railties/html/404.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - -<head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>The page you were looking for doesn't exist (404)</title> - <style type="text/css"> - body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } - div.dialog { - width: 25em; - padding: 0 4em; - margin: 4em auto 0 auto; - border: 1px solid #ccc; - border-right-color: #999; - border-bottom-color: #999; - } - h1 { font-size: 100%; color: #f00; line-height: 1.5em; } - </style> -</head> - -<body> - <!-- This file lives in public/404.html --> - <div class="dialog"> - <h1>The page you were looking for doesn't exist.</h1> - <p>You may have mistyped the address or the page may have moved.</p> - </div> -</body> -</html> \ No newline at end of file diff --git a/vendor/rails/railties/html/422.html b/vendor/rails/railties/html/422.html deleted file mode 100644 index b54e4a3c..00000000 --- a/vendor/rails/railties/html/422.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - -<head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>The change you wanted was rejected (422)</title> - <style type="text/css"> - body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } - div.dialog { - width: 25em; - padding: 0 4em; - margin: 4em auto 0 auto; - border: 1px solid #ccc; - border-right-color: #999; - border-bottom-color: #999; - } - h1 { font-size: 100%; color: #f00; line-height: 1.5em; } - </style> -</head> - -<body> - <!-- This file lives in public/422.html --> - <div class="dialog"> - <h1>The change you wanted was rejected.</h1> - <p>Maybe you tried to change something you didn't have access to.</p> - </div> -</body> -</html> \ No newline at end of file diff --git a/vendor/rails/railties/html/500.html b/vendor/rails/railties/html/500.html deleted file mode 100644 index ec3bbf02..00000000 --- a/vendor/rails/railties/html/500.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - -<head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>We're sorry, but something went wrong (500)</title> - <style type="text/css"> - body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } - div.dialog { - width: 25em; - padding: 0 4em; - margin: 4em auto 0 auto; - border: 1px solid #ccc; - border-right-color: #999; - border-bottom-color: #999; - } - h1 { font-size: 100%; color: #f00; line-height: 1.5em; } - </style> -</head> - -<body> - <!-- This file lives in public/500.html --> - <div class="dialog"> - <h1>We're sorry, but something went wrong.</h1> - <p>We've been notified about this issue and we'll take a look at it shortly.</p> - </div> -</body> -</html> diff --git a/vendor/rails/railties/html/favicon.ico b/vendor/rails/railties/html/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/railties/html/images/rails.png b/vendor/rails/railties/html/images/rails.png deleted file mode 100644 index d5edc04e..00000000 Binary files a/vendor/rails/railties/html/images/rails.png and /dev/null differ diff --git a/vendor/rails/railties/html/index.html b/vendor/rails/railties/html/index.html deleted file mode 100644 index 0dd5189f..00000000 --- a/vendor/rails/railties/html/index.html +++ /dev/null @@ -1,275 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> - <head> - <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> - <title>Ruby on Rails: Welcome aboard</title> - <style type="text/css" media="screen"> - body { - margin: 0; - margin-bottom: 25px; - padding: 0; - background-color: #f0f0f0; - font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana"; - font-size: 13px; - color: #333; - } - - h1 { - font-size: 28px; - color: #000; - } - - a {color: #03c} - a:hover { - background-color: #03c; - color: white; - text-decoration: none; - } - - - #page { - background-color: #f0f0f0; - width: 750px; - margin: 0; - margin-left: auto; - margin-right: auto; - } - - #content { - float: left; - background-color: white; - border: 3px solid #aaa; - border-top: none; - padding: 25px; - width: 500px; - } - - #sidebar { - float: right; - width: 175px; - } - - #footer { - clear: both; - } - - - #header, #about, #getting-started { - padding-left: 75px; - padding-right: 30px; - } - - - #header { - background-image: url("images/rails.png"); - background-repeat: no-repeat; - background-position: top left; - height: 64px; - } - #header h1, #header h2 {margin: 0} - #header h2 { - color: #888; - font-weight: normal; - font-size: 16px; - } - - - #about h3 { - margin: 0; - margin-bottom: 10px; - font-size: 14px; - } - - #about-content { - background-color: #ffd; - border: 1px solid #fc0; - margin-left: -11px; - } - #about-content table { - margin-top: 10px; - margin-bottom: 10px; - font-size: 11px; - border-collapse: collapse; - } - #about-content td { - padding: 10px; - padding-top: 3px; - padding-bottom: 3px; - } - #about-content td.name {color: #555} - #about-content td.value {color: #000} - - #about-content.failure { - background-color: #fcc; - border: 1px solid #f00; - } - #about-content.failure p { - margin: 0; - padding: 10px; - } - - - #getting-started { - border-top: 1px solid #ccc; - margin-top: 25px; - padding-top: 15px; - } - #getting-started h1 { - margin: 0; - font-size: 20px; - } - #getting-started h2 { - margin: 0; - font-size: 14px; - font-weight: normal; - color: #333; - margin-bottom: 25px; - } - #getting-started ol { - margin-left: 0; - padding-left: 0; - } - #getting-started li { - font-size: 18px; - color: #888; - margin-bottom: 25px; - } - #getting-started li h2 { - margin: 0; - font-weight: normal; - font-size: 18px; - color: #333; - } - #getting-started li p { - color: #555; - font-size: 13px; - } - - - #search { - margin: 0; - padding-top: 10px; - padding-bottom: 10px; - font-size: 11px; - } - #search input { - font-size: 11px; - margin: 2px; - } - #search-text {width: 170px} - - - #sidebar ul { - margin-left: 0; - padding-left: 0; - } - #sidebar ul h3 { - margin-top: 25px; - font-size: 16px; - padding-bottom: 10px; - border-bottom: 1px solid #ccc; - } - #sidebar li { - list-style-type: none; - } - #sidebar ul.links li { - margin-bottom: 5px; - } - - </style> - <script type="text/javascript" src="javascripts/prototype.js"></script> - <script type="text/javascript" src="javascripts/effects.js"></script> - <script type="text/javascript"> - function about() { - if (Element.empty('about-content')) { - new Ajax.Updater('about-content', 'rails/info/properties', { - method: 'get', - onFailure: function() {Element.classNames('about-content').add('failure')}, - onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})} - }); - } else { - new Effect[Element.visible('about-content') ? - 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25}); - } - } - - window.onload = function() { - $('search-text').value = ''; - $('search').onsubmit = function() { - $('search-text').value = 'site:rubyonrails.org ' + $F('search-text'); - } - } - </script> - </head> - <body> - <div id="page"> - <div id="sidebar"> - <ul id="sidebar-items"> - <li> - <form id="search" action="http://www.google.com/search" method="get"> - <input type="hidden" name="hl" value="en" /> - <input type="text" id="search-text" name="q" value="site:rubyonrails.org " /> - <input type="submit" value="Search" /> the Rails site - </form> - </li> - - <li> - <h3>Join the community</h3> - <ul class="links"> - <li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li> - <li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li> - <li><a href="http://wiki.rubyonrails.org/">Wiki</a></li> - </ul> - </li> - - <li> - <h3>Browse the documentation</h3> - <ul class="links"> - <li><a href="http://api.rubyonrails.org/">Rails API</a></li> - <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li> - <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li> - <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li> - </ul> - </li> - </ul> - </div> - - <div id="content"> - <div id="header"> - <h1>Welcome aboard</h1> - <h2>You&rsquo;re riding Ruby on Rails!</h2> - </div> - - <div id="about"> - <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3> - <div id="about-content" style="display: none"></div> - </div> - - <div id="getting-started"> - <h1>Getting started</h1> - <h2>Here&rsquo;s how to get rolling:</h2> - - <ol> - <li> - <h2>Use <tt>script/generate</tt> to create your models and controllers</h2> - <p>To see all available options, run it without parameters.</p> - </li> - - <li> - <h2>Set up a default route and remove or rename this file</h2> - <p>Routes are set up in config/routes.rb.</p> - </li> - - <li> - <h2>Create your database</h2> - <p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p> - </li> - </ol> - </div> - </div> - - <div id="footer">&nbsp;</div> - </div> - </body> -</html> \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/application.js b/vendor/rails/railties/html/javascripts/application.js deleted file mode 100644 index fe457769..00000000 --- a/vendor/rails/railties/html/javascripts/application.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place your application-specific JavaScript functions and classes here -// This file is automatically included by javascript_include_tag :defaults diff --git a/vendor/rails/railties/html/javascripts/controls.js b/vendor/rails/railties/html/javascripts/controls.js deleted file mode 100644 index ca29aefd..00000000 --- a/vendor/rails/railties/html/javascripts/controls.js +++ /dev/null @@ -1,963 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan) -// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com) -// Contributors: -// Richard Livsey -// Rahul Bhargava -// Rob Wills -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -// Autocompleter.Base handles all the autocompletion functionality -// that's independent of the data source for autocompletion. This -// includes drawing the autocompletion menu, observing keyboard -// and mouse events, and similar. -// -// Specific autocompleters need to provide, at the very least, -// a getUpdatedChoices function that will be invoked every time -// the text inside the monitored textbox changes. This method -// should get the text for which to provide autocompletion by -// invoking this.getToken(), NOT by directly accessing -// this.element.value. This is to allow incremental tokenized -// autocompletion. Specific auto-completion logic (AJAX, etc) -// belongs in getUpdatedChoices. -// -// Tokenized incremental autocompletion is enabled automatically -// when an autocompleter is instantiated with the 'tokens' option -// in the options parameter, e.g.: -// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); -// will incrementally autocomplete with a comma as the token. -// Additionally, ',' in the above example can be replaced with -// a token array, e.g. { tokens: [',', '\n'] } which -// enables autocompletion on multiple tokens. This is most -// useful when one of the tokens is \n (a newline), as it -// allows smart autocompletion after linebreaks. - -if(typeof Effect == 'undefined') - throw("controls.js requires including script.aculo.us' effects.js library"); - -var Autocompleter = { }; -Autocompleter.Base = Class.create({ - baseInitialize: function(element, update, options) { - element = $(element); - this.element = element; - this.update = $(update); - this.hasFocus = false; - this.changed = false; - this.active = false; - this.index = 0; - this.entryCount = 0; - this.oldElementValue = this.element.value; - - if(this.setOptions) - this.setOptions(options); - else - this.options = options || { }; - - this.options.paramName = this.options.paramName || this.element.name; - this.options.tokens = this.options.tokens || []; - this.options.frequency = this.options.frequency || 0.4; - this.options.minChars = this.options.minChars || 1; - this.options.onShow = this.options.onShow || - function(element, update){ - if(!update.style.position || update.style.position=='absolute') { - update.style.position = 'absolute'; - Position.clone(element, update, { - setHeight: false, - offsetTop: element.offsetHeight - }); - } - Effect.Appear(update,{duration:0.15}); - }; - this.options.onHide = this.options.onHide || - function(element, update){ new Effect.Fade(update,{duration:0.15}) }; - - if(typeof(this.options.tokens) == 'string') - this.options.tokens = new Array(this.options.tokens); - // Force carriage returns as token delimiters anyway - if (!this.options.tokens.include('\n')) - this.options.tokens.push('\n'); - - this.observer = null; - - this.element.setAttribute('autocomplete','off'); - - Element.hide(this.update); - - Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this)); - Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this)); - }, - - show: function() { - if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); - if(!this.iefix && - (Prototype.Browser.IE) && - (Element.getStyle(this.update, 'position')=='absolute')) { - new Insertion.After(this.update, - '<iframe id="' + this.update.id + '_iefix" '+ - 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + - 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>'); - this.iefix = $(this.update.id+'_iefix'); - } - if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); - }, - - fixIEOverlapping: function() { - Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); - this.iefix.style.zIndex = 1; - this.update.style.zIndex = 2; - Element.show(this.iefix); - }, - - hide: function() { - this.stopIndicator(); - if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); - if(this.iefix) Element.hide(this.iefix); - }, - - startIndicator: function() { - if(this.options.indicator) Element.show(this.options.indicator); - }, - - stopIndicator: function() { - if(this.options.indicator) Element.hide(this.options.indicator); - }, - - onKeyPress: function(event) { - if(this.active) - switch(event.keyCode) { - case Event.KEY_TAB: - case Event.KEY_RETURN: - this.selectEntry(); - Event.stop(event); - case Event.KEY_ESC: - this.hide(); - this.active = false; - Event.stop(event); - return; - case Event.KEY_LEFT: - case Event.KEY_RIGHT: - return; - case Event.KEY_UP: - this.markPrevious(); - this.render(); - Event.stop(event); - return; - case Event.KEY_DOWN: - this.markNext(); - this.render(); - Event.stop(event); - return; - } - else - if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || - (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return; - - this.changed = true; - this.hasFocus = true; - - if(this.observer) clearTimeout(this.observer); - this.observer = - setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); - }, - - activate: function() { - this.changed = false; - this.hasFocus = true; - this.getUpdatedChoices(); - }, - - onHover: function(event) { - var element = Event.findElement(event, 'LI'); - if(this.index != element.autocompleteIndex) - { - this.index = element.autocompleteIndex; - this.render(); - } - Event.stop(event); - }, - - onClick: function(event) { - var element = Event.findElement(event, 'LI'); - this.index = element.autocompleteIndex; - this.selectEntry(); - this.hide(); - }, - - onBlur: function(event) { - // needed to make click events working - setTimeout(this.hide.bind(this), 250); - this.hasFocus = false; - this.active = false; - }, - - render: function() { - if(this.entryCount > 0) { - for (var i = 0; i < this.entryCount; i++) - this.index==i ? - Element.addClassName(this.getEntry(i),"selected") : - Element.removeClassName(this.getEntry(i),"selected"); - if(this.hasFocus) { - this.show(); - this.active = true; - } - } else { - this.active = false; - this.hide(); - } - }, - - markPrevious: function() { - if(this.index > 0) this.index--; - else this.index = this.entryCount-1; - this.getEntry(this.index).scrollIntoView(true); - }, - - markNext: function() { - if(this.index < this.entryCount-1) this.index++; - else this.index = 0; - this.getEntry(this.index).scrollIntoView(false); - }, - - getEntry: function(index) { - return this.update.firstChild.childNodes[index]; - }, - - getCurrentEntry: function() { - return this.getEntry(this.index); - }, - - selectEntry: function() { - this.active = false; - this.updateElement(this.getCurrentEntry()); - }, - - updateElement: function(selectedElement) { - if (this.options.updateElement) { - this.options.updateElement(selectedElement); - return; - } - var value = ''; - if (this.options.select) { - var nodes = $(selectedElement).select('.' + this.options.select) || []; - if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); - } else - value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - - var bounds = this.getTokenBounds(); - if (bounds[0] != -1) { - var newValue = this.element.value.substr(0, bounds[0]); - var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/); - if (whitespace) - newValue += whitespace[0]; - this.element.value = newValue + value + this.element.value.substr(bounds[1]); - } else { - this.element.value = value; - } - this.oldElementValue = this.element.value; - this.element.focus(); - - if (this.options.afterUpdateElement) - this.options.afterUpdateElement(this.element, selectedElement); - }, - - updateChoices: function(choices) { - if(!this.changed && this.hasFocus) { - this.update.innerHTML = choices; - Element.cleanWhitespace(this.update); - Element.cleanWhitespace(this.update.down()); - - if(this.update.firstChild && this.update.down().childNodes) { - this.entryCount = - this.update.down().childNodes.length; - for (var i = 0; i < this.entryCount; i++) { - var entry = this.getEntry(i); - entry.autocompleteIndex = i; - this.addObservers(entry); - } - } else { - this.entryCount = 0; - } - - this.stopIndicator(); - this.index = 0; - - if(this.entryCount==1 && this.options.autoSelect) { - this.selectEntry(); - this.hide(); - } else { - this.render(); - } - } - }, - - addObservers: function(element) { - Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); - Event.observe(element, "click", this.onClick.bindAsEventListener(this)); - }, - - onObserverEvent: function() { - this.changed = false; - this.tokenBounds = null; - if(this.getToken().length>=this.options.minChars) { - this.getUpdatedChoices(); - } else { - this.active = false; - this.hide(); - } - this.oldElementValue = this.element.value; - }, - - getToken: function() { - var bounds = this.getTokenBounds(); - return this.element.value.substring(bounds[0], bounds[1]).strip(); - }, - - getTokenBounds: function() { - if (null != this.tokenBounds) return this.tokenBounds; - var value = this.element.value; - if (value.strip().empty()) return [-1, 0]; - var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue); - var offset = (diff == this.oldElementValue.length ? 1 : 0); - var prevTokenPos = -1, nextTokenPos = value.length; - var tp; - for (var index = 0, l = this.options.tokens.length; index < l; ++index) { - tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1); - if (tp > prevTokenPos) prevTokenPos = tp; - tp = value.indexOf(this.options.tokens[index], diff + offset); - if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp; - } - return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]); - } -}); - -Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) { - var boundary = Math.min(newS.length, oldS.length); - for (var index = 0; index < boundary; ++index) - if (newS[index] != oldS[index]) - return index; - return boundary; -}; - -Ajax.Autocompleter = Class.create(Autocompleter.Base, { - initialize: function(element, update, url, options) { - this.baseInitialize(element, update, options); - this.options.asynchronous = true; - this.options.onComplete = this.onComplete.bind(this); - this.options.defaultParams = this.options.parameters || null; - this.url = url; - }, - - getUpdatedChoices: function() { - this.startIndicator(); - - var entry = encodeURIComponent(this.options.paramName) + '=' + - encodeURIComponent(this.getToken()); - - this.options.parameters = this.options.callback ? - this.options.callback(this.element, entry) : entry; - - if(this.options.defaultParams) - this.options.parameters += '&' + this.options.defaultParams; - - new Ajax.Request(this.url, this.options); - }, - - onComplete: function(request) { - this.updateChoices(request.responseText); - } -}); - -// The local array autocompleter. Used when you'd prefer to -// inject an array of autocompletion options into the page, rather -// than sending out Ajax queries, which can be quite slow sometimes. -// -// The constructor takes four parameters. The first two are, as usual, -// the id of the monitored textbox, and id of the autocompletion menu. -// The third is the array you want to autocomplete from, and the fourth -// is the options block. -// -// Extra local autocompletion options: -// - choices - How many autocompletion choices to offer -// -// - partialSearch - If false, the autocompleter will match entered -// text only at the beginning of strings in the -// autocomplete array. Defaults to true, which will -// match text at the beginning of any *word* in the -// strings in the autocomplete array. If you want to -// search anywhere in the string, additionally set -// the option fullSearch to true (default: off). -// -// - fullSsearch - Search anywhere in autocomplete array strings. -// -// - partialChars - How many characters to enter before triggering -// a partial match (unlike minChars, which defines -// how many characters are required to do any match -// at all). Defaults to 2. -// -// - ignoreCase - Whether to ignore case when autocompleting. -// Defaults to true. -// -// It's possible to pass in a custom function as the 'selector' -// option, if you prefer to write your own autocompletion logic. -// In that case, the other options above will not apply unless -// you support them. - -Autocompleter.Local = Class.create(Autocompleter.Base, { - initialize: function(element, update, array, options) { - this.baseInitialize(element, update, options); - this.options.array = array; - }, - - getUpdatedChoices: function() { - this.updateChoices(this.options.selector(this)); - }, - - setOptions: function(options) { - this.options = Object.extend({ - choices: 10, - partialSearch: true, - partialChars: 2, - ignoreCase: true, - fullSearch: false, - selector: function(instance) { - var ret = []; // Beginning matches - var partial = []; // Inside matches - var entry = instance.getToken(); - var count = 0; - - for (var i = 0; i < instance.options.array.length && - ret.length < instance.options.choices ; i++) { - - var elem = instance.options.array[i]; - var foundPos = instance.options.ignoreCase ? - elem.toLowerCase().indexOf(entry.toLowerCase()) : - elem.indexOf(entry); - - while (foundPos != -1) { - if (foundPos == 0 && elem.length != entry.length) { - ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" + - elem.substr(entry.length) + "</li>"); - break; - } else if (entry.length >= instance.options.partialChars && - instance.options.partialSearch && foundPos != -1) { - if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) { - partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" + - elem.substr(foundPos, entry.length) + "</strong>" + elem.substr( - foundPos + entry.length) + "</li>"); - break; - } - } - - foundPos = instance.options.ignoreCase ? - elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : - elem.indexOf(entry, foundPos + 1); - - } - } - if (partial.length) - ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)); - return "<ul>" + ret.join('') + "</ul>"; - } - }, options || { }); - } -}); - -// AJAX in-place editor and collection editor -// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007). - -// Use this if you notice weird scrolling problems on some browsers, -// the DOM might be a bit confused when this gets called so do this -// waits 1 ms (with setTimeout) until it does the activation -Field.scrollFreeActivate = function(field) { - setTimeout(function() { - Field.activate(field); - }, 1); -}; - -Ajax.InPlaceEditor = Class.create({ - initialize: function(element, url, options) { - this.url = url; - this.element = element = $(element); - this.prepareOptions(); - this._controls = { }; - arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!! - Object.extend(this.options, options || { }); - if (!this.options.formId && this.element.id) { - this.options.formId = this.element.id + '-inplaceeditor'; - if ($(this.options.formId)) - this.options.formId = ''; - } - if (this.options.externalControl) - this.options.externalControl = $(this.options.externalControl); - if (!this.options.externalControl) - this.options.externalControlOnly = false; - this._originalBackground = this.element.getStyle('background-color') || 'transparent'; - this.element.title = this.options.clickToEditText; - this._boundCancelHandler = this.handleFormCancellation.bind(this); - this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this); - this._boundFailureHandler = this.handleAJAXFailure.bind(this); - this._boundSubmitHandler = this.handleFormSubmission.bind(this); - this._boundWrapperHandler = this.wrapUp.bind(this); - this.registerListeners(); - }, - checkForEscapeOrReturn: function(e) { - if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return; - if (Event.KEY_ESC == e.keyCode) - this.handleFormCancellation(e); - else if (Event.KEY_RETURN == e.keyCode) - this.handleFormSubmission(e); - }, - createControl: function(mode, handler, extraClasses) { - var control = this.options[mode + 'Control']; - var text = this.options[mode + 'Text']; - if ('button' == control) { - var btn = document.createElement('input'); - btn.type = 'submit'; - btn.value = text; - btn.className = 'editor_' + mode + '_button'; - if ('cancel' == mode) - btn.onclick = this._boundCancelHandler; - this._form.appendChild(btn); - this._controls[mode] = btn; - } else if ('link' == control) { - var link = document.createElement('a'); - link.href = '#'; - link.appendChild(document.createTextNode(text)); - link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler; - link.className = 'editor_' + mode + '_link'; - if (extraClasses) - link.className += ' ' + extraClasses; - this._form.appendChild(link); - this._controls[mode] = link; - } - }, - createEditField: function() { - var text = (this.options.loadTextURL ? this.options.loadingText : this.getText()); - var fld; - if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) { - fld = document.createElement('input'); - fld.type = 'text'; - var size = this.options.size || this.options.cols || 0; - if (0 < size) fld.size = size; - } else { - fld = document.createElement('textarea'); - fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows); - fld.cols = this.options.cols || 40; - } - fld.name = this.options.paramName; - fld.value = text; // No HTML breaks conversion anymore - fld.className = 'editor_field'; - if (this.options.submitOnBlur) - fld.onblur = this._boundSubmitHandler; - this._controls.editor = fld; - if (this.options.loadTextURL) - this.loadExternalText(); - this._form.appendChild(this._controls.editor); - }, - createForm: function() { - var ipe = this; - function addText(mode, condition) { - var text = ipe.options['text' + mode + 'Controls']; - if (!text || condition === false) return; - ipe._form.appendChild(document.createTextNode(text)); - }; - this._form = $(document.createElement('form')); - this._form.id = this.options.formId; - this._form.addClassName(this.options.formClassName); - this._form.onsubmit = this._boundSubmitHandler; - this.createEditField(); - if ('textarea' == this._controls.editor.tagName.toLowerCase()) - this._form.appendChild(document.createElement('br')); - if (this.options.onFormCustomization) - this.options.onFormCustomization(this, this._form); - addText('Before', this.options.okControl || this.options.cancelControl); - this.createControl('ok', this._boundSubmitHandler); - addText('Between', this.options.okControl && this.options.cancelControl); - this.createControl('cancel', this._boundCancelHandler, 'editor_cancel'); - addText('After', this.options.okControl || this.options.cancelControl); - }, - destroy: function() { - if (this._oldInnerHTML) - this.element.innerHTML = this._oldInnerHTML; - this.leaveEditMode(); - this.unregisterListeners(); - }, - enterEditMode: function(e) { - if (this._saving || this._editing) return; - this._editing = true; - this.triggerCallback('onEnterEditMode'); - if (this.options.externalControl) - this.options.externalControl.hide(); - this.element.hide(); - this.createForm(); - this.element.parentNode.insertBefore(this._form, this.element); - if (!this.options.loadTextURL) - this.postProcessEditField(); - if (e) Event.stop(e); - }, - enterHover: function(e) { - if (this.options.hoverClassName) - this.element.addClassName(this.options.hoverClassName); - if (this._saving) return; - this.triggerCallback('onEnterHover'); - }, - getText: function() { - return this.element.innerHTML.unescapeHTML(); - }, - handleAJAXFailure: function(transport) { - this.triggerCallback('onFailure', transport); - if (this._oldInnerHTML) { - this.element.innerHTML = this._oldInnerHTML; - this._oldInnerHTML = null; - } - }, - handleFormCancellation: function(e) { - this.wrapUp(); - if (e) Event.stop(e); - }, - handleFormSubmission: function(e) { - var form = this._form; - var value = $F(this._controls.editor); - this.prepareSubmission(); - var params = this.options.callback(form, value) || ''; - if (Object.isString(params)) - params = params.toQueryParams(); - params.editorId = this.element.id; - if (this.options.htmlResponse) { - var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions); - Object.extend(options, { - parameters: params, - onComplete: this._boundWrapperHandler, - onFailure: this._boundFailureHandler - }); - new Ajax.Updater({ success: this.element }, this.url, options); - } else { - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: params, - onComplete: this._boundWrapperHandler, - onFailure: this._boundFailureHandler - }); - new Ajax.Request(this.url, options); - } - if (e) Event.stop(e); - }, - leaveEditMode: function() { - this.element.removeClassName(this.options.savingClassName); - this.removeForm(); - this.leaveHover(); - this.element.style.backgroundColor = this._originalBackground; - this.element.show(); - if (this.options.externalControl) - this.options.externalControl.show(); - this._saving = false; - this._editing = false; - this._oldInnerHTML = null; - this.triggerCallback('onLeaveEditMode'); - }, - leaveHover: function(e) { - if (this.options.hoverClassName) - this.element.removeClassName(this.options.hoverClassName); - if (this._saving) return; - this.triggerCallback('onLeaveHover'); - }, - loadExternalText: function() { - this._form.addClassName(this.options.loadingClassName); - this._controls.editor.disabled = true; - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: 'editorId=' + encodeURIComponent(this.element.id), - onComplete: Prototype.emptyFunction, - onSuccess: function(transport) { - this._form.removeClassName(this.options.loadingClassName); - var text = transport.responseText; - if (this.options.stripLoadedTextTags) - text = text.stripTags(); - this._controls.editor.value = text; - this._controls.editor.disabled = false; - this.postProcessEditField(); - }.bind(this), - onFailure: this._boundFailureHandler - }); - new Ajax.Request(this.options.loadTextURL, options); - }, - postProcessEditField: function() { - var fpc = this.options.fieldPostCreation; - if (fpc) - $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate'](); - }, - prepareOptions: function() { - this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions); - Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks); - [this._extraDefaultOptions].flatten().compact().each(function(defs) { - Object.extend(this.options, defs); - }.bind(this)); - }, - prepareSubmission: function() { - this._saving = true; - this.removeForm(); - this.leaveHover(); - this.showSaving(); - }, - registerListeners: function() { - this._listeners = { }; - var listener; - $H(Ajax.InPlaceEditor.Listeners).each(function(pair) { - listener = this[pair.value].bind(this); - this._listeners[pair.key] = listener; - if (!this.options.externalControlOnly) - this.element.observe(pair.key, listener); - if (this.options.externalControl) - this.options.externalControl.observe(pair.key, listener); - }.bind(this)); - }, - removeForm: function() { - if (!this._form) return; - this._form.remove(); - this._form = null; - this._controls = { }; - }, - showSaving: function() { - this._oldInnerHTML = this.element.innerHTML; - this.element.innerHTML = this.options.savingText; - this.element.addClassName(this.options.savingClassName); - this.element.style.backgroundColor = this._originalBackground; - this.element.show(); - }, - triggerCallback: function(cbName, arg) { - if ('function' == typeof this.options[cbName]) { - this.options[cbName](this, arg); - } - }, - unregisterListeners: function() { - $H(this._listeners).each(function(pair) { - if (!this.options.externalControlOnly) - this.element.stopObserving(pair.key, pair.value); - if (this.options.externalControl) - this.options.externalControl.stopObserving(pair.key, pair.value); - }.bind(this)); - }, - wrapUp: function(transport) { - this.leaveEditMode(); - // Can't use triggerCallback due to backward compatibility: requires - // binding + direct element - this._boundComplete(transport, this.element); - } -}); - -Object.extend(Ajax.InPlaceEditor.prototype, { - dispose: Ajax.InPlaceEditor.prototype.destroy -}); - -Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, { - initialize: function($super, element, url, options) { - this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions; - $super(element, url, options); - }, - - createEditField: function() { - var list = document.createElement('select'); - list.name = this.options.paramName; - list.size = 1; - this._controls.editor = list; - this._collection = this.options.collection || []; - if (this.options.loadCollectionURL) - this.loadCollection(); - else - this.checkForExternalText(); - this._form.appendChild(this._controls.editor); - }, - - loadCollection: function() { - this._form.addClassName(this.options.loadingClassName); - this.showLoadingText(this.options.loadingCollectionText); - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: 'editorId=' + encodeURIComponent(this.element.id), - onComplete: Prototype.emptyFunction, - onSuccess: function(transport) { - var js = transport.responseText.strip(); - if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check - throw('Server returned an invalid collection representation.'); - this._collection = eval(js); - this.checkForExternalText(); - }.bind(this), - onFailure: this.onFailure - }); - new Ajax.Request(this.options.loadCollectionURL, options); - }, - - showLoadingText: function(text) { - this._controls.editor.disabled = true; - var tempOption = this._controls.editor.firstChild; - if (!tempOption) { - tempOption = document.createElement('option'); - tempOption.value = ''; - this._controls.editor.appendChild(tempOption); - tempOption.selected = true; - } - tempOption.update((text || '').stripScripts().stripTags()); - }, - - checkForExternalText: function() { - this._text = this.getText(); - if (this.options.loadTextURL) - this.loadExternalText(); - else - this.buildOptionList(); - }, - - loadExternalText: function() { - this.showLoadingText(this.options.loadingText); - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: 'editorId=' + encodeURIComponent(this.element.id), - onComplete: Prototype.emptyFunction, - onSuccess: function(transport) { - this._text = transport.responseText.strip(); - this.buildOptionList(); - }.bind(this), - onFailure: this.onFailure - }); - new Ajax.Request(this.options.loadTextURL, options); - }, - - buildOptionList: function() { - this._form.removeClassName(this.options.loadingClassName); - this._collection = this._collection.map(function(entry) { - return 2 === entry.length ? entry : [entry, entry].flatten(); - }); - var marker = ('value' in this.options) ? this.options.value : this._text; - var textFound = this._collection.any(function(entry) { - return entry[0] == marker; - }.bind(this)); - this._controls.editor.update(''); - var option; - this._collection.each(function(entry, index) { - option = document.createElement('option'); - option.value = entry[0]; - option.selected = textFound ? entry[0] == marker : 0 == index; - option.appendChild(document.createTextNode(entry[1])); - this._controls.editor.appendChild(option); - }.bind(this)); - this._controls.editor.disabled = false; - Field.scrollFreeActivate(this._controls.editor); - } -}); - -//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! **** -//**** This only exists for a while, in order to let **** -//**** users adapt to the new API. Read up on the new **** -//**** API and convert your code to it ASAP! **** - -Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) { - if (!options) return; - function fallback(name, expr) { - if (name in options || expr === undefined) return; - options[name] = expr; - }; - fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' : - options.cancelLink == options.cancelButton == false ? false : undefined))); - fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' : - options.okLink == options.okButton == false ? false : undefined))); - fallback('highlightColor', options.highlightcolor); - fallback('highlightEndColor', options.highlightendcolor); -}; - -Object.extend(Ajax.InPlaceEditor, { - DefaultOptions: { - ajaxOptions: { }, - autoRows: 3, // Use when multi-line w/ rows == 1 - cancelControl: 'link', // 'link'|'button'|false - cancelText: 'cancel', - clickToEditText: 'Click to edit', - externalControl: null, // id|elt - externalControlOnly: false, - fieldPostCreation: 'activate', // 'activate'|'focus'|false - formClassName: 'inplaceeditor-form', - formId: null, // id|elt - highlightColor: '#ffff99', - highlightEndColor: '#ffffff', - hoverClassName: '', - htmlResponse: true, - loadingClassName: 'inplaceeditor-loading', - loadingText: 'Loading...', - okControl: 'button', // 'link'|'button'|false - okText: 'ok', - paramName: 'value', - rows: 1, // If 1 and multi-line, uses autoRows - savingClassName: 'inplaceeditor-saving', - savingText: 'Saving...', - size: 0, - stripLoadedTextTags: false, - submitOnBlur: false, - textAfterControls: '', - textBeforeControls: '', - textBetweenControls: '' - }, - DefaultCallbacks: { - callback: function(form) { - return Form.serialize(form); - }, - onComplete: function(transport, element) { - // For backward compatibility, this one is bound to the IPE, and passes - // the element directly. It was too often customized, so we don't break it. - new Effect.Highlight(element, { - startcolor: this.options.highlightColor, keepBackgroundImage: true }); - }, - onEnterEditMode: null, - onEnterHover: function(ipe) { - ipe.element.style.backgroundColor = ipe.options.highlightColor; - if (ipe._effect) - ipe._effect.cancel(); - }, - onFailure: function(transport, ipe) { - alert('Error communication with the server: ' + transport.responseText.stripTags()); - }, - onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls. - onLeaveEditMode: null, - onLeaveHover: function(ipe) { - ipe._effect = new Effect.Highlight(ipe.element, { - startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor, - restorecolor: ipe._originalBackground, keepBackgroundImage: true - }); - } - }, - Listeners: { - click: 'enterEditMode', - keydown: 'checkForEscapeOrReturn', - mouseover: 'enterHover', - mouseout: 'leaveHover' - } -}); - -Ajax.InPlaceCollectionEditor.DefaultOptions = { - loadingCollectionText: 'Loading options...' -}; - -// Delayed observer, like Form.Element.Observer, -// but waits for delay after last key input -// Ideal for live-search fields - -Form.Element.DelayedObserver = Class.create({ - initialize: function(element, delay, callback) { - this.delay = delay || 0.5; - this.element = $(element); - this.callback = callback; - this.timer = null; - this.lastValue = $F(this.element); - Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); - }, - delayedListener: function(event) { - if(this.lastValue == $F(this.element)) return; - if(this.timer) clearTimeout(this.timer); - this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); - this.lastValue = $F(this.element); - }, - onTimerEvent: function() { - this.timer = null; - this.callback(this.element, $F(this.element)); - } -}); \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/dragdrop.js b/vendor/rails/railties/html/javascripts/dragdrop.js deleted file mode 100644 index 07229f98..00000000 --- a/vendor/rails/railties/html/javascripts/dragdrop.js +++ /dev/null @@ -1,973 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -if(Object.isUndefined(Effect)) - throw("dragdrop.js requires including script.aculo.us' effects.js library"); - -var Droppables = { - drops: [], - - remove: function(element) { - this.drops = this.drops.reject(function(d) { return d.element==$(element) }); - }, - - add: function(element) { - element = $(element); - var options = Object.extend({ - greedy: true, - hoverclass: null, - tree: false - }, arguments[1] || { }); - - // cache containers - if(options.containment) { - options._containers = []; - var containment = options.containment; - if(Object.isArray(containment)) { - containment.each( function(c) { options._containers.push($(c)) }); - } else { - options._containers.push($(containment)); - } - } - - if(options.accept) options.accept = [options.accept].flatten(); - - Element.makePositioned(element); // fix IE - options.element = element; - - this.drops.push(options); - }, - - findDeepestChild: function(drops) { - deepest = drops[0]; - - for (i = 1; i < drops.length; ++i) - if (Element.isParent(drops[i].element, deepest.element)) - deepest = drops[i]; - - return deepest; - }, - - isContained: function(element, drop) { - var containmentNode; - if(drop.tree) { - containmentNode = element.treeNode; - } else { - containmentNode = element.parentNode; - } - return drop._containers.detect(function(c) { return containmentNode == c }); - }, - - isAffected: function(point, element, drop) { - return ( - (drop.element!=element) && - ((!drop._containers) || - this.isContained(element, drop)) && - ((!drop.accept) || - (Element.classNames(element).detect( - function(v) { return drop.accept.include(v) } ) )) && - Position.within(drop.element, point[0], point[1]) ); - }, - - deactivate: function(drop) { - if(drop.hoverclass) - Element.removeClassName(drop.element, drop.hoverclass); - this.last_active = null; - }, - - activate: function(drop) { - if(drop.hoverclass) - Element.addClassName(drop.element, drop.hoverclass); - this.last_active = drop; - }, - - show: function(point, element) { - if(!this.drops.length) return; - var drop, affected = []; - - this.drops.each( function(drop) { - if(Droppables.isAffected(point, element, drop)) - affected.push(drop); - }); - - if(affected.length>0) - drop = Droppables.findDeepestChild(affected); - - if(this.last_active && this.last_active != drop) this.deactivate(this.last_active); - if (drop) { - Position.within(drop.element, point[0], point[1]); - if(drop.onHover) - drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); - - if (drop != this.last_active) Droppables.activate(drop); - } - }, - - fire: function(event, element) { - if(!this.last_active) return; - Position.prepare(); - - if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) - if (this.last_active.onDrop) { - this.last_active.onDrop(element, this.last_active.element, event); - return true; - } - }, - - reset: function() { - if(this.last_active) - this.deactivate(this.last_active); - } -}; - -var Draggables = { - drags: [], - observers: [], - - register: function(draggable) { - if(this.drags.length == 0) { - this.eventMouseUp = this.endDrag.bindAsEventListener(this); - this.eventMouseMove = this.updateDrag.bindAsEventListener(this); - this.eventKeypress = this.keyPress.bindAsEventListener(this); - - Event.observe(document, "mouseup", this.eventMouseUp); - Event.observe(document, "mousemove", this.eventMouseMove); - Event.observe(document, "keypress", this.eventKeypress); - } - this.drags.push(draggable); - }, - - unregister: function(draggable) { - this.drags = this.drags.reject(function(d) { return d==draggable }); - if(this.drags.length == 0) { - Event.stopObserving(document, "mouseup", this.eventMouseUp); - Event.stopObserving(document, "mousemove", this.eventMouseMove); - Event.stopObserving(document, "keypress", this.eventKeypress); - } - }, - - activate: function(draggable) { - if(draggable.options.delay) { - this._timeout = setTimeout(function() { - Draggables._timeout = null; - window.focus(); - Draggables.activeDraggable = draggable; - }.bind(this), draggable.options.delay); - } else { - window.focus(); // allows keypress events if window isn't currently focused, fails for Safari - this.activeDraggable = draggable; - } - }, - - deactivate: function() { - this.activeDraggable = null; - }, - - updateDrag: function(event) { - if(!this.activeDraggable) return; - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - // Mozilla-based browsers fire successive mousemove events with - // the same coordinates, prevent needless redrawing (moz bug?) - if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; - this._lastPointer = pointer; - - this.activeDraggable.updateDrag(event, pointer); - }, - - endDrag: function(event) { - if(this._timeout) { - clearTimeout(this._timeout); - this._timeout = null; - } - if(!this.activeDraggable) return; - this._lastPointer = null; - this.activeDraggable.endDrag(event); - this.activeDraggable = null; - }, - - keyPress: function(event) { - if(this.activeDraggable) - this.activeDraggable.keyPress(event); - }, - - addObserver: function(observer) { - this.observers.push(observer); - this._cacheObserverCallbacks(); - }, - - removeObserver: function(element) { // element instead of observer fixes mem leaks - this.observers = this.observers.reject( function(o) { return o.element==element }); - this._cacheObserverCallbacks(); - }, - - notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' - if(this[eventName+'Count'] > 0) - this.observers.each( function(o) { - if(o[eventName]) o[eventName](eventName, draggable, event); - }); - if(draggable.options[eventName]) draggable.options[eventName](draggable, event); - }, - - _cacheObserverCallbacks: function() { - ['onStart','onEnd','onDrag'].each( function(eventName) { - Draggables[eventName+'Count'] = Draggables.observers.select( - function(o) { return o[eventName]; } - ).length; - }); - } -}; - -/*--------------------------------------------------------------------------*/ - -var Draggable = Class.create({ - initialize: function(element) { - var defaults = { - handle: false, - reverteffect: function(element, top_offset, left_offset) { - var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; - new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, - queue: {scope:'_draggable', position:'end'} - }); - }, - endeffect: function(element) { - var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0; - new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, - queue: {scope:'_draggable', position:'end'}, - afterFinish: function(){ - Draggable._dragging[element] = false - } - }); - }, - zindex: 1000, - revert: false, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } - delay: 0 - }; - - if(!arguments[1] || Object.isUndefined(arguments[1].endeffect)) - Object.extend(defaults, { - starteffect: function(element) { - element._opacity = Element.getOpacity(element); - Draggable._dragging[element] = true; - new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); - } - }); - - var options = Object.extend(defaults, arguments[1] || { }); - - this.element = $(element); - - if(options.handle && Object.isString(options.handle)) - this.handle = this.element.down('.'+options.handle, 0); - - if(!this.handle) this.handle = $(options.handle); - if(!this.handle) this.handle = this.element; - - if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { - options.scroll = $(options.scroll); - this._isScrollChild = Element.childOf(this.element, options.scroll); - } - - Element.makePositioned(this.element); // fix IE - - this.options = options; - this.dragging = false; - - this.eventMouseDown = this.initDrag.bindAsEventListener(this); - Event.observe(this.handle, "mousedown", this.eventMouseDown); - - Draggables.register(this); - }, - - destroy: function() { - Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); - Draggables.unregister(this); - }, - - currentDelta: function() { - return([ - parseInt(Element.getStyle(this.element,'left') || '0'), - parseInt(Element.getStyle(this.element,'top') || '0')]); - }, - - initDrag: function(event) { - if(!Object.isUndefined(Draggable._dragging[this.element]) && - Draggable._dragging[this.element]) return; - if(Event.isLeftClick(event)) { - // abort on form elements, fixes a Firefox issue - var src = Event.element(event); - if((tag_name = src.tagName.toUpperCase()) && ( - tag_name=='INPUT' || - tag_name=='SELECT' || - tag_name=='OPTION' || - tag_name=='BUTTON' || - tag_name=='TEXTAREA')) return; - - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var pos = Position.cumulativeOffset(this.element); - this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); - - Draggables.activate(this); - Event.stop(event); - } - }, - - startDrag: function(event) { - this.dragging = true; - if(!this.delta) - this.delta = this.currentDelta(); - - if(this.options.zindex) { - this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); - this.element.style.zIndex = this.options.zindex; - } - - if(this.options.ghosting) { - this._clone = this.element.cloneNode(true); - this._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); - if (!this._originallyAbsolute) - Position.absolutize(this.element); - this.element.parentNode.insertBefore(this._clone, this.element); - } - - if(this.options.scroll) { - if (this.options.scroll == window) { - var where = this._getWindowScroll(this.options.scroll); - this.originalScrollLeft = where.left; - this.originalScrollTop = where.top; - } else { - this.originalScrollLeft = this.options.scroll.scrollLeft; - this.originalScrollTop = this.options.scroll.scrollTop; - } - } - - Draggables.notify('onStart', this, event); - - if(this.options.starteffect) this.options.starteffect(this.element); - }, - - updateDrag: function(event, pointer) { - if(!this.dragging) this.startDrag(event); - - if(!this.options.quiet){ - Position.prepare(); - Droppables.show(pointer, this.element); - } - - Draggables.notify('onDrag', this, event); - - this.draw(pointer); - if(this.options.change) this.options.change(this); - - if(this.options.scroll) { - this.stopScrolling(); - - var p; - if (this.options.scroll == window) { - with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } - } else { - p = Position.page(this.options.scroll); - p[0] += this.options.scroll.scrollLeft + Position.deltaX; - p[1] += this.options.scroll.scrollTop + Position.deltaY; - p.push(p[0]+this.options.scroll.offsetWidth); - p.push(p[1]+this.options.scroll.offsetHeight); - } - var speed = [0,0]; - if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity); - if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity); - if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity); - if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); - this.startScrolling(speed); - } - - // fix AppleWebKit rendering - if(Prototype.Browser.WebKit) window.scrollBy(0,0); - - Event.stop(event); - }, - - finishDrag: function(event, success) { - this.dragging = false; - - if(this.options.quiet){ - Position.prepare(); - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - Droppables.show(pointer, this.element); - } - - if(this.options.ghosting) { - if (!this._originallyAbsolute) - Position.relativize(this.element); - delete this._originallyAbsolute; - Element.remove(this._clone); - this._clone = null; - } - - var dropped = false; - if(success) { - dropped = Droppables.fire(event, this.element); - if (!dropped) dropped = false; - } - if(dropped && this.options.onDropped) this.options.onDropped(this.element); - Draggables.notify('onEnd', this, event); - - var revert = this.options.revert; - if(revert && Object.isFunction(revert)) revert = revert(this.element); - - var d = this.currentDelta(); - if(revert && this.options.reverteffect) { - if (dropped == 0 || revert != 'failure') - this.options.reverteffect(this.element, - d[1]-this.delta[1], d[0]-this.delta[0]); - } else { - this.delta = d; - } - - if(this.options.zindex) - this.element.style.zIndex = this.originalZ; - - if(this.options.endeffect) - this.options.endeffect(this.element); - - Draggables.deactivate(this); - Droppables.reset(); - }, - - keyPress: function(event) { - if(event.keyCode!=Event.KEY_ESC) return; - this.finishDrag(event, false); - Event.stop(event); - }, - - endDrag: function(event) { - if(!this.dragging) return; - this.stopScrolling(); - this.finishDrag(event, true); - Event.stop(event); - }, - - draw: function(point) { - var pos = Position.cumulativeOffset(this.element); - if(this.options.ghosting) { - var r = Position.realOffset(this.element); - pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; - } - - var d = this.currentDelta(); - pos[0] -= d[0]; pos[1] -= d[1]; - - if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { - pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; - pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; - } - - var p = [0,1].map(function(i){ - return (point[i]-pos[i]-this.offset[i]) - }.bind(this)); - - if(this.options.snap) { - if(Object.isFunction(this.options.snap)) { - p = this.options.snap(p[0],p[1],this); - } else { - if(Object.isArray(this.options.snap)) { - p = p.map( function(v, i) { - return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)); - } else { - p = p.map( function(v) { - return (v/this.options.snap).round()*this.options.snap }.bind(this)); - } - }} - - var style = this.element.style; - if((!this.options.constraint) || (this.options.constraint=='horizontal')) - style.left = p[0] + "px"; - if((!this.options.constraint) || (this.options.constraint=='vertical')) - style.top = p[1] + "px"; - - if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering - }, - - stopScrolling: function() { - if(this.scrollInterval) { - clearInterval(this.scrollInterval); - this.scrollInterval = null; - Draggables._lastScrollPointer = null; - } - }, - - startScrolling: function(speed) { - if(!(speed[0] || speed[1])) return; - this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; - this.lastScrolled = new Date(); - this.scrollInterval = setInterval(this.scroll.bind(this), 10); - }, - - scroll: function() { - var current = new Date(); - var delta = current - this.lastScrolled; - this.lastScrolled = current; - if(this.options.scroll == window) { - with (this._getWindowScroll(this.options.scroll)) { - if (this.scrollSpeed[0] || this.scrollSpeed[1]) { - var d = delta / 1000; - this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] ); - } - } - } else { - this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; - this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; - } - - Position.prepare(); - Droppables.show(Draggables._lastPointer, this.element); - Draggables.notify('onDrag', this); - if (this._isScrollChild) { - Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); - Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; - Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; - if (Draggables._lastScrollPointer[0] < 0) - Draggables._lastScrollPointer[0] = 0; - if (Draggables._lastScrollPointer[1] < 0) - Draggables._lastScrollPointer[1] = 0; - this.draw(Draggables._lastScrollPointer); - } - - if(this.options.change) this.options.change(this); - }, - - _getWindowScroll: function(w) { - var T, L, W, H; - with (w.document) { - if (w.document.documentElement && documentElement.scrollTop) { - T = documentElement.scrollTop; - L = documentElement.scrollLeft; - } else if (w.document.body) { - T = body.scrollTop; - L = body.scrollLeft; - } - if (w.innerWidth) { - W = w.innerWidth; - H = w.innerHeight; - } else if (w.document.documentElement && documentElement.clientWidth) { - W = documentElement.clientWidth; - H = documentElement.clientHeight; - } else { - W = body.offsetWidth; - H = body.offsetHeight; - } - } - return { top: T, left: L, width: W, height: H }; - } -}); - -Draggable._dragging = { }; - -/*--------------------------------------------------------------------------*/ - -var SortableObserver = Class.create({ - initialize: function(element, observer) { - this.element = $(element); - this.observer = observer; - this.lastValue = Sortable.serialize(this.element); - }, - - onStart: function() { - this.lastValue = Sortable.serialize(this.element); - }, - - onEnd: function() { - Sortable.unmark(); - if(this.lastValue != Sortable.serialize(this.element)) - this.observer(this.element) - } -}); - -var Sortable = { - SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, - - sortables: { }, - - _findRootElement: function(element) { - while (element.tagName.toUpperCase() != "BODY") { - if(element.id && Sortable.sortables[element.id]) return element; - element = element.parentNode; - } - }, - - options: function(element) { - element = Sortable._findRootElement($(element)); - if(!element) return; - return Sortable.sortables[element.id]; - }, - - destroy: function(element){ - element = $(element); - var s = Sortable.sortables[element.id]; - - if(s) { - Draggables.removeObserver(s.element); - s.droppables.each(function(d){ Droppables.remove(d) }); - s.draggables.invoke('destroy'); - - delete Sortable.sortables[s.element.id]; - } - }, - - create: function(element) { - element = $(element); - var options = Object.extend({ - element: element, - tag: 'li', // assumes li children, override with tag: 'tagname' - dropOnEmpty: false, - tree: false, - treeTag: 'ul', - overlap: 'vertical', // one of 'vertical', 'horizontal' - constraint: 'vertical', // one of 'vertical', 'horizontal', false - containment: element, // also takes array of elements (or id's); or false - handle: false, // or a CSS class - only: false, - delay: 0, - hoverclass: null, - ghosting: false, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - format: this.SERIALIZE_RULE, - - // these take arrays of elements or ids and can be - // used for better initialization performance - elements: false, - handles: false, - - onChange: Prototype.emptyFunction, - onUpdate: Prototype.emptyFunction - }, arguments[1] || { }); - - // clear any old sortable with same element - this.destroy(element); - - // build options for the draggables - var options_for_draggable = { - revert: true, - quiet: options.quiet, - scroll: options.scroll, - scrollSpeed: options.scrollSpeed, - scrollSensitivity: options.scrollSensitivity, - delay: options.delay, - ghosting: options.ghosting, - constraint: options.constraint, - handle: options.handle }; - - if(options.starteffect) - options_for_draggable.starteffect = options.starteffect; - - if(options.reverteffect) - options_for_draggable.reverteffect = options.reverteffect; - else - if(options.ghosting) options_for_draggable.reverteffect = function(element) { - element.style.top = 0; - element.style.left = 0; - }; - - if(options.endeffect) - options_for_draggable.endeffect = options.endeffect; - - if(options.zindex) - options_for_draggable.zindex = options.zindex; - - // build options for the droppables - var options_for_droppable = { - overlap: options.overlap, - containment: options.containment, - tree: options.tree, - hoverclass: options.hoverclass, - onHover: Sortable.onHover - }; - - var options_for_tree = { - onHover: Sortable.onEmptyHover, - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass - }; - - // fix for gecko engine - Element.cleanWhitespace(element); - - options.draggables = []; - options.droppables = []; - - // drop on empty handling - if(options.dropOnEmpty || options.tree) { - Droppables.add(element, options_for_tree); - options.droppables.push(element); - } - - (options.elements || this.findElements(element, options) || []).each( function(e,i) { - var handle = options.handles ? $(options.handles[i]) : - (options.handle ? $(e).select('.' + options.handle)[0] : e); - options.draggables.push( - new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); - Droppables.add(e, options_for_droppable); - if(options.tree) e.treeNode = element; - options.droppables.push(e); - }); - - if(options.tree) { - (Sortable.findTreeElements(element, options) || []).each( function(e) { - Droppables.add(e, options_for_tree); - e.treeNode = element; - options.droppables.push(e); - }); - } - - // keep reference - this.sortables[element.id] = options; - - // for onupdate - Draggables.addObserver(new SortableObserver(element, options.onUpdate)); - - }, - - // return all suitable-for-sortable elements in a guaranteed order - findElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.tag); - }, - - findTreeElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.treeTag); - }, - - onHover: function(element, dropon, overlap) { - if(Element.isParent(dropon, element)) return; - - if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) { - return; - } else if(overlap>0.5) { - Sortable.mark(dropon, 'before'); - if(dropon.previousSibling != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, dropon); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } else { - Sortable.mark(dropon, 'after'); - var nextElement = dropon.nextSibling || null; - if(nextElement != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, nextElement); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } - }, - - onEmptyHover: function(element, dropon, overlap) { - var oldParentNode = element.parentNode; - var droponOptions = Sortable.options(dropon); - - if(!Element.isParent(dropon, element)) { - var index; - - var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); - var child = null; - - if(children) { - var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); - - for (index = 0; index < children.length; index += 1) { - if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) { - offset -= Element.offsetSize (children[index], droponOptions.overlap); - } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { - child = index + 1 < children.length ? children[index + 1] : null; - break; - } else { - child = children[index]; - break; - } - } - } - - dropon.insertBefore(element, child); - - Sortable.options(oldParentNode).onChange(element); - droponOptions.onChange(element); - } - }, - - unmark: function() { - if(Sortable._marker) Sortable._marker.hide(); - }, - - mark: function(dropon, position) { - // mark on ghosting only - var sortable = Sortable.options(dropon.parentNode); - if(sortable && !sortable.ghosting) return; - - if(!Sortable._marker) { - Sortable._marker = - ($('dropmarker') || Element.extend(document.createElement('DIV'))). - hide().addClassName('dropmarker').setStyle({position:'absolute'}); - document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); - } - var offsets = Position.cumulativeOffset(dropon); - Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); - - if(position=='after') - if(sortable.overlap == 'horizontal') - Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); - else - Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); - - Sortable._marker.show(); - }, - - _tree: function(element, options, parent) { - var children = Sortable.findElements(element, options) || []; - - for (var i = 0; i < children.length; ++i) { - var match = children[i].id.match(options.format); - - if (!match) continue; - - var child = { - id: encodeURIComponent(match ? match[1] : null), - element: element, - parent: parent, - children: [], - position: parent.children.length, - container: $(children[i]).down(options.treeTag) - }; - - /* Get the element containing the children and recurse over it */ - if (child.container) - this._tree(child.container, options, child); - - parent.children.push (child); - } - - return parent; - }, - - tree: function(element) { - element = $(element); - var sortableOptions = this.options(element); - var options = Object.extend({ - tag: sortableOptions.tag, - treeTag: sortableOptions.treeTag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format - }, arguments[1] || { }); - - var root = { - id: null, - parent: null, - children: [], - container: element, - position: 0 - }; - - return Sortable._tree(element, options, root); - }, - - /* Construct a [i] index for a particular node */ - _constructIndex: function(node) { - var index = ''; - do { - if (node.id) index = '[' + node.position + ']' + index; - } while ((node = node.parent) != null); - return index; - }, - - sequence: function(element) { - element = $(element); - var options = Object.extend(this.options(element), arguments[1] || { }); - - return $(this.findElements(element, options) || []).map( function(item) { - return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; - }); - }, - - setSequence: function(element, new_sequence) { - element = $(element); - var options = Object.extend(this.options(element), arguments[2] || { }); - - var nodeMap = { }; - this.findElements(element, options).each( function(n) { - if (n.id.match(options.format)) - nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; - n.parentNode.removeChild(n); - }); - - new_sequence.each(function(ident) { - var n = nodeMap[ident]; - if (n) { - n[1].appendChild(n[0]); - delete nodeMap[ident]; - } - }); - }, - - serialize: function(element) { - element = $(element); - var options = Object.extend(Sortable.options(element), arguments[1] || { }); - var name = encodeURIComponent( - (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); - - if (options.tree) { - return Sortable.tree(element, arguments[1]).children.map( function (item) { - return [name + Sortable._constructIndex(item) + "[id]=" + - encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); - }).flatten().join('&'); - } else { - return Sortable.sequence(element, arguments[1]).map( function(item) { - return name + "[]=" + encodeURIComponent(item); - }).join('&'); - } - } -}; - -// Returns true if child is contained within element -Element.isParent = function(child, element) { - if (!child.parentNode || child == element) return false; - if (child.parentNode == element) return true; - return Element.isParent(child.parentNode, element); -}; - -Element.findChildren = function(element, only, recursive, tagName) { - if(!element.hasChildNodes()) return null; - tagName = tagName.toUpperCase(); - if(only) only = [only].flatten(); - var elements = []; - $A(element.childNodes).each( function(e) { - if(e.tagName && e.tagName.toUpperCase()==tagName && - (!only || (Element.classNames(e).detect(function(v) { return only.include(v) })))) - elements.push(e); - if(recursive) { - var grandchildren = Element.findChildren(e, only, recursive, tagName); - if(grandchildren) elements.push(grandchildren); - } - }); - - return (elements.length>0 ? elements.flatten() : []); -}; - -Element.offsetSize = function (element, type) { - return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; -}; \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/effects.js b/vendor/rails/railties/html/javascripts/effects.js deleted file mode 100644 index 5a639d2d..00000000 --- a/vendor/rails/railties/html/javascripts/effects.js +++ /dev/null @@ -1,1128 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// Contributors: -// Justin Palmer (http://encytemedia.com/) -// Mark Pilgrim (http://diveintomark.org/) -// Martin Bialasinki -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -// converts rgb() and #xxx to #xxxxxx format, -// returns self (or first argument) if not convertable -String.prototype.parseColor = function() { - var color = '#'; - if (this.slice(0,4) == 'rgb(') { - var cols = this.slice(4,this.length-1).split(','); - var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); - } else { - if (this.slice(0,1) == '#') { - if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); - if (this.length==7) color = this.toLowerCase(); - } - } - return (color.length==7 ? color : (arguments[0] || this)); -}; - -/*--------------------------------------------------------------------------*/ - -Element.collectTextNodes = function(element) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); - }).flatten().join(''); -}; - -Element.collectTextNodesIgnoreClass = function(element, className) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? - Element.collectTextNodesIgnoreClass(node, className) : '')); - }).flatten().join(''); -}; - -Element.setContentZoom = function(element, percent) { - element = $(element); - element.setStyle({fontSize: (percent/100) + 'em'}); - if (Prototype.Browser.WebKit) window.scrollBy(0,0); - return element; -}; - -Element.getInlineOpacity = function(element){ - return $(element).style.opacity || ''; -}; - -Element.forceRerendering = function(element) { - try { - element = $(element); - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch(e) { } -}; - -/*--------------------------------------------------------------------------*/ - -var Effect = { - _elementDoesNotExistError: { - name: 'ElementDoesNotExistError', - message: 'The specified DOM element does not exist, but is required for this effect to operate' - }, - Transitions: { - linear: Prototype.K, - sinoidal: function(pos) { - return (-Math.cos(pos*Math.PI)/2) + .5; - }, - reverse: function(pos) { - return 1-pos; - }, - flicker: function(pos) { - var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4; - return pos > 1 ? 1 : pos; - }, - wobble: function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5; - }, - pulse: function(pos, pulses) { - return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5; - }, - spring: function(pos) { - return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); - }, - none: function(pos) { - return 0; - }, - full: function(pos) { - return 1; - } - }, - DefaultOptions: { - duration: 1.0, // seconds - fps: 100, // 100= assume 66fps max. - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' - }, - tagifyText: function(element) { - var tagifyStyle = 'position:relative'; - if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; - - element = $(element); - $A(element.childNodes).each( function(child) { - if (child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - new Element('span', {style: tagifyStyle}).update( - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if (((typeof element == 'object') || - Object.isFunction(element)) && - (element.length)) - elements = element; - else - elements = $(element).childNodes; - - var options = Object.extend({ - speed: 0.1, - delay: 0.0 - }, arguments[2] || { }); - var masterDelay = options.delay; - - $A(elements).each( function(element, index) { - new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); - }); - }, - PAIRS: { - 'slide': ['SlideDown','SlideUp'], - 'blind': ['BlindDown','BlindUp'], - 'appear': ['Appear','Fade'] - }, - toggle: function(element, effect) { - element = $(element); - effect = (effect || 'appear').toLowerCase(); - var options = Object.extend({ - queue: { position:'end', scope:(element.id || 'global'), limit: 1 } - }, arguments[2] || { }); - Effect[element.visible() ? - Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); - } -}; - -Effect.DefaultOptions.transition = Effect.Transitions.sinoidal; - -/* ------------- core effects ------------- */ - -Effect.ScopedQueue = Class.create(Enumerable, { - initialize: function() { - this.effects = []; - this.interval = null; - }, - _each: function(iterator) { - this.effects._each(iterator); - }, - add: function(effect) { - var timestamp = new Date().getTime(); - - var position = Object.isString(effect.options.queue) ? - effect.options.queue : effect.options.queue.position; - - switch(position) { - case 'front': - // move unstarted effects after this effect - this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - }); - break; - case 'with-last': - timestamp = this.effects.pluck('startOn').max() || timestamp; - break; - case 'end': - // start effect after last queued effect has finished - timestamp = this.effects.pluck('finishOn').max() || timestamp; - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - - if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) - this.effects.push(effect); - - if (!this.interval) - this.interval = setInterval(this.loop.bind(this), 15); - }, - remove: function(effect) { - this.effects = this.effects.reject(function(e) { return e==effect }); - if (this.effects.length == 0) { - clearInterval(this.interval); - this.interval = null; - } - }, - loop: function() { - var timePos = new Date().getTime(); - for(var i=0, len=this.effects.length;i<len;i++) - this.effects[i] && this.effects[i].loop(timePos); - } -}); - -Effect.Queues = { - instances: $H(), - get: function(queueName) { - if (!Object.isString(queueName)) return queueName; - - return this.instances.get(queueName) || - this.instances.set(queueName, new Effect.ScopedQueue()); - } -}; -Effect.Queue = Effect.Queues.get('global'); - -Effect.Base = Class.create({ - position: null, - start: function(options) { - function codeForEvent(options,eventName){ - return ( - (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') + - (options[eventName] ? 'this.options.'+eventName+'(this);' : '') - ); - } - if (options && options.transition === false) options.transition = Effect.Transitions.linear; - this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { }); - this.currentFrame = 0; - this.state = 'idle'; - this.startOn = this.options.delay*1000; - this.finishOn = this.startOn+(this.options.duration*1000); - this.fromToDelta = this.options.to-this.options.from; - this.totalTime = this.finishOn-this.startOn; - this.totalFrames = this.options.fps*this.options.duration; - - this.render = (function() { - function dispatch(effect, eventName) { - if (effect.options[eventName + 'Internal']) - effect.options[eventName + 'Internal'](effect); - if (effect.options[eventName]) - effect.options[eventName](effect); - } - - return function(pos) { - if (this.state === "idle") { - this.state = "running"; - dispatch(this, 'beforeSetup'); - if (this.setup) this.setup(); - dispatch(this, 'afterSetup'); - } - if (this.state === "running") { - pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from; - this.position = pos; - dispatch(this, 'beforeUpdate'); - if (this.update) this.update(pos); - dispatch(this, 'afterUpdate'); - } - }; - })(); - - this.event('beforeStart'); - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - 'global' : this.options.queue.scope).add(this); - }, - loop: function(timePos) { - if (timePos >= this.startOn) { - if (timePos >= this.finishOn) { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - if (this.finish) this.finish(); - this.event('afterFinish'); - return; - } - var pos = (timePos - this.startOn) / this.totalTime, - frame = (pos * this.totalFrames).round(); - if (frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - cancel: function() { - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - 'global' : this.options.queue.scope).remove(this); - this.state = 'finished'; - }, - event: function(eventName) { - if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); - if (this.options[eventName]) this.options[eventName](this); - }, - inspect: function() { - var data = $H(); - for(property in this) - if (!Object.isFunction(this[property])) data.set(property, this[property]); - return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>'; - } -}); - -Effect.Parallel = Class.create(Effect.Base, { - initialize: function(effects) { - this.effects = effects || []; - this.start(arguments[1]); - }, - update: function(position) { - this.effects.invoke('render', position); - }, - finish: function(position) { - this.effects.each( function(effect) { - effect.render(1.0); - effect.cancel(); - effect.event('beforeFinish'); - if (effect.finish) effect.finish(position); - effect.event('afterFinish'); - }); - } -}); - -Effect.Tween = Class.create(Effect.Base, { - initialize: function(object, from, to) { - object = Object.isString(object) ? $(object) : object; - var args = $A(arguments), method = args.last(), - options = args.length == 5 ? args[3] : null; - this.method = Object.isFunction(method) ? method.bind(object) : - Object.isFunction(object[method]) ? object[method].bind(object) : - function(value) { object[method] = value }; - this.start(Object.extend({ from: from, to: to }, options || { })); - }, - update: function(position) { - this.method(position); - } -}); - -Effect.Event = Class.create(Effect.Base, { - initialize: function() { - this.start(Object.extend({ duration: 0 }, arguments[0] || { })); - }, - update: Prototype.emptyFunction -}); - -Effect.Opacity = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - // make this work on IE on elements without 'layout' - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - var options = Object.extend({ - from: this.element.getOpacity() || 0.0, - to: 1.0 - }, arguments[1] || { }); - this.start(options); - }, - update: function(position) { - this.element.setOpacity(position); - } -}); - -Effect.Move = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - x: 0, - y: 0, - mode: 'relative' - }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - this.element.makePositioned(); - this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); - this.originalTop = parseFloat(this.element.getStyle('top') || '0'); - if (this.options.mode == 'absolute') { - this.options.x = this.options.x - this.originalLeft; - this.options.y = this.options.y - this.originalTop; - } - }, - update: function(position) { - this.element.setStyle({ - left: (this.options.x * position + this.originalLeft).round() + 'px', - top: (this.options.y * position + this.originalTop).round() + 'px' - }); - } -}); - -// for backwards compatibility -Effect.MoveBy = function(element, toTop, toLeft) { - return new Effect.Move(element, - Object.extend({ x: toLeft, y: toTop }, arguments[3] || { })); -}; - -Effect.Scale = Class.create(Effect.Base, { - initialize: function(element, percent) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or { } with provided values - scaleFrom: 100.0, - scaleTo: percent - }, arguments[2] || { }); - this.start(options); - }, - setup: function() { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = this.element.getStyle('position'); - - this.originalStyle = { }; - ['top','left','width','height','fontSize'].each( function(k) { - this.originalStyle[k] = this.element.style[k]; - }.bind(this)); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = this.element.getStyle('font-size') || '100%'; - ['em','px','%','pt'].each( function(fontSizeType) { - if (fontSize.indexOf(fontSizeType)>0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }.bind(this)); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - this.dims = null; - if (this.options.scaleMode=='box') - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - if (/^content/.test(this.options.scaleMode)) - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - if (!this.dims) - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - }, - update: function(position) { - var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); - if (this.options.scaleContent && this.fontSize) - this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType }); - this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); - }, - finish: function(position) { - if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle); - }, - setDimensions: function(height, width) { - var d = { }; - if (this.options.scaleX) d.width = width.round() + 'px'; - if (this.options.scaleY) d.height = height.round() + 'px'; - if (this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if (this.elementPositioning == 'absolute') { - if (this.options.scaleY) d.top = this.originalTop-topd + 'px'; - if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; - } else { - if (this.options.scaleY) d.top = -topd + 'px'; - if (this.options.scaleX) d.left = -leftd + 'px'; - } - } - this.element.setStyle(d); - } -}); - -Effect.Highlight = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - // Prevent executing on elements not in the layout flow - if (this.element.getStyle('display')=='none') { this.cancel(); return; } - // Disable background image during the effect - this.oldStyle = { }; - if (!this.options.keepBackgroundImage) { - this.oldStyle.backgroundImage = this.element.getStyle('background-image'); - this.element.setStyle({backgroundImage: 'none'}); - } - if (!this.options.endcolor) - this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); - if (!this.options.restorecolor) - this.options.restorecolor = this.element.getStyle('background-color'); - // init color calculations - this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); - this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); - }, - update: function(position) { - this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){ - return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) }); - }, - finish: function() { - this.element.setStyle(Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = function(element) { - var options = arguments[1] || { }, - scrollOffsets = document.viewport.getScrollOffsets(), - elementOffsets = $(element).cumulativeOffset(); - - if (options.offset) elementOffsets[1] += options.offset; - - return new Effect.Tween(null, - scrollOffsets.top, - elementOffsets[1], - options, - function(p){ scrollTo(scrollOffsets.left, p.round()); } - ); -}; - -/* ------------- combination effects ------------- */ - -Effect.Fade = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - var options = Object.extend({ - from: element.getOpacity() || 1.0, - to: 0.0, - afterFinishInternal: function(effect) { - if (effect.options.to!=0) return; - effect.element.hide().setStyle({opacity: oldOpacity}); - } - }, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Appear = function(element) { - element = $(element); - var options = Object.extend({ - from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0), - to: 1.0, - // force Safari to render floated elements properly - afterFinishInternal: function(effect) { - effect.element.forceRerendering(); - }, - beforeSetup: function(effect) { - effect.element.setOpacity(effect.options.from).show(); - }}, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Puff = function(element) { - element = $(element); - var oldStyle = { - opacity: element.getInlineOpacity(), - position: element.getStyle('position'), - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height - }; - return new Effect.Parallel( - [ new Effect.Scale(element, 200, - { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], - Object.extend({ duration: 1.0, - beforeSetupInternal: function(effect) { - Position.absolutize(effect.effects[0].element); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().setStyle(oldStyle); } - }, arguments[1] || { }) - ); -}; - -Effect.BlindUp = function(element) { - element = $(element); - element.makeClipping(); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }, arguments[1] || { }) - ); -}; - -Effect.BlindDown = function(element) { - element = $(element); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping(); - } - }, arguments[1] || { })); -}; - -Effect.SwitchOff = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - return new Effect.Appear(element, Object.extend({ - duration: 0.4, - from: 0, - transition: Effect.Transitions.flicker, - afterFinishInternal: function(effect) { - new Effect.Scale(effect.element, 1, { - duration: 0.3, scaleFromCenter: true, - scaleX: false, scaleContent: false, restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); - } - }); - } - }, arguments[1] || { })); -}; - -Effect.DropOut = function(element) { - element = $(element); - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left'), - opacity: element.getInlineOpacity() }; - return new Effect.Parallel( - [ new Effect.Move(element, {x: 0, y: 100, sync: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 }) ], - Object.extend( - { duration: 0.5, - beforeSetup: function(effect) { - effect.effects[0].element.makePositioned(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); - } - }, arguments[1] || { })); -}; - -Effect.Shake = function(element) { - element = $(element); - var options = Object.extend({ - distance: 20, - duration: 0.5 - }, arguments[1] || {}); - var distance = parseFloat(options.distance); - var split = parseFloat(options.duration) / 10.0; - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left') }; - return new Effect.Move(element, - { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { - effect.element.undoPositioned().setStyle(oldStyle); - }}); }}); }}); }}); }}); }}); -}; - -Effect.SlideDown = function(element) { - element = $(element).cleanWhitespace(); - // SlideDown need to have the content of the element wrapped in a container element with fixed height! - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: window.opera ? 0 : 1, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } - }, arguments[1] || { }) - ); -}; - -Effect.SlideUp = function(element) { - element = $(element).cleanWhitespace(); - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, window.opera ? 0 : 1, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); - } - }, arguments[1] || { }) - ); -}; - -// Bug in opera makes the TD containing this element expand for a instance after finish -Effect.Squish = function(element) { - return new Effect.Scale(element, window.opera ? 1 : 0, { - restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }); -}; - -Effect.Grow = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.full - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.width; - initialMoveY = moveY = 0; - moveX = -dims.width; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.height; - moveY = -dims.height; - break; - case 'bottom-right': - initialMoveX = dims.width; - initialMoveY = dims.height; - moveX = -dims.width; - moveY = -dims.height; - break; - case 'center': - initialMoveX = dims.width / 2; - initialMoveY = dims.height / 2; - moveX = -dims.width / 2; - moveY = -dims.height / 2; - break; - } - - return new Effect.Move(element, { - x: initialMoveX, - y: initialMoveY, - duration: 0.01, - beforeSetup: function(effect) { - effect.element.hide().makeClipping().makePositioned(); - }, - afterFinishInternal: function(effect) { - new Effect.Parallel( - [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), - new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), - new Effect.Scale(effect.element, 100, { - scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, - sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) - ], Object.extend({ - beforeSetup: function(effect) { - effect.effects[0].element.setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); - } - }, options) - ); - } - }); -}; - -Effect.Shrink = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.none - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.width; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.height; - break; - case 'bottom-right': - moveX = dims.width; - moveY = dims.height; - break; - case 'center': - moveX = dims.width / 2; - moveY = dims.height / 2; - break; - } - - return new Effect.Parallel( - [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), - new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), - new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) - ], Object.extend({ - beforeStartInternal: function(effect) { - effect.effects[0].element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } - }, options) - ); -}; - -Effect.Pulsate = function(element) { - element = $(element); - var options = arguments[1] || { }, - oldOpacity = element.getInlineOpacity(), - transition = options.transition || Effect.Transitions.linear, - reverser = function(pos){ - return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5); - }; - - return new Effect.Opacity(element, - Object.extend(Object.extend({ duration: 2.0, from: 0, - afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } - }, options), {transition: reverser})); -}; - -Effect.Fold = function(element) { - element = $(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height }; - element.makeClipping(); - return new Effect.Scale(element, 5, Object.extend({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function(effect) { - new Effect.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().setStyle(oldStyle); - } }); - }}, arguments[1] || { })); -}; - -Effect.Morph = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - style: { } - }, arguments[1] || { }); - - if (!Object.isString(options.style)) this.style = $H(options.style); - else { - if (options.style.include(':')) - this.style = options.style.parseStyle(); - else { - this.element.addClassName(options.style); - this.style = $H(this.element.getStyles()); - this.element.removeClassName(options.style); - var css = this.element.getStyles(); - this.style = this.style.reject(function(style) { - return style.value == css[style.key]; - }); - options.afterFinishInternal = function(effect) { - effect.element.addClassName(effect.options.style); - effect.transforms.each(function(transform) { - effect.element.style[transform.style] = ''; - }); - }; - } - } - this.start(options); - }, - - setup: function(){ - function parseColor(color){ - if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; - color = color.parseColor(); - return $R(0,2).map(function(i){ - return parseInt( color.slice(i*2+1,i*2+3), 16 ); - }); - } - this.transforms = this.style.map(function(pair){ - var property = pair[0], value = pair[1], unit = null; - - if (value.parseColor('#zzzzzz') != '#zzzzzz') { - value = value.parseColor(); - unit = 'color'; - } else if (property == 'opacity') { - value = parseFloat(value); - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - } else if (Element.CSS_LENGTH.test(value)) { - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - unit = (components.length == 3) ? components[2] : null; - } - - var originalValue = this.element.getStyle(property); - return { - style: property.camelize(), - originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), - targetValue: unit=='color' ? parseColor(value) : value, - unit: unit - }; - }.bind(this)).reject(function(transform){ - return ( - (transform.originalValue == transform.targetValue) || - ( - transform.unit != 'color' && - (isNaN(transform.originalValue) || isNaN(transform.targetValue)) - ) - ); - }); - }, - update: function(position) { - var style = { }, transform, i = this.transforms.length; - while(i--) - style[(transform = this.transforms[i]).style] = - transform.unit=='color' ? '#'+ - (Math.round(transform.originalValue[0]+ - (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() + - (Math.round(transform.originalValue[1]+ - (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() + - (Math.round(transform.originalValue[2]+ - (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : - (transform.originalValue + - (transform.targetValue - transform.originalValue) * position).toFixed(3) + - (transform.unit === null ? '' : transform.unit); - this.element.setStyle(style, true); - } -}); - -Effect.Transform = Class.create({ - initialize: function(tracks){ - this.tracks = []; - this.options = arguments[1] || { }; - this.addTracks(tracks); - }, - addTracks: function(tracks){ - tracks.each(function(track){ - track = $H(track); - var data = track.values().first(); - this.tracks.push($H({ - ids: track.keys().first(), - effect: Effect.Morph, - options: { style: data } - })); - }.bind(this)); - return this; - }, - play: function(){ - return new Effect.Parallel( - this.tracks.map(function(track){ - var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options'); - var elements = [$(ids) || $$(ids)].flatten(); - return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) }); - }).flatten(), - this.options - ); - } -}); - -Element.CSS_PROPERTIES = $w( - 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + - 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + - 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + - 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + - 'fontSize fontWeight height left letterSpacing lineHeight ' + - 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ - 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + - 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + - 'right textIndent top width wordSpacing zIndex'); - -Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -String.__parseStyleElement = document.createElement('div'); -String.prototype.parseStyle = function(){ - var style, styleRules = $H(); - if (Prototype.Browser.WebKit) - style = new Element('div',{style:this}).style; - else { - String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>'; - style = String.__parseStyleElement.childNodes[0].style; - } - - Element.CSS_PROPERTIES.each(function(property){ - if (style[property]) styleRules.set(property, style[property]); - }); - - if (Prototype.Browser.IE && this.include('opacity')) - styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); - - return styleRules; -}; - -if (document.defaultView && document.defaultView.getComputedStyle) { - Element.getStyles = function(element) { - var css = document.defaultView.getComputedStyle($(element), null); - return Element.CSS_PROPERTIES.inject({ }, function(styles, property) { - styles[property] = css[property]; - return styles; - }); - }; -} else { - Element.getStyles = function(element) { - element = $(element); - var css = element.currentStyle, styles; - styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) { - results[property] = css[property]; - return results; - }); - if (!styles.opacity) styles.opacity = element.getOpacity(); - return styles; - }; -} - -Effect.Methods = { - morph: function(element, style) { - element = $(element); - new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { })); - return element; - }, - visualEffect: function(element, effect, options) { - element = $(element); - var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); - new Effect[klass](element, options); - return element; - }, - highlight: function(element, options) { - element = $(element); - new Effect.Highlight(element, options); - return element; - } -}; - -$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ - 'pulsate shake puff squish switchOff dropOut').each( - function(effect) { - Effect.Methods[effect] = function(element, options){ - element = $(element); - Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); - return element; - }; - } -); - -$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( - function(f) { Effect.Methods[f] = Element[f]; } -); - -Element.addMethods(Effect.Methods); \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/prototype.js b/vendor/rails/railties/html/javascripts/prototype.js deleted file mode 100644 index dfe8ab4e..00000000 --- a/vendor/rails/railties/html/javascripts/prototype.js +++ /dev/null @@ -1,4320 +0,0 @@ -/* Prototype JavaScript framework, version 1.6.0.3 - * (c) 2005-2008 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * - *--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.6.0.3', - - Browser: { - IE: !!(window.attachEvent && - navigator.userAgent.indexOf('Opera') === -1), - Opera: navigator.userAgent.indexOf('Opera') > -1, - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && - navigator.userAgent.indexOf('KHTML') === -1, - MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) - }, - - BrowserFeatures: { - XPath: !!document.evaluate, - SelectorsAPI: !!document.querySelector, - ElementExtensions: !!window.HTMLElement, - SpecificElementExtensions: - document.createElement('div')['__proto__'] && - document.createElement('div')['__proto__'] !== - document.createElement('form')['__proto__'] - }, - - ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - K: function(x) { return x } -}; - -if (Prototype.Browser.MobileSafari) - Prototype.BrowserFeatures.SpecificElementExtensions = false; - - -/* Based on Alex Arnell's inheritance implementation. */ -var Class = { - create: function() { - var parent = null, properties = $A(arguments); - if (Object.isFunction(properties[0])) - parent = properties.shift(); - - function klass() { - this.initialize.apply(this, arguments); - } - - Object.extend(klass, Class.Methods); - klass.superclass = parent; - klass.subclasses = []; - - if (parent) { - var subclass = function() { }; - subclass.prototype = parent.prototype; - klass.prototype = new subclass; - parent.subclasses.push(klass); - } - - for (var i = 0; i < properties.length; i++) - klass.addMethods(properties[i]); - - if (!klass.prototype.initialize) - klass.prototype.initialize = Prototype.emptyFunction; - - klass.prototype.constructor = klass; - - return klass; - } -}; - -Class.Methods = { - addMethods: function(source) { - var ancestor = this.superclass && this.superclass.prototype; - var properties = Object.keys(source); - - if (!Object.keys({ toString: true }).length) - properties.push("toString", "valueOf"); - - for (var i = 0, length = properties.length; i < length; i++) { - var property = properties[i], value = source[property]; - if (ancestor && Object.isFunction(value) && - value.argumentNames().first() == "$super") { - var method = value; - value = (function(m) { - return function() { return ancestor[m].apply(this, arguments) }; - })(property).wrap(method); - - value.valueOf = method.valueOf.bind(method); - value.toString = method.toString.bind(method); - } - this.prototype[property] = value; - } - - return this; - } -}; - -var Abstract = { }; - -Object.extend = function(destination, source) { - for (var property in source) - destination[property] = source[property]; - return destination; -}; - -Object.extend(Object, { - inspect: function(object) { - try { - if (Object.isUndefined(object)) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : String(object); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - toJSON: function(object) { - var type = typeof object; - switch (type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (Object.isElement(object)) return; - - var results = []; - for (var property in object) { - var value = Object.toJSON(object[property]); - if (!Object.isUndefined(value)) - results.push(property.toJSON() + ': ' + value); - } - - return '{' + results.join(', ') + '}'; - }, - - toQueryString: function(object) { - return $H(object).toQueryString(); - }, - - toHTML: function(object) { - return object && object.toHTML ? object.toHTML() : String.interpret(object); - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({ }, object); - }, - - isElement: function(object) { - return !!(object && object.nodeType == 1); - }, - - isArray: function(object) { - return object != null && typeof object == "object" && - 'splice' in object && 'join' in object; - }, - - isHash: function(object) { - return object instanceof Hash; - }, - - isFunction: function(object) { - return typeof object == "function"; - }, - - isString: function(object) { - return typeof object == "string"; - }, - - isNumber: function(object) { - return typeof object == "number"; - }, - - isUndefined: function(object) { - return typeof object == "undefined"; - } -}); - -Object.extend(Function.prototype, { - argumentNames: function() { - var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1] - .replace(/\s+/g, '').split(','); - return names.length == 1 && !names[0] ? [] : names; - }, - - bind: function() { - if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } - }, - - bindAsEventListener: function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [event || window.event].concat(args)); - } - }, - - curry: function() { - if (!arguments.length) return this; - var __method = this, args = $A(arguments); - return function() { - return __method.apply(this, args.concat($A(arguments))); - } - }, - - delay: function() { - var __method = this, args = $A(arguments), timeout = args.shift() * 1000; - return window.setTimeout(function() { - return __method.apply(__method, args); - }, timeout); - }, - - defer: function() { - var args = [0.01].concat($A(arguments)); - return this.delay.apply(this, args); - }, - - wrap: function(wrapper) { - var __method = this; - return function() { - return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); - } - }, - - methodize: function() { - if (this._methodized) return this._methodized; - var __method = this; - return this._methodized = function() { - return __method.apply(null, [this].concat($A(arguments))); - }; - } -}); - -Date.prototype.toJSON = function() { - return '"' + this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z"'; -}; - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) { } - } - - return returnValue; - } -}; - -RegExp.prototype.match = RegExp.prototype.test; - -RegExp.escape = function(str) { - return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -}; - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create({ - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - execute: function() { - this.callback(this); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - } finally { - this.currentlyExecuting = false; - } - } - } -}); -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = Object.isUndefined(count) ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return String(this); - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = Object.isUndefined(truncation) ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : String(this); - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var self = arguments.callee; - self.text.data = this; - return self.div.innerHTML; - }, - - unescapeHTML: function() { - var div = new Element('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return { }; - - return match[1].split(separator || '&').inject({ }, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()); - var value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - times: function(count) { - return count < 1 ? '' : new Array(count + 1).join(this); - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { - var character = String.specialChar[match[0]]; - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - }, - - toJSON: function() { - return this.inspect(true); - }, - - unfilterJSON: function(filter) { - return this.sub(filter || Prototype.JSONFilter, '#{1}'); - }, - - isJSON: function() { - var str = this; - if (str.blank()) return false; - str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); - }, - - evalJSON: function(sanitize) { - var json = this.unfilterJSON(); - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - }, - - include: function(pattern) { - return this.indexOf(pattern) > -1; - }, - - startsWith: function(pattern) { - return this.indexOf(pattern) === 0; - }, - - endsWith: function(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; - }, - - empty: function() { - return this == ''; - }, - - blank: function() { - return /^\s*$/.test(this); - }, - - interpolate: function(object, pattern) { - return new Template(this, pattern).evaluate(object); - } -}); - -if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { - escapeHTML: function() { - return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); - }, - unescapeHTML: function() { - return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>'); - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (Object.isFunction(replacement)) return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -}; - -String.prototype.parseQuery = String.prototype.toQueryParams; - -Object.extend(String.prototype.escapeHTML, { - div: document.createElement('div'), - text: document.createTextNode('') -}); - -String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text); - -var Template = Class.create({ - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - if (Object.isFunction(object.toTemplateReplacements)) - object = object.toTemplateReplacements(); - - return this.template.gsub(this.pattern, function(match) { - if (object == null) return ''; - - var before = match[1] || ''; - if (before == '\\') return match[2]; - - var ctx = object, expr = match[3]; - var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; - match = pattern.exec(expr); - if (match == null) return before; - - while (match != null) { - var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; - ctx = ctx[comp]; - if (null == ctx || '' == match[3]) break; - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); - match = pattern.exec(expr); - } - - return before + String.interpret(ctx); - }); - } -}); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; - -var $break = { }; - -var Enumerable = { - each: function(iterator, context) { - var index = 0; - try { - this._each(function(value) { - iterator.call(context, value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator, context) { - var index = -number, slices = [], array = this.toArray(); - if (number < 1) return array; - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.collect(iterator, context); - }, - - all: function(iterator, context) { - iterator = iterator || Prototype.K; - var result = true; - this.each(function(value, index) { - result = result && !!iterator.call(context, value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator, context) { - iterator = iterator || Prototype.K; - var result = false; - this.each(function(value, index) { - if (result = !!iterator.call(context, value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - this.each(function(value, index) { - results.push(iterator.call(context, value, index)); - }); - return results; - }, - - detect: function(iterator, context) { - var result; - this.each(function(value, index) { - if (iterator.call(context, value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator, context) { - var results = []; - this.each(function(value, index) { - if (iterator.call(context, value, index)) - results.push(value); - }); - return results; - }, - - grep: function(filter, iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - - if (Object.isString(filter)) - filter = new RegExp(filter); - - this.each(function(value, index) { - if (filter.match(value)) - results.push(iterator.call(context, value, index)); - }); - return results; - }, - - include: function(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; - - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = Object.isUndefined(fillWith) ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator, context) { - this.each(function(value, index) { - memo = iterator.call(context, memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator, context) { - iterator = iterator || Prototype.K; - var trues = [], falses = []; - this.each(function(value, index) { - (iterator.call(context, value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator, context) { - var results = []; - this.each(function(value, index) { - if (!iterator.call(context, value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator, context) { - return this.map(function(value, index) { - return { - value: value, - criteria: iterator.call(context, value, index) - }; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (Object.isFunction(args.last())) - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#<Enumerable:' + this.toArray().inspect() + '>'; - } -}; - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - filter: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray, - every: Enumerable.all, - some: Enumerable.any -}); -function $A(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; -} - -if (Prototype.Browser.WebKit) { - $A = function(iterable) { - if (!iterable) return []; - // In Safari, only use the `toArray` method if it's not a NodeList. - // A NodeList is a function, has an function `item` property, and a numeric - // `length` property. Adapted from Google Doctype. - if (!(typeof iterable === 'function' && typeof iterable.length === - 'number' && typeof iterable.item === 'function') && iterable.toArray) - return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; - }; -} - -Array.from = $A; - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(Object.isArray(value) ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - }, - - intersect: function(array) { - return this.uniq().findAll(function(item) { - return array.detect(function(value) { return item === value }); - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - }, - - toJSON: function() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (!Object.isUndefined(value)) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } -}); - -// use native browser JS 1.6 implementation if available -if (Object.isFunction(Array.prototype.forEach)) - Array.prototype._each = Array.prototype.forEach; - -if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { - i || (i = 0); - var length = this.length; - if (i < 0) i = length + i; - for (; i < length; i++) - if (this[i] === item) return i; - return -1; -}; - -if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { - i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; - var n = this.slice(0, i).reverse().indexOf(item); - return (n < 0) ? n : i - n - 1; -}; - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string) { - if (!Object.isString(string)) return []; - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if (Prototype.Browser.Opera){ - Array.prototype.concat = function() { - var array = []; - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for (var i = 0, length = arguments.length; i < length; i++) { - if (Object.isArray(arguments[i])) { - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - }; -} -Object.extend(Number.prototype, { - toColorPart: function() { - return this.toPaddedString(2, 16); - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator, context) { - $R(0, this, true).each(iterator, context); - return this; - }, - - toPaddedString: function(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - }, - - toJSON: function() { - return isFinite(this) ? this.toString() : 'null'; - } -}); - -$w('abs round ceil floor').each(function(method){ - Number.prototype[method] = Math[method].methodize(); -}); -function $H(object) { - return new Hash(object); -}; - -var Hash = Class.create(Enumerable, (function() { - - function toQueryPair(key, value) { - if (Object.isUndefined(value)) return key; - return key + '=' + encodeURIComponent(String.interpret(value)); - } - - return { - initialize: function(object) { - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); - }, - - _each: function(iterator) { - for (var key in this._object) { - var value = this._object[key], pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - set: function(key, value) { - return this._object[key] = value; - }, - - get: function(key) { - // simulating poorly supported hasOwnProperty - if (this._object[key] !== Object.prototype[key]) - return this._object[key]; - }, - - unset: function(key) { - var value = this._object[key]; - delete this._object[key]; - return value; - }, - - toObject: function() { - return Object.clone(this._object); - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - index: function(value) { - var match = this.detect(function(pair) { - return pair.value === value; - }); - return match && match.key; - }, - - merge: function(object) { - return this.clone().update(object); - }, - - update: function(object) { - return new Hash(object).inject(this, function(result, pair) { - result.set(pair.key, pair.value); - return result; - }); - }, - - toQueryString: function() { - return this.inject([], function(results, pair) { - var key = encodeURIComponent(pair.key), values = pair.value; - - if (values && typeof values == 'object') { - if (Object.isArray(values)) - return results.concat(values.map(toQueryPair.curry(key))); - } else results.push(toQueryPair(key, values)); - return results; - }).join('&'); - }, - - inspect: function() { - return '#<Hash:{' + this.map(function(pair) { - return pair.map(Object.inspect).join(': '); - }).join(', ') + '}>'; - }, - - toJSON: function() { - return Object.toJSON(this.toObject()); - }, - - clone: function() { - return new Hash(this); - } - } -})()); - -Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; -Hash.from = $H; -var ObjectRange = Class.create(Enumerable, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -}; - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -}; - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (Object.isFunction(responder[callback])) { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) { } - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { Ajax.activeRequestCount++ }, - onComplete: function() { Ajax.activeRequestCount-- } -}); - -Ajax.Base = Class.create({ - initialize: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '', - evalJSON: true, - evalJS: true - }; - Object.extend(this.options, options || { }); - - this.options.method = this.options.method.toLowerCase(); - - if (Object.isString(this.options.parameters)) - this.options.parameters = this.options.parameters.toQueryParams(); - else if (Object.isHash(this.options.parameters)) - this.options.parameters = this.options.parameters.toObject(); - } -}); - -Ajax.Request = Class.create(Ajax.Base, { - _complete: false, - - initialize: function($super, url, options) { - $super(options); - this.transport = Ajax.getTransport(); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Object.toQueryString(params)) { - // when GET, append parameters to URL - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - var response = new Ajax.Response(this); - if (this.options.onCreate) this.options.onCreate(response); - Ajax.Responders.dispatch('onCreate', this, response); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (Object.isFunction(extras.push)) - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - var status = this.getStatus(); - return !status || (status >= 200 && status < 300); - }, - - getStatus: function() { - try { - return this.transport.status || 0; - } catch (e) { return 0 } - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + response.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - var contentType = response.getHeader('Content-type'); - if (this.options.evalJS == 'force' - || (this.options.evalJS && this.isSameOrigin() && contentType - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - isSameOrigin: function() { - var m = this.url.match(/^\s*https?:\/\/[^\/]*/); - return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ - protocol: location.protocol, - domain: document.domain, - port: location.port ? ':' + location.port : '' - })); - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name) || null; - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Response = Class.create({ - initialize: function(request){ - this.request = request; - var transport = this.transport = request.transport, - readyState = this.readyState = transport.readyState; - - if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { - this.status = this.getStatus(); - this.statusText = this.getStatusText(); - this.responseText = String.interpret(transport.responseText); - this.headerJSON = this._getHeaderJSON(); - } - - if(readyState == 4) { - var xml = transport.responseXML; - this.responseXML = Object.isUndefined(xml) ? null : xml; - this.responseJSON = this._getResponseJSON(); - } - }, - - status: 0, - statusText: '', - - getStatus: Ajax.Request.prototype.getStatus, - - getStatusText: function() { - try { - return this.transport.statusText || ''; - } catch (e) { return '' } - }, - - getHeader: Ajax.Request.prototype.getHeader, - - getAllHeaders: function() { - try { - return this.getAllResponseHeaders(); - } catch (e) { return null } - }, - - getResponseHeader: function(name) { - return this.transport.getResponseHeader(name); - }, - - getAllResponseHeaders: function() { - return this.transport.getAllResponseHeaders(); - }, - - _getHeaderJSON: function() { - var json = this.getHeader('X-JSON'); - if (!json) return null; - json = decodeURIComponent(escape(json)); - try { - return json.evalJSON(this.request.options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - }, - - _getResponseJSON: function() { - var options = this.request.options; - if (!options.evalJSON || (options.evalJSON != 'force' && - !(this.getHeader('Content-type') || '').include('application/json')) || - this.responseText.blank()) - return null; - try { - return this.responseText.evalJSON(options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - } -}); - -Ajax.Updater = Class.create(Ajax.Request, { - initialize: function($super, container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - }; - - options = Object.clone(options); - var onComplete = options.onComplete; - options.onComplete = (function(response, json) { - this.updateContent(response.responseText); - if (Object.isFunction(onComplete)) onComplete(response, json); - }).bind(this); - - $super(url, options); - }, - - updateContent: function(responseText) { - var receiver = this.container[this.success() ? 'success' : 'failure'], - options = this.options; - - if (!options.evalScripts) responseText = responseText.stripScripts(); - - if (receiver = $(receiver)) { - if (options.insertion) { - if (Object.isString(options.insertion)) { - var insertion = { }; insertion[options.insertion] = responseText; - receiver.insert(insertion); - } - else options.insertion(receiver, responseText); - } - else receiver.update(responseText); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { - initialize: function($super, container, url, options) { - $super(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = { }; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(response) { - if (this.options.decay) { - this.decay = (response.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = response.responseText; - } - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (Object.isString(element)) - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(Element.extend(query.snapshotItem(i))); - return results; - }; -} - -/*--------------------------------------------------------------------------*/ - -if (!window.Node) var Node = { }; - -if (!Node.ELEMENT_NODE) { - // DOM level 2 ECMAScript Language Binding - Object.extend(Node, { - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }); -} - -(function() { - var element = this.Element; - this.Element = function(tagName, attributes) { - attributes = attributes || { }; - tagName = tagName.toLowerCase(); - var cache = Element.cache; - if (Prototype.Browser.IE && attributes.name) { - tagName = '<' + tagName + ' name="' + attributes.name + '">'; - delete attributes.name; - return Element.writeAttribute(document.createElement(tagName), attributes); - } - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); - }; - Object.extend(this.Element, element || { }); - if (element) this.Element.prototype = element.prototype; -}).call(window); - -Element.cache = { }; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - element = $(element); - element.style.display = 'none'; - return element; - }, - - show: function(element) { - element = $(element); - element.style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - content = Object.toHTML(content); - element.innerHTML = content.stripScripts(); - content.evalScripts.bind(content).defer(); - return element; - }, - - replace: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - else if (!Object.isElement(content)) { - content = Object.toHTML(content); - var range = element.ownerDocument.createRange(); - range.selectNode(element); - content.evalScripts.bind(content).defer(); - content = range.createContextualFragment(content.stripScripts()); - } - element.parentNode.replaceChild(content, element); - return element; - }, - - insert: function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = {bottom:insertions}; - - var content, insert, tagName, childNodes; - - for (var position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - insert = Element._insertionTranslations[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - insert(element, content); - continue; - } - - content = Object.toHTML(content); - - tagName = ((position == 'before' || position == 'after') - ? element.parentNode : element).tagName.toUpperCase(); - - childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - - if (position == 'top' || position == 'after') childNodes.reverse(); - childNodes.each(insert.curry(element)); - - content.evalScripts.bind(content).defer(); - } - - return element; - }, - - wrap: function(element, wrapper, attributes) { - element = $(element); - if (Object.isElement(wrapper)) - $(wrapper).writeAttribute(attributes || { }); - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); - else wrapper = new Element('div', wrapper); - if (element.parentNode) - element.parentNode.replaceChild(wrapper, element); - wrapper.appendChild(element); - return wrapper; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $(element).select("*"); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (Object.isString(selector)) - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = element.ancestors(); - return Object.isNumber(expression) ? ancestors[expression] : - Selector.findElement(ancestors, expression, index); - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - return Object.isNumber(expression) ? element.descendants()[expression] : - Element.select(element, expression)[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); - var previousSiblings = element.previousSiblings(); - return Object.isNumber(expression) ? previousSiblings[expression] : - Selector.findElement(previousSiblings, expression, index); - }, - - next: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); - var nextSiblings = element.nextSiblings(); - return Object.isNumber(expression) ? nextSiblings[expression] : - Selector.findElement(nextSiblings, expression, index); - }, - - select: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - adjacent: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element.parentNode, args).without(element); - }, - - identify: function(element) { - element = $(element); - var id = element.readAttribute('id'), self = arguments.callee; - if (id) return id; - do { id = 'anonymous_element_' + self.counter++ } while ($(id)); - element.writeAttribute('id', id); - return id; - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - var t = Element._attributeTranslations.read; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - if (name.include(':')) { - return (!element.attributes || !element.attributes[name]) ? null : - element.attributes[name].value; - } - } - return element.getAttribute(name); - }, - - writeAttribute: function(element, name, value) { - element = $(element); - var attributes = { }, t = Element._attributeTranslations.write; - - if (typeof name == 'object') attributes = name; - else attributes[name] = Object.isUndefined(value) ? true : value; - - for (var attr in attributes) { - name = t.names[attr] || attr; - value = attributes[attr]; - if (t.values[attr]) name = t.values[attr](element, value); - if (value === false || value === null) - element.removeAttribute(name); - else if (value === true) - element.setAttribute(name, name); - else element.setAttribute(name, value); - } - return element; - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - return (elementClassName.length > 0 && (elementClassName == className || - new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - if (!element.hasClassName(className)) - element.className += (element.className ? ' ' : '') + className; - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - element.className = element.className.replace( - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - return element[element.hasClassName(className) ? - 'removeClassName' : 'addClassName'](className); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - - if (element.compareDocumentPosition) - return (element.compareDocumentPosition(ancestor) & 8) === 8; - - if (ancestor.contains) - return ancestor.contains(element) && ancestor !== element; - - while (element = element.parentNode) - if (element == ancestor) return true; - - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = element.cumulativeOffset(); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value || value == 'auto') { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles) { - element = $(element); - var elementStyle = element.style, match; - if (Object.isString(styles)) { - element.style.cssText += ';' + styles; - return styles.include('opacity') ? - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; - } - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]); - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : - property] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = element.getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (Prototype.Browser.Opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = Element.getStyle(element, 'overflow') || 'auto'; - if (element._overflow !== 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if (element.tagName.toUpperCase() == 'BODY') break; - var p = Element.getStyle(element, 'position'); - if (p !== 'static') break; - } - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - absolutize: function(element) { - element = $(element); - if (element.getStyle('position') == 'absolute') return element; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - var offsets = element.positionedOffset(); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - return element; - }, - - relativize: function(element) { - element = $(element); - if (element.getStyle('position') == 'relative') return element; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - return element; - }, - - cumulativeScrollOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - getOffsetParent: function(element) { - if (element.offsetParent) return $(element.offsetParent); - if (element == document.body) return $(element); - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return $(element); - - return $(document.body); - }, - - viewportOffset: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body && - Element.getStyle(element, 'position') == 'absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return Element._returnOffset(valueL, valueT); - }, - - clonePosition: function(element, source) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || { }); - - // find page position of source - source = $(source); - var p = source.viewportOffset(); - - // find coordinate system to use - element = $(element); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(element, 'position') == 'absolute') { - parent = element.getOffsetParent(); - delta = parent.viewportOffset(); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if (options.setWidth) element.style.width = source.offsetWidth + 'px'; - if (options.setHeight) element.style.height = source.offsetHeight + 'px'; - return element; - } -}; - -Element.Methods.identify.counter = 1; - -Object.extend(Element.Methods, { - getElementsBySelector: Element.Methods.select, - childElements: Element.Methods.immediateDescendants -}); - -Element._attributeTranslations = { - write: { - names: { - className: 'class', - htmlFor: 'for' - }, - values: { } - } -}; - -if (Prototype.Browser.Opera) { - Element.Methods.getStyle = Element.Methods.getStyle.wrap( - function(proceed, element, style) { - switch (style) { - case 'left': case 'top': case 'right': case 'bottom': - if (proceed(element, 'position') === 'static') return null; - case 'height': case 'width': - // returns '0px' for hidden elements; we want it to return null - if (!Element.visible(element)) return null; - - // returns the border-box dimensions rather than the content-box - // dimensions, so we subtract padding and borders from the value - var dim = parseInt(proceed(element, style), 10); - - if (dim !== element['offset' + style.capitalize()]) - return dim + 'px'; - - var properties; - if (style === 'height') { - properties = ['border-top-width', 'padding-top', - 'padding-bottom', 'border-bottom-width']; - } - else { - properties = ['border-left-width', 'padding-left', - 'padding-right', 'border-right-width']; - } - return properties.inject(dim, function(memo, property) { - var val = proceed(element, property); - return val === null ? memo : memo - parseInt(val, 10); - }) + 'px'; - default: return proceed(element, style); - } - } - ); - - Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( - function(proceed, element, attribute) { - if (attribute === 'title') return element.title; - return proceed(element, attribute); - } - ); -} - -else if (Prototype.Browser.IE) { - // IE doesn't report offsets correctly for static elements, so we change them - // to "relative" to get the values, then change them back. - Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( - function(proceed, element) { - element = $(element); - // IE throws an error if element is not in document - try { element.offsetParent } - catch(e) { return $(document.body) } - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - - $w('positionedOffset viewportOffset').each(function(method) { - Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element) { - element = $(element); - try { element.offsetParent } - catch(e) { return Element._returnOffset(0,0) } - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - // Trigger hasLayout on the offset parent so that IE6 reports - // accurate offsetTop and offsetLeft values for position: fixed. - var offsetParent = element.getOffsetParent(); - if (offsetParent && offsetParent.getStyle('position') === 'fixed') - offsetParent.setStyle({ zoom: 1 }); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - }); - - Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap( - function(proceed, element) { - try { element.offsetParent } - catch(e) { return Element._returnOffset(0,0) } - return proceed(element); - } - ); - - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset' + style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - function stripAlpha(filter){ - return filter.replace(/alpha\([^\)]*\)/gi,''); - } - element = $(element); - var currentStyle = element.currentStyle; - if ((currentStyle && !currentStyle.hasLayout) || - (!currentStyle && element.style.zoom == 'normal')) - element.style.zoom = 1; - - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - (filter = stripAlpha(filter)) ? - style.filter = filter : style.removeAttribute('filter'); - return element; - } else if (value < 0.00001) value = 0; - style.filter = stripAlpha(filter) + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - Element._attributeTranslations = { - read: { - names: { - 'class': 'className', - 'for': 'htmlFor' - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _getAttrNode: function(element, attribute) { - var node = element.getAttributeNode(attribute); - return node ? node.value : ""; - }, - _getEv: function(element, attribute) { - attribute = element.getAttribute(attribute); - return attribute ? attribute.toString().slice(23, -2) : null; - }, - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - return element.title; - } - } - } - }; - - Element._attributeTranslations.write = { - names: Object.extend({ - cellpadding: 'cellPadding', - cellspacing: 'cellSpacing' - }, Element._attributeTranslations.read.names), - values: { - checked: function(element, value) { - element.checked = !!value; - }, - - style: function(element, value) { - element.style.cssText = value ? value : ''; - } - } - }; - - Element._attributeTranslations.has = {}; - - $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + - 'encType maxLength readOnly longDesc frameBorder').each(function(attr) { - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; - Element._attributeTranslations.has[attr.toLowerCase()] = attr; - }); - - (function(v) { - Object.extend(v, { - href: v._getAttr, - src: v._getAttr, - type: v._getAttr, - action: v._getAttrNode, - disabled: v._flag, - checked: v._flag, - readonly: v._flag, - multiple: v._flag, - onload: v._getEv, - onunload: v._getEv, - onclick: v._getEv, - ondblclick: v._getEv, - onmousedown: v._getEv, - onmouseup: v._getEv, - onmouseover: v._getEv, - onmousemove: v._getEv, - onmouseout: v._getEv, - onfocus: v._getEv, - onblur: v._getEv, - onkeypress: v._getEv, - onkeydown: v._getEv, - onkeyup: v._getEv, - onsubmit: v._getEv, - onreset: v._getEv, - onselect: v._getEv, - onchange: v._getEv - }); - })(Element._attributeTranslations.read.values); -} - -else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -else if (Prototype.Browser.WebKit) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - - if (value == 1) - if(element.tagName.toUpperCase() == 'IMG' && element.width) { - element.width++; element.width--; - } else try { - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch (e) { } - - return element; - }; - - // Safari returns margins on body which is incorrect if the child is absolutely - // positioned. For performance reasons, redefine Element#cumulativeOffset for - // KHTML/WebKit only. - Element.Methods.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return Element._returnOffset(valueL, valueT); - }; -} - -if (Prototype.Browser.IE || Prototype.Browser.Opera) { - // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements - Element.Methods.update = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - - content = Object.toHTML(content); - var tagName = element.tagName.toUpperCase(); - - if (tagName in Element._insertionTranslations.tags) { - $A(element.childNodes).each(function(node) { element.removeChild(node) }); - Element._getContentFromAnonymousElement(tagName, content.stripScripts()) - .each(function(node) { element.appendChild(node) }); - } - else element.innerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -if ('outerHTML' in document.createElement('div')) { - Element.Methods.replace = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - element.parentNode.replaceChild(content, element); - return element; - } - - content = Object.toHTML(content); - var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); - - if (Element._insertionTranslations.tags[tagName]) { - var nextSibling = element.next(); - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - parent.removeChild(element); - if (nextSibling) - fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); - else - fragments.each(function(node) { parent.appendChild(node) }); - } - else element.outerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -Element._returnOffset = function(l, t) { - var result = [l, t]; - result.left = l; - result.top = t; - return result; -}; - -Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; - if (t) { - div.innerHTML = t[0] + html + t[1]; - t[2].times(function() { div = div.firstChild }); - } else div.innerHTML = html; - return $A(div.childNodes); -}; - -Element._insertionTranslations = { - before: function(element, node) { - element.parentNode.insertBefore(node, element); - }, - top: function(element, node) { - element.insertBefore(node, element.firstChild); - }, - bottom: function(element, node) { - element.appendChild(node); - }, - after: function(element, node) { - element.parentNode.insertBefore(node, element.nextSibling); - }, - tags: { - TABLE: ['<table>', '</table>', 1], - TBODY: ['<table><tbody>', '</tbody></table>', 2], - TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3], - TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4], - SELECT: ['<select>', '</select>', 1] - } -}; - -(function() { - Object.extend(this.tags, { - THEAD: this.tags.TBODY, - TFOOT: this.tags.TBODY, - TH: this.tags.TD - }); -}).call(Element._insertionTranslations); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - attribute = Element._attributeTranslations.has[attribute] || attribute; - var node = $(element).getAttributeNode(attribute); - return !!(node && node.specified); - } -}; - -Element.Methods.ByTag = { }; - -Object.extend(Element, Element.Methods); - -if (!Prototype.BrowserFeatures.ElementExtensions && - document.createElement('div')['__proto__']) { - window.HTMLElement = { }; - window.HTMLElement.prototype = document.createElement('div')['__proto__']; - Prototype.BrowserFeatures.ElementExtensions = true; -} - -Element.extend = (function() { - if (Prototype.BrowserFeatures.SpecificElementExtensions) - return Prototype.K; - - var Methods = { }, ByTag = Element.Methods.ByTag; - - var extend = Object.extend(function(element) { - if (!element || element._extendedByPrototype || - element.nodeType != 1 || element == window) return element; - - var methods = Object.clone(Methods), - tagName = element.tagName.toUpperCase(), property, value; - - // extend methods for specific tags - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); - - for (property in methods) { - value = methods[property]; - if (Object.isFunction(value) && !(property in element)) - element[property] = value.methodize(); - } - - element._extendedByPrototype = Prototype.emptyFunction; - return element; - - }, { - refresh: function() { - // extend methods for all tags (Safari doesn't need this) - if (!Prototype.BrowserFeatures.ElementExtensions) { - Object.extend(Methods, Element.Methods); - Object.extend(Methods, Element.Methods.Simulated); - } - } - }); - - extend.refresh(); - return extend; -})(); - -Element.hasAttribute = function(element, attribute) { - if (element.hasAttribute) return element.hasAttribute(attribute); - return Element.Methods.Simulated.hasAttribute(element, attribute); -}; - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || { }); - else { - if (Object.isArray(tagName)) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = { }; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - for (var property in methods) { - var value = methods[property]; - if (!Object.isFunction(value)) continue; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = value.methodize(); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - window[klass] = { }; - window[klass].prototype = document.createElement(tagName)['__proto__']; - return window[klass]; - } - - if (F.ElementExtensions) { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (Object.isUndefined(klass)) continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; - - if (Element.extend.refresh) Element.extend.refresh(); - Element.cache = { }; -}; - -document.viewport = { - getDimensions: function() { - var dimensions = { }, B = Prototype.Browser; - $w('width height').each(function(d) { - var D = d.capitalize(); - if (B.WebKit && !document.evaluate) { - // Safari <3.0 needs self.innerWidth/Height - dimensions[d] = self['inner' + D]; - } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) { - // Opera <9.5 needs document.body.clientWidth/Height - dimensions[d] = document.body['client' + D] - } else { - dimensions[d] = document.documentElement['client' + D]; - } - }); - return dimensions; - }, - - getWidth: function() { - return this.getDimensions().width; - }, - - getHeight: function() { - return this.getDimensions().height; - }, - - getScrollOffsets: function() { - return Element._returnOffset( - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); - } -}; -/* Portions of the Selector class are derived from Jack Slocum's DomQuery, - * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style - * license. Please see http://www.yui-ext.com/ for more information. */ - -var Selector = Class.create({ - initialize: function(expression) { - this.expression = expression.strip(); - - if (this.shouldUseSelectorsAPI()) { - this.mode = 'selectorsAPI'; - } else if (this.shouldUseXPath()) { - this.mode = 'xpath'; - this.compileXPathMatcher(); - } else { - this.mode = "normal"; - this.compileMatcher(); - } - - }, - - shouldUseXPath: function() { - if (!Prototype.BrowserFeatures.XPath) return false; - - var e = this.expression; - - // Safari 3 chokes on :*-of-type and :empty - if (Prototype.Browser.WebKit && - (e.include("-of-type") || e.include(":empty"))) - return false; - - // XPath can't do namespaced attributes, nor can it read - // the "checked" property from DOM nodes - if ((/(\[[\w-]*?:|:checked)/).test(e)) - return false; - - return true; - }, - - shouldUseSelectorsAPI: function() { - if (!Prototype.BrowserFeatures.SelectorsAPI) return false; - - if (!Selector._div) Selector._div = new Element('div'); - - // Make sure the browser treats the selector as valid. Test on an - // isolated element to minimize cost of this check. - try { - Selector._div.querySelector(this.expression); - } catch(e) { - return false; - } - - return true; - }, - - compileMatcher: function() { - var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; - - if (Selector._cache[e]) { - this.matcher = Selector._cache[e]; - return; - } - - this.matcher = ["this.matcher = function(root) {", - "var r = root, h = Selector.handlers, c = false, n;"]; - - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : - new Template(c[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.matcher.push("return h.unique(n);\n}"); - eval(this.matcher.join('\n')); - Selector._cache[this.expression] = this.matcher; - }, - - compileXPathMatcher: function() { - var e = this.expression, ps = Selector.patterns, - x = Selector.xpath, le, m; - - if (Selector._cache[e]) { - this.xpath = Selector._cache[e]; return; - } - - this.matcher = ['.//*']; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - if (m = e.match(ps[i])) { - this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : - new Template(x[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.xpath = this.matcher.join(''); - Selector._cache[this.expression] = this.xpath; - }, - - findElements: function(root) { - root = root || document; - var e = this.expression, results; - - switch (this.mode) { - case 'selectorsAPI': - // querySelectorAll queries document-wide, then filters to descendants - // of the context element. That's not what we want. - // Add an explicit context to the selector if necessary. - if (root !== document) { - var oldId = root.id, id = $(root).identify(); - e = "#" + id + " " + e; - } - - results = $A(root.querySelectorAll(e)).map(Element.extend); - root.id = oldId; - - return results; - case 'xpath': - return document._getElementsByXPath(this.xpath, root); - default: - return this.matcher(root); - } - }, - - match: function(element) { - this.tokens = []; - - var e = this.expression, ps = Selector.patterns, as = Selector.assertions; - var le, p, m; - - while (e && le !== e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - // use the Selector.assertions methods unless the selector - // is too complex. - if (as[i]) { - this.tokens.push([i, Object.clone(m)]); - e = e.replace(m[0], ''); - } else { - // reluctantly do a document-wide search - // and look for a match in the array - return this.findElements(document).include(element); - } - } - } - } - - var match = true, name, matches; - for (var i = 0, token; token = this.tokens[i]; i++) { - name = token[0], matches = token[1]; - if (!Selector.assertions[name](element, matches)) { - match = false; break; - } - } - - return match; - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#<Selector:" + this.expression.inspect() + ">"; - } -}); - -Object.extend(Selector, { - _cache: { }, - - xpath: { - descendant: "//*", - child: "/*", - adjacent: "/following-sibling::*[1]", - laterSibling: '/following-sibling::*', - tagName: function(m) { - if (m[1] == '*') return ''; - return "[local-name()='" + m[1].toLowerCase() + - "' or local-name()='" + m[1].toUpperCase() + "']"; - }, - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", - id: "[@id='#{1}']", - attrPresence: function(m) { - m[1] = m[1].toLowerCase(); - return new Template("[@#{1}]").evaluate(m); - }, - attr: function(m) { - m[1] = m[1].toLowerCase(); - m[3] = m[5] || m[6]; - return new Template(Selector.xpath.operators[m[2]]).evaluate(m); - }, - pseudo: function(m) { - var h = Selector.xpath.pseudos[m[1]]; - if (!h) return ''; - if (Object.isFunction(h)) return h(m); - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); - }, - operators: { - '=': "[@#{1}='#{3}']", - '!=': "[@#{1}!='#{3}']", - '^=': "[starts-with(@#{1}, '#{3}')]", - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", - '*=': "[contains(@#{1}, '#{3}')]", - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" - }, - pseudos: { - 'first-child': '[not(preceding-sibling::*)]', - 'last-child': '[not(following-sibling::*)]', - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', - 'empty': "[count(*) = 0 and (count(text()) = 0)]", - 'checked': "[@checked]", - 'disabled': "[(@disabled) and (@type!='hidden')]", - 'enabled': "[not(@disabled) and (@type!='hidden')]", - 'not': function(m) { - var e = m[6], p = Selector.patterns, - x = Selector.xpath, le, v; - - var exclusion = []; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in p) { - if (m = e.match(p[i])) { - v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); - exclusion.push("(" + v.substring(1, v.length - 1) + ")"); - e = e.replace(m[0], ''); - break; - } - } - } - return "[not(" + exclusion.join(" and ") + ")]"; - }, - 'nth-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); - }, - 'nth-last-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); - }, - 'nth-of-type': function(m) { - return Selector.xpath.pseudos.nth("position() ", m); - }, - 'nth-last-of-type': function(m) { - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); - }, - 'first-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); - }, - 'last-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); - }, - 'only-of-type': function(m) { - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); - }, - nth: function(fragment, m) { - var mm, formula = m[6], predicate; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - if (mm = formula.match(/^(\d+)$/)) // digit only - return '[' + fragment + "= " + mm[1] + ']'; - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (mm[1] == "-") mm[1] = -1; - var a = mm[1] ? Number(mm[1]) : 1; - var b = mm[2] ? Number(mm[2]) : 0; - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + - "((#{fragment} - #{b}) div #{a} >= 0)]"; - return new Template(predicate).evaluate({ - fragment: fragment, a: a, b: b }); - } - } - } - }, - - criteria: { - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', - className: 'n = h.className(n, r, "#{1}", c); c = false;', - id: 'n = h.id(n, r, "#{1}", c); c = false;', - attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;', - attr: function(m) { - m[3] = (m[5] || m[6]); - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m); - }, - pseudo: function(m) { - if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); - }, - descendant: 'c = "descendant";', - child: 'c = "child";', - adjacent: 'c = "adjacent";', - laterSibling: 'c = "laterSibling";' - }, - - patterns: { - // combinators must be listed first - // (and descendant needs to be last combinator) - laterSibling: /^\s*~\s*/, - child: /^\s*>\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, - - // selectors follow - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, - id: /^#([\w\-\*]+)(\b|$)/, - className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: -/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, - attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ - }, - - // for Selector.match and Element#match - assertions: { - tagName: function(element, matches) { - return matches[1].toUpperCase() == element.tagName.toUpperCase(); - }, - - className: function(element, matches) { - return Element.hasClassName(element, matches[1]); - }, - - id: function(element, matches) { - return element.id === matches[1]; - }, - - attrPresence: function(element, matches) { - return Element.hasAttribute(element, matches[1]); - }, - - attr: function(element, matches) { - var nodeValue = Element.readAttribute(element, matches[1]); - return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); - } - }, - - handlers: { - // UTILITY FUNCTIONS - // joins two collections - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - a.push(node); - return a; - }, - - // marks an array of nodes for counting - mark: function(nodes) { - var _true = Prototype.emptyFunction; - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = _true; - return nodes; - }, - - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = undefined; - return nodes; - }, - - // mark each child node with its position (for nth calls) - // "ofType" flag indicates whether we're indexing for nth-of-type - // rather than nth-child - index: function(parentNode, reverse, ofType) { - parentNode._countedByPrototype = Prototype.emptyFunction; - if (reverse) { - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { - var node = nodes[i]; - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - } else { - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - }, - - // filters out duplicates and extends all nodes - unique: function(nodes) { - if (nodes.length == 0) return nodes; - var results = [], n; - for (var i = 0, l = nodes.length; i < l; i++) - if (!(n = nodes[i])._countedByPrototype) { - n._countedByPrototype = Prototype.emptyFunction; - results.push(Element.extend(n)); - } - return Selector.handlers.unmark(results); - }, - - // COMBINATOR FUNCTIONS - descendant: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName('*')); - return results; - }, - - child: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) { - for (var j = 0, child; child = node.childNodes[j]; j++) - if (child.nodeType == 1 && child.tagName != '!') results.push(child); - } - return results; - }, - - adjacent: function(nodes) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - var next = this.nextElementSibling(node); - if (next) results.push(next); - } - return results; - }, - - laterSibling: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, Element.nextSiblings(node)); - return results; - }, - - nextElementSibling: function(node) { - while (node = node.nextSibling) - if (node.nodeType == 1) return node; - return null; - }, - - previousElementSibling: function(node) { - while (node = node.previousSibling) - if (node.nodeType == 1) return node; - return null; - }, - - // TOKEN FUNCTIONS - tagName: function(nodes, root, tagName, combinator) { - var uTagName = tagName.toUpperCase(); - var results = [], h = Selector.handlers; - if (nodes) { - if (combinator) { - // fastlane for ordinary descendant combinators - if (combinator == "descendant") { - for (var i = 0, node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName(tagName)); - return results; - } else nodes = this[combinator](nodes); - if (tagName == "*") return nodes; - } - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName.toUpperCase() === uTagName) results.push(node); - return results; - } else return root.getElementsByTagName(tagName); - }, - - id: function(nodes, root, id, combinator) { - var targetNode = $(id), h = Selector.handlers; - if (!targetNode) return []; - if (!nodes && root == document) return [targetNode]; - if (nodes) { - if (combinator) { - if (combinator == 'child') { - for (var i = 0, node; node = nodes[i]; i++) - if (targetNode.parentNode == node) return [targetNode]; - } else if (combinator == 'descendant') { - for (var i = 0, node; node = nodes[i]; i++) - if (Element.descendantOf(targetNode, node)) return [targetNode]; - } else if (combinator == 'adjacent') { - for (var i = 0, node; node = nodes[i]; i++) - if (Selector.handlers.previousElementSibling(targetNode) == node) - return [targetNode]; - } else nodes = h[combinator](nodes); - } - for (var i = 0, node; node = nodes[i]; i++) - if (node == targetNode) return [targetNode]; - return []; - } - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; - }, - - className: function(nodes, root, className, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - return Selector.handlers.byClassName(nodes, root, className); - }, - - byClassName: function(nodes, root, className) { - if (!nodes) nodes = Selector.handlers.descendant([root]); - var needle = ' ' + className + ' '; - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { - nodeClassName = node.className; - if (nodeClassName.length == 0) continue; - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) - results.push(node); - } - return results; - }, - - attrPresence: function(nodes, root, attr, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (Element.hasAttribute(node, attr)) results.push(node); - return results; - }, - - attr: function(nodes, root, attr, value, operator, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var handler = Selector.operators[operator], results = []; - for (var i = 0, node; node = nodes[i]; i++) { - var nodeValue = Element.readAttribute(node, attr); - if (nodeValue === null) continue; - if (handler(nodeValue, value)) results.push(node); - } - return results; - }, - - pseudo: function(nodes, name, value, root, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - if (!nodes) nodes = root.getElementsByTagName("*"); - return Selector.pseudos[name](nodes, value, root); - } - }, - - pseudos: { - 'first-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.previousElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'last-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.nextElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'only-child': function(nodes, value, root) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) - results.push(node); - return results; - }, - 'nth-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root); - }, - 'nth-last-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true); - }, - 'nth-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, false, true); - }, - 'nth-last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true, true); - }, - 'first-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, false, true); - }, - 'last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, true, true); - }, - 'only-of-type': function(nodes, formula, root) { - var p = Selector.pseudos; - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); - }, - - // handles the an+b logic - getIndices: function(a, b, total) { - if (a == 0) return b > 0 ? [b] : []; - return $R(1, total).inject([], function(memo, i) { - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); - return memo; - }); - }, - - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type - nth: function(nodes, formula, root, reverse, ofType) { - if (nodes.length == 0) return []; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - var h = Selector.handlers, results = [], indexed = [], m; - h.mark(nodes); - for (var i = 0, node; node = nodes[i]; i++) { - if (!node.parentNode._countedByPrototype) { - h.index(node.parentNode, reverse, ofType); - indexed.push(node.parentNode); - } - } - if (formula.match(/^\d+$/)) { // just a number - formula = Number(formula); - for (var i = 0, node; node = nodes[i]; i++) - if (node.nodeIndex == formula) results.push(node); - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (m[1] == "-") m[1] = -1; - var a = m[1] ? Number(m[1]) : 1; - var b = m[2] ? Number(m[2]) : 0; - var indices = Selector.pseudos.getIndices(a, b, nodes.length); - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { - for (var j = 0; j < l; j++) - if (node.nodeIndex == indices[j]) results.push(node); - } - } - h.unmark(nodes); - h.unmark(indexed); - return results; - }, - - 'empty': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - // IE treats comments as element nodes - if (node.tagName == '!' || node.firstChild) continue; - results.push(node); - } - return results; - }, - - 'not': function(nodes, selector, root) { - var h = Selector.handlers, selectorType, m; - var exclusions = new Selector(selector).findElements(root); - h.mark(exclusions); - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node._countedByPrototype) results.push(node); - h.unmark(exclusions); - return results; - }, - - 'enabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node.disabled && (!node.type || node.type !== 'hidden')) - results.push(node); - return results; - }, - - 'disabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.disabled) results.push(node); - return results; - }, - - 'checked': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.checked) results.push(node); - return results; - } - }, - - operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); }, - '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); }, - '*=': function(nv, v) { return nv == v || nv && nv.include(v); }, - '$=': function(nv, v) { return nv.endsWith(v); }, - '*=': function(nv, v) { return nv.include(v); }, - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() + - '-').include('-' + (v || "").toUpperCase() + '-'); } - }, - - split: function(expression) { - var expressions = []; - expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { - expressions.push(m[1].strip()); - }); - return expressions; - }, - - matchElements: function(elements, expression) { - var matches = $$(expression), h = Selector.handlers; - h.mark(matches); - for (var i = 0, results = [], element; element = elements[i]; i++) - if (element._countedByPrototype) results.push(element); - h.unmark(matches); - return results; - }, - - findElement: function(elements, expression, index) { - if (Object.isNumber(expression)) { - index = expression; expression = false; - } - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - expressions = Selector.split(expressions.join(',')); - var results = [], h = Selector.handlers; - for (var i = 0, l = expressions.length, selector; i < l; i++) { - selector = new Selector(expressions[i].strip()); - h.concat(results, selector.findElements(element)); - } - return (l > 1) ? h.unique(results) : results; - } -}); - -if (Prototype.Browser.IE) { - Object.extend(Selector.handlers, { - // IE returns comment nodes on getElementsByTagName("*"). - // Filter them out. - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - if (node.tagName !== "!") a.push(node); - return a; - }, - - // IE improperly serializes _countedByPrototype in (inner|outer)HTML. - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node.removeAttribute('_countedByPrototype'); - return nodes; - } - }); -} - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, options) { - if (typeof options != 'object') options = { hash: !!options }; - else if (Object.isUndefined(options.hash)) options.hash = true; - var key, value, submitted = false, submit = options.submit; - - var data = elements.inject({ }, function(result, element) { - if (!element.disabled && element.name) { - key = element.name; value = $(element).getValue(); - if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted && - submit !== false && (!submit || key == submit) && (submitted = true)))) { - if (key in result) { - // a key is already present; construct an array of values - if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return options.hash ? data : Object.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, options) { - return Form.serializeElements(Form.getElements(form), options); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - Form.getElements(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - var elements = $(form).getElements().findAll(function(element) { - return 'hidden' != element.type && !element.disabled; - }); - var firstByIndex = elements.findAll(function(element) { - return element.hasAttribute('tabIndex') && element.tabIndex >= 0; - }).sortBy(function(element) { return element.tabIndex }).first(); - - return firstByIndex ? firstByIndex : elements.find(function(element) { - return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || { }); - - var params = options.parameters, action = form.readAttribute('action') || ''; - if (action.blank()) action = window.location.href; - options.parameters = form.serialize(true); - - if (params) { - if (Object.isString(params)) params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(action, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -}; - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = { }; - pair[element.name] = value; - return Object.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - setValue: function(element, value) { - element = $(element); - var method = element.tagName.toLowerCase(); - Form.Element.Serializers[method](element, value); - return element; - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type))) - element.select(); - } catch (e) { } - return element; - }, - - disable: function(element) { - element = $(element); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -}; - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element, value) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element, value); - default: - return Form.Element.Serializers.textarea(element, value); - } - }, - - inputSelector: function(element, value) { - if (Object.isUndefined(value)) return element.checked ? element.value : null; - else element.checked = !!value; - }, - - textarea: function(element, value) { - if (Object.isUndefined(value)) return element.value; - else element.value = value; - }, - - select: function(element, value) { - if (Object.isUndefined(value)) - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - else { - var opt, currentValue, single = !Object.isArray(value); - for (var i = 0, length = element.length; i < length; i++) { - opt = element.options[i]; - currentValue = this.optionValue(opt); - if (single) { - if (currentValue == value) { - opt.selected = true; - return; - } - } - else opt.selected = value.include(currentValue); - } - } - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -}; - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = Class.create(PeriodicalExecuter, { - initialize: function($super, element, frequency, callback) { - $super(callback, frequency); - this.element = $(element); - this.lastValue = this.getValue(); - }, - - execute: function() { - var value = this.getValue(); - if (Object.isString(this.lastValue) && Object.isString(value) ? - this.lastValue != value : String(this.lastValue) != String(value)) { - this.callback(this.element, value); - this.lastValue = value; - } - } -}); - -Form.Element.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = Class.create({ - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback, this); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -}); - -Form.Element.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) var Event = { }; - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - KEY_INSERT: 45, - - cache: { }, - - relatedTarget: function(event) { - var element; - switch(event.type) { - case 'mouseover': element = event.fromElement; break; - case 'mouseout': element = event.toElement; break; - default: return null; - } - return Element.extend(element); - } -}); - -Event.Methods = (function() { - var isButton; - - if (Prototype.Browser.IE) { - var buttonMap = { 0: 1, 1: 4, 2: 2 }; - isButton = function(event, code) { - return event.button == buttonMap[code]; - }; - - } else if (Prototype.Browser.WebKit) { - isButton = function(event, code) { - switch (code) { - case 0: return event.which == 1 && !event.metaKey; - case 1: return event.which == 1 && event.metaKey; - default: return false; - } - }; - - } else { - isButton = function(event, code) { - return event.which ? (event.which === code + 1) : (event.button === code); - }; - } - - return { - isLeftClick: function(event) { return isButton(event, 0) }, - isMiddleClick: function(event) { return isButton(event, 1) }, - isRightClick: function(event) { return isButton(event, 2) }, - - element: function(event) { - event = Event.extend(event); - - var node = event.target, - type = event.type, - currentTarget = event.currentTarget; - - if (currentTarget && currentTarget.tagName) { - // Firefox screws up the "click" event when moving between radio buttons - // via arrow keys. It also screws up the "load" and "error" events on images, - // reporting the document as the target instead of the original image. - if (type === 'load' || type === 'error' || - (type === 'click' && currentTarget.tagName.toLowerCase() === 'input' - && currentTarget.type === 'radio')) - node = currentTarget; - } - if (node.nodeType == Node.TEXT_NODE) node = node.parentNode; - return Element.extend(node); - }, - - findElement: function(event, expression) { - var element = Event.element(event); - if (!expression) return element; - var elements = [element].concat(element.ancestors()); - return Selector.findElement(elements, expression, 0); - }, - - pointer: function(event) { - var docElement = document.documentElement, - body = document.body || { scrollLeft: 0, scrollTop: 0 }; - return { - x: event.pageX || (event.clientX + - (docElement.scrollLeft || body.scrollLeft) - - (docElement.clientLeft || 0)), - y: event.pageY || (event.clientY + - (docElement.scrollTop || body.scrollTop) - - (docElement.clientTop || 0)) - }; - }, - - pointerX: function(event) { return Event.pointer(event).x }, - pointerY: function(event) { return Event.pointer(event).y }, - - stop: function(event) { - Event.extend(event); - event.preventDefault(); - event.stopPropagation(); - event.stopped = true; - } - }; -})(); - -Event.extend = (function() { - var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { - m[name] = Event.Methods[name].methodize(); - return m; - }); - - if (Prototype.Browser.IE) { - Object.extend(methods, { - stopPropagation: function() { this.cancelBubble = true }, - preventDefault: function() { this.returnValue = false }, - inspect: function() { return "[object Event]" } - }); - - return function(event) { - if (!event) return false; - if (event._extendedByPrototype) return event; - - event._extendedByPrototype = Prototype.emptyFunction; - var pointer = Event.pointer(event); - Object.extend(event, { - target: event.srcElement, - relatedTarget: Event.relatedTarget(event), - pageX: pointer.x, - pageY: pointer.y - }); - return Object.extend(event, methods); - }; - - } else { - Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__']; - Object.extend(Event.prototype, methods); - return Prototype.K; - } -})(); - -Object.extend(Event, (function() { - var cache = Event.cache; - - function getEventID(element) { - if (element._prototypeEventID) return element._prototypeEventID[0]; - arguments.callee.id = arguments.callee.id || 1; - return element._prototypeEventID = [++arguments.callee.id]; - } - - function getDOMEventName(eventName) { - if (eventName && eventName.include(':')) return "dataavailable"; - return eventName; - } - - function getCacheForID(id) { - return cache[id] = cache[id] || { }; - } - - function getWrappersForEventName(id, eventName) { - var c = getCacheForID(id); - return c[eventName] = c[eventName] || []; - } - - function createWrapper(element, eventName, handler) { - var id = getEventID(element); - var c = getWrappersForEventName(id, eventName); - if (c.pluck("handler").include(handler)) return false; - - var wrapper = function(event) { - if (!Event || !Event.extend || - (event.eventName && event.eventName != eventName)) - return false; - - Event.extend(event); - handler.call(element, event); - }; - - wrapper.handler = handler; - c.push(wrapper); - return wrapper; - } - - function findWrapper(id, eventName, handler) { - var c = getWrappersForEventName(id, eventName); - return c.find(function(wrapper) { return wrapper.handler == handler }); - } - - function destroyWrapper(id, eventName, handler) { - var c = getCacheForID(id); - if (!c[eventName]) return false; - c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); - } - - function destroyCache() { - for (var id in cache) - for (var eventName in cache[id]) - cache[id][eventName] = null; - } - - - // Internet Explorer needs to remove event handlers on page unload - // in order to avoid memory leaks. - if (window.attachEvent) { - window.attachEvent("onunload", destroyCache); - } - - // Safari has a dummy event handler on page unload so that it won't - // use its bfcache. Safari <= 3.1 has an issue with restoring the "document" - // object when page is returned to via the back button using its bfcache. - if (Prototype.Browser.WebKit) { - window.addEventListener('unload', Prototype.emptyFunction, false); - } - - return { - observe: function(element, eventName, handler) { - element = $(element); - var name = getDOMEventName(eventName); - - var wrapper = createWrapper(element, eventName, handler); - if (!wrapper) return element; - - if (element.addEventListener) { - element.addEventListener(name, wrapper, false); - } else { - element.attachEvent("on" + name, wrapper); - } - - return element; - }, - - stopObserving: function(element, eventName, handler) { - element = $(element); - var id = getEventID(element), name = getDOMEventName(eventName); - - if (!handler && eventName) { - getWrappersForEventName(id, eventName).each(function(wrapper) { - element.stopObserving(eventName, wrapper.handler); - }); - return element; - - } else if (!eventName) { - Object.keys(getCacheForID(id)).each(function(eventName) { - element.stopObserving(eventName); - }); - return element; - } - - var wrapper = findWrapper(id, eventName, handler); - if (!wrapper) return element; - - if (element.removeEventListener) { - element.removeEventListener(name, wrapper, false); - } else { - element.detachEvent("on" + name, wrapper); - } - - destroyWrapper(id, eventName, handler); - - return element; - }, - - fire: function(element, eventName, memo) { - element = $(element); - if (element == document && document.createEvent && !element.dispatchEvent) - element = document.documentElement; - - var event; - if (document.createEvent) { - event = document.createEvent("HTMLEvents"); - event.initEvent("dataavailable", true, true); - } else { - event = document.createEventObject(); - event.eventType = "ondataavailable"; - } - - event.eventName = eventName; - event.memo = memo || { }; - - if (document.createEvent) { - element.dispatchEvent(event); - } else { - element.fireEvent(event.eventType, event); - } - - return Event.extend(event); - } - }; -})()); - -Object.extend(Event, Event.Methods); - -Element.addMethods({ - fire: Event.fire, - observe: Event.observe, - stopObserving: Event.stopObserving -}); - -Object.extend(document, { - fire: Element.Methods.fire.methodize(), - observe: Element.Methods.observe.methodize(), - stopObserving: Element.Methods.stopObserving.methodize(), - loaded: false -}); - -(function() { - /* Support for the DOMContentLoaded event is based on work by Dan Webb, - Matthias Miller, Dean Edwards and John Resig. */ - - var timer; - - function fireContentLoadedEvent() { - if (document.loaded) return; - if (timer) window.clearInterval(timer); - document.fire("dom:loaded"); - document.loaded = true; - } - - if (document.addEventListener) { - if (Prototype.Browser.WebKit) { - timer = window.setInterval(function() { - if (/loaded|complete/.test(document.readyState)) - fireContentLoadedEvent(); - }, 0); - - Event.observe(window, "load", fireContentLoadedEvent); - - } else { - document.addEventListener("DOMContentLoaded", - fireContentLoadedEvent, false); - } - - } else { - document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>"); - $("__onDOMContentLoaded").onreadystatechange = function() { - if (this.readyState == "complete") { - this.onreadystatechange = null; - fireContentLoadedEvent(); - } - }; - } -})(); -/*------------------------------- DEPRECATED -------------------------------*/ - -Hash.toQueryString = Object.toQueryString; - -var Toggle = { display: Element.toggle }; - -Element.Methods.childOf = Element.Methods.descendantOf; - -var Insertion = { - Before: function(element, content) { - return Element.insert(element, {before:content}); - }, - - Top: function(element, content) { - return Element.insert(element, {top:content}); - }, - - Bottom: function(element, content) { - return Element.insert(element, {bottom:content}); - }, - - After: function(element, content) { - return Element.insert(element, {after:content}); - } -}; - -var $continue = new Error('"throw $continue" is deprecated, use "return" instead'); - -// This should be moved to script.aculo.us; notice the deprecated methods -// further below, that map to the newer Element methods. -var Position = { - // set to true if needed, warning: firefox performance problems - // NOT neeeded for page scrolling, only if draggable contained in - // scrollable elements - includeScrollOffsets: false, - - // must be called before calling withinIncludingScrolloffset, every time the - // page is scrolled - prepare: function() { - this.deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - this.deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - }, - - // caches x/y coordinate pair to use with overlap - within: function(element, x, y) { - if (this.includeScrollOffsets) - return this.withinIncludingScrolloffsets(element, x, y); - this.xcomp = x; - this.ycomp = y; - this.offset = Element.cumulativeOffset(element); - - return (y >= this.offset[1] && - y < this.offset[1] + element.offsetHeight && - x >= this.offset[0] && - x < this.offset[0] + element.offsetWidth); - }, - - withinIncludingScrolloffsets: function(element, x, y) { - var offsetcache = Element.cumulativeScrollOffset(element); - - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.offset = Element.cumulativeOffset(element); - - return (this.ycomp >= this.offset[1] && - this.ycomp < this.offset[1] + element.offsetHeight && - this.xcomp >= this.offset[0] && - this.xcomp < this.offset[0] + element.offsetWidth); - }, - - // within must be called directly before - overlap: function(mode, element) { - if (!mode) return 0; - if (mode == 'vertical') - return ((this.offset[1] + element.offsetHeight) - this.ycomp) / - element.offsetHeight; - if (mode == 'horizontal') - return ((this.offset[0] + element.offsetWidth) - this.xcomp) / - element.offsetWidth; - }, - - // Deprecation layer -- use newer Element methods now (1.5.2). - - cumulativeOffset: Element.Methods.cumulativeOffset, - - positionedOffset: Element.Methods.positionedOffset, - - absolutize: function(element) { - Position.prepare(); - return Element.absolutize(element); - }, - - relativize: function(element) { - Position.prepare(); - return Element.relativize(element); - }, - - realOffset: Element.Methods.cumulativeScrollOffset, - - offsetParent: Element.Methods.getOffsetParent, - - page: Element.Methods.viewportOffset, - - clone: function(source, target, options) { - options = options || { }; - return Element.clonePosition(target, source, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ - function iter(name) { - return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]"; - } - - instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? - function(element, className) { - className = className.toString().strip(); - var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className); - return cond ? document._getElementsByXPath('.//*' + cond, element) : []; - } : function(element, className) { - className = className.toString().strip(); - var elements = [], classNames = (/\s/.test(className) ? $w(className) : null); - if (!classNames && !className) return elements; - - var nodes = $(element).getElementsByTagName('*'); - className = ' ' + className + ' '; - - for (var i = 0, child, cn; child = nodes[i]; i++) { - if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) || - (classNames && classNames.all(function(name) { - return !name.toString().blank() && cn.include(' ' + name + ' '); - })))) - elements.push(Element.extend(child)); - } - return elements; - }; - - return function(className, parentElement) { - return $(parentElement || document.body).getElementsByClassName(className); - }; -}(Element.Methods); - -/*--------------------------------------------------------------------------*/ - -Element.ClassNames = Class.create(); -Element.ClassNames.prototype = { - initialize: function(element) { - this.element = $(element); - }, - - _each: function(iterator) { - this.element.className.split(/\s+/).select(function(name) { - return name.length > 0; - })._each(iterator); - }, - - set: function(className) { - this.element.className = className; - }, - - add: function(classNameToAdd) { - if (this.include(classNameToAdd)) return; - this.set($A(this).concat(classNameToAdd).join(' ')); - }, - - remove: function(classNameToRemove) { - if (!this.include(classNameToRemove)) return; - this.set($A(this).without(classNameToRemove).join(' ')); - }, - - toString: function() { - return $A(this).join(' '); - } -}; - -Object.extend(Element.ClassNames.prototype, Enumerable); - -/*--------------------------------------------------------------------------*/ - -Element.addMethods(); \ No newline at end of file diff --git a/vendor/rails/railties/html/robots.txt b/vendor/rails/railties/html/robots.txt deleted file mode 100644 index 085187fa..00000000 --- a/vendor/rails/railties/html/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file -# -# To ban all spiders from the entire site uncomment the next two lines: -# User-Agent: * -# Disallow: / diff --git a/vendor/rails/railties/lib/code_statistics.rb b/vendor/rails/railties/lib/code_statistics.rb deleted file mode 100644 index 740d8a17..00000000 --- a/vendor/rails/railties/lib/code_statistics.rb +++ /dev/null @@ -1,107 +0,0 @@ -class CodeStatistics #:nodoc: - - TEST_TYPES = %w(Units Functionals Unit\ tests Functional\ tests Integration\ tests) - - def initialize(*pairs) - @pairs = pairs - @statistics = calculate_statistics - @total = calculate_total if pairs.length > 1 - end - - def to_s - print_header - @pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) } - print_splitter - - if @total - print_line("Total", @total) - print_splitter - end - - print_code_test_stats - end - - private - def calculate_statistics - @pairs.inject({}) { |stats, pair| stats[pair.first] = calculate_directory_statistics(pair.last); stats } - end - - def calculate_directory_statistics(directory, pattern = /.*\.rb$/) - stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 } - - Dir.foreach(directory) do |file_name| - if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name) - newstats = calculate_directory_statistics(directory + "/" + file_name, pattern) - stats.each { |k, v| stats[k] += newstats[k] } - end - - next unless file_name =~ pattern - - f = File.open(directory + "/" + file_name) - - while line = f.gets - stats["lines"] += 1 - stats["classes"] += 1 if line =~ /class [A-Z]/ - stats["methods"] += 1 if line =~ /def [a-z]/ - stats["codelines"] += 1 unless line =~ /^\s*$/ || line =~ /^\s*#/ - end - end - - stats - end - - def calculate_total - total = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 } - @statistics.each_value { |pair| pair.each { |k, v| total[k] += v } } - total - end - - def calculate_code - code_loc = 0 - @statistics.each { |k, v| code_loc += v['codelines'] unless TEST_TYPES.include? k } - code_loc - end - - def calculate_tests - test_loc = 0 - @statistics.each { |k, v| test_loc += v['codelines'] if TEST_TYPES.include? k } - test_loc - end - - def print_header - print_splitter - puts "| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |" - print_splitter - end - - def print_splitter - puts "+----------------------+-------+-------+---------+---------+-----+-------+" - end - - def print_line(name, statistics) - m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0 - loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0 - - start = if TEST_TYPES.include? name - "| #{name.ljust(20)} " - else - "| #{name.ljust(20)} " - end - - puts start + - "| #{statistics["lines"].to_s.rjust(5)} " + - "| #{statistics["codelines"].to_s.rjust(5)} " + - "| #{statistics["classes"].to_s.rjust(7)} " + - "| #{statistics["methods"].to_s.rjust(7)} " + - "| #{m_over_c.to_s.rjust(3)} " + - "| #{loc_over_m.to_s.rjust(5)} |" - end - - def print_code_test_stats - code = calculate_code - tests = calculate_tests - - puts " Code LOC: #{code} Test LOC: #{tests} Code to Test Ratio: 1:#{sprintf("%.1f", tests.to_f/code)}" - puts "" - end - end diff --git a/vendor/rails/railties/lib/commands.rb b/vendor/rails/railties/lib/commands.rb deleted file mode 100644 index 841e98a0..00000000 --- a/vendor/rails/railties/lib/commands.rb +++ /dev/null @@ -1,17 +0,0 @@ -commands = Dir["#{File.dirname(__FILE__)}/commands/*.rb"].collect { |file_path| File.basename(file_path).split(".").first } - -if commands.include?(ARGV.first) - require "#{File.dirname(__FILE__)}/commands/#{ARGV.shift}" -else - puts <<-USAGE -The 'run' provides a unified access point for all the default Rails' commands. - -Usage: ./script/run <command> [OPTIONS] - -Examples: - ./script/run generate controller Admin - ./script/run process reaper - -USAGE - puts "Choose: #{commands.join(", ")}" -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/commands/about.rb b/vendor/rails/railties/lib/commands/about.rb deleted file mode 100644 index bc2cfcb9..00000000 --- a/vendor/rails/railties/lib/commands/about.rb +++ /dev/null @@ -1,3 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails/info' -puts Rails::Info diff --git a/vendor/rails/railties/lib/commands/console.rb b/vendor/rails/railties/lib/commands/console.rb deleted file mode 100644 index 63df8346..00000000 --- a/vendor/rails/railties/lib/commands/console.rb +++ /dev/null @@ -1,45 +0,0 @@ -irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' - -require 'optparse' - -options = { :sandbox => false, :irb => irb } -OptionParser.new do |opt| - opt.banner = "Usage: console [environment] [options]" - opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v } - opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v } - opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v } - opt.parse!(ARGV) -end - -libs = " -r irb/completion" -libs << %( -r "#{RAILS_ROOT}/config/environment") -libs << " -r console_app" -libs << " -r console_sandbox" if options[:sandbox] -libs << " -r console_with_helpers" - -if options[:debugger] - begin - require 'ruby-debug' - libs << " -r ruby-debug" - puts "=> Debugger enabled" - rescue Exception - puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'" - exit - end -end - -ENV['RAILS_ENV'] = case ARGV.first - when "p"; "production" - when "d"; "development" - when "t"; "test" - else - ARGV.first || ENV['RAILS_ENV'] || 'development' -end - -if options[:sandbox] - puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})" - puts "Any modifications you make will be rolled back on exit" -else - puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})" -end -exec "#{options[:irb]} #{libs} --simple-prompt" diff --git a/vendor/rails/railties/lib/commands/dbconsole.rb b/vendor/rails/railties/lib/commands/dbconsole.rb deleted file mode 100644 index b4160494..00000000 --- a/vendor/rails/railties/lib/commands/dbconsole.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'erb' -require 'yaml' -require 'optparse' - -include_password = false -options = {} - -OptionParser.new do |opt| - opt.banner = "Usage: dbconsole [options] [environment]" - opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v| - include_password = true - end - - opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'], - "Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode| - options['mode'] = mode - end - - opt.on("-h", "--header") do |h| - options['header'] = h - end - - opt.parse!(ARGV) - abort opt.to_s unless (0..1).include?(ARGV.size) -end - -env = ARGV.first || ENV['RAILS_ENV'] || 'development' -unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[env] - abort "No database is configured for the environment '#{env}'" -end - - -def find_cmd(*commands) - dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR) - commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/ - - full_path_command = nil - found = commands.detect do |cmd| - dir = dirs_on_path.detect do |path| - full_path_command = File.join(path, cmd) - File.executable? full_path_command - end - end - found ? full_path_command : abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.") -end - -case config["adapter"] -when /^mysql/ - args = { - 'host' => '--host', - 'port' => '--port', - 'socket' => '--socket', - 'username' => '--user', - 'encoding' => '--default-character-set' - }.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact - - if config['password'] && include_password - args << "--password=#{config['password']}" - elsif config['password'] && !config['password'].to_s.empty? - args << "-p" - end - - args << config['database'] - - exec(find_cmd('mysql', 'mysql5'), *args) - -when "postgresql" - ENV['PGUSER'] = config["username"] if config["username"] - ENV['PGHOST'] = config["host"] if config["host"] - ENV['PGPORT'] = config["port"].to_s if config["port"] - ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && include_password - exec(find_cmd('psql'), config["database"]) - -when "sqlite" - exec(find_cmd('sqlite'), config["database"]) - -when "sqlite3" - args = [] - - args << "-#{options['mode']}" if options['mode'] - args << "-header" if options['header'] - args << config['database'] - - exec(find_cmd('sqlite3'), *args) -else - abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!" -end diff --git a/vendor/rails/railties/lib/commands/destroy.rb b/vendor/rails/railties/lib/commands/destroy.rb deleted file mode 100644 index f4b81d65..00000000 --- a/vendor/rails/railties/lib/commands/destroy.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails_generator' -require 'rails_generator/scripts/destroy' - -ARGV.shift if ['--help', '-h'].include?(ARGV[0]) -Rails::Generator::Scripts::Destroy.new.run(ARGV) diff --git a/vendor/rails/railties/lib/commands/generate.rb b/vendor/rails/railties/lib/commands/generate.rb deleted file mode 100755 index 3d3db3d8..00000000 --- a/vendor/rails/railties/lib/commands/generate.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails_generator' -require 'rails_generator/scripts/generate' - -ARGV.shift if ['--help', '-h'].include?(ARGV[0]) -Rails::Generator::Scripts::Generate.new.run(ARGV) diff --git a/vendor/rails/railties/lib/commands/ncgi/listener b/vendor/rails/railties/lib/commands/ncgi/listener deleted file mode 100755 index 7079ef78..00000000 --- a/vendor/rails/railties/lib/commands/ncgi/listener +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env ruby - -require 'stringio' -require 'fileutils' -require 'fcgi_handler' - -def message(s) - $stderr.puts "listener: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -class RemoteCGI < CGI - attr_accessor :stdinput, :stdoutput, :env_table - def initialize(env_table, input = nil, output = nil) - self.env_table = env_table - self.stdinput = input || StringIO.new - self.stdoutput = output || StringIO.new - super() - end - - def out(stream) # Ignore the requested output stream - super(stdoutput) - end -end - -class Listener - include DRbUndumped - - def initialize(timeout, socket_path) - @socket = File.expand_path(socket_path) - @mutex = Mutex.new - @active = false - @timeout = timeout - - @handler = RailsFCGIHandler.new - @handler.extend DRbUndumped - - message 'opening socket' - DRb.start_service("drbunix:#{@socket}", self) - - message 'entering process loop' - @handler.process! self - end - - def each_cgi(&cgi_block) - @cgi_block = cgi_block - message 'entering idle loop' - loop do - sleep @timeout rescue nil - die! unless @active - @active = false - end - end - - def process(env, input) - message 'received request' - @mutex.synchronize do - @active = true - - message 'creating input stream' - input_stream = StringIO.new(input) - message 'building CGI instance' - cgi = RemoteCGI.new(eval(env), input_stream) - - message 'yielding to fcgi handler' - @cgi_block.call cgi - message 'yield finished -- sending output' - - cgi.stdoutput.seek(0) - output = cgi.stdoutput.read - - return output - end - end - - def die! - message 'shutting down' - DRb.stop_service - FileUtils.rm_f @socket - Kernel.exit 0 - end -end - -socket_path = ARGV.shift -timeout = (ARGV.shift || 90).to_i - -Listener.new(timeout, socket_path) diff --git a/vendor/rails/railties/lib/commands/ncgi/tracker b/vendor/rails/railties/lib/commands/ncgi/tracker deleted file mode 100755 index 4ca12d77..00000000 --- a/vendor/rails/railties/lib/commands/ncgi/tracker +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env ruby - -require 'drb' -require 'thread' - -def message(s) - $stderr.puts "tracker: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -class Tracker - include DRbUndumped - - def initialize(instances, socket_path) - @instances = instances - @socket = File.expand_path(socket_path) - @active = false - - @listeners = [] - @instances.times { @listeners << Mutex.new } - - message "using #{@listeners.length} listeners" - message "opening socket at #{@socket}" - - @service = DRb.start_service("drbunix://#{@socket}", self) - end - - def with_listener - message "listener requested" - - mutex = has_lock = index = nil - 3.times do - @listeners.each_with_index do |mutex, index| - has_lock = mutex.try_lock - break if has_lock - end - break if has_lock - sleep 0.05 - end - - if has_lock - message "obtained listener #{index}" - @active = true - begin yield index - ensure - mutex.unlock - message "released listener #{index}" - end - else - message "dropping request because no listeners are available!" - end - end - - def background(check_interval = nil) - if check_interval - loop do - sleep check_interval - message "Idle for #{check_interval}, shutting down" unless @active - @active = false - Kernel.exit 0 - end - else DRb.thread.join - end - end -end - -socket_path = ARGV.shift -instances = ARGV.shift.to_i -t = Tracker.new(instances, socket_path) -t.background(ARGV.first ? ARGV.shift.to_i : 90) diff --git a/vendor/rails/railties/lib/commands/performance/benchmarker.rb b/vendor/rails/railties/lib/commands/performance/benchmarker.rb deleted file mode 100644 index e8804fe1..00000000 --- a/vendor/rails/railties/lib/commands/performance/benchmarker.rb +++ /dev/null @@ -1,24 +0,0 @@ -if ARGV.empty? - puts "Usage: ./script/performance/benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." - exit 1 -end - -begin - N = Integer(ARGV.first) - ARGV.shift -rescue ArgumentError - N = 1 -end - -require RAILS_ROOT + '/config/environment' -require 'benchmark' -include Benchmark - -# Don't include compilation in the benchmark -ARGV.each { |expression| eval(expression) } - -bm(6) do |x| - ARGV.each_with_index do |expression, idx| - x.report("##{idx + 1}") { N.times { eval(expression) } } - end -end diff --git a/vendor/rails/railties/lib/commands/performance/profiler.rb b/vendor/rails/railties/lib/commands/performance/profiler.rb deleted file mode 100644 index 7df840f1..00000000 --- a/vendor/rails/railties/lib/commands/performance/profiler.rb +++ /dev/null @@ -1,50 +0,0 @@ -if ARGV.empty? - $stderr.puts "Usage: ./script/performance/profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" - exit(1) -end - -# Keep the expensive require out of the profile. -$stderr.puts 'Loading Rails...' -require RAILS_ROOT + '/config/environment' - -# Define a method to profile. -if ARGV[1] and ARGV[1].to_i > 1 - eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end" -else - eval "def profile_me() #{ARGV[0]} end" -end - -# Use the ruby-prof extension if available. Fall back to stdlib profiler. -begin - begin - require "ruby-prof" - $stderr.puts 'Using the ruby-prof extension.' - RubyProf.measure_mode = RubyProf::WALL_TIME - RubyProf.start - profile_me - results = RubyProf.stop - if ARGV[2] - printer_class = RubyProf.const_get((ARGV[2] + "_printer").classify) - else - printer_class = RubyProf::FlatPrinter - end - printer = printer_class.new(results) - printer.print($stderr) - rescue LoadError - require "prof" - $stderr.puts 'Using the old ruby-prof extension.' - Prof.clock_mode = Prof::GETTIMEOFDAY - Prof.start - profile_me - results = Prof.stop - require 'rubyprof_ext' - Prof.print_profile(results, $stderr) - end -rescue LoadError - require 'profiler' - $stderr.puts 'Using the standard Ruby profiler.' - Profiler__.start_profile - profile_me - Profiler__.stop_profile - Profiler__.print_profile($stderr) -end diff --git a/vendor/rails/railties/lib/commands/plugin.rb b/vendor/rails/railties/lib/commands/plugin.rb deleted file mode 100644 index 9f99a8d5..00000000 --- a/vendor/rails/railties/lib/commands/plugin.rb +++ /dev/null @@ -1,968 +0,0 @@ -# Rails Plugin Manager. -# -# Listing available plugins: -# -# $ ./script/plugin list -# continuous_builder http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder -# asset_timestamping http://svn.aviditybytes.com/rails/plugins/asset_timestamping -# enumerations_mixin http://svn.protocool.com/rails/plugins/enumerations_mixin/trunk -# calculations http://techno-weenie.net/svn/projects/calculations/ -# ... -# -# Installing plugins: -# -# $ ./script/plugin install continuous_builder asset_timestamping -# -# Finding Repositories: -# -# $ ./script/plugin discover -# -# Adding Repositories: -# -# $ ./script/plugin source http://svn.protocool.com/rails/plugins/ -# -# How it works: -# -# * Maintains a list of subversion repositories that are assumed to have -# a plugin directory structure. Manage them with the (source, unsource, -# and sources commands) -# -# * The discover command scrapes the following page for things that -# look like subversion repositories with plugins: -# http://wiki.rubyonrails.org/rails/pages/Plugins -# -# * Unless you specify that you want to use svn, script/plugin uses plain old -# HTTP for downloads. The following bullets are true if you specify -# that you want to use svn. -# -# * If `vendor/plugins` is under subversion control, the script will -# modify the svn:externals property and perform an update. You can -# use normal subversion commands to keep the plugins up to date. -# -# * Or, if `vendor/plugins` is not under subversion control, the -# plugin is pulled via `svn checkout` or `svn export` but looks -# exactly the same. -# -# Specifying revisions: -# -# * Subversion revision is a single integer. -# -# * Git revision format: -# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental' -# - short: 'experimental' (equivalent to 'refs/heads/experimental') -# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0') -# -# -# This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com) -# and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php) - -$verbose = false - - -require 'open-uri' -require 'fileutils' -require 'tempfile' - -include FileUtils - -class RailsEnvironment - attr_reader :root - - def initialize(dir) - @root = dir - end - - def self.find(dir=nil) - dir ||= pwd - while dir.length > 1 - return new(dir) if File.exist?(File.join(dir, 'config', 'environment.rb')) - dir = File.dirname(dir) - end - end - - def self.default - @default ||= find - end - - def self.default=(rails_env) - @default = rails_env - end - - def install(name_uri_or_plugin) - if name_uri_or_plugin.is_a? String - if name_uri_or_plugin =~ /:\/\// - plugin = Plugin.new(name_uri_or_plugin) - else - plugin = Plugins[name_uri_or_plugin] - end - else - plugin = name_uri_or_plugin - end - unless plugin.nil? - plugin.install - else - puts "Plugin not found: #{name_uri_or_plugin}" - end - end - - def use_svn? - require 'active_support/core_ext/kernel' - silence_stderr {`svn --version` rescue nil} - !$?.nil? && $?.success? - end - - def use_externals? - use_svn? && File.directory?("#{root}/vendor/plugins/.svn") - end - - def use_checkout? - # this is a bit of a guess. we assume that if the rails environment - # is under subversion then they probably want the plugin checked out - # instead of exported. This can be overridden on the command line - File.directory?("#{root}/.svn") - end - - def best_install_method - return :http unless use_svn? - case - when use_externals? then :externals - when use_checkout? then :checkout - else :export - end - end - - def externals - return [] unless use_externals? - ext = `svn propget svn:externals "#{root}/vendor/plugins"` - lines = ext.respond_to?(:lines) ? ext.lines : ext - lines.reject{ |line| line.strip == '' }.map do |line| - line.strip.split(/\s+/, 2) - end - end - - def externals=(items) - unless items.is_a? String - items = items.map{|name,uri| "#{name.ljust(29)} #{uri.chomp('/')}"}.join("\n") - end - Tempfile.open("svn-set-prop") do |file| - file.write(items) - file.flush - system("svn propset -q svn:externals -F \"#{file.path}\" \"#{root}/vendor/plugins\"") - end - end - -end - -class Plugin - attr_reader :name, :uri - - def initialize(uri, name=nil) - @uri = uri - guess_name(uri) - end - - def self.find(name) - name =~ /\// ? new(name) : Repositories.instance.find_plugin(name) - end - - def to_s - "#{@name.ljust(30)}#{@uri}" - end - - def svn_url? - @uri =~ /svn(?:\+ssh)?:\/\/*/ - end - - def git_url? - @uri =~ /^git:\/\// || @uri =~ /\.git$/ - end - - def installed? - File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \ - or rails_env.externals.detect{ |name, repo| self.uri == repo } - end - - def install(method=nil, options = {}) - method ||= rails_env.best_install_method? - if :http == method - method = :export if svn_url? - method = :git if git_url? - end - - uninstall if installed? and options[:force] - - unless installed? - send("install_using_#{method}", options) - run_install_hook - else - puts "already installed: #{name} (#{uri}). pass --force to reinstall" - end - end - - def uninstall - path = "#{rails_env.root}/vendor/plugins/#{name}" - if File.directory?(path) - puts "Removing 'vendor/plugins/#{name}'" if $verbose - run_uninstall_hook - rm_r path - else - puts "Plugin doesn't exist: #{path}" - end - # clean up svn:externals - externals = rails_env.externals - externals.reject!{|n,u| name == n or name == u} - rails_env.externals = externals - end - - def info - tmp = "#{rails_env.root}/_tmp_about.yml" - if svn_url? - cmd = "svn export #{@uri} \"#{rails_env.root}/#{tmp}\"" - puts cmd if $verbose - system(cmd) - end - open(svn_url? ? tmp : File.join(@uri, 'about.yml')) do |stream| - stream.read - end rescue "No about.yml found in #{uri}" - ensure - FileUtils.rm_rf tmp if svn_url? - end - - private - - def run_install_hook - install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb" - load install_hook_file if File.exist? install_hook_file - end - - def run_uninstall_hook - uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb" - load uninstall_hook_file if File.exist? uninstall_hook_file - end - - def install_using_export(options = {}) - svn_command :export, options - end - - def install_using_checkout(options = {}) - svn_command :checkout, options - end - - def install_using_externals(options = {}) - externals = rails_env.externals - externals.push([@name, uri]) - rails_env.externals = externals - install_using_checkout(options) - end - - def install_using_http(options = {}) - root = rails_env.root - mkdir_p "#{root}/vendor/plugins/#{@name}" - Dir.chdir "#{root}/vendor/plugins/#{@name}" do - puts "fetching from '#{uri}'" if $verbose - fetcher = RecursiveHTTPFetcher.new(uri, -1) - fetcher.quiet = true if options[:quiet] - fetcher.fetch - end - end - - def install_using_git(options = {}) - root = rails_env.root - mkdir_p(install_path = "#{root}/vendor/plugins/#{name}") - Dir.chdir install_path do - init_cmd = "git init" - init_cmd += " -q" if options[:quiet] and not $verbose - puts init_cmd if $verbose - system(init_cmd) - base_cmd = "git pull --depth 1 #{uri}" - base_cmd += " -q" if options[:quiet] and not $verbose - base_cmd += " #{options[:revision]}" if options[:revision] - puts base_cmd if $verbose - if system(base_cmd) - puts "removing: .git .gitignore" if $verbose - rm_rf %w(.git .gitignore) - else - rm_rf install_path - end - end - end - - def svn_command(cmd, options = {}) - root = rails_env.root - mkdir_p "#{root}/vendor/plugins" - base_cmd = "svn #{cmd} #{uri} \"#{root}/vendor/plugins/#{name}\"" - base_cmd += ' -q' if options[:quiet] and not $verbose - base_cmd += " -r #{options[:revision]}" if options[:revision] - puts base_cmd if $verbose - system(base_cmd) - end - - def guess_name(url) - @name = File.basename(url) - if @name == 'trunk' || @name.empty? - @name = File.basename(File.dirname(url)) - end - @name.gsub!(/\.git$/, '') if @name =~ /\.git$/ - end - - def rails_env - @rails_env || RailsEnvironment.default - end -end - -class Repositories - include Enumerable - - def initialize(cache_file = File.join(find_home, ".rails-plugin-sources")) - @cache_file = File.expand_path(cache_file) - load! - end - - def each(&block) - @repositories.each(&block) - end - - def add(uri) - unless find{|repo| repo.uri == uri } - @repositories.push(Repository.new(uri)).last - end - end - - def remove(uri) - @repositories.reject!{|repo| repo.uri == uri} - end - - def exist?(uri) - @repositories.detect{|repo| repo.uri == uri } - end - - def all - @repositories - end - - def find_plugin(name) - @repositories.each do |repo| - repo.each do |plugin| - return plugin if plugin.name == name - end - end - return nil - end - - def load! - contents = File.exist?(@cache_file) ? File.read(@cache_file) : defaults - contents = defaults if contents.empty? - @repositories = contents.split(/\n/).reject do |line| - line =~ /^\s*#/ or line =~ /^\s*$/ - end.map { |source| Repository.new(source.strip) } - end - - def save - File.open(@cache_file, 'w') do |f| - each do |repo| - f.write(repo.uri) - f.write("\n") - end - end - end - - def defaults - <<-DEFAULTS - http://dev.rubyonrails.com/svn/rails/plugins/ - DEFAULTS - end - - def find_home - ['HOME', 'USERPROFILE'].each do |homekey| - return ENV[homekey] if ENV[homekey] - end - if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] - return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}" - end - begin - File.expand_path("~") - rescue StandardError => ex - if File::ALT_SEPARATOR - "C:/" - else - "/" - end - end - end - - def self.instance - @instance ||= Repositories.new - end - - def self.each(&block) - self.instance.each(&block) - end -end - -class Repository - include Enumerable - attr_reader :uri, :plugins - - def initialize(uri) - @uri = uri.chomp('/') << "/" - @plugins = nil - end - - def plugins - unless @plugins - if $verbose - puts "Discovering plugins in #{@uri}" - puts index - end - - @plugins = index.reject{ |line| line !~ /\/$/ } - @plugins.map! { |name| Plugin.new(File.join(@uri, name), name) } - end - - @plugins - end - - def each(&block) - plugins.each(&block) - end - - private - def index - @index ||= RecursiveHTTPFetcher.new(@uri).ls - end -end - - -# load default environment and parse arguments -require 'optparse' -module Commands - - class Plugin - attr_reader :environment, :script_name, :sources - def initialize - @environment = RailsEnvironment.default - @rails_root = RailsEnvironment.default.root - @script_name = File.basename($0) - @sources = [] - end - - def environment=(value) - @environment = value - RailsEnvironment.default = value - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@script_name} [OPTIONS] command" - o.define_head "Rails plugin manager." - - o.separator "" - o.separator "GENERAL OPTIONS" - - o.on("-r", "--root=DIR", String, - "Set an explicit rails app directory.", - "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) } - o.on("-s", "--source=URL1,URL2", Array, - "Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources} - - o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose } - o.on("-h", "--help", "Show this help message.") { puts o; exit } - - o.separator "" - o.separator "COMMANDS" - - o.separator " discover Discover plugin repositories." - o.separator " list List available plugins." - o.separator " install Install plugin(s) from known repositories or URLs." - o.separator " update Update installed plugins." - o.separator " remove Uninstall plugins." - o.separator " source Add a plugin source repository." - o.separator " unsource Remove a plugin repository." - o.separator " sources List currently configured plugin repositories." - - o.separator "" - o.separator "EXAMPLES" - o.separator " Install a plugin:" - o.separator " #{@script_name} install continuous_builder\n" - o.separator " Install a plugin from a subversion URL:" - o.separator " #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" - o.separator " Install a plugin from a git URL:" - o.separator " #{@script_name} install git://github.com/SomeGuy/my_awesome_plugin.git\n" - o.separator " Install a plugin and add a svn:externals entry to vendor/plugins" - o.separator " #{@script_name} install -x continuous_builder\n" - o.separator " List all available plugins:" - o.separator " #{@script_name} list\n" - o.separator " List plugins in the specified repository:" - o.separator " #{@script_name} list --source=http://dev.rubyonrails.com/svn/rails/plugins/\n" - o.separator " Discover and prompt to add new repositories:" - o.separator " #{@script_name} discover\n" - o.separator " Discover new repositories but just list them, don't add anything:" - o.separator " #{@script_name} discover -l\n" - o.separator " Add a new repository to the source list:" - o.separator " #{@script_name} source http://dev.rubyonrails.com/svn/rails/plugins/\n" - o.separator " Remove a repository from the source list:" - o.separator " #{@script_name} unsource http://dev.rubyonrails.com/svn/rails/plugins/\n" - o.separator " Show currently configured repositories:" - o.separator " #{@script_name} sources\n" - end - end - - def parse!(args=ARGV) - general, sub = split_args(args) - options.parse!(general) - - command = general.shift - if command =~ /^(list|discover|install|source|unsource|sources|remove|update|info)$/ - command = Commands.const_get(command.capitalize).new(self) - command.parse!(sub) - else - puts "Unknown command: #{command}" - puts options - exit 1 - end - end - - def split_args(args) - left = [] - left << args.shift while args[0] and args[0] =~ /^-/ - left << args.shift if args[0] - return [left, args] - end - - def self.parse!(args=ARGV) - Plugin.new.parse!(args) - end - end - - - class List - def initialize(base_command) - @base_command = base_command - @sources = [] - @local = false - @remote = true - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} list [OPTIONS] [PATTERN]" - o.define_head "List available plugins." - o.separator "" - o.separator "Options:" - o.separator "" - o.on( "-s", "--source=URL1,URL2", Array, - "Use the specified plugin repositories.") {|sources| @sources = sources} - o.on( "--local", - "List locally installed plugins.") {|local| @local, @remote = local, false} - o.on( "--remote", - "List remotely available plugins. This is the default behavior", - "unless --local is provided.") {|remote| @remote = remote} - end - end - - def parse!(args) - options.order!(args) - unless @sources.empty? - @sources.map!{ |uri| Repository.new(uri) } - else - @sources = Repositories.instance.all - end - if @remote - @sources.map{|r| r.plugins}.flatten.each do |plugin| - if @local or !plugin.installed? - puts plugin.to_s - end - end - else - cd "#{@base_command.environment.root}/vendor/plugins" - Dir["*"].select{|p| File.directory?(p)}.each do |name| - puts name - end - end - end - end - - - class Sources - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} sources [OPTIONS] [PATTERN]" - o.define_head "List configured plugin repositories." - o.separator "" - o.separator "Options:" - o.separator "" - o.on( "-c", "--check", - "Report status of repository.") { |sources| @sources = sources} - end - end - - def parse!(args) - options.parse!(args) - Repositories.each do |repo| - puts repo.uri - end - end - end - - - class Source - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} source REPOSITORY [REPOSITORY [REPOSITORY]...]" - o.define_head "Add new repositories to the default search list." - end - end - - def parse!(args) - options.parse!(args) - count = 0 - args.each do |uri| - if Repositories.instance.add(uri) - puts "added: #{uri.ljust(50)}" if $verbose - count += 1 - else - puts "failed: #{uri.ljust(50)}" - end - end - Repositories.instance.save - puts "Added #{count} repositories." - end - end - - - class Unsource - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} unsource URI [URI [URI]...]" - o.define_head "Remove repositories from the default search list." - o.separator "" - o.on_tail("-h", "--help", "Show this help message.") { puts o; exit } - end - end - - def parse!(args) - options.parse!(args) - count = 0 - args.each do |uri| - if Repositories.instance.remove(uri) - count += 1 - puts "removed: #{uri.ljust(50)}" - else - puts "failed: #{uri.ljust(50)}" - end - end - Repositories.instance.save - puts "Removed #{count} repositories." - end - end - - - class Discover - def initialize(base_command) - @base_command = base_command - @list = false - @prompt = true - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} discover URI [URI [URI]...]" - o.define_head "Discover repositories referenced on a page." - o.separator "" - o.separator "Options:" - o.separator "" - o.on( "-l", "--list", - "List but don't prompt or add discovered repositories.") { |list| @list, @prompt = list, !@list } - o.on( "-n", "--no-prompt", - "Add all new repositories without prompting.") { |v| @prompt = !v } - end - end - - def parse!(args) - options.parse!(args) - args = ['http://wiki.rubyonrails.org/rails/pages/Plugins'] if args.empty? - args.each do |uri| - scrape(uri) do |repo_uri| - catch(:next_uri) do - if @prompt - begin - $stdout.print "Add #{repo_uri}? [Y/n] " - throw :next_uri if $stdin.gets !~ /^y?$/i - rescue Interrupt - $stdout.puts - exit 1 - end - elsif @list - puts repo_uri - throw :next_uri - end - Repositories.instance.add(repo_uri) - puts "discovered: #{repo_uri}" if $verbose or !@prompt - end - end - end - Repositories.instance.save - end - - def scrape(uri) - require 'open-uri' - puts "Scraping #{uri}" if $verbose - dupes = [] - content = open(uri).each do |line| - begin - if line =~ /<a[^>]*href=['"]([^'"]*)['"]/ || line =~ /(svn:\/\/[^<|\n]*)/ - uri = $1 - if uri =~ /^\w+:\/\// && uri =~ /\/plugins\// && uri !~ /\/browser\// && uri !~ /^http:\/\/wiki\.rubyonrails/ && uri !~ /http:\/\/instiki/ - uri = extract_repository_uri(uri) - yield uri unless dupes.include?(uri) || Repositories.instance.exist?(uri) - dupes << uri - end - end - rescue - puts "Problems scraping '#{uri}': #{$!.to_s}" - end - end - end - - def extract_repository_uri(uri) - uri.match(/(svn|https?):.*\/plugins\//i)[0] - end - end - - class Install - def initialize(base_command) - @base_command = base_command - @method = :http - @options = { :quiet => false, :revision => nil, :force => false } - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} install PLUGIN [PLUGIN [PLUGIN] ...]" - o.define_head "Install one or more plugins." - o.separator "" - o.separator "Options:" - o.on( "-x", "--externals", - "Use svn:externals to grab the plugin.", - "Enables plugin updates and plugin versioning.") { |v| @method = :externals } - o.on( "-o", "--checkout", - "Use svn checkout to grab the plugin.", - "Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout } - o.on( "-e", "--export", - "Use svn export to grab the plugin.", - "Exports the plugin, allowing you to check it into your local repository. Does not enable updates, or add an svn:externals entry.") { |v| @method = :export } - o.on( "-q", "--quiet", - "Suppresses the output from installation.", - "Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true } - o.on( "-r REVISION", "--revision REVISION", - "Checks out the given revision from subversion or git.", - "Ignored if subversion/git is not used.") { |v| @options[:revision] = v } - o.on( "-f", "--force", - "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true } - o.separator "" - o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to " - o.separator "a plugin repository." - end - end - - def determine_install_method - best = @base_command.environment.best_install_method - @method = :http if best == :http and @method == :export - case - when (best == :http and @method != :http) - msg = "Cannot install using subversion because `svn' cannot be found in your PATH" - when (best == :export and (@method != :export and @method != :http)) - msg = "Cannot install using #{@method} because this project is not under subversion." - when (best != :externals and @method == :externals) - msg = "Cannot install using externals because vendor/plugins is not under subversion." - end - if msg - puts msg - exit 1 - end - @method - end - - def parse!(args) - options.parse!(args) - environment = @base_command.environment - install_method = determine_install_method - puts "Plugins will be installed using #{install_method}" if $verbose - args.each do |name| - ::Plugin.find(name).install(install_method, @options) - end - rescue StandardError => e - puts "Plugin not found: #{args.inspect}" - puts e.inspect if $verbose - exit 1 - end - end - - class Update - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} update [name [name]...]" - o.on( "-r REVISION", "--revision REVISION", - "Checks out the given revision from subversion.", - "Ignored if subversion is not used.") { |v| @revision = v } - o.define_head "Update plugins." - end - end - - def parse!(args) - options.parse!(args) - root = @base_command.environment.root - cd root - args = Dir["vendor/plugins/*"].map do |f| - File.directory?("#{f}/.svn") ? File.basename(f) : nil - end.compact if args.empty? - cd "vendor/plugins" - args.each do |name| - if File.directory?(name) - puts "Updating plugin: #{name}" - system("svn #{$verbose ? '' : '-q'} up \"#{name}\" #{@revision ? "-r #{@revision}" : ''}") - else - puts "Plugin doesn't exist: #{name}" - end - end - end - end - - class Remove - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} remove name [name]..." - o.define_head "Remove plugins." - end - end - - def parse!(args) - options.parse!(args) - root = @base_command.environment.root - args.each do |name| - ::Plugin.new(name).uninstall - end - end - end - - class Info - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} info name [name]..." - o.define_head "Shows plugin info at {url}/about.yml." - end - end - - def parse!(args) - options.parse!(args) - args.each do |name| - puts ::Plugin.find(name).info - puts - end - end - end -end - -class RecursiveHTTPFetcher - attr_accessor :quiet - def initialize(urls_to_fetch, level = 1, cwd = ".") - @level = level - @cwd = cwd - @urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a - @quiet = false - end - - def ls - @urls_to_fetch.collect do |url| - if url =~ /^svn(\+ssh)?:\/\/.*/ - `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil - else - open(url) do |stream| - links("", stream.read) - end rescue nil - end - end.flatten - end - - def push_d(dir) - @cwd = File.join(@cwd, dir) - FileUtils.mkdir_p(@cwd) - end - - def pop_d - @cwd = File.dirname(@cwd) - end - - def links(base_url, contents) - links = [] - contents.scan(/href\s*=\s*\"*[^\">]*/i) do |link| - link = link.sub(/href="/i, "") - next if link =~ /svnindex.xsl$/ - next if link =~ /^(\w*:|)\/\// || link =~ /^\./ - links << File.join(base_url, link) - end - links - end - - def download(link) - puts "+ #{File.join(@cwd, File.basename(link))}" unless @quiet - open(link) do |stream| - File.open(File.join(@cwd, File.basename(link)), "wb") do |file| - file.write(stream.read) - end - end - end - - def fetch(links = @urls_to_fetch) - links.each do |l| - (l =~ /\/$/ || links == @urls_to_fetch) ? fetch_dir(l) : download(l) - end - end - - def fetch_dir(url) - @level += 1 - push_d(File.basename(url)) if @level > 0 - open(url) do |stream| - contents = stream.read - fetch(links(url, contents)) - end - pop_d if @level > 0 - @level -= 1 - end -end - -Commands::Plugin.parse! diff --git a/vendor/rails/railties/lib/commands/runner.rb b/vendor/rails/railties/lib/commands/runner.rb deleted file mode 100644 index 5a4f244c..00000000 --- a/vendor/rails/railties/lib/commands/runner.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'optparse' - -options = { :environment => (ENV['RAILS_ENV'] || "development").dup } -code_or_file = nil - -ARGV.clone.options do |opts| - script_name = File.basename($0) - opts.banner = "Usage: #{$0} [options] ('Some.ruby(code)' or a filename)" - - opts.separator "" - - opts.on("-e", "--environment=name", String, - "Specifies the environment for the runner to operate under (test/development/production).", - "Default: development") { |v| options[:environment] = v } - - opts.separator "" - - opts.on("-h", "--help", - "Show this help message.") { $stderr.puts opts; exit } - - if RUBY_PLATFORM !~ /(:?mswin|mingw)/ - opts.separator "" - opts.separator "You can also use runner as a shebang line for your scripts like this:" - opts.separator "-------------------------------------------------------------" - opts.separator "#!/usr/bin/env #{File.expand_path($0)}" - opts.separator "" - opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }" - opts.separator "-------------------------------------------------------------" - end - - opts.order! { |o| code_or_file ||= o } rescue retry -end - -ARGV.delete(code_or_file) - -ENV["RAILS_ENV"] = options[:environment] -RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - -require RAILS_ROOT + '/config/environment' - -begin - if code_or_file.nil? - $stderr.puts "Run '#{$0} -h' for help." - exit 1 - elsif File.exist?(code_or_file) - eval(File.read(code_or_file), nil, code_or_file) - else - eval(code_or_file) - end -ensure - if defined? Rails - Rails.logger.flush if Rails.logger.respond_to?(:flush) - end -end diff --git a/vendor/rails/railties/lib/commands/server.rb b/vendor/rails/railties/lib/commands/server.rb deleted file mode 100644 index ebe34a42..00000000 --- a/vendor/rails/railties/lib/commands/server.rb +++ /dev/null @@ -1,114 +0,0 @@ -require 'active_support' -require 'action_controller' - -require 'fileutils' -require 'optparse' - -# TODO: Push Thin adapter upstream so we don't need worry about requiring it -begin - require_library_or_gem 'thin' -rescue Exception - # Thin not available -end - -options = { - :Port => 3000, - :Host => "0.0.0.0", - :environment => (ENV['RAILS_ENV'] || "development").dup, - :config => RAILS_ROOT + "/config.ru", - :detach => false, - :debugger => false, - :path => nil -} - -ARGV.clone.options do |opts| - opts.on("-p", "--port=port", Integer, - "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v } - opts.on("-b", "--binding=ip", String, - "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v } - opts.on("-c", "--config=file", String, - "Use custom rackup configuration file") { |v| options[:config] = v } - opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:detach] = true } - opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true } - opts.on("-e", "--environment=name", String, - "Specifies the environment to run this server under (test/development/production).", - "Default: development") { |v| options[:environment] = v } - opts.on("-P", "--path=/path", String, "Runs Rails app mounted at a specific path.", "Default: /") { |v| options[:path] = v } - - opts.separator "" - - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } - - opts.parse! -end - -server = Rack::Handler.get(ARGV.first) rescue nil -unless server - begin - server = Rack::Handler::Mongrel - rescue LoadError => e - server = Rack::Handler::WEBrick - end -end - -puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" -puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}#{options[:path]}" - -%w(cache pids sessions sockets).each do |dir_to_make| - FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) -end - -if options[:detach] - Process.daemon - pid = "#{RAILS_ROOT}/tmp/pids/server.pid" - File.open(pid, 'w'){ |f| f.write(Process.pid) } - at_exit { File.delete(pid) if File.exist?(pid) } -end - -ENV["RAILS_ENV"] = options[:environment] -RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - -if File.exist?(options[:config]) - config = options[:config] - if config =~ /\.ru$/ - cfgfile = File.read(config) - if cfgfile[/^#\\(.*)/] - opts.parse!($1.split(/\s+/)) - end - inner_app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config) - else - require config - inner_app = Object.const_get(File.basename(config, '.rb').capitalize) - end -else - require RAILS_ROOT + "/config/environment" - inner_app = ActionController::Dispatcher.new -end - -if options[:path].nil? - map_path = "/" -else - ActionController::Base.relative_url_root = options[:path] - map_path = options[:path] -end - -app = Rack::Builder.new { - use Rails::Rack::LogTailer unless options[:detach] - use Rails::Rack::Debugger if options[:debugger] - map map_path do - use Rails::Rack::Static - run inner_app - end -}.to_app - -puts "=> Call with -d to detach" - -trap(:INT) { exit } - -puts "=> Ctrl-C to shutdown server" - -begin - server.run(app, options.merge(:AccessLog => [])) -ensure - puts 'Exiting' -end diff --git a/vendor/rails/railties/lib/commands/update.rb b/vendor/rails/railties/lib/commands/update.rb deleted file mode 100644 index 83ef8333..00000000 --- a/vendor/rails/railties/lib/commands/update.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails_generator' -require 'rails_generator/scripts/update' -Rails::Generator::Scripts::Update.new.run(ARGV) diff --git a/vendor/rails/railties/lib/console_app.rb b/vendor/rails/railties/lib/console_app.rb deleted file mode 100644 index d7d01d70..00000000 --- a/vendor/rails/railties/lib/console_app.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'active_support/test_case' -require 'action_controller' - -# work around the at_exit hook in test/unit, which kills IRB -Test::Unit.run = true if Test::Unit.respond_to?(:run=) - -# reference the global "app" instance, created on demand. To recreate the -# instance, pass a non-false value as the parameter. -def app(create=false) - @app_integration_instance = nil if create - @app_integration_instance ||= new_session do |sess| - sess.host! "www.example.com" - end -end - -# create a new session. If a block is given, the new session will be yielded -# to the block before being returned. -def new_session - session = ActionController::Integration::Session.new - yield session if block_given? - session -end - -#reloads the environment -def reload! - puts "Reloading..." - Dispatcher.cleanup_application - Dispatcher.reload_application - true -end diff --git a/vendor/rails/railties/lib/console_sandbox.rb b/vendor/rails/railties/lib/console_sandbox.rb deleted file mode 100644 index 65a3d686..00000000 --- a/vendor/rails/railties/lib/console_sandbox.rb +++ /dev/null @@ -1,6 +0,0 @@ -ActiveRecord::Base.connection.increment_open_transactions -ActiveRecord::Base.connection.begin_db_transaction -at_exit do - ActiveRecord::Base.connection.rollback_db_transaction - ActiveRecord::Base.connection.decrement_open_transactions -end diff --git a/vendor/rails/railties/lib/console_with_helpers.rb b/vendor/rails/railties/lib/console_with_helpers.rb deleted file mode 100644 index 039db667..00000000 --- a/vendor/rails/railties/lib/console_with_helpers.rb +++ /dev/null @@ -1,5 +0,0 @@ -def helper - @helper ||= ApplicationController.helpers -end - -@controller = ApplicationController.new diff --git a/vendor/rails/railties/lib/dispatcher.rb b/vendor/rails/railties/lib/dispatcher.rb deleted file mode 100644 index 1ca635f8..00000000 --- a/vendor/rails/railties/lib/dispatcher.rb +++ /dev/null @@ -1,24 +0,0 @@ -#-- -# Copyright (c) 2004-2010 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ -require 'action_controller/dispatcher' -Dispatcher = ActionController::Dispatcher diff --git a/vendor/rails/railties/lib/fcgi_handler.rb b/vendor/rails/railties/lib/fcgi_handler.rb deleted file mode 100644 index 0cd2dc51..00000000 --- a/vendor/rails/railties/lib/fcgi_handler.rb +++ /dev/null @@ -1,239 +0,0 @@ -require 'fcgi' -require 'logger' -require 'dispatcher' -require 'rbconfig' - -class RailsFCGIHandler - SIGNALS = { - 'HUP' => :reload, - 'INT' => :exit_now, - 'TERM' => :exit_now, - 'USR1' => :exit, - 'USR2' => :restart - } - GLOBAL_SIGNALS = SIGNALS.keys - %w(USR1) - - attr_reader :when_ready - - attr_accessor :log_file_path - attr_accessor :gc_request_period - - # Initialize and run the FastCGI instance, passing arguments through to new. - def self.process!(*args, &block) - new(*args, &block).process! - end - - # Initialize the FastCGI instance with the path to a crash log - # detailing unhandled exceptions (default RAILS_ROOT/log/fastcgi.crash.log) - # and the number of requests to process between garbage collection runs - # (default nil for normal GC behavior.) Optionally, pass a block which - # takes this instance as an argument for further configuration. - def initialize(log_file_path = nil, gc_request_period = nil) - self.log_file_path = log_file_path || "#{RAILS_ROOT}/log/fastcgi.crash.log" - self.gc_request_period = gc_request_period - - # Yield for additional configuration. - yield self if block_given? - - # Safely install signal handlers. - install_signal_handlers - - @app = Dispatcher.new - - # Start error timestamp at 11 seconds ago. - @last_error_on = Time.now - 11 - end - - def process!(provider = FCGI) - mark_features! - - dispatcher_log :info, 'starting' - process_each_request provider - dispatcher_log :info, 'stopping gracefully' - - rescue Exception => error - case error - when SystemExit - dispatcher_log :info, 'stopping after explicit exit' - when SignalException - dispatcher_error error, 'stopping after unhandled signal' - else - # Retry if exceptions occur more than 10 seconds apart. - if Time.now - @last_error_on > 10 - @last_error_on = Time.now - dispatcher_error error, 'retrying after unhandled exception' - retry - else - dispatcher_error error, 'stopping after unhandled exception within 10 seconds of the last' - end - end - end - - protected - def process_each_request(provider) - request = nil - - catch :exit do - provider.each do |request| - process_request(request) - - case when_ready - when :reload - reload! - when :restart - close_connection(request) - restart! - when :exit - close_connection(request) - throw :exit - end - end - end - rescue SignalException => signal - raise unless signal.message == 'SIGUSR1' - close_connection(request) - end - - def process_request(request) - @processing, @when_ready = true, nil - gc_countdown - - with_signal_handler 'USR1' do - begin - ::Rack::Handler::FastCGI.serve(request, @app) - rescue SignalException, SystemExit - raise - rescue Exception => error - dispatcher_error error, 'unhandled dispatch error' - end - end - ensure - @processing = false - end - - def logger - @logger ||= Logger.new(@log_file_path) - end - - def dispatcher_log(level, msg) - time_str = Time.now.strftime("%d/%b/%Y:%H:%M:%S") - logger.send(level, "[#{time_str} :: #{$$}] #{msg}") - rescue Exception => log_error # Logger errors - STDERR << "Couldn't write to #{@log_file_path.inspect}: #{msg}\n" - STDERR << " #{log_error.class}: #{log_error.message}\n" - end - - def dispatcher_error(e, msg = "") - error_message = - "Dispatcher failed to catch: #{e} (#{e.class})\n" + - " #{e.backtrace.join("\n ")}\n#{msg}" - dispatcher_log(:error, error_message) - end - - def install_signal_handlers - GLOBAL_SIGNALS.each { |signal| install_signal_handler(signal) } - end - - def install_signal_handler(signal, handler = nil) - if SIGNALS.include?(signal) && self.class.method_defined?(name = "#{SIGNALS[signal]}_handler") - handler ||= method(name).to_proc - - begin - trap(signal, handler) - rescue ArgumentError - dispatcher_log :warn, "Ignoring unsupported signal #{signal}." - end - else - dispatcher_log :warn, "Ignoring unsupported signal #{signal}." - end - end - - def with_signal_handler(signal) - install_signal_handler(signal) - yield - ensure - install_signal_handler(signal, 'DEFAULT') - end - - def exit_now_handler(signal) - dispatcher_log :info, "asked to stop immediately" - exit - end - - def exit_handler(signal) - dispatcher_log :info, "asked to stop ASAP" - if @processing - @when_ready = :exit - else - throw :exit - end - end - - def reload_handler(signal) - dispatcher_log :info, "asked to reload ASAP" - if @processing - @when_ready = :reload - else - reload! - end - end - - def restart_handler(signal) - dispatcher_log :info, "asked to restart ASAP" - if @processing - @when_ready = :restart - else - restart! - end - end - - def restart! - config = ::Config::CONFIG - ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT'] - command_line = [ruby, $0, ARGV].flatten.join(' ') - - dispatcher_log :info, "restarted" - - # close resources as they won't be closed by - # the OS when using exec - logger.close rescue nil - Rails.logger.close rescue nil - - exec(command_line) - end - - def reload! - run_gc! if gc_request_period - restore! - @when_ready = nil - dispatcher_log :info, "reloaded" - end - - # Make a note of $" so we can safely reload this instance. - def mark_features! - @features = $".clone - end - - def restore! - $".replace @features - Dispatcher.reset_application! - ActionController::Routing::Routes.reload - end - - def run_gc! - @gc_request_countdown = gc_request_period - GC.enable; GC.start; GC.disable - end - - def gc_countdown - if gc_request_period - @gc_request_countdown ||= gc_request_period - @gc_request_countdown -= 1 - run_gc! if @gc_request_countdown <= 0 - end - end - - def close_connection(request) - request.finish if request - end -end diff --git a/vendor/rails/railties/lib/initializer.rb b/vendor/rails/railties/lib/initializer.rb deleted file mode 100644 index fc68d005..00000000 --- a/vendor/rails/railties/lib/initializer.rb +++ /dev/null @@ -1,1152 +0,0 @@ -require 'logger' -require 'set' -require 'pathname' - -$LOAD_PATH.unshift File.dirname(__FILE__) -require 'railties_path' -require 'rails/version' -require 'rails/plugin/locator' -require 'rails/plugin/loader' -require 'rails/gem_dependency' -require 'rails/rack' - - -RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV) - -module Rails - class << self - # The Configuration instance used to configure the Rails environment - def configuration - @@configuration - end - - def configuration=(configuration) - @@configuration = configuration - end - - def initialized? - @initialized || false - end - - def initialized=(initialized) - @initialized ||= initialized - end - - def logger - if defined?(RAILS_DEFAULT_LOGGER) - RAILS_DEFAULT_LOGGER - else - nil - end - end - - def backtrace_cleaner - @@backtrace_cleaner ||= begin - # Relies on ActiveSupport, so we have to lazy load to postpone definition until AS has been loaded - require 'rails/backtrace_cleaner' - Rails::BacktraceCleaner.new - end - end - - def root - Pathname.new(RAILS_ROOT) if defined?(RAILS_ROOT) - end - - def env - @_env ||= ActiveSupport::StringInquirer.new(RAILS_ENV) - end - - def cache - RAILS_CACHE - end - - def version - VERSION::STRING - end - - def public_path - @@public_path ||= self.root ? File.join(self.root, "public") : "public" - end - - def public_path=(path) - @@public_path = path - end - end - - # The Initializer is responsible for processing the Rails configuration, such - # as setting the $LOAD_PATH, requiring the right frameworks, initializing - # logging, and more. It can be run either as a single command that'll just - # use the default configuration, like this: - # - # Rails::Initializer.run - # - # But normally it's more interesting to pass in a custom configuration - # through the block running: - # - # Rails::Initializer.run do |config| - # config.frameworks -= [ :action_mailer ] - # end - # - # This will use the default configuration options from Rails::Configuration, - # but allow for overwriting on select areas. - class Initializer - # The Configuration instance used by this Initializer instance. - attr_reader :configuration - - # The set of loaded plugins. - attr_reader :loaded_plugins - - # Whether or not all the gem dependencies have been met - attr_reader :gems_dependencies_loaded - - # Runs the initializer. By default, this will invoke the #process method, - # which simply executes all of the initialization routines. Alternately, - # you can specify explicitly which initialization routine you want: - # - # Rails::Initializer.run(:set_load_path) - # - # This is useful if you only want the load path initialized, without - # incurring the overhead of completely loading the entire environment. - def self.run(command = :process, configuration = Configuration.new) - yield configuration if block_given? - initializer = new configuration - initializer.send(command) - initializer - end - - # Create a new Initializer instance that references the given Configuration - # instance. - def initialize(configuration) - @configuration = configuration - @loaded_plugins = [] - end - - # Sequentially step through all of the available initialization routines, - # in order (view execution order in source). - def process - Rails.configuration = configuration - - check_ruby_version - install_gem_spec_stubs - set_load_path - add_gem_load_paths - - require_frameworks - set_autoload_paths - add_plugin_load_paths - load_environment - preload_frameworks - - initialize_encoding - initialize_database - - initialize_cache - initialize_framework_caches - - initialize_logger - initialize_framework_logging - - initialize_dependency_mechanism - initialize_whiny_nils - - initialize_time_zone - initialize_i18n - - initialize_framework_settings - initialize_framework_views - - initialize_metal - - add_support_load_paths - - check_for_unbuilt_gems - - load_gems - load_plugins - - # pick up any gems that plugins depend on - add_gem_load_paths - load_gems - check_gem_dependencies - - # bail out if gems are missing - note that check_gem_dependencies will have - # already called abort() unless $gems_rake_task is set - return unless gems_dependencies_loaded - - load_application_initializers - - # the framework is now fully initialized - after_initialize - - # Setup database middleware after initializers have run - initialize_database_middleware - - # Prepare dispatcher callbacks and run 'prepare' callbacks - prepare_dispatcher - - # Routing must be initialized after plugins to allow the former to extend the routes - initialize_routing - - # Observers are loaded after plugins in case Observers or observed models are modified by plugins. - load_observers - - # Load view path cache - load_view_paths - - # Load application classes - load_application_classes - - # Disable dependency loading during request cycle - disable_dependency_loading - - # Flag initialized - Rails.initialized = true - end - - # Check for valid Ruby version - # This is done in an external file, so we can use it - # from the `rails` program as well without duplication. - def check_ruby_version - require 'ruby_version_check' - end - - # If Rails is vendored and RubyGems is available, install stub GemSpecs - # for Rails, Active Support, Active Record, Action Pack, Action Mailer, and - # Active Resource. This allows Gem plugins to depend on Rails even when - # the Gem version of Rails shouldn't be loaded. - def install_gem_spec_stubs - unless Rails.respond_to?(:vendor_rails?) - abort %{Your config/boot.rb is outdated: Run "rake rails:update".} - end - - if Rails.vendor_rails? - begin; require "rubygems"; rescue LoadError; return; end - - stubs = %w(rails activesupport activerecord actionpack actionmailer activeresource) - stubs.reject! { |s| Gem.loaded_specs.key?(s) } - - stubs.each do |stub| - Gem.loaded_specs[stub] = Gem::Specification.new do |s| - s.name = stub - s.version = Rails::VERSION::STRING - s.loaded_from = "" - end - end - end - end - - # Set the <tt>$LOAD_PATH</tt> based on the value of - # Configuration#autoload_paths. Duplicates are removed. - def set_load_path - load_paths = configuration.autoload_paths + configuration.framework_paths - load_paths.reverse_each { |dir| $LOAD_PATH.unshift(dir) if File.directory?(dir) } - $LOAD_PATH.uniq! - end - - # Set the paths from which Rails will automatically load source files, and - # the load_once paths. - def set_autoload_paths - ActiveSupport::Dependencies.autoload_paths = configuration.autoload_paths.uniq - ActiveSupport::Dependencies.autoload_once_paths = configuration.autoload_once_paths.uniq - - extra = ActiveSupport::Dependencies.autoload_once_paths - ActiveSupport::Dependencies.autoload_paths - unless extra.empty? - abort <<-end_error - autoload_once_paths must be a subset of the autoload_paths. - Extra items in autoload_once_paths: #{extra * ','} - end_error - end - - # Freeze the arrays so future modifications will fail rather than do nothing mysteriously - configuration.autoload_once_paths.freeze - end - - # Requires all frameworks specified by the Configuration#frameworks - # list. By default, all frameworks (Active Record, Active Support, - # Action Pack, Action Mailer, and Active Resource) are loaded. - def require_frameworks - configuration.frameworks.each { |framework| require(framework.to_s) } - rescue LoadError => e - # Re-raise as RuntimeError because Mongrel would swallow LoadError. - raise e.to_s - end - - # Preload all frameworks specified by the Configuration#frameworks. - # Used by Passenger to ensure everything's loaded before forking and - # to avoid autoload race conditions in JRuby. - def preload_frameworks - if configuration.preload_frameworks - configuration.frameworks.each do |framework| - # String#classify and #constantize aren't available yet. - toplevel = Object.const_get(framework.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }) - toplevel.load_all! if toplevel.respond_to?(:load_all!) - end - end - end - - # Add the load paths used by support functions such as the info controller - def add_support_load_paths - end - - # Adds all load paths from plugins to the global set of load paths, so that - # code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies). - def add_plugin_load_paths - plugin_loader.add_plugin_load_paths - end - - def add_gem_load_paths - Rails::GemDependency.add_frozen_gem_path - unless @configuration.gems.empty? - require "rubygems" - @configuration.gems.each { |gem| gem.add_load_paths } - end - end - - def load_gems - unless $gems_rake_task - @configuration.gems.each { |gem| gem.load } - end - end - - def check_for_unbuilt_gems - unbuilt_gems = @configuration.gems.select(&:frozen?).reject(&:built?) - if unbuilt_gems.size > 0 - # don't print if the gems:build rake tasks are being run - unless $gems_build_rake_task - abort <<-end_error -The following gems have native components that need to be built - #{unbuilt_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "} - -You're running: - ruby #{Gem.ruby_version} at #{Gem.ruby} - rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '} - -Run `rake gems:build` to build the unbuilt gems. - end_error - end - end - end - - def check_gem_dependencies - unloaded_gems = @configuration.gems.reject { |g| g.loaded? } - if unloaded_gems.size > 0 - @gems_dependencies_loaded = false - # don't print if the gems rake tasks are being run - unless $gems_rake_task - abort <<-end_error -Missing these required gems: - #{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "} - -You're running: - ruby #{Gem.ruby_version} at #{Gem.ruby} - rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '} - -Run `rake gems:install` to install the missing gems. - end_error - end - else - @gems_dependencies_loaded = true - end - end - - # Loads all plugins in <tt>config.plugin_paths</tt>. <tt>plugin_paths</tt> - # defaults to <tt>vendor/plugins</tt> but may also be set to a list of - # paths, such as - # config.plugin_paths = ["#{RAILS_ROOT}/lib/plugins", "#{RAILS_ROOT}/vendor/plugins"] - # - # In the default implementation, as each plugin discovered in <tt>plugin_paths</tt> is initialized: - # * its +lib+ directory, if present, is added to the load path (immediately after the applications lib directory) - # * <tt>init.rb</tt> is evaluated, if present - # - # After all plugins are loaded, duplicates are removed from the load path. - # If an array of plugin names is specified in config.plugins, only those plugins will be loaded - # and they plugins will be loaded in that order. Otherwise, plugins are loaded in alphabetical - # order. - # - # if config.plugins ends contains :all then the named plugins will be loaded in the given order and all other - # plugins will be loaded in alphabetical order - def load_plugins - plugin_loader.load_plugins - end - - def plugin_loader - @plugin_loader ||= configuration.plugin_loader.new(self) - end - - # Loads the environment specified by Configuration#environment_path, which - # is typically one of development, test, or production. - def load_environment - silence_warnings do - return if @environment_loaded - @environment_loaded = true - - config = configuration - constants = self.class.constants - - eval(IO.read(configuration.environment_path), binding, configuration.environment_path) - - (self.class.constants - constants).each do |const| - Object.const_set(const, self.class.const_get(const)) - end - end - end - - def load_observers - if gems_dependencies_loaded && configuration.frameworks.include?(:active_record) - ActiveRecord::Base.instantiate_observers - end - end - - def load_view_paths - if configuration.frameworks.include?(:action_view) - ActionController::Base.view_paths.load! if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.view_paths.load! if configuration.frameworks.include?(:action_mailer) - end - end - - # Eager load application classes - def load_application_classes - return if $rails_rake_task && configuration.dependency_loading - if configuration.cache_classes - configuration.eager_load_paths.each do |load_path| - matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ - Dir.glob("#{load_path}/**/*.rb").sort.each do |file| - require_dependency file.sub(matcher, '\1') - end - end - end - end - - # For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the - # multibyte safe operations. Plugin authors supporting other encodings - # should override this behaviour and set the relevant +default_charset+ - # on ActionController::Base. - # - # For Ruby 1.9, this does nothing. Specify the default encoding in the Ruby - # shebang line if you don't want UTF-8. - def initialize_encoding - $KCODE='u' if RUBY_VERSION < '1.9' - end - - # This initialization routine does nothing unless <tt>:active_record</tt> - # is one of the frameworks to load (Configuration#frameworks). If it is, - # this sets the database configuration from Configuration#database_configuration - # and then establishes the connection. - def initialize_database - if configuration.frameworks.include?(:active_record) - ActiveRecord::Base.configurations = configuration.database_configuration - ActiveRecord::Base.establish_connection - end - end - - def initialize_database_middleware - if configuration.frameworks.include?(:active_record) - if configuration.frameworks.include?(:action_controller) && - ActionController::Base.session_store.name == 'ActiveRecord::SessionStore' - configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::ConnectionAdapters::ConnectionManagement - configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::QueryCache - else - configuration.middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement - configuration.middleware.use ActiveRecord::QueryCache - end - end - end - - def initialize_cache - unless defined?(RAILS_CACHE) - silence_warnings { Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(configuration.cache_store) } - - if RAILS_CACHE.respond_to?(:middleware) - # Insert middleware to setup and teardown local cache for each request - configuration.middleware.insert_after(:"ActionController::Failsafe", RAILS_CACHE.middleware) - end - end - end - - def initialize_framework_caches - if configuration.frameworks.include?(:action_controller) - ActionController::Base.cache_store ||= RAILS_CACHE - end - end - - # If the RAILS_DEFAULT_LOGGER constant is already set, this initialization - # routine does nothing. If the constant is not set, and Configuration#logger - # is not +nil+, this also does nothing. Otherwise, a new logger instance - # is created at Configuration#log_path, with a default log level of - # Configuration#log_level. - # - # If the log could not be created, the log will be set to output to - # +STDERR+, with a log level of +WARN+. - def initialize_logger - # if the environment has explicitly defined a logger, use it - return if Rails.logger - - unless logger = configuration.logger - begin - logger = ActiveSupport::BufferedLogger.new(configuration.log_path) - logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase) - if configuration.environment == "production" - logger.auto_flushing = false - end - rescue StandardError => e - logger = ActiveSupport::BufferedLogger.new(STDERR) - logger.level = ActiveSupport::BufferedLogger::WARN - logger.warn( - "Rails Error: Unable to access log file. Please ensure that #{configuration.log_path} exists and is chmod 0666. " + - "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed." - ) - end - end - - silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger } - end - - # Sets the logger for Active Record, Action Controller, and Action Mailer - # (but only for those frameworks that are to be loaded). If the framework's - # logger is already set, it is not changed, otherwise it is set to use - # RAILS_DEFAULT_LOGGER. - def initialize_framework_logging - for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks) - framework.to_s.camelize.constantize.const_get("Base").logger ||= Rails.logger - end - - ActiveSupport::Dependencies.logger ||= Rails.logger - Rails.cache.logger ||= Rails.logger - end - - # Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+ - # (but only for those frameworks that are to be loaded). If the framework's - # paths have already been set, it is not changed, otherwise it is - # set to use Configuration#view_path. - def initialize_framework_views - if configuration.frameworks.include?(:action_view) - view_path = ActionView::PathSet.type_cast(configuration.view_path) - ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) && ActionMailer::Base.view_paths.blank? - ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.blank? - end - end - - # If Action Controller is not one of the loaded frameworks (Configuration#frameworks) - # this does nothing. Otherwise, it loads the routing definitions and sets up - # loading module used to lazily load controllers (Configuration#controller_paths). - def initialize_routing - return unless configuration.frameworks.include?(:action_controller) - - ActionController::Routing.controller_paths += configuration.controller_paths - ActionController::Routing::Routes.add_configuration_file(configuration.routes_configuration_file) - ActionController::Routing::Routes.reload! - end - - # Sets the dependency loading mechanism based on the value of - # Configuration#cache_classes. - def initialize_dependency_mechanism - ActiveSupport::Dependencies.mechanism = configuration.cache_classes ? :require : :load - end - - # Loads support for "whiny nil" (noisy warnings when methods are invoked - # on +nil+ values) if Configuration#whiny_nils is true. - def initialize_whiny_nils - require('active_support/whiny_nil') if configuration.whiny_nils - end - - # Sets the default value for Time.zone, and turns on ActiveRecord::Base#time_zone_aware_attributes. - # If assigned value cannot be matched to a TimeZone, an exception will be raised. - def initialize_time_zone - if configuration.time_zone - zone_default = Time.__send__(:get_zone, configuration.time_zone) - - unless zone_default - raise \ - 'Value assigned to config.time_zone not recognized.' + - 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' - end - - Time.zone_default = zone_default - - if configuration.frameworks.include?(:active_record) - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - end - end - end - - # Set the i18n configuration from config.i18n but special-case for the load_path which should be - # appended to what's already set instead of overwritten. - def initialize_i18n - configuration.i18n.each do |setting, value| - if setting == :load_path - I18n.load_path += value - else - I18n.send("#{setting}=", value) - end - end - end - - def initialize_metal - Rails::Rack::Metal.requested_metals = configuration.metals - Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths - - configuration.middleware.insert_before( - :"ActionController::ParamsParser", - Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?) - end - - # Initializes framework-specific settings for each of the loaded frameworks - # (Configuration#frameworks). The available settings map to the accessors - # on each of the corresponding Base classes. - def initialize_framework_settings - configuration.frameworks.each do |framework| - base_class = framework.to_s.camelize.constantize.const_get("Base") - - configuration.send(framework).each do |setting, value| - base_class.send("#{setting}=", value) - end - end - configuration.active_support.each do |setting, value| - ActiveSupport.send("#{setting}=", value) - end - end - - # Fires the user-supplied after_initialize block (Configuration#after_initialize) - def after_initialize - if gems_dependencies_loaded - configuration.after_initialize_blocks.each do |block| - block.call - end - end - end - - def load_application_initializers - if gems_dependencies_loaded - Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer| - load(initializer) - end - end - end - - def prepare_dispatcher - return unless configuration.frameworks.include?(:action_controller) - require 'dispatcher' unless defined?(::Dispatcher) - Dispatcher.define_dispatcher_callbacks(configuration.cache_classes) - Dispatcher.run_prepare_callbacks - end - - def disable_dependency_loading - if configuration.cache_classes && !configuration.dependency_loading - ActiveSupport::Dependencies.unhook! - end - end - end - - # The Configuration class holds all the parameters for the Initializer and - # ships with defaults that suites most Rails applications. But it's possible - # to overwrite everything. Usually, you'll create an Configuration file - # implicitly through the block running on the Initializer, but it's also - # possible to create the Configuration instance in advance and pass it in - # like this: - # - # config = Rails::Configuration.new - # Rails::Initializer.run(:process, config) - class Configuration - # The application's base directory. - attr_reader :root_path - - # A stub for setting options on ActionController::Base. - attr_accessor :action_controller - - # A stub for setting options on ActionMailer::Base. - attr_accessor :action_mailer - - # A stub for setting options on ActionView::Base. - attr_accessor :action_view - - # A stub for setting options on ActiveRecord::Base. - attr_accessor :active_record - - # A stub for setting options on ActiveResource::Base. - attr_accessor :active_resource - - # A stub for setting options on ActiveSupport. - attr_accessor :active_support - - # Whether to preload all frameworks at startup. - attr_accessor :preload_frameworks - - # Whether or not classes should be cached (set to false if you want - # application classes to be reloaded on each request) - attr_accessor :cache_classes - - # The list of paths that should be searched for controllers. (Defaults - # to <tt>app/controllers</tt>.) - attr_accessor :controller_paths - - # The path to the database configuration file to use. (Defaults to - # <tt>config/database.yml</tt>.) - attr_accessor :database_configuration_file - - # The path to the routes configuration file to use. (Defaults to - # <tt>config/routes.rb</tt>.) - attr_accessor :routes_configuration_file - - # The list of rails framework components that should be loaded. (Defaults - # to <tt>:active_record</tt>, <tt>:action_controller</tt>, - # <tt>:action_view</tt>, <tt>:action_mailer</tt>, and - # <tt>:active_resource</tt>). - attr_accessor :frameworks - - # An array of additional paths to prepend to the load path. By default, - # all +app+, +lib+, +vendor+ and mock paths are included in this list. - attr_accessor :autoload_paths - - # Deprecated, use autoload_paths. - def load_paths - $stderr.puts("config.load_paths is deprecated and removed in Rails 3, please use autoload_paths instead") - autoload_paths - end - - # Deprecated, use autoload_paths=. - def load_paths=(paths) - $stderr.puts("config.load_paths= is deprecated and removed in Rails 3, please use autoload_paths= instead") - self.autoload_paths = paths - end - - # An array of paths from which Rails will automatically load from only once. - # All elements of this array must also be in +autoload_paths+. - attr_accessor :autoload_once_paths - - # Deprecated, use autoload_once_paths. - def load_once_paths - $stderr.puts("config.load_once_paths is deprecated and removed in Rails 3, please use autoload_once_paths instead") - autoload_once_paths - end - - # Deprecated, use autoload_once_paths=. - def load_once_paths=(paths) - $stderr.puts("config.load_once_paths= is deprecated and removed in Rails 3, please use autoload_once_paths= instead") - self.autoload_once_paths = paths - end - - # An array of paths from which Rails will eager load on boot if cache - # classes is enabled. All elements of this array must also be in - # +autoload_paths+. - attr_accessor :eager_load_paths - - # The log level to use for the default Rails logger. In production mode, - # this defaults to <tt>:info</tt>. In development mode, it defaults to - # <tt>:debug</tt>. - attr_accessor :log_level - - # The path to the log file to use. Defaults to log/#{environment}.log - # (e.g. log/development.log or log/production.log). - attr_accessor :log_path - - # The specific logger to use. By default, a logger will be created and - # initialized using #log_path and #log_level, but a programmer may - # specifically set the logger to use via this accessor and it will be - # used directly. - attr_accessor :logger - - # The specific cache store to use. By default, the ActiveSupport::Cache::Store will be used. - attr_accessor :cache_store - - # The root of the application's views. (Defaults to <tt>app/views</tt>.) - attr_accessor :view_path - - # Set to +true+ if you want to be warned (noisily) when you try to invoke - # any method of +nil+. Set to +false+ for the standard Ruby behavior. - attr_accessor :whiny_nils - - # The list of plugins to load. If this is set to <tt>nil</tt>, all plugins will - # be loaded. If this is set to <tt>[]</tt>, no plugins will be loaded. Otherwise, - # plugins will be loaded in the order specified. - attr_reader :plugins - def plugins=(plugins) - @plugins = plugins.nil? ? nil : plugins.map { |p| p.to_sym } - end - - # The list of metals to load. If this is set to <tt>nil</tt>, all metals will - # be loaded in alphabetical order. If this is set to <tt>[]</tt>, no metals will - # be loaded. Otherwise metals will be loaded in the order specified - attr_accessor :metals - - # The path to the root of the plugins directory. By default, it is in - # <tt>vendor/plugins</tt>. - attr_accessor :plugin_paths - - # The classes that handle finding the desired plugins that you'd like to load for - # your application. By default it is the Rails::Plugin::FileSystemLocator which finds - # plugins to load in <tt>vendor/plugins</tt>. You can hook into gem location by subclassing - # Rails::Plugin::Locator and adding it onto the list of <tt>plugin_locators</tt>. - attr_accessor :plugin_locators - - # The class that handles loading each plugin. Defaults to Rails::Plugin::Loader, but - # a sub class would have access to fine grained modification of the loading behavior. See - # the implementation of Rails::Plugin::Loader for more details. - attr_accessor :plugin_loader - - # Enables or disables plugin reloading. You can get around this setting per plugin. - # If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt> - # to make it reloadable: - # - # ActiveSupport::Dependencies.autoload_once_paths.delete lib_path - # - # If <tt>reload_plugins?</tt> is true, add this to your plugin's <tt>init.rb</tt> - # to only load it once: - # - # ActiveSupport::Dependencies.autoload_once_paths << lib_path - # - attr_accessor :reload_plugins - - # Returns true if plugin reloading is enabled. - def reload_plugins? - !!@reload_plugins - end - - # Enables or disables dependency loading during the request cycle. Setting - # <tt>dependency_loading</tt> to true will allow new classes to be loaded - # during a request. Setting it to false will disable this behavior. - # - # Those who want to run in a threaded environment should disable this - # option and eager load or require all there classes on initialization. - # - # If <tt>cache_classes</tt> is disabled, dependency loaded will always be - # on. - attr_accessor :dependency_loading - - # An array of gems that this rails application depends on. Rails will automatically load - # these gems during installation, and allow you to install any missing gems with: - # - # rake gems:install - # - # You can add gems with the #gem method. - attr_accessor :gems - - # Adds a single Gem dependency to the rails application. By default, it will require - # the library with the same name as the gem. Use :lib to specify a different name. - # - # # gem 'aws-s3', '>= 0.4.0' - # # require 'aws/s3' - # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \ - # :source => "http://code.whytheluckystiff.net" - # - # To require a library be installed, but not attempt to load it, pass :lib => false - # - # config.gem 'qrp', :version => '0.4.1', :lib => false - def gem(name, options = {}) - @gems << Rails::GemDependency.new(name, options) - end - - # Deprecated options: - def breakpoint_server(_ = nil) - $stderr.puts %( - ******************************************************************* - * config.breakpoint_server has been deprecated and has no effect. * - ******************************************************************* - ) - end - alias_method :breakpoint_server=, :breakpoint_server - - # Sets the default +time_zone+. Setting this will enable +time_zone+ - # awareness for Active Record models and set the Active Record default - # timezone to <tt>:utc</tt>. - attr_accessor :time_zone - - # Accessor for i18n settings. - attr_accessor :i18n - - # Create a new Configuration instance, initialized with the default - # values. - def initialize - set_root_path! - - self.frameworks = default_frameworks - self.autoload_paths = default_autoload_paths - self.autoload_once_paths = default_autoload_once_paths - self.eager_load_paths = default_eager_load_paths - self.log_path = default_log_path - self.log_level = default_log_level - self.view_path = default_view_path - self.controller_paths = default_controller_paths - self.preload_frameworks = default_preload_frameworks - self.cache_classes = default_cache_classes - self.dependency_loading = default_dependency_loading - self.whiny_nils = default_whiny_nils - self.plugins = default_plugins - self.plugin_paths = default_plugin_paths - self.plugin_locators = default_plugin_locators - self.plugin_loader = default_plugin_loader - self.database_configuration_file = default_database_configuration_file - self.routes_configuration_file = default_routes_configuration_file - self.gems = default_gems - self.i18n = default_i18n - - for framework in default_frameworks - self.send("#{framework}=", Rails::OrderedOptions.new) - end - self.active_support = Rails::OrderedOptions.new - end - - # Set the root_path to RAILS_ROOT and canonicalize it. - def set_root_path! - raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT) - raise 'RAILS_ROOT is not a directory' unless File.directory?(::RAILS_ROOT) - - @root_path = - # Pathname is incompatible with Windows, but Windows doesn't have - # real symlinks so File.expand_path is safe. - if RUBY_PLATFORM =~ /(:?mswin|mingw)/ - File.expand_path(::RAILS_ROOT) - - # Otherwise use Pathname#realpath which respects symlinks. - else - Pathname.new(::RAILS_ROOT).realpath.to_s - end - - Object.const_set(:RELATIVE_RAILS_ROOT, ::RAILS_ROOT.dup) unless defined?(::RELATIVE_RAILS_ROOT) - ::RAILS_ROOT.replace @root_path - end - - # Enable threaded mode. Allows concurrent requests to controller actions and - # multiple database connections. Also disables automatic dependency loading - # after boot, and disables reloading code on every request, as these are - # fundamentally incompatible with thread safety. - def threadsafe! - self.preload_frameworks = true - self.cache_classes = true - self.dependency_loading = false - self.action_controller.allow_concurrency = true - self - end - - # Loads and returns the contents of the #database_configuration_file. The - # contents of the file are processed via ERB before being sent through - # YAML::load. - def database_configuration - require 'erb' - YAML::load(ERB.new(IO.read(database_configuration_file)).result) - end - - # The path to the current environment's file (<tt>development.rb</tt>, etc.). By - # default the file is at <tt>config/environments/#{environment}.rb</tt>. - def environment_path - "#{root_path}/config/environments/#{environment}.rb" - end - - # Return the currently selected environment. By default, it returns the - # value of the RAILS_ENV constant. - def environment - ::RAILS_ENV - end - - # Adds a block which will be executed after rails has been fully initialized. - # Useful for per-environment configuration which depends on the framework being - # fully initialized. - def after_initialize(&after_initialize_block) - after_initialize_blocks << after_initialize_block if after_initialize_block - end - - # Returns the blocks added with Configuration#after_initialize - def after_initialize_blocks - @after_initialize_blocks ||= [] - end - - # Add a preparation callback that will run before every request in development - # mode, or before the first request in production. - # - # See Dispatcher#to_prepare. - def to_prepare(&callback) - after_initialize do - require 'dispatcher' unless defined?(::Dispatcher) - Dispatcher.to_prepare(&callback) - end - end - - def middleware - require 'action_controller' - ActionController::Dispatcher.middleware - end - - def builtin_directories - # Include builtins only in the development environment. - (environment == 'development') ? Dir["#{RAILTIES_PATH}/builtin/*/"] : [] - end - - def framework_paths - paths = %w(railties railties/lib activesupport/lib) - paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view) - - [:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework| - paths << "#{framework.to_s.gsub('_', '')}/lib" if frameworks.include?(framework) - end - - paths.map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) } - end - - private - def framework_root_path - defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{root_path}/vendor/rails" - end - - def default_frameworks - [ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ] - end - - def default_autoload_paths - paths = [] - - # Add the old mock paths only if the directories exists - paths.concat(Dir["#{root_path}/test/mocks/#{environment}"]) if File.exists?("#{root_path}/test/mocks/#{environment}") - - # Add the app's controller directory - paths.concat(Dir["#{root_path}/app/controllers/"]) - - # Followed by the standard includes. - paths.concat %w( - app - app/metal - app/models - app/controllers - app/helpers - app/services - lib - vendor - ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } - - paths.concat builtin_directories - end - - # Doesn't matter since plugins aren't in autoload_paths yet. - def default_autoload_once_paths - [] - end - - def default_eager_load_paths - %w( - app/metal - app/models - app/controllers - app/helpers - ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } - end - - def default_log_path - File.join(root_path, 'log', "#{environment}.log") - end - - def default_log_level - environment == 'production' ? :info : :debug - end - - def default_database_configuration_file - File.join(root_path, 'config', 'database.yml') - end - - def default_routes_configuration_file - File.join(root_path, 'config', 'routes.rb') - end - - def default_view_path - File.join(root_path, 'app', 'views') - end - - def default_controller_paths - paths = [File.join(root_path, 'app', 'controllers')] - paths.concat builtin_directories - paths - end - - def default_dependency_loading - true - end - - def default_preload_frameworks - false - end - - def default_cache_classes - true - end - - def default_whiny_nils - false - end - - def default_plugins - nil - end - - def default_plugin_paths - ["#{root_path}/vendor/plugins"] - end - - def default_plugin_locators - locators = [] - locators << Plugin::GemLocator if defined? Gem - locators << Plugin::FileSystemLocator - end - - def default_plugin_loader - Plugin::Loader - end - - def default_cache_store - if File.exist?("#{root_path}/tmp/cache/") - [ :file_store, "#{root_path}/tmp/cache/" ] - else - :memory_store - end - end - - def default_gems - [] - end - - def default_i18n - i18n = Rails::OrderedOptions.new - i18n.load_path = [] - - if File.exist?(File.join(RAILS_ROOT, 'config', 'locales')) - i18n.load_path << Dir[File.join(RAILS_ROOT, 'config', 'locales', '*.{rb,yml}')] - i18n.load_path.flatten! - end - - i18n - end - end -end - -# Needs to be duplicated from Active Support since its needed before Active -# Support is available. Here both Options and Hash are namespaced to prevent -# conflicts with other implementations AND with the classes residing in Active Support. -class Rails::OrderedOptions < Array #:nodoc: - def []=(key, value) - key = key.to_sym - - if pair = find_pair(key) - pair.pop - pair << value - else - self << [key, value] - end - end - - def [](key) - pair = find_pair(key.to_sym) - pair ? pair.last : nil - end - - def method_missing(name, *args) - if name.to_s =~ /(.*)=$/ - self[$1.to_sym] = args.first - else - self[name] - end - end - - private - def find_pair(key) - self.each { |i| return i if i.first == key } - return false - end -end - diff --git a/vendor/rails/railties/lib/performance_test_help.rb b/vendor/rails/railties/lib/performance_test_help.rb deleted file mode 100644 index 5148b4ab..00000000 --- a/vendor/rails/railties/lib/performance_test_help.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'action_controller/performance_test' - -ActionController::Base.perform_caching = true -ActiveSupport::Dependencies.mechanism = :require -Rails.logger.level = ActiveSupport::BufferedLogger::INFO diff --git a/vendor/rails/railties/lib/rails/backtrace_cleaner.rb b/vendor/rails/railties/lib/rails/backtrace_cleaner.rb deleted file mode 100644 index 923ed8b3..00000000 --- a/vendor/rails/railties/lib/rails/backtrace_cleaner.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Rails - class BacktraceCleaner < ActiveSupport::BacktraceCleaner - ERB_METHOD_SIG = /:in `_run_erb_.*/ - - RAILS_GEMS = %w( actionpack activerecord actionmailer activesupport activeresource rails ) - - VENDOR_DIRS = %w( vendor/rails ) - SERVER_DIRS = %w( lib/mongrel bin/mongrel - lib/passenger bin/passenger-spawn-server - lib/rack ) - RAILS_NOISE = %w( script/server ) - RUBY_NOISE = %w( rubygems/custom_require benchmark.rb ) - - ALL_NOISE = VENDOR_DIRS + SERVER_DIRS + RAILS_NOISE + RUBY_NOISE - - def initialize - super - add_filter { |line| line.sub("#{RAILS_ROOT}/", '') } - add_filter { |line| line.sub(ERB_METHOD_SIG, '') } - add_filter { |line| line.sub('./', '/') } # for tests - - add_gem_filters - - add_silencer { |line| ALL_NOISE.any? { |dir| line.include?(dir) } } - add_silencer { |line| RAILS_GEMS.any? { |gem| line =~ /^#{gem} / } } - add_silencer { |line| line =~ %r(vendor/plugins/[^\/]+/lib) } - end - - - private - def add_gem_filters - Gem.path.each do |path| - # http://gist.github.com/30430 - add_filter { |line| line.sub(/(#{path})\/gems\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) \4')} - end - - vendor_gems_path = Rails::GemDependency.unpacked_path.sub("#{RAILS_ROOT}/",'') - add_filter { |line| line.sub(/(#{vendor_gems_path})\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) [v] \4')} - end - end - - # For installing the BacktraceCleaner in the test/unit - module BacktraceFilterForTestUnit #:nodoc: - def self.included(klass) - klass.send :alias_method_chain, :filter_backtrace, :cleaning - end - - def filter_backtrace_with_cleaning(backtrace, prefix=nil) - backtrace = filter_backtrace_without_cleaning(backtrace, prefix) - backtrace = backtrace.first.split("\n") if backtrace.size == 1 - Rails.backtrace_cleaner.clean(backtrace) - end - end -end diff --git a/vendor/rails/railties/lib/rails/gem_builder.rb b/vendor/rails/railties/lib/rails/gem_builder.rb deleted file mode 100644 index 79c61cc0..00000000 --- a/vendor/rails/railties/lib/rails/gem_builder.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rubygems' -require 'rubygems/installer' - -module Rails - - # this class hijacks the functionality of Gem::Installer by overloading its - # initializer to only provide the information needed by - # Gem::Installer#build_extensions (which happens to be what we have) - class GemBuilder < Gem::Installer - - def initialize(spec, gem_dir) - @spec = spec - @gem_dir = gem_dir - end - - # silence the underlying builder - def say(message) - end - - end -end diff --git a/vendor/rails/railties/lib/rails/gem_dependency.rb b/vendor/rails/railties/lib/rails/gem_dependency.rb deleted file mode 100644 index 1ff608a8..00000000 --- a/vendor/rails/railties/lib/rails/gem_dependency.rb +++ /dev/null @@ -1,317 +0,0 @@ -require 'rails/vendor_gem_source_index' - -module Gem - def self.source_index=(index) - @@source_index = index - end -end - -module Rails - class GemDependency < Gem::Dependency - attr_accessor :lib, :source, :dep - - def self.unpacked_path - @unpacked_path ||= File.join(RAILS_ROOT, 'vendor', 'gems') - end - - @@framework_gems = {} - - def self.add_frozen_gem_path - @@paths_loaded ||= begin - source_index = Rails::VendorGemSourceIndex.new(Gem.source_index) - Gem.clear_paths - Gem.source_index = source_index - # loaded before us - we can't change them, so mark them - Gem.loaded_specs.each do |name, spec| - @@framework_gems[name] = spec - end - true - end - end - - def self.from_directory_name(directory_name, load_spec=true) - directory_name_parts = File.basename(directory_name).split('-') - - version = directory_name_parts.find { |s| s.match(/^\d(\.\d|\.\w+)*$/) } - name = directory_name_parts[0..directory_name_parts.index(version)-1].join('-') if version - - result = self.new(name, :version => version) - spec_filename = File.join(directory_name, '.specification') - if load_spec - raise "Missing specification file in #{File.dirname(spec_filename)}. Perhaps you need to do a 'rake gems:refresh_specs'\?" unless File.exists?(spec_filename) - spec = YAML::load_file(spec_filename) - result.specification = spec - end - result - rescue ArgumentError => e - raise "Unable to determine gem name and version from '#{directory_name}'" - end - - def initialize(name, options = {}) - require 'rubygems' unless Object.const_defined?(:Gem) - - if options[:requirement] - req = options[:requirement] - elsif options[:version] - req = Gem::Requirement.create(options[:version]) - else - req = Gem::Requirement.default - end - - @lib = options[:lib] - @source = options[:source] - @loaded = @frozen = @load_paths_added = false - - super(name, req) - end - - def add_load_paths - self.class.add_frozen_gem_path - return if @loaded || @load_paths_added - if framework_gem? - @load_paths_added = @loaded = @frozen = true - return - end - - begin - dep = Gem::Dependency.new(name, requirement) - spec = Gem.source_index.find { |_,s| s.satisfies_requirement?(dep) }.last - spec.activate # a way that exists - rescue - gem self.name, self.requirement # < 1.8 unhappy way - end - - @spec = Gem.loaded_specs[name] - @frozen = @spec.loaded_from.include?(self.class.unpacked_path) if @spec - @load_paths_added = true - rescue Gem::LoadError - end - - def dependencies - return [] if framework_gem? - return [] unless installed? - specification.dependencies.reject do |dependency| - dependency.type == :development - end.map do |dependency| - GemDependency.new(dependency.name, :requirement => (dependency.respond_to?(:requirement) ? dependency.requirement : dependency.version_requirements)) - end - end - - def specification - # code repeated from Gem.activate. Find a matching spec, or the currently loaded version. - # error out if loaded version and requested version are incompatible. - @spec ||= begin - matches = Gem.source_index.search(self) - matches << @@framework_gems[name] if framework_gem? - if Gem.loaded_specs[name] then - # This gem is already loaded. If the currently loaded gem is not in the - # list of candidate gems, then we have a version conflict. - existing_spec = Gem.loaded_specs[name] - unless matches.any? { |spec| spec.version == existing_spec.version } then - raise Gem::Exception, - "can't activate #{@dep}, already activated #{existing_spec.full_name}" - end - # we're stuck with it, so change to match - version_requirements = Gem::Requirement.create("=#{existing_spec.version}") - existing_spec - else - # new load - matches.last - end - end - end - - def specification=(s) - @spec = s - end - - def built? - return false unless frozen? - - if vendor_gem? - specification.extensions.each do |ext| - makefile = File.join(unpacked_gem_directory, File.dirname(ext), 'Makefile') - return false unless File.exists?(makefile) - end - end - - true - end - - def framework_gem? - @@framework_gems.has_key?(name) - end - - def frozen? - @frozen ||= vendor_rails? || vendor_gem? - end - - def installed? - Gem.loaded_specs.keys.include?(name) - end - - def load_paths_added? - # always try to add load paths - even if a gem is loaded, it may not - # be a compatible version (ie random_gem 0.4 is loaded and a later spec - # needs >= 0.5 - gem 'random_gem' will catch this and error out) - @load_paths_added - end - - def loaded? - @loaded ||= begin - if vendor_rails? - true - elsif specification.nil? - false - else - # check if the gem is loaded by inspecting $" - # specification.files lists all the files contained in the gem - gem_files = specification.files - # select only the files contained in require_paths - typically in bin and lib - require_paths_regexp = Regexp.new("^(#{specification.require_paths*'|'})/") - gem_lib_files = gem_files.select { |f| require_paths_regexp.match(f) } - # chop the leading directory off - a typical file might be in - # lib/gem_name/file_name.rb, but it will be 'require'd as gem_name/file_name.rb - gem_lib_files.map! { |f| f.split('/', 2)[1] } - # if any of the files from the above list appear in $", the gem is assumed to - # have been loaded - !(gem_lib_files & $").empty? - end - end - end - - def vendor_rails? - Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.empty? - end - - def vendor_gem? - specification && File.exists?(unpacked_gem_directory) - end - - def build(options={}) - require 'rails/gem_builder' - return if specification.nil? - if options[:force] || !built? - return unless File.exists?(unpacked_specification_filename) - spec = YAML::load_file(unpacked_specification_filename) - Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions - puts "Built gem: '#{unpacked_gem_directory}'" - end - dependencies.each { |dep| dep.build(options) } - end - - def install - unless installed? - cmd = "#{gem_command} #{install_command.join(' ')}" - puts cmd - puts %x(#{cmd}) - end - end - - def load - return if @loaded || @load_paths_added == false - require(@lib || name) unless @lib == false - @loaded = true - rescue LoadError - puts $!.to_s - $!.backtrace.each { |b| puts b } - end - - def refresh - Rails::VendorGemSourceIndex.silence_spec_warnings = true - real_gems = Gem.source_index.installed_source_index - exact_dep = Gem::Dependency.new(name, "= #{specification.version}") - matches = real_gems.search(exact_dep) - installed_spec = matches.first - if frozen? - if installed_spec - # we have a real copy - # get a fresh spec - matches should only have one element - # note that there is no reliable method to check that the loaded - # spec is the same as the copy from real_gems - Gem.activate changes - # some of the fields - real_spec = Gem::Specification.load(matches.first.loaded_from) - write_specification(real_spec) - puts "Reloaded specification for #{name} from installed gems." - else - # the gem isn't installed locally - write out our current specs - write_specification(specification) - puts "Gem #{name} not loaded locally - writing out current spec." - end - else - if framework_gem? - puts "Gem directory for #{name} not found - check if it's loading before rails." - else - puts "Something bad is going on - gem directory not found for #{name}." - end - end - end - - def unpack(options={}) - unless frozen? || framework_gem? - FileUtils.mkdir_p unpack_base - Dir.chdir unpack_base do - Gem::GemRunner.new.run(unpack_command) - end - # Gem.activate changes the spec - get the original - real_spec = Gem::Specification.load(specification.loaded_from) - write_specification(real_spec) - end - dependencies.each { |dep| dep.unpack(options) } if options[:recursive] - end - - def write_specification(spec) - # copy the gem's specification into GEMDIR/.specification so that - # we can access information about the gem on deployment systems - # without having the gem installed - File.open(unpacked_specification_filename, 'w') do |file| - file.puts spec.to_yaml - end - end - - def ==(other) - Gem::Dependency === other.class && - self.name == other.name && self.requirement == other.requirement - end - alias_method :eql?, :"==" - - private - - def gem_command - case RUBY_PLATFORM - when /win32/ - 'gem.bat' - when /java/ - 'jruby -S gem' - else - 'gem' - end - end - - def install_command - cmd = %w(install) << name - cmd << "--version" << %("#{requirement.to_s}") if requirement - cmd << "--source" << @source if @source - cmd - end - - def unpack_command - cmd = %w(unpack) << name - cmd << "--version" << "= "+specification.version.to_s if requirement - cmd - end - - def unpack_base - Rails::GemDependency.unpacked_path - end - - def unpacked_gem_directory - File.join(unpack_base, specification.full_name) - end - - def unpacked_specification_filename - File.join(unpacked_gem_directory, '.specification') - end - - end -end diff --git a/vendor/rails/railties/lib/rails/plugin.rb b/vendor/rails/railties/lib/rails/plugin.rb deleted file mode 100644 index 52912577..00000000 --- a/vendor/rails/railties/lib/rails/plugin.rb +++ /dev/null @@ -1,179 +0,0 @@ -module Rails - # The Plugin class should be an object which provides the following methods: - # - # * +name+ - Used during initialisation to order the plugin (based on name and - # the contents of <tt>config.plugins</tt>). - # * +valid?+ - Returns true if this plugin can be loaded. - # * +load_paths+ - Each path within the returned array will be added to the <tt>$LOAD_PATH</tt>. - # * +load+ - Finally 'load' the plugin. - # - # These methods are expected by the Rails::Plugin::Locator and Rails::Plugin::Loader classes. - # The default implementation returns the <tt>lib</tt> directory as its <tt>load_paths</tt>, - # and evaluates <tt>init.rb</tt> when <tt>load</tt> is called. - # - # You can also inspect the about.yml data programmatically: - # - # plugin = Rails::Plugin.new(path_to_my_plugin) - # plugin.about["author"] # => "James Adam" - # plugin.about["url"] # => "http://interblah.net" - class Plugin - include Comparable - - attr_reader :directory, :name - - def initialize(directory) - @directory = directory - @name = File.basename(@directory) rescue nil - @loaded = false - end - - def valid? - File.directory?(directory) && (has_app_directory? || has_lib_directory? || has_init_file?) - end - - # Returns a list of paths this plugin wishes to make available in <tt>$LOAD_PATH</tt>. - def load_paths - report_nonexistant_or_empty_plugin! unless valid? - - [].tap do |load_paths| - load_paths << lib_path if has_lib_directory? - load_paths << app_paths if has_app_directory? - end.flatten - end - - # Evaluates a plugin's init.rb file. - def load(initializer) - return if loaded? - report_nonexistant_or_empty_plugin! unless valid? - evaluate_init_rb(initializer) - @loaded = true - end - - def loaded? - @loaded - end - - def <=>(other_plugin) - name <=> other_plugin.name - end - - def about - @about ||= load_about_information - end - - # Engines are plugins with an app/ directory. - def engine? - has_app_directory? - end - - # Returns true if the engine ships with a routing file - def routed? - File.exist?(routing_file) - end - - # Returns true if there is any localization file in locale_path - def localized? - locale_files.any? - end - - def view_path - File.join(directory, 'app', 'views') - end - - def controller_path - File.join(directory, 'app', 'controllers') - end - - def metal_path - File.join(directory, 'app', 'metal') - end - - def routing_file - File.join(directory, 'config', 'routes.rb') - end - - def locale_path - File.join(directory, 'config', 'locales') - end - - def locale_files - Dir[ File.join(locale_path, '*.{rb,yml}') ] - end - - - private - def load_about_information - about_yml_path = File.join(@directory, "about.yml") - parsed_yml = File.exist?(about_yml_path) ? YAML.load(File.read(about_yml_path)) : {} - parsed_yml || {} - rescue Exception - {} - end - - def report_nonexistant_or_empty_plugin! - raise LoadError, "Can not find the plugin named: #{name}" - end - - - def app_paths - [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path, metal_path ] - end - - def lib_path - File.join(directory, 'lib') - end - - def classic_init_path - File.join(directory, 'init.rb') - end - - def gem_init_path - File.join(directory, 'rails', 'init.rb') - end - - def init_path - File.file?(gem_init_path) ? gem_init_path : classic_init_path - end - - - def has_app_directory? - File.directory?(File.join(directory, 'app')) - end - - def has_lib_directory? - File.directory?(lib_path) - end - - def has_init_file? - File.file?(init_path) - end - - - def evaluate_init_rb(initializer) - if has_init_file? - silence_warnings do - # Allow plugins to reference the current configuration object - config = initializer.configuration - - eval(IO.read(init_path), binding, init_path) - end - end - end - end - - # This Plugin subclass represents a Gem plugin. Although RubyGems has already - # taken care of $LOAD_PATHs, it exposes its load_paths to add them - # to Dependencies.load_paths. - class GemPlugin < Plugin - # Initialize this plugin from a Gem::Specification. - def initialize(spec, gem) - directory = spec.full_gem_path - super(directory) - @name = spec.name - end - - def init_path - File.join(directory, 'rails', 'init.rb') - end - end -end diff --git a/vendor/rails/railties/lib/rails/plugin/loader.rb b/vendor/rails/railties/lib/rails/plugin/loader.rb deleted file mode 100644 index a9754426..00000000 --- a/vendor/rails/railties/lib/rails/plugin/loader.rb +++ /dev/null @@ -1,198 +0,0 @@ -require "rails/plugin" - -module Rails - class Plugin - class Loader - attr_reader :initializer - - # Creates a new Plugin::Loader instance, associated with the given - # Rails::Initializer. This default implementation automatically locates - # all plugins, and adds all plugin load paths, when it is created. The plugins - # are then fully loaded (init.rb is evaluated) when load_plugins is called. - # - # It is the loader's responsibility to ensure that only the plugins specified - # in the configuration are actually loaded, and that the order defined - # is respected. - def initialize(initializer) - @initializer = initializer - end - - # Returns the plugins to be loaded, in the order they should be loaded. - def plugins - @plugins ||= all_plugins.select { |plugin| should_load?(plugin) }.sort { |p1, p2| order_plugins(p1, p2) } - end - - # Returns the plugins that are in engine-form (have an app/ directory) - def engines - @engines ||= plugins.select(&:engine?) - end - - # Returns all the plugins that could be found by the current locators. - def all_plugins - @all_plugins ||= locate_plugins - @all_plugins - end - - def load_plugins - plugins.each do |plugin| - plugin.load(initializer) - register_plugin_as_loaded(plugin) - end - - configure_engines - - ensure_all_registered_plugins_are_loaded! - end - - # Adds the load paths for every plugin into the $LOAD_PATH. Plugin load paths are - # added *after* the application's <tt>lib</tt> directory, to ensure that an application - # can always override code within a plugin. - # - # Plugin load paths are also added to Dependencies.autoload_paths, and Dependencies.autoload_once_paths. - def add_plugin_load_paths - plugins.each do |plugin| - plugin.load_paths.each do |path| - $LOAD_PATH.insert(application_lib_index + 1, path) - - ActiveSupport::Dependencies.autoload_paths << path - - unless configuration.reload_plugins? - ActiveSupport::Dependencies.autoload_once_paths << path - end - end - end - - $LOAD_PATH.uniq! - end - - def engine_metal_paths - engines.collect(&:metal_path) - end - - protected - def configure_engines - if engines.any? - add_engine_routing_configurations - add_engine_locales - add_engine_controller_paths - add_engine_view_paths - end - end - - def add_engine_routing_configurations - engines.select(&:routed?).collect(&:routing_file).each do |routing_file| - ActionController::Routing::Routes.add_configuration_file(routing_file) - end - end - - def add_engine_locales - # reverse it such that the last engine can overwrite translations from the first, like with routes - locale_files = engines.select(&:localized?).collect(&:locale_files).reverse.flatten - I18n.load_path += locale_files - I18n.load_path - end - - def add_engine_controller_paths - ActionController::Routing.controller_paths += engines.collect(&:controller_path) - end - - def add_engine_view_paths - # reverse it such that the last engine can overwrite view paths from the first, like with routes - paths = ActionView::PathSet.new(engines.collect(&:view_path).reverse) - ActionController::Base.view_paths.concat(paths) - ActionMailer::Base.view_paths.concat(paths) if configuration.frameworks.include?(:action_mailer) - end - - # The locate_plugins method uses each class in config.plugin_locators to - # find the set of all plugins available to this Rails application. - def locate_plugins - configuration.plugin_locators.map do |locator| - locator.new(initializer).plugins - end.flatten - # TODO: sorting based on config.plugins - end - - def register_plugin_as_loaded(plugin) - initializer.loaded_plugins << plugin - end - - def configuration - initializer.configuration - end - - def should_load?(plugin) - # uses Plugin#name and Plugin#valid? - enabled?(plugin) && plugin.valid? - end - - def order_plugins(plugin_a, plugin_b) - if !explicit_plugin_loading_order? - plugin_a <=> plugin_b - else - if !explicitly_enabled?(plugin_a) && !explicitly_enabled?(plugin_b) - plugin_a <=> plugin_b - else - effective_order_of(plugin_a) <=> effective_order_of(plugin_b) - end - end - end - - def effective_order_of(plugin) - if explicitly_enabled?(plugin) - registered_plugin_names.index(plugin.name) - else - registered_plugin_names.index('all') - end - end - - def application_lib_index - $LOAD_PATH.index(File.join(RAILS_ROOT, 'lib')) || 0 - end - - def enabled?(plugin) - !explicit_plugin_loading_order? || registered?(plugin) - end - - def explicit_plugin_loading_order? - !registered_plugin_names.nil? - end - - def registered?(plugin) - explicit_plugin_loading_order? && registered_plugins_names_plugin?(plugin) - end - - def explicitly_enabled?(plugin) - !explicit_plugin_loading_order? || explicitly_registered?(plugin) - end - - def explicitly_registered?(plugin) - explicit_plugin_loading_order? && registered_plugin_names.include?(plugin.name) - end - - def registered_plugins_names_plugin?(plugin) - registered_plugin_names.include?(plugin.name) || registered_plugin_names.include?('all') - end - - # The plugins that have been explicitly listed with config.plugins. If this list is nil - # then it means the client does not care which plugins or in what order they are loaded, - # so we load all in alphabetical order. If it is an empty array, we load no plugins, if it is - # non empty, we load the named plugins in the order specified. - def registered_plugin_names - configuration.plugins ? configuration.plugins.map(&:to_s) : nil - end - - def loaded?(plugin_name) - initializer.loaded_plugins.detect { |plugin| plugin.name == plugin_name.to_s } - end - - def ensure_all_registered_plugins_are_loaded! - if explicit_plugin_loading_order? - if configuration.plugins.detect {|plugin| plugin != :all && !loaded?(plugin) } - missing_plugins = configuration.plugins - (plugins.map{|p| p.name.to_sym} + [:all]) - raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence(:locale => :en)}" - end - end - end - - end - end -end diff --git a/vendor/rails/railties/lib/rails/plugin/locator.rb b/vendor/rails/railties/lib/rails/plugin/locator.rb deleted file mode 100644 index a6fc388a..00000000 --- a/vendor/rails/railties/lib/rails/plugin/locator.rb +++ /dev/null @@ -1,100 +0,0 @@ -module Rails - class Plugin - - # The Plugin::Locator class should be subclasses to provide custom plugin-finding - # abilities to Rails (i.e. loading plugins from Gems, etc). Each subclass should implement - # the <tt>located_plugins</tt> method, which return an array of Plugin objects that have been found. - class Locator - include Enumerable - - attr_reader :initializer - - def initialize(initializer) - @initializer = initializer - end - - # This method should return all the plugins which this Plugin::Locator can find - # These will then be used by the current Plugin::Loader, which is responsible for actually - # loading the plugins themselves - def plugins - raise "The `plugins' method must be defined by concrete subclasses of #{self.class}" - end - - def each(&block) - plugins.each(&block) - end - - def plugin_names - plugins.map(&:name) - end - end - - # The Rails::Plugin::FileSystemLocator will try to locate plugins by examining the directories - # in the paths given in configuration.plugin_paths. Any plugins that can be found are returned - # in a list. - # - # The criteria for a valid plugin in this case is found in Rails::Plugin#valid?, although - # other subclasses of Rails::Plugin::Locator can of course use different conditions. - class FileSystemLocator < Locator - - # Returns all the plugins which can be loaded in the filesystem, under the paths given - # by configuration.plugin_paths. - def plugins - initializer.configuration.plugin_paths.flatten.inject([]) do |plugins, path| - plugins.concat locate_plugins_under(path) - plugins - end.flatten - end - - private - - # Attempts to create a plugin from the given path. If the created plugin is valid? - # (see Rails::Plugin#valid?) then the plugin instance is returned; otherwise nil. - def create_plugin(path) - plugin = Rails::Plugin.new(path) - plugin.valid? ? plugin : nil - end - - # This starts at the base path looking for valid plugins (see Rails::Plugin#valid?). - # Since plugins can be nested arbitrarily deep within an unspecified number of intermediary - # directories, this method runs recursively until it finds a plugin directory, e.g. - # - # locate_plugins_under('vendor/plugins/acts/acts_as_chunky_bacon') - # => <Rails::Plugin name: 'acts_as_chunky_bacon' ... > - # - def locate_plugins_under(base_path) - Dir.glob(File.join(base_path, '*')).sort.inject([]) do |plugins, path| - if plugin = create_plugin(path) - plugins << plugin - elsif File.directory?(path) - plugins.concat locate_plugins_under(path) - end - plugins - end - end - end - - # The GemLocator scans all the loaded RubyGems, looking for gems with - # a <tt>rails/init.rb</tt> file. - class GemLocator < Locator - def plugins - gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem } - specs = gem_index.keys - specs += Gem.loaded_specs.values.select do |spec| - spec.loaded_from && # prune stubs - File.exist?(File.join(spec.full_gem_path, "rails", "init.rb")) - end - specs.compact! - - require "rubygems/dependency_list" - - deps = Gem::DependencyList.new - deps.add(*specs) unless specs.empty? - - deps.dependency_order.collect do |spec| - Rails::GemPlugin.new(spec, gem_index[spec]) - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails/rack.rb b/vendor/rails/railties/lib/rails/rack.rb deleted file mode 100644 index 9705f65e..00000000 --- a/vendor/rails/railties/lib/rails/rack.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Rails - module Rack - autoload :Debugger, "rails/rack/debugger" - autoload :LogTailer, "rails/rack/log_tailer" - autoload :Metal, "rails/rack/metal" - autoload :Static, "rails/rack/static" - end -end diff --git a/vendor/rails/railties/lib/rails/rack/debugger.rb b/vendor/rails/railties/lib/rails/rack/debugger.rb deleted file mode 100644 index 0a7b4055..00000000 --- a/vendor/rails/railties/lib/rails/rack/debugger.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Rails - module Rack - class Debugger - def initialize(app) - @app = app - - ARGV.clear # clear ARGV so that script/server options aren't passed to IRB - - require_library_or_gem 'ruby-debug' - ::Debugger.start - ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) - puts "=> Debugger enabled" - rescue Exception - puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'" - exit - end - - def call(env) - @app.call(env) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/rack/log_tailer.rb b/vendor/rails/railties/lib/rails/rack/log_tailer.rb deleted file mode 100644 index a237cee6..00000000 --- a/vendor/rails/railties/lib/rails/rack/log_tailer.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Rails - module Rack - class LogTailer - EnvironmentLog = "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log" - - def initialize(app, log = nil) - @app = app - - path = Pathname.new(log || EnvironmentLog).cleanpath - @cursor = ::File.size(path) - @last_checked = Time.now.to_f - - @file = ::File.open(path, 'r') - end - - def call(env) - response = @app.call(env) - tail_log - response - end - - def tail_log - @file.seek @cursor - - mod = @file.mtime.to_f - if mod > @last_checked - contents = @file.read - @last_checked = mod - @cursor += contents.size - $stdout.print contents - end - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/rack/metal.rb b/vendor/rails/railties/lib/rails/rack/metal.rb deleted file mode 100644 index 8719a5c5..00000000 --- a/vendor/rails/railties/lib/rails/rack/metal.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'active_support/ordered_hash' - -module Rails - module Rack - class Metal - NotFoundResponse = [404, {}, []].freeze - NotFound = lambda { NotFoundResponse } - - cattr_accessor :metal_paths - self.metal_paths = ["#{Rails.root}/app/metal"] - cattr_accessor :requested_metals - - def self.metals - matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/ - metal_glob = metal_paths.map{ |base| "#{base}/**/*.rb" } - all_metals = {} - - metal_glob.each do |glob| - Dir[glob].sort.map do |file| - file = file.match(matcher)[1] - all_metals[file.camelize] = file - end - end - - load_list = requested_metals || all_metals.keys - - load_list.map do |requested_metal| - if metal = all_metals[requested_metal] - require_dependency metal - requested_metal.constantize - end - end.compact - end - - def initialize(app) - @app = app - @metals = ActiveSupport::OrderedHash.new - self.class.metals.each { |app| @metals[app] = true } - freeze - end - - def call(env) - @metals.keys.each do |app| - result = app.call(env) - return result unless result[0].to_i == 404 - end - @app.call(env) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/rack/static.rb b/vendor/rails/railties/lib/rails/rack/static.rb deleted file mode 100644 index f07c6beb..00000000 --- a/vendor/rails/railties/lib/rails/rack/static.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'rack/utils' - -module Rails - module Rack - class Static - FILE_METHODS = %w(GET HEAD).freeze - - def initialize(app) - @app = app - @file_server = ::Rack::File.new(File.join(RAILS_ROOT, "public")) - end - - def call(env) - path = env['PATH_INFO'].chomp('/') - method = env['REQUEST_METHOD'] - - if FILE_METHODS.include?(method) - if file_exist?(path) - return @file_server.call(env) - else - cached_path = directory_exist?(path) ? "#{path}/index" : path - cached_path += ::ActionController::Base.page_cache_extension - - if file_exist?(cached_path) - env['PATH_INFO'] = cached_path - return @file_server.call(env) - end - end - end - - @app.call(env) - end - - private - def file_exist?(path) - full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path)) - File.file?(full_path) && File.readable?(full_path) - end - - def directory_exist?(path) - full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path)) - File.directory?(full_path) && File.readable?(full_path) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb b/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb deleted file mode 100644 index 9324de98..00000000 --- a/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb +++ /dev/null @@ -1,140 +0,0 @@ -require 'rubygems' -require 'yaml' - -module Rails - - class VendorGemSourceIndex - # VendorGemSourceIndex acts as a proxy for the Gem source index, allowing - # gems to be loaded from vendor/gems. Rather than the standard gem repository format, - # vendor/gems contains unpacked gems, with YAML specifications in .specification in - # each gem directory. - include Enumerable - - attr_reader :installed_source_index - attr_reader :vendor_source_index - - @@silence_spec_warnings = false - - def self.silence_spec_warnings - @@silence_spec_warnings - end - - def self.silence_spec_warnings=(v) - @@silence_spec_warnings = v - end - - def initialize(installed_index, vendor_dir=Rails::GemDependency.unpacked_path) - @installed_source_index = installed_index - @vendor_dir = vendor_dir - refresh! - end - - def refresh! - # reload the installed gems - # HACK: I don't think this is needed: @installed_source_index.refresh! - vendor_gems = {} - - # handle vendor Rails gems - they are identified by having loaded_from set to "" - # we add them manually to the list, so that other gems can find them via dependencies - Gem.loaded_specs.each do |n, s| - next unless s.loaded_from.to_s.empty? - vendor_gems[s.full_name] = s - end - - # load specifications from vendor/gems - Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |d| - dir_name = File.basename(d) - dir_version = version_for_dir(dir_name) - spec = load_specification(d) - if spec - if spec.full_name != dir_name - # mismatched directory name and gem spec - produced by 2.1.0-era unpack code - if dir_version - # fix the spec version - this is not optimal (spec.files may be wrong) - # but it's better than breaking apps. Complain to remind users to get correct specs. - # use ActiveSupport::Deprecation.warn, as the logger is not set yet - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has a mismatched specification file."+ - " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings - spec.version = dir_version - else - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems is not in a versioned directory"+ - "(should be #{spec.full_name}).") unless @@silence_spec_warnings - # continue, assume everything is OK - end - end - else - # no spec - produced by early-2008 unpack code - # emulate old behavior, and complain. - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has no specification file."+ - " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings - if dir_version - spec = Gem::Specification.new - spec.version = dir_version - spec.require_paths = ['lib'] - ext_path = File.join(d, 'ext') - spec.require_paths << 'ext' if File.exist?(ext_path) - spec.name = /^(.*)-[^-]+$/.match(dir_name)[1] - files = ['lib'] - # set files to everything in lib/ - files += Dir[File.join(d, 'lib', '*')].map { |v| v.gsub(/^#{d}\//, '') } - files += Dir[File.join(d, 'ext', '*')].map { |v| v.gsub(/^#{d}\//, '') } if ext_path - spec.files = files - else - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems not in a versioned directory."+ - " Giving up.") unless @@silence_spec_warnings - next - end - end - spec.loaded_from = File.join(d, '.specification') - # finally, swap out full_gem_path - # it would be better to use a Gem::Specification subclass, but the YAML loads an explicit class - class << spec - def full_gem_path - path = File.join installation_path, full_name - return path if File.directory? path - File.join installation_path, original_name - end - end - vendor_gems[File.basename(d)] = spec - end - @vendor_source_index = Gem::SourceIndex.new(vendor_gems) - end - - def version_for_dir(d) - version = d.split('-').find { |s| s.match(/^\d(\.\d|\.\w+)*$/) } - Gem::Version.new(version) - end - - def load_specification(gem_dir) - spec_file = File.join(gem_dir, '.specification') - YAML.load_file(spec_file) if File.exist?(spec_file) - end - - def find_name(*args) - @installed_source_index.find_name(*args) + @vendor_source_index.find_name(*args) - end - - def search(*args) - # look for vendor gems, and then installed gems - later elements take priority - @installed_source_index.search(*args) + @vendor_source_index.search(*args) - end - - def each(&block) - @vendor_source_index.each(&block) - @installed_source_index.each(&block) - end - - def add_spec(spec) - @vendor_source_index.add_spec spec - end - - def remove_spec(spec) - @vendor_source_index.remove_spec spec - end - - def size - @vendor_source_index.size + @installed_source_index.size - end - - end -end diff --git a/vendor/rails/railties/lib/rails/version.rb b/vendor/rails/railties/lib/rails/version.rb deleted file mode 100644 index b89643ff..00000000 --- a/vendor/rails/railties/lib/rails/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Rails - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 14 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/railties/lib/rails_generator.rb b/vendor/rails/railties/lib/rails_generator.rb deleted file mode 100644 index 264c6490..00000000 --- a/vendor/rails/railties/lib/rails_generator.rb +++ /dev/null @@ -1,46 +0,0 @@ -#-- -# Copyright (c) 2004 Jeremy Kemper -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -railties = File.expand_path("..", __FILE__) -$:.unshift(railties) unless $:.include?(railties) - -activesupport = File.expand_path("../../../activesupport/lib", __FILE__) -$:.unshift(activesupport) unless $:.include?(activesupport) - -begin - require 'active_support' -rescue LoadError - require 'rubygems' - gem 'activesupport' -end - -require 'rails_generator/base' -require 'rails_generator/lookup' -require 'rails_generator/commands' - -Rails::Generator::Base.send(:include, Rails::Generator::Lookup) -Rails::Generator::Base.send(:include, Rails::Generator::Commands) - -# Set up a default logger for convenience. -require 'rails_generator/simple_logger' -Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) diff --git a/vendor/rails/railties/lib/rails_generator/base.rb b/vendor/rails/railties/lib/rails_generator/base.rb deleted file mode 100644 index dd75f05c..00000000 --- a/vendor/rails/railties/lib/rails_generator/base.rb +++ /dev/null @@ -1,266 +0,0 @@ -require File.dirname(__FILE__) + '/options' -require File.dirname(__FILE__) + '/manifest' -require File.dirname(__FILE__) + '/spec' -require File.dirname(__FILE__) + '/generated_attribute' - -module Rails - # Rails::Generator is a code generation platform tailored for the Rails - # web application framework. Generators are easily invoked within Rails - # applications to add and remove components such as models and controllers. - # New generators are easy to create and may be distributed as RubyGems, - # tarballs, or Rails plugins for inclusion system-wide, per-user, - # or per-application. - # - # For actual examples see the rails_generator/generators directory in the - # Rails source (or the +railties+ directory if you have frozen the Rails - # source in your application). - # - # Generators may subclass other generators to provide variations that - # require little or no new logic but replace the template files. - # - # For a RubyGem, put your generator class and templates in the +lib+ - # directory. For a Rails plugin, make a +generators+ directory at the - # root of your plugin. - # - # The layout of generator files can be seen in the built-in - # +controller+ generator: - # - # generators/ - # components/ - # controller/ - # controller_generator.rb - # templates/ - # controller.rb - # functional_test.rb - # helper.rb - # view.html.erb - # - # The directory name (+controller+) matches the name of the generator file - # (controller_generator.rb) and class (ControllerGenerator). The files - # that will be copied or used as templates are stored in the +templates+ - # directory. - # - # The filenames of the templates don't matter, but choose something that - # will be self-explanatory since you will be referencing these in the - # +manifest+ method inside your generator subclass. - # - # - module Generator - class GeneratorError < StandardError; end - class UsageError < GeneratorError; end - - - # The base code generator is bare-bones. It sets up the source and - # destination paths and tells the logger whether to keep its trap shut. - # - # It's useful for copying files such as stylesheets, images, or - # javascripts. - # - # For more comprehensive template-based passive code generation with - # arguments, you'll want Rails::Generator::NamedBase. - # - # Generators create a manifest of the actions they perform then hand - # the manifest to a command which replays the actions to do the heavy - # lifting (such as checking for existing files or creating directories - # if needed). Create, destroy, and list commands are included. Since a - # single manifest may be used by any command, creating new generators is - # as simple as writing some code templates and declaring what you'd like - # to do with them. - # - # The manifest method must be implemented by subclasses, returning a - # Rails::Generator::Manifest. The +record+ method is provided as a - # convenience for manifest creation. Example: - # - # class StylesheetGenerator < Rails::Generator::Base - # def manifest - # record do |m| - # m.directory('public/stylesheets') - # m.file('application.css', 'public/stylesheets/application.css') - # end - # end - # end - # - # See Rails::Generator::Commands::Create for a list of methods available - # to the manifest. - class Base - include Options - - # Declare default options for the generator. These options - # are inherited to subclasses. - default_options :collision => :ask, :quiet => false - - # A logger instance available everywhere in the generator. - cattr_accessor :logger - - # Every generator that is dynamically looked up is tagged with a - # Spec describing where it was found. - class_inheritable_accessor :spec - - attr_reader :source_root, :destination_root, :args - - def initialize(runtime_args, runtime_options = {}) - @args = runtime_args - parse!(@args, runtime_options) - - # Derive source and destination paths. - @source_root = options[:source] || File.join(spec.path, 'templates') - if options[:destination] - @destination_root = options[:destination] - elsif defined? ::RAILS_ROOT - @destination_root = ::RAILS_ROOT - end - - # Silence the logger if requested. - logger.quiet = options[:quiet] - - # Raise usage error if help is requested. - usage if options[:help] - end - - # Generators must provide a manifest. Use the +record+ method to create - # a new manifest and record your generator's actions. - def manifest - raise NotImplementedError, "No manifest for '#{spec.name}' generator." - end - - # Return the full path from the source root for the given path. - # Example for source_root = '/source': - # source_path('some/path.rb') == '/source/some/path.rb' - # - # The given path may include a colon ':' character to indicate that - # the file belongs to another generator. This notation allows any - # generator to borrow files from another. Example: - # source_path('model:fixture.yml') = '/model/source/path/fixture.yml' - def source_path(relative_source) - # Check whether we're referring to another generator's file. - name, path = relative_source.split(':', 2) - - # If not, return the full path to our source file. - if path.nil? - File.join(source_root, name) - - # Otherwise, ask our referral for the file. - else - # FIXME: this is broken, though almost always true. Others' - # source_root are not necessarily the templates dir. - File.join(self.class.lookup(name).path, 'templates', path) - end - end - - # Return the full path from the destination root for the given path. - # Example for destination_root = '/dest': - # destination_path('some/path.rb') == '/dest/some/path.rb' - def destination_path(relative_destination) - File.join(destination_root, relative_destination) - end - - def after_generate - end - - protected - # Convenience method for generator subclasses to record a manifest. - def record - Rails::Generator::Manifest.new(self) { |m| yield m } - end - - # Override with your own usage banner. - def banner - "Usage: #{$0} #{spec.name} [options]" - end - - # Read USAGE from file in generator base path. - def usage_message - File.read(File.join(spec.path, 'USAGE')) rescue '' - end - end - - - # The base generator for named components: models, controllers, mailers, - # etc. The target name is taken as the first argument and inflected to - # singular, plural, class, file, and table forms for your convenience. - # The remaining arguments are aliased to +actions+ as an array for - # controller and mailer convenience. - # - # Several useful local variables and methods are populated in the - # +initialize+ method. See below for a list of Attributes and - # External Aliases available to both the manifest and to all templates. - # - # If no name is provided, the generator raises a usage error with content - # optionally read from the USAGE file in the generator's base path. - # - # For example, the +controller+ generator takes the first argument as - # the name of the class and subsequent arguments as the names of - # actions to be generated: - # - # ./script/generate controller Article index new create - # - # See Rails::Generator::Base for a discussion of manifests, - # Rails::Generator::Commands::Create for methods available to the manifest, - # and Rails::Generator for a general discussion of generators. - class NamedBase < Base - attr_reader :name, :class_name, :singular_name, :plural_name, :table_name - attr_reader :class_path, :file_path, :class_nesting, :class_nesting_depth - alias_method :file_name, :singular_name - alias_method :actions, :args - - def initialize(runtime_args, runtime_options = {}) - super - - # Name argument is required. - usage if runtime_args.empty? - - @args = runtime_args.dup - base_name = @args.shift - assign_names!(base_name) - end - - protected - # Override with your own usage banner. - def banner - "Usage: #{$0} #{spec.name} #{spec.name.camelize}Name [options]" - end - - def attributes - @attributes ||= @args.collect do |attribute| - Rails::Generator::GeneratedAttribute.new(*attribute.split(":")) - end - end - - - private - def assign_names!(name) - @name = name - base_name, @class_path, @file_path, @class_nesting, @class_nesting_depth = extract_modules(@name) - @class_name_without_nesting, @singular_name, @plural_name = inflect_names(base_name) - @table_name = (!defined?(ActiveRecord::Base) || ActiveRecord::Base.pluralize_table_names) ? plural_name : singular_name - if @class_nesting.empty? - @class_name = @class_name_without_nesting - else - @table_name = @class_nesting.underscore << "_" << @table_name - @class_name = "#{@class_nesting}::#{@class_name_without_nesting}" - end - @table_name.gsub! '/', '_' - end - - # Extract modules from filesystem-style or ruby-style path: - # good/fun/stuff - # Good::Fun::Stuff - # produce the same results. - def extract_modules(name) - modules = name.include?('/') ? name.split('/') : name.split('::') - name = modules.pop - path = modules.map { |m| m.underscore } - file_path = (path + [name.underscore]).join('/') - nesting = modules.map { |m| m.camelize }.join('::') - [name, path, file_path, nesting, modules.size] - end - - def inflect_names(name) - camel = name.camelize - under = camel.underscore - plural = under.pluralize - [camel, under, plural] - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/commands.rb b/vendor/rails/railties/lib/rails_generator/commands.rb deleted file mode 100644 index b684dc92..00000000 --- a/vendor/rails/railties/lib/rails_generator/commands.rb +++ /dev/null @@ -1,621 +0,0 @@ -require 'delegate' -require 'optparse' -require 'fileutils' -require 'tempfile' -require 'erb' - -module Rails - module Generator - module Commands - # Here's a convenient way to get a handle on generator commands. - # Command.instance('destroy', my_generator) instantiates a Destroy - # delegate of my_generator ready to do your dirty work. - def self.instance(command, generator) - const_get(command.to_s.camelize).new(generator) - end - - # Even more convenient access to commands. Include Commands in - # the generator Base class to get a nice #command instance method - # which returns a delegate for the requested command. - def self.included(base) - base.send(:define_method, :command) do |command| - Commands.instance(command, self) - end - end - - - # Generator commands delegate Rails::Generator::Base and implement - # a standard set of actions. Their behavior is defined by the way - # they respond to these actions: Create brings life; Destroy brings - # death; List passively observes. - # - # Commands are invoked by replaying (or rewinding) the generator's - # manifest of actions. See Rails::Generator::Manifest and - # Rails::Generator::Base#manifest method that generator subclasses - # are required to override. - # - # Commands allows generators to "plug in" invocation behavior, which - # corresponds to the GoF Strategy pattern. - class Base < DelegateClass(Rails::Generator::Base) - # Replay action manifest. RewindBase subclass rewinds manifest. - def invoke! - manifest.replay(self) - after_generate - end - - def dependency(generator_name, args, runtime_options = {}) - logger.dependency(generator_name) do - self.class.new(instance(generator_name, args, full_options(runtime_options))).invoke! - end - end - - # Does nothing for all commands except Create. - def class_collisions(*class_names) - end - - # Does nothing for all commands except Create. - def readme(*args) - end - - protected - def current_migration_number - Dir.glob("#{RAILS_ROOT}/#{@migration_directory}/[0-9]*_*.rb").inject(0) do |max, file_path| - n = File.basename(file_path).split('_', 2).first.to_i - if n > max then n else max end - end - end - - def next_migration_number - current_migration_number + 1 - end - - def migration_directory(relative_path) - directory(@migration_directory = relative_path) - end - - def existing_migrations(file_name) - Dir.glob("#{@migration_directory}/[0-9]*_*.rb").grep(/[0-9]+_#{file_name}.rb$/) - end - - def migration_exists?(file_name) - not existing_migrations(file_name).empty? - end - - def next_migration_string(padding = 3) - if ActiveRecord::Base.timestamped_migrations - Time.now.utc.strftime("%Y%m%d%H%M%S") - else - "%.#{padding}d" % next_migration_number - end - end - - def gsub_file(relative_destination, regexp, *args, &block) - path = destination_path(relative_destination) - content = File.read(path).gsub(regexp, *args, &block) - File.open(path, 'wb') { |file| file.write(content) } - end - - private - # Ask the user interactively whether to force collision. - def force_file_collision?(destination, src, dst, file_options = {}, &block) - $stdout.print "overwrite #{destination}? (enter \"h\" for help) [Ynaqdh] " - case $stdin.gets.chomp - when /\Ad\z/i - Tempfile.open(File.basename(destination), File.dirname(dst)) do |temp| - temp.write render_file(src, file_options, &block) - temp.rewind - $stdout.puts `#{diff_cmd} "#{dst}" "#{temp.path}"` - end - puts "retrying" - raise 'retry diff' - when /\Aa\z/i - $stdout.puts "forcing #{spec.name}" - options[:collision] = :force - when /\Aq\z/i - $stdout.puts "aborting #{spec.name}" - raise SystemExit - when /\An\z/i then :skip - when /\Ay\z/i then :force - else - $stdout.puts <<-HELP -Y - yes, overwrite -n - no, do not overwrite -a - all, overwrite this and all others -q - quit, abort -d - diff, show the differences between the old and the new -h - help, show this help -HELP - raise 'retry' - end - rescue - retry - end - - def diff_cmd - ENV['RAILS_DIFF'] || 'diff -u' - end - - def render_template_part(template_options) - # Getting Sandbox to evaluate part template in it - part_binding = template_options[:sandbox].call.sandbox_binding - part_rel_path = template_options[:insert] - part_path = source_path(part_rel_path) - - # Render inner template within Sandbox binding - rendered_part = ERB.new(File.readlines(part_path).join, nil, '-').result(part_binding) - begin_mark = template_part_mark(template_options[:begin_mark], template_options[:mark_id]) - end_mark = template_part_mark(template_options[:end_mark], template_options[:mark_id]) - begin_mark + rendered_part + end_mark - end - - def template_part_mark(name, id) - "<!--[#{name}:#{id}]-->\n" - end - end - - # Base class for commands which handle generator actions in reverse, such as Destroy. - class RewindBase < Base - # Rewind action manifest. - def invoke! - manifest.rewind(self) - end - end - - - # Create is the premier generator command. It copies files, creates - # directories, renders templates, and more. - class Create < Base - - # Check whether the given class names are already taken by - # Ruby or Rails. In the future, expand to check other namespaces - # such as the rest of the user's app. - def class_collisions(*class_names) - path = class_names.shift - class_names.flatten.each do |class_name| - # Convert to string to allow symbol arguments. - class_name = class_name.to_s - - # Skip empty strings. - next if class_name.strip.empty? - - # Split the class from its module nesting. - nesting = class_name.split('::') - name = nesting.pop - - # Hack to limit const_defined? to non-inherited on 1.9. - extra = [] - extra << false unless Object.method(:const_defined?).arity == 1 - - # Extract the last Module in the nesting. - last = nesting.inject(Object) { |last, nest| - break unless last.const_defined?(nest, *extra) - last.const_get(nest) - } - - # If the last Module exists, check whether the given - # class exists and raise a collision if so. - if last and last.const_defined?(name.camelize, *extra) - raise_class_collision(class_name) - end - end - end - - # Copy a file from source to destination with collision checking. - # - # The file_options hash accepts :chmod and :shebang and :collision options. - # :chmod sets the permissions of the destination file: - # file 'config/empty.log', 'log/test.log', :chmod => 0664 - # :shebang sets the #!/usr/bin/ruby line for scripts - # file 'bin/generate.rb', 'script/generate', :chmod => 0755, :shebang => '/usr/bin/env ruby' - # :collision sets the collision option only for the destination file: - # file 'settings/server.yml', 'config/server.yml', :collision => :skip - # - # Collisions are handled by checking whether the destination file - # exists and either skipping the file, forcing overwrite, or asking - # the user what to do. - def file(relative_source, relative_destination, file_options = {}, &block) - # Determine full paths for source and destination files. - source = source_path(relative_source) - destination = destination_path(relative_destination) - destination_exists = File.exist?(destination) - - # If source and destination are identical then we're done. - if destination_exists and identical?(source, destination, &block) - return logger.identical(relative_destination) - end - - # Check for and resolve file collisions. - if destination_exists - - # Make a choice whether to overwrite the file. :force and - # :skip already have their mind made up, but give :ask a shot. - choice = case (file_options[:collision] || options[:collision]).to_sym #|| :ask - when :ask then force_file_collision?(relative_destination, source, destination, file_options, &block) - when :force then :force - when :skip then :skip - else raise "Invalid collision option: #{options[:collision].inspect}" - end - - # Take action based on our choice. Bail out if we chose to - # skip the file; otherwise, log our transgression and continue. - case choice - when :force then logger.force(relative_destination) - when :skip then return(logger.skip(relative_destination)) - else raise "Invalid collision choice: #{choice}.inspect" - end - - # File doesn't exist so log its unbesmirched creation. - else - logger.create relative_destination - end - - # If we're pretending, back off now. - return if options[:pretend] - - # Write destination file with optional shebang. Yield for content - # if block given so templaters may render the source file. If a - # shebang is requested, replace the existing shebang or insert a - # new one. - File.open(destination, 'wb') do |dest| - dest.write render_file(source, file_options, &block) - end - - # Optionally change permissions. - if file_options[:chmod] - FileUtils.chmod(file_options[:chmod], destination) - end - - # Optionally add file to subversion or git - system("svn add #{destination}") if options[:svn] - system("git add -v #{relative_destination}") if options[:git] - end - - # Checks if the source and the destination file are identical. If - # passed a block then the source file is a template that needs to first - # be evaluated before being compared to the destination. - def identical?(source, destination, &block) - return false if File.directory? destination - source = block_given? ? File.open(source) {|sf| yield(sf)} : IO.read(source) - destination = IO.read(destination) - source == destination - end - - # Generate a file for a Rails application using an ERuby template. - # Looks up and evaluates a template by name and writes the result. - # - # The ERB template uses explicit trim mode to best control the - # proliferation of whitespace in generated code. <%- trims leading - # whitespace; -%> trims trailing whitespace including one newline. - # - # A hash of template options may be passed as the last argument. - # The options accepted by the file are accepted as well as :assigns, - # a hash of variable bindings. Example: - # template 'foo', 'bar', :assigns => { :action => 'view' } - # - # Template is implemented in terms of file. It calls file with a - # block which takes a file handle and returns its rendered contents. - def template(relative_source, relative_destination, template_options = {}) - file(relative_source, relative_destination, template_options) do |file| - # Evaluate any assignments in a temporary, throwaway binding. - vars = template_options[:assigns] || {} - b = template_options[:binding] || binding - vars.each { |k,v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b } - - # Render the source file with the temporary binding. - ERB.new(file.read, nil, '-').result(b) - end - end - - def complex_template(relative_source, relative_destination, template_options = {}) - options = template_options.dup - options[:assigns] ||= {} - options[:assigns]['template_for_inclusion'] = render_template_part(template_options) - template(relative_source, relative_destination, options) - end - - # Create a directory including any missing parent directories. - # Always skips directories which exist. - def directory(relative_path) - path = destination_path(relative_path) - if File.exist?(path) - logger.exists relative_path - else - logger.create relative_path - unless options[:pretend] - FileUtils.mkdir_p(path) - # git doesn't require adding the paths, adding the files later will - # automatically do a path add. - - # Subversion doesn't do path adds, so we need to add - # each directory individually. - # So stack up the directory tree and add the paths to - # subversion in order without recursion. - if options[:svn] - stack = [relative_path] - until File.dirname(stack.last) == stack.last # dirname('.') == '.' - stack.push File.dirname(stack.last) - end - stack.reverse_each do |rel_path| - svn_path = destination_path(rel_path) - system("svn add -N #{svn_path}") unless File.directory?(File.join(svn_path, '.svn')) - end - end - end - end - end - - # Display a README. - def readme(*relative_sources) - relative_sources.flatten.each do |relative_source| - logger.readme relative_source - puts File.read(source_path(relative_source)) unless options[:pretend] - end - end - - # When creating a migration, it knows to find the first available file in db/migrate and use the migration.rb template. - def migration_template(relative_source, relative_destination, template_options = {}) - migration_directory relative_destination - migration_file_name = template_options[:migration_file_name] || file_name - raise "Another migration is already named #{migration_file_name}: #{existing_migrations(migration_file_name).first}" if migration_exists?(migration_file_name) - template(relative_source, "#{relative_destination}/#{next_migration_string}_#{migration_file_name}.rb", template_options) - end - - def route_resources(*resources) - resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') - sentinel = 'ActionController::Routing::Routes.draw do |map|' - - logger.route "map.resources #{resource_list}" - unless options[:pretend] - gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| - "#{match}\n map.resources #{resource_list}\n" - end - end - end - - private - def render_file(path, options = {}) - File.open(path, 'rb') do |file| - if block_given? - yield file - else - content = '' - if shebang = options[:shebang] - content << "#!#{shebang}\n" - if line = file.gets - content << "line\n" if line !~ /^#!/ - end - end - content << file.read - end - end - end - - # Raise a usage error with an informative WordNet suggestion. - # Thanks to Florian Gross (flgr). - def raise_class_collision(class_name) - message = <<end_message - The name '#{class_name}' is either already used in your application or reserved by Ruby on Rails. - Please choose an alternative and run this generator again. -end_message - if suggest = find_synonyms(class_name) - if suggest.any? - message << "\n Suggestions: \n\n" - message << suggest.join("\n") - end - end - raise UsageError, message - end - - SYNONYM_LOOKUP_URI = "http://wordnet.princeton.edu/perl/webwn?s=%s" - - # Look up synonyms on WordNet. Thanks to Florian Gross (flgr). - def find_synonyms(word) - require 'open-uri' - require 'timeout' - timeout(5) do - open(SYNONYM_LOOKUP_URI % word) do |stream| - # Grab words linked to dictionary entries as possible synonyms - data = stream.read.gsub("&nbsp;", " ").scan(/<a href="webwn.*?">([\w ]*?)<\/a>/s).uniq - end - end - rescue Exception - return nil - end - end - - - # Undo the actions performed by a generator. Rewind the action - # manifest and attempt to completely erase the results of each action. - class Destroy < RewindBase - # Remove a file if it exists and is a file. - def file(relative_source, relative_destination, file_options = {}) - destination = destination_path(relative_destination) - if File.exist?(destination) - logger.rm relative_destination - unless options[:pretend] - if options[:svn] - # If the file has been marked to be added - # but has not yet been checked in, revert and delete - if options[:svn][relative_destination] - system("svn revert #{destination}") - FileUtils.rm(destination) - else - # If the directory is not in the status list, it - # has no modifications so we can simply remove it - system("svn rm #{destination}") - end - elsif options[:git] - if options[:git][:new][relative_destination] - # file has been added, but not committed - system("git reset HEAD #{relative_destination}") - FileUtils.rm(destination) - elsif options[:git][:modified][relative_destination] - # file is committed and modified - system("git rm -f #{relative_destination}") - else - # If the directory is not in the status list, it - # has no modifications so we can simply remove it - system("git rm #{relative_destination}") - end - else - FileUtils.rm(destination) - end - end - else - logger.missing relative_destination - return - end - end - - # Templates are deleted just like files and the actions take the - # same parameters, so simply alias the file method. - alias_method :template, :file - - # Remove each directory in the given path from right to left. - # Remove each subdirectory if it exists and is a directory. - def directory(relative_path) - parts = relative_path.split('/') - until parts.empty? - partial = File.join(parts) - path = destination_path(partial) - if File.exist?(path) - if Dir[File.join(path, '*')].empty? - logger.rmdir partial - unless options[:pretend] - if options[:svn] - # If the directory has been marked to be added - # but has not yet been checked in, revert and delete - if options[:svn][relative_path] - system("svn revert #{path}") - FileUtils.rmdir(path) - else - # If the directory is not in the status list, it - # has no modifications so we can simply remove it - system("svn rm #{path}") - end - # I don't think git needs to remove directories?.. - # or maybe they have special consideration... - else - FileUtils.rmdir(path) - end - end - else - logger.notempty partial - end - else - logger.missing partial - end - parts.pop - end - end - - def complex_template(*args) - # nothing should be done here - end - - # When deleting a migration, it knows to delete every file named "[0-9]*_#{file_name}". - def migration_template(relative_source, relative_destination, template_options = {}) - migration_directory relative_destination - - migration_file_name = template_options[:migration_file_name] || file_name - unless migration_exists?(migration_file_name) - puts "There is no migration named #{migration_file_name}" - return - end - - - existing_migrations(migration_file_name).each do |file_path| - file(relative_source, file_path, template_options) - end - end - - def route_resources(*resources) - resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') - look_for = "\n map.resources #{resource_list}\n" - logger.route "map.resources #{resource_list}" - gsub_file 'config/routes.rb', /(#{look_for})/mi, '' - end - end - - - # List a generator's action manifest. - class List < Base - def dependency(generator_name, args, options = {}) - logger.dependency "#{generator_name}(#{args.join(', ')}, #{options.inspect})" - end - - def class_collisions(*class_names) - logger.class_collisions class_names.join(', ') - end - - def file(relative_source, relative_destination, options = {}) - logger.file relative_destination - end - - def template(relative_source, relative_destination, options = {}) - logger.template relative_destination - end - - def complex_template(relative_source, relative_destination, options = {}) - logger.template "#{options[:insert]} inside #{relative_destination}" - end - - def directory(relative_path) - logger.directory "#{destination_path(relative_path)}/" - end - - def readme(*args) - logger.readme args.join(', ') - end - - def migration_template(relative_source, relative_destination, options = {}) - migration_directory relative_destination - logger.migration_template file_name - end - - def route_resources(*resources) - resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') - logger.route "map.resources #{resource_list}" - end - end - - # Update generator's action manifest. - class Update < Create - def file(relative_source, relative_destination, options = {}) - # logger.file relative_destination - end - - def template(relative_source, relative_destination, options = {}) - # logger.template relative_destination - end - - def complex_template(relative_source, relative_destination, template_options = {}) - - begin - dest_file = destination_path(relative_destination) - source_to_update = File.readlines(dest_file).join - rescue Errno::ENOENT - logger.missing relative_destination - return - end - - logger.refreshing "#{template_options[:insert].gsub(/\.erb/,'')} inside #{relative_destination}" - - begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id])) - end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id])) - - # Refreshing inner part of the template with freshly rendered part. - rendered_part = render_template_part(template_options) - source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part) - - File.open(dest_file, 'w') { |file| file.write(source_to_update) } - end - - def directory(relative_path) - # logger.directory "#{destination_path(relative_path)}/" - end - end - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generated_attribute.rb b/vendor/rails/railties/lib/rails_generator/generated_attribute.rb deleted file mode 100644 index 81c3bfd2..00000000 --- a/vendor/rails/railties/lib/rails_generator/generated_attribute.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'optparse' - -module Rails - module Generator - class GeneratedAttribute - attr_accessor :name, :type, :column - - def initialize(name, type) - @name, @type = name, type.to_sym - @column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type) - end - - def field_type - @field_type ||= case type - when :integer, :float, :decimal then :text_field - when :time then :time_select - when :datetime, :timestamp then :datetime_select - when :date then :date_select - when :string then :text_field - when :text then :text_area - when :boolean then :check_box - else - :text_field - end - end - - def default - @default ||= case type - when :integer then 1 - when :float then 1.5 - when :decimal then "9.99" - when :datetime, :timestamp, :time then Time.now.to_s(:db) - when :date then Date.today.to_s(:db) - when :string then "MyString" - when :text then "MyText" - when :boolean then false - else - "" - end - end - - def reference? - [ :references, :belongs_to ].include?(self.type) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE b/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE deleted file mode 100644 index 36d6061a..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE +++ /dev/null @@ -1,9 +0,0 @@ -Description: - The 'rails' command creates a new Rails application with a default - directory structure and configuration at the path you specify. - -Example: - rails ~/Code/Ruby/weblog - - This generates a skeletal Rails installation in ~/Code/Ruby/weblog. - See the README in the newly created application to get going. diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb deleted file mode 100644 index 0b67eef5..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ /dev/null @@ -1,266 +0,0 @@ -require 'rbconfig' -require File.dirname(__FILE__) + '/template_runner' -require 'digest/md5' -require 'active_support/secure_random' - -class AppGenerator < Rails::Generator::Base - DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - - DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 frontbase ibm_db ) - DEFAULT_DATABASE = 'sqlite3' - - mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.." - default_options :db => (ENV["RAILS_DEFAULT_DATABASE"] || DEFAULT_DATABASE), - :shebang => DEFAULT_SHEBANG, :with_dispatchers => false, :freeze => false - - - def initialize(runtime_args, runtime_options = {}) - super - - usage if args.empty? - usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db])) - - @destination_root = args.shift - @app_name = File.basename(File.expand_path(@destination_root)) - end - - def manifest - record do |m| - create_directories(m) - create_root_files(m) - create_app_files(m) - create_config_files(m) - create_script_files(m) - create_test_files(m) - create_public_files(m) - create_documentation_file(m) - create_log_files(m) - end - end - - def after_generate - if options[:template] - Rails::TemplateRunner.new(options[:template], @destination_root) - end - end - - protected - def banner - "Usage: #{$0} /path/to/your/app [options]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("-r", "--ruby=path", String, - "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).", - "Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v } - - opt.on("-d", "--database=name", String, - "Preconfigure for selected database (options: #{DATABASES.join('/')}).", - "Default: #{DEFAULT_DATABASE}") { |v| options[:db] = v } - - opt.on("-D", "--with-dispatchers", - "Add CGI/FastCGI/mod_ruby dispatches code to generated application skeleton", - "Default: false") { |v| options[:with_dispatchers] = v } - - opt.on("-f", "--freeze", - "Freeze Rails in vendor/rails from the gems generating the skeleton", - "Default: false") { |v| options[:freeze] = v } - - opt.on("-m", "--template=path", String, - "Use an application template that lives at path (can be a filesystem path or URL).", - "Default: (none)") { |v| options[:template] = v } - - end - - - private - def create_directories(m) - m.directory '' - - # Intermediate directories are automatically created so don't sweat their absence here. - %w( - app/controllers - app/helpers - app/models - app/views/layouts - config/environments - config/initializers - config/locales - db - doc - lib - lib/tasks - log - public/images - public/javascripts - public/stylesheets - script/performance - test/fixtures - test/functional - test/integration - test/performance - test/unit - vendor - vendor/plugins - tmp/sessions - tmp/sockets - tmp/cache - tmp/pids - ).each { |path| m.directory(path) } - end - - def create_root_files(m) - m.file "fresh_rakefile", "Rakefile" - m.file "README", "README" - end - - def create_app_files(m) - m.file "helpers/application_controller.rb", "app/controllers/application_controller.rb" - m.file "helpers/application_helper.rb", "app/helpers/application_helper.rb" - end - - def create_config_files(m) - create_database_configuration_file(m) - create_routes_file(m) - create_locale_file(m) - create_seeds_file(m) - create_initializer_files(m) - create_environment_files(m) - end - - def create_documentation_file(m) - m.file "doc/README_FOR_APP", "doc/README_FOR_APP" - end - - def create_log_files(m) - %w( server production development test ).each do |file| - m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666 - end - end - - def create_public_files(m) - create_dispatch_files(m) - create_error_files(m) - create_welcome_file(m) - create_browser_convention_files(m) - create_rails_image(m) - create_javascript_files(m) - end - - def create_script_files(m) - %w( - about console dbconsole destroy generate runner server plugin - performance/benchmarker performance/profiler - ).each do |file| - m.file "bin/#{file}", "script/#{file}", { - :chmod => 0755, - :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] - } - end - end - - def create_test_files(m) - m.file "helpers/test_helper.rb", "test/test_helper.rb" - m.file "helpers/performance_test.rb", "test/performance/browsing_test.rb" - end - - - def create_database_configuration_file(m) - m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => { - :app_name => @app_name, - :socket => options[:db] == "mysql" ? mysql_socket_location : nil } - end - - def create_routes_file(m) - m.file "configs/routes.rb", "config/routes.rb" - end - - def create_seeds_file(m) - m.file "configs/seeds.rb", "db/seeds.rb" - end - - def create_initializer_files(m) - %w( - backtrace_silencers - inflections - mime_types - new_rails_defaults - ).each do |initializer| - m.file "configs/initializers/#{initializer}.rb", "config/initializers/#{initializer}.rb" - end - - m.template "configs/initializers/session_store.rb", "config/initializers/session_store.rb", - :assigns => { :app_name => @app_name, :app_secret => ActiveSupport::SecureRandom.hex(64) } - - m.template "configs/initializers/cookie_verification_secret.rb", "config/initializers/cookie_verification_secret.rb", - :assigns => { :app_secret => ActiveSupport::SecureRandom.hex(64) } - end - - def create_locale_file(m) - m.file "configs/locales/en.yml", "config/locales/en.yml" - end - - def create_environment_files(m) - m.template "environments/environment.rb", "config/environment.rb", - :assigns => { :freeze => options[:freeze] } - - m.file "environments/boot.rb", "config/boot.rb" - m.file "environments/production.rb", "config/environments/production.rb" - m.file "environments/development.rb", "config/environments/development.rb" - m.file "environments/test.rb", "config/environments/test.rb" - end - - - def create_dispatch_files(m) - if options[:with_dispatchers] - dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] } - - m.file "dispatches/config.ru", "config.ru" - m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options - m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options - m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options - end - end - - def create_error_files(m) - %w( 404 422 500 ).each do |file| - m.file "html/#{file}.html", "public/#{file}.html" - end - end - - def create_welcome_file(m) - m.file 'html/index.html', 'public/index.html' - end - - def create_browser_convention_files(m) - m.file "html/favicon.ico", "public/favicon.ico" - m.file "html/robots.txt", "public/robots.txt" - end - - def create_rails_image(m) - m.file "html/images/rails.png", "public/images/rails.png" - end - - def create_javascript_files(m) - %w( prototype effects dragdrop controls application ).each do |javascript| - m.file "html/javascripts/#{javascript}.js", "public/javascripts/#{javascript}.js" - end - end - - - def mysql_socket_location - [ - "/tmp/mysql.sock", # default - "/var/run/mysqld/mysqld.sock", # debian/gentoo - "/var/tmp/mysql.sock", # freebsd - "/var/lib/mysql/mysql.sock", # fedora - "/opt/local/lib/mysql/mysql.sock", # fedora - "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql - "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4 - "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5 - "/opt/lampp/var/mysql/mysql.sock" # xampp for linux - ].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/git.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/git.rb deleted file mode 100644 index a53494de..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/git.rb +++ /dev/null @@ -1,18 +0,0 @@ -STDOUT.sync = true - -module Rails - class Git < Scm - def self.clone(repos, branch=nil) - system "git clone #{repos}" - - if branch - system "cd #{repos.split('/').last}/" - system "git checkout #{branch}" - end - end - - def self.run(command) - system "git #{command}" - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/scm.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/scm.rb deleted file mode 100644 index f6c08cad..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/scm.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Rails - class Scm - private - def self.hash_to_parameters(hash) - hash.collect { |key, value| "--#{key} #{(value.kind_of?(String) ? value : "")}"}.join(" ") - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/svn.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/svn.rb deleted file mode 100644 index 22b5966d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/svn.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Rails - class Svn < Scm - def self.checkout(repos, branch = nil) - `svn checkout #{repos}/#{branch || "trunk"}` - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb deleted file mode 100644 index 40f21cc4..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb +++ /dev/null @@ -1,401 +0,0 @@ -require File.dirname(__FILE__) + '/scm/scm' -require File.dirname(__FILE__) + '/scm/git' -require File.dirname(__FILE__) + '/scm/svn' - -require 'open-uri' -require 'fileutils' - -module Rails - class TemplateRunner - attr_reader :root - attr_writer :logger - - def initialize(template, root = '') # :nodoc: - @root = File.expand_path(File.directory?(root) ? root : File.join(Dir.pwd, root)) - - log 'applying', "template: #{template}" - - load_template(template) - - log 'applied', "#{template}" - end - - def load_template(template) - begin - code = open(template).read - in_root { self.instance_eval(code) } - rescue LoadError, Errno::ENOENT => e - raise "The template [#{template}] could not be loaded. Error: #{e}" - end - end - - # Create a new file in the Rails project folder. Specify the - # relative path from RAILS_ROOT. Data is the return value of a block - # or a data string. - # - # ==== Examples - # - # file("lib/fun_party.rb") do - # hostname = ask("What is the virtual hostname I should use?") - # "vhost.name = #{hostname}" - # end - # - # file("config/apach.conf", "your apache config") - # - def file(filename, data = nil, log_action = true, &block) - log 'file', filename if log_action - dir, file = [File.dirname(filename), File.basename(filename)] - - inside(dir) do - File.open(file, "w") do |f| - if block_given? - f.write(block.call) - else - f.write(data) - end - end - end - end - - # Install a plugin. You must provide either a Subversion url or Git url. - # For a Git-hosted plugin, you can specify if it should be added as a submodule instead of cloned. - # - # ==== Examples - # - # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git' - # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true - # plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk' - # - def plugin(name, options) - log 'plugin', name - - if options[:git] && options[:submodule] - in_root do - Git.run("submodule add #{options[:git]} vendor/plugins/#{name}") - end - elsif options[:git] || options[:svn] - in_root do - run_ruby_script("script/plugin install #{options[:svn] || options[:git]}", false) - end - else - log "! no git or svn provided for #{name}. skipping..." - end - end - - # Adds an entry into config/environment.rb for the supplied gem : - def gem(name, options = {}) - log 'gem', name - env = options.delete(:env) - - gems_code = "config.gem '#{name}'" - - if options.any? - opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"',"'")}"] }.sort.join(", ") - gems_code << ", #{opts}" - end - - environment gems_code, :env => env - end - - # Adds a line inside the Initializer block for config/environment.rb. Used by #gem - # If options :env is specified, the line is appended to the corresponding - # file in config/environments/#{env}.rb - def environment(data = nil, options = {}, &block) - sentinel = 'Rails::Initializer.run do |config|' - - data = block.call if !data && block_given? - - in_root do - if options[:env].nil? - gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match| - "#{match}\n " << data - end - else - Array.wrap(options[:env]).each do|env| - append_file "config/environments/#{env}.rb", "\n#{data}" - end - end - end - end - - # Run a command in git. - # - # ==== Examples - # - # git :init - # git :add => "this.file that.rb" - # git :add => "onefile.rb", :rm => "badfile.cxx" - # - def git(command = {}) - in_root do - if command.is_a?(Symbol) - log 'running', "git #{command}" - Git.run(command.to_s) - else - command.each do |command, options| - log 'running', "git #{command} #{options}" - Git.run("#{command} #{options}") - end - end - end - end - - # Create a new file in the vendor/ directory. Code can be specified - # in a block or a data string can be given. - # - # ==== Examples - # - # vendor("sekrit.rb") do - # sekrit_salt = "#{Time.now}--#{3.years.ago}--#{rand}--" - # "salt = '#{sekrit_salt}'" - # end - # - # vendor("foreign.rb", "# Foreign code is fun") - # - def vendor(filename, data = nil, &block) - log 'vendoring', filename - file("vendor/#{filename}", data, false, &block) - end - - # Create a new file in the lib/ directory. Code can be specified - # in a block or a data string can be given. - # - # ==== Examples - # - # lib("crypto.rb") do - # "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'" - # end - # - # lib("foreign.rb", "# Foreign code is fun") - # - def lib(filename, data = nil, &block) - log 'lib', filename - file("lib/#{filename}", data, false, &block) - end - - # Create a new Rakefile with the provided code (either in a block or a string). - # - # ==== Examples - # - # rakefile("bootstrap.rake") do - # project = ask("What is the UNIX name of your project?") - # - # <<-TASK - # namespace :#{project} do - # task :bootstrap do - # puts "i like boots!" - # end - # end - # TASK - # end - # - # rakefile("seed.rake", "puts 'im plantin ur seedz'") - # - def rakefile(filename, data = nil, &block) - log 'rakefile', filename - file("lib/tasks/#{filename}", data, false, &block) - end - - # Create a new initializer with the provided code (either in a block or a string). - # - # ==== Examples - # - # initializer("globals.rb") do - # data = "" - # - # ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do - # data << "#{const} = :entp" - # end - # - # data - # end - # - # initializer("api.rb", "API_KEY = '123456'") - # - def initializer(filename, data = nil, &block) - log 'initializer', filename - file("config/initializers/#{filename}", data, false, &block) - end - - # Generate something using a generator from Rails or a plugin. - # The second parameter is the argument string that is passed to - # the generator or an Array that is joined. - # - # ==== Example - # - # generate(:authenticated, "user session") - # - def generate(what, *args) - log 'generating', what - argument = args.map(&:to_s).flatten.join(" ") - - in_root { run_ruby_script("script/generate #{what} #{argument}", false) } - end - - # Executes a command - # - # ==== Example - # - # inside('vendor') do - # run('ln -s ~/edge rails') - # end - # - def run(command, log_action = true) - log 'executing', "#{command} from #{Dir.pwd}" if log_action - `#{command}` - end - - # Executes a ruby script (taking into account WIN32 platform quirks) - def run_ruby_script(command, log_action = true) - ruby_command = RUBY_PLATFORM=~ /win32/ ? 'ruby ' : '' - run("#{ruby_command}#{command}", log_action) - end - - # Runs the supplied rake task - # - # ==== Example - # - # rake("db:migrate") - # rake("db:migrate", :env => "production") - # rake("gems:install", :sudo => true) - # - def rake(command, options = {}) - log 'rake', command - env = options[:env] || 'development' - sudo = options[:sudo] ? 'sudo ' : '' - in_root { run("#{sudo}rake #{command} RAILS_ENV=#{env}", false) } - end - - # Just run the capify command in root - # - # ==== Example - # - # capify! - # - def capify! - log 'capifying' - in_root { run('capify .', false) } - end - - # Add Rails to /vendor/rails - # - # ==== Example - # - # freeze! - # - def freeze!(args = {}) - log 'vendor', 'rails edge' - in_root { run('rake rails:freeze:edge', false) } - end - - # Make an entry in Rails routing file conifg/routes.rb - # - # === Example - # - # route "map.root :controller => :welcome" - # - def route(routing_code) - log 'route', routing_code - sentinel = 'ActionController::Routing::Routes.draw do |map|' - - in_root do - gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| - "#{match}\n #{routing_code}\n" - end - end - end - - protected - - # Get a user's input - # - # ==== Example - # - # answer = ask("Should I freeze the latest Rails?") - # freeze! if ask("Should I freeze the latest Rails?") == "yes" - # - def ask(string) - log '', string - STDIN.gets.strip - end - - # Do something in the root of the Rails application or - # a provided subfolder; the full path is yielded to the block you provide. - # The path is set back to the previous path when the method exits. - def inside(dir = '', &block) - folder = File.join(root, dir) - FileUtils.mkdir_p(folder) unless File.exist?(folder) - FileUtils.cd(folder) { block.arity == 1 ? yield(folder) : yield } - end - - def in_root - FileUtils.cd(root) { yield } - end - - # Helper to test if the user says yes(y)? - # - # ==== Example - # - # freeze! if yes?("Should I freeze the latest Rails?") - # - def yes?(question) - answer = ask(question).downcase - answer == "y" || answer == "yes" - end - - # Helper to test if the user does NOT say yes(y)? - # - # ==== Example - # - # capify! if no?("Will you be using vlad to deploy your application?") - # - def no?(question) - !yes?(question) - end - - # Run a regular expression replacement on a file - # - # ==== Example - # - # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' - # - def gsub_file(relative_destination, regexp, *args, &block) - path = destination_path(relative_destination) - content = File.read(path).gsub(regexp, *args, &block) - File.open(path, 'wb') { |file| file.write(content) } - end - - # Append text to a file - # - # ==== Example - # - # append_file 'config/environments/test.rb', 'config.gem "rspec"' - # - def append_file(relative_destination, data) - path = destination_path(relative_destination) - File.open(path, 'ab') { |file| file.write(data) } - end - - def destination_path(relative_destination) - File.join(root, relative_destination) - end - - def log(action, message = '') - logger.log(action, message) - end - - def logger - @logger ||= Rails::Generator::Base.logger - end - - def logger - @logger ||= if defined?(Rails::Generator::Base) - Rails::Generator::Base.logger - else - require 'rails_generator/simple_logger' - Rails::Generator::SimpleLogger.new(STDOUT) - end - end - - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE deleted file mode 100644 index 362872e8..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE +++ /dev/null @@ -1,30 +0,0 @@ -Description: - Stubs out a new controller and its views. Pass the controller name, either - CamelCased or under_scored, and a list of views as arguments. - - To create a controller within a module, specify the controller name as a - path like 'parent_module/controller_name'. - - This generates a controller class in app/controllers, view templates in - app/views/controller_name, a helper class in app/helpers, a functional - test suite in test/functional and a helper test suite in test/unit/helpers. - -Example: - `./script/generate controller CreditCard open debit credit close` - - Credit card controller with URLs like /credit_card/debit. - Controller: app/controllers/credit_card_controller.rb - Functional Test: test/functional/credit_card_controller_test.rb - Views: app/views/credit_card/debit.html.erb [...] - Helper: app/helpers/credit_card_helper.rb - Helper Test: test/unit/helpers/credit_card_helper_test.rb - -Modules Example: - `./script/generate controller 'admin/credit_card' suspend late_fee` - - Credit card admin controller with URLs /admin/credit_card/suspend. - Controller: app/controllers/admin/credit_card_controller.rb - Functional Test: test/functional/admin/credit_card_controller_test.rb - Views: app/views/admin/credit_card/debit.html.erb [...] - Helper: app/helpers/admin/credit_card_helper.rb - Helper Test: test/unit/helpers/admin/credit_card_helper_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb deleted file mode 100644 index dc126e8a..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb +++ /dev/null @@ -1,43 +0,0 @@ -class ControllerGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper", "#{class_name}HelperTest" - - # Controller, helper, views, and test directories. - m.directory File.join('app/controllers', class_path) - m.directory File.join('app/helpers', class_path) - m.directory File.join('app/views', class_path, file_name) - m.directory File.join('test/functional', class_path) - m.directory File.join('test/unit/helpers', class_path) - - # Controller class, functional test, and helper class. - m.template 'controller.rb', - File.join('app/controllers', - class_path, - "#{file_name}_controller.rb") - - m.template 'functional_test.rb', - File.join('test/functional', - class_path, - "#{file_name}_controller_test.rb") - - m.template 'helper.rb', - File.join('app/helpers', - class_path, - "#{file_name}_helper.rb") - - m.template 'helper_test.rb', - File.join('test/unit/helpers', - class_path, - "#{file_name}_helper_test.rb") - - # View template for each action. - actions.each do |action| - path = File.join('app/views', class_path, file_name, "#{action}.html.erb") - m.template 'view.html.erb', path, - :assigns => { :action => action, :path => path } - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb deleted file mode 100644 index cda2659e..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class <%= class_name %>Controller < ApplicationController -<% for action in actions -%> - def <%= action %> - end - -<% end -%> -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb deleted file mode 100644 index 62fa5d86..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>ControllerTest < ActionController::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb deleted file mode 100644 index 3fe2ecdc..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper_test.rb deleted file mode 100644 index 591e4090..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb deleted file mode 100644 index ad85431f..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<h1><%= class_name %>#<%= action %></h1> -<p>Find me in <%= path %></p> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/helper/USAGE deleted file mode 100644 index ef27ca61..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/USAGE +++ /dev/null @@ -1,24 +0,0 @@ -Description: - Stubs out a new helper. Pass the helper name, either - CamelCased or under_scored. - - To create a helper within a module, specify the helper name as a - path like 'parent_module/helper_name'. - - This generates a helper class in app/helpers and a helper test - suite in test/unit/helpers. - -Example: - `./script/generate helper CreditCard` - - Credit card helper. - Helper: app/helpers/credit_card_helper.rb - Test: test/unit/helpers/credit_card_helper_test.rb - -Modules Example: - `./script/generate helper 'admin/credit_card'` - - Credit card admin helper. - Helper: app/helpers/admin/credit_card_helper.rb - Test: test/unit/helpers/admin/credit_card_helper_test.rb - diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/helper_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/helper/helper_generator.rb deleted file mode 100644 index f7831f7c..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/helper_generator.rb +++ /dev/null @@ -1,25 +0,0 @@ -class HelperGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_path, "#{class_name}Helper", "#{class_name}HelperTest" - - # Helper and helper test directories. - m.directory File.join('app/helpers', class_path) - m.directory File.join('test/unit/helpers', class_path) - - # Helper and helper test class. - - m.template 'helper.rb', - File.join('app/helpers', - class_path, - "#{file_name}_helper.rb") - - m.template 'helper_test.rb', - File.join('test/unit/helpers', - class_path, - "#{file_name}_helper_test.rb") - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper.rb deleted file mode 100644 index 3fe2ecdc..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper_test.rb deleted file mode 100644 index 591e4090..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE deleted file mode 100644 index 09e2691f..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Stubs out a new integration test. Pass the name of the test, either - CamelCased or under_scored, as an argument. The new test class is - generated in test/integration/testname_test.rb - -Example: - `./script/generate integration_test GeneralStories` creates a GeneralStories - integration test in test/integration/general_stories_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb deleted file mode 100644 index 44323f28..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -class IntegrationTestGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # integration test directory - m.directory File.join('test/integration', class_path) - - # integration test stub - m.template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb deleted file mode 100644 index 2c57158b..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionController::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE deleted file mode 100644 index 61a649ed..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE +++ /dev/null @@ -1,16 +0,0 @@ -Description: - Stubs out a new mailer and its views. Pass the mailer name, either - CamelCased or under_scored, and an optional list of emails as arguments. - - This generates a mailer class in app/models, view templates in - app/views/mailer_name, a unit test in test/unit, and fixtures in - test/fixtures. - -Example: - `./script/generate mailer Notifications signup forgot_password invoice` - - creates a Notifications mailer class, views, test, and fixtures: - Mailer: app/models/notifications.rb - Views: app/views/notifications/signup.erb [...] - Test: test/unit/test/unit/notifications_test.rb - Fixtures: test/fixtures/notifications/signup [...] diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb deleted file mode 100644 index ba6d60ca..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb +++ /dev/null @@ -1,30 +0,0 @@ -class MailerGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # Mailer, view, test, and fixture directories. - m.directory File.join('app/models', class_path) - m.directory File.join('app/views', file_path) - m.directory File.join('test/unit', class_path) - m.directory File.join('test/fixtures', file_path) - - # Mailer class and unit test. - m.template "mailer.rb", File.join('app/models', class_path, "#{file_name}.rb") - m.template "unit_test.rb", File.join('test/unit', class_path, "#{file_name}_test.rb") - - # View template and fixture for each action. - actions.each do |action| - relative_path = File.join(file_path, action) - view_path = File.join('app/views', "#{relative_path}.erb") - fixture_path = File.join('test/fixtures', relative_path) - - m.template "view.erb", view_path, - :assigns => { :action => action, :path => view_path } - m.template "fixture.erb", fixture_path, - :assigns => { :action => action, :path => view_path } - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb deleted file mode 100644 index 6899257d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= class_name %>#<%= action %> - -Find me in <%= path %> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb deleted file mode 100644 index ce15ae9d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb +++ /dev/null @@ -1,15 +0,0 @@ -class <%= class_name %> < ActionMailer::Base - -<% for action in actions -%> - - def <%= action %>(sent_at = Time.now) - subject '<%= class_name %>#<%= action %>' - recipients '' - from '' - sent_on sent_at - - body :greeting => 'Hi,' - end -<% end -%> - -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb deleted file mode 100644 index 4de94076..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionMailer::TestCase -<% for action in actions -%> - test "<%= action %>" do - @expected.subject = '<%= class_name %>#<%= action %>' - @expected.body = read_fixture('<%= action %>') - @expected.date = Time.now - - assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded - end - -<% end -%> -<% if actions.blank? -%> - # replace this with your real tests - test "the truth" do - assert true - end -<% end -%> -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb deleted file mode 100644 index 6899257d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= class_name %>#<%= action %> - -Find me in <%= path %> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/metal/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/metal/USAGE deleted file mode 100644 index 123ec6c0..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/metal/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Cast some metal! - -Examples: - `./script/generate metal poller` - - This will create: - Metal: app/metal/poller.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/metal/metal_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/metal/metal_generator.rb deleted file mode 100644 index 64f49d92..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/metal/metal_generator.rb +++ /dev/null @@ -1,8 +0,0 @@ -class MetalGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - m.directory 'app/metal' - m.template 'metal.rb', File.join('app/metal', "#{file_name}.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/metal/templates/metal.rb b/vendor/rails/railties/lib/rails_generator/generators/components/metal/templates/metal.rb deleted file mode 100644 index e94982b6..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/metal/templates/metal.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Allow the metal piece to run in isolation -require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) - -class <%= class_name %> - def self.call(env) - if env["PATH_INFO"] =~ /^\/<%= file_name %>/ - [200, {"Content-Type" => "text/html"}, ["Hello, World!"]] - else - [404, {"Content-Type" => "text/html"}, ["Not Found"]] - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE deleted file mode 100644 index b83c6579..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE +++ /dev/null @@ -1,29 +0,0 @@ -Description: - Stubs out a new database migration. Pass the migration name, either - CamelCased or under_scored, and an optional list of attribute pairs as arguments. - - A migration class is generated in db/migrate prefixed by a timestamp of the current date and time. - - You can name your migration in either of these formats to generate add/remove - column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable - -Example: - `./script/generate migration AddSslFlag` - - If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration - db/migrate/20080514090912_add_ssl_flag.rb - - `./script/generate migration AddTitleBodyToPost title:string body:text published:boolean` - - This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with - this in the Up migration: - - add_column :posts, :title, :string - add_column :posts, :body, :text - add_column :posts, :published, :boolean - - And this in the Down migration: - - remove_column :posts, :published - remove_column :posts, :body - remove_column :posts, :title diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb deleted file mode 100644 index 9a40c5d3..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb +++ /dev/null @@ -1,20 +0,0 @@ -class MigrationGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - m.migration_template 'migration.rb', 'db/migrate', :assigns => get_local_assigns - end - end - - - private - def get_local_assigns - {}.tap do |assigns| - if class_name.underscore =~ /^(add|remove)_.*_(?:to|from)_(.*)/ - assigns[:migration_action] = $1 - assigns[:table_name] = $2.pluralize - else - assigns[:attributes] = [] - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb deleted file mode 100644 index ca35a432..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb +++ /dev/null @@ -1,11 +0,0 @@ -class <%= class_name.underscore.camelize %> < ActiveRecord::Migration - def self.up<% attributes.each do |attribute| %> - <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%> - <%- end %> - end - - def self.down<% attributes.reverse.each do |attribute| %> - <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%> - <%- end %> - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE deleted file mode 100644 index 24b03b4d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE +++ /dev/null @@ -1,27 +0,0 @@ -Description: - Stubs out a new model. Pass the model name, either CamelCased or - under_scored, and an optional list of attribute pairs as arguments. - - Attribute pairs are column_name:sql_type arguments specifying the - model's attributes. Timestamps are added by default, so you don't have to - specify them by hand as 'created_at:datetime updated_at:datetime'. - - You don't have to think up every attribute up front, but it helps to - sketch out a few so you can start working with the model immediately. - - This generates a model class in app/models, a unit test in test/unit, - a test fixture in test/fixtures/singular_name.yml, and a migration in - db/migrate. - -Examples: - `./script/generate model account` - - creates an Account model, test, fixture, and migration: - Model: app/models/account.rb - Test: test/unit/account_test.rb - Fixtures: test/fixtures/accounts.yml - Migration: db/migrate/XXX_add_accounts.rb - - `./script/generate model post title:string body:text published:boolean` - - creates a Post model with a string title, text body, and published flag. diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb deleted file mode 100644 index 1895d8a9..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +++ /dev/null @@ -1,52 +0,0 @@ -class ModelGenerator < Rails::Generator::NamedBase - default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # Model, test, and fixture directories. - m.directory File.join('app/models', class_path) - m.directory File.join('test/unit', class_path) - m.directory File.join('test/fixtures', class_path) - - # Model class, unit test, and fixtures. - m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") - m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") - - unless options[:skip_fixture] - m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml") - end - - migration_file_path = file_path.gsub(/\//, '_') - migration_name = class_name - if ActiveRecord::Base.pluralize_table_names - migration_name = migration_name.pluralize - migration_file_path = migration_file_path.pluralize - end - - unless options[:skip_migration] - m.migration_template 'migration.rb', 'db/migrate', :assigns => { - :migration_name => "Create#{migration_name.gsub(/::/, '')}" - }, :migration_file_name => "create_#{migration_file_path}" - end - end - end - - protected - def banner - "Usage: #{$0} #{spec.name} ModelName [field:type, field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-timestamps", - "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - opt.on("--skip-fixture", - "Don't generation a fixture file for this model") { |v| options[:skip_fixture] = v} - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml deleted file mode 100644 index a30132bc..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -<% unless attributes.empty? -%> -one: -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%> - -two: -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%> -<% else -%> -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value -<% end -%> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb deleted file mode 100644 index 382fd115..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb +++ /dev/null @@ -1,16 +0,0 @@ -class <%= migration_name %> < ActiveRecord::Migration - def self.up - create_table :<%= table_name %> do |t| -<% for attribute in attributes -%> - t.<%= attribute.type %> :<%= attribute.name %> -<% end -%> -<% unless options[:skip_timestamps] %> - t.timestamps -<% end -%> - end - end - - def self.down - drop_table :<%= table_name %> - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb deleted file mode 100644 index 6fcf393b..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb +++ /dev/null @@ -1,5 +0,0 @@ -class <%= class_name %> < ActiveRecord::Base -<% attributes.select(&:reference?).each do |attribute| -%> - belongs_to :<%= attribute.name %> -<% end -%> -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb deleted file mode 100644 index 3e0bc29d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE deleted file mode 100644 index a5d744a3..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE +++ /dev/null @@ -1,13 +0,0 @@ -Description: - Stubs out a new observer. Pass the observer name, either CamelCased or - under_scored, as an argument. - - The generator creates an observer class in app/models and a unit test in - test/unit. - -Example: - `./script/generate observer Account` - - creates an Account observer and unit test: - Observer: app/models/account_observer.rb - Test: test/unit/account_observer_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb deleted file mode 100644 index 3c4b330a..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ObserverGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions "#{class_name}Observer", "#{class_name}ObserverTest" - - # Observer, and test directories. - m.directory File.join('app/models', class_path) - m.directory File.join('test/unit', class_path) - - # Observer class and unit test fixtures. - m.template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb") - m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb deleted file mode 100644 index b9a30041..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb +++ /dev/null @@ -1,2 +0,0 @@ -class <%= class_name %>Observer < ActiveRecord::Observer -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb deleted file mode 100644 index 03f6d566..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>ObserverTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/USAGE deleted file mode 100644 index d84051eb..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Stubs out a new performance test. Pass the name of the test, either - CamelCased or under_scored, as an argument. The new test class is - generated in test/performance/testname_test.rb - -Example: - `./script/generate performance_test GeneralStories` creates a GeneralStories - performance test in test/performance/general_stories_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb deleted file mode 100644 index 83ce8ac6..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -class PerformanceTestGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # performance test directory - m.directory File.join('test/performance', class_path) - - # performance test stub - m.template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb deleted file mode 100644 index 27c91b0f..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'performance_test_help' - -class <%= class_name %>Test < ActionController::PerformanceTest - # Replace this with your real tests. - def test_homepage - get '/' - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE deleted file mode 100644 index d2ecfc2d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE +++ /dev/null @@ -1,25 +0,0 @@ -Description: - Stubs out a new plugin. Pass the plugin name, either CamelCased or - under_scored, as an argument. Pass --with-generator to add an example - generator also. - - This creates a plugin in vendor/plugins including an init.rb and README - as well as standard lib, task, and test directories. - -Example: - `./script/generate plugin BrowserFilters` - - creates a standard browser_filters plugin: - vendor/plugins/browser_filters/README - vendor/plugins/browser_filters/init.rb - vendor/plugins/browser_filters/install.rb - vendor/plugins/browser_filters/lib/browser_filters.rb - vendor/plugins/browser_filters/test/browser_filters_test.rb - vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake - - ./script/generate plugin BrowserFilters --with-generator - - creates a browser_filters generator also: - vendor/plugins/browser_filters/generators/browser_filters/browser_filters_generator.rb - vendor/plugins/browser_filters/generators/browser_filters/USAGE - vendor/plugins/browser_filters/generators/browser_filters/templates/ diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb deleted file mode 100644 index 34c10b51..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +++ /dev/null @@ -1,39 +0,0 @@ -class PluginGenerator < Rails::Generator::NamedBase - attr_reader :plugin_path - - def initialize(runtime_args, runtime_options = {}) - @with_generator = runtime_args.delete("--with-generator") - super - @plugin_path = "vendor/plugins/#{file_name}" - end - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name - - m.directory "#{plugin_path}/lib" - m.directory "#{plugin_path}/lib/tasks" - m.directory "#{plugin_path}/test" - - m.template 'README', "#{plugin_path}/README" - m.template 'MIT-LICENSE', "#{plugin_path}/MIT-LICENSE" - m.template 'Rakefile', "#{plugin_path}/Rakefile" - m.template 'init.rb', "#{plugin_path}/init.rb" - m.template 'install.rb', "#{plugin_path}/install.rb" - m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb" - m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb" - m.template 'tasks.rake', "#{plugin_path}/lib/tasks/#{file_name}.rake" - m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb" - m.template 'test_helper.rb', "#{plugin_path}/test/test_helper.rb" - if @with_generator - m.directory "#{plugin_path}/generators" - m.directory "#{plugin_path}/generators/#{file_name}" - m.directory "#{plugin_path}/generators/#{file_name}/templates" - - m.template 'generator.rb', "#{plugin_path}/generators/#{file_name}/#{file_name}_generator.rb" - m.template 'USAGE', "#{plugin_path}/generators/#{file_name}/USAGE" - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE deleted file mode 100644 index 8717df05..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) <%= Date.today.year %> [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README deleted file mode 100644 index 702db07c..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README +++ /dev/null @@ -1,13 +0,0 @@ -<%= class_name %> -<%= "=" * class_name.size %> - -Introduction goes here. - - -Example -======= - -Example goes here. - - -Copyright (c) <%= Date.today.year %> [name of plugin creator], released under the MIT license diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile deleted file mode 100644 index c56ce947..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +++ /dev/null @@ -1,23 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rdoc/task' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the <%= file_name %> plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the <%= file_name %> plugin.' -RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = '<%= class_name %>' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE deleted file mode 100644 index ea9f4f12..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Explain the generator - -Example: - ./script/generate <%= file_name %> Thing - - This will create: - what/will/it/create diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb deleted file mode 100644 index 3e800df6..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb +++ /dev/null @@ -1,8 +0,0 @@ -class <%= class_name %>Generator < Rails::Generator::NamedBase - def manifest - record do |m| - # m.directory "lib" - # m.template 'README', "README" - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb deleted file mode 100644 index 3c19a743..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb +++ /dev/null @@ -1 +0,0 @@ -# Include hook code here diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb deleted file mode 100644 index f7732d37..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb +++ /dev/null @@ -1 +0,0 @@ -# Install hook code here diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb deleted file mode 100644 index d8d908a9..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb +++ /dev/null @@ -1 +0,0 @@ -# <%= class_name %> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake deleted file mode 100644 index 72920a9d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake +++ /dev/null @@ -1,4 +0,0 @@ -# desc "Explaining what the task does" -# task :<%= file_name %> do -# # Task goes here -# end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb deleted file mode 100644 index 51093e14..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rubygems' -require 'test/unit' -require 'active_support' -require 'active_support/test_case' diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb deleted file mode 100644 index 97383334..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +++ /dev/null @@ -1 +0,0 @@ -# Uninstall hook code here diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb deleted file mode 100644 index 3e0bc29d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE deleted file mode 100644 index e6043f1d..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE +++ /dev/null @@ -1,23 +0,0 @@ -Description: - Stubs out a new resource including an empty model and controller suitable - for a restful, resource-oriented application. Pass the singular model name, - either CamelCased or under_scored, as the first argument, and an optional - list of attribute pairs. - - Attribute pairs are column_name:sql_type arguments specifying the - model's attributes. Timestamps are added by default, so you don't have to - specify them by hand as 'created_at:datetime updated_at:datetime'. - - You don't have to think up every attribute up front, but it helps to - sketch out a few so you can start working with the resource immediately. - - This creates a model, controller, helper, tests and fixtures for all of them, - and the corresponding map.resources declaration in config/routes.rb - - Unlike the scaffold generator, the resource generator does not create - views or add any methods to the generated controller. - -Examples: - `./script/generate resource post` # no attributes - `./script/generate resource post title:string body:text published:boolean` - `./script/generate resource purchase order_id:integer amount:decimal` diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb deleted file mode 100644 index 4ee2fbff..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +++ /dev/null @@ -1,76 +0,0 @@ -class ResourceGenerator < Rails::Generator::NamedBase - default_options :skip_timestamps => false, :skip_migration => false - - attr_reader :controller_name, - :controller_class_path, - :controller_file_path, - :controller_class_nesting, - :controller_class_nesting_depth, - :controller_class_name, - :controller_singular_name, - :controller_plural_name - alias_method :controller_file_name, :controller_singular_name - alias_method :controller_table_name, :controller_plural_name - - def initialize(runtime_args, runtime_options = {}) - super - - @controller_name = @name.pluralize - - base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name) - @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name) - - if @controller_class_nesting.empty? - @controller_class_name = @controller_class_name_without_nesting - else - @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" - end - end - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper") - m.class_collisions(class_name) - - # Controller, helper, views, and test directories. - m.directory(File.join('app/models', class_path)) - m.directory(File.join('app/controllers', controller_class_path)) - m.directory(File.join('app/helpers', controller_class_path)) - m.directory(File.join('app/views', controller_class_path, controller_file_name)) - m.directory(File.join('test/functional', controller_class_path)) - m.directory(File.join('test/unit', class_path)) - m.directory(File.join('test/unit/helpers', class_path)) - - m.dependency 'model', [name] + @args, :collision => :skip - - m.template( - 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") - ) - - m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) - m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")) - m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb")) - - m.route_resources controller_file_name - end - end - - protected - def banner - "Usage: #{$0} resource ModelName [field:type, field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-timestamps", - "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - end - - def model_name - class_name.demodulize - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb deleted file mode 100644 index 765a9426..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class <%= controller_class_name %>Controller < ApplicationController -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb deleted file mode 100644 index b1bb1dac..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>ControllerTest < ActionController::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb deleted file mode 100644 index 9bd821b1..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= controller_class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb deleted file mode 100644 index 061f64a5..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE deleted file mode 100644 index 810aea16..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE +++ /dev/null @@ -1,29 +0,0 @@ -Description: - Scaffolds an entire resource, from model and migration to controller and - views, along with a full test suite. The resource is ready to use as a - starting point for your RESTful, resource-oriented application. - - Pass the name of the model (in singular form), either CamelCased or - under_scored, as the first argument, and an optional list of attribute - pairs. - - Attribute pairs are column_name:sql_type arguments specifying the - model's attributes. Timestamps are added by default, so you don't have to - specify them by hand as 'created_at:datetime updated_at:datetime'. - - You don't have to think up every attribute up front, but it helps to - sketch out a few so you can start working with the resource immediately. - - For example, 'scaffold post title:string body:text published:boolean' - gives you a model with those three attributes, a controller that handles - the create/show/update/destroy, forms to create and edit your posts, and - an index that lists them all, as well as a map.resources :posts - declaration in config/routes.rb. - - If you want to remove all the generated files, run - 'script/destroy scaffold ModelName'. - -Examples: - `./script/generate scaffold post` - `./script/generate scaffold post title:string body:text published:boolean` - `./script/generate scaffold purchase order_id:integer amount:decimal` diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb deleted file mode 100644 index 88bc3252..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +++ /dev/null @@ -1,103 +0,0 @@ -class ScaffoldGenerator < Rails::Generator::NamedBase - default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false - - attr_reader :controller_name, - :controller_class_path, - :controller_file_path, - :controller_class_nesting, - :controller_class_nesting_depth, - :controller_class_name, - :controller_underscore_name, - :controller_singular_name, - :controller_plural_name - alias_method :controller_file_name, :controller_underscore_name - alias_method :controller_table_name, :controller_plural_name - - def initialize(runtime_args, runtime_options = {}) - super - - if @name == @name.pluralize && !options[:force_plural] - logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural." - @name = @name.singularize - assign_names!(@name) - end - - @controller_name = @name.pluralize - - base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name) - @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name) - @controller_singular_name=base_name.singularize - if @controller_class_nesting.empty? - @controller_class_name = @controller_class_name_without_nesting - else - @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" - end - end - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper") - m.class_collisions(class_name) - - # Controller, helper, views, test and stylesheets directories. - m.directory(File.join('app/models', class_path)) - m.directory(File.join('app/controllers', controller_class_path)) - m.directory(File.join('app/helpers', controller_class_path)) - m.directory(File.join('app/views', controller_class_path, controller_file_name)) - m.directory(File.join('app/views/layouts', controller_class_path)) - m.directory(File.join('test/functional', controller_class_path)) - m.directory(File.join('test/unit', class_path)) - m.directory(File.join('test/unit/helpers', class_path)) - m.directory(File.join('public/stylesheets', class_path)) - - for action in scaffold_views - m.template( - "view_#{action}.html.erb", - File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb") - ) - end - - # Layout and stylesheet. - m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb")) - m.template('style.css', 'public/stylesheets/scaffold.css') - - m.template( - 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") - ) - - m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) - m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")) - m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb")) - - m.route_resources controller_file_name - - m.dependency 'model', [name] + @args, :collision => :skip - end - end - - protected - # Override with your own usage banner. - def banner - "Usage: #{$0} scaffold ModelName [field:type, field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-timestamps", - "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - opt.on("--force-plural", - "Forces the generation of a plural ModelName") { |v| options[:force_plural] = v } - end - - def scaffold_views - %w[ index show new edit ] - end - - def model_name - class_name.demodulize - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb deleted file mode 100644 index cef254cd..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +++ /dev/null @@ -1,83 +0,0 @@ -class <%= controller_class_name %>Controller < ApplicationController - # GET /<%= table_name %> - # GET /<%= table_name %>.xml - def index - @<%= table_name %> = <%= class_name %>.all - - respond_to do |format| - format.html # index.html.erb - format.xml { render :xml => @<%= table_name %> } - end - end - - # GET /<%= table_name %>/1 - # GET /<%= table_name %>/1.xml - def show - @<%= file_name %> = <%= class_name %>.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.xml { render :xml => @<%= file_name %> } - end - end - - # GET /<%= table_name %>/new - # GET /<%= table_name %>/new.xml - def new - @<%= file_name %> = <%= class_name %>.new - - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @<%= file_name %> } - end - end - - # GET /<%= table_name %>/1/edit - def edit - @<%= file_name %> = <%= class_name %>.find(params[:id]) - end - - # POST /<%= table_name %> - # POST /<%= table_name %>.xml - def create - @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>]) - - respond_to do |format| - if @<%= file_name %>.save - format.html { redirect_to(@<%= file_name %>, :notice => '<%= class_name %> was successfully created.') } - format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> } - else - format.html { render :action => "new" } - format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity } - end - end - end - - # PUT /<%= table_name %>/1 - # PUT /<%= table_name %>/1.xml - def update - @<%= file_name %> = <%= class_name %>.find(params[:id]) - - respond_to do |format| - if @<%= file_name %>.update_attributes(params[:<%= file_name %>]) - format.html { redirect_to(@<%= file_name %>, :notice => '<%= class_name %> was successfully updated.') } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity } - end - end - end - - # DELETE /<%= table_name %>/1 - # DELETE /<%= table_name %>/1.xml - def destroy - @<%= file_name %> = <%= class_name %>.find(params[:id]) - @<%= file_name %>.destroy - - respond_to do |format| - format.html { redirect_to(<%= table_name %>_url) } - format.xml { head :ok } - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb deleted file mode 100644 index cd2fc578..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>ControllerTest < ActionController::TestCase - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:<%= table_name %>) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create <%= file_name %>" do - assert_difference('<%= class_name %>.count') do - post :create, :<%= file_name %> => { } - end - - assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) - end - - test "should show <%= file_name %>" do - get :show, :id => <%= table_name %>(:one).to_param - assert_response :success - end - - test "should get edit" do - get :edit, :id => <%= table_name %>(:one).to_param - assert_response :success - end - - test "should update <%= file_name %>" do - put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { } - assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) - end - - test "should destroy <%= file_name %>" do - assert_difference('<%= class_name %>.count', -1) do - delete :destroy, :id => <%= table_name %>(:one).to_param - end - - assert_redirected_to <%= table_name %>_path - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb deleted file mode 100644 index 9bd821b1..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= controller_class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb deleted file mode 100644 index 061f64a5..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb deleted file mode 100644 index 1478ff68..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> - <title><%= controller_class_name %>: <%%= controller.action_name %></title> - <%%= stylesheet_link_tag 'scaffold' %> -</head> -<body> - -<p style="color: green"><%%= notice %></p> - -<%%= yield %> - -</body> -</html> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css deleted file mode 100644 index 093c2099..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css +++ /dev/null @@ -1,54 +0,0 @@ -body { background-color: #fff; color: #333; } - -body, p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { color: #000; } -a:visited { color: #666; } -a:hover { color: #fff; background-color:#000; } - -.fieldWithErrors { - padding: 2px; - background-color: red; - display: table; -} - -#errorExplanation { - width: 400px; - border: 2px solid red; - padding: 7px; - padding-bottom: 12px; - margin-bottom: 20px; - background-color: #f0f0f0; -} - -#errorExplanation h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - background-color: #c00; - color: #fff; -} - -#errorExplanation p { - color: #333; - margin-bottom: 0; - padding: 5px; -} - -#errorExplanation ul li { - font-size: 12px; - list-style: square; -} - diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb deleted file mode 100644 index cca1d61c..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<h1>Editing <%= singular_name %></h1> - -<%% form_for(@<%= singular_name %>) do |f| %> - <%%= f.error_messages %> - -<% for attribute in attributes -%> - <p> - <%%= f.label :<%= attribute.name %> %><br /> - <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> - </p> -<% end -%> - <p> - <%%= f.submit 'Update' %> - </p> -<%% end %> - -<%%= link_to 'Show', @<%= singular_name %> %> | -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb deleted file mode 100644 index 2e603d5b..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<h1>Listing <%= plural_name %></h1> - -<table> - <tr> -<% for attribute in attributes -%> - <th><%= attribute.column.human_name %></th> -<% end -%> - </tr> - -<%% @<%= plural_name %>.each do |<%= singular_name %>| %> - <tr> -<% for attribute in attributes -%> - <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td> -<% end -%> - <td><%%= link_to 'Show', <%= singular_name %> %></td> - <td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td> - <td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td> - </tr> -<%% end %> -</table> - -<br /> - -<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb deleted file mode 100644 index 96c89fc5..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<h1>New <%= singular_name %></h1> - -<%% form_for(@<%= singular_name %>) do |f| %> - <%%= f.error_messages %> - -<% for attribute in attributes -%> - <p> - <%%= f.label :<%= attribute.name %> %><br /> - <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> - </p> -<% end -%> - <p> - <%%= f.submit 'Create' %> - </p> -<%% end %> - -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb deleted file mode 100644 index adecaf70..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% for attribute in attributes -%> -<p> - <b><%= attribute.column.human_name %>:</b> - <%%=h @<%= singular_name %>.<%= attribute.name %> %> -</p> - -<% end -%> - -<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> | -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE deleted file mode 100644 index 87117a3c..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE +++ /dev/null @@ -1,10 +0,0 @@ -Description: - Creates a migration to add the sessions table used by the Active Record - session store. Pass the migration name, either CamelCased or under_scored, - as an argument. - -Example: - `./script/generate session_migration CreateSessionTable` - - With 4 existing migrations, this creates the AddSessionTable migration - in db/migrate/005_add_session_table.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb deleted file mode 100644 index 2e177033..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +++ /dev/null @@ -1,18 +0,0 @@ -class SessionMigrationGenerator < Rails::Generator::NamedBase - def initialize(runtime_args, runtime_options = {}) - runtime_args << 'add_session_table' if runtime_args.empty? - super - end - - def manifest - record do |m| - m.migration_template 'migration.rb', 'db/migrate', - :assigns => { :session_table_name => default_session_table_name } - end - end - - protected - def default_session_table_name - ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session' - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb deleted file mode 100644 index ca220a5f..00000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb +++ /dev/null @@ -1,16 +0,0 @@ -class <%= class_name %> < ActiveRecord::Migration - def self.up - create_table :<%= session_table_name %> do |t| - t.string :session_id, :null => false - t.text :data - t.timestamps - end - - add_index :<%= session_table_name %>, :session_id - add_index :<%= session_table_name %>, :updated_at - end - - def self.down - drop_table :<%= session_table_name %> - end -end diff --git a/vendor/rails/railties/lib/rails_generator/lookup.rb b/vendor/rails/railties/lib/rails_generator/lookup.rb deleted file mode 100644 index a3525364..00000000 --- a/vendor/rails/railties/lib/rails_generator/lookup.rb +++ /dev/null @@ -1,249 +0,0 @@ -require 'pathname' - -require File.dirname(__FILE__) + '/spec' - -class Object - class << self - # Lookup missing generators using const_missing. This allows any - # generator to reference another without having to know its location: - # RubyGems, ~/.rails/generators, and RAILS_ROOT/generators. - def lookup_missing_generator(class_id) - if md = /(.+)Generator$/.match(class_id.to_s) - name = md.captures.first.demodulize.underscore - Rails::Generator::Base.lookup(name).klass - else - const_missing_before_generators(class_id) - end - end - - unless respond_to?(:const_missing_before_generators) - alias_method :const_missing_before_generators, :const_missing - alias_method :const_missing, :lookup_missing_generator - end - end -end - -# User home directory lookup adapted from RubyGems. -def Dir.user_home - if ENV['HOME'] - ENV['HOME'] - elsif ENV['USERPROFILE'] - ENV['USERPROFILE'] - elsif ENV['HOMEDRIVE'] and ENV['HOMEPATH'] - "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}" - else - File.expand_path '~' - end -end - - -module Rails - module Generator - - # Generator lookup is managed by a list of sources which return specs - # describing where to find and how to create generators. This module - # provides class methods for manipulating the source list and looking up - # generator specs, and an #instance wrapper for quickly instantiating - # generators by name. - # - # A spec is not a generator: it's a description of where to find - # the generator and how to create it. A source is anything that - # yields generators from #each. PathSource and GemGeneratorSource are provided. - module Lookup - def self.included(base) - base.extend(ClassMethods) - base.use_component_sources! - end - - # Convenience method to instantiate another generator. - def instance(generator_name, args, runtime_options = {}) - self.class.instance(generator_name, args, runtime_options) - end - - module ClassMethods - # The list of sources where we look, in order, for generators. - def sources - read_inheritable_attribute(:sources) or use_component_sources! - end - - # Add a source to the end of the list. - def append_sources(*args) - sources.concat(args.flatten) - invalidate_cache! - end - - # Add a source to the beginning of the list. - def prepend_sources(*args) - write_inheritable_array(:sources, args.flatten + sources) - invalidate_cache! - end - - # Reset the source list. - def reset_sources - write_inheritable_attribute(:sources, []) - invalidate_cache! - end - - # Use application generators (app, ?). - def use_application_sources! - reset_sources - sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/applications") - end - - # Use component generators (model, controller, etc). - # 1. Rails application. If RAILS_ROOT is defined we know we're - # generating in the context of a Rails application, so search - # RAILS_ROOT/generators. - # 2. Look in plugins, either for generators/ or rails_generators/ - # directories within each plugin - # 3. User home directory. Search ~/.rails/generators. - # 4. RubyGems. Search for gems named *_generator, and look for - # generators within any RubyGem's - # /rails_generators/<generator_name>_generator.rb file. - # 5. Builtins. Model, controller, mailer, scaffold, and so on. - def use_component_sources! - reset_sources - if defined? ::RAILS_ROOT - sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators") - sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators") - Rails.configuration.plugin_paths.each do |path| - relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT)) - sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/*/**/{,rails_}generators") - end - end - sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators") - if Object.const_defined?(:Gem) - sources << GemGeneratorSource.new - sources << GemPathSource.new - end - sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/components") - end - - # Lookup knows how to find generators' Specs from a list of Sources. - # Searches the sources, in order, for the first matching name. - def lookup(generator_name) - @found ||= {} - generator_name = generator_name.to_s.downcase - @found[generator_name] ||= cache.find { |spec| spec.name == generator_name } - unless @found[generator_name] - chars = generator_name.scan(/./).map{|c|"#{c}.*?"} - rx = /^#{chars}$/ - gns = cache.select{|spec| spec.name =~ rx } - @found[generator_name] ||= gns.first if gns.length == 1 - raise GeneratorError, "Pattern '#{generator_name}' matches more than one generator: #{gns.map{|sp|sp.name}.join(', ')}" if gns.length > 1 - end - @found[generator_name] or raise GeneratorError, "Couldn't find '#{generator_name}' generator" - end - - # Convenience method to lookup and instantiate a generator. - def instance(generator_name, args = [], runtime_options = {}) - lookup(generator_name).klass.new(args, full_options(runtime_options)) - end - - private - # Lookup and cache every generator from the source list. - def cache - @cache ||= sources.inject([]) { |cache, source| cache + source.to_a } - end - - # Clear the cache whenever the source list changes. - def invalidate_cache! - @cache = nil - end - end - end - - # Sources enumerate (yield from #each) generator specs which describe - # where to find and how to create generators. Enumerable is mixed in so, - # for example, source.collect will retrieve every generator. - # Sources may be assigned a label to distinguish them. - class Source - include Enumerable - - attr_reader :label - def initialize(label) - @label = label - end - - # The each method must be implemented in subclasses. - # The base implementation raises an error. - def each - raise NotImplementedError - end - - # Return a convenient sorted list of all generator names. - def names - map { |spec| spec.name }.sort - end - end - - - # PathSource looks for generators in a filesystem directory. - class PathSource < Source - attr_reader :path - - def initialize(label, path) - super label - @path = path - end - - # Yield each eligible subdirectory. - def each - Dir["#{path}/[a-z]*"].each do |dir| - if File.directory?(dir) - yield Spec.new(File.basename(dir), dir, label) - end - end - end - end - - class AbstractGemSource < Source - def initialize - super :RubyGems - end - end - - # GemGeneratorSource hits the mines to quarry for generators. The latest versions - # of gems named *_generator are selected. - class GemGeneratorSource < AbstractGemSource - # Yield latest versions of generator gems. - def each - dependency = Gem::Dependency.new(/_generator$/, Gem::Requirement.default) - Gem::cache.search(dependency).inject({}) { |latest, gem| - hem = latest[gem.name] - latest[gem.name] = gem if hem.nil? or gem.version > hem.version - latest - }.values.each { |gem| - yield Spec.new(gem.name.sub(/_generator$/, ''), gem.full_gem_path, label) - } - end - end - - # GemPathSource looks for generators within any RubyGem's /rails_generators/<generator_name>_generator.rb file. - class GemPathSource < AbstractGemSource - # Yield each generator within rails_generator subdirectories. - def each - generator_full_paths.each do |generator| - yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label) - end - end - - private - def generator_full_paths - @generator_full_paths ||= - Gem::cache.inject({}) do |latest, name_gem| - name, gem = name_gem - hem = latest[gem.name] - latest[gem.name] = gem if hem.nil? or gem.version > hem.version - latest - end.values.inject([]) do |mem, gem| - Dir[gem.full_gem_path + '/{rails_,}generators/**/*_generator.rb'].each do |generator| - mem << generator - end - mem - end - end - end - - end -end diff --git a/vendor/rails/railties/lib/rails_generator/manifest.rb b/vendor/rails/railties/lib/rails_generator/manifest.rb deleted file mode 100644 index 702effa7..00000000 --- a/vendor/rails/railties/lib/rails_generator/manifest.rb +++ /dev/null @@ -1,53 +0,0 @@ -module Rails - module Generator - - # Manifest captures the actions a generator performs. Instantiate - # a manifest with an optional target object, hammer it with actions, - # then replay or rewind on the object of your choice. - # - # Example: - # manifest = Manifest.new { |m| - # m.make_directory '/foo' - # m.create_file '/foo/bar.txt' - # } - # manifest.replay(creator) - # manifest.rewind(destroyer) - class Manifest - attr_reader :target - - # Take a default action target. Yield self if block given. - def initialize(target = nil) - @target, @actions = target, [] - yield self if block_given? - end - - # Record an action. - def method_missing(action, *args, &block) - @actions << [action, args, block] - end - - # Replay recorded actions. - def replay(target = nil) - send_actions(target || @target, @actions) - end - - # Rewind recorded actions. - def rewind(target = nil) - send_actions(target || @target, @actions.reverse) - end - - # Erase recorded actions. - def erase - @actions = [] - end - - private - def send_actions(target, actions) - actions.each do |method, args, block| - target.send(method, *args, &block) - end - end - end - - end -end diff --git a/vendor/rails/railties/lib/rails_generator/options.rb b/vendor/rails/railties/lib/rails_generator/options.rb deleted file mode 100644 index 070f96b6..00000000 --- a/vendor/rails/railties/lib/rails_generator/options.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'optparse' - -module Rails - module Generator - module Options - def self.included(base) - base.extend(ClassMethods) - class << base - if respond_to?(:inherited) - alias_method :inherited_without_options, :inherited - end - alias_method :inherited, :inherited_with_options - end - end - - module ClassMethods - def inherited_with_options(sub) - inherited_without_options(sub) if respond_to?(:inherited_without_options) - sub.extend(Rails::Generator::Options::ClassMethods) - end - - def mandatory_options(options = nil) - if options - write_inheritable_attribute(:mandatory_options, options) - else - read_inheritable_attribute(:mandatory_options) or write_inheritable_attribute(:mandatory_options, {}) - end - end - - def default_options(options = nil) - if options - write_inheritable_attribute(:default_options, options) - else - read_inheritable_attribute(:default_options) or write_inheritable_attribute(:default_options, {}) - end - end - - # Merge together our class options. In increasing precedence: - # default_options (class default options) - # runtime_options (provided as argument) - # mandatory_options (class mandatory options) - def full_options(runtime_options = {}) - default_options.merge(runtime_options).merge(mandatory_options) - end - - end - - # Each instance has an options hash that's populated by #parse. - def options - @options ||= {} - end - attr_writer :options - - protected - # Convenient access to class mandatory options. - def mandatory_options - self.class.mandatory_options - end - - # Convenient access to class default options. - def default_options - self.class.default_options - end - - # Merge together our instance options. In increasing precedence: - # default_options (class default options) - # options (instance options) - # runtime_options (provided as argument) - # mandatory_options (class mandatory options) - def full_options(runtime_options = {}) - self.class.full_options(options.merge(runtime_options)) - end - - # Parse arguments into the options hash. Classes may customize - # parsing behavior by overriding these methods: - # #banner Usage: ./script/generate [options] - # #add_options! Options: - # some options.. - # #add_general_options! General Options: - # general options.. - def parse!(args, runtime_options = {}) - self.options = {} - - @option_parser = OptionParser.new do |opt| - opt.banner = banner - add_options!(opt) - add_general_options!(opt) - opt.parse!(args) - end - - return args - ensure - self.options = full_options(runtime_options) - end - - # Raise a usage error. Override usage_message to provide a blurb - # after the option parser summary. - def usage(message = usage_message) - raise UsageError, "#{@option_parser}\n#{message}" - end - - def usage_message - '' - end - - # Override with your own usage banner. - def banner - "Usage: #{$0} [options]" - end - - # Override to add your options to the parser: - # def add_options!(opt) - # opt.on('-v', '--verbose') { |value| options[:verbose] = value } - # end - def add_options!(opt) - end - - # Adds general options like -h and --quiet. Usually don't override. - def add_general_options!(opt) - opt.separator '' - opt.separator 'Rails Info:' - opt.on('-v', '--version', 'Show the Rails version number and quit.') - opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v } - - opt.separator '' - opt.separator 'General Options:' - - opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v } - opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force } - opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip } - opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v } - opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v } - opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do - options[:svn] = {} - `svn status`.each_line do |line| - options[:svn][line.chomp[7..-1]] = true - end - end - opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do - options[:git] = {:new => {}, :modified => {}} - `git status`.each_line do |line| - options[:git][:new][line.chomp[14..-1]] = true if line =~ /new file:/ - options[:git][:modified][line.chomp[14..-1]] = true if line =~ /modified:/ - end - end - end - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts.rb b/vendor/rails/railties/lib/rails_generator/scripts.rb deleted file mode 100644 index 9b1a9983..00000000 --- a/vendor/rails/railties/lib/rails_generator/scripts.rb +++ /dev/null @@ -1,89 +0,0 @@ -require File.dirname(__FILE__) + '/options' - -module Rails - module Generator - module Scripts - - # Generator scripts handle command-line invocation. Each script - # responds to an invoke! class method which handles option parsing - # and generator invocation. - class Base - include Options - default_options :collision => :ask, :quiet => false - - # Run the generator script. Takes an array of unparsed arguments - # and a hash of parsed arguments, takes the generator as an option - # or first remaining argument, and invokes the requested command. - def run(args = [], runtime_options = {}) - begin - parse!(args.dup, runtime_options) - rescue OptionParser::InvalidOption => e - # Don't cry, script. Generators want what you think is invalid. - end - - # Generator name is the only required option. - unless options[:generator] - usage if args.empty? - options[:generator] ||= args.shift - end - - # Look up generator instance and invoke command on it. - Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke! - rescue => e - puts e - puts " #{e.backtrace.join("\n ")}\n" if options[:backtrace] - raise SystemExit - end - - protected - # Override with your own script usage banner. - def banner - "Usage: #{$0} generator [options] [args]" - end - - def usage_message - usage = "\nInstalled Generators\n" - Rails::Generator::Base.sources.inject([]) do |mem, source| - # Using an association list instead of a hash to preserve order, - # for aesthetic reasons more than anything else. - label = source.label.to_s.capitalize - pair = mem.assoc(label) - mem << (pair = [label, []]) if pair.nil? - pair[1] |= source.names - mem - end.each do |label, names| - usage << " #{label}: #{names.join(', ')}\n" unless names.empty? - end - - usage << <<end_blurb - -More are available at http://wiki.rubyonrails.org/rails/pages/AvailableGenerators - 1. Download, for example, login_generator.zip - 2. Unzip to directory #{Dir.user_home}/.rails/generators/login - to use the generator with all your Rails apps -end_blurb - - if Object.const_defined?(:RAILS_ROOT) - usage << <<end_blurb - or to #{File.expand_path(RAILS_ROOT)}/lib/generators/login - to use with this app only. -end_blurb - end - - usage << <<end_blurb - 3. Run generate with no arguments for usage information - #{$0} login - -Generator gems are also available: - 1. gem search -r generator - 2. gem install login_generator - 3. #{$0} login - -end_blurb - return usage - end - end # Base - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb b/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb deleted file mode 100644 index a7c2a147..00000000 --- a/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb +++ /dev/null @@ -1,29 +0,0 @@ -require File.dirname(__FILE__) + '/../scripts' - -module Rails::Generator::Scripts - class Destroy < Base - mandatory_options :command => :destroy - - protected - def usage_message - usage = "\nInstalled Generators\n" - Rails::Generator::Base.sources.each do |source| - label = source.label.to_s.capitalize - names = source.names - usage << " #{label}: #{names.join(', ')}\n" unless names.empty? - end - - usage << <<end_blurb - -script/generate command. For instance, 'script/destroy migration CreatePost' -will delete the appropriate XXX_create_post.rb migration file in db/migrate, -while 'script/destroy scaffold Post' will delete the posts controller and -views, post model and migration, all associated tests, and the map.resources -:posts line in config/routes.rb. - -For instructions on finding new generators, run script/generate. -end_blurb - return usage - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts/generate.rb b/vendor/rails/railties/lib/rails_generator/scripts/generate.rb deleted file mode 100644 index 1fe2f54a..00000000 --- a/vendor/rails/railties/lib/rails_generator/scripts/generate.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.dirname(__FILE__) + '/../scripts' - -module Rails::Generator::Scripts - class Generate < Base - mandatory_options :command => :create - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts/update.rb b/vendor/rails/railties/lib/rails_generator/scripts/update.rb deleted file mode 100644 index 53a9faa3..00000000 --- a/vendor/rails/railties/lib/rails_generator/scripts/update.rb +++ /dev/null @@ -1,12 +0,0 @@ -require File.dirname(__FILE__) + '/../scripts' - -module Rails::Generator::Scripts - class Update < Base - mandatory_options :command => :update - - protected - def banner - "Usage: #{$0} [options] scaffold" - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb b/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb deleted file mode 100644 index 7dd495a2..00000000 --- a/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'active_support/deprecation' - -module Rails - # A class for creating random secret keys. This class will do its best to create a - # random secret key that's as secure as possible, using whatever methods are - # available on the current platform. For example: - # - # generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name") - # generator.generate_secret # => "f3f1be90053fa851... (some long string)" - # - # This class is *deprecated* in Rails 2.2 in favor of ActiveSupport::SecureRandom. - # It is currently a wrapper around ActiveSupport::SecureRandom. - class SecretKeyGenerator - def initialize(identifier) - end - - # Generate a random secret key with the best possible method available on - # the current platform. - def generate_secret - ActiveSupport::SecureRandom.hex(64) - end - deprecate :generate_secret=>"You should use ActiveSupport::SecureRandom.hex(64)" - end -end diff --git a/vendor/rails/railties/lib/rails_generator/simple_logger.rb b/vendor/rails/railties/lib/rails_generator/simple_logger.rb deleted file mode 100644 index d750f07b..00000000 --- a/vendor/rails/railties/lib/rails_generator/simple_logger.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Rails - module Generator - class SimpleLogger # :nodoc: - attr_reader :out - attr_accessor :quiet - - def initialize(out = $stdout) - @out = out - @quiet = false - @level = 0 - end - - def log(status, message, &block) - @out.print("%12s %s%s\n" % [status, ' ' * @level, message]) unless quiet - indent(&block) if block_given? - end - - def indent(&block) - @level += 1 - if block_given? - begin - block.call - ensure - outdent - end - end - end - - def outdent - @level -= 1 - if block_given? - begin - block.call - ensure - indent - end - end - end - - private - def method_missing(method, *args, &block) - log(method.to_s, args.first, &block) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/spec.rb b/vendor/rails/railties/lib/rails_generator/spec.rb deleted file mode 100644 index 9d780b7a..00000000 --- a/vendor/rails/railties/lib/rails_generator/spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Rails - module Generator - # A spec knows where a generator was found and how to instantiate it. - # Metadata include the generator's name, its base path, and the source - # which yielded it (PathSource, GemPathSource, etc.) - class Spec - attr_reader :name, :path, :source - - def initialize(name, path, source) - @name, @path, @source = name, path, source - end - - # Look up the generator class. Require its class file, find the class - # in ObjectSpace, tag it with this spec, and return. - def klass - unless @klass - require class_file - @klass = lookup_class - @klass.spec = self - end - @klass - end - - def class_file - "#{path}/#{name}_generator.rb" - end - - def class_name - "#{name.camelize}Generator" - end - - private - # Search for the first Class descending from Rails::Generator::Base - # whose name matches the requested class name. - def lookup_class - ObjectSpace.each_object(Class) do |obj| - return obj if obj.ancestors.include?(Rails::Generator::Base) and - obj.name.split('::').last == class_name - end - raise NameError, "Missing #{class_name} class in #{class_file}" - end - end - end -end diff --git a/vendor/rails/railties/lib/railties_path.rb b/vendor/rails/railties/lib/railties_path.rb deleted file mode 100644 index a298a4cc..00000000 --- a/vendor/rails/railties/lib/railties_path.rb +++ /dev/null @@ -1 +0,0 @@ -RAILTIES_PATH = File.join(File.dirname(__FILE__), '..') diff --git a/vendor/rails/railties/lib/ruby_version_check.rb b/vendor/rails/railties/lib/ruby_version_check.rb deleted file mode 100644 index 68d3acc8..00000000 --- a/vendor/rails/railties/lib/ruby_version_check.rb +++ /dev/null @@ -1,17 +0,0 @@ -min_release = "1.8.2 (2004-12-25)" -ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})" -if ruby_release =~ /1\.8\.3/ - abort <<-end_message - - Rails does not work with Ruby version 1.8.3. - Please upgrade to version 1.8.4 or downgrade to 1.8.2. - - end_message -elsif ruby_release < min_release - abort <<-end_message - - Rails requires Ruby version #{min_release} or later. - You're running #{ruby_release}; please upgrade to continue. - - end_message -end diff --git a/vendor/rails/railties/lib/rubyprof_ext.rb b/vendor/rails/railties/lib/rubyprof_ext.rb deleted file mode 100644 index f6e90357..00000000 --- a/vendor/rails/railties/lib/rubyprof_ext.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'prof' - -module Prof #:nodoc: - # Adapted from Shugo Maeda's unprof.rb - def self.print_profile(results, io = $stderr) - total = results.detect { |i| - i.method_class.nil? && i.method_id == :"#toplevel" - }.total_time - total = 0.001 if total < 0.001 - - io.puts " %% cumulative self self total" - io.puts " time seconds seconds calls ms/call ms/call name" - - sum = 0.0 - for r in results - sum += r.self_time - - name = if r.method_class.nil? - r.method_id.to_s - elsif r.method_class.is_a?(Class) - "#{r.method_class}##{r.method_id}" - else - "#{r.method_class}.#{r.method_id}" - end - io.printf "%6.2f %8.3f %8.3f %8d %8.2f %8.2f %s\n", - r.self_time / total * 100, - sum, - r.self_time, - r.count, - r.self_time * 1000 / r.count, - r.total_time * 1000 / r.count, - name - end - end -end diff --git a/vendor/rails/railties/lib/source_annotation_extractor.rb b/vendor/rails/railties/lib/source_annotation_extractor.rb deleted file mode 100644 index 591fd6f6..00000000 --- a/vendor/rails/railties/lib/source_annotation_extractor.rb +++ /dev/null @@ -1,102 +0,0 @@ -# Implements the logic behind the rake tasks for annotations like -# -# rake notes -# rake notes:optimize -# -# and friends. See <tt>rake -T notes</tt> and <tt>railties/lib/tasks/annotations.rake</tt>. -# -# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that -# represent the line where the annotation lives, its tag, and its text. Note -# the filename is not stored. -# -# Annotations are looked for in comments and modulus whitespace they have to -# start with the tag optionally followed by a colon. Everything up to the end -# of the line (or closing ERb comment tag) is considered to be their text. -class SourceAnnotationExtractor - class Annotation < Struct.new(:line, :tag, :text) - - # Returns a representation of the annotation that looks like this: - # - # [126] [TODO] This algorithm is simple and clearly correct, make it faster. - # - # If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above. - # Otherwise the string contains just line and text. - def to_s(options={}) - s = "[%3d] " % line - s << "[#{tag}] " if options[:tag] - s << text - end - end - - # Prints all annotations with tag +tag+ under the root directories +app+, +lib+, - # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+, - # +.rxml+, +.rjs+, +.rhtml+, or +.erb+ are taken into account. The +options+ - # hash is passed to each annotation's +to_s+. - # - # This class method is the single entry point for the rake tasks. - def self.enumerate(tag, options={}) - extractor = new(tag) - extractor.display(extractor.find, options) - end - - attr_reader :tag - - def initialize(tag) - @tag = tag - end - - # Returns a hash that maps filenames under +dirs+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ - # are taken into account. - def find(dirs=%w(app lib test)) - dirs.inject({}) { |h, dir| h.update(find_in(dir)) } - end - - # Returns a hash that maps filenames under +dir+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ - # are taken into account. - def find_in(dir) - results = {} - - Dir.glob("#{dir}/*") do |item| - next if File.basename(item)[0] == ?. - - if File.directory?(item) - results.update(find_in(item)) - elsif item =~ /\.(builder|(r(?:b|xml|js)))$/ - results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) - elsif item =~ /\.(rhtml|erb)$/ - results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)) - end - end - - results - end - - # If +file+ is the filename of a file that contains annotations this method returns - # a hash with a single entry that maps +file+ to an array of its annotations. - # Otherwise it returns an empty hash. - def extract_annotations_from(file, pattern) - lineno = 0 - result = File.readlines(file).inject([]) do |list, line| - lineno += 1 - next list unless line =~ pattern - list << Annotation.new(lineno, $1, $2) - end - result.empty? ? {} : { file => result } - end - - # Prints the mapping from filenames to annotations in +results+ ordered by filename. - # The +options+ hash is passed to each annotation's +to_s+. - def display(results, options={}) - results.keys.sort.each do |file| - puts "#{file}:" - results[file].each do |note| - puts " * #{note.to_s(options)}" - end - puts - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/tasks/annotations.rake b/vendor/rails/railties/lib/tasks/annotations.rake deleted file mode 100644 index 48ac4009..00000000 --- a/vendor/rails/railties/lib/tasks/annotations.rake +++ /dev/null @@ -1,20 +0,0 @@ -require 'source_annotation_extractor' - -desc "Enumerate all annotations" -task :notes do - SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true -end - -namespace :notes do - ["OPTIMIZE", "FIXME", "TODO"].each do |annotation| - desc "Enumerate all #{annotation} annotations" - task annotation.downcase.intern do - SourceAnnotationExtractor.enumerate annotation - end - end - - desc "Enumerate a custom annotation, specify with ANNOTATION=WTFHAX" - task :custom do - SourceAnnotationExtractor.enumerate ENV['ANNOTATION'] - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/tasks/databases.rake b/vendor/rails/railties/lib/tasks/databases.rake deleted file mode 100644 index 1cf24343..00000000 --- a/vendor/rails/railties/lib/tasks/databases.rake +++ /dev/null @@ -1,436 +0,0 @@ -namespace :db do - task :load_config => :rails_env do - require 'active_record' - ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration - end - - namespace :create do - desc 'Create all the local databases defined in config/database.yml' - task :all => :load_config do - ActiveRecord::Base.configurations.each_value do |config| - # Skip entries that don't have a database key, such as the first entry here: - # - # defaults: &defaults - # adapter: mysql - # username: root - # password: - # host: localhost - # - # development: - # database: blog_development - # <<: *defaults - next unless config['database'] - # Only connect to local databases - local_database?(config) { create_database(config) } - end - end - end - - desc 'Create the database defined in config/database.yml for the current RAILS_ENV' - task :create => :load_config do - create_database(ActiveRecord::Base.configurations[RAILS_ENV]) - end - - def create_database(config) - begin - if config['adapter'] =~ /sqlite/ - if File.exist?(config['database']) - $stderr.puts "#{config['database']} already exists" - else - begin - # Create the SQLite database - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection - rescue - $stderr.puts $!, *($!.backtrace) - $stderr.puts "Couldn't create database for #{config.inspect}" - end - end - return # Skip the else clause of begin/rescue - else - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection - end - rescue - case config['adapter'] - when /^mysql/ - @charset = ENV['CHARSET'] || 'utf8' - @collation = ENV['COLLATION'] || 'utf8_unicode_ci' - begin - ActiveRecord::Base.establish_connection(config.merge('database' => nil)) - ActiveRecord::Base.connection.create_database(config['database'], :charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation)) - ActiveRecord::Base.establish_connection(config) - rescue - $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)" - end - when 'postgresql' - @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' - begin - ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) - ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding)) - ActiveRecord::Base.establish_connection(config) - rescue - $stderr.puts $!, *($!.backtrace) - $stderr.puts "Couldn't create database for #{config.inspect}" - end - end - else - $stderr.puts "#{config['database']} already exists" - end - end - - namespace :drop do - desc 'Drops all the local databases defined in config/database.yml' - task :all => :load_config do - ActiveRecord::Base.configurations.each_value do |config| - # Skip entries that don't have a database key - next unless config['database'] - # Only connect to local databases - local_database?(config) { drop_database(config) } - end - end - end - - desc 'Drops the database for the current RAILS_ENV' - task :drop => :load_config do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - drop_database(config) - end - - def local_database?(config, &block) - if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank? - yield - else - puts "This task only modifies local databases. #{config['database']} is on a remote host." - end - end - - - desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false." - task :migrate => :environment do - ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - - namespace :migrate do - desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.' - task :redo => :environment do - if ENV["VERSION"] - Rake::Task["db:migrate:down"].invoke - Rake::Task["db:migrate:up"].invoke - else - Rake::Task["db:rollback"].invoke - Rake::Task["db:migrate"].invoke - end - end - - desc 'Resets your database using your migrations for the current environment' - task :reset => ["db:drop", "db:create", "db:migrate"] - - desc 'Runs the "up" for a given migration VERSION.' - task :up => :environment do - version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - raise "VERSION is required" unless version - ActiveRecord::Migrator.run(:up, "db/migrate/", version) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - - desc 'Runs the "down" for a given migration VERSION.' - task :down => :environment do - version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - raise "VERSION is required" unless version - ActiveRecord::Migrator.run(:down, "db/migrate/", version) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - end - - desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n' - task :rollback => :environment do - step = ENV['STEP'] ? ENV['STEP'].to_i : 1 - ActiveRecord::Migrator.rollback('db/migrate/', step) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - - desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' - task :reset => [ 'db:drop', 'db:setup' ] - - desc "Retrieves the charset for the current environment's database" - task :charset => :environment do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - case config['adapter'] - when /^mysql/ - ActiveRecord::Base.establish_connection(config) - puts ActiveRecord::Base.connection.charset - when 'postgresql' - ActiveRecord::Base.establish_connection(config) - puts ActiveRecord::Base.connection.encoding - else - puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - end - - desc "Retrieves the collation for the current environment's database" - task :collation => :environment do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - case config['adapter'] - when /^mysql/ - ActiveRecord::Base.establish_connection(config) - puts ActiveRecord::Base.connection.collation - else - puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - end - - desc "Retrieves the current schema version number" - task :version => :environment do - puts "Current version: #{ActiveRecord::Migrator.current_version}" - end - - desc "Raises an error if there are pending migrations" - task :abort_if_pending_migrations => :environment do - if defined? ActiveRecord - pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations - - if pending_migrations.any? - puts "You have #{pending_migrations.size} pending migrations:" - pending_migrations.each do |pending_migration| - puts ' %4d %s' % [pending_migration.version, pending_migration.name] - end - abort %{Run "rake db:migrate" to update your database then try again.} - end - end - end - - desc 'Create the database, load the schema, and initialize with the seed data' - task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] - - desc 'Load the seed data from db/seeds.rb' - task :seed => :environment do - seed_file = File.join(Rails.root, 'db', 'seeds.rb') - load(seed_file) if File.exist?(seed_file) - end - - namespace :fixtures do - desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." - task :load => :environment do - require 'active_record/fixtures' - ActiveRecord::Base.establish_connection(Rails.env) - base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') - fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir - - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| - Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) - end - end - - desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." - task :identify => :environment do - require "active_record/fixtures" - - label, id = ENV["LABEL"], ENV["ID"] - raise "LABEL or ID required" if label.blank? && id.blank? - - puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label - - base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') - Dir["#{base_dir}/**/*.yml"].each do |file| - if data = YAML::load(ERB.new(IO.read(file)).result) - data.keys.each do |key| - key_id = Fixtures.identify(key) - - if key == label || key_id == id.to_i - puts "#{file}: #{key} (#{key_id})" - end - end - end - end - end - end - - namespace :schema do - desc "Create a db/schema.rb file that can be portably used against any DB supported by AR" - task :dump => :environment do - require 'active_record/schema_dumper' - File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file| - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file) - end - Rake::Task["db:schema:dump"].reenable - end - - desc "Load a schema.rb file into the database" - task :load => :environment do - file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb" - if File.exists?(file) - load(file) - else - abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{RAILS_ROOT}/config/environment.rb to prevent active_record from loading: config.frameworks -= [ :active_record ]} - end - end - end - - namespace :structure do - desc "Dump the database structure to a SQL file" - task :dump => :environment do - abcs = ActiveRecord::Base.configurations - case abcs[RAILS_ENV]["adapter"] - when /^mysql/, "oci", "oracle" - ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) - File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } - when "postgresql" - ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"] - ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"] - ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"] - search_path = abcs[RAILS_ENV]["schema_search_path"] - search_path = "--schema=#{search_path}" if search_path - `pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}` - raise "Error dumping database" if $?.exitstatus == 1 - when "sqlite", "sqlite3" - dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"] - `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql` - when "sqlserver" - `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r` - `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r` - when "firebird" - set_firebird_env(abcs[RAILS_ENV]) - db_string = firebird_db_string(abcs[RAILS_ENV]) - sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql" - else - raise "Task not supported by '#{abcs["test"]["adapter"]}'" - end - - if ActiveRecord::Base.connection.supports_migrations? - File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } - end - end - end - - namespace :test do - desc "Recreate the test database from the current schema.rb" - task :load => 'db:test:purge' do - ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) - ActiveRecord::Schema.verbose = false - Rake::Task["db:schema:load"].invoke - end - - desc "Recreate the test database from the current environment's database schema" - task :clone => %w(db:schema:dump db:test:load) - - desc "Recreate the test databases from the development structure" - task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do - abcs = ActiveRecord::Base.configurations - case abcs["test"]["adapter"] - when /^mysql/ - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') - IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table| - ActiveRecord::Base.connection.execute(table) - end - when "postgresql" - ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] - ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] - ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] - `psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` - when "sqlite", "sqlite3" - dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] - `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql` - when "sqlserver" - `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when "oci", "oracle" - ActiveRecord::Base.establish_connection(:test) - IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl| - ActiveRecord::Base.connection.execute(ddl) - end - when "firebird" - set_firebird_env(abcs["test"]) - db_string = firebird_db_string(abcs["test"]) - sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}" - else - raise "Task not supported by '#{abcs["test"]["adapter"]}'" - end - end - - desc "Empty the test database" - task :purge => :environment do - abcs = ActiveRecord::Base.configurations - case abcs["test"]["adapter"] - when /^mysql/ - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"]) - when "postgresql" - ActiveRecord::Base.clear_active_connections! - drop_database(abcs['test']) - create_database(abcs['test']) - when "sqlite", "sqlite3" - dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] - File.delete(dbfile) if File.exist?(dbfile) - when "sqlserver" - dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-') - `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}` - `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when "oci", "oracle" - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl| - ActiveRecord::Base.connection.execute(ddl) - end - when "firebird" - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.recreate_database! - else - raise "Task not supported by '#{abcs["test"]["adapter"]}'" - end - end - - desc 'Check for pending migrations and load the test schema' - task :prepare => 'db:abort_if_pending_migrations' do - if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? - Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke - end - end - end - - namespace :sessions do - desc "Creates a sessions migration for use with ActiveRecord::SessionStore" - task :create => :environment do - raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? - require 'rails_generator' - require 'rails_generator/scripts/generate' - Rails::Generator::Scripts::Generate.new.run(["session_migration", ENV["MIGRATION"] || "CreateSessions"]) - end - - desc "Clear the sessions table" - task :clear => :environment do - ActiveRecord::Base.connection.execute "DELETE FROM #{session_table_name}" - end - end -end - -def drop_database(config) - begin - case config['adapter'] - when /^mysql/ - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection.drop_database config['database'] - when /^sqlite/ - FileUtils.rm(File.join(RAILS_ROOT, config['database'])) - when 'postgresql' - ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) - ActiveRecord::Base.connection.drop_database config['database'] - end - rescue Exception => e - puts "Couldn't drop #{config['database']} : #{e.inspect}" - end -end - -def session_table_name - ActiveRecord::Base.pluralize_table_names ? :sessions : :session -end - -def set_firebird_env(config) - ENV["ISC_USER"] = config["username"].to_s if config["username"] - ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"] -end - -def firebird_db_string(config) - FireRuby::Database.db_string_for(config.symbolize_keys) -end diff --git a/vendor/rails/railties/lib/tasks/documentation.rake b/vendor/rails/railties/lib/tasks/documentation.rake deleted file mode 100644 index b3111a5a..00000000 --- a/vendor/rails/railties/lib/tasks/documentation.rake +++ /dev/null @@ -1,93 +0,0 @@ -begin - require 'rdoc/task' -namespace :doc do - desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" - RDoc::Task.new("app") { |rdoc| - rdoc.rdoc_dir = 'doc/app' - rdoc.template = ENV['template'] if ENV['template'] - rdoc.title = ENV['title'] || "Rails Application Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.options << '--charset' << 'utf-8' - rdoc.rdoc_files.include('doc/README_FOR_APP') - rdoc.rdoc_files.include('app/**/*.rb') - rdoc.rdoc_files.include('lib/**/*.rb') - } - - desc "Generate documentation for the Rails framework" - RDoc::Task.new("rails") { |rdoc| - rdoc.rdoc_dir = 'doc/api' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.title = "Rails Framework Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE') - rdoc.rdoc_files.include('vendor/rails/railties/README') - rdoc.rdoc_files.include('vendor/rails/railties/lib/{*.rb,commands/*.rb,rails_generator/*.rb}') - rdoc.rdoc_files.include('vendor/rails/activerecord/README') - rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb') - rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*') - rdoc.rdoc_files.include('vendor/rails/activeresource/README') - rdoc.rdoc_files.include('vendor/rails/activeresource/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/activeresource/lib/active_resource.rb') - rdoc.rdoc_files.include('vendor/rails/activeresource/lib/active_resource/*') - rdoc.rdoc_files.include('vendor/rails/actionpack/README') - rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb') - rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb') - rdoc.rdoc_files.include('vendor/rails/actionmailer/README') - rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb') - rdoc.rdoc_files.include('vendor/rails/activesupport/README') - rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb') - } - - plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } - - desc "Generate documentation for all installed plugins" - task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" } - - desc "Remove plugin documentation" - task :clobber_plugins do - rm_rf 'doc/plugins' rescue nil - end - - desc "Generate Rails guides" - task :guides do - require File.join(RAILTIES_PATH, "guides/rails_guides") - RailsGuides::Generator.new(File.join(RAILS_ROOT, "doc/guides")).generate - end - - namespace :plugins do - # Define doc tasks for each plugin - plugins.each do |plugin| - desc "Generate documentation for the #{plugin} plugin" - task(plugin => :environment) do - plugin_base = "vendor/plugins/#{plugin}" - options = [] - files = Rake::FileList.new - options << "-o doc/plugins/#{plugin}" - options << "--title '#{plugin.titlecase} Plugin Documentation'" - options << '--line-numbers' << '--inline-source' - options << '--charset' << 'utf-8' - options << '-T html' - - files.include("#{plugin_base}/lib/**/*.rb") - if File.exist?("#{plugin_base}/README") - files.include("#{plugin_base}/README") - options << "--main '#{plugin_base}/README'" - end - files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG") - - options << files.to_s - - sh %(rdoc #{options * ' '}) - end - end - end -end -rescue LoadError - $stderr.puts 'Please install RDoc 2.4.2+ to generate documentation.' -end diff --git a/vendor/rails/railties/lib/tasks/framework.rake b/vendor/rails/railties/lib/tasks/framework.rake deleted file mode 100644 index 76ee9aff..00000000 --- a/vendor/rails/railties/lib/tasks/framework.rake +++ /dev/null @@ -1,146 +0,0 @@ -namespace :rails do - namespace :freeze do - desc "Lock this application to the current gems (by unpacking them into vendor/rails)" - task :gems do - deps = %w(actionpack activerecord actionmailer activesupport activeresource) - require 'rubygems' - require 'rubygems/gem_runner' - - rails = (version = ENV['VERSION']) ? - Gem.cache.find_name('rails', "= #{version}").first : - Gem.cache.find_name('rails').sort_by { |g| g.version }.last - - version ||= rails.version - - unless rails - puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available." - exit - end - - puts "Freezing to the gems for Rails #{rails.version}" - rm_rf "vendor/rails" - mkdir_p "vendor/rails" - - begin - chdir("vendor/rails") do - rails.dependencies.select { |g| deps.include? g.name }.each do |g| - Gem::GemRunner.new.run(["unpack", g.name, "--version", g.respond_to?(:requirement) ? g.requirement.to_s : g.version_requirements.to_s]) - mv(Dir.glob("#{g.name}*").first, g.name) - end - - Gem::GemRunner.new.run(["unpack", "rails", "--version", "=#{version}"]) - FileUtils.mv(Dir.glob("rails*").first, "railties") - end - rescue Exception - rm_rf "vendor/rails" - raise - end - end - - desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0' - task :edge do - require 'open-uri' - version = ENV["RELEASE"] || "edge" - target = "rails_#{version}.zip" - commits = "http://github.com/api/v1/yaml/rails/rails/commits/master" - url = "http://dev.rubyonrails.org/archives/#{target}" - - chdir 'vendor' do - latest_revision = YAML.load(open(commits))["commits"].first["id"] - - puts "Downloading Rails from #{url}" - File.open('rails.zip', 'wb') do |dst| - open url do |src| - while chunk = src.read(4096) - dst << chunk - end - end - end - - puts 'Unpacking Rails' - rm_rf 'rails' - `unzip rails.zip` - %w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner| - rm_f goner - end - - puts "Frozen to git revision #{latest_revision}" - File.open('rails/REVISION', 'w') do |revision| - revision.puts latest_revision - end - end - - puts 'Updating current scripts, javascripts, and configuration settings' - Rake::Task['rails:update'].invoke - end - end - - desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems" - task :unfreeze do - rm_rf "vendor/rails" - end - - desc "Update both configs, scripts and public/javascripts from Rails" - task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ] - - desc "Applies the template supplied by LOCATION=/path/to/template" - task :template do - require 'rails_generator/generators/applications/app/template_runner' - Rails::TemplateRunner.new(ENV["LOCATION"]) - end - - namespace :update do - desc "Add new scripts to the application script/ directory" - task :scripts do - local_base = "script" - edge_base = "#{File.dirname(__FILE__)}/../../bin" - - local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) } - edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) } - - edge.each do |script| - base_name = script[(edge_base.length+1)..-1] - next if base_name == "rails" - next if local.detect { |path| base_name == path[(local_base.length+1)..-1] } - if !File.directory?("#{local_base}/#{File.dirname(base_name)}") - mkdir_p "#{local_base}/#{File.dirname(base_name)}" - end - install script, "#{local_base}/#{base_name}", :mode => 0755 - end - end - - desc "Update your javascripts from your current rails install" - task :javascripts do - require 'railties_path' - project_dir = RAILS_ROOT + '/public/javascripts/' - scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js'] - scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js') - FileUtils.cp(scripts, project_dir) - end - - desc "Update config/boot.rb from your current rails install" - task :configs do - require 'railties_path' - FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb') - end - - desc "Rename application.rb to application_controller.rb" - task :application_controller do - old_style = RAILS_ROOT + '/app/controllers/application.rb' - new_style = RAILS_ROOT + '/app/controllers/application_controller.rb' - if File.exists?(old_style) && !File.exists?(new_style) - FileUtils.mv(old_style, new_style) - puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary" - end - end - - desc "Generate dispatcher files in RAILS_ROOT/public" - task :generate_dispatchers do - require 'railties_path' - FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi') - end - end -end diff --git a/vendor/rails/railties/lib/tasks/gems.rake b/vendor/rails/railties/lib/tasks/gems.rake deleted file mode 100644 index f1c34c7c..00000000 --- a/vendor/rails/railties/lib/tasks/gems.rake +++ /dev/null @@ -1,78 +0,0 @@ -desc "List the gems that this rails application depends on" -task :gems => 'gems:base' do - Rails.configuration.gems.each do |gem| - print_gem_status(gem) - end - puts - puts "I = Installed" - puts "F = Frozen" - puts "R = Framework (loaded before rails starts)" -end - -namespace :gems do - task :base do - $gems_rake_task = true - require 'rubygems' - require 'rubygems/gem_runner' - Rake::Task[:environment].invoke - end - - desc "Build any native extensions for unpacked gems" - task :build do - $gems_build_rake_task = true - frozen_gems.each { |gem| gem.build } - end - - namespace :build do - desc "Force the build of all gems" - task :force do - $gems_build_rake_task = true - frozen_gems.each { |gem| gem.build(:force => true) } - end - end - - desc "Installs all required gems." - task :install => :base do - current_gems.each { |gem| gem.install } - end - - desc "Unpacks all required gems into vendor/gems." - task :unpack => :install do - current_gems.each { |gem| gem.unpack } - end - - namespace :unpack do - desc "Unpacks all required gems and their dependencies into vendor/gems." - task :dependencies => :install do - current_gems.each { |gem| gem.unpack(:recursive => true) } - end - end - - desc "Regenerate gem specifications in correct format." - task :refresh_specs do - frozen_gems(false).each { |gem| gem.refresh } - end -end - -def current_gems - gems = Rails.configuration.gems - gems = gems.select { |gem| gem.name == ENV['GEM'] } unless ENV['GEM'].blank? - gems -end - -def frozen_gems(load_specs=true) - Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*-*')].map do |gem_dir| - Rails::GemDependency.from_directory_name(gem_dir, load_specs) - end -end - -def print_gem_status(gem, indent=1) - code = case - when gem.framework_gem? then 'R' - when gem.frozen? then 'F' - when gem.installed? then 'I' - else ' ' - end - puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}" - gem.dependencies.each { |g| print_gem_status(g, indent+1) } -end diff --git a/vendor/rails/railties/lib/tasks/log.rake b/vendor/rails/railties/lib/tasks/log.rake deleted file mode 100644 index 6e133469..00000000 --- a/vendor/rails/railties/lib/tasks/log.rake +++ /dev/null @@ -1,9 +0,0 @@ -namespace :log do - desc "Truncates all *.log files in log/ to zero bytes" - task :clear do - FileList["log/*.log"].each do |log_file| - f = File.open(log_file, "w") - f.close - end - end -end diff --git a/vendor/rails/railties/lib/tasks/middleware.rake b/vendor/rails/railties/lib/tasks/middleware.rake deleted file mode 100644 index 05f15918..00000000 --- a/vendor/rails/railties/lib/tasks/middleware.rake +++ /dev/null @@ -1,7 +0,0 @@ -desc 'Prints out your Rack middleware stack' -task :middleware => :environment do - ActionController::Dispatcher.middleware.active.each do |middleware| - puts "use #{middleware.inspect}" - end - puts "run ActionController::Dispatcher.new" -end diff --git a/vendor/rails/railties/lib/tasks/misc.rake b/vendor/rails/railties/lib/tasks/misc.rake deleted file mode 100644 index 9e6f96db..00000000 --- a/vendor/rails/railties/lib/tasks/misc.rake +++ /dev/null @@ -1,63 +0,0 @@ -task :default => :test -task :environment do - $rails_rake_task = true - require(File.join(RAILS_ROOT, 'config', 'environment')) -end - -task :rails_env do - unless defined? RAILS_ENV - RAILS_ENV = ENV['RAILS_ENV'] ||= 'development' - end -end - -desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.' -task :secret do - puts ActiveSupport::SecureRandom.hex(64) -end - -require 'active_support' -namespace :time do - namespace :zones do - desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' - task :all do - build_time_zone_list(:all) - end - - desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' - task :us do - build_time_zone_list(:us_zones) - end - - desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time' - task :local do - jan_offset = Time.now.beginning_of_year.utc_offset - jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset - offset = jan_offset < jul_offset ? jan_offset : jul_offset - build_time_zone_list(:all, offset) - end - - # to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600 - def build_time_zone_list(method, offset = ENV['OFFSET']) - if offset - offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/) - sign = $1 == '-' ? -1 : 1 - hours, minutes = $2.to_f, $3.to_f - ((hours * 3600) + (minutes.to_f * 60)) * sign - elsif offset.to_f.abs <= 13 - offset.to_f * 3600 - else - offset.to_f - end - end - previous_offset = nil - ActiveSupport::TimeZone.__send__(method).each do |zone| - if offset.nil? || offset == zone.utc_offset - puts "\n* UTC #{zone.formatted_offset} *" unless zone.utc_offset == previous_offset - puts zone.name - previous_offset = zone.utc_offset - end - end - puts "\n" - end - end -end diff --git a/vendor/rails/railties/lib/tasks/rails.rb b/vendor/rails/railties/lib/tasks/rails.rb deleted file mode 100644 index b9bc099f..00000000 --- a/vendor/rails/railties/lib/tasks/rails.rb +++ /dev/null @@ -1,14 +0,0 @@ -$VERBOSE = nil - -# Load Rails rakefile extensions -Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext } - -# Load any custom rakefile extensions -deprecated_paths = Dir["#{RAILS_ROOT}/vendor/plugins/*/tasks/**/*.rake"].sort -if deprecated_paths.any? - plugins = deprecated_paths.map { |p| $1 if p =~ %r((vendor/plugins/[^/]+/tasks)) }.compact - ActiveSupport::Deprecation.warn "Rake tasks in #{plugins.to_sentence} are deprecated. Use lib/tasks instead." - deprecated_paths.each { |ext| load ext } -end -Dir["#{RAILS_ROOT}/vendor/plugins/*/lib/tasks/**/*.rake"].sort.each { |ext| load ext } -Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } diff --git a/vendor/rails/railties/lib/tasks/routes.rake b/vendor/rails/railties/lib/tasks/routes.rake deleted file mode 100644 index abbf3258..00000000 --- a/vendor/rails/railties/lib/tasks/routes.rake +++ /dev/null @@ -1,18 +0,0 @@ -desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.' -task :routes => :environment do - all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes - routes = all_routes.collect do |route| - name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s - verb = route.conditions[:method].to_s.upcase - segs = route.segments.inject("") { |str,s| str << s.to_s } - segs.chop! if segs.length > 1 - reqs = route.requirements.empty? ? "" : route.requirements.inspect - {:name => name, :verb => verb, :segs => segs, :reqs => reqs} - end - name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max - verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max - segs_width = routes.collect {|r| r[:segs]}.collect {|s| s.length}.max - routes.each do |r| - puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:segs].ljust(segs_width)} #{r[:reqs]}" - end -end diff --git a/vendor/rails/railties/lib/tasks/statistics.rake b/vendor/rails/railties/lib/tasks/statistics.rake deleted file mode 100644 index 5ab27a0f..00000000 --- a/vendor/rails/railties/lib/tasks/statistics.rake +++ /dev/null @@ -1,17 +0,0 @@ -STATS_DIRECTORIES = [ - %w(Controllers app/controllers), - %w(Helpers app/helpers), - %w(Models app/models), - %w(Libraries lib/), - %w(APIs app/apis), - %w(Integration\ tests test/integration), - %w(Functional\ tests test/functional), - %w(Unit\ tests test/unit) - -].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } - -desc "Report code statistics (KLOCs, etc) from the application" -task :stats do - require 'code_statistics' - CodeStatistics.new(*STATS_DIRECTORIES).to_s -end diff --git a/vendor/rails/railties/lib/tasks/testing.rake b/vendor/rails/railties/lib/tasks/testing.rake deleted file mode 100644 index fd5e52a0..00000000 --- a/vendor/rails/railties/lib/tasks/testing.rake +++ /dev/null @@ -1,139 +0,0 @@ -TEST_CHANGES_SINCE = Time.now - 600 - -# Look up tests for recently modified sources. -def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago) - FileList[source_pattern].map do |path| - if File.mtime(path) > touched_since - tests = [] - source_dir = File.dirname(path).split("/") - source_file = File.basename(path, '.rb') - - # Support subdirs in app/models and app/controllers - modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path - - # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb - test = "#{modified_test_path}/#{source_file}_test.rb" - tests.push test if File.exist?(test) - - # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb - test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}" - FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test) - - return tests - - end - end.flatten.compact -end - - -# Recreated here from ActiveSupport because :uncommitted needs it before Rails is available -module Kernel - def silence_stderr - old_stderr = STDERR.dup - STDERR.reopen(RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'NUL:' : '/dev/null') - STDERR.sync = true - yield - ensure - STDERR.reopen(old_stderr) - end -end - -desc 'Run all unit, functional and integration tests' -task :test do - errors = %w(test:units test:functionals test:integration).collect do |task| - begin - Rake::Task[task].invoke - nil - rescue => e - task - end - end.compact - abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? -end - -namespace :test do - Rake::TestTask.new(:recent => "db:test:prepare") do |t| - since = TEST_CHANGES_SINCE - touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + - recent_tests('app/models/**/*.rb', 'test/unit', since) + - recent_tests('app/controllers/**/*.rb', 'test/functional', since) - - t.libs << 'test' - t.verbose = true - t.test_files = touched.uniq - end - Rake::Task['test:recent'].comment = "Test recent changes" - - Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t| - def t.file_list - if File.directory?(".svn") - changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] } - elsif File.directory?(".git") - changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.map { |path| path.chomp } - else - abort "Not a Subversion or Git checkout." - end - - models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ } - controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ } - - unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } - functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" } - - unit_tests.uniq + functional_tests.uniq - end - - t.libs << 'test' - t.verbose = true - end - Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - - Rake::TestTask.new(:units => "db:test:prepare") do |t| - t.libs << "test" - t.pattern = 'test/unit/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:units'].comment = "Run the unit tests in test/unit" - - Rake::TestTask.new(:functionals => "db:test:prepare") do |t| - t.libs << "test" - t.pattern = 'test/functional/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" - - Rake::TestTask.new(:integration => "db:test:prepare") do |t| - t.libs << "test" - t.pattern = 'test/integration/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - - Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| - t.libs << 'test' - t.pattern = 'test/performance/**/*_test.rb' - t.verbose = true - t.options = '-- --benchmark' - end - Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - - Rake::TestTask.new(:profile => 'db:test:prepare') do |t| - t.libs << 'test' - t.pattern = 'test/performance/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:profile'].comment = 'Profile the performance tests' - - Rake::TestTask.new(:plugins => :environment) do |t| - t.libs << "test" - - if ENV['PLUGIN'] - t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb" - else - t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb' - end - - t.verbose = true - end - Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)" -end diff --git a/vendor/rails/railties/lib/tasks/tmp.rake b/vendor/rails/railties/lib/tasks/tmp.rake deleted file mode 100644 index fea15058..00000000 --- a/vendor/rails/railties/lib/tasks/tmp.rake +++ /dev/null @@ -1,37 +0,0 @@ -namespace :tmp do - desc "Clear session, cache, and socket files from tmp/" - task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"] - - desc "Creates tmp directories for sessions, cache, sockets, and pids" - task :create do - FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids )) - end - - namespace :sessions do - desc "Clears all files in tmp/sessions" - task :clear do - FileUtils.rm(Dir['tmp/sessions/[^.]*']) - end - end - - namespace :cache do - desc "Clears all files and directories in tmp/cache" - task :clear do - FileUtils.rm_rf(Dir['tmp/cache/[^.]*']) - end - end - - namespace :sockets do - desc "Clears all files in tmp/sockets" - task :clear do - FileUtils.rm(Dir['tmp/sockets/[^.]*']) - end - end - - namespace :pids do - desc "Clears all files in tmp/pids" - task :clear do - FileUtils.rm(Dir['tmp/pids/[^.]*']) - end - end -end diff --git a/vendor/rails/railties/lib/test_help.rb b/vendor/rails/railties/lib/test_help.rb deleted file mode 100644 index f8608925..00000000 --- a/vendor/rails/railties/lib/test_help.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Make double-sure the RAILS_ENV is set to test, -# so fixtures are loaded to the right database -silence_warnings { RAILS_ENV = "test" } - -require 'test/unit' -require 'action_controller/test_case' -require 'action_view/test_case' -require 'action_controller/integration' -require 'action_mailer/test_case' if defined?(ActionMailer) - -if defined?(ActiveRecord) - require 'active_record/test_case' - require 'active_record/fixtures' - - class ActiveSupport::TestCase - include ActiveRecord::TestFixtures - self.fixture_path = "#{RAILS_ROOT}/test/fixtures/" - self.use_instantiated_fixtures = false - self.use_transactional_fixtures = true - end - - ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path - - def create_fixtures(*table_names, &block) - Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block) - end -end - -begin - require_library_or_gem 'ruby-debug' - Debugger.start - if Debugger.respond_to?(:settings) - Debugger.settings[:autoeval] = true - Debugger.settings[:autolist] = 1 - end -rescue LoadError - # ruby-debug wasn't available so neither can the debugging be -end diff --git a/vendor/rails/railties/lib/webrick_server.rb b/vendor/rails/railties/lib/webrick_server.rb deleted file mode 100644 index 2f60151b..00000000 --- a/vendor/rails/railties/lib/webrick_server.rb +++ /dev/null @@ -1,156 +0,0 @@ -# Donated by Florian Gross - -require 'webrick' -require 'cgi' -require 'stringio' -require 'dispatcher' - -include WEBrick - -class CGI #:nodoc: - def stdinput - @stdin || $stdin - end - - def env_table - @env_table || ENV - end - - def initialize(type = "query", table = nil, stdin = nil) - @env_table, @stdin = table, stdin - - if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE") - Apache.request.setup_cgi_env - end - - extend QueryExtension - @multipart = false - if defined?(CGI_PARAMS) - warn "do not use CGI_PARAMS and CGI_COOKIES" - @params = CGI_PARAMS.dup - @cookies = CGI_COOKIES.dup - else - initialize_query() # set @params, @cookies - end - @output_cookies = nil - @output_hidden = nil - end -end - -# A custom dispatch servlet for use with WEBrick. It dispatches requests -# (using the Rails Dispatcher) to the appropriate controller/action. By default, -# it restricts WEBrick to a managing a single Rails request at a time, but you -# can change this behavior by setting ActionController::Base.allow_concurrency -# to true. -class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet - # Start the WEBrick server with the given options, mounting the - # DispatchServlet at <tt>/</tt>. - def self.dispatch(options = {}) - Socket.do_not_reverse_lookup = true # patch for OS X - - params = { :Port => options[:port].to_i, - :ServerType => options[:server_type], - :BindAddress => options[:ip] } - params[:MimeTypes] = options[:mime_types] if options[:mime_types] - - server = WEBrick::HTTPServer.new(params) - server.mount('/', DispatchServlet, options) - - trap("INT") { server.shutdown } - server.start - end - - def initialize(server, options) #:nodoc: - @server_options = options - @file_handler = WEBrick::HTTPServlet::FileHandler.new(server, options[:server_root]) - # Change to the RAILS_ROOT, since Webrick::Daemon.start does a Dir::cwd("/") - # OPTIONS['working_directory'] is an absolute path of the RAILS_ROOT, set in railties/lib/commands/servers/webrick.rb - Dir.chdir(OPTIONS['working_directory']) if defined?(OPTIONS) && File.directory?(OPTIONS['working_directory']) - super - end - - def service(req, res) #:nodoc: - unless handle_file(req, res) - unless handle_dispatch(req, res) - raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." - end - end - end - - def handle_file(req, res) #:nodoc: - begin - req = req.dup - path = req.path.dup - - # Add .html if the last path piece has no . in it - path << '.html' if path != '/' && (%r{(^|/)[^./]+$} =~ path) - path.gsub!('+', ' ') # Unescape + since FileHandler doesn't do so. - - req.instance_variable_set(:@path_info, path) # Set the modified path... - - @file_handler.send(:service, req, res) - return true - rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err - res.set_error(err) - return true - rescue => err - return false - end - end - - def handle_dispatch(req, res, origin = nil) #:nodoc: - data = StringIO.new - Dispatcher.dispatch( - CGI.new("query", create_env_table(req, origin), StringIO.new(req.body || "")), - ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, - data - ) - - header, body = extract_header_and_body(data) - - set_charset(header) - assign_status(res, header) - res.cookies.concat(header.delete('set-cookie') || []) - header.each { |key, val| res[key] = val.join(", ") } - - res.body = body - return true - rescue => err - p err, err.backtrace - return false - end - - private - def create_env_table(req, origin) - env = req.meta_vars.clone - env.delete "SCRIPT_NAME" - env["QUERY_STRING"] = req.request_uri.query - env["REQUEST_URI"] = origin if origin - return env - end - - def extract_header_and_body(data) - data.rewind - data = data.read - - raw_header, body = *data.split(/^[\xd\xa]{2}/on, 2) - header = WEBrick::HTTPUtils::parse_header(raw_header) - - return header, body - end - - def set_charset(header) - ct = header["content-type"] - if ct.any? { |x| x =~ /^text\// } && ! ct.any? { |x| x =~ /charset=/ } - ch = @server_options[:charset] || "UTF-8" - ct.find { |x| x =~ /^text\// } << ("; charset=" + ch) - end - end - - def assign_status(res, header) - if /^(\d+)/ =~ header['status'][0] - res.status = $1.to_i - header.delete('status') - end - end -end diff --git a/vendor/rails/railties/tags b/vendor/rails/railties/tags deleted file mode 100644 index b79f0943..00000000 --- a/vendor/rails/railties/tags +++ /dev/null @@ -1,2260 +0,0 @@ -!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ -!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ -!_TAG_PROGRAM_NAME Exuberant Ctags // -!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ -!_TAG_PROGRAM_VERSION 5.8 // -%name%.rb lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb 1;" F -%name%_test.rb lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb 1;" F -+ lib/rails/initializable.rb /^ def +(other)$/;" f class:Rails.Initializable.Collection -404.html lib/rails/generators/rails/app/templates/public/404.html 1;" F -404.html tmp/app/public/404.html 1;" F -404.html tmp/app_template/public/404.html 1;" F -422.html lib/rails/generators/rails/app/templates/public/422.html 1;" F -422.html tmp/app/public/422.html 1;" F -422.html tmp/app_template/public/422.html 1;" F -500.html lib/rails/generators/rails/app/templates/public/500.html 1;" F -500.html tmp/app/public/500.html 1;" F -500.html tmp/app_template/public/500.html 1;" F -ActionController lib/rails/test_help.rb /^class ActionController::TestCase$/;" c -ActionController test/rails_info_controller_test.rb /^module ActionController$/;" m -ActionDispatch lib/rails/test_help.rb /^class ActionDispatch::IntegrationTest$/;" c -ActionMethods lib/rails/generators/rails/app/app_generator.rb /^ module ActionMethods$/;" m class:Rails -Actions lib/rails/generators/actions.rb /^ module Actions$/;" m class:Rails.Generators -ActionsTest test/generators/actions_test.rb /^class ActionsTest < Rails::Generators::TestCase$/;" c -ActiveModel lib/rails/generators/active_model.rb /^ class ActiveModel$/;" c class:Rails.Generators -ActiveRecord test/fixtures/lib/generators/active_record/fixjour_generator.rb /^module ActiveRecord$/;" m -ActiveRecord test/generators/named_base_test.rb /^module ActiveRecord$/;" m -ActiveSupport lib/rails/test_help.rb /^ class ActiveSupport::TestCase$/;" c -ActiveSupport tmp/app/test/test_helper.rb /^class ActiveSupport::TestCase$/;" c -ActiveSupport tmp/app_template/test/test_helper.rb /^class ActiveSupport::TestCase$/;" c -AddLastNameToUsers test/railties/shared_tests.rb /^ class AddLastNameToUsers < ActiveRecord::Migration$/;" c class:RailtiesTest.SharedTests.test_copying_migrations -Admin test/application/routing_test.rb /^ module Admin$/;" m -Admin test/railties/shared_tests.rb /^ class Admin::Foo::BarController < ApplicationController$/;" c class:RailtiesTest.test_namespaced_controllers_with_namespaced_routes -Ajax.InPlaceCollectionEditor.DefaultOptions.loadingCollectionText lib/rails/generators/rails/app/templates/public/javascripts/controls.js /^Ajax.InPlaceCollectionEditor.DefaultOptions = {$/;" p -Ajax.InPlaceCollectionEditor.DefaultOptions.loadingCollectionText tmp/app/public/javascripts/controls.js /^Ajax.InPlaceCollectionEditor.DefaultOptions = {$/;" p -Ajax.InPlaceCollectionEditor.DefaultOptions.loadingCollectionText tmp/app_template/public/javascripts/controls.js /^Ajax.InPlaceCollectionEditor.DefaultOptions = {$/;" p -Ajax.InPlaceEditor lib/rails/generators/rails/app/templates/public/javascripts/controls.js /^});$/;" c -Ajax.InPlaceEditor tmp/app/public/javascripts/controls.js /^});$/;" c -Ajax.InPlaceEditor tmp/app_template/public/javascripts/controls.js /^});$/;" c -Ajax.InPlaceEditor.initialize lib/rails/generators/rails/app/templates/public/javascripts/controls.js /^Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {$/;" m -Ajax.InPlaceEditor.initialize tmp/app/public/javascripts/controls.js /^Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {$/;" m -Ajax.InPlaceEditor.initialize tmp/app_template/public/javascripts/controls.js /^Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {$/;" m -Annotation lib/rails/source_annotation_extractor.rb /^ class Annotation < Struct.new(:line, :tag, :text)$/;" c class:SourceAnnotationExtractor -AppBase lib/rails/generators/app_base.rb /^ class AppBase < Base$/;" c class:Rails.Generators -AppBuilder lib/rails/generators/rails/app/app_generator.rb /^ class AppBuilder$/;" c class:Rails -AppBuilder test/fixtures/lib/app_builders/empty_builder.rb /^class AppBuilder$/;" c -AppBuilder test/fixtures/lib/app_builders/simple_builder.rb /^class AppBuilder$/;" c -AppBuilder test/fixtures/lib/app_builders/tweak_builder.rb /^class AppBuilder < Rails::AppBuilder$/;" c -AppGenerator lib/rails/generators/rails/app/app_generator.rb /^ class AppGenerator < AppBase$/;" c class:Generators -AppGeneratorTest test/generators/app_generator_test.rb /^class AppGeneratorTest < Rails::Generators::TestCase$/;" c -AppTemplate test/railties/engine_test.rb /^ module AppTemplate$/;" m -AppTemplate tmp/app/config/application.rb /^module AppTemplate$/;" m -AppTemplate tmp/app_template/config/application.rb /^module AppTemplate$/;" m -Application lib/rails/application.rb /^ class Application < Engine$/;" c class:Rails -Application lib/rails/application/bootstrap.rb /^ class Application$/;" c class:Rails -Application lib/rails/application/configuration.rb /^ class Application$/;" c class:Rails -Application lib/rails/application/finisher.rb /^ class Application$/;" c class:Rails -Application lib/rails/application/railties.rb /^ class Application < Engine$/;" c class:Rails -Application lib/rails/application/routes_reloader.rb /^ class Application$/;" c class:Rails -Application lib/rails/generators/rails/app/templates/config/application.rb /^ class Application < Rails::Application$/;" c -Application test/abstract_unit.rb /^ class Application < Rails::Application$/;" c class:TestApp -Application test/initializable_test.rb /^ class Application$/;" c -Application tmp/app/config/application.rb /^ class Application < Rails::Application$/;" c class:AppTemplate -Application tmp/app_template/config/application.rb /^ class Application < Rails::Application$/;" c class:AppTemplate -ApplicationController lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb /^class ApplicationController < ActionController::Base$/;" c -ApplicationController test/application/initializers/frameworks_test.rb /^ class ApplicationController < ActionController::Base$/;" c -ApplicationController tmp/app/app/controllers/application_controller.rb /^class ApplicationController < ActionController::Base$/;" c -ApplicationController tmp/app_template/app/controllers/application_controller.rb /^class ApplicationController < ActionController::Base$/;" c -ApplicationGeneratingController test/railties/mounted_engine_test.rb /^ class ApplicationGeneratingController < ActionController::Base$/;" c class:ApplicationTests.ApplicationRoutingTest -ApplicationHelper lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb /^module ApplicationHelper$/;" m -ApplicationHelper test/application/initializers/frameworks_test.rb /^ module ApplicationHelper$/;" m -ApplicationHelper tmp/app/app/helpers/application_helper.rb /^module ApplicationHelper$/;" m -ApplicationHelper tmp/app_template/app/helpers/application_helper.rb /^module ApplicationHelper$/;" m -ApplicationRoutingTest test/railties/mounted_engine_test.rb /^ class ApplicationRoutingTest < Test::Unit::TestCase$/;" c class:ApplicationTests -ApplicationTests test/application/configuration_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/generators_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/boot_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/check_ruby_version_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/frameworks_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/hooks_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/i18n_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/load_path_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/initializers/notifications_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/middleware/best_practices_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/middleware/cache_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/middleware/remote_ip_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/middleware/sendfile_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/middleware_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/paths_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/rackup_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/rake_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/routing_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/runner_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/test_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/application/url_generation_test.rb /^module ApplicationTests$/;" m -ApplicationTests test/railties/mounted_engine_test.rb /^module ApplicationTests$/;" m -Autocompleter.Base lib/rails/generators/rails/app/templates/public/javascripts/controls.js /^});$/;" c -Autocompleter.Base tmp/app/public/javascripts/controls.js /^});$/;" c -Autocompleter.Base tmp/app_template/public/javascripts/controls.js /^});$/;" c -Autocompleter.Base.getTokenBounds lib/rails/generators/rails/app/templates/public/javascripts/controls.js /^Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {$/;" m -Autocompleter.Base.getTokenBounds tmp/app/public/javascripts/controls.js /^Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {$/;" m -Autocompleter.Base.getTokenBounds tmp/app_template/public/javascripts/controls.js /^Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {$/;" m -BacktraceCleaner lib/rails/backtrace_cleaner.rb /^ class BacktraceCleaner < ActiveSupport::BacktraceCleaner$/;" c class:Rails -BacktraceCleanerFilterTest test/backtrace_cleaner_test.rb /^ class BacktraceCleanerFilterTest < ActiveSupport::TestCase$/;" c -BacktraceCleanerVendorGemTest test/backtrace_cleaner_test.rb /^ class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase$/;" c -BacktraceFilterForTestUnit lib/rails/backtrace_cleaner.rb /^ module BacktraceFilterForTestUnit #:nodoc:$/;" m class:Rails -Bar test/initializable_test.rb /^ class Bar < Foo$/;" c class:InitializableTests -Bar test/railties/railtie_test.rb /^ class Bar < Foo; end$/;" c -BarController test/application/routing_test.rb /^ class BarController < ActionController::Base$/;" c -BarController test/railties/shared_tests.rb /^ class BarController < ActionController::Base$/;" c class:RailtiesTest.test_routes_in_plugins_have_lower_priority_than_application_ones -BarHelper test/application/initializers/frameworks_test.rb /^ module BarHelper$/;" m -BarHelper test/application/routing_test.rb /^ module BarHelper$/;" m -BarHelper test/railties/engine_test.rb /^ module BarHelper$/;" m -Base lib/rails/generators/base.rb /^ class Base < Thor::Group$/;" c class:Rails.Generators -Base lib/rails/generators/erb.rb /^ class Base < Rails::Generators::NamedBase #:nodoc:$/;" c class:Erb.Generators -Base lib/rails/generators/test_unit.rb /^ class Base < Rails::Generators::NamedBase #:nodoc:$/;" c class:TestUnit.Generators -Base test/generators/named_base_test.rb /^ class Base$/;" c class:ActiveRecord -Base test/rails_info_controller_test.rb /^ class Base$/;" c class:ActionController -Basic test/initializable_test.rb /^ class Basic < ActiveSupport::TestCase$/;" c -BeforeAfter test/initializable_test.rb /^ class BeforeAfter < ActiveSupport::TestCase$/;" c -BestPracticesTest test/application/middleware/best_practices_test.rb /^ class BestPracticesTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Blog test/railties/mounted_engine_test.rb /^ module Blog$/;" m class:ApplicationTests.ApplicationRoutingTest -Bootstrap lib/rails/application/bootstrap.rb /^ module Bootstrap$/;" m class:Rails.Application -BrowsingTest lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb /^class BrowsingTest < ActionDispatch::PerformanceTest$/;" c -BrowsingTest tmp/app/test/performance/browsing_test.rb /^class BrowsingTest < ActionDispatch::PerformanceTest$/;" c -BrowsingTest tmp/app_template/test/performance/browsing_test.rb /^class BrowsingTest < ActionDispatch::PerformanceTest$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushBash.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushCss.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushJava.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js /^ function Brush()$/;" f -Brush guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js /^ };$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushPython.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushSass.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushScala.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushSql.js /^ function Brush()$/;" c -Brush guides/assets/javascripts/syntaxhighlighter/shBrushXml.js /^ function Brush()$/;" c -Brush.fixComments guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js /^ function fixComments(match, regexInfo)$/;" f -Brush.getKeywordsCSS guides/assets/javascripts/syntaxhighlighter/shBrushCss.js /^ function getKeywordsCSS(str)$/;" f -Brush.getKeywordsCSS guides/assets/javascripts/syntaxhighlighter/shBrushSass.js /^ function getKeywordsCSS(str)$/;" f -Brush.getValuesCSS guides/assets/javascripts/syntaxhighlighter/shBrushCss.js /^ function getValuesCSS(str)$/;" f -Brush.getValuesCSS guides/assets/javascripts/syntaxhighlighter/shBrushSass.js /^ function getValuesCSS(str)$/;" f -Brush.process guides/assets/javascripts/syntaxhighlighter/shBrushXml.js /^ function process(match, regexInfo)$/;" f -Bukkit test/isolation/abstract_unit.rb /^ class Bukkit$/;" c -BukkitController test/railties/shared_tests.rb /^ class BukkitController < ActionController::Base$/;" c class:RailtiesTest.test_adds_helpers_to_controller_views -BukkitController test/railties/shared_tests.rb /^ class BukkitController < ActionController::Base$/;" c class:RailtiesTest.test_adds_its_views_to_view_paths -BukkitController test/railties/shared_tests.rb /^ class BukkitController < ActionController::Base$/;" c class:RailtiesTest.test_adds_its_views_to_view_paths_with_lower_proriority_than_app_ones -BukkitHelper test/railties/shared_tests.rb /^ module BukkitHelper$/;" m class:RailtiesTest.test_adds_helpers_to_controller_views -Bukkits test/railties/engine_test.rb /^ class Bukkits$/;" c class:RailtiesTest.EngineTest.setup -Bukkits test/railties/engine_test.rb /^ class Bukkits$/;" c -Bukkits test/railties/engine_test.rb /^ class Bukkits::FooController < ActionController::Base$/;" c -Bukkits test/railties/engine_test.rb /^ class Bukkits::PostsController < ActionController::Base$/;" c -Bukkits test/railties/engine_test.rb /^ module Bukkits$/;" m -Bukkits test/railties/plugin_test.rb /^ class Bukkits$/;" c -Bukkits test/railties/shared_tests.rb /^ class Bukkits$/;" c class:RailtiesTest.test_midleware_referenced_in_configuration -CheckRubyVersionTest test/application/initializers/check_ruby_version_test.rb /^ class CheckRubyVersionTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Child test/initializable_test.rb /^ class Child < Parent$/;" c class:InitializableTests -ClassMethods lib/rails/generators/migration.rb /^ module ClassMethods$/;" m class:Rails.Generators.Migration -ClassMethods lib/rails/initializable.rb /^ module ClassMethods$/;" m class:Rails.Initializable -ClassMethods lib/rails/railtie/configurable.rb /^ module ClassMethods$/;" m class:Rails.Railtie.Configurable -CodeStatistics lib/rails/code_statistics.rb /^class CodeStatistics #:nodoc:$/;" c -Collection lib/rails/initializable.rb /^ class Collection < Array$/;" c class:Rails.Initializable -Commands lib/rails/commands/plugin.rb /^module Commands$/;" m -Configurable lib/rails/railtie/configurable.rb /^ module Configurable$/;" m class:Rails.Railtie -Configuration lib/rails/application/configuration.rb /^ class Configuration < ::Rails::Engine::Configuration$/;" c class:Rails.Application -Configuration lib/rails/configuration.rb /^ module Configuration$/;" m class:Rails -Configuration lib/rails/engine/configuration.rb /^ class Configuration < ::Rails::Railtie::Configuration$/;" c class:Rails.Engine -Configuration lib/rails/railtie/configuration.rb /^ class Configuration$/;" c class:Rails.Railtie -ConfigurationTest test/application/configuration_test.rb /^ class ConfigurationTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Console lib/rails/commands/console.rb /^ class Console$/;" c class:Rails -ConsoleTest test/application/console_test.rb /^class ConsoleTest < Test::Unit::TestCase$/;" c -ControllerGenerator lib/rails/generators/erb/controller/controller_generator.rb /^ class ControllerGenerator < Base$/;" c class:Erb.Generators -ControllerGenerator lib/rails/generators/rails/controller/controller_generator.rb /^ class ControllerGenerator < NamedBase$/;" c class:Rails.Generators -ControllerGenerator lib/rails/generators/test_unit/controller/controller_generator.rb /^ class ControllerGenerator < Base$/;" c class:TestUnit.Generators -ControllerGeneratorTest test/generators/controller_generator_test.rb /^class ControllerGeneratorTest < Rails::Generators::TestCase$/;" c -CreateSessions test/railties/shared_tests.rb /^ class CreateSessions < ActiveRecord::Migration$/;" c class:RailtiesTest.SharedTests.test_copying_migrations -CreateSessions test/railties/shared_tests.rb /^ class CreateSessions < ActiveRecord::Migration$/;" c class:RailtiesTest.SharedTests.test_install_migrations_and_assets -CreateUsers test/railties/shared_tests.rb /^ class CreateUsers < ActiveRecord::Migration$/;" c class:RailtiesTest.SharedTests.test_copying_migrations -CreateUsers test/railties/shared_tests.rb /^ class CreateUsers < ActiveRecord::Migration$/;" c class:RailtiesTest.SharedTests.test_install_migrations_and_assets -CreateYaffles test/railties/shared_tests.rb /^ class CreateYaffles < ActiveRecord::Migration$/;" c class:RailtiesTest.SharedTests -CustomAppGeneratorTest test/generators/app_generator_test.rb /^class CustomAppGeneratorTest < Rails::Generators::TestCase$/;" c -CustomPluginGeneratorTest test/generators/plugin_new_generator_test.rb /^class CustomPluginGeneratorTest < Rails::Generators::TestCase$/;" c -DBConsole lib/rails/commands/dbconsole.rb /^ class DBConsole$/;" c class:Rails -Debugger lib/rails/rack/debugger.rb /^ class Debugger$/;" c class:Rails.Rack -Draggable lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^var Draggable = Class.create({$/;" v -Draggable tmp/app/public/javascripts/dragdrop.js /^var Draggable = Class.create({$/;" v -Draggable tmp/app_template/public/javascripts/dragdrop.js /^var Draggable = Class.create({$/;" v -Draggables.drags lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^var Draggables = {$/;" p -Draggables.drags tmp/app/public/javascripts/dragdrop.js /^var Draggables = {$/;" p -Draggables.drags tmp/app_template/public/javascripts/dragdrop.js /^var Draggables = {$/;" p -Droppables.drops lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^var Droppables = {$/;" p -Droppables.drops tmp/app/public/javascripts/dragdrop.js /^var Droppables = {$/;" p -Droppables.drops tmp/app_template/public/javascripts/dragdrop.js /^var Droppables = {$/;" p -Effect.Appear lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Appear tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Appear tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.BlindDown lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.BlindDown tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.BlindDown tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.BlindUp lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.BlindUp tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.BlindUp tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.DropOut lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.DropOut tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.DropOut tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.DropOut.oldStyle.top lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.DropOut.oldStyle.top tmp/app/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.DropOut.oldStyle.top tmp/app_template/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Fade lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Fade tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Fade tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Fold lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Fold tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Fold tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Fold.oldStyle.top lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Fold.oldStyle.top tmp/app/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Fold.oldStyle.top tmp/app_template/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Grow lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Grow tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Grow tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Grow.oldStyle.top lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Grow.oldStyle.top tmp/app/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Grow.oldStyle.top tmp/app_template/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Methods.highlight lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ },$/;" m -Effect.Methods.highlight tmp/app/public/javascripts/effects.js /^ },$/;" m -Effect.Methods.highlight tmp/app_template/public/javascripts/effects.js /^ },$/;" m -Effect.Methods.morph lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^Effect.Methods = {$/;" m -Effect.Methods.morph tmp/app/public/javascripts/effects.js /^Effect.Methods = {$/;" m -Effect.Methods.morph tmp/app_template/public/javascripts/effects.js /^Effect.Methods = {$/;" m -Effect.Methods.visualEffect lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ },$/;" m -Effect.Methods.visualEffect tmp/app/public/javascripts/effects.js /^ },$/;" m -Effect.Methods.visualEffect tmp/app_template/public/javascripts/effects.js /^ },$/;" m -Effect.MoveBy lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^});$/;" f -Effect.MoveBy tmp/app/public/javascripts/effects.js /^});$/;" f -Effect.MoveBy tmp/app_template/public/javascripts/effects.js /^});$/;" f -Effect.Puff lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Puff tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Puff tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Puff.oldStyle.opacity lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Puff.oldStyle.opacity tmp/app/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Puff.oldStyle.opacity tmp/app_template/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Pulsate lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Pulsate tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Pulsate tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Queues.instances lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^Effect.Queues = {$/;" p -Effect.Queues.instances tmp/app/public/javascripts/effects.js /^Effect.Queues = {$/;" p -Effect.Queues.instances tmp/app_template/public/javascripts/effects.js /^Effect.Queues = {$/;" p -Effect.ScrollTo lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^});$/;" f -Effect.ScrollTo tmp/app/public/javascripts/effects.js /^});$/;" f -Effect.ScrollTo tmp/app_template/public/javascripts/effects.js /^});$/;" f -Effect.Shake lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Shake tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Shake tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Shake.oldStyle.top lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Shake.oldStyle.top tmp/app/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Shake.oldStyle.top tmp/app_template/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Shrink lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Shrink tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Shrink tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Shrink.oldStyle.top lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Shrink.oldStyle.top tmp/app/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.Shrink.oldStyle.top tmp/app_template/public/javascripts/effects.js /^ var oldStyle = {$/;" p -Effect.SlideDown lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.SlideDown tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.SlideDown tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.SlideUp lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.SlideUp tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.SlideUp tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.Squish lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.Squish tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.Squish tmp/app_template/public/javascripts/effects.js /^};$/;" f -Effect.SwitchOff lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Effect.SwitchOff tmp/app/public/javascripts/effects.js /^};$/;" f -Effect.SwitchOff tmp/app_template/public/javascripts/effects.js /^};$/;" f -Element.collectTextNodes lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Element.collectTextNodes tmp/app/public/javascripts/effects.js /^};$/;" f -Element.collectTextNodes tmp/app_template/public/javascripts/effects.js /^};$/;" f -Element.collectTextNodesIgnoreClass lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Element.collectTextNodesIgnoreClass tmp/app/public/javascripts/effects.js /^};$/;" f -Element.collectTextNodesIgnoreClass tmp/app_template/public/javascripts/effects.js /^};$/;" f -Element.findChildren lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^};$/;" f -Element.findChildren tmp/app/public/javascripts/dragdrop.js /^};$/;" f -Element.findChildren tmp/app_template/public/javascripts/dragdrop.js /^};$/;" f -Element.forceRerendering lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Element.forceRerendering tmp/app/public/javascripts/effects.js /^};$/;" f -Element.forceRerendering tmp/app_template/public/javascripts/effects.js /^};$/;" f -Element.getInlineOpacity lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Element.getInlineOpacity tmp/app/public/javascripts/effects.js /^};$/;" f -Element.getInlineOpacity tmp/app_template/public/javascripts/effects.js /^};$/;" f -Element.getStyles lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^if (document.defaultView && document.defaultView.getComputedStyle) {$/;" f -Element.getStyles tmp/app/public/javascripts/effects.js /^if (document.defaultView && document.defaultView.getComputedStyle) {$/;" f -Element.getStyles tmp/app_template/public/javascripts/effects.js /^if (document.defaultView && document.defaultView.getComputedStyle) {$/;" f -Element.isParent lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^};$/;" f -Element.isParent tmp/app/public/javascripts/dragdrop.js /^};$/;" f -Element.isParent tmp/app_template/public/javascripts/dragdrop.js /^};$/;" f -Element.offsetSize lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^};$/;" f -Element.offsetSize tmp/app/public/javascripts/dragdrop.js /^};$/;" f -Element.offsetSize tmp/app_template/public/javascripts/dragdrop.js /^};$/;" f -Element.setContentZoom lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^};$/;" f -Element.setContentZoom tmp/app/public/javascripts/effects.js /^};$/;" f -Element.setContentZoom tmp/app_template/public/javascripts/effects.js /^};$/;" f -Engine lib/rails/engine.rb /^ class Engine < Railtie$/;" c class:Rails -Engine lib/rails/engine/configuration.rb /^ class Engine$/;" c class:Rails -Engine lib/rails/engine/railties.rb /^ class Engine < Railtie$/;" c class:Rails -Engine lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb /^ class Engine < Rails::Engine$/;" c -Engine test/railties/engine_test.rb /^ class Engine < ::Rails::Engine$/;" c class:RailtiesTest.EngineTest.setup.Bukkits -Engine test/railties/engine_test.rb /^ class Engine < ::Rails::Engine$/;" c class:AppTemplate -Engine test/railties/engine_test.rb /^ class Engine < ::Rails::Engine$/;" c class:Bukkits -Engine test/railties/mounted_engine_test.rb /^ class Engine < ::Rails::Engine$/;" c class:ApplicationTests.ApplicationRoutingTest.Blog -Engine test/railties/plugin_test.rb /^ class Engine < Rails::Engine$/;" c class:Bukkits -EngineHelper test/railties/engine_test.rb /^ module EngineHelper$/;" m -EngineTest test/railties/engine_test.rb /^ class EngineTest < Test::Unit::TestCase$/;" c class:RailtiesTest -Erb lib/rails/generators/erb.rb /^module Erb$/;" m -Erb lib/rails/generators/erb/controller/controller_generator.rb /^module Erb$/;" m -Erb lib/rails/generators/erb/mailer/mailer_generator.rb /^module Erb$/;" m -Erb lib/rails/generators/erb/scaffold/scaffold_generator.rb /^module Erb$/;" m -Error lib/rails/generators/base.rb /^ class Error < Thor::Error$/;" c class:Rails.Generators -Event.Handler lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ if (!submitBubbles || !changeBubbles) {$/;" c -Event.Handler tmp/app/public/javascripts/rails.js /^ if (!submitBubbles || !changeBubbles) {$/;" c -Event.Handler tmp/app_template/public/javascripts/rails.js /^ if (!submitBubbles || !changeBubbles) {$/;" c -Event.Handler.initialize lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap($/;" m -Event.Handler.initialize tmp/app/public/javascripts/rails.js /^ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap($/;" m -Event.Handler.initialize tmp/app_template/public/javascripts/rails.js /^ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap($/;" m -ExpiresController test/application/middleware/cache_test.rb /^ class ExpiresController < ApplicationController$/;" c class:ApplicationTests.RoutingTest.simple_controller -Field.scrollFreeActivate lib/rails/generators/rails/app/templates/public/javascripts/controls.js /^});$/;" f -Field.scrollFreeActivate tmp/app/public/javascripts/controls.js /^});$/;" f -Field.scrollFreeActivate tmp/app_template/public/javascripts/controls.js /^});$/;" f -Finisher lib/rails/application/finisher.rb /^ module Finisher$/;" m class:Rails.Application -FixjourGenerator test/fixtures/lib/generators/active_record/fixjour_generator.rb /^ class FixjourGenerator < Base$/;" c class:ActiveRecord.Generators -FixjourGenerator test/fixtures/lib/generators/fixjour_generator.rb /^class FixjourGenerator < Rails::Generators::NamedBase$/;" c -Foo test/application/initializers/frameworks_test.rb /^ class Foo < ActionMailer::Base$/;" c -Foo test/application/initializers/load_path_test.rb /^ module Foo; end$/;" m -Foo test/application/initializers/load_path_test.rb /^ module Foo; end$/;" m class:ApplicationTests -Foo test/initializable_test.rb /^ class Foo$/;" c class:InitializableTests -Foo test/railties/plugin_test.rb /^ class Foo < Rails::Plugin; end$/;" c -Foo test/railties/railtie_test.rb /^ class Foo < Rails::Railtie ; config.after_initialize { $after_initialize = true } ; end$/;" c -Foo test/railties/railtie_test.rb /^ class Foo < Rails::Railtie ; config.to_prepare { $to_prepare = true } ; end$/;" c -Foo test/railties/railtie_test.rb /^ class Foo < Rails::Railtie ; end$/;" c -Foo test/railties/railtie_test.rb /^ class Foo < Rails::Railtie$/;" c -Foo test/railties/shared_tests.rb /^ module Foo; end$/;" m class:RailtiesTest.test_autoload_any_path_under_app -FooController test/application/initializers/frameworks_test.rb /^ class FooController < ApplicationController$/;" c -FooController test/application/routing_test.rb /^ class FooController < ApplicationController$/;" c -FooController test/application/routing_test.rb /^ class FooController < ApplicationController$/;" c class:Admin -FooController test/application/routing_test.rb /^ class FooController < ApplicationController$/;" c -FooController test/isolation/abstract_unit.rb /^ class FooController < ApplicationController$/;" c class:simple_controller -FooController test/railties/engine_test.rb /^ class FooController < ActionController::Base$/;" c -FooController test/railties/shared_tests.rb /^ class FooController < ActionController::Base$/;" c class:RailtiesTest.test_routes_in_plugins_have_lower_priority_than_application_ones -FooHelper test/application/initializers/frameworks_test.rb /^ module FooHelper$/;" m -FooTest test/application/test_test.rb /^ class FooTest < ActiveSupport::TestCase$/;" c class:ApplicationTests -FooTest test/application/test_test.rb /^ class FooTest < ActiveSupport::TestCase$/;" c class:ApplicationTests.TestTest -Foobar test/fixtures/lib/rails/generators/foobar/foobar_generator.rb /^module Foobar$/;" m -FoobarGenerator test/fixtures/lib/rails/generators/foobar/foobar_generator.rb /^ class FoobarGenerator < Rails::Generators::Base$/;" c class:Foobar -FrameworlsTest test/application/initializers/frameworks_test.rb /^ class FrameworlsTest < Test::Unit::TestCase$/;" c class:ApplicationTests -GemBooting test/application/initializers/boot_test.rb /^ class GemBooting < Test::Unit::TestCase$/;" c class:ApplicationTests -GeneratedAttribute lib/rails/generators/generated_attribute.rb /^ class GeneratedAttribute$/;" c class:Rails.Generators -GeneratedAttributeTest test/generators/generated_attribute_test.rb /^class GeneratedAttributeTest < Rails::Generators::TestCase$/;" c -Generation test/isolation/abstract_unit.rb /^ module Generation$/;" m -Generator guides/rails_guides/generator.rb /^ class Generator$/;" c class:RailsGuides -GeneratorGenerator lib/rails/generators/rails/generator/generator_generator.rb /^ class GeneratorGenerator < NamedBase$/;" c class:Rails.Generators -GeneratorGeneratorTest test/generators/generator_generator_test.rb /^class GeneratorGeneratorTest < Rails::Generators::TestCase$/;" c -Generators lib/rails/configuration.rb /^ class Generators #:nodoc:$/;" c class:Rails.Configuration -Generators lib/rails/generators.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/actions.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/active_model.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/app_base.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/base.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/erb.rb /^ module Generators$/;" m class:Erb -Generators lib/rails/generators/erb/controller/controller_generator.rb /^ module Generators$/;" m class:Erb -Generators lib/rails/generators/erb/mailer/mailer_generator.rb /^ module Generators$/;" m class:Erb -Generators lib/rails/generators/erb/scaffold/scaffold_generator.rb /^ module Generators$/;" m class:Erb -Generators lib/rails/generators/generated_attribute.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/migration.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/named_base.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/app/app_generator.rb /^ module Generators$/;" m -Generators lib/rails/generators/rails/controller/controller_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/generator/generator_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/helper/helper_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/integration_test/integration_test_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/migration/migration_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/model/model_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/observer/observer_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/performance_test/performance_test_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/plugin/plugin_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ module Generators$/;" m -Generators lib/rails/generators/rails/resource/resource_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/scaffold/scaffold_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/session_migration/session_migration_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/rails/stylesheets/stylesheets_generator.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/resource_helpers.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/test_case.rb /^ module Generators$/;" m class:Rails -Generators lib/rails/generators/test_unit.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/controller/controller_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/helper/helper_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/integration/integration_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/mailer/mailer_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/model/model_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/observer/observer_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/performance/performance_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/plugin/plugin_generator.rb /^ module Generators$/;" m class:TestUnit -Generators lib/rails/generators/test_unit/scaffold/scaffold_generator.rb /^ module Generators$/;" m class:TestUnit -Generators test/fixtures/lib/generators/active_record/fixjour_generator.rb /^ module Generators$/;" m class:ActiveRecord -Generators test/generators/scaffold_controller_generator_test.rb /^ module Generators$/;" m class:Unknown -GeneratorsTest test/application/generators_test.rb /^ class GeneratorsTest < Test::Unit::TestCase$/;" c class:ApplicationTests -GeneratorsTest test/generators_test.rb /^class GeneratorsTest < Rails::Generators::TestCase$/;" c -GeneratorsTestHelper test/generators/generators_test_helper.rb /^module GeneratorsTestHelper$/;" m -HelperGenerator lib/rails/generators/rails/helper/helper_generator.rb /^ class HelperGenerator < NamedBase$/;" c class:Rails.Generators -HelperGenerator lib/rails/generators/test_unit/helper/helper_generator.rb /^ class HelperGenerator < Base$/;" c class:TestUnit.Generators -HelperGeneratorTest test/generators/helper_generator_test.rb /^class HelperGeneratorTest < Rails::Generators::TestCase$/;" c -Helpers guides/rails_guides/helpers.rb /^ module Helpers$/;" m class:RailsGuides -HomeController test/railties/engine_test.rb /^ class HomeController < ActionController::Base$/;" c class:Bukkits -I18nTest test/application/initializers/i18n_test.rb /^ class I18nTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Indexer guides/rails_guides/indexer.rb /^ class Indexer$/;" c class:RailsGuides -Info lib/rails/commands/plugin.rb /^ class Info$/;" c class:Commands -Info lib/rails/info.rb /^ module Info$/;" m class:Rails -Info test/rails_info_test.rb /^ class Info; end$/;" c class:Rails -InfoControllerTest test/rails_info_controller_test.rb /^class InfoControllerTest < ActionController::TestCase$/;" c -InfoTest test/rails_info_test.rb /^class InfoTest < ActiveSupport::TestCase$/;" c -Initializable lib/rails/initializable.rb /^ module Initializable$/;" m class:Rails -InitializableTests test/initializable_test.rb /^module InitializableTests$/;" m -Initializer lib/rails/initializable.rb /^ class Initializer$/;" c class:Rails.Initializable -InitializersTest test/application/initializers/hooks_test.rb /^ class InitializersTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Install lib/rails/commands/plugin.rb /^ class Install$/;" c class:Commands -Instance test/initializable_test.rb /^ class Instance$/;" c class:InitializableTests -InstanceTest test/initializable_test.rb /^ class InstanceTest < ActiveSupport::TestCase$/;" c -IntegrationGenerator lib/rails/generators/test_unit/integration/integration_generator.rb /^ class IntegrationGenerator < Base$/;" c class:TestUnit.Generators -IntegrationTestGenerator lib/rails/generators/rails/integration_test/integration_test_generator.rb /^ class IntegrationTestGenerator < NamedBase$/;" c class:Rails.Generators -IntegrationTestGeneratorTest test/generators/integration_test_generator_test.rb /^class IntegrationTestGeneratorTest < Rails::Generators::TestCase$/;" c -Interdependent test/initializable_test.rb /^ module Interdependent$/;" m class:InitializableTests -Levenshtein guides/rails_guides/levenshtein.rb /^ module Levenshtein$/;" m class:RailsGuides -LoadPathTest test/application/initializers/load_path_test.rb /^ class LoadPathTest < Test::Unit::TestCase$/;" c class:ApplicationTests -LoadingTest test/application/loading_test.rb /^class LoadingTest < Test::Unit::TestCase$/;" c -LogTailer lib/rails/rack/log_tailer.rb /^ class LogTailer$/;" c class:Rails.Rack -Logger lib/rails/rack/logger.rb /^ class Logger < ActiveSupport::LogSubscriber$/;" c class:Rails.Rack -MailerGenerator lib/rails/generators/erb/mailer/mailer_generator.rb /^ class MailerGenerator < ControllerGenerator$/;" c class:Erb.Generators -MailerGenerator lib/rails/generators/test_unit/mailer/mailer_generator.rb /^ class MailerGenerator < Base$/;" c class:TestUnit.Generators -MailerGeneratorTest test/generators/mailer_generator_test.rb /^class MailerGeneratorTest < Rails::Generators::TestCase$/;" c -MiddlewareStackProxy lib/rails/configuration.rb /^ class MiddlewareStackProxy #:nodoc:$/;" c class:Rails.Configuration -MiddlewareTest test/application/middleware_test.rb /^ class MiddlewareTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Migration lib/rails/generators/migration.rb /^ module Migration$/;" m class:Rails.Generators -MigrationGenerator lib/rails/generators/rails/migration/migration_generator.rb /^ class MigrationGenerator < NamedBase #metagenerator$/;" c class:Rails.Generators -MigrationGeneratorTest test/generators/migration_generator_test.rb /^class MigrationGeneratorTest < Rails::Generators::TestCase$/;" c -ModelGenerator lib/rails/generators/rails/model/model_generator.rb /^ class ModelGenerator < NamedBase #metagenerator$/;" c class:Rails.Generators -ModelGenerator lib/rails/generators/test_unit/model/model_generator.rb /^ class ModelGenerator < Base$/;" c class:TestUnit.Generators -ModelGeneratorTest test/generators/model_generator_test.rb /^class ModelGeneratorTest < Rails::Generators::TestCase$/;" c -MoreInitializers test/initializable_test.rb /^ class MoreInitializers$/;" c class:InitializableTests.OverriddenInitializer -MyApp test/application/url_generation_test.rb /^ class MyApp < Rails::Application$/;" c class:ApplicationTests.UrlGenerationTest -MyMailer test/railties/engine_test.rb /^ class MyMailer < ActionMailer::Base$/;" c class:Bukkits -MyTie test/railties/railtie_test.rb /^ class MyTie < Rails::Railtie$/;" c -NamedBase lib/rails/generators/named_base.rb /^ class NamedBase < Base$/;" c class:Rails.Generators -NamedBaseTest test/generators/named_base_test.rb /^class NamedBaseTest < Rails::Generators::TestCase$/;" c -NamespacedControllerGeneratorTest test/generators/namespaced_generators_test.rb /^class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase$/;" c -NamespacedGeneratorTestCase test/generators/namespaced_generators_test.rb /^class NamespacedGeneratorTestCase < Rails::Generators::TestCase$/;" c -NamespacedMailerGeneratorTest test/generators/namespaced_generators_test.rb /^class NamespacedMailerGeneratorTest < NamespacedGeneratorTestCase$/;" c -NamespacedModelGeneratorTest test/generators/namespaced_generators_test.rb /^class NamespacedModelGeneratorTest < NamespacedGeneratorTestCase$/;" c -NamespacedObserverGeneratorTest test/generators/namespaced_generators_test.rb /^class NamespacedObserverGeneratorTest < NamespacedGeneratorTestCase$/;" c -NamespacedScaffoldGeneratorTest test/generators/namespaced_generators_test.rb /^class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase$/;" c -NavigationTest lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb /^class NavigationTest < ActionDispatch::IntegrationTest$/;" c -NotificationsTest test/application/initializers/notifications_test.rb /^ class NotificationsTest < Test::Unit::TestCase$/;" c class:ApplicationTests -ObserverGenerator lib/rails/generators/rails/observer/observer_generator.rb /^ class ObserverGenerator < NamedBase #metagenerator$/;" c class:Rails.Generators -ObserverGenerator lib/rails/generators/test_unit/observer/observer_generator.rb /^ class ObserverGenerator < Base$/;" c class:TestUnit.Generators -ObserverGeneratorTest test/generators/observer_generator_test.rb /^class ObserverGeneratorTest < Rails::Generators::TestCase$/;" c -Options lib/rails/commands/server.rb /^ class Options$/;" c class:Rails.Server -OverriddenInitializer test/initializable_test.rb /^ class OverriddenInitializer$/;" c class:InitializableTests -OverriddenInitializerTest test/initializable_test.rb /^ class OverriddenInitializerTest < ActiveSupport::TestCase$/;" c -Parent test/initializable_test.rb /^ class Parent$/;" c class:InitializableTests -Path lib/rails/paths.rb /^ class Path < Array$/;" c class:Rails.Paths -PathParent lib/rails/paths.rb /^ module PathParent #:nodoc:$/;" m class:Rails.Paths -Paths lib/rails/paths.rb /^ module Paths$/;" m class:Rails -Paths test/isolation/abstract_unit.rb /^ module Paths$/;" m class:TestHelpers -PathsTest test/application/paths_test.rb /^ class PathsTest < Test::Unit::TestCase$/;" c class:ApplicationTests -PathsTest test/paths_test.rb /^class PathsTest < ActiveSupport::TestCase$/;" c -PerformanceGenerator lib/rails/generators/test_unit/performance/performance_generator.rb /^ class PerformanceGenerator < Base$/;" c class:TestUnit.Generators -PerformanceTestGenerator lib/rails/generators/rails/performance_test/performance_test_generator.rb /^ class PerformanceTestGenerator < NamedBase$/;" c class:Rails.Generators -PerformanceTestGeneratorTest test/generators/performance_test_generator_test.rb /^class PerformanceTestGeneratorTest < Rails::Generators::TestCase$/;" c -Plugin lib/rails/commands/plugin.rb /^ class Plugin$/;" c class:Commands -Plugin lib/rails/commands/plugin.rb /^class Plugin$/;" c -Plugin lib/rails/plugin.rb /^ class Plugin < Engine$/;" c class:Rails -PluginA test/initializable_test.rb /^ class PluginA$/;" c class:InitializableTests.Interdependent -PluginB test/initializable_test.rb /^ class PluginB$/;" c -PluginBuilder lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ class PluginBuilder$/;" c class:Rails -PluginBuilder test/fixtures/lib/plugin_builders/empty_builder.rb /^class PluginBuilder$/;" c -PluginBuilder test/fixtures/lib/plugin_builders/simple_builder.rb /^class PluginBuilder$/;" c -PluginBuilder test/fixtures/lib/plugin_builders/spec_builder.rb /^class PluginBuilder < Rails::PluginBuilder$/;" c -PluginBuilder test/fixtures/lib/plugin_builders/tweak_builder.rb /^class PluginBuilder < Rails::PluginBuilder$/;" c -PluginGenerator lib/rails/generators/rails/plugin/plugin_generator.rb /^ class PluginGenerator < NamedBase$/;" c class:Rails.Generators -PluginGenerator lib/rails/generators/test_unit/plugin/plugin_generator.rb /^ class PluginGenerator < Base$/;" c class:TestUnit.Generators -PluginGeneratorTest test/generators/plugin_generator_test.rb /^class PluginGeneratorTest < Rails::Generators::TestCase$/;" c -PluginNewGenerator lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ class PluginNewGenerator < AppBase$/;" c class:Generators -PluginNewGeneratorTest test/generators/plugin_new_generator_test.rb /^class PluginNewGeneratorTest < Rails::Generators::TestCase$/;" c -PluginOrderingTest test/railties/plugin_ordering_test.rb /^ class PluginOrderingTest < Test::Unit::TestCase$/;" c class:RailtiesTest -PluginTest test/railties/plugin_test.rb /^ class PluginTest < Test::Unit::TestCase$/;" c class:RailtiesTest -Post test/application/loading_test.rb /^ class Post < ActiveRecord::Base$/;" c class:LoadingTest.test_constants_in_app_are_autoloaded -Post test/application/loading_test.rb /^ class Post < ActiveRecord::Base$/;" c class:test_descendants_are_cleaned_on_each_request_without_cache_classes -Post test/railties/engine_test.rb /^ class Post$/;" c class:Bukkits -Post test/railties/mounted_engine_test.rb /^ class Post$/;" c class:ApplicationTests.ApplicationRoutingTest.Blog -PostsController test/application/test_test.rb /^ class PostsController < ActionController::Base$/;" c -PostsController test/railties/mounted_engine_test.rb /^ class PostsController < ActionController::Base$/;" c class:ApplicationTests.ApplicationRoutingTest.Blog -PostsTest test/application/test_test.rb /^ class PostsTest < ActionDispatch::IntegrationTest$/;" c -Prof lib/rails/rubyprof_ext.rb /^module Prof #:nodoc:$/;" m -Prototype.Browser lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ Version: '1.7',$/;" p -Prototype.Browser tmp/app/public/javascripts/prototype.js /^ Version: '1.7',$/;" p -Prototype.Browser tmp/app_template/public/javascripts/prototype.js /^ Version: '1.7',$/;" p -Prototype.Version lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^var Prototype = {$/;" p -Prototype.Version tmp/app/public/javascripts/prototype.js /^var Prototype = {$/;" p -Prototype.Version tmp/app_template/public/javascripts/prototype.js /^var Prototype = {$/;" p -Rack lib/rails/rack.rb /^ module Rack$/;" m class:Rails -Rack lib/rails/rack/debugger.rb /^ module Rack$/;" m class:Rails -Rack lib/rails/rack/log_tailer.rb /^ module Rack$/;" m class:Rails -Rack lib/rails/rack/logger.rb /^ module Rack$/;" m class:Rails -Rack test/isolation/abstract_unit.rb /^ module Rack$/;" m class:TestHelpers -RackupTest test/application/rackup_test.rb /^ class RackupTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Rails lib/rails.rb /^module Rails$/;" m -Rails lib/rails/application.rb /^module Rails$/;" m -Rails lib/rails/application/bootstrap.rb /^module Rails$/;" m -Rails lib/rails/application/configuration.rb /^module Rails$/;" m -Rails lib/rails/application/finisher.rb /^module Rails$/;" m -Rails lib/rails/application/railties.rb /^module Rails$/;" m -Rails lib/rails/application/routes_reloader.rb /^module Rails$/;" m -Rails lib/rails/backtrace_cleaner.rb /^module Rails$/;" m -Rails lib/rails/commands/console.rb /^module Rails$/;" m -Rails lib/rails/commands/dbconsole.rb /^module Rails$/;" m -Rails lib/rails/commands/server.rb /^module Rails$/;" m -Rails lib/rails/configuration.rb /^module Rails$/;" m -Rails lib/rails/engine.rb /^module Rails$/;" m -Rails lib/rails/engine/configuration.rb /^module Rails$/;" m -Rails lib/rails/engine/railties.rb /^module Rails$/;" m -Rails lib/rails/generators.rb /^module Rails$/;" m -Rails lib/rails/generators/actions.rb /^module Rails$/;" m -Rails lib/rails/generators/active_model.rb /^module Rails$/;" m -Rails lib/rails/generators/app_base.rb /^module Rails$/;" m -Rails lib/rails/generators/base.rb /^module Rails$/;" m -Rails lib/rails/generators/generated_attribute.rb /^module Rails$/;" m -Rails lib/rails/generators/migration.rb /^module Rails$/;" m -Rails lib/rails/generators/named_base.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/app/app_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/controller/controller_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/generator/generator_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/helper/helper_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/integration_test/integration_test_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/migration/migration_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/model/model_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/observer/observer_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/performance_test/performance_test_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/plugin/plugin_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/resource/resource_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/scaffold/scaffold_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/session_migration/session_migration_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/rails/stylesheets/stylesheets_generator.rb /^module Rails$/;" m -Rails lib/rails/generators/resource_helpers.rb /^module Rails$/;" m -Rails lib/rails/generators/test_case.rb /^module Rails$/;" m -Rails lib/rails/info.rb /^module Rails$/;" m -Rails lib/rails/info_controller.rb /^class Rails::InfoController < ActionController::Base$/;" c -Rails lib/rails/initializable.rb /^module Rails$/;" m -Rails lib/rails/paths.rb /^module Rails$/;" m -Rails lib/rails/plugin.rb /^module Rails$/;" m -Rails lib/rails/rack.rb /^module Rails$/;" m -Rails lib/rails/rack/debugger.rb /^module Rails$/;" m -Rails lib/rails/rack/log_tailer.rb /^module Rails$/;" m -Rails lib/rails/rack/logger.rb /^module Rails$/;" m -Rails lib/rails/rack/static.rb /^module Rails::Rack$/;" m -Rails lib/rails/railtie.rb /^module Rails$/;" m -Rails lib/rails/railtie/configurable.rb /^module Rails$/;" m -Rails lib/rails/railtie/configuration.rb /^module Rails$/;" m -Rails lib/rails/script_rails_loader.rb /^module Rails$/;" m -Rails lib/rails/test_unit/railtie.rb /^module Rails$/;" m -Rails lib/rails/version.rb /^module Rails$/;" m -Rails test/generators/generators_test_helper.rb /^module Rails$/;" m -Rails test/rails_info_test.rb /^ module Rails$/;" m -Rails test/railties/railtie_test.rb /^ class Rails::Railtie$/;" c -RailsEnvironment lib/rails/commands/plugin.rb /^class RailsEnvironment$/;" c -RailsGuides guides/rails_guides/generator.rb /^module RailsGuides$/;" m -RailsGuides guides/rails_guides/helpers.rb /^module RailsGuides$/;" m -RailsGuides guides/rails_guides/indexer.rb /^module RailsGuides$/;" m -RailsGuides guides/rails_guides/levenshtein.rb /^module RailsGuides$/;" m -RailsGuides guides/rails_guides/textile_extensions.rb /^module RailsGuides$/;" m -RailsGuides guides/w3c_validator.rb /^module RailsGuides$/;" m -Railtie lib/rails/railtie.rb /^ class Railtie$/;" c class:Rails -Railtie lib/rails/railtie/configurable.rb /^ class Railtie$/;" c class:Rails -Railtie lib/rails/railtie/configuration.rb /^ class Railtie$/;" c class:Rails -RailtieTest test/railties/railtie_test.rb /^ class RailtieTest < Test::Unit::TestCase$/;" c class:RailtiesTest -Railties lib/rails/application/railties.rb /^ class Railties < Rails::Engine::Railties$/;" c class:Rails.Application -Railties lib/rails/engine/railties.rb /^ class Railties$/;" c class:Rails.Engine -RailtiesTest test/railties/engine_test.rb /^module RailtiesTest$/;" m -RailtiesTest test/railties/plugin_ordering_test.rb /^module RailtiesTest$/;" m -RailtiesTest test/railties/plugin_test.rb /^module RailtiesTest$/;" m -RailtiesTest test/railties/railtie_test.rb /^module RailtiesTest$/;" m -RailtiesTest test/railties/shared_tests.rb /^module RailtiesTest$/;" m -RakeTest test/application/rake_test.rb /^ class RakeTest < Test::Unit::TestCase$/;" c class:ApplicationTests -RecursiveHTTPFetcher lib/rails/commands/plugin.rb /^class RecursiveHTTPFetcher$/;" c -RemoteIpTest test/application/middleware/remote_ip_test.rb /^ class RemoteIpTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Remove lib/rails/commands/plugin.rb /^ class Remove$/;" c class:Commands -ResourceGenerator lib/rails/generators/rails/resource/resource_generator.rb /^ class ResourceGenerator < ModelGenerator #metagenerator$/;" c class:Rails.Generators -ResourceGeneratorTest test/generators/resource_generator_test.rb /^class ResourceGeneratorTest < Rails::Generators::TestCase$/;" c -ResourceHelpers lib/rails/generators/resource_helpers.rb /^ module ResourceHelpers$/;" m class:Rails.Generators -Root lib/rails/paths.rb /^ class Root < ::Hash$/;" c class:Rails.Paths -RoutesReloader lib/rails/application/routes_reloader.rb /^ class RoutesReloader < ::ActiveSupport::FileUpdateChecker$/;" c class:Rails.Application -RoutingTest test/application/middleware/cache_test.rb /^ class RoutingTest < Test::Unit::TestCase$/;" c class:ApplicationTests -RoutingTest test/application/routing_test.rb /^ class RoutingTest < Test::Unit::TestCase$/;" c class:ApplicationTests -RunnerTest test/application/runner_test.rb /^ class RunnerTest < Test::Unit::TestCase$/;" c class:ApplicationTests -ScaffoldControllerGenerator lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb /^ class ScaffoldControllerGenerator < NamedBase$/;" c class:Rails.Generators -ScaffoldControllerGeneratorTest test/generators/scaffold_controller_generator_test.rb /^class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase$/;" c -ScaffoldGenerator lib/rails/generators/erb/scaffold/scaffold_generator.rb /^ class ScaffoldGenerator < Base$/;" c class:Erb.Generators -ScaffoldGenerator lib/rails/generators/rails/scaffold/scaffold_generator.rb /^ class ScaffoldGenerator < ResourceGenerator #metagenerator$/;" c class:Rails.Generators -ScaffoldGenerator lib/rails/generators/test_unit/scaffold/scaffold_generator.rb /^ class ScaffoldGenerator < Base$/;" c class:TestUnit.Generators -ScaffoldGeneratorTest test/generators/scaffold_generator_test.rb /^class ScaffoldGeneratorTest < Rails::Generators::TestCase$/;" c -ScriptRailsLoader lib/rails/script_rails_loader.rb /^ module ScriptRailsLoader$/;" m class:Rails -ScriptRailsLoaderTest test/script_rails_loader_test.rb /^class ScriptRailsLoaderTest < ActiveSupport::TestCase$/;" c -SendfileTest test/application/middleware/sendfile_test.rb /^ class SendfileTest < Test::Unit::TestCase$/;" c class:ApplicationTests -Server lib/rails/commands/server.rb /^ class Server < ::Rack::Server$/;" c class:Rails -SessionMigrationGenerator lib/rails/generators/rails/session_migration/session_migration_generator.rb /^ class SessionMigrationGenerator < NamedBase #metagenerator$/;" c class:Rails.Generators -SessionMigrationGeneratorTest test/generators/session_migration_generator_test.rb /^class SessionMigrationGeneratorTest < Rails::Generators::TestCase$/;" c -SharedCustomGeneratorTests test/generators/shared_generator_tests.rb /^module SharedCustomGeneratorTests$/;" m -SharedGeneratorTests test/generators/shared_generator_tests.rb /^module SharedGeneratorTests$/;" m -SharedTests test/railties/shared_tests.rb /^ module SharedTests$/;" m class:RailtiesTest -SomeHelper test/railties/engine_test.rb /^ module SomeHelper$/;" m -Sortable.SERIALIZE_RULE lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^var Sortable = {$/;" p -Sortable.SERIALIZE_RULE tmp/app/public/javascripts/dragdrop.js /^var Sortable = {$/;" p -Sortable.SERIALIZE_RULE tmp/app_template/public/javascripts/dragdrop.js /^var Sortable = {$/;" p -SortableObserver lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^var SortableObserver = Class.create({$/;" v -SortableObserver tmp/app/public/javascripts/dragdrop.js /^var SortableObserver = Class.create({$/;" v -SortableObserver tmp/app_template/public/javascripts/dragdrop.js /^var SortableObserver = Class.create({$/;" v -SourceAnnotationExtractor lib/rails/source_annotation_extractor.rb /^class SourceAnnotationExtractor$/;" c -Sprokkit test/railties/shared_tests.rb /^ class Sprokkit$/;" c class:RailtiesTest.test_routes_are_added_to_router -Str lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function Str(key, holder, stack) {$/;" f -Str tmp/app/public/javascripts/prototype.js /^ function Str(key, holder, stack) {$/;" f -Str tmp/app_template/public/javascripts/prototype.js /^ function Str(key, holder, stack) {$/;" f -String lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^\/\/ script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009$/;" c -String tmp/app/public/javascripts/effects.js /^\/\/ script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009$/;" c -String tmp/app_template/public/javascripts/effects.js /^\/\/ script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009$/;" c -String.parseColor lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^String.prototype.parseColor = function() {$/;" m -String.parseColor tmp/app/public/javascripts/effects.js /^String.prototype.parseColor = function() {$/;" m -String.parseColor tmp/app_template/public/javascripts/effects.js /^String.prototype.parseColor = function() {$/;" m -String.parseStyle lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^String.prototype.parseStyle = function(){$/;" m -String.parseStyle tmp/app/public/javascripts/effects.js /^String.prototype.parseStyle = function(){$/;" m -String.parseStyle tmp/app_template/public/javascripts/effects.js /^String.prototype.parseStyle = function(){$/;" m -StylesheetsGenerator lib/rails/generators/rails/stylesheets/stylesheets_generator.rb /^ class StylesheetsGenerator < Base$/;" c class:Rails.Generators -StylesheetsGeneratorTest test/generators/stylesheets_generator_test.rb /^class StylesheetsGeneratorTest < Rails::Generators::TestCase$/;" c -Test test/isolation/abstract_unit.rb /^class Test::Unit::TestCase$/;" c -TestApp test/abstract_unit.rb /^module TestApp$/;" m -TestCase lib/rails/generators/test_case.rb /^ class TestCase < ActiveSupport::TestCase$/;" c class:Rails.Generators -TestHelpers test/isolation/abstract_unit.rb /^module TestHelpers$/;" m -TestTest test/application/test_test.rb /^ class TestTest < Test::Unit::TestCase$/;" c class:ApplicationTests -TestUnit lib/rails/generators/test_unit.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/controller/controller_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/helper/helper_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/integration/integration_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/mailer/mailer_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/model/model_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/observer/observer_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/performance/performance_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/plugin/plugin_generator.rb /^module TestUnit$/;" m -TestUnit lib/rails/generators/test_unit/scaffold/scaffold_generator.rb /^module TestUnit$/;" m -TestUnitRailtie lib/rails/test_unit/railtie.rb /^ class TestUnitRailtie < Rails::Railtie$/;" c class:Rails -TestWithBacktrace test/backtrace_cleaner_test.rb /^ class TestWithBacktrace$/;" c -TextileExtensions guides/rails_guides/textile_extensions.rb /^ module TextileExtensions$/;" m class:RailsGuides -Try.these lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^var Try = {$/;" m -Try.these tmp/app/public/javascripts/prototype.js /^var Try = {$/;" m -Try.these tmp/app_template/public/javascripts/prototype.js /^var Try = {$/;" m -Type lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function Type(o) {$/;" f -Type tmp/app/public/javascripts/prototype.js /^ function Type(o) {$/;" f -Type tmp/app_template/public/javascripts/prototype.js /^ function Type(o) {$/;" f -Unknown test/generators/scaffold_controller_generator_test.rb /^module Unknown$/;" m -Upcaser test/railties/engine_test.rb /^ class Upcaser$/;" c -UrlGenerationTest test/application/url_generation_test.rb /^ class UrlGenerationTest < Test::Unit::TestCase$/;" c class:ApplicationTests -User test/application/console_test.rb /^ class User < ActiveRecord::Base$/;" c class:ConsoleTest.test_active_record_does_not_panic_when_referencing_an_observed_constant -User test/application/console_test.rb /^ class User$/;" c class:ConsoleTest.test_reload_should_reload_constants -User test/application/loading_test.rb /^ class User < ActiveRecord::Base$/;" c class:LoadingTest.test_models_without_table_do_not_panic_on_scope_definitions_when_loaded -User test/application/runner_test.rb /^ class User$/;" c class:ApplicationTests.RunnerTest.setup -UserObserver test/application/console_test.rb /^ class UserObserver < ActiveRecord::Observer$/;" c class:ConsoleTest.test_active_record_does_not_panic_when_referencing_an_observed_constant -VERSION lib/rails/version.rb /^ module VERSION #:nodoc:$/;" m class:Rails -Validator guides/w3c_validator.rb /^ class Validator$/;" c class:RailsGuides -WithArgs test/initializable_test.rb /^ class WithArgs$/;" c class:InitializableTests -WithArgsTest test/initializable_test.rb /^ class WithArgsTest < ActiveSupport::TestCase$/;" c -WithOptionsGenerator test/generators_test.rb /^ class WithOptionsGenerator < Rails::Generators::Base$/;" c class:GeneratorsTest.test_developer_options_are_overwriten_by_user_options -Word test/initializable_test.rb /^ module Word$/;" m class:InitializableTests -WrongGenerator test/fixtures/lib/generators/wrong_generator.rb /^class WrongGenerator < Rails::Generator::NamedBase$/;" c -YazilarController test/application/routing_test.rb /^ class YazilarController < ApplicationController$/;" c -Zoo test/application/initializers/load_path_test.rb /^ class Zoo ; include ReptileHouse ; end$/;" c -Zoo test/application/initializers/load_path_test.rb /^ module Zoo::ReptileHouse ; end$/;" m -[]= lib/rails/paths.rb /^ def []=(path, value)$/;" f class:Rails.Paths.Root -_all_autoload_once_paths lib/rails/engine.rb /^ def _all_autoload_once_paths$/;" f -_all_autoload_paths lib/rails/engine.rb /^ def _all_autoload_paths$/;" f -_all_load_paths lib/rails/engine.rb /^ def _all_load_paths$/;" f -about lib/rails/generators/rails/app/templates/public/index.html /^ function about() {$/;" f -about tmp/app/public/index.html /^ function about() {$/;" f -about tmp/app_template/public/index.html /^ function about() {$/;" f -abstract_railtie? lib/rails/railtie.rb /^ def abstract_railtie?$/;" f class:Rails.Railtie -abstract_unit.rb test/abstract_unit.rb 1;" F -abstract_unit.rb test/isolation/abstract_unit.rb 1;" F -action test/generators/actions_test.rb /^ def action(*args, &block)$/;" f class:ActionsTest -action test/generators/app_generator_test.rb /^ def action(*args, &block)$/;" f -action test/generators/app_generator_test.rb /^ def action(*args, &block)$/;" f class:CustomAppGeneratorTest -action test/generators/plugin_new_generator_test.rb /^ def action(*args, &block)$/;" f class:CustomPluginGeneratorTest -action test/generators/plugin_new_generator_test.rb /^ def action(*args, &block)$/;" f class:PluginNewGeneratorTest -actions.rb lib/rails/generators/actions.rb 1;" F -actions_test.rb test/generators/actions_test.rb 1;" F -active_model.rb lib/rails/generators/active_model.rb 1;" F -add lib/rails/paths.rb /^ def add(path, options={})$/;" f class:Rails.Paths.Root -add_gem_filters lib/rails/backtrace_cleaner.rb /^ def add_gem_filters$/;" f class:Rails.BacktraceCleaner -add_lib_to_load_path! lib/rails/application.rb /^ def add_lib_to_load_path! #:nodoc:$/;" f class:Rails -add_resource_route lib/rails/generators/rails/resource/resource_generator.rb /^ def add_resource_route$/;" f class:Rails.Generators.ResourceGenerator -add_routes lib/rails/generators/rails/controller/controller_generator.rb /^ def add_routes$/;" f class:Rails.Generators.ControllerGenerator -add_shared_options_for lib/rails/generators/app_base.rb /^ def self.add_shared_options_for(name)$/;" F class:Rails.Generators.AppBase -add_shebang_option lib/rails/generators/base.rb /^ def self.add_shebang_option!$/;" F class:Rails -add_source lib/rails/generators/actions.rb /^ def add_source(source, options={})$/;" f class:Rails.Generators.Actions -add_to_config test/isolation/abstract_unit.rb /^ def add_to_config(str)$/;" f -after lib/rails/initializable.rb /^ def after$/;" f class:Rails.Initializable.Initializer -after_dispatch lib/rails/rack/logger.rb /^ def after_dispatch(env)$/;" f class:Rails.Rack.Logger -after_initialize lib/rails/railtie/configuration.rb /^ def after_initialize(&block)$/;" f class:Rails.Railtie.Configuration -aliases lib/rails/generators.rb /^ def self.aliases #:nodoc:$/;" F class:Rails.Generators -all lib/rails/application/railties.rb /^ def all(&block)$/;" f class:Rails.Application.Railties -all lib/rails/engine/railties.rb /^ def all(&block)$/;" f class:Rails.Engine.Railties -all lib/rails/generators/active_model.rb /^ def self.all(klass)$/;" F class:Rails.Generators.ActiveModel -all lib/rails/plugin.rb /^ def self.all(list, paths)$/;" F class:Rails.Plugin -all test/generators/scaffold_controller_generator_test.rb /^ def self.all(klass)$/;" F class:test_customized_orm_is_used -all.rb lib/rails/all.rb 1;" F -all_paths lib/rails/paths.rb /^ def all_paths$/;" f class:Rails.Paths.Root -allowAction lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function allowAction(element) {$/;" f -allowAction tmp/app/public/javascripts/rails.js /^ function allowAction(element) {$/;" f -allowAction tmp/app_template/public/javascripts/rails.js /^ function allowAction(element) {$/;" f -app lib/rails/console/app.rb /^def app(create=false)$/;" f -app lib/rails/engine.rb /^ def app$/;" f -app lib/rails/generators/rails/app/app_generator.rb /^ def app$/;" f class:Rails.AppBuilder -app lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def app$/;" f class:Rails.PluginBuilder -app test/application/configuration_test.rb /^ def app$/;" f class:ApplicationTests.ConfigurationTest -app test/application/initializers/i18n_test.rb /^ def app$/;" f class:ApplicationTests.I18nTest -app test/application/loading_test.rb /^ def app$/;" f class:LoadingTest -app test/application/middleware/remote_ip_test.rb /^ def app$/;" f class:ApplicationTests.RemoteIpTest -app test/application/middleware/sendfile_test.rb /^ def app$/;" f class:ApplicationTests.SendfileTest -app test/application/middleware_test.rb /^ def app$/;" f class:ApplicationTests.MiddlewareTest -app test/application/url_generation_test.rb /^ def app$/;" f class:ApplicationTests.UrlGenerationTest -app test/isolation/abstract_unit.rb /^ def app(env = "production")$/;" f class:TestHelpers.Rack -app test/railties/engine_test.rb /^ def app$/;" f -app test/railties/mounted_engine_test.rb /^ def app$/;" f class:ApplicationTests -app test/railties/railtie_test.rb /^ def app$/;" f class:RailtiesTest.RailtieTest -app test/railties/shared_tests.rb /^ def app$/;" f class:RailtiesTest.SharedTests -app.rb lib/rails/console/app.rb 1;" F -app_base.rb lib/rails/generators/app_base.rb 1;" F -app_const lib/rails/generators/rails/app/app_generator.rb /^ def app_const$/;" f class:Generators.AppGenerator -app_const test/application/generators_test.rb /^ def app_const$/;" f class:ApplicationTests.GeneratorsTest -app_const_base lib/rails/generators/rails/app/app_generator.rb /^ def app_const_base$/;" f class:Generators.AppGenerator -app_file test/isolation/abstract_unit.rb /^ def app_file(path, contents)$/;" f -app_generator.rb lib/rails/generators/rails/app/app_generator.rb 1;" F -app_generator_test.rb test/generators/app_generator_test.rb 1;" F -app_generators lib/rails/railtie/configuration.rb /^ def app_generators$/;" f class:Rails.Railtie.Configuration -app_middleware lib/rails/railtie/configuration.rb /^ def app_middleware$/;" f class:Rails.Railtie.Configuration -app_name lib/rails/generators/rails/app/app_generator.rb /^ def app_name$/;" f class:Generators.AppGenerator -app_path test/isolation/abstract_unit.rb /^ def app_path(*args)$/;" f class:TestHelpers.Paths -app_secret lib/rails/generators/rails/app/app_generator.rb /^ def app_secret$/;" f class:Generators.AppGenerator -app_templates_dir lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def app_templates_dir$/;" f class:Generators.PluginNewGenerator -application lib/rails.rb /^ def application$/;" f class:Rails -application.js lib/rails/generators/rails/app/templates/public/javascripts/application.js 1;" F -application.js tmp/app/public/javascripts/application.js 1;" F -application.js tmp/app_template/public/javascripts/application.js 1;" F -application.rb lib/rails/application.rb 1;" F -application.rb lib/rails/commands/application.rb 1;" F -application.rb lib/rails/generators/rails/app/templates/config/application.rb 1;" F -application.rb lib/rails/generators/rails/plugin_new/templates/rails/application.rb 1;" F -application.rb tmp/app/config/application.rb 1;" F -application.rb tmp/app_template/config/application.rb 1;" F -application= lib/rails.rb /^ def application=(application)$/;" f class:Rails -application_controller.rb lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb 1;" F -application_controller.rb tmp/app/app/controllers/application_controller.rb 1;" F -application_controller.rb tmp/app_template/app/controllers/application_controller.rb 1;" F -application_definition lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def application_definition$/;" f class:Generators.PluginNewGenerator -application_helper.rb lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb 1;" F -application_helper.rb tmp/app/app/helpers/application_helper.rb 1;" F -application_helper.rb tmp/app_template/app/helpers/application_helper.rb 1;" F -application_name lib/rails/generators/named_base.rb /^ def application_name$/;" f class:Rails.Generators -application_route_in_view test/railties/mounted_engine_test.rb /^ def application_route_in_view$/;" f class:ApplicationTests.ApplicationRoutingTest.Blog.PostsController -apply_rails_template lib/rails/generators/app_base.rb /^ def apply_rails_template$/;" f class:Rails.Generators.AppBase -arguments lib/rails/generators/test_case.rb /^ def self.arguments(array)$/;" F class:Rails.Generators.TestCase -assert_body test/isolation/abstract_unit.rb /^ def assert_body(expected, resp)$/;" f class:TestHelpers -assert_class_method lib/rails/generators/test_case.rb /^ def assert_class_method(method, content, &block)$/;" f class:Rails.Generators.TestCase -assert_fallbacks test/application/initializers/i18n_test.rb /^ def assert_fallbacks(fallbacks)$/;" f class:ApplicationTests.I18nTest -assert_field_default_value lib/rails/generators/test_case.rb /^ def assert_field_default_value(attribute_type, value)$/;" f class:Rails.Generators.TestCase -assert_field_type lib/rails/generators/test_case.rb /^ def assert_field_type(attribute_type, field_type)$/;" f class:Rails.Generators.TestCase -assert_file lib/rails/generators/test_case.rb /^ def assert_file(relative, *contents)$/;" f class:Rails.Generators.TestCase -assert_header test/isolation/abstract_unit.rb /^ def assert_header(key, value, resp)$/;" f class:TestHelpers -assert_in_load_path test/application/paths_test.rb /^ def assert_in_load_path(*path)$/;" f class:ApplicationTests.PathsTest -assert_instance_method lib/rails/generators/test_case.rb /^ def assert_instance_method(method, content)$/;" f class:Rails.Generators.TestCase -assert_migration lib/rails/generators/test_case.rb /^ def assert_migration(relative, *contents, &block)$/;" f class:Rails.Generators.TestCase -assert_missing test/isolation/abstract_unit.rb /^ def assert_missing(resp)$/;" f class:TestHelpers -assert_name test/generators/named_base_test.rb /^ def assert_name(generator, value, method)$/;" f class:NamedBaseTest -assert_no_fallbacks test/application/initializers/i18n_test.rb /^ def assert_no_fallbacks$/;" f class:ApplicationTests.I18nTest -assert_no_file lib/rails/generators/test_case.rb /^ def assert_no_file(relative)$/;" f class:Rails.Generators.TestCase -assert_no_migration lib/rails/generators/test_case.rb /^ def assert_no_migration(relative)$/;" f class:Rails.Generators.TestCase -assert_not_in_load_path test/application/paths_test.rb /^ def assert_not_in_load_path(*path)$/;" f class:ApplicationTests.PathsTest -assert_path test/application/paths_test.rb /^ def assert_path(paths, *dir)$/;" f class:ApplicationTests.PathsTest -assert_property test/rails_info_test.rb /^ def assert_property(property_name, value)$/;" f -assert_rails_boots test/application/initializers/check_ruby_version_test.rb /^ def assert_rails_boots$/;" f class:ApplicationTests -assert_rails_does_not_boot test/application/initializers/check_ruby_version_test.rb /^ def assert_rails_does_not_boot$/;" f -assert_success test/isolation/abstract_unit.rb /^ def assert_success(resp)$/;" f class:TestHelpers -assert_utf8 test/application/configuration_test.rb /^ def assert_utf8$/;" f -assert_welcome test/isolation/abstract_unit.rb /^ def assert_welcome(resp)$/;" f class:TestHelpers -assign_names! lib/rails/generators/named_base.rb /^ def assign_names!(name) #:nodoc:$/;" f class:Rails.Generators -author guides/rails_guides/helpers.rb /^ def author(name, nick, image = 'credits_pic_blank.gif', &block)$/;" f class:RailsGuides.Helpers -autoload_once lib/rails/paths.rb /^ def autoload_once$/;" f class:Rails.Paths.Root -autoload_once_paths lib/rails/engine/configuration.rb /^ def autoload_once_paths$/;" f class:Rails.Engine.Configuration -autoload_paths lib/rails/engine/configuration.rb /^ def autoload_paths$/;" f class:Rails.Engine.Configuration -autoload_paths lib/rails/paths.rb /^ def autoload_paths$/;" f class:Rails.Paths.Root -available_views lib/rails/generators/erb/scaffold/scaffold_generator.rb /^ def available_views$/;" f class:Erb.Generators.ScaffoldGenerator -backtrace_cleaner lib/rails.rb /^ def backtrace_cleaner$/;" f class:Rails -backtrace_cleaner.rb lib/rails/backtrace_cleaner.rb 1;" F -backtrace_cleaner_test.rb test/backtrace_cleaner_test.rb 1;" F -backtrace_silencers.rb lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb 1;" F -backtrace_silencers.rb tmp/app_template/config/initializers/backtrace_silencers.rb 1;" F -banner lib/rails/generators/base.rb /^ def self.banner$/;" F class:Rails -banner lib/rails/generators/rails/app/app_generator.rb /^ def self.banner$/;" F class:Generators.AppGenerator -banner lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def self.banner$/;" F class:Generators.PluginNewGenerator -bar test/application/routing_test.rb /^ def bar$/;" f class:FooController -bar test/railties/engine_test.rb /^ def bar$/;" f class:BarHelper -bar test/railties/engine_test.rb /^ def bar$/;" f class:Bukkits -base.rb lib/rails/generators/base.rb 1;" F -base_name lib/rails/generators/base.rb /^ def self.base_name$/;" F class:Rails -base_root lib/rails/generators/base.rb /^ def self.base_root$/;" F class:Rails -baz test/application/routing_test.rb /^ def baz$/;" f class:FooController -before lib/rails/initializable.rb /^ def before$/;" f class:Rails.Initializable.Initializer -before_configuration lib/rails/railtie/configuration.rb /^ def before_configuration(&block)$/;" f class:Rails.Railtie.Configuration -before_dispatch lib/rails/rack/logger.rb /^ def before_dispatch(env)$/;" f class:Rails.Rack.Logger -before_eager_load lib/rails/railtie/configuration.rb /^ def before_eager_load(&block)$/;" f class:Rails.Railtie.Configuration -before_initialize lib/rails/railtie/configuration.rb /^ def before_initialize(&block)$/;" f class:Rails.Railtie.Configuration -benchmarker.rb lib/rails/commands/benchmarker.rb 1;" F -best_install_method lib/rails/commands/plugin.rb /^ def best_install_method$/;" f class:RailsEnvironment -best_practices_test.rb test/application/middleware/best_practices_test.rb 1;" F -bind lib/rails/initializable.rb /^ def bind(context)$/;" f class:Rails.Initializable.Initializer -boot! test/application/middleware_test.rb /^ def boot!$/;" f -boot.rb lib/rails/generators/rails/app/templates/config/boot.rb 1;" F -boot.rb lib/rails/generators/rails/plugin_new/templates/rails/boot.rb 1;" F -boot.rb tmp/app/config/boot.rb 1;" F -boot.rb tmp/app_template/config/boot.rb 1;" F -boot_rails test/isolation/abstract_unit.rb /^ def boot_rails$/;" f -boot_rails test/railties/plugin_ordering_test.rb /^ def boot_rails$/;" f class:RailtiesTest.PluginOrderingTest -boot_rails test/railties/shared_tests.rb /^ def boot_rails$/;" f class:RailtiesTest.SharedTests -boot_test.rb test/application/initializers/boot_test.rb 1;" F -bootstrap.rb lib/rails/application/bootstrap.rb 1;" F -browsing_test.rb lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb 1;" F -browsing_test.rb tmp/app/test/performance/browsing_test.rb 1;" F -browsing_test.rb tmp/app_template/test/performance/browsing_test.rb 1;" F -build lib/rails/generators/active_model.rb /^ def self.build(klass, params=nil)$/;" F class:Rails.Generators.ActiveModel -build lib/rails/generators/app_base.rb /^ def build(meth, *args)$/;" f class:Rails.Generators.AppBase -build_app test/isolation/abstract_unit.rb /^ def build_app(options = {})$/;" f class:Generation -builder lib/rails/generators/app_base.rb /^ def builder$/;" f class:Rails.Generators.AppBase -builder_class test/generators/app_generator_test.rb /^ def builder_class$/;" f class:CustomAppGeneratorTest -builder_class test/generators/plugin_new_generator_test.rb /^ def builder_class$/;" f class:CustomPluginGeneratorTest -builders_dir test/generators/app_generator_test.rb /^ def builders_dir$/;" f class:CustomAppGeneratorTest -builders_dir test/generators/plugin_new_generator_test.rb /^ def builders_dir$/;" f class:CustomPluginGeneratorTest -bukkits test/railties/shared_tests.rb /^ def bukkits$/;" f class:RailtiesTest.test_adds_helpers_to_controller_views.BukkitHelper -bundle_if_dev_or_edge lib/rails/generators/app_base.rb /^ def bundle_if_dev_or_edge$/;" f class:Rails.Generators -bundler? guides/rails_guides.rb /^def bundler?$/;" f -cache lib/rails.rb /^ def cache$/;" f class:Rails -cache_store lib/rails/application/configuration.rb /^ def cache_store$/;" f class:Rails.Application.Configuration -cache_test.rb test/application/middleware/cache_test.rb 1;" F -calculate_code lib/rails/code_statistics.rb /^ def calculate_code$/;" f class:CodeStatistics -calculate_directory_statistics lib/rails/code_statistics.rb /^ def calculate_directory_statistics(directory, pattern = \/.*\\.rb$\/)$/;" f class:CodeStatistics -calculate_statistics lib/rails/code_statistics.rb /^ def calculate_statistics$/;" f class:CodeStatistics -calculate_tests lib/rails/code_statistics.rb /^ def calculate_tests$/;" f class:CodeStatistics -calculate_total lib/rails/code_statistics.rb /^ def calculate_total$/;" f class:CodeStatistics -call lib/rails/engine.rb /^ def call(env)$/;" f -call lib/rails/rack/debugger.rb /^ def call(env)$/;" f class:Rails.Rack.Debugger -call lib/rails/rack/log_tailer.rb /^ def call(env)$/;" f class:Rails.Rack.LogTailer -call lib/rails/rack/logger.rb /^ def call(env)$/;" f class:Rails.Rack.Logger -call test/application/middleware_test.rb /^ def call(env)$/;" f -call test/railties/engine_test.rb /^ def call(env)$/;" f class:Upcaser -call test/railties/shared_tests.rb /^ def call(env)$/;" f class:RailtiesTest.test_midleware_referenced_in_configuration.Bukkits -call test/railties/shared_tests.rb /^ def self.call(env)$/;" F class:RailtiesTest.test_routes_are_added_to_router.Sprokkit -camelized lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def camelized$/;" f class:Generators.PluginNewGenerator -capify! lib/rails/generators/actions.rb /^ def capify!$/;" f class:Rails.Generators -check_class_collision lib/rails/generators/named_base.rb /^ def self.check_class_collision(options={})$/;" F class:Rails.Generators -check_fragment_identifiers guides/rails_guides/generator.rb /^ def check_fragment_identifiers(html, anchors)$/;" f -check_ruby_version_test.rb test/application/initializers/check_ruby_version_test.rb 1;" F -child.id lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var child = {$/;" p -child.id tmp/app/public/javascripts/dragdrop.js /^ var child = {$/;" p -child.id tmp/app_template/public/javascripts/dragdrop.js /^ var child = {$/;" p -children lib/rails/paths.rb /^ def children$/;" f class:Rails.Paths.Path -class_collisions lib/rails/generators/base.rb /^ def class_collisions(*class_names) #:nodoc:$/;" f class:Rails -class_name lib/rails/generators/named_base.rb /^ def class_name$/;" f class:Rails.Generators -class_option lib/rails/generators/base.rb /^ def self.class_option(name, options={}) #:nodoc:$/;" F class:Rails -class_path lib/rails/generators/named_base.rb /^ def class_path$/;" f class:Rails.Generators -clear! lib/rails/application/routes_reloader.rb /^ def clear!$/;" f class:Rails.Application.RoutesReloader -cli.rb lib/rails/cli.rb 1;" F -clone lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function clone(object) {$/;" f -clone tmp/app/public/javascripts/prototype.js /^ function clone(object) {$/;" f -clone tmp/app_template/public/javascripts/prototype.js /^ function clone(object) {$/;" f -code guides/rails_guides/helpers.rb /^ def code(&block)$/;" f class:RailsGuides.Helpers -code guides/rails_guides/textile_extensions.rb /^ def code(body)$/;" f class:RailsGuides.TextileExtensions -code_statistics.rb lib/rails/code_statistics.rb 1;" F -colorize_logging lib/rails/application/configuration.rb /^ def colorize_logging$/;" f class:Rails.Application.Configuration -colorize_logging= lib/rails/application/configuration.rb /^ def colorize_logging=(val)$/;" f class:Rails.Application.Configuration -commands.rb lib/rails/commands.rb 1;" F -compiled_asset_path lib/rails/application/configuration.rb /^ def compiled_asset_path$/;" f class:Rails.Application.Configuration -compiled_asset_path lib/rails/engine/configuration.rb /^ def compiled_asset_path$/;" f class:Rails.Engine.Configuration -config lib/rails/application.rb /^ def config$/;" f class:Rails -config lib/rails/engine.rb /^ def config$/;" f -config lib/rails/generators/rails/app/app_generator.rb /^ def config$/;" f class:Rails.AppBuilder -config lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def config$/;" f class:Rails.PluginBuilder -config lib/rails/plugin.rb /^ def config$/;" f class:Rails -config lib/rails/railtie.rb /^ def config$/;" f class:Rails -configru lib/rails/generators/rails/app/app_generator.rb /^ def configru$/;" f class:Rails.AppBuilder -configurable.rb lib/rails/railtie/configurable.rb 1;" F -configuration lib/rails.rb /^ def configuration$/;" f class:Rails -configuration.rb lib/rails/application/configuration.rb 1;" F -configuration.rb lib/rails/configuration.rb 1;" F -configuration.rb lib/rails/engine/configuration.rb 1;" F -configuration.rb lib/rails/railtie/configuration.rb 1;" F -configuration_test.rb test/application/configuration_test.rb 1;" F -configure lib/rails/generators.rb /^ def self.configure!(config = Rails.application.config.generators) #:nodoc:$/;" F class:Rails.Generators -configure lib/rails/railtie/configurable.rb /^ def configure(&block)$/;" f class:Rails.Railtie.Configurable.ClassMethods -consider_all_requests_local? lib/rails/info_controller.rb /^ def consider_all_requests_local?$/;" f class:Rails -console lib/rails/railtie.rb /^ def console(&blk)$/;" f class:Rails.Railtie -console.rb lib/rails/commands/console.rb 1;" F -console_test.rb test/application/console_test.rb 1;" F -controller lib/rails/console/helpers.rb /^def controller$/;" f -controller test/isolation/abstract_unit.rb /^ def controller(name, contents)$/;" f -controller.rb lib/rails/generators/rails/controller/templates/controller.rb 1;" F -controller.rb lib/rails/generators/rails/scaffold_controller/templates/controller.rb 1;" F -controller_class_name lib/rails/generators/resource_helpers.rb /^ def controller_class_name$/;" f class:Rails.Generators.ResourceHelpers -controller_class_path lib/rails/generators/resource_helpers.rb /^ def controller_class_path$/;" f class:Rails.Generators.ResourceHelpers -controller_file_name lib/rails/generators/resource_helpers.rb /^ def controller_file_name$/;" f class:Rails.Generators.ResourceHelpers -controller_file_path lib/rails/generators/resource_helpers.rb /^ def controller_file_path$/;" f class:Rails.Generators.ResourceHelpers -controller_generator.rb lib/rails/generators/erb/controller/controller_generator.rb 1;" F -controller_generator.rb lib/rails/generators/rails/controller/controller_generator.rb 1;" F -controller_generator.rb lib/rails/generators/test_unit/controller/controller_generator.rb 1;" F -controller_generator_test.rb test/generators/controller_generator_test.rb 1;" F -controller_i18n_scope lib/rails/generators/resource_helpers.rb /^ def controller_i18n_scope$/;" f class:Rails.Generators.ResourceHelpers -controls.js lib/rails/generators/rails/app/templates/public/javascripts/controls.js 1;" F -controls.js tmp/app/public/javascripts/controls.js 1;" F -controls.js tmp/app_template/public/javascripts/controls.js 1;" F -copy_app test/application/configuration_test.rb /^ def copy_app$/;" f class:ApplicationTests.ConfigurationTest -copy_assets guides/rails_guides/generator.rb /^ def copy_assets$/;" f class:RailsGuides.Generator -copy_routes test/generators/generators_test_helper.rb /^ def copy_routes$/;" f class:GeneratorsTestHelper -copy_stylesheets_file lib/rails/generators/rails/stylesheets/stylesheets_generator.rb /^ def copy_stylesheets_file$/;" f class:Rails.Generators.StylesheetsGenerator -copy_view_files lib/rails/generators/erb/controller/controller_generator.rb /^ def copy_view_files$/;" f class:Erb.Generators.ControllerGenerator -copy_view_files lib/rails/generators/erb/scaffold/scaffold_generator.rb /^ def copy_view_files$/;" f class:Erb.Generators.ScaffoldGenerator -count test/application/runner_test.rb /^ def self.count$/;" F class:ApplicationTests.RunnerTest.setup.User -create lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def create$/;" f -create_active_record_files lib/rails/generators/rails/app/app_generator.rb /^ def create_active_record_files$/;" f class:Generators.AppGenerator -create_app_files lib/rails/generators/rails/app/app_generator.rb /^ def create_app_files$/;" f class:Generators.AppGenerator -create_app_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_app_files$/;" f class:Generators.PluginNewGenerator -create_boot_file lib/rails/generators/rails/app/app_generator.rb /^ def create_boot_file$/;" f class:Generators.AppGenerator -create_config_files lib/rails/generators/rails/app/app_generator.rb /^ def create_config_files$/;" f class:Generators.AppGenerator -create_config_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_config_files$/;" f class:Generators.PluginNewGenerator -create_controller_files lib/rails/generators/rails/controller/controller_generator.rb /^ def create_controller_files$/;" f class:Rails.Generators.ControllerGenerator -create_controller_files lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb /^ def create_controller_files$/;" f class:Rails.Generators.ScaffoldControllerGenerator -create_db_files lib/rails/generators/rails/app/app_generator.rb /^ def create_db_files$/;" f class:Generators.AppGenerator -create_doc_files lib/rails/generators/rails/app/app_generator.rb /^ def create_doc_files$/;" f class:Generators.AppGenerator -create_dummy_app lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_dummy_app(path = nil)$/;" f class:Generators.PluginNewGenerator -create_fixture_file lib/rails/generators/test_unit/model/model_generator.rb /^ def create_fixture_file$/;" f class:TestUnit.Generators.ModelGenerator -create_fixtures lib/rails/test_help.rb /^ def create_fixtures(*table_names, &block)$/;" f -create_generated_attribute lib/rails/generators/test_case.rb /^ def create_generated_attribute(attribute_type, name = 'test')$/;" f class:Rails.Generators.TestCase -create_generator_files lib/rails/generators/rails/generator/generator_generator.rb /^ def create_generator_files$/;" f class:Rails.Generators.GeneratorGenerator -create_helper_files lib/rails/generators/rails/helper/helper_generator.rb /^ def create_helper_files$/;" f class:Rails.Generators.HelperGenerator -create_helper_files lib/rails/generators/test_unit/helper/helper_generator.rb /^ def create_helper_files$/;" f class:TestUnit.Generators.HelperGenerator -create_javascript_files lib/rails/generators/rails/app/app_generator.rb /^ def create_javascript_files$/;" f class:Generators.AppGenerator -create_javascript_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_javascript_files$/;" f class:Generators.PluginNewGenerator -create_lib_files lib/rails/generators/rails/app/app_generator.rb /^ def create_lib_files$/;" f class:Generators.AppGenerator -create_lib_files lib/rails/generators/rails/plugin/plugin_generator.rb /^ def create_lib_files$/;" f class:Rails.Generators.PluginGenerator -create_lib_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_lib_files$/;" f class:Generators.PluginNewGenerator -create_log_files lib/rails/generators/rails/app/app_generator.rb /^ def create_log_files$/;" f class:Generators.AppGenerator -create_output_dir_if_needed guides/rails_guides/generator.rb /^ def create_output_dir_if_needed$/;" f class:RailsGuides.Generator -create_public_files lib/rails/generators/rails/app/app_generator.rb /^ def create_public_files$/;" f class:Generators.AppGenerator -create_public_image_files lib/rails/generators/rails/app/app_generator.rb /^ def create_public_image_files$/;" f class:Generators.AppGenerator -create_public_stylesheets_files lib/rails/generators/rails/app/app_generator.rb /^ def create_public_stylesheets_files$/;" f class:Generators.AppGenerator -create_public_stylesheets_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_public_stylesheets_files$/;" f class:Generators.PluginNewGenerator -create_root lib/rails/generators/app_base.rb /^ def create_root$/;" f class:Rails.Generators.AppBase -create_root_files lib/rails/generators/rails/app/app_generator.rb /^ def create_root_files$/;" f class:Generators.AppGenerator -create_root_files lib/rails/generators/rails/plugin/plugin_generator.rb /^ def create_root_files$/;" f class:Rails.Generators.PluginGenerator -create_root_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_root_files$/;" f class:Generators.PluginNewGenerator -create_root_folder lib/rails/generators/erb/scaffold/scaffold_generator.rb /^ def create_root_folder$/;" f class:Erb.Generators.ScaffoldGenerator -create_script_files lib/rails/generators/rails/app/app_generator.rb /^ def create_script_files$/;" f class:Generators.AppGenerator -create_script_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_script_files$/;" f class:Generators.PluginNewGenerator -create_tasks_files lib/rails/generators/rails/plugin/plugin_generator.rb /^ def create_tasks_files$/;" f class:Rails.Generators.PluginGenerator -create_test_dummy_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_test_dummy_files$/;" f class:Generators.PluginNewGenerator -create_test_dummy_template.rb test/fixtures/lib/create_test_dummy_template.rb 1;" F -create_test_file lib/rails/generators/test_unit/model/model_generator.rb /^ def create_test_file$/;" f class:TestUnit.Generators.ModelGenerator -create_test_files lib/rails/generators/rails/app/app_generator.rb /^ def create_test_files$/;" f class:Generators.AppGenerator -create_test_files lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def create_test_files$/;" f class:Generators.PluginNewGenerator -create_test_files lib/rails/generators/test_unit/controller/controller_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.ControllerGenerator -create_test_files lib/rails/generators/test_unit/integration/integration_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.IntegrationGenerator -create_test_files lib/rails/generators/test_unit/mailer/mailer_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.MailerGenerator -create_test_files lib/rails/generators/test_unit/observer/observer_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.ObserverGenerator -create_test_files lib/rails/generators/test_unit/performance/performance_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.PerformanceGenerator -create_test_files lib/rails/generators/test_unit/plugin/plugin_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.PluginGenerator -create_test_files lib/rails/generators/test_unit/scaffold/scaffold_generator.rb /^ def create_test_files$/;" f class:TestUnit.Generators.ScaffoldGenerator -create_tmp_files lib/rails/generators/rails/app/app_generator.rb /^ def create_tmp_files$/;" f class:Generators.AppGenerator -create_vendor_files lib/rails/generators/rails/app/app_generator.rb /^ def create_vendor_files$/;" f class:Generators.AppGenerator -current_migration_number lib/rails/generators/migration.rb /^ def current_migration_number(dirname) #:nodoc:$/;" f class:Rails.Generators.Migration.ClassMethods -database_configuration lib/rails/application/configuration.rb /^ def database_configuration$/;" f class:Rails.Application.Configuration -database_gemfile_entry lib/rails/generators/app_base.rb /^ def database_gemfile_entry$/;" f class:Rails.Generators -database_yml lib/rails/generators/rails/app/app_generator.rb /^ def database_yml$/;" f class:Rails -db lib/rails/generators/rails/app/app_generator.rb /^ def db$/;" f class:Rails -dbconsole.rb lib/rails/commands/dbconsole.rb 1;" F -debugger.rb lib/rails/rack/debugger.rb 1;" F -default lib/rails/commands/plugin.rb /^ def self.default$/;" F class:RailsEnvironment -default lib/rails/commands/plugin.rb /^ def self.default=(rails_env)$/;" F class:RailsEnvironment -default lib/rails/generators/generated_attribute.rb /^ def default$/;" f class:Rails.Generators -default_aliases_for_option lib/rails/generators/base.rb /^ def self.default_aliases_for_option(name, options)$/;" F class:Rails -default_asset_path lib/rails/application.rb /^ def default_asset_path$/;" f class:Rails -default_asset_path lib/rails/engine.rb /^ def default_asset_path$/;" f -default_files test/generators/app_generator_test.rb /^ def default_files$/;" f class:AppGeneratorTest -default_files test/generators/app_generator_test.rb /^ def default_files$/;" f class:CustomAppGeneratorTest -default_files test/generators/plugin_new_generator_test.rb /^ def default_files$/;" f class:CustomPluginGeneratorTest -default_files test/generators/plugin_new_generator_test.rb /^ def default_files$/;" f class:PluginNewGeneratorTest -default_for_option lib/rails/generators/base.rb /^ def self.default_for_option(config, name, options, default)$/;" F class:Rails -default_middleware_stack lib/rails/application.rb /^ def default_middleware_stack$/;" f class:Rails -default_middleware_stack lib/rails/engine.rb /^ def default_middleware_stack$/;" f -default_options lib/rails/commands/server.rb /^ def default_options$/;" f class:Rails.Server -default_source_root lib/rails/generators/base.rb /^ def self.default_source_root$/;" F class:Rails -default_value_for_option lib/rails/generators/base.rb /^ def self.default_value_for_option(name, options)$/;" F class:Rails -defined_app_const_base lib/rails/generators/rails/app/app_generator.rb /^ def defined_app_const_base$/;" f class:Generators.AppGenerator -defined_app_name lib/rails/generators/rails/app/app_generator.rb /^ def defined_app_name$/;" f class:Generators.AppGenerator -delete lib/rails/configuration.rb /^ def delete(*args, &block)$/;" f class:Rails.Configuration.MiddlewareStackProxy -delete test/isolation/abstract_unit.rb /^ def delete(file)$/;" f class:Bukkit -desc lib/rails/generators/base.rb /^ def self.desc(description=nil)$/;" F class:Rails.Generators.Base -destination lib/rails/generators/test_case.rb /^ def self.destination(path)$/;" F class:Rails.Generators.TestCase -destination_root_is_set? lib/rails/generators/test_case.rb /^ def destination_root_is_set? #:nodoc:$/;" f class:Rails.Generators.TestCase -destroy lib/rails/generators/active_model.rb /^ def destroy$/;" f class:Rails.Generators.ActiveModel -destroy lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def destroy$/;" f -destroy.rb lib/rails/commands/destroy.rb 1;" F -determine_install_method lib/rails/commands/plugin.rb /^ def determine_install_method$/;" f class:Commands.Install -dev_or_edge? lib/rails/generators/app_base.rb /^ def dev_or_edge?$/;" f class:Rails.Generators -development.rb tmp/app_template/config/environments/development.rb 1;" F -disableFormElements lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function disableFormElements(form) {$/;" f -disableFormElements tmp/app/public/javascripts/rails.js /^ function disableFormElements(form) {$/;" f -disableFormElements tmp/app_template/public/javascripts/rails.js /^ function disableFormElements(form) {$/;" f -display lib/rails/source_annotation_extractor.rb /^ def display(results, options={})$/;" f -distance guides/rails_guides/levenshtein.rb /^ def self.distance(s1, s2)$/;" F class:RailsGuides.Levenshtein -doc lib/rails/generators/rails/app/app_generator.rb /^ def doc$/;" f class:Rails -download lib/rails/commands/plugin.rb /^ def download(link)$/;" f class:RecursiveHTTPFetcher -dragdrop.js lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js 1;" F -dragdrop.js tmp/app/public/javascripts/dragdrop.js 1;" F -dragdrop.js tmp/app_template/public/javascripts/dragdrop.js 1;" F -drop lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var drop, affected = [];$/;" v -drop tmp/app/public/javascripts/dragdrop.js /^ var drop, affected = [];$/;" v -drop tmp/app_template/public/javascripts/dragdrop.js /^ var drop, affected = [];$/;" v -droponOptions lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var droponOptions = Sortable.options(dropon);$/;" v -droponOptions tmp/app/public/javascripts/dragdrop.js /^ var droponOptions = Sortable.options(dropon);$/;" v -droponOptions tmp/app_template/public/javascripts/dragdrop.js /^ var droponOptions = Sortable.options(dropon);$/;" v -dummy_path lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def dummy_path(path = nil)$/;" f class:Generators.PluginNewGenerator -eager_load lib/rails/paths.rb /^ def eager_load$/;" f class:Rails.Paths.Root -eager_load! lib/rails/application.rb /^ def eager_load! #:nodoc:$/;" f class:Rails -eager_load! lib/rails/engine.rb /^ def eager_load!$/;" f class:Rails -eager_load! lib/rails/railtie.rb /^ def eager_load!$/;" f class:Rails -eager_load_paths lib/rails/engine/configuration.rb /^ def eager_load_paths$/;" f class:Rails.Engine.Configuration -edit lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def edit$/;" f -effects.js lib/rails/generators/rails/app/templates/public/javascripts/effects.js 1;" F -effects.js tmp/app/public/javascripts/effects.js 1;" F -effects.js tmp/app_template/public/javascripts/effects.js 1;" F -empty_builder.rb test/fixtures/lib/app_builders/empty_builder.rb 1;" F -empty_builder.rb test/fixtures/lib/plugin_builders/empty_builder.rb 1;" F -empty_directory_with_gitkeep lib/rails/generators/app_base.rb /^ def empty_directory_with_gitkeep(destination, config = {})$/;" f class:Rails.Generators -enableFormElements lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function enableFormElements(form) {$/;" f -enableFormElements tmp/app/public/javascripts/rails.js /^ function enableFormElements(form) {$/;" f -enableFormElements tmp/app_template/public/javascripts/rails.js /^ function enableFormElements(form) {$/;" f -encoding= lib/rails/application/configuration.rb /^ def encoding=(value)$/;" f class:Rails.Application.Configuration -endpoint lib/rails/engine.rb /^ def endpoint(endpoint = nil)$/;" f class:Rails.Engine -endpoint lib/rails/engine.rb /^ def endpoint$/;" f -engine test/isolation/abstract_unit.rb /^ def engine(name)$/;" f -engine.rb lib/rails/engine.rb 1;" F -engine.rb lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb 1;" F -engine_route test/railties/mounted_engine_test.rb /^ def engine_route$/;" f class:ApplicationTests.ApplicationRoutingTest.ApplicationGeneratingController -engine_route_in_view test/railties/mounted_engine_test.rb /^ def engine_route_in_view$/;" f class:ApplicationTests.ApplicationRoutingTest.ApplicationGeneratingController -engine_test.rb test/railties/engine_test.rb 1;" F -engines lib/rails/engine/railties.rb /^ def self.engines$/;" F class:Rails.Engine.Railties -ensure_current_path lib/rails/generators/test_case.rb /^ def ensure_current_path #:nodoc:$/;" f class:Rails.Generators.TestCase -enumerate lib/rails/source_annotation_extractor.rb /^ def self.enumerate(tag, options={})$/;" F class:SourceAnnotationExtractor -env lib/rails.rb /^ def env$/;" f class:Rails -env= lib/rails.rb /^ def env=(environment)$/;" f class:Rails -env_config lib/rails/application.rb /^ def env_config$/;" f class:Rails -env_config lib/rails/engine.rb /^ def env_config$/;" f -environment lib/rails/generators/actions.rb /^ def environment(data=nil, options={}, &block)$/;" f class:Rails.Generators.Actions -environment.rb lib/rails/generators/rails/app/templates/config/environment.rb 1;" F -environment.rb tmp/app/config/environment.rb 1;" F -environment.rb tmp/app_template/config/environment.rb 1;" F -environment= lib/rails/commands/plugin.rb /^ def environment=(value)$/;" f class:Commands.Plugin -erb.rb lib/rails/generators/erb.rb 1;" F -errors lib/rails/generators/active_model.rb /^ def errors$/;" f class:Rails.Generators.ActiveModel -exec_script_rails lib/rails/script_rails_loader.rb /^ def self.exec_script_rails!$/;" F class:Rails.ScriptRailsLoader -existent lib/rails/paths.rb /^ def existent$/;" f class:Rails -expanded lib/rails/paths.rb /^ def expanded$/;" f class:Rails -expires_etag test/application/middleware/cache_test.rb /^ def expires_etag$/;" f class:ApplicationTests.RoutingTest.simple_controller.ExpiresController -expires_header test/application/middleware/cache_test.rb /^ def expires_header$/;" f class:ApplicationTests.RoutingTest.simple_controller.ExpiresController -expires_last_modified test/application/middleware/cache_test.rb /^ def expires_last_modified$/;" f class:ApplicationTests.RoutingTest.simple_controller.ExpiresController -extend lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function extend(destination, source) {$/;" f -extend tmp/app/public/javascripts/prototype.js /^ function extend(destination, source) {$/;" f -extend tmp/app_template/public/javascripts/prototype.js /^ function extend(destination, source) {$/;" f -externals lib/rails/commands/plugin.rb /^ def externals$/;" f class:RailsEnvironment -externals= lib/rails/commands/plugin.rb /^ def externals=(items)$/;" f class:RailsEnvironment -extify lib/rails/generators/actions.rb /^ def extify(name)$/;" f class:Rails.Generators.route -extract_anchors guides/rails_guides/generator.rb /^ def extract_anchors(html)$/;" f class:RailsGuides -extract_annotations_from lib/rails/source_annotation_extractor.rb /^ def extract_annotations_from(file, pattern)$/;" f -extract_body test/isolation/abstract_unit.rb /^ def extract_body(response)$/;" f class:TestHelpers.Rack -fallbacks lib/rails/generators.rb /^ def self.fallbacks$/;" F class:Rails.Generators -fetch lib/rails/commands/plugin.rb /^ def fetch(links = @urls_to_fetch)$/;" f -fetch_dir lib/rails/commands/plugin.rb /^ def fetch_dir(url)$/;" f -field_type lib/rails/generators/generated_attribute.rb /^ def field_type$/;" f class:Rails.Generators.GeneratedAttribute -file lib/rails/generators/rails/app/app_generator.rb /^ def file(*args, &block)$/;" f class:Generators.AppGenerator -file_path lib/rails/generators/named_base.rb /^ def file_path$/;" f class:Rails.Generators -filename_with_extensions lib/rails/generators/erb.rb /^ def filename_with_extensions(name)$/;" f class:Erb.Generators.Base -filter_backtrace_with_cleaning lib/rails/backtrace_cleaner.rb /^ def filter_backtrace_with_cleaning(backtrace, prefix=nil)$/;" f class:Rails.BacktraceFilterForTestUnit -filter_by lib/rails/paths.rb /^ def filter_by(constraint)$/;" f class:Rails.Paths.Root -finalize! lib/rails/application/routes_reloader.rb /^ def finalize!$/;" f class:Rails.Application.RoutesReloader -find lib/rails/commands/plugin.rb /^ def self.find(dir=nil)$/;" F class:RailsEnvironment -find lib/rails/commands/plugin.rb /^ def self.find(name)$/;" F class:Plugin -find lib/rails/engine.rb /^ def find(path)$/;" f class:Rails.Engine -find lib/rails/generators/active_model.rb /^ def self.find(klass, params=nil)$/;" F class:Rails.Generators.ActiveModel -find lib/rails/source_annotation_extractor.rb /^ def find(dirs=%w(app lib test))$/;" f class:SourceAnnotationExtractor -find_by_namespace lib/rails/generators.rb /^ def self.find_by_namespace(name, base=nil, context=nil) #:nodoc:$/;" F class:Rails.Generators -find_cmd lib/rails/commands/dbconsole.rb /^ def find_cmd(*commands)$/;" f -find_in lib/rails/source_annotation_extractor.rb /^ def find_in(dir)$/;" f class:SourceAnnotationExtractor -find_root_with_flag lib/rails/engine.rb /^ def find_root_with_flag(flag, default=nil)$/;" f -finish_template lib/rails/generators/rails/app/app_generator.rb /^ def finish_template$/;" f class:Generators.AppGenerator -finish_template lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def finish_template$/;" f class:Generators.PluginNewGenerator -finisher.rb lib/rails/application/finisher.rb 1;" F -first lib/rails/paths.rb /^ def first$/;" f class:Rails.Paths.Path -fixjour_generator.rb test/fixtures/lib/generators/active_record/fixjour_generator.rb 1;" F -fixjour_generator.rb test/fixtures/lib/generators/fixjour_generator.rb 1;" F -foo_or_bar? test/application/routing_test.rb /^ def foo_or_bar?$/;" f class:BarHelper -foobar_generator.rb test/fixtures/lib/rails/generators/foobar/foobar_generator.rb 1;" F -format lib/rails/generators/erb.rb /^ def format$/;" f class:Erb.Generators.Base -format lib/rails/generators/erb/mailer/mailer_generator.rb /^ def format$/;" f class:Erb.Generators.MailerGenerator -framework_path test/isolation/abstract_unit.rb /^ def framework_path$/;" f class:TestHelpers.Paths -framework_version lib/rails/info.rb /^ def framework_version(framework)$/;" f class:Rails -frameworks lib/rails/info.rb /^ def frameworks$/;" f class:Rails -frameworks_test.rb test/application/initializers/frameworks_test.rb 1;" F -from_app test/railties/engine_test.rb /^ def from_app$/;" f class:Bukkits -from_app_helper test/application/initializers/frameworks_test.rb /^ def from_app_helper$/;" f class:ApplicationHelper -from_bar_helper test/application/initializers/frameworks_test.rb /^ def from_bar_helper$/;" f class:BarHelper -from_foo_helper test/application/initializers/frameworks_test.rb /^ def from_foo_helper$/;" f class:FooHelper -full? lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def full?$/;" f class:Generators.PluginNewGenerator -functional_test.rb lib/rails/generators/test_unit/controller/templates/functional_test.rb 1;" F -functional_test.rb lib/rails/generators/test_unit/mailer/templates/functional_test.rb 1;" F -functional_test.rb lib/rails/generators/test_unit/scaffold/templates/functional_test.rb 1;" F -gem lib/rails/generators/actions.rb /^ def gem(*args)$/;" f class:Rails.Generators.Actions -gem_for_database lib/rails/generators/app_base.rb /^ def gem_for_database$/;" f class:Rails.Generators -gemfile lib/rails/generators/rails/app/app_generator.rb /^ def gemfile$/;" f class:Rails.AppBuilder -gemfile lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def gemfile$/;" f class:Rails.PluginBuilder -gemspec lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def gemspec$/;" f class:Rails.PluginBuilder -generate guides/rails_guides/generator.rb /^ def generate$/;" f class:RailsGuides.Generator -generate lib/rails/generators/actions.rb /^ def generate(what, *args)$/;" f class:Rails.Generators -generate.rb lib/rails/commands/generate.rb 1;" F -generate? guides/rails_guides/generator.rb /^ def generate?(source_file, output_file)$/;" f class:RailsGuides.Generator -generate_application_route test/railties/mounted_engine_test.rb /^ def generate_application_route$/;" f class:ApplicationTests.ApplicationRoutingTest.Blog.PostsController -generate_guide guides/rails_guides/generator.rb /^ def generate_guide(guide, output_file)$/;" f class:RailsGuides.Generator -generate_guides guides/rails_guides/generator.rb /^ def generate_guides$/;" f class:RailsGuides.Generator -generate_railtie_name lib/rails/railtie.rb /^ def generate_railtie_name(class_or_module)$/;" f class:Rails.Railtie -generate_test_dummy lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def generate_test_dummy(force = false)$/;" f class:Rails.PluginBuilder -generate_test_dummy test/fixtures/lib/plugin_builders/spec_builder.rb /^ def generate_test_dummy$/;" f class:PluginBuilder -generated_attribute.rb lib/rails/generators/generated_attribute.rb 1;" F -generated_attribute_test.rb test/generators/generated_attribute_test.rb 1;" F -generator lib/rails/generators/test_case.rb /^ def generator(args=self.default_arguments, options={}, config={})$/;" f class:Rails.Generators.TestCase -generator.rb guides/rails_guides/generator.rb 1;" F -generator_dir lib/rails/generators/rails/generator/generator_generator.rb /^ def generator_dir$/;" f class:Rails.Generators.GeneratorGenerator -generator_generator.rb lib/rails/generators/rails/generator/generator_generator.rb 1;" F -generator_generator_test.rb test/generators/generator_generator_test.rb 1;" F -generator_name lib/rails/generators/base.rb /^ def self.generator_name$/;" F class:Rails -generators lib/rails/engine/configuration.rb /^ def generators #:nodoc$/;" f class:Rails.Engine.Configuration -generators lib/rails/railtie.rb /^ def generators(&blk)$/;" f class:Rails.Railtie -generators lib/rails/railtie/configuration.rb /^ def generators(&block) #:nodoc$/;" f class:Rails.Railtie.Configuration -generators.rb lib/rails/generators.rb 1;" F -generators_test.rb test/application/generators_test.rb 1;" F -generators_test.rb test/generators_test.rb 1;" F -generators_test_helper.rb test/generators/generators_test_helper.rb 1;" F -get test/isolation/abstract_unit.rb /^ def get(path)$/;" f class:TestHelpers -get_builder_class lib/rails/generators/rails/app/app_generator.rb /^ def get_builder_class$/;" f class:Generators.AppGenerator -get_builder_class lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def get_builder_class$/;" f class:Generators.PluginNewGenerator -git lib/rails/generators/actions.rb /^ def git(command={})$/;" f class:Rails.Generators -git_url? lib/rails/commands/plugin.rb /^ def git_url?$/;" f class:Plugin -gitignore lib/rails/generators/rails/app/app_generator.rb /^ def gitignore$/;" f class:Rails.AppBuilder -gitignore lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def gitignore$/;" f class:Rails.PluginBuilder -gitignore test/fixtures/lib/app_builders/simple_builder.rb /^ def gitignore$/;" f class:AppBuilder -gitignore test/fixtures/lib/app_builders/tweak_builder.rb /^ def gitignore$/;" f class:AppBuilder -gitignore test/fixtures/lib/plugin_builders/simple_builder.rb /^ def gitignore$/;" f class:PluginBuilder -gitignore test/fixtures/lib/plugin_builders/tweak_builder.rb /^ def gitignore$/;" f class:PluginBuilder -global_plugins lib/rails/plugin.rb /^ def self.global_plugins$/;" F class:Rails.Plugin -guess_name lib/rails/commands/plugin.rb /^ def guess_name(url)$/;" f -guide guides/rails_guides/helpers.rb /^ def guide(name, url, options = {}, &block)$/;" f class:RailsGuides.Helpers -guideMenu guides/assets/javascripts/guides.js /^function guideMenu(){$/;" f -guides.js guides/assets/javascripts/guides.js 1;" F -guides_to_generate guides/rails_guides/generator.rb /^ def guides_to_generate$/;" f class:RailsGuides.Generator -guides_to_validate guides/w3c_validator.rb /^ def guides_to_validate$/;" f class:RailsGuides.Validator -handleMethod lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function handleMethod(element) {$/;" f -handleMethod tmp/app/public/javascripts/rails.js /^ function handleMethod(element) {$/;" f -handleMethod tmp/app_template/public/javascripts/rails.js /^ function handleMethod(element) {$/;" f -handleRemote lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function handleRemote(element) {$/;" f -handleRemote tmp/app/public/javascripts/rails.js /^ function handleRemote(element) {$/;" f -handleRemote tmp/app_template/public/javascripts/rails.js /^ function handleRemote(element) {$/;" f -handler lib/rails/generators/erb.rb /^ def handler$/;" f class:Erb.Generators.Base -help lib/rails/generators.rb /^ def self.help(command = 'generate')$/;" F class:Rails -help_the_engine test/railties/engine_test.rb /^ def help_the_engine$/;" f class:EngineHelper -helper lib/rails/console/helpers.rb /^def helper$/;" f -helper.rb lib/rails/generators/rails/helper/templates/helper.rb 1;" F -helper_generator.rb lib/rails/generators/rails/helper/helper_generator.rb 1;" F -helper_generator.rb lib/rails/generators/test_unit/helper/helper_generator.rb 1;" F -helper_generator_test.rb test/generators/helper_generator_test.rb 1;" F -helper_test.rb lib/rails/generators/test_unit/helper/templates/helper_test.rb 1;" F -helpers.rb guides/rails_guides/helpers.rb 1;" F -helpers.rb lib/rails/console/helpers.rb 1;" F -hidden_namespaces lib/rails/generators.rb /^ def self.hidden_namespaces$/;" F class:Rails.Generators -hide_namespaces lib/rails/generators.rb /^ def hide_namespaces(*namespaces)$/;" f class:Rails.Generators -hook_for lib/rails/generators/base.rb /^ def self.hook_for(*names, &block)$/;" F class:Rails.Generators -hooks lib/rails/generators/base.rb /^ def self.hooks #:nodoc:$/;" F class:Rails -hooks_test.rb test/application/initializers/hooks_test.rb 1;" F -human_name lib/rails/generators/generated_attribute.rb /^ def human_name$/;" f class:Rails -human_name lib/rails/generators/named_base.rb /^ def human_name$/;" f class:Rails.Generators -i18n_scope lib/rails/generators/named_base.rb /^ def i18n_scope$/;" f class:Rails.Generators -i18n_test.rb test/application/initializers/i18n_test.rb 1;" F -id test/railties/mounted_engine_test.rb /^ def id$/;" f class:ApplicationTests.ApplicationRoutingTest.Blog.Post -images lib/rails/generators/rails/app/app_generator.rb /^ def images$/;" f -in_rails_application lib/rails/script_rails_loader.rb /^ def self.in_rails_application?$/;" F class:Rails -in_rails_application_subdirectory lib/rails/script_rails_loader.rb /^ def self.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))$/;" F class:Rails -included lib/rails/backtrace_cleaner.rb /^ def self.included(klass)$/;" F class:Rails.BacktraceFilterForTestUnit -included lib/rails/generators/migration.rb /^ def self.included(base) #:nodoc:$/;" F class:Rails.Generators.Migration -included lib/rails/generators/resource_helpers.rb /^ def self.included(base) #:nodoc:$/;" F class:Rails.Generators.ResourceHelpers -included lib/rails/initializable.rb /^ def self.included(base)$/;" F class:Rails.Initializable -included test/generators/generators_test_helper.rb /^ def self.included(base)$/;" F class:GeneratorsTestHelper -included_helpers test/application/initializers/frameworks_test.rb /^ def included_helpers$/;" f class:FooController -indent lib/rails/generators/named_base.rb /^ def indent(content, multiplier = 2)$/;" f class:Rails.Generators.NamedBase -index guides/rails_guides/indexer.rb /^ def index$/;" f class:RailsGuides.Indexer -index lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def index$/;" f -index test/application/configuration_test.rb /^ def index$/;" f -index test/application/middleware/sendfile_test.rb /^ def index$/;" f class:ApplicationTests.SendfileTest -index test/application/middleware_test.rb /^ def index$/;" f -index test/application/routing_test.rb /^ def index$/;" f class:Admin.FooController -index test/application/routing_test.rb /^ def index$/;" f class:BarController -index test/application/routing_test.rb /^ def index$/;" f class:FooController -index test/application/routing_test.rb /^ def index$/;" f class:YazilarController -index test/application/url_generation_test.rb /^ def index$/;" f class:ApplicationTests -index test/isolation/abstract_unit.rb /^ def index$/;" f class:simple_controller.FooController -index test/railties/engine_test.rb /^ def index$/;" f class:Bukkits.HomeController -index test/railties/engine_test.rb /^ def index$/;" f class:Bukkits -index test/railties/engine_test.rb /^ def index$/;" f class:FooController -index test/railties/mounted_engine_test.rb /^ def index$/;" f class:ApplicationTests.ApplicationRoutingTest.Blog.PostsController -index test/railties/shared_tests.rb /^ def index$/;" f class:RailtiesTest.test_adds_helpers_to_controller_views.BukkitController -index test/railties/shared_tests.rb /^ def index$/;" f class:RailtiesTest.test_adds_its_views_to_view_paths.BukkitController -index test/railties/shared_tests.rb /^ def index$/;" f class:RailtiesTest.test_adds_its_views_to_view_paths_with_lower_proriority_than_app_ones.BukkitController -index test/railties/shared_tests.rb /^ def index$/;" f class:RailtiesTest.test_namespaced_controllers_with_namespaced_routes.Admin -index test/railties/shared_tests.rb /^ def index$/;" f class:RailtiesTest.test_routes_in_plugins_have_lower_priority_than_application_ones.BarController -index test/railties/shared_tests.rb /^ def index$/;" f class:RailtiesTest.test_routes_in_plugins_have_lower_priority_than_application_ones.FooController -index.html lib/rails/generators/rails/app/templates/public/index.html 1;" F -index.html tmp/app/public/index.html 1;" F -index.html tmp/app_template/public/index.html 1;" F -index_helper lib/rails/generators/named_base.rb /^ def index_helper$/;" f class:Rails.Generators -indexer.rb guides/rails_guides/indexer.rb 1;" F -inflections.rb lib/rails/generators/rails/app/templates/config/initializers/inflections.rb 1;" F -inflections.rb tmp/app_template/config/initializers/inflections.rb 1;" F -info lib/rails/commands/plugin.rb /^ def info$/;" f class:Plugin -info.rb lib/rails/info.rb 1;" F -info_controller.rb lib/rails/info_controller.rb 1;" F -inherited lib/rails/application.rb /^ def inherited(base)$/;" f class:Rails.Application -inherited lib/rails/engine.rb /^ def inherited(base)$/;" f class:Rails.Engine -inherited lib/rails/generators/base.rb /^ def self.inherited(base) #:nodoc:$/;" F class:Rails -inherited lib/rails/plugin.rb /^ def self.inherited(base)$/;" F class:Rails.Plugin -inherited lib/rails/railtie.rb /^ def inherited(base)$/;" f class:Rails.Railtie -inherited lib/rails/railtie/configurable.rb /^ def inherited(base)$/;" f class:Rails.Railtie.Configurable.ClassMethods -init.rb lib/rails/generators/rails/plugin/templates/init.rb 1;" F -init.rb test/fixtures/about_yml_plugins/bad_about_yml/init.rb 1;" F -init.rb test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb 1;" F -initializable.rb lib/rails/initializable.rb 1;" F -initializable_test.rb test/initializable_test.rb 1;" F -initialize guides/rails_guides/generator.rb /^ def initialize(output=nil)$/;" f class:RailsGuides.Generator -initialize guides/rails_guides/indexer.rb /^ def initialize(body, warnings)$/;" f class:RailsGuides.Indexer -initialize lib/rails/application/configuration.rb /^ def initialize(*)$/;" f class:Rails.Application.Configuration -initialize lib/rails/application/routes_reloader.rb /^ def initialize$/;" f class:Rails.Application.RoutesReloader -initialize lib/rails/backtrace_cleaner.rb /^ def initialize$/;" f class:Rails.BacktraceCleaner -initialize lib/rails/code_statistics.rb /^ def initialize(*pairs)$/;" f class:CodeStatistics -initialize lib/rails/commands/console.rb /^ def initialize(app)$/;" f class:Rails.Console -initialize lib/rails/commands/dbconsole.rb /^ def initialize(app)$/;" f class:Rails.DBConsole -initialize lib/rails/commands/plugin.rb /^ def initialize$/;" f class:Commands.Plugin -initialize lib/rails/commands/plugin.rb /^ def initialize(base_command)$/;" f class:Commands.Info -initialize lib/rails/commands/plugin.rb /^ def initialize(base_command)$/;" f class:Commands.Install -initialize lib/rails/commands/plugin.rb /^ def initialize(base_command)$/;" f class:Commands.Remove -initialize lib/rails/commands/plugin.rb /^ def initialize(dir)$/;" f class:RailsEnvironment -initialize lib/rails/commands/plugin.rb /^ def initialize(uri, name = nil)$/;" f class:Plugin -initialize lib/rails/commands/plugin.rb /^ def initialize(urls_to_fetch, level = 1, cwd = ".")$/;" f class:RecursiveHTTPFetcher -initialize lib/rails/commands/server.rb /^ def initialize(*)$/;" f class:Rails.Server -initialize lib/rails/configuration.rb /^ def initialize$/;" f class:Rails.Configuration.Generators -initialize lib/rails/configuration.rb /^ def initialize$/;" f class:Rails.Configuration.MiddlewareStackProxy -initialize lib/rails/engine/configuration.rb /^ def initialize(root=nil)$/;" f class:Rails.Engine.Configuration -initialize lib/rails/engine/railties.rb /^ def initialize(config)$/;" f class:Rails.Engine.Railties -initialize lib/rails/generators/active_model.rb /^ def initialize(name)$/;" f class:Rails.Generators.ActiveModel -initialize lib/rails/generators/app_base.rb /^ def initialize(*args)$/;" f class:Rails.Generators.AppBase -initialize lib/rails/generators/generated_attribute.rb /^ def initialize(name, type)$/;" f class:Rails.Generators.GeneratedAttribute -initialize lib/rails/generators/named_base.rb /^ def initialize(args, *options) #:nodoc:$/;" f class:Rails.Generators.NamedBase -initialize lib/rails/generators/rails/app/app_generator.rb /^ def initialize(*args)$/;" f class:Generators.AppGenerator -initialize lib/rails/generators/rails/app/app_generator.rb /^ def initialize(generator)$/;" f class:Rails.ActionMethods -initialize lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def initialize(*args)$/;" f class:Generators.PluginNewGenerator -initialize lib/rails/generators/resource_helpers.rb /^ def initialize(*args) #:nodoc:$/;" f class:Rails.Generators.ResourceHelpers -initialize lib/rails/initializable.rb /^ def initialize(name, context, options, &block)$/;" f class:Rails.Initializable.Initializer -initialize lib/rails/paths.rb /^ def initialize(path)$/;" f class:Rails.Paths.Root -initialize lib/rails/paths.rb /^ def initialize(root, current, *paths)$/;" f class:Rails.Paths.Path -initialize lib/rails/plugin.rb /^ def initialize(root)$/;" f class:Rails -initialize lib/rails/rack/debugger.rb /^ def initialize(app)$/;" f class:Rails.Rack.Debugger -initialize lib/rails/rack/log_tailer.rb /^ def initialize(app, log = nil)$/;" f class:Rails.Rack.LogTailer -initialize lib/rails/rack/logger.rb /^ def initialize(app)$/;" f class:Rails.Rack.Logger -initialize lib/rails/railtie/configuration.rb /^ def initialize$/;" f class:Rails.Railtie.Configuration -initialize lib/rails/source_annotation_extractor.rb /^ def initialize(tag)$/;" f class:SourceAnnotationExtractor -initialize test/isolation/abstract_unit.rb /^ def initialize(path)$/;" f class:Bukkit -initialize test/railties/engine_test.rb /^ def initialize(app)$/;" f class:Upcaser -initialize test/railties/shared_tests.rb /^ def initialize(app)$/;" f class:RailtiesTest.test_midleware_referenced_in_configuration.Bukkits -initialize! lib/rails.rb /^ def initialize!$/;" f class:Rails -initialize! lib/rails/application.rb /^ def initialize!$/;" f class:Rails -initialize_console lib/rails/application.rb /^ def initialize_console(sandbox=false)$/;" f class:Rails -initialize_copy lib/rails/configuration.rb /^ def initialize_copy(source)$/;" f class:Rails.Configuration.Generators -initialize_dirs guides/rails_guides/generator.rb /^ def initialize_dirs(output)$/;" f class:RailsGuides.Generator -initialize_generators lib/rails/application.rb /^ def initialize_generators$/;" f class:Rails -initialize_tasks lib/rails/application.rb /^ def initialize_tasks$/;" f class:Rails -initialized= lib/rails.rb /^ def initialized=(initialized)$/;" f class:Rails -initialized? lib/rails.rb /^ def initialized?$/;" f class:Rails -initializer lib/rails/generators/actions.rb /^ def initializer(filename, data=nil, &block)$/;" f class:Rails.Generators -initializer lib/rails/initializable.rb /^ def initializer(name, opts = {}, &blk)$/;" f class:Rails.Initializable.ClassMethods -initializers lib/rails/application.rb /^ def initializers$/;" f class:Rails -initializers lib/rails/engine.rb /^ def initializers$/;" f -initializers lib/rails/initializable.rb /^ def initializers$/;" f class:Rails.Initializable.ClassMethods -initializers lib/rails/initializable.rb /^ def initializers$/;" f class:Rails.Initializable -initializers test/initializable_test.rb /^ def self.initializers$/;" F class:Application -initializers test/initializable_test.rb /^ def self.initializers$/;" F class:InitializableTests.OverriddenInitializer -initializers_chain lib/rails/initializable.rb /^ def initializers_chain$/;" f class:Rails.Initializable.ClassMethods -initializers_for lib/rails/initializable.rb /^ def initializers_for(binding)$/;" f class:Rails.Initializable.ClassMethods -insertHiddenField lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function insertHiddenField(form, name, value) {$/;" f -insertHiddenField tmp/app/public/javascripts/rails.js /^ function insertHiddenField(form, name, value) {$/;" f -insertHiddenField tmp/app_template/public/javascripts/rails.js /^ function insertHiddenField(form, name, value) {$/;" f -insert_after lib/rails/configuration.rb /^ def insert_after(*args, &block)$/;" f class:Rails.Configuration.MiddlewareStackProxy -insert_before lib/rails/configuration.rb /^ def insert_before(*args, &block)$/;" f class:Rails.Configuration.MiddlewareStackProxy -inside_template lib/rails/generators/named_base.rb /^ def inside_template$/;" f class:Rails.Generators.NamedBase -inside_template? lib/rails/generators/named_base.rb /^ def inside_template?$/;" f class:Rails.Generators.NamedBase -inspect lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function inspect(object) {$/;" f -inspect tmp/app/public/javascripts/prototype.js /^ function inspect(object) {$/;" f -inspect tmp/app_template/public/javascripts/prototype.js /^ function inspect(object) {$/;" f -install lib/rails/commands/plugin.rb /^ def install(method=nil, options = {})$/;" f class:Plugin -install lib/rails/commands/plugin.rb /^ def install(name_uri_or_plugin)$/;" f class:RailsEnvironment -install.rb lib/rails/generators/rails/plugin/templates/install.rb 1;" F -install_using_checkout lib/rails/commands/plugin.rb /^ def install_using_checkout(options = {})$/;" f class:Plugin -install_using_export lib/rails/commands/plugin.rb /^ def install_using_export(options = {})$/;" f class:Plugin -install_using_externals lib/rails/commands/plugin.rb /^ def install_using_externals(options = {})$/;" f class:Plugin -install_using_git lib/rails/commands/plugin.rb /^ def install_using_git(options = {})$/;" f -install_using_http lib/rails/commands/plugin.rb /^ def install_using_http(options = {})$/;" f class:Plugin -installed? lib/rails/commands/plugin.rb /^ def installed?$/;" f class:Plugin -instance lib/rails/railtie/configurable.rb /^ def instance$/;" f class:Rails.Railtie.Configurable.ClassMethods -instrument test/application/initializers/notifications_test.rb /^ def instrument(*args, &block)$/;" f class:ApplicationTests.NotificationsTest -integration_generator.rb lib/rails/generators/test_unit/integration/integration_generator.rb 1;" F -integration_test.rb lib/rails/generators/test_unit/integration/templates/integration_test.rb 1;" F -integration_test_generator.rb lib/rails/generators/rails/integration_test/integration_test_generator.rb 1;" F -integration_test_generator_test.rb test/generators/integration_test_generator_test.rb 1;" F -invoke lib/rails/generators.rb /^ def self.invoke(namespace, args=ARGV, config={})$/;" F class:Rails.Generators -invoke_fallbacks_for lib/rails/generators.rb /^ def self.invoke_fallbacks_for(name, base) #:nodoc:$/;" F class:Rails -isArray lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isArray(object) {$/;" f -isArray tmp/app/public/javascripts/prototype.js /^ function isArray(object) {$/;" f -isArray tmp/app_template/public/javascripts/prototype.js /^ function isArray(object) {$/;" f -isDate lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isDate(object) {$/;" f -isDate tmp/app/public/javascripts/prototype.js /^ function isDate(object) {$/;" f -isDate tmp/app_template/public/javascripts/prototype.js /^ function isDate(object) {$/;" f -isElement lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isElement(object) {$/;" f -isElement tmp/app/public/javascripts/prototype.js /^ function isElement(object) {$/;" f -isElement tmp/app_template/public/javascripts/prototype.js /^ function isElement(object) {$/;" f -isForm lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function isForm(element) {$/;" f -isForm tmp/app/public/javascripts/rails.js /^ function isForm(element) {$/;" f -isForm tmp/app_template/public/javascripts/rails.js /^ function isForm(element) {$/;" f -isFunction lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isFunction(object) {$/;" f -isFunction tmp/app/public/javascripts/prototype.js /^ function isFunction(object) {$/;" f -isFunction tmp/app_template/public/javascripts/prototype.js /^ function isFunction(object) {$/;" f -isHash lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isHash(object) {$/;" f -isHash tmp/app/public/javascripts/prototype.js /^ function isHash(object) {$/;" f -isHash tmp/app_template/public/javascripts/prototype.js /^ function isHash(object) {$/;" f -isInput lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ function isInput(element) {$/;" f -isInput tmp/app/public/javascripts/rails.js /^ function isInput(element) {$/;" f -isInput tmp/app_template/public/javascripts/rails.js /^ function isInput(element) {$/;" f -isNumber lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isNumber(object) {$/;" f -isNumber tmp/app/public/javascripts/prototype.js /^ function isNumber(object) {$/;" f -isNumber tmp/app_template/public/javascripts/prototype.js /^ function isNumber(object) {$/;" f -isString lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isString(object) {$/;" f -isString tmp/app/public/javascripts/prototype.js /^ function isString(object) {$/;" f -isString tmp/app_template/public/javascripts/prototype.js /^ function isString(object) {$/;" f -isUndefined lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function isUndefined(object) {$/;" f -isUndefined tmp/app/public/javascripts/prototype.js /^ function isUndefined(object) {$/;" f -isUndefined tmp/app_template/public/javascripts/prototype.js /^ function isUndefined(object) {$/;" f -isolate_namespace lib/rails/engine.rb /^ def isolate_namespace(mod)$/;" f class:Rails.Engine -javascripts lib/rails/generators/rails/app/app_generator.rb /^ def javascripts$/;" f -javascripts lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def javascripts$/;" f class:Rails.PluginBuilder -jquery.js lib/rails/generators/rails/app/templates/public/javascripts/jquery.js 1;" F -jquery_ujs.js lib/rails/generators/rails/app/templates/public/javascripts/jquery_ujs.js 1;" F -keys lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function keys(object) {$/;" f -keys tmp/app/public/javascripts/prototype.js /^ function keys(object) {$/;" f -keys tmp/app_template/public/javascripts/prototype.js /^ function keys(object) {$/;" f -last lib/rails/paths.rb /^ def last$/;" f class:Rails.Paths.Path -levenshtein.rb guides/rails_guides/levenshtein.rb 1;" F -lib lib/rails/generators/actions.rb /^ def lib(filename, data=nil, &block)$/;" f class:Rails.Generators -lib lib/rails/generators/rails/app/app_generator.rb /^ def lib$/;" f class:Rails -lib lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def lib$/;" f class:Rails.PluginBuilder -license lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def license$/;" f class:Rails.PluginBuilder -links lib/rails/commands/plugin.rb /^ def links(base_url, contents)$/;" f class:RecursiveHTTPFetcher.ls -load_app test/application/initializers/i18n_test.rb /^ def load_app$/;" f class:ApplicationTests.I18nTest -load_console lib/rails/application.rb /^ def load_console(sandbox=false)$/;" f class:Rails -load_console lib/rails/railtie.rb /^ def load_console$/;" f class:Rails -load_environment test/application/console_test.rb /^ def load_environment$/;" f class:ConsoleTest -load_generators lib/rails/application.rb /^ def load_generators$/;" f class:Rails -load_generators lib/rails/railtie.rb /^ def load_generators$/;" f class:Rails -load_generators_from_railties lib/rails/generators.rb /^ def self.load_generators_from_railties! #:nodoc:$/;" F -load_path_test.rb test/application/initializers/load_path_test.rb 1;" F -load_paths lib/rails/application/routes_reloader.rb /^ def load_paths$/;" f class:Rails.Application.RoutesReloader -load_paths lib/rails/paths.rb /^ def load_paths$/;" f class:Rails.Paths.Root -load_seed lib/rails/engine.rb /^ def load_seed$/;" f -load_tasks lib/rails/application.rb /^ def load_tasks$/;" f class:Rails -load_tasks lib/rails/engine.rb /^ def load_tasks$/;" f class:Rails -load_tasks lib/rails/railtie.rb /^ def load_tasks$/;" f class:Rails -loading_test.rb test/application/loading_test.rb 1;" F -log lib/rails/generators/actions.rb /^ def log(*args)$/;" f class:Rails.Generators.route -log lib/rails/generators/rails/app/app_generator.rb /^ def log$/;" f class:Rails -log_level lib/rails/application/configuration.rb /^ def log_level$/;" f class:Rails.Application.Configuration -log_path lib/rails/commands/server.rb /^ def log_path$/;" f class:Rails.Server -log_tailer.rb lib/rails/rack/log_tailer.rb 1;" F -logger lib/rails.rb /^ def logger$/;" f class:Rails -logger.rb lib/rails/rack/logger.rb 1;" F -logger= lib/rails.rb /^ def logger=(logger)$/;" f class:Rails -lookup lib/rails/generators.rb /^ def self.lookup! #:nodoc:$/;" F -lookup lib/rails/generators.rb /^ def self.lookup(namespaces) #:nodoc:$/;" F class:Rails -ls lib/rails/commands/plugin.rb /^ def ls$/;" f class:RecursiveHTTPFetcher -mailer_generator.rb lib/rails/generators/erb/mailer/mailer_generator.rb 1;" F -mailer_generator.rb lib/rails/generators/test_unit/mailer/mailer_generator.rb 1;" F -mailer_generator_test.rb test/generators/mailer_generator_test.rb 1;" F -make_basic_app test/isolation/abstract_unit.rb /^ def make_basic_app$/;" f -masterDelay lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^ var masterDelay = options.delay;$/;" v -masterDelay tmp/app/public/javascripts/effects.js /^ var masterDelay = options.delay;$/;" v -masterDelay tmp/app_template/public/javascripts/effects.js /^ var masterDelay = options.delay;$/;" v -merge_into lib/rails/configuration.rb /^ def merge_into(other)$/;" f class:Rails.Configuration.MiddlewareStackProxy -method_missing lib/rails/configuration.rb /^ def method_missing(method, *args)$/;" f class:Rails.Configuration.Generators -method_missing lib/rails/generators/rails/app/app_generator.rb /^ def method_missing(meth, *args, &block)$/;" f class:Rails.ActionMethods -method_missing lib/rails/paths.rb /^ def method_missing(id, *args)$/;" f class:Rails.Paths.PathParent -method_missing lib/rails/railtie/configurable.rb /^ def method_missing(*args, &block)$/;" f class:Rails.Railtie.Configurable.ClassMethods -method_missing lib/rails/railtie/configuration.rb /^ def method_missing(name, *args, &blk)$/;" f class:Rails.Railtie.Configuration -middleware lib/rails/commands/server.rb /^ def middleware$/;" f class:Rails.Server -middleware lib/rails/engine/configuration.rb /^ def middleware$/;" f class:Rails.Engine.Configuration -middleware test/application/middleware_test.rb /^ def middleware$/;" f -middleware_test.rb test/application/middleware_test.rb 1;" F -migration.rb lib/rails/generators/migration.rb 1;" F -migration_exists? lib/rails/generators/migration.rb /^ def migration_exists?(dirname, file_name) #:nodoc:$/;" f class:Rails.Generators.Migration.ClassMethods -migration_file_name lib/rails/generators/test_case.rb /^ def migration_file_name(relative) #:nodoc:$/;" f class:Rails.Generators.TestCase -migration_generator.rb lib/rails/generators/rails/migration/migration_generator.rb 1;" F -migration_generator_test.rb test/generators/migration_generator_test.rb 1;" F -migration_lookup_at lib/rails/generators/migration.rb /^ def migration_lookup_at(dirname) #:nodoc:$/;" f class:Rails.Generators.Migration.ClassMethods -migration_template lib/rails/generators/migration.rb /^ def migration_template(source, destination=nil, config={})$/;" f class:Rails.Generators.Migration.ClassMethods -mime_types.rb lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb 1;" F -mime_types.rb tmp/app_template/config/initializers/mime_types.rb 1;" F -model_generator.rb lib/rails/generators/rails/model/model_generator.rb 1;" F -model_generator.rb lib/rails/generators/test_unit/model/model_generator.rb 1;" F -model_generator.rb test/fixtures/lib/generators/model_generator.rb 1;" F -model_generator_test.rb test/generators/model_generator_test.rb 1;" F -module_namespacing lib/rails/generators/named_base.rb /^ def module_namespacing(&block)$/;" f class:Rails.Generators.NamedBase -mountable? lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def mountable?$/;" f class:Generators.PluginNewGenerator -mounted_engine_test.rb test/railties/mounted_engine_test.rb 1;" F -mute lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def mute(&block)$/;" f class:Generators.PluginNewGenerator -mysql_socket lib/rails/generators/rails/app/app_generator.rb /^ def mysql_socket$/;" f class:Generators.AppGenerator -name lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var name = encodeURIComponent($/;" v -name lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def name$/;" f class:Generators.PluginNewGenerator -name tmp/app/public/javascripts/dragdrop.js /^ var name = encodeURIComponent($/;" v -name tmp/app_template/public/javascripts/dragdrop.js /^ var name = encodeURIComponent($/;" v -named_base.rb lib/rails/generators/named_base.rb 1;" F -named_base_test.rb test/generators/named_base_test.rb 1;" F -names lib/rails/info.rb /^ def names$/;" f class:Rails.Info -namespace lib/rails/generators/base.rb /^ def self.namespace(name=nil)$/;" F class:Rails.Generators -namespace lib/rails/generators/named_base.rb /^ def namespace$/;" f class:Rails.Generators.NamedBase -namespaced? lib/rails/generators/named_base.rb /^ def namespaced?$/;" f class:Rails.Generators -namespaced_class_path lib/rails/generators/named_base.rb /^ def namespaced_class_path$/;" f class:Rails.Generators -namespaced_generators_test.rb test/generators/namespaced_generators_test.rb 1;" F -namespaces_to_paths lib/rails/generators.rb /^ def self.namespaces_to_paths(namespaces) #:nodoc:$/;" F -navigation_test.rb lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb 1;" F -new lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def new$/;" f -new test/railties/engine_test.rb /^ def new$/;" f class:Bukkits -new_app test/application/configuration_test.rb /^ def new_app$/;" f class:ApplicationTests.ConfigurationTest -new_record? test/railties/mounted_engine_test.rb /^ def new_record?$/;" f class:ApplicationTests.ApplicationRoutingTest.Blog.Post -new_session lib/rails/console/app.rb /^def new_session$/;" f -next_migration_number lib/rails/generators/migration.rb /^ def next_migration_number(dirname) #:nodoc:$/;" f class:Rails.Generators.Migration.ClassMethods.current_migration_number -no_color lib/rails/generators.rb /^ def self.no_color!$/;" F class:Rails.Generators -not_included_helper test/application/initializers/frameworks_test.rb /^ def not_included_helper$/;" f class:FooController -notestuff guides/rails_guides/textile_extensions.rb /^ def notestuff(body)$/;" f class:RailsGuides.TextileExtensions -notifications_test.rb test/application/initializers/notifications_test.rb 1;" F -notify test/application/initializers/frameworks_test.rb /^ def notify$/;" f class:Foo -observer_generator.rb lib/rails/generators/rails/observer/observer_generator.rb 1;" F -observer_generator.rb lib/rails/generators/test_unit/observer/observer_generator.rb 1;" F -observer_generator_test.rb test/generators/observer_generator_test.rb 1;" F -offsets lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var offsets = dropon.cumulativeOffset();$/;" v -offsets tmp/app/public/javascripts/dragdrop.js /^ var offsets = dropon.cumulativeOffset();$/;" v -offsets tmp/app_template/public/javascripts/dragdrop.js /^ var offsets = dropon.cumulativeOffset();$/;" v -opt_parser lib/rails/commands/server.rb /^ def opt_parser$/;" f class:Rails.Server -options lib/rails/commands/plugin.rb /^ def options$/;" f class:Commands.Info -options lib/rails/commands/plugin.rb /^ def options$/;" f class:Commands.Install -options lib/rails/commands/plugin.rb /^ def options$/;" f class:Commands.Plugin -options lib/rails/commands/plugin.rb /^ def options$/;" f class:Commands.Remove -options lib/rails/generators.rb /^ def self.options #:nodoc:$/;" F class:Rails.Generators -options_for_draggable.quiet lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ revert: true,$/;" p -options_for_draggable.quiet tmp/app/public/javascripts/dragdrop.js /^ revert: true,$/;" p -options_for_draggable.quiet tmp/app_template/public/javascripts/dragdrop.js /^ revert: true,$/;" p -options_for_draggable.revert lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var options_for_draggable = {$/;" p -options_for_draggable.revert tmp/app/public/javascripts/dragdrop.js /^ var options_for_draggable = {$/;" p -options_for_draggable.revert tmp/app_template/public/javascripts/dragdrop.js /^ var options_for_draggable = {$/;" p -options_for_droppable.overlap lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var options_for_droppable = {$/;" p -options_for_droppable.overlap tmp/app/public/javascripts/dragdrop.js /^ var options_for_droppable = {$/;" p -options_for_droppable.overlap tmp/app_template/public/javascripts/dragdrop.js /^ var options_for_droppable = {$/;" p -options_for_tree.onHover lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var options_for_tree = {$/;" p -options_for_tree.onHover tmp/app/public/javascripts/dragdrop.js /^ var options_for_tree = {$/;" p -options_for_tree.onHover tmp/app_template/public/javascripts/dragdrop.js /^ var options_for_tree = {$/;" p -orm_class lib/rails/generators/resource_helpers.rb /^ def orm_class$/;" f class:Rails.Generators.ResourceHelpers -orm_instance lib/rails/generators/resource_helpers.rb /^ def orm_instance(name=singular_table_name)$/;" f class:Rails.Generators.ResourceHelpers -output_file_for guides/rails_guides/generator.rb /^ def output_file_for(guide)$/;" f class:RailsGuides.Generator -parse lib/rails/commands/plugin.rb /^ def self.parse!(args=ARGV)$/;" F class:Commands.Plugin -parse! lib/rails/commands/plugin.rb /^ def parse!(args)$/;" f class:Commands.Info -parse! lib/rails/commands/plugin.rb /^ def parse!(args)$/;" f class:Commands.Install -parse! lib/rails/commands/plugin.rb /^ def parse!(args)$/;" f class:Commands.Remove -parse! lib/rails/commands/plugin.rb /^ def parse!(args=ARGV)$/;" f class:Commands.Plugin -parse! lib/rails/commands/server.rb /^ def parse!(args)$/;" f class:Rails.Server.Options -parse_attributes! lib/rails/generators/named_base.rb /^ def parse_attributes! #:nodoc:$/;" f class:Rails.Generators -partial lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ var partial = [];$/;" v -partial tmp/app/public/javascripts/prototype.js /^ var partial = [];$/;" v -partial tmp/app_template/public/javascripts/prototype.js /^ var partial = [];$/;" v -paths lib/rails/application/configuration.rb /^ def paths$/;" f class:Rails.Application.Configuration -paths lib/rails/engine/configuration.rb /^ def paths$/;" f class:Rails.Engine.Configuration -paths lib/rails/paths.rb /^ def paths$/;" f class:Rails -paths.rb lib/rails/paths.rb 1;" F -paths_test.rb test/application/paths_test.rb 1;" F -paths_test.rb test/paths_test.rb 1;" F -performance_generator.rb lib/rails/generators/test_unit/performance/performance_generator.rb 1;" F -performance_test.rb lib/rails/generators/test_unit/performance/templates/performance_test.rb 1;" F -performance_test_generator.rb lib/rails/generators/rails/performance_test/performance_test_generator.rb 1;" F -performance_test_generator_test.rb test/generators/performance_test_generator_test.rb 1;" F -performance_test_help.rb lib/rails/performance_test_help.rb 1;" F -persisted? test/railties/engine_test.rb /^ def persisted?$/;" f class:Bukkits.Post -plugin lib/rails/generators/actions.rb /^ def plugin(name, options)$/;" f class:Rails.Generators.Actions -plugin test/isolation/abstract_unit.rb /^ def plugin(name, string = "")$/;" f -plugin.rb lib/rails/commands/plugin.rb 1;" F -plugin.rb lib/rails/plugin.rb 1;" F -plugin_dir lib/rails/generators/rails/plugin/plugin_generator.rb /^ def plugin_dir(join=nil)$/;" f class:Rails.Generators.PluginGenerator -plugin_generator.rb lib/rails/generators/rails/plugin/plugin_generator.rb 1;" F -plugin_generator.rb lib/rails/generators/test_unit/plugin/plugin_generator.rb 1;" F -plugin_generator_test.rb test/generators/plugin_generator_test.rb 1;" F -plugin_new.rb lib/rails/commands/plugin_new.rb 1;" F -plugin_new_generator.rb lib/rails/generators/rails/plugin_new/plugin_new_generator.rb 1;" F -plugin_new_generator_test.rb test/generators/plugin_new_generator_test.rb 1;" F -plugin_ordering_test.rb test/railties/plugin_ordering_test.rb 1;" F -plugin_test.rb test/railties/plugin_test.rb 1;" F -plugins lib/rails/engine/railties.rb /^ def plugins$/;" f class:Rails.Engine.Railties -plural_file_name lib/rails/generators/named_base.rb /^ def plural_file_name$/;" f class:Rails.Generators -plural_name lib/rails/generators/named_base.rb /^ def plural_name$/;" f class:Rails.Generators -plural_table_name lib/rails/generators/named_base.rb /^ def plural_table_name$/;" f class:Rails.Generators -pluralize_table_names? lib/rails/generators/named_base.rb /^ def pluralize_table_names?$/;" f class:Rails.Generators -plusplus guides/rails_guides/textile_extensions.rb /^ def plusplus(body)$/;" f class:RailsGuides.TextileExtensions -pointer lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var pointer = [Event.pointerX(event), Event.pointerY(event)];$/;" v -pointer tmp/app/public/javascripts/dragdrop.js /^ var pointer = [Event.pointerX(event), Event.pointerY(event)];$/;" v -pointer tmp/app_template/public/javascripts/dragdrop.js /^ var pointer = [Event.pointerX(event), Event.pointerY(event)];$/;" v -polymorphic_path_without_namespace test/railties/engine_test.rb /^ def polymorphic_path_without_namespace$/;" f class:Bukkits -polymorphic_route test/railties/mounted_engine_test.rb /^ def polymorphic_route$/;" f class:ApplicationTests.ApplicationRoutingTest.ApplicationGeneratingController -pop_d lib/rails/commands/plugin.rb /^ def pop_d$/;" f class:RecursiveHTTPFetcher.ls -prepare_destination lib/rails/generators/test_case.rb /^ def prepare_destination$/;" f class:Rails.Generators.TestCase -prepare_for_invocation lib/rails/generators/base.rb /^ def self.prepare_for_invocation(name, value) #:nodoc:$/;" F class:Rails -print_code_test_stats lib/rails/code_statistics.rb /^ def print_code_test_stats$/;" f -print_header lib/rails/code_statistics.rb /^ def print_header$/;" f class:CodeStatistics -print_line lib/rails/code_statistics.rb /^ def print_line(name, statistics)$/;" f class:CodeStatistics -print_list lib/rails/generators.rb /^ def self.print_list(base, namespaces) #:nodoc:$/;" F class:Rails -print_profile lib/rails/rubyprof_ext.rb /^ def self.print_profile(results, io = $stderr)$/;" F class:Prof -print_splitter lib/rails/code_statistics.rb /^ def print_splitter$/;" f class:CodeStatistics -process guides/rails_guides/indexer.rb /^ def process(string, current_level=3, counters=[1])$/;" f class:RailsGuides.Indexer -production.rb tmp/app_template/config/environments/production.rb 1;" F -profiler.rb lib/rails/commands/profiler.rb 1;" F -properties lib/rails/info_controller.rb /^ def properties$/;" f class:Rails -properties test/rails_info_test.rb /^ def properties$/;" f -property lib/rails/info.rb /^ def property(name, value = nil)$/;" f class:Rails -property_defined? test/rails_info_test.rb /^ def property_defined?(property_name)$/;" f -prototype.js lib/rails/generators/rails/app/templates/public/javascripts/prototype.js 1;" F -prototype.js tmp/app/public/javascripts/prototype.js 1;" F -prototype.js tmp/app_template/public/javascripts/prototype.js 1;" F -prototype_ujs.js lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js 1;" F -public_directory lib/rails/generators/rails/app/app_generator.rb /^ def public_directory$/;" f -public_path lib/rails.rb /^ def public_path$/;" f class:Rails -push_d lib/rails/commands/plugin.rb /^ def push_d(dir)$/;" f class:RecursiveHTTPFetcher.ls -rack.rb lib/rails/rack.rb 1;" F -rackup test/application/rackup_test.rb /^ def rackup$/;" f class:ApplicationTests.RackupTest -rackup_test.rb test/application/rackup_test.rb 1;" F -rails tmp/app_template/script/rails 1;" F -rails.js tmp/app/public/javascripts/rails.js 1;" F -rails.js tmp/app_template/public/javascripts/rails.js 1;" F -rails.rb lib/rails.rb 1;" F -rails_env lib/rails/commands/plugin.rb /^ def rails_env$/;" f -rails_gemfile_entry lib/rails/generators/app_base.rb /^ def rails_gemfile_entry$/;" f class:Rails.Generators -rails_guides.rb guides/rails_guides.rb 1;" F -rails_info_controller_test.rb test/rails_info_controller_test.rb 1;" F -rails_info_test.rb test/rails_info_test.rb 1;" F -rails_root test/isolation/abstract_unit.rb /^ def rails_root$/;" f class:TestHelpers.Paths -railtie.rb lib/rails/railtie.rb 1;" F -railtie.rb lib/rails/test_unit/railtie.rb 1;" F -railtie_name lib/rails/plugin.rb /^ def railtie_name$/;" f class:Rails -railtie_name lib/rails/railtie.rb /^ def railtie_name(name = nil)$/;" f class:Rails.Railtie -railtie_test.rb test/railties/railtie_test.rb 1;" F -railties lib/rails/engine.rb /^ def railties$/;" f -railties lib/rails/engine/railties.rb /^ def self.railties$/;" F class:Rails.Engine.Railties -railties.rb lib/rails/application/railties.rb 1;" F -railties.rb lib/rails/engine/railties.rb 1;" F -rake lib/rails/generators/actions.rb /^ def rake(command, options={})$/;" f class:Rails.Generators -rake_tasks lib/rails/railtie.rb /^ def rake_tasks(&blk)$/;" f class:Rails.Railtie -rake_test.rb test/application/rake_test.rb 1;" F -rakefile lib/rails/generators/actions.rb /^ def rakefile(filename, data=nil, &block)$/;" f class:Rails.Generators -rakefile lib/rails/generators/rails/app/app_generator.rb /^ def rakefile$/;" f class:Rails.AppBuilder -rakefile lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def rakefile$/;" f class:Rails.PluginBuilder -rakefile_test_tasks lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def rakefile_test_tasks$/;" f class:Generators.PluginNewGenerator -readme lib/rails/generators/actions.rb /^ def readme(path)$/;" f class:Rails.Generators.route -readme lib/rails/generators/rails/app/app_generator.rb /^ def readme$/;" f class:Rails.AppBuilder -readme lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def readme$/;" f class:Rails.PluginBuilder -reference? lib/rails/generators/generated_attribute.rb /^ def reference?$/;" f class:Rails -regular_class_path lib/rails/generators/named_base.rb /^ def regular_class_path$/;" f class:Rails.Generators -reload! lib/rails/application/routes_reloader.rb /^ def reload!$/;" f class:Rails.Application.RoutesReloader -reload! lib/rails/console/app.rb /^def reload!(print=true)$/;" f -reload_routes! lib/rails/application.rb /^ def reload_routes!$/;" f class:Rails -remote_ip test/application/middleware/remote_ip_test.rb /^ def remote_ip(env = {})$/;" f class:ApplicationTests.RemoteIpTest -remote_ip_test.rb test/application/middleware/remote_ip_test.rb 1;" F -remove_hook_for lib/rails/generators/base.rb /^ def self.remove_hook_for(*names)$/;" F class:Rails -render_conditionally test/application/middleware/cache_test.rb /^ def render_conditionally(headers)$/;" f class:ApplicationTests.RoutingTest.simple_controller.ExpiresController -require_environment! lib/rails/application.rb /^ def require_environment! #:nodoc:$/;" f class:Rails -require_for_database lib/rails/generators/app_base.rb /^ def require_for_database$/;" f class:Rails.Generators -reset_script_name! test/railties/mounted_engine_test.rb /^ def reset_script_name!$/;" f class:ApplicationTests -resource_generator.rb lib/rails/generators/rails/resource/resource_generator.rb 1;" F -resource_generator_test.rb test/generators/resource_generator_test.rb 1;" F -resource_helpers.rb lib/rails/generators/resource_helpers.rb 1;" F -respond_to? lib/rails/railtie/configurable.rb /^ def respond_to?(*args)$/;" f class:Rails.Railtie.Configurable.ClassMethods -respond_to? lib/rails/railtie/configuration.rb /^ def respond_to?(name)$/;" f class:Rails.Railtie.Configuration -revert lib/rails/application/routes_reloader.rb /^ def revert$/;" f class:Rails.Application.RoutesReloader -root lib/rails.rb /^ def root$/;" f class:Rails -root test/application/paths_test.rb /^ def root(*path)$/;" f class:ApplicationTests.PathsTest -root test/generators/generators_test_helper.rb /^ def self.root$/;" F class:Rails -root.children lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ parent: null,$/;" p -root.children tmp/app/public/javascripts/dragdrop.js /^ parent: null,$/;" p -root.children tmp/app_template/public/javascripts/dragdrop.js /^ parent: null,$/;" p -root.id lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var root = {$/;" p -root.id tmp/app/public/javascripts/dragdrop.js /^ var root = {$/;" p -root.id tmp/app_template/public/javascripts/dragdrop.js /^ var root = {$/;" p -root.parent lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ id: null,$/;" p -root.parent tmp/app/public/javascripts/dragdrop.js /^ id: null,$/;" p -root.parent tmp/app_template/public/javascripts/dragdrop.js /^ id: null,$/;" p -root= lib/rails/engine/configuration.rb /^ def root=(value)$/;" f class:Rails.Engine.Configuration -route lib/rails/generators/actions.rb /^ def route(routing_code)$/;" f class:Rails.Generators -route_url lib/rails/generators/named_base.rb /^ def route_url$/;" f class:Rails.Generators -routes lib/rails/engine.rb /^ def routes$/;" f -routes.rb lib/rails/generators/rails/app/templates/config/routes.rb 1;" F -routes.rb lib/rails/generators/rails/plugin_new/templates/config/routes.rb 1;" F -routes.rb lib/rails/generators/rails/plugin_new/templates/rails/routes.rb 1;" F -routes.rb tmp/app/config/routes.rb 1;" F -routes.rb tmp/app_template/config/routes.rb 1;" F -routes? lib/rails/engine.rb /^ def routes?$/;" f -routes_helpers_in_view test/railties/engine_test.rb /^ def routes_helpers_in_view$/;" f class:Bukkits -routes_reloader lib/rails/application.rb /^ def routes_reloader$/;" f class:Rails -routes_reloader.rb lib/rails/application/routes_reloader.rb 1;" F -routing_test.rb test/application/routing_test.rb 1;" F -ruby test/application/test_test.rb /^ def ruby(*args)$/;" f -ruby_version_check.rb lib/rails/ruby_version_check.rb 1;" F -rubyprof_ext.rb lib/rails/rubyprof_ext.rb 1;" F -run lib/rails/initializable.rb /^ def run(*args)$/;" f class:Rails.Initializable.Initializer -run_generator lib/rails/generators/test_case.rb /^ def run_generator(args=self.default_arguments, config={})$/;" f class:Rails.Generators.TestCase -run_initializers lib/rails/initializable.rb /^ def run_initializers(*args)$/;" f class:Rails.Initializable -run_install_hook lib/rails/commands/plugin.rb /^ def run_install_hook$/;" f class:Plugin -run_test test/application/test_test.rb /^ def run_test(name)$/;" f -run_uninstall_hook lib/rails/commands/plugin.rb /^ def run_uninstall_hook$/;" f class:Plugin -runner.rb lib/rails/commands/runner.rb 1;" F -runner_test.rb test/application/runner_test.rb 1;" F -s lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js /^ var s = Sortable.sortables[element.id];$/;" v -s tmp/app/public/javascripts/dragdrop.js /^ var s = Sortable.sortables[element.id];$/;" v -s tmp/app_template/public/javascripts/dragdrop.js /^ var s = Sortable.sortables[element.id];$/;" v -sandbox.rb lib/rails/console/sandbox.rb 1;" F -save lib/rails/generators/active_model.rb /^ def save$/;" f class:Rails.Generators.ActiveModel -scaffold_controller_generator.rb lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb 1;" F -scaffold_controller_generator_test.rb test/generators/scaffold_controller_generator_test.rb 1;" F -scaffold_generator.rb lib/rails/generators/erb/scaffold/scaffold_generator.rb 1;" F -scaffold_generator.rb lib/rails/generators/rails/scaffold/scaffold_generator.rb 1;" F -scaffold_generator.rb lib/rails/generators/test_unit/scaffold/scaffold_generator.rb 1;" F -scaffold_generator_test.rb test/generators/scaffold_generator_test.rb 1;" F -script lib/rails/generators/rails/app/app_generator.rb /^ def script$/;" f -script lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def script(force = false)$/;" f class:Rails.PluginBuilder -script test/isolation/abstract_unit.rb /^ def script(script)$/;" f -script_name test/railties/mounted_engine_test.rb /^ def script_name(script_name)$/;" f class:ApplicationTests -script_rails_loader.rb lib/rails/script_rails_loader.rb 1;" F -script_rails_loader_test.rb test/script_rails_loader_test.rb 1;" F -secret_token.rb tmp/app_template/config/initializers/secret_token.rb 1;" F -seeds.rb lib/rails/generators/rails/app/templates/db/seeds.rb 1;" F -seeds.rb tmp/app/db/seeds.rb 1;" F -seeds.rb tmp/app_template/db/seeds.rb 1;" F -select_only guides/rails_guides/generator.rb /^ def select_only(guides)$/;" f class:RailsGuides.Generator -select_only guides/w3c_validator.rb /^ def select_only(guides)$/;" f class:RailsGuides.Validator -sendfile_test.rb test/application/middleware/sendfile_test.rb 1;" F -server.rb lib/rails/commands/server.rb 1;" F -session_migration_generator.rb lib/rails/generators/rails/session_migration/session_migration_generator.rb 1;" F -session_migration_generator_test.rb test/generators/session_migration_generator_test.rb 1;" F -session_store lib/rails/application/configuration.rb /^ def session_store(*args)$/;" f class:Rails.Application.Configuration -session_store.rb tmp/app_template/config/initializers/session_store.rb 1;" F -set_default_accessors! lib/rails/generators/app_base.rb /^ def set_default_accessors!$/;" f class:Rails.Generators.AppBase -set_environment lib/rails/commands/server.rb /^ def set_environment$/;" f class:Rails.Server -set_flags_from_environment guides/rails_guides/generator.rb /^ def set_flags_from_environment$/;" f class:RailsGuides.Generator -set_header_section guides/rails_guides/generator.rb /^ def set_header_section(body, view)$/;" f class:RailsGuides.Generator -set_index guides/rails_guides/generator.rb /^ def set_index(body, view)$/;" f class:RailsGuides.Generator -setup test/application/configuration_test.rb /^ def setup$/;" f class:ApplicationTests.ConfigurationTest -setup test/application/console_test.rb /^ def setup$/;" f class:ConsoleTest -setup test/application/generators_test.rb /^ def setup$/;" f class:ApplicationTests.GeneratorsTest -setup test/application/initializers/boot_test.rb /^ def setup$/;" f class:ApplicationTests.GemBooting -setup test/application/initializers/check_ruby_version_test.rb /^ def setup$/;" f class:ApplicationTests.CheckRubyVersionTest -setup test/application/initializers/frameworks_test.rb /^ def setup$/;" f class:ApplicationTests.FrameworlsTest -setup test/application/initializers/hooks_test.rb /^ def setup$/;" f class:ApplicationTests.InitializersTest -setup test/application/initializers/i18n_test.rb /^ def setup$/;" f class:ApplicationTests.I18nTest -setup test/application/initializers/load_path_test.rb /^ def setup$/;" f class:ApplicationTests.LoadPathTest -setup test/application/initializers/notifications_test.rb /^ def setup$/;" f class:ApplicationTests.NotificationsTest -setup test/application/loading_test.rb /^ def setup$/;" f class:LoadingTest -setup test/application/middleware/best_practices_test.rb /^ def setup$/;" f class:ApplicationTests.BestPracticesTest -setup test/application/middleware/cache_test.rb /^ def setup$/;" f class:ApplicationTests.RoutingTest -setup test/application/middleware/remote_ip_test.rb /^ def setup$/;" f class:ApplicationTests.RemoteIpTest -setup test/application/middleware/sendfile_test.rb /^ def setup$/;" f class:ApplicationTests.SendfileTest -setup test/application/middleware_test.rb /^ def setup$/;" f class:ApplicationTests.MiddlewareTest -setup test/application/paths_test.rb /^ def setup$/;" f class:ApplicationTests.PathsTest -setup test/application/rackup_test.rb /^ def setup$/;" f class:ApplicationTests.RackupTest -setup test/application/rake_test.rb /^ def setup$/;" f class:ApplicationTests.RakeTest -setup test/application/routing_test.rb /^ def setup$/;" f class:ApplicationTests.RoutingTest -setup test/application/runner_test.rb /^ def setup$/;" f class:ApplicationTests.RunnerTest -setup test/application/test_test.rb /^ def setup$/;" f class:ApplicationTests.TestTest -setup test/backtrace_cleaner_test.rb /^ def setup$/;" f class:BacktraceCleanerFilterTest -setup test/backtrace_cleaner_test.rb /^ def setup$/;" f class:BacktraceCleanerVendorGemTest -setup test/generators/actions_test.rb /^ def setup$/;" f class:ActionsTest -setup test/generators/namespaced_generators_test.rb /^ def setup$/;" f class:NamespacedGeneratorTestCase -setup test/generators/shared_generator_tests.rb /^ def setup$/;" f class:SharedCustomGeneratorTests -setup test/generators/shared_generator_tests.rb /^ def setup$/;" f class:SharedGeneratorTests -setup test/generators_test.rb /^ def setup$/;" f class:GeneratorsTest -setup test/paths_test.rb /^ def setup$/;" f class:PathsTest -setup test/rails_info_controller_test.rb /^ def setup$/;" f class:InfoControllerTest -setup test/rails_info_test.rb /^ def setup$/;" f class:InfoTest -setup test/railties/engine_test.rb /^ def setup$/;" f class:RailtiesTest.EngineTest -setup test/railties/mounted_engine_test.rb /^ def setup$/;" f class:ApplicationTests.ApplicationRoutingTest -setup test/railties/plugin_ordering_test.rb /^ def setup$/;" f class:RailtiesTest.PluginOrderingTest -setup test/railties/plugin_test.rb /^ def setup$/;" f class:RailtiesTest.PluginTest -setup test/railties/railtie_test.rb /^ def setup$/;" f class:RailtiesTest.RailtieTest -setup_ar! test/application/loading_test.rb /^ def setup_ar!$/;" f -shBrushAS3.js guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js 1;" F -shBrushAppleScript.js guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js 1;" F -shBrushBash.js guides/assets/javascripts/syntaxhighlighter/shBrushBash.js 1;" F -shBrushCSharp.js guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js 1;" F -shBrushColdFusion.js guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js 1;" F -shBrushCpp.js guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js 1;" F -shBrushCss.js guides/assets/javascripts/syntaxhighlighter/shBrushCss.js 1;" F -shBrushDelphi.js guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js 1;" F -shBrushDiff.js guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js 1;" F -shBrushErlang.js guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js 1;" F -shBrushGroovy.js guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js 1;" F -shBrushJScript.js guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js 1;" F -shBrushJava.js guides/assets/javascripts/syntaxhighlighter/shBrushJava.js 1;" F -shBrushJavaFX.js guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js 1;" F -shBrushPerl.js guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js 1;" F -shBrushPhp.js guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js 1;" F -shBrushPlain.js guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js 1;" F -shBrushPowerShell.js guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js 1;" F -shBrushPython.js guides/assets/javascripts/syntaxhighlighter/shBrushPython.js 1;" F -shBrushRuby.js guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js 1;" F -shBrushSass.js guides/assets/javascripts/syntaxhighlighter/shBrushSass.js 1;" F -shBrushScala.js guides/assets/javascripts/syntaxhighlighter/shBrushScala.js 1;" F -shBrushSql.js guides/assets/javascripts/syntaxhighlighter/shBrushSql.js 1;" F -shBrushVb.js guides/assets/javascripts/syntaxhighlighter/shBrushVb.js 1;" F -shBrushXml.js guides/assets/javascripts/syntaxhighlighter/shBrushXml.js 1;" F -shCore.js guides/assets/javascripts/syntaxhighlighter/shCore.js 1;" F -shared_generator_tests.rb test/generators/shared_generator_tests.rb 1;" F -shared_tests.rb test/railties/shared_tests.rb 1;" F -show lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def show$/;" f -show test/railties/engine_test.rb /^ def show$/;" f class:Bukkits -show_deprecation lib/rails/generators/rails/plugin/plugin_generator.rb /^ def show_deprecation$/;" f class:Rails.Generators.PluginGenerator -show_results guides/w3c_validator.rb /^ def show_results(error_list)$/;" f class:RailsGuides.Validator -simple_builder.rb test/fixtures/lib/app_builders/simple_builder.rb 1;" F -simple_builder.rb test/fixtures/lib/plugin_builders/simple_builder.rb 1;" F -simple_controller test/application/middleware/cache_test.rb /^ def simple_controller$/;" f class:ApplicationTests.RoutingTest -simple_controller test/isolation/abstract_unit.rb /^ def simple_controller$/;" f -singular_table_name lib/rails/generators/named_base.rb /^ def singular_table_name$/;" f class:Rails.Generators -skip_ lib/rails/paths.rb /^ def skip_#{m}!$/;" f class:Rails.Paths.Path -skip_test_unit? test/fixtures/lib/plugin_builders/spec_builder.rb /^ def skip_test_unit?$/;" f class:PluginBuilder -something test/railties/engine_test.rb /^ def something$/;" f class:SomeHelper -source_annotation_extractor.rb lib/rails/source_annotation_extractor.rb 1;" F -source_root lib/rails/generators/base.rb /^ def self.source_root(path=nil)$/;" F class:Rails.Generators.Base -spec_builder.rb test/fixtures/lib/plugin_builders/spec_builder.rb 1;" F -split_args lib/rails/commands/plugin.rb /^ def split_args(args)$/;" f class:Commands.Plugin -start lib/rails/commands/console.rb /^ def self.start(app)$/;" F class:Rails.Console -start lib/rails/commands/console.rb /^ def start$/;" f class:Rails.Console -start lib/rails/commands/dbconsole.rb /^ def self.start(app)$/;" F class:Rails.DBConsole -start lib/rails/commands/dbconsole.rb /^ def start$/;" f class:Rails.DBConsole -start lib/rails/commands/server.rb /^ def start$/;" f class:Rails.Server -static.rb lib/rails/rack/static.rb 1;" F -static_asset_paths lib/rails/railtie/configuration.rb /^ def static_asset_paths$/;" f class:Rails.Railtie.Configuration -stringify lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function stringify(object) {$/;" f -stringify tmp/app/public/javascripts/prototype.js /^ function stringify(object) {$/;" f -stringify tmp/app_template/public/javascripts/prototype.js /^ function stringify(object) {$/;" f -stylesheets lib/rails/generators/rails/app/app_generator.rb /^ def stylesheets$/;" f -stylesheets lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def stylesheets$/;" f class:Rails.PluginBuilder -stylesheets_generator.rb lib/rails/generators/rails/stylesheets/stylesheets_generator.rb 1;" F -stylesheets_generator_test.rb test/generators/stylesheets_generator_test.rb 1;" F -subclasses lib/rails/generators.rb /^ def self.subclasses$/;" F class:Rails.Generators -subclasses lib/rails/railtie.rb /^ def subclasses$/;" f class:Rails.Railtie -submitBubbles lib/rails/generators/rails/app/templates/public/javascripts/prototype_ujs.js /^ var submitBubbles = isEventSupported('submit'),$/;" v -submitBubbles tmp/app/public/javascripts/rails.js /^ var submitBubbles = isEventSupported('submit'),$/;" v -submitBubbles tmp/app_template/public/javascripts/rails.js /^ var submitBubbles = isEventSupported('submit'),$/;" v -svn_command lib/rails/commands/plugin.rb /^ def svn_command(cmd, options = {})$/;" f -svn_info test/rails_info_test.rb /^ def svn_info$/;" f class:InfoTest.svn_info= -svn_info= test/rails_info_test.rb /^ def svn_info=(info)$/;" f class:InfoTest -svn_url? lib/rails/commands/plugin.rb /^ def svn_url?$/;" f class:Plugin -swap lib/rails/configuration.rb /^ def swap(*args, &block)$/;" f class:Rails.Configuration.MiddlewareStackProxy -table_name lib/rails/generators/named_base.rb /^ def table_name$/;" f class:Rails.Generators -table_name_prefix test/railties/engine_test.rb /^ def self.table_name_prefix$/;" F class:Bukkits -tail! lib/rails/rack/log_tailer.rb /^ def tail!$/;" f class:Rails.Rack.LogTailer -tasks.rb lib/rails/tasks.rb 1;" F -teardown test/application/configuration_test.rb /^ def teardown$/;" f class:ApplicationTests.ConfigurationTest -teardown test/generators/actions_test.rb /^ def teardown$/;" f class:ActionsTest -teardown test/generators/namespaced_generators_test.rb /^ def teardown$/;" f class:NamespacedGeneratorTestCase -teardown test/generators/shared_generator_tests.rb /^ def teardown$/;" f class:SharedCustomGeneratorTests -teardown test/generators/shared_generator_tests.rb /^ def teardown$/;" f class:SharedGeneratorTests -teardown test/generators_test.rb /^ def teardown$/;" f class:GeneratorsTest -template lib/rails/generators/named_base.rb /^ def template(source, *args, &block)$/;" f class:Rails.Generators.NamedBase -template.rb test/fixtures/lib/template.rb 1;" F -templates_path lib/rails/generators.rb /^ def self.templates_path$/;" F class:Rails.Generators -test lib/rails/generators/rails/app/app_generator.rb /^ def test$/;" f -test lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def test$/;" f class:Rails.PluginBuilder -test test/fixtures/lib/plugin_builders/spec_builder.rb /^ def test$/;" f class:PluginBuilder -test.rb tmp/app_template/config/environments/test.rb 1;" F -test_access_to_helpers test/application/console_test.rb /^ def test_access_to_helpers$/;" f class:ConsoleTest -test_actions_are_turned_into_methods test/generators/controller_generator_test.rb /^ def test_actions_are_turned_into_methods$/;" f class:ControllerGeneratorTest -test_actions_are_turned_into_methods test/generators/mailer_generator_test.rb /^ def test_actions_are_turned_into_methods$/;" f -test_active_record_does_not_panic_when_referencing_an_observed_constant test/application/console_test.rb /^ def test_active_record_does_not_panic_when_referencing_an_observed_constant$/;" f class:ConsoleTest -test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given test/generators/app_generator_test.rb /^ def test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given$/;" f -test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given test/generators/plugin_new_generator_test.rb /^ def test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given$/;" f class:PluginNewGeneratorTest -test_add_migration_with_attributes test/generators/migration_generator_test.rb /^ def test_add_migration_with_attributes$/;" f class:MigrationGeneratorTest -test_add_routes test/generators/controller_generator_test.rb /^ def test_add_routes$/;" f class:ControllerGeneratorTest -test_add_source_adds_source_to_gemfile test/generators/actions_test.rb /^ def test_add_source_adds_source_to_gemfile$/;" f class:ActionsTest -test_adds_helpers_to_controller_views test/railties/shared_tests.rb /^ def test_adds_helpers_to_controller_views$/;" f class:RailtiesTest -test_adds_its_views_to_view_paths test/railties/shared_tests.rb /^ def test_adds_its_views_to_view_paths$/;" f class:RailtiesTest -test_adds_its_views_to_view_paths_with_lower_proriority_than_app_ones test/railties/shared_tests.rb /^ def test_adds_its_views_to_view_paths_with_lower_proriority_than_app_ones$/;" f class:RailtiesTest -test_adds_namespace_to_model test/generators/namespaced_generators_test.rb /^ def test_adds_namespace_to_model$/;" f class:NamespacedModelGeneratorTest -test_app_method_should_return_integration_session test/application/console_test.rb /^ def test_app_method_should_return_integration_session$/;" f class:ConsoleTest -test_application_controller_and_layout_files test/generators/app_generator_test.rb /^ def test_application_controller_and_layout_files$/;" f class:AppGeneratorTest -test_application_name test/generators/named_base_test.rb /^ def test_application_name$/;" f class:NamedBaseTest -test_application_name_is_detected_if_it_exists_and_app_folder_renamed test/generators/app_generator_test.rb /^ def test_application_name_is_detected_if_it_exists_and_app_folder_renamed$/;" f class:AppGeneratorTest -test_application_names_are_not_singularized test/generators/app_generator_test.rb /^ def test_application_names_are_not_singularized$/;" f class:AppGeneratorTest -test_autoload_any_path_under_app test/railties/shared_tests.rb /^ def test_autoload_any_path_under_app$/;" f class:RailtiesTest -test_being_quiet_while_creating_dummy_application test/generators/plugin_new_generator_test.rb /^ def test_being_quiet_while_creating_dummy_application$/;" f class:PluginNewGeneratorTest -test_builder_option_with_empty_app_builder test/generators/shared_generator_tests.rb /^ def test_builder_option_with_empty_app_builder$/;" f class:SharedCustomGeneratorTests -test_builder_option_with_http test/generators/shared_generator_tests.rb /^ def test_builder_option_with_http$/;" f class:SharedCustomGeneratorTests -test_builder_option_with_relative_path test/generators/shared_generator_tests.rb /^ def test_builder_option_with_relative_path$/;" f class:SharedCustomGeneratorTests -test_builder_option_with_simple_plugin_builder test/generators/shared_generator_tests.rb /^ def test_builder_option_with_simple_plugin_builder$/;" f class:SharedCustomGeneratorTests -test_builder_option_with_tweak_plugin_builder test/generators/shared_generator_tests.rb /^ def test_builder_option_with_tweak_plugin_builder$/;" f class:SharedCustomGeneratorTests -test_cache_is_disabled_in_dev_mode test/application/middleware/cache_test.rb /^ def test_cache_is_disabled_in_dev_mode$/;" f class:ApplicationTests.RoutingTest -test_cache_works_with_etags test/application/middleware/cache_test.rb /^ def test_cache_works_with_etags$/;" f class:ApplicationTests.RoutingTest -test_cache_works_with_etags_private test/application/middleware/cache_test.rb /^ def test_cache_works_with_etags_private$/;" f class:ApplicationTests.RoutingTest -test_cache_works_with_expires test/application/middleware/cache_test.rb /^ def test_cache_works_with_expires$/;" f class:ApplicationTests.RoutingTest -test_cache_works_with_expires_private test/application/middleware/cache_test.rb /^ def test_cache_works_with_expires_private$/;" f class:ApplicationTests.RoutingTest -test_cache_works_with_last_modified test/application/middleware/cache_test.rb /^ def test_cache_works_with_last_modified$/;" f class:ApplicationTests.RoutingTest -test_cache_works_with_last_modified_private test/application/middleware/cache_test.rb /^ def test_cache_works_with_last_modified_private$/;" f class:ApplicationTests.RoutingTest -test_capify_should_run_the_capify_command test/generators/actions_test.rb /^ def test_capify_should_run_the_capify_command$/;" f class:ActionsTest -test_case.rb lib/rails/generators/test_case.rb 1;" F -test_check_class_collision test/generators/controller_generator_test.rb /^ def test_check_class_collision$/;" f class:ControllerGeneratorTest -test_check_class_collision test/generators/helper_generator_test.rb /^ def test_check_class_collision$/;" f class:HelperGeneratorTest -test_check_class_collision test/generators/mailer_generator_test.rb /^ def test_check_class_collision$/;" f -test_check_class_collision test/generators/model_generator_test.rb /^ def test_check_class_collision$/;" f -test_check_class_collision test/generators/plugin_generator_test.rb /^ def test_check_class_collision$/;" f class:PluginGeneratorTest -test_check_class_collision_on_tests test/generators/helper_generator_test.rb /^ def test_check_class_collision_on_tests$/;" f class:HelperGeneratorTest -test_code_statistics_sanity test/application/rake_test.rb /^ def test_code_statistics_sanity$/;" f class:ApplicationTests -test_config_another_database test/generators/app_generator_test.rb /^ def test_config_another_database$/;" f class:AppGeneratorTest -test_config_another_database test/generators/plugin_new_generator_test.rb /^ def test_config_another_database$/;" f class:PluginNewGeneratorTest -test_config_database_is_added_by_default test/generators/app_generator_test.rb /^ def test_config_database_is_added_by_default$/;" f class:AppGeneratorTest -test_config_jquery_javascript_library test/generators/app_generator_test.rb /^ def test_config_jquery_javascript_library$/;" f -test_config_prototype_javascript_library test/generators/app_generator_test.rb /^ def test_config_prototype_javascript_library$/;" f -test_constants_in_app_are_autoloaded test/application/loading_test.rb /^ def test_constants_in_app_are_autoloaded$/;" f class:LoadingTest -test_controller_skeleton_is_created test/generators/controller_generator_test.rb /^ def test_controller_skeleton_is_created$/;" f class:ControllerGeneratorTest -test_controller_skeleton_is_created test/generators/scaffold_controller_generator_test.rb /^ def test_controller_skeleton_is_created$/;" f class:ScaffoldControllerGeneratorTest -test_copy_stylesheets test/generators/stylesheets_generator_test.rb /^ def test_copy_stylesheets$/;" f class:StylesheetsGeneratorTest -test_copying_assets test/railties/shared_tests.rb /^ def test_copying_assets$/;" f class:RailtiesTest.SharedTests -test_copying_migrations test/railties/shared_tests.rb /^ def test_copying_migrations$/;" f class:RailtiesTest.SharedTests -test_create_file_should_write_block_contents_to_file_path test/generators/actions_test.rb /^ def test_create_file_should_write_block_contents_to_file_path$/;" f class:ActionsTest -test_create_file_should_write_data_to_file_path test/generators/actions_test.rb /^ def test_create_file_should_write_data_to_file_path$/;" f class:ActionsTest -test_create_mountable_application_with_mountable_option test/generators/plugin_new_generator_test.rb /^ def test_create_mountable_application_with_mountable_option$/;" f class:PluginNewGeneratorTest -test_creates_generator_if_required test/generators/plugin_generator_test.rb /^ def test_creates_generator_if_required$/;" f class:PluginGeneratorTest -test_creates_tasks_if_required test/generators/plugin_generator_test.rb /^ def test_creates_tasks_if_required$/;" f class:PluginGeneratorTest -test_creating_engine_in_full_mode test/generators/plugin_new_generator_test.rb /^ def test_creating_engine_in_full_mode$/;" f class:PluginNewGeneratorTest -test_customized_orm_is_used test/generators/scaffold_controller_generator_test.rb /^ def test_customized_orm_is_used$/;" f -test_database_entry_is_assed_by_default_in_full_mode test/generators/plugin_new_generator_test.rb /^ def test_database_entry_is_assed_by_default_in_full_mode$/;" f class:PluginNewGeneratorTest -test_default_banner_should_not_show_rails_generator_namespace test/generators_test.rb /^ def test_default_banner_should_not_show_rails_generator_namespace$/;" f class:GeneratorsTest -test_default_banner_should_show_generator_namespace test/generators_test.rb /^ def test_default_banner_should_show_generator_namespace$/;" f class:GeneratorsTest -test_default_namespace test/generators/app_generator_test.rb /^ def test_default_namespace$/;" f -test_default_orm_is_used test/generators/scaffold_controller_generator_test.rb /^ def test_default_orm_is_used$/;" f -test_default_usage test/generators/app_generator_test.rb /^ def test_default_usage$/;" f -test_default_value_is_boolean test/generators/generated_attribute_test.rb /^ def test_default_value_is_boolean$/;" f class:GeneratedAttributeTest -test_default_value_is_date test/generators/generated_attribute_test.rb /^ def test_default_value_is_date$/;" f class:GeneratedAttributeTest -test_default_value_is_datetime test/generators/generated_attribute_test.rb /^ def test_default_value_is_datetime$/;" f class:GeneratedAttributeTest -test_default_value_is_decimal test/generators/generated_attribute_test.rb /^ def test_default_value_is_decimal$/;" f class:GeneratedAttributeTest -test_default_value_is_empty_string test/generators/generated_attribute_test.rb /^ def test_default_value_is_empty_string$/;" f class:GeneratedAttributeTest -test_default_value_is_float test/generators/generated_attribute_test.rb /^ def test_default_value_is_float$/;" f class:GeneratedAttributeTest -test_default_value_is_integer test/generators/generated_attribute_test.rb /^ def test_default_value_is_integer$/;" f class:GeneratedAttributeTest -test_default_value_is_nil test/generators/generated_attribute_test.rb /^ def test_default_value_is_nil$/;" f class:GeneratedAttributeTest -test_default_value_is_string test/generators/generated_attribute_test.rb /^ def test_default_value_is_string$/;" f class:GeneratedAttributeTest -test_default_value_is_text test/generators/generated_attribute_test.rb /^ def test_default_value_is_text$/;" f class:GeneratedAttributeTest -test_deprecation test/generators/plugin_generator_test.rb /^ def test_deprecation$/;" f class:PluginGeneratorTest -test_descendants_are_cleaned_on_each_request_without_cache_classes test/application/loading_test.rb /^ def test_descendants_are_cleaned_on_each_request_without_cache_classes$/;" f -test_dev_option test/generators/shared_generator_tests.rb /^ def test_dev_option$/;" f class:SharedGeneratorTests -test_developer_options_are_overwriten_by_user_options test/generators_test.rb /^ def test_developer_options_are_overwriten_by_user_options$/;" f class:GeneratorsTest -test_does_not_invoke_helper_if_required test/generators/controller_generator_test.rb /^ def test_does_not_invoke_helper_if_required$/;" f class:ControllerGeneratorTest -test_does_not_invoke_test_framework_if_required test/generators/controller_generator_test.rb /^ def test_does_not_invoke_test_framework_if_required$/;" f class:ControllerGeneratorTest -test_dummy_clean lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def test_dummy_clean$/;" f class:Rails.PluginBuilder -test_dummy_config lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def test_dummy_config$/;" f class:Rails.PluginBuilder -test_edge_option test/generators/shared_generator_tests.rb /^ def test_edge_option$/;" f class:SharedGeneratorTests -test_ensure_that_database_option_is_passed_to_app_generator test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_database_option_is_passed_to_app_generator$/;" f class:PluginNewGeneratorTest -test_ensure_that_javascript_option_is_passed_to_app_generator test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_javascript_option_is_passed_to_app_generator$/;" f class:PluginNewGeneratorTest -test_ensure_that_plugin_options_are_not_passed_to_app_generator test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_plugin_options_are_not_passed_to_app_generator$/;" f class:PluginNewGeneratorTest -test_ensure_that_skip_active_record_option_is_passed_to_app_generator test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_skip_active_record_option_is_passed_to_app_generator$/;" f class:PluginNewGeneratorTest -test_ensure_that_skip_javascript_option_is_passed_to_app_generator test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_skip_javascript_option_is_passed_to_app_generator$/;" f class:PluginNewGeneratorTest -test_ensure_that_test_dummy_can_be_generated_from_a_template test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_test_dummy_can_be_generated_from_a_template$/;" f class:PluginNewGeneratorTest -test_ensure_that_tests_works test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_tests_works$/;" f class:PluginNewGeneratorTest -test_ensure_that_tests_works_in_full_mode test/generators/plugin_new_generator_test.rb /^ def test_ensure_that_tests_works_in_full_mode$/;" f class:PluginNewGeneratorTest -test_environment_is_required_in_rake_tasks test/application/rake_test.rb /^ def test_environment_is_required_in_rake_tasks$/;" f class:ApplicationTests.RakeTest -test_environment_should_include_data_in_environment_initializer_block test/generators/actions_test.rb /^ def test_environment_should_include_data_in_environment_initializer_block$/;" f class:ActionsTest -test_environment_with_block_should_include_block_contents_in_environment_initializer_block test/generators/actions_test.rb /^ def test_environment_with_block_should_include_block_contents_in_environment_initializer_block$/;" f class:ActionsTest -test_existing_migration_is_removed_on_force test/generators/model_generator_test.rb /^ def test_existing_migration_is_removed_on_force$/;" f -test_fallbacks_for_generators_on_find_by_namespace test/generators_test.rb /^ def test_fallbacks_for_generators_on_find_by_namespace$/;" f class:GeneratorsTest -test_fallbacks_for_generators_on_find_by_namespace_with_context test/generators_test.rb /^ def test_fallbacks_for_generators_on_find_by_namespace_with_context$/;" f class:GeneratorsTest -test_fallbacks_for_generators_on_invoke test/generators_test.rb /^ def test_fallbacks_for_generators_on_invoke$/;" f class:GeneratorsTest -test_field_type_returns_check_box test/generators/generated_attribute_test.rb /^ def test_field_type_returns_check_box$/;" f class:GeneratedAttributeTest -test_field_type_returns_date_select test/generators/generated_attribute_test.rb /^ def test_field_type_returns_date_select$/;" f class:GeneratedAttributeTest -test_field_type_returns_datetime_select test/generators/generated_attribute_test.rb /^ def test_field_type_returns_datetime_select$/;" f class:GeneratedAttributeTest -test_field_type_returns_text_area test/generators/generated_attribute_test.rb /^ def test_field_type_returns_text_area$/;" f class:GeneratedAttributeTest -test_field_type_returns_text_field test/generators/generated_attribute_test.rb /^ def test_field_type_returns_text_field$/;" f class:GeneratedAttributeTest -test_field_type_returns_time_select test/generators/generated_attribute_test.rb /^ def test_field_type_returns_time_select$/;" f class:GeneratedAttributeTest -test_field_type_with_unknown_type_returns_text_field test/generators/generated_attribute_test.rb /^ def test_field_type_with_unknown_type_returns_text_field$/;" f class:GeneratedAttributeTest -test_file_is_added_for_backwards_compatibility test/generators/app_generator_test.rb /^ def test_file_is_added_for_backwards_compatibility$/;" f -test_files_from_inherited_invocation test/generators/resource_generator_test.rb /^ def test_files_from_inherited_invocation$/;" f class:ResourceGeneratorTest -test_find_by_namespace test/generators_test.rb /^ def test_find_by_namespace$/;" f class:GeneratorsTest -test_find_by_namespace_in_subfolder test/generators_test.rb /^ def test_find_by_namespace_in_subfolder$/;" f class:GeneratorsTest -test_find_by_namespace_show_warning_if_generator_cant_be_loaded test/generators_test.rb /^ def test_find_by_namespace_show_warning_if_generator_cant_be_loaded$/;" f class:GeneratorsTest -test_find_by_namespace_with_base test/generators_test.rb /^ def test_find_by_namespace_with_base$/;" f class:GeneratorsTest -test_find_by_namespace_with_context test/generators_test.rb /^ def test_find_by_namespace_with_context$/;" f class:GeneratorsTest -test_find_by_namespace_with_duplicated_name test/generators_test.rb /^ def test_find_by_namespace_with_duplicated_name$/;" f class:GeneratorsTest -test_find_by_namespace_with_generator_on_root test/generators_test.rb /^ def test_find_by_namespace_with_generator_on_root$/;" f class:GeneratorsTest -test_find_by_namespace_without_base_or_context_looks_into_rails_namespace test/generators_test.rb /^ def test_find_by_namespace_without_base_or_context_looks_into_rails_namespace$/;" f class:GeneratorsTest -test_fixture_is_skipped test/generators/model_generator_test.rb /^ def test_fixture_is_skipped$/;" f -test_fixture_is_skipped_if_fixture_replacement_is_given test/generators/model_generator_test.rb /^ def test_fixture_is_skipped_if_fixture_replacement_is_given$/;" f -test_framework_version test/rails_info_test.rb /^ def test_framework_version$/;" f class:InfoTest -test_frameworks_exist test/rails_info_test.rb /^ def test_frameworks_exist$/;" f class:InfoTest -test_functional_tests test/generators/scaffold_controller_generator_test.rb /^ def test_functional_tests$/;" f -test_gem_should_insert_on_separate_lines test/generators/actions_test.rb /^ def test_gem_should_insert_on_separate_lines$/;" f class:ActionsTest -test_gem_should_put_gem_dependency_in_gemfile test/generators/actions_test.rb /^ def test_gem_should_put_gem_dependency_in_gemfile$/;" f class:ActionsTest -test_gem_with_version_should_include_version_in_gemfile test/generators/actions_test.rb /^ def test_gem_with_version_should_include_version_in_gemfile$/;" f class:ActionsTest -test_gems_tasks_are_loaded_first_than_application_ones test/application/rake_test.rb /^ def test_gems_tasks_are_loaded_first_than_application_ones$/;" f class:ApplicationTests.RakeTest -test_generate_should_run_script_generate_with_argument_and_options test/generators/actions_test.rb /^ def test_generate_should_run_script_generate_with_argument_and_options$/;" f class:ActionsTest -test_generating_test_files test/generators/plugin_new_generator_test.rb /^ def test_generating_test_files$/;" f class:PluginNewGeneratorTest -test_generating_test_files_in_full_mode test/generators/plugin_new_generator_test.rb /^ def test_generating_test_files_in_full_mode$/;" f class:PluginNewGeneratorTest -test_generator_if_skip_active_record_is_given test/generators/app_generator_test.rb /^ def test_generator_if_skip_active_record_is_given$/;" f class:AppGeneratorTest -test_generator_skeleton_is_created test/generators/generator_generator_test.rb /^ def test_generator_skeleton_is_created$/;" f class:GeneratorGeneratorTest -test_generator_skeleton_is_created_without_file_name_namespace test/generators/generator_generator_test.rb /^ def test_generator_skeleton_is_created_without_file_name_namespace$/;" f class:GeneratorGeneratorTest -test_git_with_hash_should_run_each_command_using_git_scm test/generators/actions_test.rb /^ def test_git_with_hash_should_run_each_command_using_git_scm$/;" f class:ActionsTest -test_git_with_symbol_should_run_command_using_git_scm test/generators/actions_test.rb /^ def test_git_with_symbol_should_run_command_using_git_scm$/;" f class:ActionsTest -test_help.rb lib/rails/test_help.rb 1;" F -test_help_does_not_show_invoked_generators_options_if_they_already_exist test/generators/controller_generator_test.rb /^ def test_help_does_not_show_invoked_generators_options_if_they_already_exist$/;" f class:ControllerGeneratorTest -test_help_shows_invoked_generators_options test/generators/model_generator_test.rb /^ def test_help_shows_invoked_generators_options$/;" f class:ModelGeneratorTest -test_help_when_a_generator_with_required_arguments_is_invoked_without_arguments test/generators_test.rb /^ def test_help_when_a_generator_with_required_arguments_is_invoked_without_arguments$/;" f class:GeneratorsTest -test_help_with_inherited_options test/generators/resource_generator_test.rb /^ def test_help_with_inherited_options$/;" f class:ResourceGeneratorTest -test_helper.rb lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb 1;" F -test_helper.rb lib/rails/generators/test_unit/plugin/templates/test_helper.rb 1;" F -test_helper.rb tmp/app/test/test_helper.rb 1;" F -test_helper.rb tmp/app_template/test/test_helper.rb 1;" F -test_helper_are_invoked_with_a_pluralized_name test/generators/scaffold_controller_generator_test.rb /^ def test_helper_are_invoked_with_a_pluralized_name$/;" f -test_helper_skeleton_is_created test/generators/helper_generator_test.rb /^ def test_helper_skeleton_is_created$/;" f class:HelperGeneratorTest -test_helpr_is_also_namespaced test/generators/namespaced_generators_test.rb /^ def test_helpr_is_also_namespaced$/;" f class:NamespacedControllerGeneratorTest -test_homepage lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb /^ def test_homepage$/;" f class:BrowsingTest -test_homepage lib/rails/generators/test_unit/performance/templates/performance_test.rb /^ def test_homepage$/;" f -test_homepage tmp/app/test/performance/browsing_test.rb /^ def test_homepage$/;" f class:BrowsingTest -test_homepage tmp/app_template/test/performance/browsing_test.rb /^ def test_homepage$/;" f class:BrowsingTest -test_html_includes_middleware test/rails_info_test.rb /^ def test_html_includes_middleware$/;" f class:InfoTest -test_human_name test/generators/generated_attribute_test.rb /^ def test_human_name$/;" f class:GeneratedAttributeTest -test_i18n_files_have_lower_priority_than_application_ones test/railties/shared_tests.rb /^ def test_i18n_files_have_lower_priority_than_application_ones$/;" f class:RailtiesTest -test_index test/application/test_test.rb /^ def test_index$/;" f class:PostsTest -test_index_helper test/generators/named_base_test.rb /^ def test_index_helper$/;" f class:NamedBaseTest -test_index_helper_with_uncountable test/generators/named_base_test.rb /^ def test_index_helper_with_uncountable$/;" f class:NamedBaseTest -test_inherited_invocations_with_attributes test/generators/resource_generator_test.rb /^ def test_inherited_invocations_with_attributes$/;" f class:ResourceGeneratorTest -test_initializer_should_write_date_to_file_in_config_initializers test/generators/actions_test.rb /^ def test_initializer_should_write_date_to_file_in_config_initializers$/;" f class:ActionsTest -test_initializers test/railties/shared_tests.rb /^ def test_initializers$/;" f class:RailtiesTest -test_initializers_are_executed_in_rake_tasks test/application/rake_test.rb /^ def test_initializers_are_executed_in_rake_tasks$/;" f class:ApplicationTests.RakeTest -test_install_migrations_and_assets test/railties/shared_tests.rb /^ def test_install_migrations_and_assets$/;" f class:RailtiesTest.SharedTests -test_integration_test_skeleton_is_created test/generators/integration_test_generator_test.rb /^ def test_integration_test_skeleton_is_created$/;" f class:IntegrationTestGeneratorTest -test_invalid_application_name_is_fixed test/generators/app_generator_test.rb /^ def test_invalid_application_name_is_fixed$/;" f class:AppGeneratorTest -test_invalid_application_name_raises_an_error test/generators/app_generator_test.rb /^ def test_invalid_application_name_raises_an_error$/;" f class:AppGeneratorTest -test_invalid_database_option_raises_an_error test/generators/shared_generator_tests.rb /^ def test_invalid_database_option_raises_an_error$/;" f class:SharedGeneratorTests -test_invalid_plugin_name_is_fixed test/generators/plugin_new_generator_test.rb /^ def test_invalid_plugin_name_is_fixed$/;" f class:PluginNewGeneratorTest -test_invalid_plugin_name_raises_an_error test/generators/plugin_new_generator_test.rb /^ def test_invalid_plugin_name_raises_an_error$/;" f class:PluginNewGeneratorTest -test_invoke_other_generator_with_full_namespace test/generators/actions_test.rb /^ def test_invoke_other_generator_with_full_namespace$/;" f class:ActionsTest -test_invoke_other_generator_with_shortcut test/generators/actions_test.rb /^ def test_invoke_other_generator_with_shortcut$/;" f class:ActionsTest -test_invoke_when_generator_is_not_found test/generators_test.rb /^ def test_invoke_when_generator_is_not_found$/;" f class:GeneratorsTest -test_invoke_with_config_values test/generators_test.rb /^ def test_invoke_with_config_values$/;" f class:GeneratorsTest -test_invoke_with_default_values test/generators_test.rb /^ def test_invoke_with_default_values$/;" f class:GeneratorsTest -test_invoke_with_nested_namespaces test/generators_test.rb /^ def test_invoke_with_nested_namespaces$/;" f class:GeneratorsTest -test_invokes_default_orm test/generators/model_generator_test.rb /^ def test_invokes_default_orm$/;" f class:ModelGeneratorTest -test_invokes_default_orm test/generators/namespaced_generators_test.rb /^ def test_invokes_default_orm$/;" f class:NamespacedObserverGeneratorTest -test_invokes_default_orm test/generators/observer_generator_test.rb /^ def test_invokes_default_orm$/;" f class:ObserverGeneratorTest -test_invokes_default_orm_with_class_path test/generators/namespaced_generators_test.rb /^ def test_invokes_default_orm_with_class_path$/;" f class:NamespacedObserverGeneratorTest -test_invokes_default_orm_with_class_path test/generators/observer_generator_test.rb /^ def test_invokes_default_orm_with_class_path$/;" f class:ObserverGeneratorTest -test_invokes_default_template_engine test/generators/controller_generator_test.rb /^ def test_invokes_default_template_engine$/;" f class:ControllerGeneratorTest -test_invokes_default_template_engine test/generators/mailer_generator_test.rb /^ def test_invokes_default_template_engine$/;" f -test_invokes_default_template_engine test/generators/namespaced_generators_test.rb /^ def test_invokes_default_template_engine$/;" f -test_invokes_default_template_engine test/generators/namespaced_generators_test.rb /^ def test_invokes_default_template_engine$/;" f class:NamespacedControllerGeneratorTest -test_invokes_default_template_engine_even_with_no_action test/generators/controller_generator_test.rb /^ def test_invokes_default_template_engine_even_with_no_action$/;" f class:ControllerGeneratorTest -test_invokes_default_template_engine_even_with_no_action test/generators/mailer_generator_test.rb /^ def test_invokes_default_template_engine_even_with_no_action$/;" f -test_invokes_default_template_engine_even_with_no_action test/generators/namespaced_generators_test.rb /^ def test_invokes_default_template_engine_even_with_no_action$/;" f -test_invokes_default_template_engine_even_with_no_action test/generators/namespaced_generators_test.rb /^ def test_invokes_default_template_engine_even_with_no_action$/;" f class:NamespacedControllerGeneratorTest -test_invokes_default_test_framework test/generators/controller_generator_test.rb /^ def test_invokes_default_test_framework$/;" f class:ControllerGeneratorTest -test_invokes_default_test_framework test/generators/helper_generator_test.rb /^ def test_invokes_default_test_framework$/;" f class:HelperGeneratorTest -test_invokes_default_test_framework test/generators/mailer_generator_test.rb /^ def test_invokes_default_test_framework$/;" f -test_invokes_default_test_framework test/generators/model_generator_test.rb /^ def test_invokes_default_test_framework$/;" f -test_invokes_default_test_framework test/generators/namespaced_generators_test.rb /^ def test_invokes_default_test_framework$/;" f -test_invokes_default_test_framework test/generators/namespaced_generators_test.rb /^ def test_invokes_default_test_framework$/;" f class:NamespacedControllerGeneratorTest -test_invokes_default_test_framework test/generators/namespaced_generators_test.rb /^ def test_invokes_default_test_framework$/;" f class:NamespacedModelGeneratorTest -test_invokes_default_test_framework test/generators/namespaced_generators_test.rb /^ def test_invokes_default_test_framework$/;" f class:NamespacedObserverGeneratorTest -test_invokes_default_test_framework test/generators/observer_generator_test.rb /^ def test_invokes_default_test_framework$/;" f class:ObserverGeneratorTest -test_invokes_default_test_framework test/generators/plugin_generator_test.rb /^ def test_invokes_default_test_framework$/;" f class:PluginGeneratorTest -test_invokes_helper test/generators/controller_generator_test.rb /^ def test_invokes_helper$/;" f class:ControllerGeneratorTest -test_javascript_is_skipped_if_required test/generators/app_generator_test.rb /^ def test_javascript_is_skipped_if_required$/;" f -test_javascripts_generation test/generators/plugin_new_generator_test.rb /^ def test_javascripts_generation$/;" f class:PluginNewGeneratorTest -test_lib_should_write_data_to_file_in_lib test/generators/actions_test.rb /^ def test_lib_should_write_data_to_file_in_lib$/;" f class:ActionsTest -test_load_generators_from_railties test/generators_test.rb /^ def test_load_generators_from_railties$/;" f class:GeneratorsTest -test_logs_if_the_template_engine_cannot_be_found test/generators/mailer_generator_test.rb /^ def test_logs_if_the_template_engine_cannot_be_found$/;" f -test_logs_if_the_test_framework_cannot_be_found test/generators/helper_generator_test.rb /^ def test_logs_if_the_test_framework_cannot_be_found$/;" f class:HelperGeneratorTest -test_logs_if_the_test_framework_cannot_be_found test/generators/observer_generator_test.rb /^ def test_logs_if_the_test_framework_cannot_be_found$/;" f class:ObserverGeneratorTest -test_logs_if_the_test_framework_cannot_be_found test/generators/plugin_generator_test.rb /^ def test_logs_if_the_test_framework_cannot_be_found$/;" f class:PluginGeneratorTest -test_mailer_skeleton_is_created test/generators/mailer_generator_test.rb /^ def test_mailer_skeleton_is_created$/;" f class:MailerGeneratorTest -test_mailer_skeleton_is_created test/generators/namespaced_generators_test.rb /^ def test_mailer_skeleton_is_created$/;" f class:NamespacedMailerGeneratorTest -test_mailer_with_i18n_helper test/generators/mailer_generator_test.rb /^ def test_mailer_with_i18n_helper$/;" f -test_mailer_with_i18n_helper test/generators/namespaced_generators_test.rb /^ def test_mailer_with_i18n_helper$/;" f -test_mailer_with_namedspaced_mailer test/generators/mailer_generator_test.rb /^ def test_mailer_with_namedspaced_mailer$/;" f -test_mass_nouns_do_not_throw_warnings test/generators/resource_generator_test.rb /^ def test_mass_nouns_do_not_throw_warnings$/;" f -test_midleware_referenced_in_configuration test/railties/shared_tests.rb /^ def test_midleware_referenced_in_configuration$/;" f class:RailtiesTest -test_migration test/generators/migration_generator_test.rb /^ def test_migration$/;" f class:MigrationGeneratorTest -test_migration test/generators/model_generator_test.rb /^ def test_migration$/;" f class:ModelGeneratorTest -test_migration test/generators/namespaced_generators_test.rb /^ def test_migration$/;" f class:NamespacedModelGeneratorTest -test_migration_error_is_not_shown_on_revoke test/generators/model_generator_test.rb /^ def test_migration_error_is_not_shown_on_revoke$/;" f -test_migration_is_ignored_as_identical_with_skip_option test/generators/model_generator_test.rb /^ def test_migration_is_ignored_as_identical_with_skip_option$/;" f -test_migration_is_removed_on_revoke test/generators/model_generator_test.rb /^ def test_migration_is_removed_on_revoke$/;" f -test_migration_is_skipped test/generators/model_generator_test.rb /^ def test_migration_is_skipped$/;" f class:ModelGeneratorTest -test_migration_is_skipped_on_skip_behavior test/generators/model_generator_test.rb /^ def test_migration_is_skipped_on_skip_behavior$/;" f -test_migration_is_skipped_with_skip_option test/generators/model_generator_test.rb /^ def test_migration_is_skipped_with_skip_option$/;" f -test_migration_timestamps_are_skipped test/generators/model_generator_test.rb /^ def test_migration_timestamps_are_skipped$/;" f -test_migration_with_attributes test/generators/model_generator_test.rb /^ def test_migration_with_attributes$/;" f class:ModelGeneratorTest -test_migration_with_class_name test/generators/migration_generator_test.rb /^ def test_migration_with_class_name$/;" f class:MigrationGeneratorTest -test_migration_with_namespace test/generators/model_generator_test.rb /^ def test_migration_with_namespace$/;" f class:ModelGeneratorTest -test_migration_with_namespace test/generators/namespaced_generators_test.rb /^ def test_migration_with_namespace$/;" f class:NamespacedModelGeneratorTest -test_migration_with_namespaces_in_model_name_without_plurization test/generators/model_generator_test.rb /^ def test_migration_with_namespaces_in_model_name_without_plurization$/;" f class:ModelGeneratorTest -test_migration_with_nested_namespace test/generators/model_generator_test.rb /^ def test_migration_with_nested_namespace$/;" f class:ModelGeneratorTest -test_migration_with_nested_namespace test/generators/namespaced_generators_test.rb /^ def test_migration_with_nested_namespace$/;" f class:NamespacedModelGeneratorTest -test_migration_with_nested_namespace_without_pluralization test/generators/model_generator_test.rb /^ def test_migration_with_nested_namespace_without_pluralization$/;" f class:ModelGeneratorTest -test_migration_with_nested_namespace_without_pluralization test/generators/namespaced_generators_test.rb /^ def test_migration_with_nested_namespace_without_pluralization$/;" f class:NamespacedModelGeneratorTest -test_migration_with_timestamps test/generators/model_generator_test.rb /^ def test_migration_with_timestamps$/;" f -test_migration_without_pluralization test/generators/model_generator_test.rb /^ def test_migration_without_pluralization$/;" f class:ModelGeneratorTest -test_migration_without_timestamps test/generators/model_generator_test.rb /^ def test_migration_without_timestamps$/;" f -test_migrations_generated_simultaneously test/generators/migration_generator_test.rb /^ def test_migrations_generated_simultaneously$/;" f class:MigrationGeneratorTest -test_missing_type_raises_exception test/generators/generated_attribute_test.rb /^ def test_missing_type_raises_exception$/;" f class:GeneratedAttributeTest -test_model_and_migration_generator_with_change_syntax test/application/rake_test.rb /^ def test_model_and_migration_generator_with_change_syntax$/;" f class:ApplicationTests -test_model_with_belongs_to_attribute_generates_belongs_to_associations test/generators/model_generator_test.rb /^ def test_model_with_belongs_to_attribute_generates_belongs_to_associations$/;" f -test_model_with_missing_attribute_type test/generators/model_generator_test.rb /^ def test_model_with_missing_attribute_type$/;" f class:ModelGeneratorTest -test_model_with_namespace test/generators/model_generator_test.rb /^ def test_model_with_namespace$/;" f class:ModelGeneratorTest -test_model_with_namespace test/generators/namespaced_generators_test.rb /^ def test_model_with_namespace$/;" f class:NamespacedModelGeneratorTest -test_model_with_parent_option test/generators/model_generator_test.rb /^ def test_model_with_parent_option$/;" f class:ModelGeneratorTest -test_model_with_references_attribute_generates_belongs_to_associations test/generators/model_generator_test.rb /^ def test_model_with_references_attribute_generates_belongs_to_associations$/;" f -test_model_with_underscored_parent_option test/generators/model_generator_test.rb /^ def test_model_with_underscored_parent_option$/;" f class:ModelGeneratorTest -test_models_without_table_do_not_panic_on_scope_definitions_when_loaded test/application/loading_test.rb /^ def test_models_without_table_do_not_panic_on_scope_definitions_when_loaded$/;" f class:LoadingTest -test_module_file_is_not_created test/generators/namespaced_generators_test.rb /^ def test_module_file_is_not_created$/;" f class:NamespacedModelGeneratorTest -test_name_collision_raises_an_error test/generators/shared_generator_tests.rb /^ def test_name_collision_raises_an_error$/;" f class:SharedGeneratorTests -test_name_raises_an_error_if_name_already_used_constant test/generators/shared_generator_tests.rb /^ def test_name_raises_an_error_if_name_already_used_constant$/;" f class:SharedGeneratorTests -test_named_generator_attributes test/generators/named_base_test.rb /^ def test_named_generator_attributes$/;" f class:NamedBaseTest -test_named_generator_attributes_as_ruby test/generators/named_base_test.rb /^ def test_named_generator_attributes_as_ruby$/;" f class:NamedBaseTest -test_named_generator_attributes_without_pluralized test/generators/named_base_test.rb /^ def test_named_generator_attributes_without_pluralized$/;" f class:NamedBaseTest -test_named_generator_with_underscore test/generators/named_base_test.rb /^ def test_named_generator_with_underscore$/;" f class:NamedBaseTest -test_namespaced_and_not_namespaced_helpers test/generators/helper_generator_test.rb /^ def test_namespaced_and_not_namespaced_helpers$/;" f class:HelperGeneratorTest -test_namespaced_controller_skeleton_is_created test/generators/namespaced_generators_test.rb /^ def test_namespaced_controller_skeleton_is_created$/;" f class:NamespacedControllerGeneratorTest -test_namespaced_controller_with_additional_namespace test/generators/namespaced_generators_test.rb /^ def test_namespaced_controller_with_additional_namespace$/;" f class:NamespacedControllerGeneratorTest -test_namespaced_controllers_with_namespaced_routes test/railties/shared_tests.rb /^ def test_namespaced_controllers_with_namespaced_routes$/;" f class:RailtiesTest -test_namespaced_generator_skeleton test/generators/generator_generator_test.rb /^ def test_namespaced_generator_skeleton$/;" f class:GeneratorGeneratorTest -test_namespaced_generator_skeleton_without_file_name_namespace test/generators/generator_generator_test.rb /^ def test_namespaced_generator_skeleton_without_file_name_namespace$/;" f class:GeneratorGeneratorTest -test_nested_fallbacks_for_generators test/generators_test.rb /^ def test_nested_fallbacks_for_generators$/;" f class:GeneratorsTest -test_new_session_should_return_integration_session test/application/console_test.rb /^ def test_new_session_should_return_integration_session$/;" f class:ConsoleTest -test_nil_type_raises_exception test/generators/generated_attribute_test.rb /^ def test_nil_type_raises_exception$/;" f class:GeneratedAttributeTest -test_no_color_sets_proper_shell test/generators_test.rb /^ def test_no_color_sets_proper_shell$/;" f class:GeneratorsTest -test_options_before_application_name_raises_an_error test/generators/shared_generator_tests.rb /^ def test_options_before_application_name_raises_an_error$/;" f class:SharedGeneratorTests -test_overriding_test_framework test/generators/plugin_new_generator_test.rb /^ def test_overriding_test_framework$/;" f class:CustomPluginGeneratorTest -test_passing_dummy_path_as_a_parameter test/generators/plugin_new_generator_test.rb /^ def test_passing_dummy_path_as_a_parameter$/;" f class:PluginNewGeneratorTest -test_performance_test_skeleton_is_created test/generators/performance_test_generator_test.rb /^ def test_performance_test_skeleton_is_created$/;" f class:PerformanceTestGeneratorTest -test_plugin_generator_on_revoke test/generators/plugin_generator_test.rb /^ def test_plugin_generator_on_revoke$/;" f class:PluginGeneratorTest -test_plugin_new_generate_pretend test/generators/shared_generator_tests.rb /^ def test_plugin_new_generate_pretend$/;" f class:SharedGeneratorTests -test_plugin_skeleton_is_created test/generators/plugin_generator_test.rb /^ def test_plugin_skeleton_is_created$/;" f class:PluginGeneratorTest -test_plugin_with_git_option_and_branch_should_run_plugin_install test/generators/actions_test.rb /^ def test_plugin_with_git_option_and_branch_should_run_plugin_install$/;" f class:ActionsTest -test_plugin_with_git_option_and_submodule_should_use_git_scm test/generators/actions_test.rb /^ def test_plugin_with_git_option_and_submodule_should_use_git_scm$/;" f class:ActionsTest -test_plugin_with_git_option_should_run_plugin_install test/generators/actions_test.rb /^ def test_plugin_with_git_option_should_run_plugin_install$/;" f class:ActionsTest -test_plugin_with_no_options_should_skip_method test/generators/actions_test.rb /^ def test_plugin_with_no_options_should_skip_method$/;" f class:ActionsTest -test_plugin_with_svn_option_and_revision_should_run_plugin_install test/generators/actions_test.rb /^ def test_plugin_with_svn_option_and_revision_should_run_plugin_install$/;" f class:ActionsTest -test_plugin_with_svn_option_should_run_plugin_install test/generators/actions_test.rb /^ def test_plugin_with_svn_option_should_run_plugin_install$/;" f class:ActionsTest -test_plural_names_are_singularized test/generators/resource_generator_test.rb /^ def test_plural_names_are_singularized$/;" f -test_plural_names_can_be_forced test/generators/resource_generator_test.rb /^ def test_plural_names_can_be_forced$/;" f -test_property_with_block test/rails_info_test.rb /^ def test_property_with_block$/;" f class:InfoTest -test_property_with_block_swallows_exceptions_and_ignores_property test/rails_info_test.rb /^ def test_property_with_block_swallows_exceptions_and_ignores_property$/;" f class:InfoTest -test_property_with_string test/rails_info_test.rb /^ def test_property_with_string$/;" f class:InfoTest -test_prototype_and_test_unit_are_added_by_default test/generators/app_generator_test.rb /^ def test_prototype_and_test_unit_are_added_by_default$/;" f -test_puts_its_controllers_directory_on_autoload_path test/railties/shared_tests.rb /^ def test_puts_its_controllers_directory_on_autoload_path$/;" f class:RailtiesTest -test_puts_its_lib_directory_on_load_path test/railties/shared_tests.rb /^ def test_puts_its_lib_directory_on_load_path$/;" f class:RailtiesTest -test_puts_its_models_directory_on_autoload_path test/railties/shared_tests.rb /^ def test_puts_its_models_directory_on_autoload_path$/;" f class:RailtiesTest -test_rails_generators_does_not_show_active_record_hooks test/generators_test.rb /^ def test_rails_generators_does_not_show_active_record_hooks$/;" f class:GeneratorsTest -test_rails_generators_help_does_not_include_app_nor_plugin_new test/generators_test.rb /^ def test_rails_generators_help_does_not_include_app_nor_plugin_new$/;" f class:GeneratorsTest -test_rails_generators_help_with_builtin_information test/generators_test.rb /^ def test_rails_generators_help_with_builtin_information$/;" f class:GeneratorsTest -test_rails_generators_with_others_information test/generators_test.rb /^ def test_rails_generators_with_others_information$/;" f class:GeneratorsTest -test_rails_root_templates test/generators_test.rb /^ def test_rails_root_templates$/;" f class:GeneratorsTest -test_rails_update_generates_correct_session_key test/generators/app_generator_test.rb /^ def test_rails_update_generates_correct_session_key$/;" f class:AppGeneratorTest -test_rake_routes_output_strips_anchors_from_http_verbs test/application/rake_test.rb /^ def test_rake_routes_output_strips_anchors_from_http_verbs$/;" f class:ApplicationTests -test_rake_should_run_rake_command_with_development_env test/generators/actions_test.rb /^ def test_rake_should_run_rake_command_with_development_env$/;" f class:ActionsTest -test_rake_tasks_lib_tasks_are_loaded test/railties/shared_tests.rb /^ def test_rake_tasks_lib_tasks_are_loaded$/;" f class:RailtiesTest -test_rake_with_env_option_should_run_rake_command_in_env test/generators/actions_test.rb /^ def test_rake_with_env_option_should_run_rake_command_in_env$/;" f class:ActionsTest -test_rake_with_sudo_option_should_run_rake_command_with_sudo test/generators/actions_test.rb /^ def test_rake_with_sudo_option_should_run_rake_command_with_sudo$/;" f class:ActionsTest -test_rakefile_should_write_date_to_file_in_lib_tasks test/generators/actions_test.rb /^ def test_rakefile_should_write_date_to_file_in_lib_tasks$/;" f class:ActionsTest -test_readme test/generators/actions_test.rb /^ def test_readme$/;" f class:ActionsTest -test_reference_is_false test/generators/generated_attribute_test.rb /^ def test_reference_is_false$/;" f class:GeneratedAttributeTest -test_reference_is_true test/generators/generated_attribute_test.rb /^ def test_reference_is_true$/;" f class:GeneratedAttributeTest -test_reload_should_fire_preparation_and_cleanup_callbacks test/application/console_test.rb /^ def test_reload_should_fire_preparation_and_cleanup_callbacks$/;" f class:ConsoleTest -test_reload_should_reload_constants test/application/console_test.rb /^ def test_reload_should_reload_constants$/;" f class:ConsoleTest -test_remove_migration_with_attributes test/generators/migration_generator_test.rb /^ def test_remove_migration_with_attributes$/;" f -test_resource_controller_with_actions test/generators/resource_generator_test.rb /^ def test_resource_controller_with_actions$/;" f class:ResourceGeneratorTest -test_resource_controller_with_pluralized_class_name test/generators/resource_generator_test.rb /^ def test_resource_controller_with_pluralized_class_name$/;" f class:ResourceGeneratorTest -test_resource_routes_are_added test/generators/resource_generator_test.rb /^ def test_resource_routes_are_added$/;" f -test_route_is_removed_on_revoke test/generators/resource_generator_test.rb /^ def test_route_is_removed_on_revoke$/;" f -test_route_should_add_data_to_the_routes_block_in_config_routes test/generators/actions_test.rb /^ def test_route_should_add_data_to_the_routes_block_in_config_routes$/;" f class:ActionsTest -test_routes_are_added_to_router test/railties/shared_tests.rb /^ def test_routes_are_added_to_router$/;" f class:RailtiesTest -test_routes_in_plugins_have_lower_priority_than_application_ones test/railties/shared_tests.rb /^ def test_routes_in_plugins_have_lower_priority_than_application_ones$/;" f class:RailtiesTest -test_routes_should_not_be_namespaced test/generators/namespaced_generators_test.rb /^ def test_routes_should_not_be_namespaced$/;" f class:NamespacedControllerGeneratorTest -test_scaffold_generator_on_revoke_does_not_mutilate_legacy_map_parameter test/generators/scaffold_generator_test.rb /^ def test_scaffold_generator_on_revoke_does_not_mutilate_legacy_map_parameter$/;" f -test_scaffold_generator_outputs_error_message_on_missing_attribute_type test/generators/scaffold_generator_test.rb /^ def test_scaffold_generator_outputs_error_message_on_missing_attribute_type$/;" f -test_scaffold_on_invoke test/generators/namespaced_generators_test.rb /^ def test_scaffold_on_invoke$/;" f class:NamespacedScaffoldGeneratorTest -test_scaffold_on_invoke test/generators/scaffold_generator_test.rb /^ def test_scaffold_on_invoke$/;" f class:ScaffoldGeneratorTest -test_scaffold_on_revoke test/generators/namespaced_generators_test.rb /^ def test_scaffold_on_revoke$/;" f -test_scaffold_on_revoke test/generators/scaffold_generator_test.rb /^ def test_scaffold_on_revoke$/;" f -test_scaffold_plural_names test/generators/named_base_test.rb /^ def test_scaffold_plural_names$/;" f class:NamedBaseTest -test_scaffold_plural_names_as_ruby test/generators/named_base_test.rb /^ def test_scaffold_plural_names_as_ruby$/;" f class:NamedBaseTest -test_scaffold_with_namespace_on_invoke test/generators/namespaced_generators_test.rb /^ def test_scaffold_with_namespace_on_invoke$/;" f -test_scaffold_with_namespace_on_invoke test/generators/scaffold_generator_test.rb /^ def test_scaffold_with_namespace_on_invoke$/;" f -test_scaffold_with_namespace_on_revoke test/generators/namespaced_generators_test.rb /^ def test_scaffold_with_namespace_on_revoke$/;" f -test_scaffold_with_namespace_on_revoke test/generators/scaffold_generator_test.rb /^ def test_scaffold_with_namespace_on_revoke$/;" f -test_session_migration_with_custom_table_name test/generators/session_migration_generator_test.rb /^ def test_session_migration_with_custom_table_name$/;" f class:SessionMigrationGeneratorTest -test_session_migration_with_default_name test/generators/session_migration_generator_test.rb /^ def test_session_migration_with_default_name$/;" f class:SessionMigrationGeneratorTest -test_session_migration_with_given_name test/generators/session_migration_generator_test.rb /^ def test_session_migration_with_given_name$/;" f class:SessionMigrationGeneratorTest -test_shebang_is_added_to_rails_file test/generators/shared_generator_tests.rb /^ def test_shebang_is_added_to_rails_file$/;" f class:SharedGeneratorTests -test_shebang_when_is_the_same_as_default_use_env test/generators/shared_generator_tests.rb /^ def test_shebang_when_is_the_same_as_default_use_env$/;" f class:SharedGeneratorTests -test_should_create_empty_migrations_if_name_not_start_with_add_or_remove test/generators/migration_generator_test.rb /^ def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove$/;" f -test_should_give_higher_preference_to_rails_generators test/generators_test.rb /^ def test_should_give_higher_preference_to_rails_generators$/;" f class:GeneratorsTest -test_should_include_runner_in_shebang_line_in_help test/application/runner_test.rb /^ def test_should_include_runner_in_shebang_line_in_help$/;" f class:ApplicationTests.RunnerTest -test_should_run_file test/application/runner_test.rb /^ def test_should_run_file$/;" f class:ApplicationTests.RunnerTest -test_should_run_ruby_statement test/application/runner_test.rb /^ def test_should_run_ruby_statement$/;" f class:ApplicationTests.RunnerTest -test_should_set_dollar_0_to_file test/application/runner_test.rb /^ def test_should_set_dollar_0_to_file$/;" f class:ApplicationTests.RunnerTest -test_should_set_dollar_program_name_to_file test/application/runner_test.rb /^ def test_should_set_dollar_program_name_to_file$/;" f class:ApplicationTests.RunnerTest -test_simple_invoke test/generators_test.rb /^ def test_simple_invoke$/;" f class:GeneratorsTest -test_skeleton_is_created test/generators/shared_generator_tests.rb /^ def test_skeleton_is_created$/;" f class:SharedGeneratorTests -test_skip_helper_if_required test/generators/scaffold_controller_generator_test.rb /^ def test_skip_helper_if_required$/;" f -test_skip_javascripts test/generators/plugin_new_generator_test.rb /^ def test_skip_javascripts$/;" f class:PluginNewGeneratorTest -test_skip_layout_if_required test/generators/scaffold_controller_generator_test.rb /^ def test_skip_layout_if_required$/;" f -test_skipping_gemspec test/generators/plugin_new_generator_test.rb /^ def test_skipping_gemspec$/;" f class:PluginNewGeneratorTest -test_skipping_javascripts_without_mountable_option test/generators/plugin_new_generator_test.rb /^ def test_skipping_javascripts_without_mountable_option$/;" f class:PluginNewGeneratorTest -test_skipping_namespace test/generators/namespaced_generators_test.rb /^ def test_skipping_namespace$/;" f class:NamespacedControllerGeneratorTest -test_source_paths_for_not_namespaced_generators test/generators_test.rb /^ def test_source_paths_for_not_namespaced_generators$/;" f -test_stylesheets_are_not_deleted_on_revoke test/generators/stylesheets_generator_test.rb /^ def test_stylesheets_are_not_deleted_on_revoke$/;" f class:StylesheetsGeneratorTest -test_template_engine_with_class_path test/generators/controller_generator_test.rb /^ def test_template_engine_with_class_path$/;" f class:ControllerGeneratorTest -test_template_from_dir_pwd test/generators/app_generator_test.rb /^ def test_template_from_dir_pwd$/;" f -test_template_from_dir_pwd test/generators/plugin_new_generator_test.rb /^ def test_template_from_dir_pwd$/;" f class:PluginNewGeneratorTest -test_template_is_executed_when_supplied test/generators/shared_generator_tests.rb /^ def test_template_is_executed_when_supplied$/;" f class:SharedGeneratorTests -test_template_is_executed_when_supplied_an_https_path test/generators/shared_generator_tests.rb /^ def test_template_is_executed_when_supplied_an_https_path$/;" f class:SharedGeneratorTests -test_template_raises_an_error_with_invalid_path test/generators/shared_generator_tests.rb /^ def test_template_raises_an_error_with_invalid_path$/;" f class:SharedGeneratorTests -test_test.rb test/application/test_test.rb 1;" F -test_test_unit_is_removed_from_frameworks_if_skip_test_unit_is_given test/generators/app_generator_test.rb /^ def test_test_unit_is_removed_from_frameworks_if_skip_test_unit_is_given$/;" f -test_test_unit_is_skipped_if_required test/generators/shared_generator_tests.rb /^ def test_test_unit_is_skipped_if_required$/;" f class:SharedGeneratorTests -test_truth test/application/test_test.rb /^ def test_truth$/;" f class:ApplicationTests.FooTest -test_truth test/application/test_test.rb /^ def test_truth$/;" f class:ApplicationTests.TestTest.FooTest -test_unit.rb lib/rails/generators/test_unit.rb 1;" F -test_usage_read_from_file test/generators/app_generator_test.rb /^ def test_usage_read_from_file$/;" f -test_vendor_should_write_data_to_file_in_vendor test/generators/actions_test.rb /^ def test_vendor_should_write_data_to_file_in_vendor$/;" f class:ActionsTest -test_views_are_generated test/generators/scaffold_controller_generator_test.rb /^ def test_views_are_generated$/;" f -tests lib/rails/generators/test_case.rb /^ def self.tests(klass)$/;" F class:Rails.Generators.TestCase -textile guides/rails_guides/generator.rb /^ def textile(body, lite_mode=false)$/;" f class:RailsGuides.Generator -textile_extensions.rb guides/rails_guides/textile_extensions.rb 1;" F -threadsafe! lib/rails/application/configuration.rb /^ def threadsafe!$/;" f class:Rails.Application.Configuration -tip guides/rails_guides/textile_extensions.rb /^ def tip(body)$/;" f class:RailsGuides.TextileExtensions -title_to_idx guides/rails_guides/indexer.rb /^ def title_to_idx(title)$/;" f class:RailsGuides.Indexer -tmp lib/rails/generators/rails/app/app_generator.rb /^ def tmp$/;" f -tmp_path test/isolation/abstract_unit.rb /^ def tmp_path(*args)$/;" f class:TestHelpers.Paths -toHTML lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function toHTML(object) {$/;" f -toHTML tmp/app/public/javascripts/prototype.js /^ function toHTML(object) {$/;" f -toHTML tmp/app_template/public/javascripts/prototype.js /^ function toHTML(object) {$/;" f -toJSON lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function toJSON(value) {$/;" f -toJSON tmp/app/public/javascripts/prototype.js /^ function toJSON(value) {$/;" f -toJSON tmp/app_template/public/javascripts/prototype.js /^ function toJSON(value) {$/;" f -toQueryString lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function toQueryString(object) {$/;" f -toQueryString tmp/app/public/javascripts/prototype.js /^ function toQueryString(object) {$/;" f -toQueryString tmp/app_template/public/javascripts/prototype.js /^ function toQueryString(object) {$/;" f -to_html lib/rails/info.rb /^ def to_html$/;" f class:Rails -to_param test/railties/engine_test.rb /^ def to_param$/;" f class:Bukkits.Post -to_param test/railties/mounted_engine_test.rb /^ def to_param$/;" f class:ApplicationTests.ApplicationRoutingTest.Blog.Post -to_prepare lib/rails/railtie/configuration.rb /^ def to_prepare(&blk)$/;" f class:Rails.Railtie.Configuration -to_prepare_blocks lib/rails/railtie/configuration.rb /^ def to_prepare_blocks$/;" f class:Rails.Railtie.Configuration -to_s lib/rails/code_statistics.rb /^ def to_s$/;" f class:CodeStatistics -to_s lib/rails/commands/plugin.rb /^ def to_s$/;" f class:Plugin -to_s lib/rails/info.rb /^ def to_s$/;" f class:Rails -to_s lib/rails/source_annotation_extractor.rb /^ def to_s(options={})$/;" f class:SourceAnnotationExtractor.Annotation -tsort_each_child lib/rails/initializable.rb /^ def tsort_each_child(initializer, &block)$/;" f class:Rails.Initializable.Collection -tweak_builder.rb test/fixtures/lib/app_builders/tweak_builder.rb 1;" F -tweak_builder.rb test/fixtures/lib/plugin_builders/tweak_builder.rb 1;" F -two test/initializable_test.rb /^ def two$/;" f class:InitializableTests.OverriddenInitializer.MoreInitializers -uncountable? lib/rails/generators/named_base.rb /^ def uncountable?$/;" f class:Rails.Generators -uninstall lib/rails/commands/plugin.rb /^ def uninstall$/;" f class:Plugin -uninstall.rb lib/rails/generators/rails/plugin/templates/uninstall.rb 1;" F -unit_test.rb lib/rails/generators/test_unit/model/templates/unit_test.rb 1;" F -unit_test.rb lib/rails/generators/test_unit/observer/templates/unit_test.rb 1;" F -update lib/rails/generators/rails/scaffold_controller/templates/controller.rb /^ def update$/;" f -update.rb lib/rails/commands/update.rb 1;" F -update_attributes lib/rails/generators/active_model.rb /^ def update_attributes(params=nil)$/;" f class:Rails.Generators.ActiveModel -url_for_engine_route test/railties/mounted_engine_test.rb /^ def url_for_engine_route$/;" f class:ApplicationTests.ApplicationRoutingTest.ApplicationGeneratingController -url_generation_test.rb test/application/url_generation_test.rb 1;" F -use lib/rails/configuration.rb /^ def use(*args, &block)$/;" f class:Rails.Configuration.MiddlewareStackProxy -use_checkout? lib/rails/commands/plugin.rb /^ def use_checkout?$/;" f class:RailsEnvironment -use_externals? lib/rails/commands/plugin.rb /^ def use_externals?$/;" f class:RailsEnvironment -use_frameworks test/isolation/abstract_unit.rb /^ def use_frameworks(arr)$/;" f -use_svn? lib/rails/commands/plugin.rb /^ def use_svn?$/;" f class:RailsEnvironment -valid_const? lib/rails/generators/rails/app/app_generator.rb /^ def valid_const?$/;" f class:Generators.AppGenerator -valid_const? lib/rails/generators/rails/plugin_new/plugin_new_generator.rb /^ def valid_const?$/;" f class:Generators.PluginNewGenerator -validate guides/w3c_validator.rb /^ def validate$/;" f class:RailsGuides.Validator -value_for lib/rails/info.rb /^ def value_for(property_name)$/;" f class:Rails.Info -values lib/rails/generators/rails/app/templates/public/javascripts/prototype.js /^ function values(object) {$/;" f -values tmp/app/public/javascripts/prototype.js /^ function values(object) {$/;" f -values tmp/app_template/public/javascripts/prototype.js /^ function values(object) {$/;" f -var.Effect._elementDoesNotExistError lib/rails/generators/rails/app/templates/public/javascripts/effects.js /^var Effect = {$/;" p -var.Effect._elementDoesNotExistError tmp/app/public/javascripts/effects.js /^var Effect = {$/;" p -var.Effect._elementDoesNotExistError tmp/app_template/public/javascripts/effects.js /^var Effect = {$/;" p -vendor lib/rails/generators/actions.rb /^ def vendor(filename, data=nil, &block)$/;" f class:Rails.Generators -vendor_plugins lib/rails/generators/rails/app/app_generator.rb /^ def vendor_plugins$/;" f -version lib/rails.rb /^ def version$/;" f class:Rails -version.rb lib/rails/version.rb 1;" F -w3c_validator.rb guides/w3c_validator.rb 1;" F -wait test/application/initializers/notifications_test.rb /^ def wait$/;" f class:ApplicationTests.NotificationsTest -warn_about_broken_links guides/rails_guides/generator.rb /^ def warn_about_broken_links(html)$/;" f class:RailsGuides -with_bare_config test/application/generators_test.rb /^ def with_bare_config$/;" f class:ApplicationTests.GeneratorsTest -with_config test/application/generators_test.rb /^ def with_config$/;" f class:ApplicationTests.GeneratorsTest -with_workaround_for_notextile guides/rails_guides/generator.rb /^ def with_workaround_for_notextile(body)$/;" f class:RailsGuides.Generator -wrap_with_namespace lib/rails/generators/named_base.rb /^ def wrap_with_namespace(content)$/;" f class:Rails.Generators.NamedBase -write test/isolation/abstract_unit.rb /^ def write(file, string)$/;" f class:Bukkit -wrong_generator.rb test/fixtures/lib/generators/wrong_generator.rb 1;" F